PeerTube/server/typings/models/account/account.ts

96 lines
2.8 KiB
TypeScript
Raw Normal View History

2019-08-15 04:53:26 -05:00
import { AccountModel } from '../../../models/account/account'
import {
MActor,
2019-08-21 07:31:57 -05:00
MActorAP,
2019-08-15 04:53:26 -05:00
MActorAPI,
MActorAudience,
MActorDefault,
2019-08-20 06:52:49 -05:00
MActorDefaultLight,
2019-08-21 01:57:00 -05:00
MActorFormattable,
2019-08-20 06:52:49 -05:00
MActorId,
2019-08-15 04:53:26 -05:00
MActorServer,
MActorSummary,
2019-08-20 12:05:31 -05:00
MActorSummaryFormattable,
2019-08-21 01:57:00 -05:00
MActorUrl
2019-08-15 04:53:26 -05:00
} from './actor'
2019-08-20 12:05:31 -05:00
import { FunctionProperties, PickWith } from '../../utils'
2019-08-15 04:53:26 -05:00
import { MAccountBlocklistId } from './account-blocklist'
import { MChannelDefault } from '@server/typings/models'
2019-08-20 06:52:49 -05:00
type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
// ############################################################################
2019-08-15 04:53:26 -05:00
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
'VideoComments' | 'BlockedAccounts'>
2019-08-20 06:52:49 -05: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 &
2019-08-21 01:57:00 -05:00
Use<'Actor', MActor>
2019-08-20 06:52:49 -05:00
export type MAccountIdActorId = MAccountId &
Use<'Actor', MActorId>
// ############################################################################
2019-08-15 04:53:26 -05:00
// Default scope
export type MAccountDefault = MAccount &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorDefault>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// Default with default association scopes
export type MAccountDefaultChannelDefault = MAccount &
Use<'Actor', MActorDefault> &
Use<'VideoChannels', MChannelDefault[]>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// We don't need some actors attributes
2019-08-15 04:53:26 -05:00
export type MAccountLight = MAccount &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorDefaultLight>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// ############################################################################
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// Full actor
2019-08-15 04:53:26 -05:00
export type MAccountActor = MAccount &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActor>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// Full actor with server
export type MAccountServer = MAccount &
Use<'Actor', MActorServer>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// ############################################################################
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// For API
2019-08-20 12:05:31 -05:00
export type MAccountSummary = FunctionProperties<MAccount> &
Pick<MAccount, 'id' | 'name'> &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorSummary>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MAccountSummaryBlocks = MAccountSummary &
Use<'BlockedAccounts', MAccountBlocklistId[]>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MAccountAPI = MAccount &
Use<'Actor', MActorAPI>
2019-08-20 12:05:31 -05:00
// ############################################################################
// Format for API or AP object
export type MAccountSummaryFormattable = FunctionProperties<MAccount> &
Pick<MAccount, 'id' | 'name'> &
Use<'Actor', MActorSummaryFormattable>
export type MAccountFormattable = FunctionProperties<MAccount> &
Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
Use<'Actor', MActorFormattable>
2019-08-21 07:31:57 -05:00
export type MAccountAP = Pick<MAccount, 'name' | 'description'> &
Use<'Actor', MActorAP>