]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { UserModel } from '../../../models/account/user' |
1ca9f7c3 C |
2 | import { PickWith, PickWithOpt } from '../../utils' |
3 | import { | |
4 | MAccount, | |
5 | MAccountDefault, | |
6 | MAccountDefaultChannelDefault, | |
7 | MAccountFormattable, | |
8 | MAccountId, | |
9 | MAccountIdActorId, | |
10 | MAccountUrl | |
11 | } from '../account' | |
12 | import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' | |
13 | import { AccountModel } from '@server/models/account/account' | |
d7a25329 | 14 | import { MChannelFormattable } from '../video/video-channels' |
ac0868bc | 15 | import { MVideoPlaylist } from '@server/typings/models' |
453e83ea | 16 | |
0283eaac C |
17 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> |
18 | ||
19 | // ############################################################################ | |
20 | ||
453e83ea C |
21 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> |
22 | ||
0283eaac C |
23 | // ############################################################################ |
24 | ||
1ca9f7c3 | 25 | export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number } |
453e83ea C |
26 | export type MUserId = Pick<UserModel, 'id'> |
27 | ||
0283eaac | 28 | // ############################################################################ |
453e83ea | 29 | |
0283eaac C |
30 | // With account |
31 | ||
32 | export type MUserAccountId = MUser & | |
33 | Use<'Account', MAccountId> | |
34 | ||
35 | export type MUserAccountUrl = MUser & | |
36 | Use<'Account', MAccountUrl & MAccountIdActorId> | |
453e83ea C |
37 | |
38 | export type MUserAccount = MUser & | |
0283eaac | 39 | Use<'Account', MAccount> |
453e83ea | 40 | |
0283eaac C |
41 | export type MUserAccountDefault = MUser & |
42 | Use<'Account', MAccountDefault> | |
453e83ea | 43 | |
0283eaac | 44 | // With channel |
453e83ea | 45 | |
0283eaac C |
46 | export type MUserNotifSettingChannelDefault = MUser & |
47 | Use<'NotificationSetting', MNotificationSetting> & | |
48 | Use<'Account', MAccountDefaultChannelDefault> | |
453e83ea | 49 | |
0283eaac | 50 | // With notification settings |
453e83ea | 51 | |
0283eaac C |
52 | export type MUserWithNotificationSetting = MUser & |
53 | Use<'NotificationSetting', MNotificationSetting> | |
54 | ||
55 | export type MUserNotifSettingAccount = MUser & | |
56 | Use<'NotificationSetting', MNotificationSetting> & | |
57 | Use<'Account', MAccount> | |
58 | ||
59 | // Default scope | |
60 | ||
61 | export type MUserDefault = MUser & | |
62 | Use<'NotificationSetting', MNotificationSetting> & | |
63 | Use<'Account', MAccountDefault> | |
1ca9f7c3 C |
64 | |
65 | // ############################################################################ | |
66 | ||
67 | // Format for API or AP object | |
68 | ||
ac0868bc C |
69 | type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]> |
70 | type MAccountWithChannelsAndSpecialPlaylists = MAccountWithChannels & | |
71 | PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]> | |
72 | ||
1ca9f7c3 | 73 | export type MUserFormattable = MUserQuotaUsed & |
ac0868bc | 74 | Use<'Account', MAccountWithChannels> & |
1ca9f7c3 | 75 | PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable> |
ac0868bc C |
76 | |
77 | export type MMyUserFormattable = MUserFormattable & | |
78 | Use<'Account', MAccountWithChannelsAndSpecialPlaylists> |