]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/video/video-channels.ts
77790daa41947b4e5936efcfa1ae31cc8421449a
[github/Chocobozzz/PeerTube.git] / server / types / models / video / video-channels.ts
1 import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
3 import {
4 MAccountActor,
5 MAccountAPI,
6 MAccountDefault,
7 MAccountFormattable,
8 MAccountLight,
9 MAccountSummaryBlocks,
10 MAccountSummaryFormattable,
11 MAccountUrl,
12 MAccountUserId,
13 MActor,
14 MActorAccountChannelId,
15 MActorAP,
16 MActorAPI,
17 MActorDefault,
18 MActorDefaultLight,
19 MActorFormattable,
20 MActorHost,
21 MActorLight,
22 MActorSummary,
23 MActorSummaryFormattable, MActorUrl
24 } from '../account'
25 import { MVideo } from './video'
26
27 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
28
29 // ############################################################################
30
31 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
32
33 // ############################################################################
34
35 export type MChannelId = Pick<MChannel, 'id'>
36
37 // ############################################################################
38
39 export type MChannelIdActor =
40 MChannelId &
41 Use<'Actor', MActorAccountChannelId>
42
43 export type MChannelUserId =
44 Pick<MChannel, 'accountId'> &
45 Use<'Account', MAccountUserId>
46
47 export type MChannelActor =
48 MChannel &
49 Use<'Actor', MActor>
50
51 export type MChannelUrl = Use<'Actor', MActorUrl>
52
53 // Default scope
54 export type MChannelDefault =
55 MChannel &
56 Use<'Actor', MActorDefault>
57
58 // ############################################################################
59
60 // Not all association attributes
61
62 export type MChannelLight =
63 MChannel &
64 Use<'Actor', MActorDefaultLight>
65
66 export type MChannelActorLight =
67 MChannel &
68 Use<'Actor', MActorLight>
69
70 export type MChannelAccountLight =
71 MChannel &
72 Use<'Actor', MActorDefaultLight> &
73 Use<'Account', MAccountLight>
74
75 export type MChannelHost =
76 MChannelId &
77 Use<'Actor', MActorHost>
78
79 // ############################################################################
80
81 // Account associations
82
83 export type MChannelAccountActor =
84 MChannel &
85 Use<'Account', MAccountActor>
86
87 export type MChannelAccountDefault =
88 MChannel &
89 Use<'Actor', MActorDefault> &
90 Use<'Account', MAccountDefault>
91
92 export type MChannelActorAccountActor =
93 MChannel &
94 Use<'Account', MAccountActor> &
95 Use<'Actor', MActor>
96
97 // ############################################################################
98
99 // Videos associations
100 export type MChannelVideos =
101 MChannel &
102 Use<'Videos', MVideo[]>
103
104 export type MChannelActorAccountDefaultVideos =
105 MChannel &
106 Use<'Actor', MActorDefault> &
107 Use<'Account', MAccountDefault> &
108 Use<'Videos', MVideo[]>
109
110 // ############################################################################
111
112 // For API
113
114 export type MChannelSummary =
115 FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
117 Use<'Actor', MActorSummary>
118
119 export type MChannelSummaryAccount =
120 MChannelSummary &
121 Use<'Account', MAccountSummaryBlocks>
122
123 export type MChannelAPI =
124 MChannel &
125 Use<'Actor', MActorAPI> &
126 Use<'Account', MAccountAPI>
127
128 // ############################################################################
129
130 // Format for API or AP object
131
132 export type MChannelSummaryFormattable =
133 FunctionProperties<MChannel> &
134 Pick<MChannel, 'id' | 'name'> &
135 Use<'Actor', MActorSummaryFormattable>
136
137 export type MChannelAccountSummaryFormattable =
138 MChannelSummaryFormattable &
139 Use<'Account', MAccountSummaryFormattable>
140
141 export type MChannelFormattable =
142 FunctionProperties<MChannel> &
143 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
144 Use<'Actor', MActorFormattable> &
145 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
146
147 export type MChannelAP =
148 Pick<MChannel, 'name' | 'description' | 'support'> &
149 Use<'Actor', MActorAP> &
150 Use<'Account', MAccountUrl>