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