]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/account/account.ts
Cleanup model types
[github/Chocobozzz/PeerTube.git] / server / typings / models / account / account.ts
1 import { AccountModel } from '../../../models/account/account'
2 import {
3 MActor,
4 MActorAccountChannelId,
5 MActorAPI,
6 MActorAudience,
7 MActorDefault,
8 MActorDefaultLight,
9 MActorId,
10 MActorServer,
11 MActorSummary,
12 MActorUrl
13 } from './actor'
14 import { PickWith } from '../../utils'
15 import { MAccountBlocklistId } from './account-blocklist'
16 import { MChannelDefault } from '@server/typings/models'
17
18 type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
19
20 // ############################################################################
21
22 export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
23 'VideoComments' | 'BlockedAccounts'>
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
43 // Default scope
44 export type MAccountDefault = MAccount &
45 Use<'Actor', MActorDefault>
46
47 // Default with default association scopes
48 export type MAccountDefaultChannelDefault = MAccount &
49 Use<'Actor', MActorDefault> &
50 Use<'VideoChannels', MChannelDefault[]>
51
52 // We don't need some actors attributes
53 export type MAccountLight = MAccount &
54 Use<'Actor', MActorDefaultLight>
55
56 // ############################################################################
57
58 // Full actor
59 export type MAccountActor = MAccount &
60 Use<'Actor', MActor>
61
62 // Full actor with server
63 export type MAccountServer = MAccount &
64 Use<'Actor', MActorServer>
65
66 // ############################################################################
67
68 // For API
69
70 export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
71 Use<'Actor', MActorSummary>
72
73 export type MAccountSummaryBlocks = MAccountSummary &
74 Use<'BlockedAccounts', MAccountBlocklistId[]>
75
76 export type MAccountAPI = MAccount &
77 Use<'Actor', MActorAPI>