diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-20 13:52:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-20 14:53:42 +0200 |
commit | 0283eaac2a8e73006c66df3cf5bb9012e37450e5 (patch) | |
tree | 1fb73aeef57f984a77f47828ade23c6365ce8eb0 /server/typings/models/user/user.ts | |
parent | 96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff) | |
download | PeerTube-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.ts | 49 |
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' | |||
3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' | 3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' |
4 | import { MNotificationSetting } from './user-notification-setting' | 4 | import { MNotificationSetting } from './user-notification-setting' |
5 | 5 | ||
6 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
6 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | 10 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> |
7 | 11 | ||
12 | // ############################################################################ | ||
13 | |||
8 | export type MUserId = Pick<UserModel, 'id'> | 14 | export type MUserId = Pick<UserModel, 'id'> |
9 | 15 | ||
10 | export type MUserWithNotificationSetting = MUser & | 16 | // ############################################################################ |
11 | PickWith<UserModel, 'NotificationSetting', MNotificationSetting> | ||
12 | 17 | ||
13 | export type MUserAccountDefault = MUser & | 18 | // With account |
14 | PickWith<UserModel, 'Account', MAccountDefault> | 19 | |
20 | export type MUserAccountId = MUser & | ||
21 | Use<'Account', MAccountId> | ||
22 | |||
23 | export type MUserAccountUrl = MUser & | ||
24 | Use<'Account', MAccountUrl & MAccountIdActorId> | ||
15 | 25 | ||
16 | export type MUserAccount = MUser & | 26 | export type MUserAccount = MUser & |
17 | PickWith<UserModel, 'Account', MAccount> | 27 | Use<'Account', MAccount> |
18 | 28 | ||
19 | export type MUserAccountId = MUser & | 29 | export type MUserAccountDefault = MUser & |
20 | PickWith<UserModel, 'Account', MAccountId> | 30 | Use<'Account', MAccountDefault> |
21 | 31 | ||
22 | export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount | 32 | // With channel |
23 | 33 | ||
24 | export type MUserDefault = MUser & | 34 | export type MUserNotifSettingChannelDefault = MUser & |
25 | MUserWithNotificationSetting & | 35 | Use<'NotificationSetting', MNotificationSetting> & |
26 | MUserAccountDefault | 36 | Use<'Account', MAccountDefaultChannelDefault> |
27 | 37 | ||
28 | export type MUserChannel = MUserWithNotificationSetting & | 38 | // With notification settings |
29 | PickWith<UserModel, 'Account', MAccountDefaultChannelDefault> | ||
30 | 39 | ||
31 | export type MUserAccountUrl = MUser & | 40 | export type MUserWithNotificationSetting = MUser & |
32 | PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId> | 41 | Use<'NotificationSetting', MNotificationSetting> |
42 | |||
43 | export type MUserNotifSettingAccount = MUser & | ||
44 | Use<'NotificationSetting', MNotificationSetting> & | ||
45 | Use<'Account', MAccount> | ||
46 | |||
47 | // Default scope | ||
48 | |||
49 | export type MUserDefault = MUser & | ||
50 | Use<'NotificationSetting', MNotificationSetting> & | ||
51 | Use<'Account', MAccountDefault> | ||