]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/video/video-channels.ts
Cleanup model types
[github/Chocobozzz/PeerTube.git] / server / typings / models / video / video-channels.ts
1 import { PickWith } from '../../utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
3 import {
4 MAccountActor,
5 MAccountAPI,
6 MAccountDefault,
7 MAccountLight,
8 MAccountSummaryBlocks,
9 MAccountUserId,
10 MActor,
11 MActorAccountChannelId,
12 MActorAPI,
13 MActorDefault,
14 MActorDefaultLight,
15 MActorLight,
16 MActorSummary
17 } from '../account'
18 import { MVideo } from './video'
19
20 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
21
22 // ############################################################################
23
24 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
25
26 // ############################################################################
27
28 export type MChannelId = Pick<MChannel, 'id'>
29
30 // ############################################################################
31
32 export type MChannelIdActor = MChannelId &
33 Use<'Actor', MActorAccountChannelId>
34
35 export type MChannelUserId = Pick<MChannel, 'accountId'> &
36 Use<'Account', MAccountUserId>
37
38 export type MChannelActor = MChannel &
39 Use<'Actor', MActor>
40
41 // Default scope
42 export type MChannelDefault = MChannel &
43 Use<'Actor', MActorDefault>
44
45 // ############################################################################
46
47 // Not all association attributes
48
49 export type MChannelLight = MChannel &
50 Use<'Actor', MActorDefaultLight>
51
52 export type MChannelActorLight = MChannel &
53 Use<'Actor', MActorLight>
54
55 export type MChannelAccountLight = MChannel &
56 Use<'Actor', MActorDefaultLight> &
57 Use<'Account', MAccountLight>
58
59 // ############################################################################
60
61 // Account associations
62
63 export type MChannelAccountActor = MChannel &
64 Use<'Account', MAccountActor>
65
66 export type MChannelAccountDefault = MChannel &
67 Use<'Actor', MActorDefault> &
68 Use<'Account', MAccountDefault>
69
70 export type MChannelActorAccountActor = MChannel &
71 Use<'Account', MAccountActor> &
72 Use<'Actor', MActor>
73
74 // ############################################################################
75
76 // Videos associations
77 export type MChannelVideos = MChannel &
78 Use<'Videos', MVideo[]>
79
80 export type MChannelActorAccountDefaultVideos = MChannel &
81 Use<'Actor', MActorDefault> &
82 Use<'Account', MAccountDefault> &
83 Use<'Videos', MVideo[]>
84
85 // ############################################################################
86
87 // For API
88
89 export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
90 Use<'Actor', MActorSummary>
91
92 export type MChannelSummaryAccount = MChannelSummary &
93 Use<'Account', MAccountSummaryBlocks>
94
95 export type MChannelAPI = MChannel &
96 Use<'Actor', MActorAPI> &
97 Use<'Account', MAccountAPI>