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