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