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