aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/account/actor.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-20 13:52:49 +0200
committerChocobozzz <me@florianbigard.com>2019-08-20 14:53:42 +0200
commit0283eaac2a8e73006c66df3cf5bb9012e37450e5 (patch)
tree1fb73aeef57f984a77f47828ade23c6365ce8eb0 /server/typings/models/account/actor.ts
parent96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff)
downloadPeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.gz
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.zst
PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.zip
Cleanup model types
Diffstat (limited to 'server/typings/models/account/actor.ts')
-rw-r--r--server/typings/models/account/actor.ts93
1 files changed, 61 insertions, 32 deletions
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts
index f3e752a98..7d99a433b 100644
--- a/server/typings/models/account/actor.ts
+++ b/server/typings/models/account/actor.ts
@@ -1,74 +1,103 @@
1import { ActorModel } from '../../../models/activitypub/actor' 1import { ActorModel } from '../../../models/activitypub/actor'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account' 3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4import { MServerHost, MServerHostBlocks, MServer } from '../server' 4import { MServer, MServerHost, MServerHostBlocks } from '../server'
5import { MAvatar } from './avatar' 5import { MAvatar } from './avatar'
6import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video' 6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
7
8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
9
10// ############################################################################
7 11
8export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> 12export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
9 13
14// ############################################################################
15
10export type MActorUrl = Pick<MActor, 'url'> 16export type MActorUrl = Pick<MActor, 'url'>
11export type MActorId = Pick<MActor, 'id'> 17export type MActorId = Pick<MActor, 'id'>
12export type MActorUsername = Pick<MActor, 'preferredUsername'> 18export type MActorUsername = Pick<MActor, 'preferredUsername'>
13export type MActorHost = PickWith<ActorModel, 'Server', MServerHost>
14 19
15export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> 20export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
16export type MActorAudience = MActorUrl & MActorFollowersUrl 21export type MActorAudience = MActorUrl & MActorFollowersUrl
22export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
23export type MActorSignature = MActorAccountChannelId
17 24
18export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> 25export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
19 26
27// ############################################################################
28
29// Some association attributes
30
31export type MActorHost = Use<'Server', MServerHost>
32
20export type MActorDefaultLight = MActorLight & 33export type MActorDefaultLight = MActorLight &
21 MActorHost & 34 Use<'Server', MServerHost> &
22 PickWith<ActorModel, 'Avatar', MAvatar> 35 Use<'Avatar', MAvatar>
23 36
24export type MActorAccountId = MActor & 37export type MActorAccountId = MActor &
25 PickWith<ActorModel, 'Account', MAccountId> 38 Use<'Account', MAccountId>
26export type MActorAccountIdActor = MActor & 39export type MActorAccountIdActor = MActor &
27 PickWith<ActorModel, 'Account', MAccountIdActor> 40 Use<'Account', MAccountIdActor>
28 41
29export type MActorChannelId = MActor & 42export type MActorChannelId = MActor &
30 PickWith<ActorModel, 'VideoChannel', MChannelId> 43 Use<'VideoChannel', MChannelId>
31export type MActorChannelIdActor = MActor & 44export type MActorChannelIdActor = MActor &
32 PickWith<ActorModel, 'VideoChannel', MChannelIdActor> 45 Use<'VideoChannel', MChannelIdActor>
33 46
34export type MActorAccountChannelId = MActorAccountId & MActorChannelId 47export type MActorAccountChannelId = MActorAccountId & MActorChannelId
35export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor 48export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
36 49
50// ############################################################################
51
52// Include raw account/channel/server
53
37export type MActorAccount = MActor & 54export type MActorAccount = MActor &
38 PickWith<ActorModel, 'Account', MAccount> 55 Use<'Account', MAccount>
39 56
40export type MActorChannel = MActor & 57export type MActorChannel = MActor &
41 PickWith<ActorModel, 'VideoChannel', MChannel> 58 Use<'VideoChannel', MChannel>
42 59
43export type MActorAccountChannel = MActorAccount & MActorChannel 60export type MActorAccountChannel = MActorAccount & MActorChannel
44 61
45export type MActorChannelAccount = MActor &
46 PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
47
48export type MActorServer = MActor & 62export type MActorServer = MActor &
49 PickWith<ActorModel, 'Server', MServer> 63 Use<'Server', MServer>
50 64
51export type MActorDefault = MActorServer & 65// ############################################################################
52 PickWith<ActorModel, 'Avatar', MAvatar>
53 66
54export type MActorFull = MActorDefault & 67// Complex actor associations
55 PickWith<ActorModel, 'Account', MAccount> &
56 PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
57 68
58export type MActorFullActor = MActorDefault & 69export type MActorDefault = MActor &
59 PickWith<ActorModel, 'Account', MAccountActorDefault> & 70 Use<'Server', MServer> &
60 PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault> 71 Use<'Avatar', MAvatar>
61 72
62export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & 73// Actor with channel that is associated to an account and its actor
63 MActorHost & 74// Actor -> VideoChannel -> Account -> Actor
64 PickWith<ActorModel, 'Avatar', MAvatar> 75export type MActorChannelAccountActor = MActor &
76 Use<'VideoChannel', MChannelAccountActor>
65 77
66export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> & 78export type MActorFull = MActor &
67 PickWith<ActorModel, 'Server', MServerHostBlocks> 79 Use<'Server', MServer> &
80 Use<'Avatar', MAvatar> &
81 Use<'Account', MAccount> &
82 Use<'VideoChannel', MChannelAccountActor>
68 83
69export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> 84// Same than ActorFull, but the account and the channel have their actor
85export 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
95export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
96 Use<'Server', MServerHost> &
97 Use<'Avatar', MAvatar>
98
99export type MActorSummaryBlocks = MActorSummary &
100 Use<'Server', MServerHostBlocks>
70 101
71export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | 102export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
72 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> 103 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
73
74export type MActorSignature = MActorAccountChannelId