aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/user/user.ts
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/user.ts
parent96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff)
downloadPeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.gz
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.zst
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.zip
Cleanup model types
Diffstat (limited to 'server/typings/models/user/user.ts')
-rw-r--r--server/typings/models/user/user.ts49
1 files changed, 34 insertions, 15 deletions
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>