1 import { ActorModel } from '../../../models/activitypub/actor'
2 import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
3 import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4 import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5 import { MAvatar, MAvatarFormattable } 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 MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'>
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>
32 export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
34 export type MActorDefaultLight =
36 Use<'Server', MServerHost> &
37 Use<'Avatar', MAvatar>
39 export type MActorAccountId =
41 Use<'Account', MAccountId>
42 export type MActorAccountIdActor =
44 Use<'Account', MAccountIdActor>
46 export type MActorChannelId =
48 Use<'VideoChannel', MChannelId>
49 export type MActorChannelIdActor =
51 Use<'VideoChannel', MChannelIdActor>
53 export type MActorAccountChannelId = MActorAccountId & MActorChannelId
54 export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
56 // ############################################################################
58 // Include raw account/channel/server
60 export type MActorAccount =
62 Use<'Account', MAccount>
64 export type MActorChannel =
66 Use<'VideoChannel', MChannel>
68 export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
70 export type MActorServer =
72 Use<'Server', MServer>
74 // ############################################################################
76 // Complex actor associations
78 export type MActorDefault =
80 Use<'Server', MServer> &
81 Use<'Avatar', MAvatar>
83 // Actor with channel that is associated to an account and its actor
84 // Actor -> VideoChannel -> Account -> Actor
85 export type MActorChannelAccountActor =
87 Use<'VideoChannel', MChannelAccountActor>
89 export type MActorFull =
91 Use<'Server', MServer> &
92 Use<'Avatar', MAvatar> &
93 Use<'Account', MAccount> &
94 Use<'VideoChannel', MChannelAccountActor>
96 // Same than ActorFull, but the account and the channel have their actor
97 export type MActorFullActor =
99 Use<'Server', MServer> &
100 Use<'Avatar', MAvatar> &
101 Use<'Account', MAccountDefault> &
102 Use<'VideoChannel', MChannelAccountDefault>
104 // ############################################################################
108 export type MActorSummary =
109 FunctionProperties<MActor> &
110 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
111 Use<'Server', MServerHost> &
112 Use<'Avatar', MAvatar>
114 export type MActorSummaryBlocks =
116 Use<'Server', MServerHostBlocks>
118 export type MActorAPI =
119 Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
120 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
122 // ############################################################################
124 // Format for API or AP object
126 export type MActorSummaryFormattable =
127 FunctionProperties<MActor> &
128 Pick<MActor, 'url' | 'preferredUsername'> &
129 Use<'Server', MServerHost> &
130 Use<'Avatar', MAvatarFormattable>
132 export type MActorFormattable =
133 MActorSummaryFormattable &
134 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
135 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
137 export type MActorAP =
139 Use<'Avatar', MAvatar>