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

110 lines
2.9 KiB
TypeScript
Raw Normal View History

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