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