1 import { VideoModel } from '../../../models/video/video'
2 import { PickWith, PickWithOpt } from '../../utils'
4 MChannelAccountDefault,
6 MChannelAccountSummaryFormattable,
10 } from './video-channels'
11 import { MTag } from './tag'
12 import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
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'
25 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
27 // ############################################################################
30 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
31 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
32 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
34 // ############################################################################
36 export type MVideoId = Pick<MVideo, 'id'>
37 export type MVideoUrl = Pick<MVideo, 'url'>
38 export type MVideoUUID = Pick<MVideo, 'uuid'>
40 export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
41 export type MVideoIdUrl = MVideoId & MVideoUrl
42 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
44 // ############################################################################
46 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
48 // "With" to not confuse with the VideoFile model
49 export type MVideoWithFile =
51 Use<'VideoFiles', MVideoFile[]> &
52 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
54 export type MVideoThumbnail =
56 Use<'Thumbnails', MThumbnail[]>
58 export type MVideoIdThumbnail =
60 Use<'Thumbnails', MThumbnail[]>
62 export type MVideoWithFileThumbnail =
64 Use<'VideoFiles', MVideoFile[]> &
65 Use<'Thumbnails', MThumbnail[]>
67 export type MVideoThumbnailBlacklist =
69 Use<'Thumbnails', MThumbnail[]> &
70 Use<'VideoBlacklist', MVideoBlacklistLight>
72 export type MVideoTag =
76 export type MVideoWithSchedule =
78 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
80 export type MVideoWithCaptions =
82 Use<'VideoCaptions', MVideoCaptionLanguage[]>
84 export type MVideoWithStreamingPlaylist =
86 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
88 // ############################################################################
90 // Associations with not all their attributes
92 export type MVideoUserHistory =
94 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
96 export type MVideoWithBlacklistLight =
98 Use<'VideoBlacklist', MVideoBlacklistLight>
100 export type MVideoAccountLight =
102 Use<'VideoChannel', MChannelAccountLight>
104 export type MVideoWithRights =
106 Use<'VideoBlacklist', MVideoBlacklistLight> &
107 Use<'Thumbnails', MThumbnail[]> &
108 Use<'VideoChannel', MChannelUserId>
110 // ############################################################################
112 // All files with some additional associations
114 export type MVideoWithAllFiles =
116 Use<'VideoFiles', MVideoFile[]> &
117 Use<'Thumbnails', MThumbnail[]> &
118 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
120 export type MVideoAccountLightBlacklistAllFiles =
122 Use<'VideoFiles', MVideoFile[]> &
123 Use<'Thumbnails', MThumbnail[]> &
124 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
125 Use<'VideoChannel', MChannelAccountLight> &
126 Use<'VideoBlacklist', MVideoBlacklistLight>
128 // ############################################################################
132 export type MVideoAccountDefault =
134 Use<'VideoChannel', MChannelAccountDefault>
136 export type MVideoThumbnailAccountDefault =
138 Use<'Thumbnails', MThumbnail[]> &
139 Use<'VideoChannel', MChannelAccountDefault>
141 export type MVideoWithChannelActor =
143 Use<'VideoChannel', MChannelActor>
145 export type MVideoFullLight =
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> &
154 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
156 // ############################################################################
160 export type MVideoAP =
162 Use<'Tags', MTag[]> &
163 Use<'VideoChannel', MChannelAccountLight> &
164 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
165 Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
166 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
167 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
168 Use<'Thumbnails', MThumbnail[]>
170 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
172 export type MVideoDetails =
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[]>
183 export type MVideoForUser =
185 Use<'VideoChannel', MChannelAccountDefault> &
186 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
187 Use<'VideoBlacklist', MVideoBlacklistLight> &
188 Use<'Thumbnails', MThumbnail[]>
190 export type MVideoForRedundancyAPI =
192 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
193 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
195 // ############################################################################
197 // Format for API or AP object
199 export type MVideoFormattable =
201 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
202 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
203 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
204 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
206 export type MVideoFormattableDetails =
208 Use<'VideoChannel', MChannelFormattable> &
209 Use<'Tags', MTag[]> &
210 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
211 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>