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 = MUser &
33 Use<'Account', MAccountId>
35 export type MUserAccountUrl = MUser &
36 Use<'Account', MAccountUrl & MAccountIdActorId>
38 export type MUserAccount = MUser &
39 Use<'Account', MAccount>
41 export type MUserAccountDefault = MUser &
42 Use<'Account', MAccountDefault>
46 export type MUserNotifSettingChannelDefault = MUser &
47 Use<'NotificationSetting', MNotificationSetting> &
48 Use<'Account', MAccountDefaultChannelDefault>
50 // With notification settings
52 export type MUserWithNotificationSetting = MUser &
53 Use<'NotificationSetting', MNotificationSetting>
55 export type MUserNotifSettingAccount = MUser &
56 Use<'NotificationSetting', MNotificationSetting> &
57 Use<'Account', MAccount>
61 export type MUserDefault = MUser &
62 Use<'NotificationSetting', MNotificationSetting> &
63 Use<'Account', MAccountDefault>
65 // ############################################################################
67 // Format for API or AP object
69 type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
70 type MAccountWithChannelsAndSpecialPlaylists = MAccountWithChannels &
71 PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
73 export type MUserFormattable = MUserQuotaUsed &
74 Use<'Account', MAccountWithChannels> &
75 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
77 export type MMyUserFormattable = MUserFormattable &
78 Use<'Account', MAccountWithChannelsAndSpecialPlaylists>