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-10-23 04:33:53 -05:00
|
|
|
export type MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'>
|
2019-08-20 06:52:49 -05:00
|
|
|
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
|
|
|
|
2020-01-31 09:56:52 -06: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
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorAccountId =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccountId>
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorAccountIdActor =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccountIdActor>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorChannelId =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'VideoChannel', MChannelId>
|
2020-01-31 09:56:52 -06: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
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorAccount =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Account', MAccount>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorChannel =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'VideoChannel', MChannel>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2019-08-30 09:50:12 -05:00
|
|
|
export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06: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
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorDefault =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
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
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorChannelAccountActor =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'VideoChannel', MChannelAccountActor>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorFull =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
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
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorFullActor =
|
|
|
|
MActor &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Server', MServer> &
|
|
|
|
Use<'Avatar', MAvatar> &
|
|
|
|
Use<'Account', MAccountDefault> &
|
|
|
|
Use<'VideoChannel', MChannelAccountDefault>
|
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorSummary =
|
|
|
|
FunctionProperties<MActor> &
|
2019-08-20 12:05:31 -05:00
|
|
|
Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Server', MServerHost> &
|
|
|
|
Use<'Avatar', MAvatar>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorSummaryBlocks =
|
|
|
|
MActorSummary &
|
2019-08-20 06:52:49 -05:00
|
|
|
Use<'Server', MServerHostBlocks>
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorAPI =
|
|
|
|
Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
|
2019-08-15 04:53:26 -05:00
|
|
|
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
|
2019-08-20 12:05:31 -05:00
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// Format for API or AP object
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorSummaryFormattable =
|
|
|
|
FunctionProperties<MActor> &
|
2019-08-20 12:05:31 -05:00
|
|
|
Pick<MActor, 'url' | 'preferredUsername'> &
|
|
|
|
Use<'Server', MServerHost> &
|
|
|
|
Use<'Avatar', MAvatarFormattable>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorFormattable =
|
|
|
|
MActorSummaryFormattable &
|
2019-08-20 12:05:31 -05:00
|
|
|
Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
|
2019-08-21 07:31:57 -05:00
|
|
|
Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
export type MActorAP =
|
|
|
|
MActor &
|
2019-08-21 07:31:57 -05:00
|
|
|
Use<'Avatar', MAvatar>
|