1
0
Fork 0
peertube/server/typings/models/account/account.ts

78 lines
2.2 KiB
TypeScript
Raw Normal View History

2019-08-15 05:53:26 -04:00
import { AccountModel } from '../../../models/account/account'
import {
MActor,
MActorAccountChannelId,
MActorAPI,
MActorAudience,
MActorDefault,
2019-08-20 07:52:49 -04:00
MActorDefaultLight,
MActorId,
2019-08-15 05:53:26 -04:00
MActorServer,
MActorSummary,
MActorUrl
} from './actor'
import { PickWith } from '../../utils'
import { MAccountBlocklistId } from './account-blocklist'
import { MChannelDefault } from '@server/typings/models'
2019-08-20 07:52:49 -04:00
type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
// ############################################################################
2019-08-15 05:53:26 -04:00
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
'VideoComments' | 'BlockedAccounts'>
2019-08-20 07:52:49 -04:00
// ############################################################################
// Only some attributes
export type MAccountId = Pick<MAccount, 'id'>
export type MAccountUserId = Pick<MAccount, 'userId'>
// Only some Actor attributes
export type MAccountUrl = Use<'Actor', MActorUrl>
export type MAccountAudience = Use<'Actor', MActorAudience>
export type MAccountIdActor = MAccountId &
Use<'Actor', MActorAccountChannelId>
export type MAccountIdActorId = MAccountId &
Use<'Actor', MActorId>
// ############################################################################
2019-08-15 05:53:26 -04:00
// Default scope
export type MAccountDefault = MAccount &
2019-08-20 07:52:49 -04:00
Use<'Actor', MActorDefault>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// Default with default association scopes
export type MAccountDefaultChannelDefault = MAccount &
Use<'Actor', MActorDefault> &
Use<'VideoChannels', MChannelDefault[]>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// We don't need some actors attributes
2019-08-15 05:53:26 -04:00
export type MAccountLight = MAccount &
2019-08-20 07:52:49 -04:00
Use<'Actor', MActorDefaultLight>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// ############################################################################
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// Full actor
2019-08-15 05:53:26 -04:00
export type MAccountActor = MAccount &
2019-08-20 07:52:49 -04:00
Use<'Actor', MActor>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// Full actor with server
export type MAccountServer = MAccount &
Use<'Actor', MActorServer>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// ############################################################################
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
// For API
export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
Use<'Actor', MActorSummary>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
export type MAccountSummaryBlocks = MAccountSummary &
Use<'BlockedAccounts', MAccountBlocklistId[]>
2019-08-15 05:53:26 -04:00
2019-08-20 07:52:49 -04:00
export type MAccountAPI = MAccount &
Use<'Actor', MActorAPI>