2019-08-15 05:53:26 -04:00
|
|
|
import { ActorModel } from '../../../models/activitypub/actor'
|
|
|
|
import { PickWith } from '../../utils'
|
2019-08-20 07:52:49 -04:00
|
|
|
import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
|
|
|
|
import { MServer, MServerHost, MServerHostBlocks } from '../server'
|
2019-08-15 05:53:26 -04:00
|
|
|
import { MAvatar } from './avatar'
|
2019-08-20 07:52:49 -04:00
|
|
|
import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
|
|
|
|
|
|
|
|
type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
|
|
|
|
|
|
|
|
// ############################################################################
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
|
|
|
|
|
2019-08-20 07:52:49 -04:00
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-15 05:53:26 -04: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 07:52:49 -04:00
|
|
|
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
|
|
|
|
export type MActorSignature = MActorAccountChannelId
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
|
|
|
|
|
2019-08-20 07:52:49 -04:00
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// Some association attributes
|
|
|
|
|
|
|
|
export type MActorHost = Use<'Server', MServerHost>
|
|
|
|
|
2019-08-15 05:53:26 -04:00
|
|
|
export type MActorDefaultLight = MActorLight &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'Server', MServerHost> &
|
|
|
|
Use<'Avatar', MAvatar>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorAccountId = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'Account', MAccountId>
|
2019-08-15 05:53:26 -04:00
|
|
|
export type MActorAccountIdActor = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'Account', MAccountIdActor>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorChannelId = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'VideoChannel', MChannelId>
|
2019-08-15 05:53:26 -04:00
|
|
|
export type MActorChannelIdActor = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'VideoChannel', MChannelIdActor>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorAccountChannelId = MActorAccountId & MActorChannelId
|
|
|
|
export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
|
|
|
|
|
2019-08-20 07:52:49 -04:00
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// Include raw account/channel/server
|
|
|
|
|
2019-08-15 05:53:26 -04:00
|
|
|
export type MActorAccount = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'Account', MAccount>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorChannel = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'VideoChannel', MChannel>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorAccountChannel = MActorAccount & MActorChannel
|
|
|
|
|
|
|
|
export type MActorServer = MActor &
|
2019-08-20 07:52:49 -04:00
|
|
|
Use<'Server', MServer>
|
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
|
|
|
// Complex actor associations
|
2019-08-15 05:53:26 -04:00
|
|
|
|
2019-08-20 07:52:49 -04:00
|
|
|
export type MActorDefault = MActor &
|
|
|
|
Use<'Server', MServer> &
|
|
|
|
Use<'Avatar', MAvatar>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
2019-08-20 07:52:49 -04: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 05:53:26 -04:00
|
|
|
|
2019-08-20 07:52:49 -04:00
|
|
|
export type MActorFull = MActor &
|
|
|
|
Use<'Server', MServer> &
|
|
|
|
Use<'Avatar', MAvatar> &
|
|
|
|
Use<'Account', MAccount> &
|
|
|
|
Use<'VideoChannel', MChannelAccountActor>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
2019-08-20 07:52:49 -04: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
|
|
|
|
|
|
|
|
export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
|
|
|
|
Use<'Server', MServerHost> &
|
|
|
|
Use<'Avatar', MAvatar>
|
|
|
|
|
|
|
|
export type MActorSummaryBlocks = MActorSummary &
|
|
|
|
Use<'Server', MServerHostBlocks>
|
2019-08-15 05:53:26 -04:00
|
|
|
|
|
|
|
export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
|
|
|
|
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
|