2019-08-15 04:53:26 -05:00
|
|
|
import { UserModel } from '../../../models/account/user'
|
2019-08-20 12:05:31 -05:00
|
|
|
import { PickWith, PickWithOpt } from '../../utils'
|
|
|
|
import {
|
|
|
|
MAccount,
|
|
|
|
MAccountDefault,
|
|
|
|
MAccountDefaultChannelDefault,
|
|
|
|
MAccountFormattable,
|
|
|
|
MAccountId,
|
|
|
|
MAccountIdActorId,
|
|
|
|
MAccountUrl
|
|
|
|
} from '../account'
|
|
|
|
import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
|
|
|
|
import { AccountModel } from '@server/models/account/account'
|
2019-11-15 08:06:03 -06:00
|
|
|
import { MChannelFormattable } from '../video/video-channels'
|
2020-01-03 07:17:57 -06:00
|
|
|
import { MVideoPlaylist } from '@server/typings/models'
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
|
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-15 04:53:26 -05:00
|
|
|
export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
|
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-20 12:05:31 -05:00
|
|
|
export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
|
2019-08-15 04:53:26 -05:00
|
|
|
export type MUserId = Pick<UserModel, 'id'>
|
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
// ############################################################################
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
// With account
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserAccountId =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccountId>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserAccountUrl =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccountUrl & MAccountIdActorId>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserAccount =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccount>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserAccountDefault =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccountDefault>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
// With channel
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserNotifSettingChannelDefault =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccountDefaultChannelDefault>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2019-08-20 06:52:49 -05:00
|
|
|
// With notification settings
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserWithNotificationSetting =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'NotificationSetting', MNotificationSetting>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserNotifSettingAccount =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccount>
|
|
|
|
|
|
|
|
// Default scope
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserDefault =
|
|
|
|
MUser &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccountDefault>
|
2019-08-20 12:05:31 -05:00
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// Format for API or AP object
|
|
|
|
|
2020-01-03 07:17:57 -06:00
|
|
|
type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
|
2020-01-31 09:56:52 -06:00
|
|
|
type MAccountWithChannelsAndSpecialPlaylists =
|
|
|
|
MAccountWithChannels &
|
2020-01-03 07:17:57 -06:00
|
|
|
PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MUserFormattable =
|
|
|
|
MUserQuotaUsed &
|
2020-01-03 07:17:57 -06:00
|
|
|
Use<'Account', MAccountWithChannels> &
|
2019-08-20 12:05:31 -05:00
|
|
|
PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
|
2020-01-03 07:17:57 -06:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MMyUserFormattable =
|
|
|
|
MUserFormattable &
|
2020-01-03 07:17:57 -06:00
|
|
|
Use<'Account', MAccountWithChannelsAndSpecialPlaylists>
|