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