1 import { PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoModel } from '../../../models/video/video'
3 import { MUserVideoHistoryTime } from '../user/user-video-history'
4 import { MScheduleVideoUpdate } from './schedule-video-update'
5 import { MTag } from './tag'
6 import { MThumbnail } from './thumbnail'
7 import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
8 import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
10 MChannelAccountDefault,
12 MChannelAccountSummaryFormattable,
17 } from './video-channels'
18 import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
19 import { MVideoLive } from './video-live'
21 MStreamingPlaylistFiles,
22 MStreamingPlaylistRedundancies,
23 MStreamingPlaylistRedundanciesAll,
24 MStreamingPlaylistRedundanciesOpt
25 } from './video-streaming-playlist'
27 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
29 // ############################################################################
32 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
33 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
34 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions' | 'VideoLive'>
36 // ############################################################################
38 export type MVideoId = Pick<MVideo, 'id'>
39 export type MVideoUrl = Pick<MVideo, 'url'>
40 export type MVideoUUID = Pick<MVideo, 'uuid'>
42 export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
43 export type MVideoIdUrl = MVideoId & MVideoUrl
44 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
46 // ############################################################################
48 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
50 // "With" to not confuse with the VideoFile model
51 export type MVideoWithFile =
53 Use<'VideoFiles', MVideoFile[]> &
54 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
56 export type MVideoThumbnail =
58 Use<'Thumbnails', MThumbnail[]>
60 export type MVideoIdThumbnail =
62 Use<'Thumbnails', MThumbnail[]>
64 export type MVideoWithFileThumbnail =
66 Use<'VideoFiles', MVideoFile[]> &
67 Use<'Thumbnails', MThumbnail[]>
69 export type MVideoThumbnailBlacklist =
71 Use<'Thumbnails', MThumbnail[]> &
72 Use<'VideoBlacklist', MVideoBlacklistLight>
74 export type MVideoTag =
78 export type MVideoWithSchedule =
80 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
82 export type MVideoWithCaptions =
84 Use<'VideoCaptions', MVideoCaptionLanguage[]>
86 export type MVideoWithStreamingPlaylist =
88 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
90 // ############################################################################
92 // Associations with not all their attributes
94 export type MVideoUserHistory =
96 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
98 export type MVideoWithBlacklistLight =
100 Use<'VideoBlacklist', MVideoBlacklistLight>
102 export type MVideoAccountLight =
104 Use<'VideoChannel', MChannelAccountLight>
106 export type MVideoWithRights =
108 Use<'VideoBlacklist', MVideoBlacklistLight> &
109 Use<'Thumbnails', MThumbnail[]> &
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[]>
191 export type MVideoForUser =
193 Use<'VideoChannel', MChannelAccountDefault> &
194 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
195 Use<'VideoBlacklist', MVideoBlacklistLight> &
196 Use<'Thumbnails', MThumbnail[]>
198 export type MVideoForRedundancyAPI =
200 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
201 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
203 // ############################################################################
205 // Format for API or AP object
207 export type MVideoFormattable =
209 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
210 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
211 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
212 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
214 export type MVideoFormattableDetails =
216 Use<'VideoChannel', MChannelFormattable> &
217 Use<'Tags', MTag[]> &
218 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
219 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>