aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/account/account.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/models/account/account.ts')
-rw-r--r--server/typings/models/account/account.ts69
1 files changed, 45 insertions, 24 deletions
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>