aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/models/account')
-rw-r--r--server/typings/models/account/account-blocklist.ts10
-rw-r--r--server/typings/models/account/account.ts69
-rw-r--r--server/typings/models/account/actor-follow.ts56
-rw-r--r--server/typings/models/account/actor.ts93
4 files changed, 156 insertions, 72 deletions
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts
index 6d1771de8..d20d97aa8 100644
--- a/server/typings/models/account/account-blocklist.ts
+++ b/server/typings/models/account/account-blocklist.ts
@@ -2,10 +2,16 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccountDefault } from './account' 3import { MAccountDefault } from './account'
4 4
5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
6
7// ############################################################################
8
5export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'> 9export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
6 10
11// ############################################################################
12
7export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'> 13export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
8 14
9export type MAccountBlocklistAccounts = MAccountBlocklist & 15export type MAccountBlocklistAccounts = MAccountBlocklist &
10 PickWith<AccountBlocklistModel, 'ByAccount', MAccountDefault> & 16 Use<'ByAccount', MAccountDefault> &
11 PickWith<AccountBlocklistModel, 'BlockedAccount', MAccountDefault> 17 Use<'BlockedAccount', MAccountDefault>
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts
index f3646d510..9a8784e6b 100644
--- a/server/typings/models/account/account.ts
+++ b/server/typings/models/account/account.ts
@@ -5,7 +5,8 @@ import {
5 MActorAPI, 5 MActorAPI,
6 MActorAudience, 6 MActorAudience,
7 MActorDefault, 7 MActorDefault,
8 MActorDefaultLight, MActorId, 8 MActorDefaultLight,
9 MActorId,
9 MActorServer, 10 MActorServer,
10 MActorSummary, 11 MActorSummary,
11 MActorUrl 12 MActorUrl
@@ -14,43 +15,63 @@ import { PickWith } from '../../utils'
14import { MAccountBlocklistId } from './account-blocklist' 15import { MAccountBlocklistId } from './account-blocklist'
15import { MChannelDefault } from '@server/typings/models' 16import { MChannelDefault } from '@server/typings/models'
16 17
17export type MAccountId = Pick<AccountModel, 'id'> 18type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
18export type MAccountIdActor = MAccountId & 19
19 PickWith<AccountModel, 'Actor', MActorAccountChannelId> 20// ############################################################################
20export type MAccountIdActorId = MAccountId &
21 PickWith<AccountModel, 'Actor', MActorId>
22 21
23export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | 22export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
24 'VideoComments' | 'BlockedAccounts'> 23 'VideoComments' | 'BlockedAccounts'>
25 24
25// ############################################################################
26
27// Only some attributes
28export type MAccountId = Pick<MAccount, 'id'>
29export type MAccountUserId = Pick<MAccount, 'userId'>
30
31// Only some Actor attributes
32export type MAccountUrl = Use<'Actor', MActorUrl>
33export type MAccountAudience = Use<'Actor', MActorAudience>
34
35export type MAccountIdActor = MAccountId &
36 Use<'Actor', MActorAccountChannelId>
37
38export type MAccountIdActorId = MAccountId &
39 Use<'Actor', MActorId>
40
41// ############################################################################
42
26// Default scope 43// Default scope
27export type MAccountDefault = MAccount & 44export type MAccountDefault = MAccount &
28 PickWith<AccountModel, 'Actor', MActorDefault> 45 Use<'Actor', MActorDefault>
29 46
30export type MAccountDefaultChannelDefault = MAccountDefault & 47// Default with default association scopes
31 PickWith<AccountModel, 'VideoChannels', MChannelDefault[]> 48export type MAccountDefaultChannelDefault = MAccount &
49 Use<'Actor', MActorDefault> &
50 Use<'VideoChannels', MChannelDefault[]>
32 51
52// We don't need some actors attributes
33export type MAccountLight = MAccount & 53export type MAccountLight = MAccount &
34 PickWith<AccountModel, 'Actor', MActorDefaultLight> 54 Use<'Actor', MActorDefaultLight>
35 55
36export type MAccountUserId = Pick<MAccount, 'userId'> 56// ############################################################################
37 57
58// Full actor
38export type MAccountActor = MAccount & 59export type MAccountActor = MAccount &
39 PickWith<AccountModel, 'Actor', MActor> 60 Use<'Actor', MActor>
40export type MAccountServer = MAccountActor &
41 PickWith<AccountModel, 'Actor', MActorServer>
42 61
43export type MAccountActorDefault = MAccount & 62// Full actor with server
44 PickWith<AccountModel, 'Actor', MActorDefault> 63export type MAccountServer = MAccount &
64 Use<'Actor', MActorServer>
45 65
46export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & 66// ############################################################################
47 PickWith<AccountModel, 'Actor', MActorSummary>
48 67
49export type MAccountBlocks = MAccountSummary & 68// For API
50 PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]> 69
70export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
71 Use<'Actor', MActorSummary>
51 72
52export type MAccountAPI = MAccountDefault & 73export type MAccountSummaryBlocks = MAccountSummary &
53 PickWith<AccountModel, 'Actor', MActorAPI> 74 Use<'BlockedAccounts', MAccountBlocklistId[]>
54 75
55export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl> 76export type MAccountAPI = MAccount &
56export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience> 77 Use<'Actor', MActorAPI>
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts
index 96c53d857..87050ac63 100644
--- a/server/typings/models/account/actor-follow.ts
+++ b/server/typings/models/account/actor-follow.ts
@@ -1,27 +1,55 @@
1import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 1import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2import { MActor, MActorAccountChannel, MActorChannel, MActorChannelAccount, MActorDefault, MActorHost, MActorUsername } from './actor' 2import {
3 MActor,
4 MActorAccount,
5 MActorAccountChannel,
6 MActorChannel,
7 MActorChannelAccountActor,
8 MActorDefault,
9 MActorHost,
10 MActorUsername
11} from './actor'
3import { PickWith } from '../../utils' 12import { PickWith } from '../../utils'
13import { ActorModel } from '@server/models/activitypub/actor'
14
15type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
16
17// ############################################################################
4 18
5export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> 19export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
6 20
21// ############################################################################
22
23export type MActorFollowFollowingHost = MActorFollow &
24 Use<'ActorFollowing', MActorUsername & MActorHost>
25
26// ############################################################################
27
28// With actors or actors default
29
7export type MActorFollowActors = MActorFollow & 30export type MActorFollowActors = MActorFollow &
8 PickWith<ActorFollowModel, 'ActorFollower', MActor> & 31 Use<'ActorFollower', MActor> &
9 PickWith<ActorFollowModel, 'ActorFollowing', MActor> 32 Use<'ActorFollowing', MActor>
10 33
11export type MActorFollowActorsDefault = MActorFollow & 34export type MActorFollowActorsDefault = MActorFollow &
12 PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> & 35 Use<'ActorFollower', MActorDefault> &
13 PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault> 36 Use<'ActorFollowing', MActorDefault>
14
15export type MActorFollowActorsDefaultSubscription = MActorFollow &
16 PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> &
17 PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault & MActorChannel>
18 37
19export type MActorFollowFull = MActorFollow & 38export type MActorFollowFull = MActorFollow &
20 PickWith<ActorFollowModel, 'ActorFollower', MActorAccountChannel> & 39 Use<'ActorFollower', MActorAccountChannel> &
21 PickWith<ActorFollowModel, 'ActorFollowing', MActorAccountChannel> 40 Use<'ActorFollowing', MActorAccountChannel>
22 41
23export type MActorFollowFollowingHost = MActorFollow & 42// ############################################################################
24 PickWith<ActorFollowModel, 'ActorFollowing', MActorUsername & MActorHost> 43
44// For subscriptions
45
46export type MActorFollowActorsDefaultSubscription = MActorFollow &
47 Use<'ActorFollower', MActorDefault> &
48 Use<'ActorFollowing', MActorDefault & MActorChannel>
49
50export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
51 Use<'ActorFollower', MActorAccount> &
52 Use<'ActorFollowing', MActorAccountChannel>
25 53
26export type MActorFollowSubscriptions = MActorFollow & 54export type MActorFollowSubscriptions = MActorFollow &
27 PickWith<ActorFollowModel, 'ActorFollowing', MActorChannelAccount> 55 Use<'ActorFollowing', MActorChannelAccountActor>
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