1 import { ActorModel } from '../../../models/activitypub/actor'
2 import { FunctionProperties, PickWith } 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 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>
32 export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed>
34 export type MActorDefaultLight = MActorLight &
35 Use<'Server', MServerHost> &
36 Use<'Avatar', MAvatar>
38 export type MActorAccountId = MActor &
39 Use<'Account', MAccountId>
40 export type MActorAccountIdActor = MActor &
41 Use<'Account', MAccountIdActor>
43 export type MActorChannelId = MActor &
44 Use<'VideoChannel', MChannelId>
45 export type MActorChannelIdActor = MActor &
46 Use<'VideoChannel', MChannelIdActor>
48 export type MActorAccountChannelId = MActorAccountId & MActorChannelId
49 export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
51 // ############################################################################
53 // Include raw account/channel/server
55 export type MActorAccount = MActor &
56 Use<'Account', MAccount>
58 export type MActorChannel = MActor &
59 Use<'VideoChannel', MChannel>
61 export type MActorAccountChannel = MActorAccount & MActorChannel
63 export type MActorServer = MActor &
64 Use<'Server', MServer>
66 // ############################################################################
68 // Complex actor associations
70 export type MActorDefault = MActor &
71 Use<'Server', MServer> &
72 Use<'Avatar', MAvatar>
74 // Actor with channel that is associated to an account and its actor
75 // Actor -> VideoChannel -> Account -> Actor
76 export type MActorChannelAccountActor = MActor &
77 Use<'VideoChannel', MChannelAccountActor>
79 export type MActorFull = MActor &
80 Use<'Server', MServer> &
81 Use<'Avatar', MAvatar> &
82 Use<'Account', MAccount> &
83 Use<'VideoChannel', MChannelAccountActor>
85 // Same than ActorFull, but the account and the channel have their actor
86 export type MActorFullActor = MActor &
87 Use<'Server', MServer> &
88 Use<'Avatar', MAvatar> &
89 Use<'Account', MAccountDefault> &
90 Use<'VideoChannel', MChannelAccountDefault>
92 // ############################################################################
96 export type MActorSummary = FunctionProperties<MActor> &
97 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
98 Use<'Server', MServerHost> &
99 Use<'Avatar', MAvatar>
101 export type MActorSummaryBlocks = MActorSummary &
102 Use<'Server', MServerHostBlocks>
104 export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
105 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
107 // ############################################################################
109 // Format for API or AP object
111 export type MActorSummaryFormattable = FunctionProperties<MActor> &
112 Pick<MActor, 'url' | 'preferredUsername'> &
113 Use<'Server', MServerHost> &
114 Use<'Avatar', MAvatarFormattable>
116 export type MActorFormattable = MActorSummaryFormattable &
117 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
118 Use<'Server', MServer>