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 MVideoIdUrl = MVideoId & MVideoUrl
41 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
43 // ############################################################################
45 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
47 // "With" to not confuse with the VideoFile model
48 export type MVideoWithFile =
50 Use<'VideoFiles', MVideoFile[]> &
51 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
53 export type MVideoThumbnail =
55 Use<'Thumbnails', MThumbnail[]>
57 export type MVideoIdThumbnail =
59 Use<'Thumbnails', MThumbnail[]>
61 export type MVideoWithFileThumbnail =
63 Use<'VideoFiles', MVideoFile[]> &
64 Use<'Thumbnails', MThumbnail[]>
66 export type MVideoThumbnailBlacklist =
68 Use<'Thumbnails', MThumbnail[]> &
69 Use<'VideoBlacklist', MVideoBlacklistLight>
71 export type MVideoTag =
75 export type MVideoWithSchedule =
77 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
79 export type MVideoWithCaptions =
81 Use<'VideoCaptions', MVideoCaptionLanguage[]>
83 export type MVideoWithStreamingPlaylist =
85 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
87 // ############################################################################
89 // Associations with not all their attributes
91 export type MVideoUserHistory =
93 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
95 export type MVideoWithBlacklistLight =
97 Use<'VideoBlacklist', MVideoBlacklistLight>
99 export type MVideoAccountLight =
101 Use<'VideoChannel', MChannelAccountLight>
103 export type MVideoWithRights =
105 Use<'VideoBlacklist', MVideoBlacklistLight> &
106 Use<'Thumbnails', MThumbnail[]> &
107 Use<'VideoChannel', MChannelUserId>
109 // ############################################################################
111 // All files with some additional associations
113 export type MVideoWithAllFiles =
115 Use<'VideoFiles', MVideoFile[]> &
116 Use<'Thumbnails', MThumbnail[]> &
117 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
119 export type MVideoAccountLightBlacklistAllFiles =
121 Use<'VideoFiles', MVideoFile[]> &
122 Use<'Thumbnails', MThumbnail[]> &
123 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
124 Use<'VideoChannel', MChannelAccountLight> &
125 Use<'VideoBlacklist', MVideoBlacklistLight>
127 // ############################################################################
131 export type MVideoAccountDefault =
133 Use<'VideoChannel', MChannelAccountDefault>
135 export type MVideoThumbnailAccountDefault =
137 Use<'Thumbnails', MThumbnail[]> &
138 Use<'VideoChannel', MChannelAccountDefault>
140 export type MVideoWithChannelActor =
142 Use<'VideoChannel', MChannelActor>
144 export type MVideoFullLight =
146 Use<'Thumbnails', MThumbnail[]> &
147 Use<'VideoBlacklist', MVideoBlacklistLight> &
148 Use<'Tags', MTag[]> &
149 Use<'VideoChannel', MChannelAccountLight> &
150 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
151 Use<'VideoFiles', MVideoFile[]> &
152 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
153 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
155 // ############################################################################
159 export type MVideoAP =
161 Use<'Tags', MTag[]> &
162 Use<'VideoChannel', MChannelAccountLight> &
163 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
164 Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
165 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
166 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
167 Use<'Thumbnails', MThumbnail[]>
169 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
171 export type MVideoDetails =
173 Use<'VideoBlacklist', MVideoBlacklistLight> &
174 Use<'Tags', MTag[]> &
175 Use<'VideoChannel', MChannelAccountLight> &
176 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
177 Use<'Thumbnails', MThumbnail[]> &
178 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
179 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
180 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
182 export type MVideoForUser =
184 Use<'VideoChannel', MChannelAccountDefault> &
185 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
186 Use<'VideoBlacklist', MVideoBlacklistLight> &
187 Use<'Thumbnails', MThumbnail[]>
189 export type MVideoForRedundancyAPI =
191 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
192 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
194 // ############################################################################
196 // Format for API or AP object
198 export type MVideoFormattable =
200 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
201 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
202 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
203 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
205 export type MVideoFormattableDetails =
207 Use<'VideoChannel', MChannelFormattable> &
208 Use<'Tags', MTag[]> &
209 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
210 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>