]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/account/account.ts
Add Podcast RSS feeds (#5487)
[github/Chocobozzz/PeerTube.git] / server / types / models / account / account.ts
1 import { FunctionProperties, PickWith } from '@shared/typescript-utils'
2 import { AccountModel } from '../../../models/account/account'
3 import {
4 MActor,
5 MActorAPAccount,
6 MActorAPI,
7 MActorAudience,
8 MActorDefault,
9 MActorDefaultLight,
10 MActorFormattable,
11 MActorHost,
12 MActorId,
13 MActorSummary,
14 MActorSummaryFormattable,
15 MActorUrl
16 } from '../actor'
17 import { MChannelDefault } from '../video/video-channels'
18 import { MAccountBlocklistId } from './account-blocklist'
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' | 'BlockedBy'>
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 export type MAccountHost =
72 MAccount &
73 Use<'Actor', MActorHost>
74
75 // ############################################################################
76
77 // For API
78
79 export type MAccountSummary =
80 FunctionProperties<MAccount> &
81 Pick<MAccount, 'id' | 'name'> &
82 Use<'Actor', MActorSummary>
83
84 export type MAccountSummaryBlocks =
85 MAccountSummary &
86 Use<'BlockedBy', MAccountBlocklistId[]>
87
88 export type MAccountAPI =
89 MAccount &
90 Use<'Actor', MActorAPI>
91
92 // ############################################################################
93
94 // Format for API or AP object
95
96 export type MAccountSummaryFormattable =
97 FunctionProperties<MAccount> &
98 Pick<MAccount, 'id' | 'name'> &
99 Use<'Actor', MActorSummaryFormattable>
100
101 export type MAccountFormattable =
102 FunctionProperties<MAccount> &
103 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
104 Use<'Actor', MActorFormattable>
105
106 export type MAccountAP =
107 Pick<MAccount, 'name' | 'description'> &
108 Use<'Actor', MActorAPAccount>