diff options
Diffstat (limited to 'server/typings/models/account/account.ts')
-rw-r--r-- | server/typings/models/account/account.ts | 69 |
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' | |||
14 | import { MAccountBlocklistId } from './account-blocklist' | 15 | import { MAccountBlocklistId } from './account-blocklist' |
15 | import { MChannelDefault } from '@server/typings/models' | 16 | import { MChannelDefault } from '@server/typings/models' |
16 | 17 | ||
17 | export type MAccountId = Pick<AccountModel, 'id'> | 18 | type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> |
18 | export type MAccountIdActor = MAccountId & | 19 | |
19 | PickWith<AccountModel, 'Actor', MActorAccountChannelId> | 20 | // ############################################################################ |
20 | export type MAccountIdActorId = MAccountId & | ||
21 | PickWith<AccountModel, 'Actor', MActorId> | ||
22 | 21 | ||
23 | export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | | 22 | export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | |
24 | 'VideoComments' | 'BlockedAccounts'> | 23 | 'VideoComments' | 'BlockedAccounts'> |
25 | 24 | ||
25 | // ############################################################################ | ||
26 | |||
27 | // Only some attributes | ||
28 | export type MAccountId = Pick<MAccount, 'id'> | ||
29 | export type MAccountUserId = Pick<MAccount, 'userId'> | ||
30 | |||
31 | // Only some Actor attributes | ||
32 | export type MAccountUrl = Use<'Actor', MActorUrl> | ||
33 | export type MAccountAudience = Use<'Actor', MActorAudience> | ||
34 | |||
35 | export type MAccountIdActor = MAccountId & | ||
36 | Use<'Actor', MActorAccountChannelId> | ||
37 | |||
38 | export type MAccountIdActorId = MAccountId & | ||
39 | Use<'Actor', MActorId> | ||
40 | |||
41 | // ############################################################################ | ||
42 | |||
26 | // Default scope | 43 | // Default scope |
27 | export type MAccountDefault = MAccount & | 44 | export type MAccountDefault = MAccount & |
28 | PickWith<AccountModel, 'Actor', MActorDefault> | 45 | Use<'Actor', MActorDefault> |
29 | 46 | ||
30 | export type MAccountDefaultChannelDefault = MAccountDefault & | 47 | // Default with default association scopes |
31 | PickWith<AccountModel, 'VideoChannels', MChannelDefault[]> | 48 | export type MAccountDefaultChannelDefault = MAccount & |
49 | Use<'Actor', MActorDefault> & | ||
50 | Use<'VideoChannels', MChannelDefault[]> | ||
32 | 51 | ||
52 | // We don't need some actors attributes | ||
33 | export type MAccountLight = MAccount & | 53 | export type MAccountLight = MAccount & |
34 | PickWith<AccountModel, 'Actor', MActorDefaultLight> | 54 | Use<'Actor', MActorDefaultLight> |
35 | 55 | ||
36 | export type MAccountUserId = Pick<MAccount, 'userId'> | 56 | // ############################################################################ |
37 | 57 | ||
58 | // Full actor | ||
38 | export type MAccountActor = MAccount & | 59 | export type MAccountActor = MAccount & |
39 | PickWith<AccountModel, 'Actor', MActor> | 60 | Use<'Actor', MActor> |
40 | export type MAccountServer = MAccountActor & | ||
41 | PickWith<AccountModel, 'Actor', MActorServer> | ||
42 | 61 | ||
43 | export type MAccountActorDefault = MAccount & | 62 | // Full actor with server |
44 | PickWith<AccountModel, 'Actor', MActorDefault> | 63 | export type MAccountServer = MAccount & |
64 | Use<'Actor', MActorServer> | ||
45 | 65 | ||
46 | export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & | 66 | // ############################################################################ |
47 | PickWith<AccountModel, 'Actor', MActorSummary> | ||
48 | 67 | ||
49 | export type MAccountBlocks = MAccountSummary & | 68 | // For API |
50 | PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]> | 69 | |
70 | export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & | ||
71 | Use<'Actor', MActorSummary> | ||
51 | 72 | ||
52 | export type MAccountAPI = MAccountDefault & | 73 | export type MAccountSummaryBlocks = MAccountSummary & |
53 | PickWith<AccountModel, 'Actor', MActorAPI> | 74 | Use<'BlockedAccounts', MAccountBlocklistId[]> |
54 | 75 | ||
55 | export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl> | 76 | export type MAccountAPI = MAccount & |
56 | export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience> | 77 | Use<'Actor', MActorAPI> |