aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/user
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-20 13:52:49 +0200
committerChocobozzz <me@florianbigard.com>2019-08-20 14:53:42 +0200
commit0283eaac2a8e73006c66df3cf5bb9012e37450e5 (patch)
tree1fb73aeef57f984a77f47828ade23c6365ce8eb0 /server/typings/models/user
parent96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff)
downloadPeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.gz
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.zst
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.zip
Cleanup model types
Diffstat (limited to 'server/typings/models/user')
-rw-r--r--server/typings/models/user/index.d.ts1
-rw-r--r--server/typings/models/user/user-notification.ts26
-rw-r--r--server/typings/models/user/user.ts49
3 files changed, 52 insertions, 24 deletions
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts
index e3353d0b1..6657b2128 100644
--- a/server/typings/models/user/index.d.ts
+++ b/server/typings/models/user/index.d.ts
@@ -1,3 +1,4 @@
1export * from './user' 1export * from './user'
2export * from './user-notification' 2export * from './user-notification'
3export * from './user-notification-setting'
3export * from './user-video-history' 4export * from './user-video-history'
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts
index b872c5dc5..f9daf5eb2 100644
--- a/server/typings/models/user/user-notification.ts
+++ b/server/typings/models/user/user-notification.ts
@@ -12,6 +12,10 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
12import { VideoImportModel } from '../../../models/video/video-import' 12import { VideoImportModel } from '../../../models/video/video-import'
13import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 13import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
14 14
15type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
16
17// ############################################################################
18
15export namespace UserNotificationIncludes { 19export namespace UserNotificationIncludes {
16 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> 20 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
17 export type VideoIncludeChannel = VideoInclude & 21 export type VideoIncludeChannel = VideoInclude &
@@ -56,14 +60,18 @@ export namespace UserNotificationIncludes {
56 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> 60 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
57} 61}
58 62
59export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | 63// ############################################################################
64
65export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
60 'VideoImport' | 'Account' | 'ActorFollow'> 66 'VideoImport' | 'Account' | 'ActorFollow'>
61 67
62export type UserNotificationModelForApi = UserNotificationModelOnly & 68// ############################################################################
63 PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> & 69
64 PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> & 70export type UserNotificationModelForApi = MUserNotification &
65 PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & 71 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
66 PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & 72 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
67 PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> & 73 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
68 PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & 74 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
69 PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor> 75 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
76 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
77 Use<'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts
index b91eed8d9..466cde33b 100644
--- a/server/typings/models/user/user.ts
+++ b/server/typings/models/user/user.ts
@@ -3,30 +3,49 @@ import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' 3import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
4import { MNotificationSetting } from './user-notification-setting' 4import { MNotificationSetting } from './user-notification-setting'
5 5
6type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
7
8// ############################################################################
9
6export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> 10export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
7 11
12// ############################################################################
13
8export type MUserId = Pick<UserModel, 'id'> 14export type MUserId = Pick<UserModel, 'id'>
9 15
10export type MUserWithNotificationSetting = MUser & 16// ############################################################################
11 PickWith<UserModel, 'NotificationSetting', MNotificationSetting>
12 17
13export type MUserAccountDefault = MUser & 18// With account
14 PickWith<UserModel, 'Account', MAccountDefault> 19
20export type MUserAccountId = MUser &
21 Use<'Account', MAccountId>
22
23export type MUserAccountUrl = MUser &
24 Use<'Account', MAccountUrl & MAccountIdActorId>
15 25
16export type MUserAccount = MUser & 26export type MUserAccount = MUser &
17 PickWith<UserModel, 'Account', MAccount> 27 Use<'Account', MAccount>
18 28
19export type MUserAccountId = MUser & 29export type MUserAccountDefault = MUser &
20 PickWith<UserModel, 'Account', MAccountId> 30 Use<'Account', MAccountDefault>
21 31
22export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount 32// With channel
23 33
24export type MUserDefault = MUser & 34export type MUserNotifSettingChannelDefault = MUser &
25 MUserWithNotificationSetting & 35 Use<'NotificationSetting', MNotificationSetting> &
26 MUserAccountDefault 36 Use<'Account', MAccountDefaultChannelDefault>
27 37
28export type MUserChannel = MUserWithNotificationSetting & 38// With notification settings
29 PickWith<UserModel, 'Account', MAccountDefaultChannelDefault>
30 39
31export type MUserAccountUrl = MUser & 40export type MUserWithNotificationSetting = MUser &
32 PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId> 41 Use<'NotificationSetting', MNotificationSetting>
42
43export type MUserNotifSettingAccount = MUser &
44 Use<'NotificationSetting', MNotificationSetting> &
45 Use<'Account', MAccount>
46
47// Default scope
48
49export type MUserDefault = MUser &
50 Use<'NotificationSetting', MNotificationSetting> &
51 Use<'Account', MAccountDefault>