]>
Commit | Line | Data |
---|---|---|
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' | |
7 | ||
8 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | |
9 | ||
10 | // ############################################################################ | |
11 | ||
12 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | |
13 | ||
14 | // ############################################################################ | |
15 | ||
16 | export type MActorUrl = Pick<MActor, 'url'> | |
17 | export type MActorId = Pick<MActor, 'id'> | |
18 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | |
19 | ||
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 | |
24 | ||
25 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | |
26 | ||
27 | // ############################################################################ | |
28 | ||
29 | // Some association attributes | |
30 | ||
31 | export type MActorHost = Use<'Server', MServerHost> | |
32 | export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed> | |
33 | ||
34 | export type MActorDefaultLight = MActorLight & | |
35 | Use<'Server', MServerHost> & | |
36 | Use<'Avatar', MAvatar> | |
37 | ||
38 | export type MActorAccountId = MActor & | |
39 | Use<'Account', MAccountId> | |
40 | export type MActorAccountIdActor = MActor & | |
41 | Use<'Account', MAccountIdActor> | |
42 | ||
43 | export type MActorChannelId = MActor & | |
44 | Use<'VideoChannel', MChannelId> | |
45 | export type MActorChannelIdActor = MActor & | |
46 | Use<'VideoChannel', MChannelIdActor> | |
47 | ||
48 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | |
49 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | |
50 | ||
51 | // ############################################################################ | |
52 | ||
53 | // Include raw account/channel/server | |
54 | ||
55 | export type MActorAccount = MActor & | |
56 | Use<'Account', MAccount> | |
57 | ||
58 | export type MActorChannel = MActor & | |
59 | Use<'VideoChannel', MChannel> | |
60 | ||
61 | export type MActorAccountChannel = MActorAccount & MActorChannel | |
62 | ||
63 | export type MActorServer = MActor & | |
64 | Use<'Server', MServer> | |
65 | ||
66 | // ############################################################################ | |
67 | ||
68 | // Complex actor associations | |
69 | ||
70 | export type MActorDefault = MActor & | |
71 | Use<'Server', MServer> & | |
72 | Use<'Avatar', MAvatar> | |
73 | ||
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> | |
78 | ||
79 | export type MActorFull = MActor & | |
80 | Use<'Server', MServer> & | |
81 | Use<'Avatar', MAvatar> & | |
82 | Use<'Account', MAccount> & | |
83 | Use<'VideoChannel', MChannelAccountActor> | |
84 | ||
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 | ||
96 | export type MActorSummary = FunctionProperties<MActor> & | |
97 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | |
98 | Use<'Server', MServerHost> & | |
99 | Use<'Avatar', MAvatar> | |
100 | ||
101 | export type MActorSummaryBlocks = MActorSummary & | |
102 | Use<'Server', MServerHostBlocks> | |
103 | ||
104 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | |
105 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | |
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'> & | |
118 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> | |
119 | ||
120 | export type MActorAP = MActor & | |
121 | Use<'Avatar', MAvatar> |