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