1 import { UserModel } from '../../../models/account/user'
2 import { PickWith, PickWithOpt } from '../../utils'
6 MAccountDefaultChannelDefault,
12 import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
13 import { AccountModel } from '@server/models/account/account'
14 import { MChannelFormattable } from '../video/video-channels'
15 import { MVideoPlaylist } from '@server/typings/models'
17 type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
19 // ############################################################################
21 export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
23 // ############################################################################
25 export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
26 export type MUserId = Pick<UserModel, 'id'>
28 // ############################################################################
32 export type MUserAccountId =
34 Use<'Account', MAccountId>
36 export type MUserAccountUrl =
38 Use<'Account', MAccountUrl & MAccountIdActorId>
40 export type MUserAccount =
42 Use<'Account', MAccount>
44 export type MUserAccountDefault =
46 Use<'Account', MAccountDefault>
50 export type MUserNotifSettingChannelDefault =
52 Use<'NotificationSetting', MNotificationSetting> &
53 Use<'Account', MAccountDefaultChannelDefault>
55 // With notification settings
57 export type MUserWithNotificationSetting =
59 Use<'NotificationSetting', MNotificationSetting>
61 export type MUserNotifSettingAccount =
63 Use<'NotificationSetting', MNotificationSetting> &
64 Use<'Account', MAccount>
68 export type MUserDefault =
70 Use<'NotificationSetting', MNotificationSetting> &
71 Use<'Account', MAccountDefault>
73 // ############################################################################
75 // Format for API or AP object
77 type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
78 type MAccountWithChannelsAndSpecialPlaylists =
79 MAccountWithChannels &
80 PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
82 export type MUserFormattable =
84 Use<'Account', MAccountWithChannels> &
85 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
87 export type MMyUserFormattable =
89 Use<'Account', MAccountWithChannelsAndSpecialPlaylists>