]>
Commit | Line | Data |
---|---|---|
453e83ea C |
1 | import { VideoModel } from '../../../models/video/video' |
2 | import { PickWith, PickWithOpt } from '../../utils' | |
1ca9f7c3 C |
3 | import { |
4 | MChannelAccountDefault, | |
5 | MChannelAccountLight, | |
6 | MChannelAccountSummaryFormattable, | |
7 | MChannelActor, | |
8 | MChannelFormattable, | |
9 | MChannelUserId | |
10 | } from './video-channels' | |
453e83ea | 11 | import { MTag } from './tag' |
ca6d3622 | 12 | import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption' |
b764380a C |
13 | import { |
14 | MStreamingPlaylistFiles, | |
15 | MStreamingPlaylistRedundancies, | |
16 | MStreamingPlaylistRedundanciesAll, | |
17 | MStreamingPlaylistRedundanciesOpt | |
18 | } from './video-streaming-playlist' | |
19 | import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file' | |
453e83ea | 20 | import { MThumbnail } from './thumbnail' |
1ca9f7c3 | 21 | import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' |
453e83ea C |
22 | import { MScheduleVideoUpdate } from './schedule-video-update' |
23 | import { MUserVideoHistoryTime } from '../user/user-video-history' | |
24 | ||
0283eaac C |
25 | type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M> |
26 | ||
27 | // ############################################################################ | |
28 | ||
a1587156 C |
29 | export type MVideo = |
30 | Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | | |
453e83ea C |
31 | 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' | |
32 | 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'> | |
33 | ||
0283eaac C |
34 | // ############################################################################ |
35 | ||
453e83ea C |
36 | export type MVideoId = Pick<MVideo, 'id'> |
37 | export type MVideoUrl = Pick<MVideo, 'url'> | |
38 | export type MVideoUUID = Pick<MVideo, 'uuid'> | |
39 | ||
7eba5e1f | 40 | export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid'> |
453e83ea C |
41 | export type MVideoIdUrl = MVideoId & MVideoUrl |
42 | export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> | |
43 | ||
0283eaac C |
44 | // ############################################################################ |
45 | ||
46 | // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists | |
47 | ||
48 | // "With" to not confuse with the VideoFile model | |
a1587156 C |
49 | export type MVideoWithFile = |
50 | MVideo & | |
d7a25329 C |
51 | Use<'VideoFiles', MVideoFile[]> & |
52 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> | |
453e83ea | 53 | |
a1587156 C |
54 | export type MVideoThumbnail = |
55 | MVideo & | |
0283eaac C |
56 | Use<'Thumbnails', MThumbnail[]> |
57 | ||
a1587156 C |
58 | export type MVideoIdThumbnail = |
59 | MVideoId & | |
0283eaac C |
60 | Use<'Thumbnails', MThumbnail[]> |
61 | ||
a1587156 C |
62 | export type MVideoWithFileThumbnail = |
63 | MVideo & | |
0283eaac C |
64 | Use<'VideoFiles', MVideoFile[]> & |
65 | Use<'Thumbnails', MThumbnail[]> | |
453e83ea | 66 | |
a1587156 C |
67 | export type MVideoThumbnailBlacklist = |
68 | MVideo & | |
d636ab58 C |
69 | Use<'Thumbnails', MThumbnail[]> & |
70 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
71 | ||
a1587156 C |
72 | export type MVideoTag = |
73 | MVideo & | |
0283eaac | 74 | Use<'Tags', MTag[]> |
453e83ea | 75 | |
a1587156 C |
76 | export type MVideoWithSchedule = |
77 | MVideo & | |
453e83ea C |
78 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> |
79 | ||
a1587156 C |
80 | export type MVideoWithCaptions = |
81 | MVideo & | |
0283eaac | 82 | Use<'VideoCaptions', MVideoCaptionLanguage[]> |
453e83ea | 83 | |
a1587156 C |
84 | export type MVideoWithStreamingPlaylist = |
85 | MVideo & | |
d7a25329 | 86 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
453e83ea | 87 | |
0283eaac C |
88 | // ############################################################################ |
89 | ||
90 | // Associations with not all their attributes | |
91 | ||
a1587156 C |
92 | export type MVideoUserHistory = |
93 | MVideo & | |
0283eaac | 94 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> |
453e83ea | 95 | |
a1587156 C |
96 | export type MVideoWithBlacklistLight = |
97 | MVideo & | |
0283eaac | 98 | Use<'VideoBlacklist', MVideoBlacklistLight> |
453e83ea | 99 | |
a1587156 C |
100 | export type MVideoAccountLight = |
101 | MVideo & | |
0283eaac | 102 | Use<'VideoChannel', MChannelAccountLight> |
453e83ea | 103 | |
a1587156 C |
104 | export type MVideoWithRights = |
105 | MVideo & | |
0283eaac C |
106 | Use<'VideoBlacklist', MVideoBlacklistLight> & |
107 | Use<'Thumbnails', MThumbnail[]> & | |
108 | Use<'VideoChannel', MChannelUserId> | |
453e83ea | 109 | |
0283eaac | 110 | // ############################################################################ |
453e83ea | 111 | |
0283eaac | 112 | // All files with some additional associations |
453e83ea | 113 | |
a1587156 C |
114 | export type MVideoWithAllFiles = |
115 | MVideo & | |
0283eaac C |
116 | Use<'VideoFiles', MVideoFile[]> & |
117 | Use<'Thumbnails', MThumbnail[]> & | |
d7a25329 | 118 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
453e83ea | 119 | |
a1587156 C |
120 | export type MVideoAccountLightBlacklistAllFiles = |
121 | MVideo & | |
0283eaac C |
122 | Use<'VideoFiles', MVideoFile[]> & |
123 | Use<'Thumbnails', MThumbnail[]> & | |
d7a25329 | 124 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & |
0283eaac C |
125 | Use<'VideoChannel', MChannelAccountLight> & |
126 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
453e83ea | 127 | |
0283eaac C |
128 | // ############################################################################ |
129 | ||
130 | // With account | |
453e83ea | 131 | |
a1587156 C |
132 | export type MVideoAccountDefault = |
133 | MVideo & | |
0283eaac | 134 | Use<'VideoChannel', MChannelAccountDefault> |
453e83ea | 135 | |
a1587156 C |
136 | export type MVideoThumbnailAccountDefault = |
137 | MVideo & | |
0283eaac C |
138 | Use<'Thumbnails', MThumbnail[]> & |
139 | Use<'VideoChannel', MChannelAccountDefault> | |
453e83ea | 140 | |
a1587156 C |
141 | export type MVideoWithChannelActor = |
142 | MVideo & | |
0283eaac C |
143 | Use<'VideoChannel', MChannelActor> |
144 | ||
a1587156 C |
145 | export type MVideoFullLight = |
146 | MVideo & | |
0283eaac C |
147 | Use<'Thumbnails', MThumbnail[]> & |
148 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
149 | Use<'Tags', MTag[]> & | |
150 | Use<'VideoChannel', MChannelAccountLight> & | |
151 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | |
152 | Use<'VideoFiles', MVideoFile[]> & | |
153 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
d7a25329 | 154 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
0283eaac C |
155 | |
156 | // ############################################################################ | |
157 | ||
158 | // API | |
453e83ea | 159 | |
a1587156 C |
160 | export type MVideoAP = |
161 | MVideo & | |
0283eaac C |
162 | Use<'Tags', MTag[]> & |
163 | Use<'VideoChannel', MChannelAccountLight> & | |
d7a25329 | 164 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & |
ca6d3622 | 165 | Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> & |
0283eaac | 166 | Use<'VideoBlacklist', MVideoBlacklistUnfederated> & |
d7a25329 C |
167 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> & |
168 | Use<'Thumbnails', MThumbnail[]> | |
453e83ea C |
169 | |
170 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | |
171 | ||
a1587156 C |
172 | export type MVideoDetails = |
173 | MVideo & | |
0283eaac C |
174 | Use<'VideoBlacklist', MVideoBlacklistLight> & |
175 | Use<'Tags', MTag[]> & | |
176 | Use<'VideoChannel', MChannelAccountLight> & | |
177 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
178 | Use<'Thumbnails', MThumbnail[]> & | |
179 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | |
180 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | |
181 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | |
182 | ||
a1587156 C |
183 | export type MVideoForUser = |
184 | MVideo & | |
0283eaac C |
185 | Use<'VideoChannel', MChannelAccountDefault> & |
186 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
187 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
188 | Use<'Thumbnails', MThumbnail[]> | |
1ca9f7c3 | 189 | |
a1587156 C |
190 | export type MVideoForRedundancyAPI = |
191 | MVideo & | |
b764380a C |
192 | Use<'VideoFiles', MVideoFileRedundanciesAll[]> & |
193 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]> | |
194 | ||
1ca9f7c3 C |
195 | // ############################################################################ |
196 | ||
197 | // Format for API or AP object | |
198 | ||
a1587156 C |
199 | export type MVideoFormattable = |
200 | MVideo & | |
1ca9f7c3 C |
201 | PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> & |
202 | Use<'VideoChannel', MChannelAccountSummaryFormattable> & | |
203 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> & | |
204 | PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>> | |
205 | ||
a1587156 C |
206 | export type MVideoFormattableDetails = |
207 | MVideoFormattable & | |
1ca9f7c3 C |
208 | Use<'VideoChannel', MChannelFormattable> & |
209 | Use<'Tags', MTag[]> & | |
b5fecbf4 | 210 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & |
1ca9f7c3 | 211 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |