]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/actor/actor.ts
Add Podcast RSS feeds (#5487)
[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
cb0eda56
AG
32export type MActorHostOnly = Use<'Server', MServerHost>
33export type MActorHost =
34 MActorLight &
35 Use<'Server', MServerHost>
36
b5fecbf4 37export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
0283eaac 38
a1587156
C
39export type MActorDefaultLight =
40 MActorLight &
0283eaac 41 Use<'Server', MServerHost> &
d0800f76 42 Use<'Avatars', MActorImage[]>
453e83ea 43
a1587156
C
44export type MActorAccountId =
45 MActor &
0283eaac 46 Use<'Account', MAccountId>
a1587156
C
47export type MActorAccountIdActor =
48 MActor &
0283eaac 49 Use<'Account', MAccountIdActor>
453e83ea 50
a1587156
C
51export type MActorChannelId =
52 MActor &
0283eaac 53 Use<'VideoChannel', MChannelId>
a1587156
C
54export type MActorChannelIdActor =
55 MActor &
0283eaac 56 Use<'VideoChannel', MChannelIdActor>
453e83ea
C
57
58export type MActorAccountChannelId = MActorAccountId & MActorChannelId
59export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
60
0283eaac
C
61// ############################################################################
62
63// Include raw account/channel/server
64
a1587156
C
65export type MActorAccount =
66 MActor &
0283eaac 67 Use<'Account', MAccount>
453e83ea 68
a1587156
C
69export type MActorChannel =
70 MActor &
0283eaac 71 Use<'VideoChannel', MChannel>
453e83ea 72
8424c402 73export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
453e83ea 74
cb0eda56
AG
75export type MActorServerLight =
76 MActorLight &
0283eaac 77 Use<'Server', MServer>
453e83ea 78
0283eaac 79// ############################################################################
453e83ea 80
0283eaac 81// Complex actor associations
453e83ea 82
2cb03dc1
C
83export type MActorImages =
84 MActor &
d0800f76 85 Use<'Avatars', MActorImage[]> &
86 UseOpt<'Banners', MActorImage[]>
2cb03dc1 87
a1587156
C
88export type MActorDefault =
89 MActor &
0283eaac 90 Use<'Server', MServer> &
d0800f76 91 Use<'Avatars', MActorImage[]>
453e83ea 92
2cb03dc1
C
93export type MActorDefaultChannelId =
94 MActorDefault &
95 Use<'VideoChannel', MChannelId>
96
97export type MActorDefaultBanner =
98 MActor &
99 Use<'Server', MServer> &
d0800f76 100 Use<'Avatars', MActorImage[]> &
101 Use<'Banners', MActorImage[]>
2cb03dc1 102
0283eaac
C
103// Actor with channel that is associated to an account and its actor
104// Actor -> VideoChannel -> Account -> Actor
a1587156
C
105export type MActorChannelAccountActor =
106 MActor &
0283eaac 107 Use<'VideoChannel', MChannelAccountActor>
453e83ea 108
a1587156
C
109export type MActorFull =
110 MActor &
0283eaac 111 Use<'Server', MServer> &
d0800f76 112 Use<'Avatars', MActorImage[]> &
113 Use<'Banners', MActorImage[]> &
0283eaac
C
114 Use<'Account', MAccount> &
115 Use<'VideoChannel', MChannelAccountActor>
453e83ea 116
0283eaac 117// Same than ActorFull, but the account and the channel have their actor
a1587156
C
118export type MActorFullActor =
119 MActor &
0283eaac 120 Use<'Server', MServer> &
d0800f76 121 Use<'Avatars', MActorImage[]> &
122 Use<'Banners', MActorImage[]> &
0283eaac
C
123 Use<'Account', MAccountDefault> &
124 Use<'VideoChannel', MChannelAccountDefault>
125
126// ############################################################################
127
128// API
129
a1587156
C
130export type MActorSummary =
131 FunctionProperties<MActor> &
d0800f76 132 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId'> &
0283eaac 133 Use<'Server', MServerHost> &
d0800f76 134 Use<'Avatars', MActorImage[]>
0283eaac 135
a1587156
C
136export type MActorSummaryBlocks =
137 MActorSummary &
0283eaac 138 Use<'Server', MServerHostBlocks>
453e83ea 139
a1587156
C
140export type MActorAPI =
141 Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
453e83ea 142 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
1ca9f7c3
C
143
144// ############################################################################
145
146// Format for API or AP object
147
a1587156
C
148export type MActorSummaryFormattable =
149 FunctionProperties<MActor> &
1ca9f7c3
C
150 Pick<MActor, 'url' | 'preferredUsername'> &
151 Use<'Server', MServerHost> &
d0800f76 152 Use<'Avatars', MActorImageFormattable[]>
1ca9f7c3 153
a1587156
C
154export type MActorFormattable =
155 MActorSummaryFormattable &
d0800f76 156 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt' | 'remoteCreatedAt'> &
2cb03dc1 157 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> &
d0800f76 158 UseOpt<'Banners', MActorImageFormattable[]> &
159 UseOpt<'Avatars', MActorImageFormattable[]>
b5fecbf4 160
2cb03dc1 161type MActorAPBase =
a1587156 162 MActor &
d0800f76 163 Use<'Avatars', MActorImage[]>
2cb03dc1
C
164
165export type MActorAPAccount =
166 MActorAPBase
167
168export type MActorAPChannel =
169 MActorAPBase &
d0800f76 170 Use<'Banners', MActorImage[]>