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