]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/account/account.ts
Add banners support
[github/Chocobozzz/PeerTube.git] / server / types / models / account / account.ts
1 import { FunctionProperties, PickWith } from '@shared/core-utils'
2 import { AccountModel } from '../../../models/account/account'
3 import { MChannelDefault } from '../video/video-channels'
4 import { MAccountBlocklistId } from './account-blocklist'
5 import {
6 MActor,
7 MActorAPAccount,
8 MActorAPI,
9 MActorAudience,
10 MActorDefault,
11 MActorDefaultLight,
12 MActorFormattable,
13 MActorId,
14 MActorServer,
15 MActorSummary,
16 MActorSummaryFormattable,
17 MActorUrl
18 } from './actor'
19
20 type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
21
22 // ############################################################################
23
24 export type MAccount =
25 Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
26 'VideoComments' | 'BlockedAccounts'>
27
28 // ############################################################################
29
30 // Only some attributes
31 export type MAccountId = Pick<MAccount, 'id'>
32 export type MAccountUserId = Pick<MAccount, 'userId'>
33
34 // Only some Actor attributes
35 export type MAccountUrl = Use<'Actor', MActorUrl>
36 export type MAccountAudience = Use<'Actor', MActorAudience>
37
38 export type MAccountIdActor =
39 MAccountId &
40 Use<'Actor', MActor>
41
42 export type MAccountIdActorId =
43 MAccountId &
44 Use<'Actor', MActorId>
45
46 // ############################################################################
47
48 // Default scope
49 export type MAccountDefault =
50 MAccount &
51 Use<'Actor', MActorDefault>
52
53 // Default with default association scopes
54 export type MAccountDefaultChannelDefault =
55 MAccount &
56 Use<'Actor', MActorDefault> &
57 Use<'VideoChannels', MChannelDefault[]>
58
59 // We don't need some actors attributes
60 export type MAccountLight =
61 MAccount &
62 Use<'Actor', MActorDefaultLight>
63
64 // ############################################################################
65
66 // Full actor
67 export type MAccountActor =
68 MAccount &
69 Use<'Actor', MActor>
70
71 // Full actor with server
72 export type MAccountServer =
73 MAccount &
74 Use<'Actor', MActorServer>
75
76 // ############################################################################
77
78 // For API
79
80 export type MAccountSummary =
81 FunctionProperties<MAccount> &
82 Pick<MAccount, 'id' | 'name'> &
83 Use<'Actor', MActorSummary>
84
85 export type MAccountSummaryBlocks =
86 MAccountSummary &
87 Use<'BlockedAccounts', MAccountBlocklistId[]>
88
89 export type MAccountAPI =
90 MAccount &
91 Use<'Actor', MActorAPI>
92
93 // ############################################################################
94
95 // Format for API or AP object
96
97 export type MAccountSummaryFormattable =
98 FunctionProperties<MAccount> &
99 Pick<MAccount, 'id' | 'name'> &
100 Use<'Actor', MActorSummaryFormattable>
101
102 export type MAccountFormattable =
103 FunctionProperties<MAccount> &
104 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
105 Use<'Actor', MActorFormattable>
106
107 export type MAccountAP =
108 Pick<MAccount, 'name' | 'description'> &
109 Use<'Actor', MActorAPAccount>