1 import { PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoModel } from '../../../models/video/video'
3 import { MTrackerUrl } from '../server/tracker'
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'
11 MChannelAccountDefault,
13 MChannelAccountSummaryFormattable,
18 } from './video-channels'
19 import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
20 import { MVideoLive } from './video-live'
22 MStreamingPlaylistFiles,
23 MStreamingPlaylistRedundancies,
24 MStreamingPlaylistRedundanciesAll,
25 MStreamingPlaylistRedundanciesOpt
26 } from './video-streaming-playlist'
28 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
30 // ############################################################################
33 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
34 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
35 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions' | 'VideoLive' | 'Trackers'>
37 // ############################################################################
39 export type MVideoId = Pick<MVideo, 'id'>
40 export type MVideoUrl = Pick<MVideo, 'url'>
41 export type MVideoUUID = Pick<MVideo, 'uuid'>
43 export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
44 export type MVideoIdUrl = MVideoId & MVideoUrl
45 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
47 // ############################################################################
49 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
51 // "With" to not confuse with the VideoFile model
52 export type MVideoWithFile =
54 Use<'VideoFiles', MVideoFile[]> &
55 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
57 export type MVideoThumbnail =
59 Use<'Thumbnails', MThumbnail[]>
61 export type MVideoIdThumbnail =
63 Use<'Thumbnails', MThumbnail[]>
65 export type MVideoWithFileThumbnail =
67 Use<'VideoFiles', MVideoFile[]> &
68 Use<'Thumbnails', MThumbnail[]>
70 export type MVideoThumbnailBlacklist =
72 Use<'Thumbnails', MThumbnail[]> &
73 Use<'VideoBlacklist', MVideoBlacklistLight>
75 export type MVideoTag =
79 export type MVideoWithSchedule =
81 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
83 export type MVideoWithCaptions =
85 Use<'VideoCaptions', MVideoCaptionLanguage[]>
87 export type MVideoWithStreamingPlaylist =
89 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
91 // ############################################################################
93 // Associations with not all their attributes
95 export type MVideoUserHistory =
97 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
99 export type MVideoWithBlacklistLight =
101 Use<'VideoBlacklist', MVideoBlacklistLight>
103 export type MVideoAccountLight =
105 Use<'VideoChannel', MChannelAccountLight>
107 export type MVideoWithRights =
109 Use<'VideoBlacklist', MVideoBlacklistLight> &
110 Use<'VideoChannel', MChannelUserId>
112 // ############################################################################
114 // All files with some additional associations
116 export type MVideoWithAllFiles =
118 Use<'VideoFiles', MVideoFile[]> &
119 Use<'Thumbnails', MThumbnail[]> &
120 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
122 export type MVideoAccountLightBlacklistAllFiles =
124 Use<'VideoFiles', MVideoFile[]> &
125 Use<'Thumbnails', MThumbnail[]> &
126 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
127 Use<'VideoChannel', MChannelAccountLight> &
128 Use<'VideoBlacklist', MVideoBlacklistLight>
130 // ############################################################################
134 export type MVideoAccountDefault =
136 Use<'VideoChannel', MChannelAccountDefault>
138 export type MVideoThumbnailAccountDefault =
140 Use<'Thumbnails', MThumbnail[]> &
141 Use<'VideoChannel', MChannelAccountDefault>
143 export type MVideoWithChannelActor =
145 Use<'VideoChannel', MChannelActor>
147 export type MVideoWithHost =
149 Use<'VideoChannel', MChannelHost>
151 export type MVideoFullLight =
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> &
160 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
161 Use<'VideoLive', MVideoLive>
163 // ############################################################################
167 export type MVideoAP =
169 Use<'Tags', MTag[]> &
170 Use<'VideoChannel', MChannelAccountLight> &
171 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
172 Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
173 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
174 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
175 Use<'Thumbnails', MThumbnail[]> &
176 Use<'VideoLive', MVideoLive>
178 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
180 export type MVideoDetails =
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[]> &
189 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
190 Use<'Trackers', MTrackerUrl[]>
192 export type MVideoForUser =
194 Use<'VideoChannel', MChannelAccountDefault> &
195 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
196 Use<'VideoBlacklist', MVideoBlacklistLight> &
197 Use<'Thumbnails', MThumbnail[]>
199 export type MVideoForRedundancyAPI =
201 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
202 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
204 // ############################################################################
206 // Format for API or AP object
208 export type MVideoFormattable =
210 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
211 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
212 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
213 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>> &
214 PickWithOpt<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
215 PickWithOpt<VideoModel, 'VideoFiles', MVideoFile[]>
217 export type MVideoFormattableDetails =
219 Use<'VideoChannel', MChannelFormattable> &
220 Use<'Tags', MTag[]> &
221 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
222 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
223 PickWithOpt<VideoModel, 'Trackers', MTrackerUrl[]>