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

122 lines
4.4 KiB
TypeScript
Raw Normal View History

2019-08-15 04:53:26 -05:00
import { ActorModel } from '../../../models/activitypub/actor'
2019-08-21 07:31:57 -05:00
import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2019-08-20 06:52:49 -05:00
import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
2019-08-20 12:05:31 -05:00
import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
import { MAvatar, MAvatarFormattable } from './avatar'
2019-08-20 06:52:49 -05:00
import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
// ############################################################################
2019-08-15 04:53:26 -05:00
export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
2019-08-20 06:52:49 -05:00
// ############################################################################
2019-08-15 04:53:26 -05:00
export type MActorUrl = Pick<MActor, 'url'>
export type MActorId = Pick<MActor, 'id'>
export type MActorUsername = Pick<MActor, 'preferredUsername'>
export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
export type MActorAudience = MActorUrl & MActorFollowersUrl
2019-08-20 06:52:49 -05:00
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
export type MActorSignature = MActorAccountChannelId
2019-08-15 04:53:26 -05:00
export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
2019-08-20 06:52:49 -05:00
// ############################################################################
// Some association attributes
export type MActorHost = Use<'Server', MServerHost>
2019-08-21 07:31:57 -05:00
export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
2019-08-20 06:52:49 -05:00
2019-08-15 04:53:26 -05:00
export type MActorDefaultLight = MActorLight &
2019-08-20 06:52:49 -05:00
Use<'Server', MServerHost> &
Use<'Avatar', MAvatar>
2019-08-15 04:53:26 -05:00
export type MActorAccountId = MActor &
2019-08-20 06:52:49 -05:00
Use<'Account', MAccountId>
2019-08-15 04:53:26 -05:00
export type MActorAccountIdActor = MActor &
2019-08-20 06:52:49 -05:00
Use<'Account', MAccountIdActor>
2019-08-15 04:53:26 -05:00
export type MActorChannelId = MActor &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelId>
2019-08-15 04:53:26 -05:00
export type MActorChannelIdActor = MActor &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelIdActor>
2019-08-15 04:53:26 -05:00
export type MActorAccountChannelId = MActorAccountId & MActorChannelId
export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
2019-08-20 06:52:49 -05:00
// ############################################################################
// Include raw account/channel/server
2019-08-15 04:53:26 -05:00
export type MActorAccount = MActor &
2019-08-20 06:52:49 -05:00
Use<'Account', MAccount>
2019-08-15 04:53:26 -05:00
export type MActorChannel = MActor &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannel>
2019-08-15 04:53:26 -05:00
export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
2019-08-15 04:53:26 -05:00
export type MActorServer = MActor &
2019-08-20 06:52:49 -05:00
Use<'Server', MServer>
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
// Complex actor associations
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MActorDefault = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// Actor with channel that is associated to an account and its actor
// Actor -> VideoChannel -> Account -> Actor
export type MActorChannelAccountActor = MActor &
Use<'VideoChannel', MChannelAccountActor>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MActorFull = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar> &
Use<'Account', MAccount> &
Use<'VideoChannel', MChannelAccountActor>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// Same than ActorFull, but the account and the channel have their actor
export type MActorFullActor = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar> &
Use<'Account', MAccountDefault> &
Use<'VideoChannel', MChannelAccountDefault>
// ############################################################################
// API
2019-08-20 12:05:31 -05:00
export type MActorSummary = FunctionProperties<MActor> &
Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
2019-08-20 06:52:49 -05:00
Use<'Server', MServerHost> &
Use<'Avatar', MAvatar>
export type MActorSummaryBlocks = MActorSummary &
Use<'Server', MServerHostBlocks>
2019-08-15 04:53:26 -05:00
export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
2019-08-20 12:05:31 -05:00
// ############################################################################
// Format for API or AP object
export type MActorSummaryFormattable = FunctionProperties<MActor> &
Pick<MActor, 'url' | 'preferredUsername'> &
Use<'Server', MServerHost> &
Use<'Avatar', MAvatarFormattable>
export type MActorFormattable = MActorSummaryFormattable &
Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
2019-08-21 07:31:57 -05:00
Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
export type MActorAP = MActor &
Use<'Avatar', MAvatar>