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