]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/actor/actor.ts
Implement avatar miniatures (#4639)
[github/Chocobozzz/PeerTube.git] / server / types / models / actor / actor.ts
CommitLineData
6b5f72be 1import { FunctionProperties, PickWith, PickWithOpt } from '@shared/typescript-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
d0800f76 13export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'ActorFollowers' | 'Server' | 'Banners'>
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> &
d0800f76 38 Use<'Avatars', 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 &
d0800f76 81 Use<'Avatars', MActorImage[]> &
82 UseOpt<'Banners', MActorImage[]>
2cb03dc1 83
a1587156
C
84export type MActorDefault =
85 MActor &
0283eaac 86 Use<'Server', MServer> &
d0800f76 87 Use<'Avatars', MActorImage[]>
453e83ea 88
2cb03dc1
C
89export type MActorDefaultChannelId =
90 MActorDefault &
91 Use<'VideoChannel', MChannelId>
92
93export type MActorDefaultBanner =
94 MActor &
95 Use<'Server', MServer> &
d0800f76 96 Use<'Avatars', MActorImage[]> &
97 Use<'Banners', MActorImage[]>
2cb03dc1 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> &
d0800f76 108 Use<'Avatars', MActorImage[]> &
109 Use<'Banners', 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> &
d0800f76 117 Use<'Avatars', MActorImage[]> &
118 Use<'Banners', 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> &
d0800f76 128 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId'> &
0283eaac 129 Use<'Server', MServerHost> &
d0800f76 130 Use<'Avatars', 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> &
d0800f76 148 Use<'Avatars', MActorImageFormattable[]>
1ca9f7c3 149
a1587156
C
150export type MActorFormattable =
151 MActorSummaryFormattable &
d0800f76 152 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt' | 'remoteCreatedAt'> &
2cb03dc1 153 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> &
d0800f76 154 UseOpt<'Banners', MActorImageFormattable[]> &
155 UseOpt<'Avatars', MActorImageFormattable[]>
b5fecbf4 156
2cb03dc1 157type MActorAPBase =
a1587156 158 MActor &
d0800f76 159 Use<'Avatars', MActorImage[]>
2cb03dc1
C
160
161export type MActorAPAccount =
162 MActorAPBase
163
164export type MActorAPChannel =
165 MActorAPBase &
d0800f76 166 Use<'Banners', MActorImage[]>