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