PeerTube/server/typings/models/user/user.ts

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2019-08-15 11:53:26 +02:00
import { UserModel } from '../../../models/account/user'
import { PickWith } from '../../utils'
import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
import { MNotificationSetting } from './user-notification-setting'
2019-08-20 13:52:49 +02:00
type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MUserId = Pick<UserModel, 'id'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// With account
export type MUserAccountId = MUser &
Use<'Account', MAccountId>
export type MUserAccountUrl = MUser &
Use<'Account', MAccountUrl & MAccountIdActorId>
2019-08-15 11:53:26 +02:00
export type MUserAccount = MUser &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccount>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MUserAccountDefault = MUser &
Use<'Account', MAccountDefault>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// With channel
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MUserNotifSettingChannelDefault = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccountDefaultChannelDefault>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// With notification settings
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MUserWithNotificationSetting = MUser &
Use<'NotificationSetting', MNotificationSetting>
export type MUserNotifSettingAccount = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccount>
// Default scope
export type MUserDefault = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccountDefault>