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