]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { ActorModel } from '../../../models/activitypub/actor' |
b5fecbf4 | 2 | import { FunctionProperties, PickWith, PickWithOpt } from '../../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 | |
0283eaac C |
22 | export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> |
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 | |
453e83ea | 34 | export type MActorDefaultLight = MActorLight & |
0283eaac C |
35 | Use<'Server', MServerHost> & |
36 | Use<'Avatar', MAvatar> | |
453e83ea C |
37 | |
38 | export type MActorAccountId = MActor & | |
0283eaac | 39 | Use<'Account', MAccountId> |
453e83ea | 40 | export type MActorAccountIdActor = MActor & |
0283eaac | 41 | Use<'Account', MAccountIdActor> |
453e83ea C |
42 | |
43 | export type MActorChannelId = MActor & | |
0283eaac | 44 | Use<'VideoChannel', MChannelId> |
453e83ea | 45 | export type MActorChannelIdActor = MActor & |
0283eaac | 46 | Use<'VideoChannel', MChannelIdActor> |
453e83ea C |
47 | |
48 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | |
49 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | |
50 | ||
0283eaac C |
51 | // ############################################################################ |
52 | ||
53 | // Include raw account/channel/server | |
54 | ||
453e83ea | 55 | export type MActorAccount = MActor & |
0283eaac | 56 | Use<'Account', MAccount> |
453e83ea C |
57 | |
58 | export type MActorChannel = MActor & | |
0283eaac | 59 | Use<'VideoChannel', MChannel> |
453e83ea C |
60 | |
61 | export type MActorAccountChannel = MActorAccount & MActorChannel | |
62 | ||
453e83ea | 63 | export type MActorServer = MActor & |
0283eaac | 64 | Use<'Server', MServer> |
453e83ea | 65 | |
0283eaac | 66 | // ############################################################################ |
453e83ea | 67 | |
0283eaac | 68 | // Complex actor associations |
453e83ea | 69 | |
0283eaac C |
70 | export type MActorDefault = MActor & |
71 | Use<'Server', MServer> & | |
72 | Use<'Avatar', MAvatar> | |
453e83ea | 73 | |
0283eaac C |
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> | |
453e83ea | 78 | |
0283eaac C |
79 | export type MActorFull = MActor & |
80 | Use<'Server', MServer> & | |
81 | Use<'Avatar', MAvatar> & | |
82 | Use<'Account', MAccount> & | |
83 | Use<'VideoChannel', MChannelAccountActor> | |
453e83ea | 84 | |
0283eaac C |
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> | |
91 | ||
92 | // ############################################################################ | |
93 | ||
94 | // API | |
95 | ||
1ca9f7c3 C |
96 | export type MActorSummary = FunctionProperties<MActor> & |
97 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | |
0283eaac C |
98 | Use<'Server', MServerHost> & |
99 | Use<'Avatar', MAvatar> | |
100 | ||
101 | export type MActorSummaryBlocks = MActorSummary & | |
102 | Use<'Server', MServerHostBlocks> | |
453e83ea C |
103 | |
104 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | |
105 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | |
1ca9f7c3 C |
106 | |
107 | // ############################################################################ | |
108 | ||
109 | // Format for API or AP object | |
110 | ||
111 | export type MActorSummaryFormattable = FunctionProperties<MActor> & | |
112 | Pick<MActor, 'url' | 'preferredUsername'> & | |
113 | Use<'Server', MServerHost> & | |
114 | Use<'Avatar', MAvatarFormattable> | |
115 | ||
116 | export type MActorFormattable = MActorSummaryFormattable & | |
117 | Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> & | |
b5fecbf4 C |
118 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> |
119 | ||
120 | export type MActorAP = MActor & | |
121 | Use<'Avatar', MAvatar> |