]>
Commit | Line | Data |
---|---|---|
2cb03dc1 | 1 | import { AccountModel } from '@server/models/account/account' |
7d9ba5c0 | 2 | import { UserModel } from '@server/models/user/user' |
2cb03dc1 | 3 | import { MVideoPlaylist } from '@server/types/models' |
6b5f72be | 4 | import { PickWith, PickWithOpt } from '@shared/typescript-utils' |
1ca9f7c3 C |
5 | import { |
6 | MAccount, | |
7 | MAccountDefault, | |
8 | MAccountDefaultChannelDefault, | |
9 | MAccountFormattable, | |
10 | MAccountId, | |
11 | MAccountIdActorId, | |
12 | MAccountUrl | |
13 | } from '../account' | |
d7a25329 | 14 | import { MChannelFormattable } from '../video/video-channels' |
2cb03dc1 | 15 | import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' |
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 | ||
a1587156 C |
32 | export type MUserAccountId = |
33 | MUser & | |
0283eaac C |
34 | Use<'Account', MAccountId> |
35 | ||
a1587156 C |
36 | export type MUserAccountUrl = |
37 | MUser & | |
0283eaac | 38 | Use<'Account', MAccountUrl & MAccountIdActorId> |
453e83ea | 39 | |
a1587156 C |
40 | export type MUserAccount = |
41 | MUser & | |
0283eaac | 42 | Use<'Account', MAccount> |
453e83ea | 43 | |
a1587156 C |
44 | export type MUserAccountDefault = |
45 | MUser & | |
0283eaac | 46 | Use<'Account', MAccountDefault> |
453e83ea | 47 | |
0283eaac | 48 | // With channel |
453e83ea | 49 | |
a1587156 C |
50 | export type MUserNotifSettingChannelDefault = |
51 | MUser & | |
0283eaac C |
52 | Use<'NotificationSetting', MNotificationSetting> & |
53 | Use<'Account', MAccountDefaultChannelDefault> | |
453e83ea | 54 | |
0283eaac | 55 | // With notification settings |
453e83ea | 56 | |
a1587156 C |
57 | export type MUserWithNotificationSetting = |
58 | MUser & | |
0283eaac C |
59 | Use<'NotificationSetting', MNotificationSetting> |
60 | ||
a1587156 C |
61 | export type MUserNotifSettingAccount = |
62 | MUser & | |
0283eaac C |
63 | Use<'NotificationSetting', MNotificationSetting> & |
64 | Use<'Account', MAccount> | |
65 | ||
66 | // Default scope | |
67 | ||
a1587156 C |
68 | export type MUserDefault = |
69 | MUser & | |
0283eaac C |
70 | Use<'NotificationSetting', MNotificationSetting> & |
71 | Use<'Account', MAccountDefault> | |
1ca9f7c3 C |
72 | |
73 | // ############################################################################ | |
74 | ||
75 | // Format for API or AP object | |
76 | ||
ac0868bc | 77 | type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]> |
a1587156 C |
78 | type MAccountWithChannelsAndSpecialPlaylists = |
79 | MAccountWithChannels & | |
ac0868bc C |
80 | PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]> |
81 | ||
a1587156 C |
82 | export type MUserFormattable = |
83 | MUserQuotaUsed & | |
ac0868bc | 84 | Use<'Account', MAccountWithChannels> & |
1ca9f7c3 | 85 | PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable> |
ac0868bc | 86 | |
a1587156 C |
87 | export type MMyUserFormattable = |
88 | MUserFormattable & | |
ac0868bc | 89 | Use<'Account', MAccountWithChannelsAndSpecialPlaylists> |