aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/account/account.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-18 10:45:25 +0200
committerChocobozzz <me@florianbigard.com>2020-06-18 10:46:27 +0200
commit26d6bf6533023326fa017812cf31bbe20c752d36 (patch)
tree9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types/models/account/account.ts
parentd6d951ddc0c492f3261065b5dcb4df0534d252fc (diff)
downloadPeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip
Split types and typings
Diffstat (limited to 'server/types/models/account/account.ts')
-rw-r--r--server/types/models/account/account.ts109
1 files changed, 109 insertions, 0 deletions
diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts
new file mode 100644
index 000000000..7b826ee04
--- /dev/null
+++ b/server/types/models/account/account.ts
@@ -0,0 +1,109 @@
1import { AccountModel } from '../../../models/account/account'
2import {
3 MActor,
4 MActorAP,
5 MActorAPI,
6 MActorAudience,
7 MActorDefault,
8 MActorDefaultLight,
9 MActorFormattable,
10 MActorId,
11 MActorServer,
12 MActorSummary,
13 MActorSummaryFormattable,
14 MActorUrl
15} from './actor'
16import { FunctionProperties, PickWith } from '../../utils'
17import { MAccountBlocklistId } from './account-blocklist'
18import { MChannelDefault } from '../video/video-channels'
19
20type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
21
22// ############################################################################
23
24export type MAccount =
25 Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
26 'VideoComments' | 'BlockedAccounts'>
27
28// ############################################################################
29
30// Only some attributes
31export type MAccountId = Pick<MAccount, 'id'>
32export type MAccountUserId = Pick<MAccount, 'userId'>
33
34// Only some Actor attributes
35export type MAccountUrl = Use<'Actor', MActorUrl>
36export type MAccountAudience = Use<'Actor', MActorAudience>
37
38export type MAccountIdActor =
39 MAccountId &
40 Use<'Actor', MActor>
41
42export type MAccountIdActorId =
43 MAccountId &
44 Use<'Actor', MActorId>
45
46// ############################################################################
47
48// Default scope
49export type MAccountDefault =
50 MAccount &
51 Use<'Actor', MActorDefault>
52
53// Default with default association scopes
54export type MAccountDefaultChannelDefault =
55 MAccount &
56 Use<'Actor', MActorDefault> &
57 Use<'VideoChannels', MChannelDefault[]>
58
59// We don't need some actors attributes
60export type MAccountLight =
61 MAccount &
62 Use<'Actor', MActorDefaultLight>
63
64// ############################################################################
65
66// Full actor
67export type MAccountActor =
68 MAccount &
69 Use<'Actor', MActor>
70
71// Full actor with server
72export type MAccountServer =
73 MAccount &
74 Use<'Actor', MActorServer>
75
76// ############################################################################
77
78// For API
79
80export type MAccountSummary =
81 FunctionProperties<MAccount> &
82 Pick<MAccount, 'id' | 'name'> &
83 Use<'Actor', MActorSummary>
84
85export type MAccountSummaryBlocks =
86 MAccountSummary &
87 Use<'BlockedAccounts', MAccountBlocklistId[]>
88
89export type MAccountAPI =
90 MAccount &
91 Use<'Actor', MActorAPI>
92
93// ############################################################################
94
95// Format for API or AP object
96
97export type MAccountSummaryFormattable =
98 FunctionProperties<MAccount> &
99 Pick<MAccount, 'id' | 'name'> &
100 Use<'Actor', MActorSummaryFormattable>
101
102export type MAccountFormattable =
103 FunctionProperties<MAccount> &
104 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
105 Use<'Actor', MActorFormattable>
106
107export type MAccountAP =
108 Pick<MAccount, 'name' | 'description'> &
109 Use<'Actor', MActorAP>