1 import { ActorModel } from '../../../models/activitypub/actor'
2 import { PickWith } from '../../utils'
3 import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4 import { MServer, MServerHost, MServerHostBlocks } from '../server'
5 import { MAvatar } from './avatar'
6 import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
8 type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
10 // ############################################################################
12 export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
14 // ############################################################################
16 export type MActorUrl = Pick<MActor, 'url'>
17 export type MActorId = Pick<MActor, 'id'>
18 export type MActorUsername = Pick<MActor, 'preferredUsername'>
20 export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
21 export type MActorAudience = MActorUrl & MActorFollowersUrl
22 export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
23 export type MActorSignature = MActorAccountChannelId
25 export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
27 // ############################################################################
29 // Some association attributes
31 export type MActorHost = Use<'Server', MServerHost>
33 export type MActorDefaultLight = MActorLight &
34 Use<'Server', MServerHost> &
35 Use<'Avatar', MAvatar>
37 export type MActorAccountId = MActor &
38 Use<'Account', MAccountId>
39 export type MActorAccountIdActor = MActor &
40 Use<'Account', MAccountIdActor>
42 export type MActorChannelId = MActor &
43 Use<'VideoChannel', MChannelId>
44 export type MActorChannelIdActor = MActor &
45 Use<'VideoChannel', MChannelIdActor>
47 export type MActorAccountChannelId = MActorAccountId & MActorChannelId
48 export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
50 // ############################################################################
52 // Include raw account/channel/server
54 export type MActorAccount = MActor &
55 Use<'Account', MAccount>
57 export type MActorChannel = MActor &
58 Use<'VideoChannel', MChannel>
60 export type MActorAccountChannel = MActorAccount & MActorChannel
62 export type MActorServer = MActor &
63 Use<'Server', MServer>
65 // ############################################################################
67 // Complex actor associations
69 export type MActorDefault = MActor &
70 Use<'Server', MServer> &
71 Use<'Avatar', MAvatar>
73 // Actor with channel that is associated to an account and its actor
74 // Actor -> VideoChannel -> Account -> Actor
75 export type MActorChannelAccountActor = MActor &
76 Use<'VideoChannel', MChannelAccountActor>
78 export type MActorFull = MActor &
79 Use<'Server', MServer> &
80 Use<'Avatar', MAvatar> &
81 Use<'Account', MAccount> &
82 Use<'VideoChannel', MChannelAccountActor>
84 // Same than ActorFull, but the account and the channel have their actor
85 export type MActorFullActor = MActor &
86 Use<'Server', MServer> &
87 Use<'Avatar', MAvatar> &
88 Use<'Account', MAccountDefault> &
89 Use<'VideoChannel', MChannelAccountDefault>
91 // ############################################################################
95 export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
96 Use<'Server', MServerHost> &
97 Use<'Avatar', MAvatar>
99 export type MActorSummaryBlocks = MActorSummary &
100 Use<'Server', MServerHostBlocks>
102 export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
103 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>