diff options
Diffstat (limited to 'server/typings/models/account/actor.ts')
-rw-r--r-- | server/typings/models/account/actor.ts | 93 |
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 @@ | |||
1 | import { ActorModel } from '../../../models/activitypub/actor' | 1 | import { ActorModel } from '../../../models/activitypub/actor' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account' | 3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' |
4 | import { MServerHost, MServerHostBlocks, MServer } from '../server' | 4 | import { MServer, MServerHost, MServerHostBlocks } from '../server' |
5 | import { MAvatar } from './avatar' | 5 | import { MAvatar } from './avatar' |
6 | import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video' | 6 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' |
7 | |||
8 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | ||
9 | |||
10 | // ############################################################################ | ||
7 | 11 | ||
8 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | 12 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> |
9 | 13 | ||
14 | // ############################################################################ | ||
15 | |||
10 | export type MActorUrl = Pick<MActor, 'url'> | 16 | export type MActorUrl = Pick<MActor, 'url'> |
11 | export type MActorId = Pick<MActor, 'id'> | 17 | export type MActorId = Pick<MActor, 'id'> |
12 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | 18 | export type MActorUsername = Pick<MActor, 'preferredUsername'> |
13 | export type MActorHost = PickWith<ActorModel, 'Server', MServerHost> | ||
14 | 19 | ||
15 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> | 20 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> |
16 | export type MActorAudience = MActorUrl & MActorFollowersUrl | 21 | export type MActorAudience = MActorUrl & MActorFollowersUrl |
22 | export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> | ||
23 | export type MActorSignature = MActorAccountChannelId | ||
17 | 24 | ||
18 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | 25 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> |
19 | 26 | ||
27 | // ############################################################################ | ||
28 | |||
29 | // Some association attributes | ||
30 | |||
31 | export type MActorHost = Use<'Server', MServerHost> | ||
32 | |||
20 | export type MActorDefaultLight = MActorLight & | 33 | export type MActorDefaultLight = MActorLight & |
21 | MActorHost & | 34 | Use<'Server', MServerHost> & |
22 | PickWith<ActorModel, 'Avatar', MAvatar> | 35 | Use<'Avatar', MAvatar> |
23 | 36 | ||
24 | export type MActorAccountId = MActor & | 37 | export type MActorAccountId = MActor & |
25 | PickWith<ActorModel, 'Account', MAccountId> | 38 | Use<'Account', MAccountId> |
26 | export type MActorAccountIdActor = MActor & | 39 | export type MActorAccountIdActor = MActor & |
27 | PickWith<ActorModel, 'Account', MAccountIdActor> | 40 | Use<'Account', MAccountIdActor> |
28 | 41 | ||
29 | export type MActorChannelId = MActor & | 42 | export type MActorChannelId = MActor & |
30 | PickWith<ActorModel, 'VideoChannel', MChannelId> | 43 | Use<'VideoChannel', MChannelId> |
31 | export type MActorChannelIdActor = MActor & | 44 | export type MActorChannelIdActor = MActor & |
32 | PickWith<ActorModel, 'VideoChannel', MChannelIdActor> | 45 | Use<'VideoChannel', MChannelIdActor> |
33 | 46 | ||
34 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | 47 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId |
35 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | 48 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor |
36 | 49 | ||
50 | // ############################################################################ | ||
51 | |||
52 | // Include raw account/channel/server | ||
53 | |||
37 | export type MActorAccount = MActor & | 54 | export type MActorAccount = MActor & |
38 | PickWith<ActorModel, 'Account', MAccount> | 55 | Use<'Account', MAccount> |
39 | 56 | ||
40 | export type MActorChannel = MActor & | 57 | export type MActorChannel = MActor & |
41 | PickWith<ActorModel, 'VideoChannel', MChannel> | 58 | Use<'VideoChannel', MChannel> |
42 | 59 | ||
43 | export type MActorAccountChannel = MActorAccount & MActorChannel | 60 | export type MActorAccountChannel = MActorAccount & MActorChannel |
44 | 61 | ||
45 | export type MActorChannelAccount = MActor & | ||
46 | PickWith<ActorModel, 'VideoChannel', MChannelAccountActor> | ||
47 | |||
48 | export type MActorServer = MActor & | 62 | export type MActorServer = MActor & |
49 | PickWith<ActorModel, 'Server', MServer> | 63 | Use<'Server', MServer> |
50 | 64 | ||
51 | export type MActorDefault = MActorServer & | 65 | // ############################################################################ |
52 | PickWith<ActorModel, 'Avatar', MAvatar> | ||
53 | 66 | ||
54 | export type MActorFull = MActorDefault & | 67 | // Complex actor associations |
55 | PickWith<ActorModel, 'Account', MAccount> & | ||
56 | PickWith<ActorModel, 'VideoChannel', MChannelAccountActor> | ||
57 | 68 | ||
58 | export type MActorFullActor = MActorDefault & | 69 | export type MActorDefault = MActor & |
59 | PickWith<ActorModel, 'Account', MAccountActorDefault> & | 70 | Use<'Server', MServer> & |
60 | PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault> | 71 | Use<'Avatar', MAvatar> |
61 | 72 | ||
62 | export 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> | 75 | export type MActorChannelAccountActor = MActor & |
76 | Use<'VideoChannel', MChannelAccountActor> | ||
65 | 77 | ||
66 | export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> & | 78 | export 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 | ||
69 | export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> | 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> | ||
70 | 101 | ||
71 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | 102 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | |
72 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | 103 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> |
73 | |||
74 | export type MActorSignature = MActorAccountChannelId | ||