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