]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/user/user.ts
Cleanup model types
[github/Chocobozzz/PeerTube.git] / server / typings / models / user / user.ts
1 import { UserModel } from '../../../models/account/user'
2 import { PickWith } from '../../utils'
3 import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
4 import { MNotificationSetting } from './user-notification-setting'
5
6 type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
7
8 // ############################################################################
9
10 export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
11
12 // ############################################################################
13
14 export type MUserId = Pick<UserModel, 'id'>
15
16 // ############################################################################
17
18 // With account
19
20 export type MUserAccountId = MUser &
21 Use<'Account', MAccountId>
22
23 export type MUserAccountUrl = MUser &
24 Use<'Account', MAccountUrl & MAccountIdActorId>
25
26 export type MUserAccount = MUser &
27 Use<'Account', MAccount>
28
29 export type MUserAccountDefault = MUser &
30 Use<'Account', MAccountDefault>
31
32 // With channel
33
34 export type MUserNotifSettingChannelDefault = MUser &
35 Use<'NotificationSetting', MNotificationSetting> &
36 Use<'Account', MAccountDefaultChannelDefault>
37
38 // With notification settings
39
40 export type MUserWithNotificationSetting = MUser &
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>