]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { ActorModel } from '../../../models/activitypub/actor' |
67ed6552 | 2 | import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils' |
0283eaac | 3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' |
1ca9f7c3 C |
4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' |
5 | import { MAvatar, MAvatarFormattable } from './avatar' | |
0283eaac C |
6 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' |
7 | ||
8 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | |
9 | ||
10 | // ############################################################################ | |
453e83ea C |
11 | |
12 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | |
13 | ||
0283eaac C |
14 | // ############################################################################ |
15 | ||
453e83ea C |
16 | export type MActorUrl = Pick<MActor, 'url'> |
17 | export type MActorId = Pick<MActor, 'id'> | |
18 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | |
453e83ea C |
19 | |
20 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> | |
21 | export type MActorAudience = MActorUrl & MActorFollowersUrl | |
47581df0 | 22 | export type MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'> |
0283eaac | 23 | export type MActorSignature = MActorAccountChannelId |
453e83ea C |
24 | |
25 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | |
26 | ||
0283eaac C |
27 | // ############################################################################ |
28 | ||
29 | // Some association attributes | |
30 | ||
31 | export type MActorHost = Use<'Server', MServerHost> | |
b5fecbf4 | 32 | export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed> |
0283eaac | 33 | |
a1587156 C |
34 | export type MActorDefaultLight = |
35 | MActorLight & | |
0283eaac C |
36 | Use<'Server', MServerHost> & |
37 | Use<'Avatar', MAvatar> | |
453e83ea | 38 | |
a1587156 C |
39 | export type MActorAccountId = |
40 | MActor & | |
0283eaac | 41 | Use<'Account', MAccountId> |
a1587156 C |
42 | export type MActorAccountIdActor = |
43 | MActor & | |
0283eaac | 44 | Use<'Account', MAccountIdActor> |
453e83ea | 45 | |
a1587156 C |
46 | export type MActorChannelId = |
47 | MActor & | |
0283eaac | 48 | Use<'VideoChannel', MChannelId> |
a1587156 C |
49 | export type MActorChannelIdActor = |
50 | MActor & | |
0283eaac | 51 | Use<'VideoChannel', MChannelIdActor> |
453e83ea C |
52 | |
53 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | |
54 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | |
55 | ||
0283eaac C |
56 | // ############################################################################ |
57 | ||
58 | // Include raw account/channel/server | |
59 | ||
a1587156 C |
60 | export type MActorAccount = |
61 | MActor & | |
0283eaac | 62 | Use<'Account', MAccount> |
453e83ea | 63 | |
a1587156 C |
64 | export type MActorChannel = |
65 | MActor & | |
0283eaac | 66 | Use<'VideoChannel', MChannel> |
453e83ea | 67 | |
8424c402 | 68 | export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel |
453e83ea | 69 | |
a1587156 C |
70 | export type MActorServer = |
71 | MActor & | |
0283eaac | 72 | Use<'Server', MServer> |
453e83ea | 73 | |
0283eaac | 74 | // ############################################################################ |
453e83ea | 75 | |
0283eaac | 76 | // Complex actor associations |
453e83ea | 77 | |
a1587156 C |
78 | export type MActorDefault = |
79 | MActor & | |
0283eaac C |
80 | Use<'Server', MServer> & |
81 | Use<'Avatar', MAvatar> | |
453e83ea | 82 | |
0283eaac C |
83 | // Actor with channel that is associated to an account and its actor |
84 | // Actor -> VideoChannel -> Account -> Actor | |
a1587156 C |
85 | export type MActorChannelAccountActor = |
86 | MActor & | |
0283eaac | 87 | Use<'VideoChannel', MChannelAccountActor> |
453e83ea | 88 | |
a1587156 C |
89 | export type MActorFull = |
90 | MActor & | |
0283eaac C |
91 | Use<'Server', MServer> & |
92 | Use<'Avatar', MAvatar> & | |
93 | Use<'Account', MAccount> & | |
94 | Use<'VideoChannel', MChannelAccountActor> | |
453e83ea | 95 | |
0283eaac | 96 | // Same than ActorFull, but the account and the channel have their actor |
a1587156 C |
97 | export type MActorFullActor = |
98 | MActor & | |
0283eaac C |
99 | Use<'Server', MServer> & |
100 | Use<'Avatar', MAvatar> & | |
101 | Use<'Account', MAccountDefault> & | |
102 | Use<'VideoChannel', MChannelAccountDefault> | |
103 | ||
104 | // ############################################################################ | |
105 | ||
106 | // API | |
107 | ||
a1587156 C |
108 | export type MActorSummary = |
109 | FunctionProperties<MActor> & | |
1ca9f7c3 | 110 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & |
0283eaac C |
111 | Use<'Server', MServerHost> & |
112 | Use<'Avatar', MAvatar> | |
113 | ||
a1587156 C |
114 | export type MActorSummaryBlocks = |
115 | MActorSummary & | |
0283eaac | 116 | Use<'Server', MServerHostBlocks> |
453e83ea | 117 | |
a1587156 C |
118 | export type MActorAPI = |
119 | Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | |
453e83ea | 120 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> |
1ca9f7c3 C |
121 | |
122 | // ############################################################################ | |
123 | ||
124 | // Format for API or AP object | |
125 | ||
a1587156 C |
126 | export type MActorSummaryFormattable = |
127 | FunctionProperties<MActor> & | |
1ca9f7c3 C |
128 | Pick<MActor, 'url' | 'preferredUsername'> & |
129 | Use<'Server', MServerHost> & | |
130 | Use<'Avatar', MAvatarFormattable> | |
131 | ||
a1587156 C |
132 | export type MActorFormattable = |
133 | MActorSummaryFormattable & | |
1ca9f7c3 | 134 | Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> & |
b5fecbf4 C |
135 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> |
136 | ||
a1587156 C |
137 | export type MActorAP = |
138 | MActor & | |
b5fecbf4 | 139 | Use<'Avatar', MAvatar> |