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'
|
2019-11-15 15:06:03 +01:00
|
|
|
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
|
|
|
|
|
|
|
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
|
|
|
|
'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>
|
|
|
|
|
|
|
|
export type MAccountIdActor = MAccountId &
|
2019-08-21 08:57:00 +02:00
|
|
|
Use<'Actor', MActor>
|
2019-08-20 13:52:49 +02:00
|
|
|
|
|
|
|
export type MAccountIdActorId = MAccountId &
|
|
|
|
Use<'Actor', MActorId>
|
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
// Default scope
|
|
|
|
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
|
|
|
|
export type MAccountDefaultChannelDefault = MAccount &
|
|
|
|
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
|
2019-08-15 11:53:26 +02: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
|
2019-08-15 11:53:26 +02: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
|
|
|
|
export type MAccountServer = MAccount &
|
|
|
|
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
|
|
|
|
|
2019-08-20 19:05:31 +02:00
|
|
|
export type MAccountSummary = FunctionProperties<MAccount> &
|
|
|
|
Pick<MAccount, 'id' | 'name'> &
|
2019-08-20 13:52:49 +02:00
|
|
|
Use<'Actor', MActorSummary>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
export type MAccountSummaryBlocks = MAccountSummary &
|
|
|
|
Use<'BlockedAccounts', MAccountBlocklistId[]>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
export type MAccountAPI = MAccount &
|
|
|
|
Use<'Actor', MActorAPI>
|
2019-08-20 19:05:31 +02: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 14:31:57 +02:00
|
|
|
|
|
|
|
export type MAccountAP = Pick<MAccount, 'name' | 'description'> &
|
|
|
|
Use<'Actor', MActorAP>
|