]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/types/models/actor/actor.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / types / models / actor / actor.ts
... / ...
CommitLineData
1import { FunctionProperties, PickWith, PickWithOpt } from '@shared/typescript-utils'
2import { ActorModel } from '../../../models/actor/actor'
3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from '../account'
4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
6import { MActorImage, MActorImageFormattable } from './actor-image'
7
8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
9type UseOpt<K extends keyof ActorModel, M> = PickWithOpt<ActorModel, K, M>
10
11// ############################################################################
12
13export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'ActorFollowers' | 'Server' | 'Banners'>
14
15// ############################################################################
16
17export type MActorUrl = Pick<MActor, 'url'>
18export type MActorId = Pick<MActor, 'id'>
19export type MActorUsername = Pick<MActor, 'preferredUsername'>
20
21export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
22export type MActorAudience = MActorUrl & MActorFollowersUrl
23export type MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'>
24export type MActorSignature = MActorAccountChannelId
25
26export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
27
28// ############################################################################
29
30// Some association attributes
31
32export type MActorHostOnly = Use<'Server', MServerHost>
33export type MActorHost =
34 MActorLight &
35 Use<'Server', MServerHost>
36
37export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
38
39export type MActorDefaultLight =
40 MActorLight &
41 Use<'Server', MServerHost> &
42 Use<'Avatars', MActorImage[]>
43
44export type MActorAccountId =
45 MActor &
46 Use<'Account', MAccountId>
47export type MActorAccountIdActor =
48 MActor &
49 Use<'Account', MAccountIdActor>
50
51export type MActorChannelId =
52 MActor &
53 Use<'VideoChannel', MChannelId>
54export type MActorChannelIdActor =
55 MActor &
56 Use<'VideoChannel', MChannelIdActor>
57
58export type MActorAccountChannelId = MActorAccountId & MActorChannelId
59export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
60
61// ############################################################################
62
63// Include raw account/channel/server
64
65export type MActorAccount =
66 MActor &
67 Use<'Account', MAccount>
68
69export type MActorChannel =
70 MActor &
71 Use<'VideoChannel', MChannel>
72
73export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
74
75export type MActorServerLight =
76 MActorLight &
77 Use<'Server', MServer>
78
79// ############################################################################
80
81// Complex actor associations
82
83export type MActorImages =
84 MActor &
85 Use<'Avatars', MActorImage[]> &
86 UseOpt<'Banners', MActorImage[]>
87
88export type MActorDefault =
89 MActor &
90 Use<'Server', MServer> &
91 Use<'Avatars', MActorImage[]>
92
93export type MActorDefaultChannelId =
94 MActorDefault &
95 Use<'VideoChannel', MChannelId>
96
97export type MActorDefaultBanner =
98 MActor &
99 Use<'Server', MServer> &
100 Use<'Avatars', MActorImage[]> &
101 Use<'Banners', MActorImage[]>
102
103// Actor with channel that is associated to an account and its actor
104// Actor -> VideoChannel -> Account -> Actor
105export type MActorChannelAccountActor =
106 MActor &
107 Use<'VideoChannel', MChannelAccountActor>
108
109export type MActorFull =
110 MActor &
111 Use<'Server', MServer> &
112 Use<'Avatars', MActorImage[]> &
113 Use<'Banners', MActorImage[]> &
114 Use<'Account', MAccount> &
115 Use<'VideoChannel', MChannelAccountActor>
116
117// Same than ActorFull, but the account and the channel have their actor
118export type MActorFullActor =
119 MActor &
120 Use<'Server', MServer> &
121 Use<'Avatars', MActorImage[]> &
122 Use<'Banners', MActorImage[]> &
123 Use<'Account', MAccountDefault> &
124 Use<'VideoChannel', MChannelAccountDefault>
125
126// ############################################################################
127
128// API
129
130export type MActorSummary =
131 FunctionProperties<MActor> &
132 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId'> &
133 Use<'Server', MServerHost> &
134 Use<'Avatars', MActorImage[]>
135
136export type MActorSummaryBlocks =
137 MActorSummary &
138 Use<'Server', MServerHostBlocks>
139
140export type MActorAPI =
141 Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
142 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
143
144// ############################################################################
145
146// Format for API or AP object
147
148export type MActorSummaryFormattable =
149 FunctionProperties<MActor> &
150 Pick<MActor, 'url' | 'preferredUsername'> &
151 Use<'Server', MServerHost> &
152 Use<'Avatars', MActorImageFormattable[]>
153
154export type MActorFormattable =
155 MActorSummaryFormattable &
156 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt' | 'remoteCreatedAt'> &
157 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> &
158 UseOpt<'Banners', MActorImageFormattable[]> &
159 UseOpt<'Avatars', MActorImageFormattable[]>
160
161type MActorAPBase =
162 MActor &
163 Use<'Avatars', MActorImage[]>
164
165export type MActorAPAccount =
166 MActorAPBase
167
168export type MActorAPChannel =
169 MActorAPBase &
170 Use<'Banners', MActorImage[]>