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