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