aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/user
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-15 11:53:26 +0200
committerChocobozzz <me@florianbigard.com>2019-08-19 17:26:35 +0200
commit453e83ea5d81d203ba34bc43cd5c2c750ba40568 (patch)
tree604e02f4343d13a4ba42e1fb7527ba6ab9111712 /server/typings/models/user
parent13176a07a95984a53cc59aec5217f2ce9806d1bc (diff)
downloadPeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.gz
PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.zst
PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.zip
Stronger model typings
Diffstat (limited to 'server/typings/models/user')
-rw-r--r--server/typings/models/user/index.d.ts3
-rw-r--r--server/typings/models/user/user-notification-setting.ts3
-rw-r--r--server/typings/models/user/user-notification.ts69
-rw-r--r--server/typings/models/user/user-video-history.ts5
-rw-r--r--server/typings/models/user/user.ts32
5 files changed, 112 insertions, 0 deletions
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts
new file mode 100644
index 000000000..e3353d0b1
--- /dev/null
+++ b/server/typings/models/user/index.d.ts
@@ -0,0 +1,3 @@
1export * from './user'
2export * from './user-notification'
3export * from './user-video-history'
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts
new file mode 100644
index 000000000..585d30a66
--- /dev/null
+++ b/server/typings/models/user/user-notification-setting.ts
@@ -0,0 +1,3 @@
1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'
2
3export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'>
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts
new file mode 100644
index 000000000..b872c5dc5
--- /dev/null
+++ b/server/typings/models/user/user-notification.ts
@@ -0,0 +1,69 @@
1import { UserNotificationModel } from '../../../models/account/user-notification'
2import { PickWith } from '../../utils'
3import { VideoModel } from '../../../models/video/video'
4import { ActorModel } from '../../../models/activitypub/actor'
5import { ServerModel } from '../../../models/server/server'
6import { AvatarModel } from '../../../models/avatar/avatar'
7import { VideoChannelModel } from '../../../models/video/video-channel'
8import { AccountModel } from '../../../models/account/account'
9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { VideoAbuseModel } from '../../../models/video/video-abuse'
11import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
12import { VideoImportModel } from '../../../models/video/video-import'
13import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
14
15export namespace UserNotificationIncludes {
16 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
17 export type VideoIncludeChannel = VideoInclude &
18 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
19
20 export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
21 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
22 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
23
24 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
25 export type VideoChannelIncludeActor = VideoChannelInclude &
26 PickWith<VideoChannelModel, 'Actor', ActorInclude>
27
28 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
29 export type AccountIncludeActor = AccountInclude &
30 PickWith<AccountModel, 'Actor', ActorInclude>
31
32 export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
33 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
34 PickWith<VideoCommentModel, 'Video', VideoInclude>
35
36 export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> &
37 PickWith<VideoAbuseModel, 'Video', VideoInclude>
38
39 export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> &
40 PickWith<VideoAbuseModel, 'Video', VideoInclude>
41
42 export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
43 PickWith<VideoImportModel, 'Video', VideoInclude>
44
45 export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
46 PickWith<ActorModel, 'Account', AccountInclude> &
47 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
48 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
49
50 export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> &
51 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
52 PickWith<ActorModel, 'Account', AccountInclude>
53
54 export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> &
55 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
56 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
57}
58
59export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
60 'VideoImport' | 'Account' | 'ActorFollow'>
61
62export type UserNotificationModelForApi = UserNotificationModelOnly &
63 PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> &
64 PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> &
65 PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
66 PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
67 PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> &
68 PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
69 PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts
new file mode 100644
index 000000000..62673ab1b
--- /dev/null
+++ b/server/typings/models/user/user-video-history.ts
@@ -0,0 +1,5 @@
1import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
2
3export type MUserVideoHistory = Omit<UserVideoHistoryModel, 'Video' | 'User'>
4
5export type MUserVideoHistoryTime = Pick<MUserVideoHistory, 'currentTime'>
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts
new file mode 100644
index 000000000..b91eed8d9
--- /dev/null
+++ b/server/typings/models/user/user.ts
@@ -0,0 +1,32 @@
1import { UserModel } from '../../../models/account/user'
2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
4import { MNotificationSetting } from './user-notification-setting'
5
6export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
7
8export type MUserId = Pick<UserModel, 'id'>
9
10export type MUserWithNotificationSetting = MUser &
11 PickWith<UserModel, 'NotificationSetting', MNotificationSetting>
12
13export type MUserAccountDefault = MUser &
14 PickWith<UserModel, 'Account', MAccountDefault>
15
16export type MUserAccount = MUser &
17 PickWith<UserModel, 'Account', MAccount>
18
19export type MUserAccountId = MUser &
20 PickWith<UserModel, 'Account', MAccountId>
21
22export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount
23
24export type MUserDefault = MUser &
25 MUserWithNotificationSetting &
26 MUserAccountDefault
27
28export type MUserChannel = MUserWithNotificationSetting &
29 PickWith<UserModel, 'Account', MAccountDefaultChannelDefault>
30
31export type MUserAccountUrl = MUser &
32 PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId>