]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
453e83ea 1import { ActorModel } from '../../../models/activitypub/actor'
b5fecbf4 2import { FunctionProperties, PickWith, PickWithOpt } from '../../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
0283eaac
C
22export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
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
453e83ea 34export type MActorDefaultLight = MActorLight &
0283eaac
C
35 Use<'Server', MServerHost> &
36 Use<'Avatar', MAvatar>
453e83ea
C
37
38export type MActorAccountId = MActor &
0283eaac 39 Use<'Account', MAccountId>
453e83ea 40export type MActorAccountIdActor = MActor &
0283eaac 41 Use<'Account', MAccountIdActor>
453e83ea
C
42
43export type MActorChannelId = MActor &
0283eaac 44 Use<'VideoChannel', MChannelId>
453e83ea 45export type MActorChannelIdActor = MActor &
0283eaac 46 Use<'VideoChannel', MChannelIdActor>
453e83ea
C
47
48export type MActorAccountChannelId = MActorAccountId & MActorChannelId
49export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
50
0283eaac
C
51// ############################################################################
52
53// Include raw account/channel/server
54
453e83ea 55export type MActorAccount = MActor &
0283eaac 56 Use<'Account', MAccount>
453e83ea
C
57
58export type MActorChannel = MActor &
0283eaac 59 Use<'VideoChannel', MChannel>
453e83ea
C
60
61export type MActorAccountChannel = MActorAccount & MActorChannel
62
453e83ea 63export type MActorServer = MActor &
0283eaac 64 Use<'Server', MServer>
453e83ea 65
0283eaac 66// ############################################################################
453e83ea 67
0283eaac 68// Complex actor associations
453e83ea 69
0283eaac
C
70export type MActorDefault = MActor &
71 Use<'Server', MServer> &
72 Use<'Avatar', MAvatar>
453e83ea 73
0283eaac
C
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>
453e83ea 78
0283eaac
C
79export type MActorFull = MActor &
80 Use<'Server', MServer> &
81 Use<'Avatar', MAvatar> &
82 Use<'Account', MAccount> &
83 Use<'VideoChannel', MChannelAccountActor>
453e83ea 84
0283eaac
C
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
1ca9f7c3
C
96export type MActorSummary = FunctionProperties<MActor> &
97 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
0283eaac
C
98 Use<'Server', MServerHost> &
99 Use<'Avatar', MAvatar>
100
101export type MActorSummaryBlocks = MActorSummary &
102 Use<'Server', MServerHostBlocks>
453e83ea
C
103
104export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
105 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
1ca9f7c3
C
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'> &
b5fecbf4
C
118 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
119
120export type MActorAP = MActor &
121 Use<'Avatar', MAvatar>