1 import { VideoModel } from '../../../models/video/video'
2 import { PickWith, PickWithOpt } from '@shared/core-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'
24 import { MVideoLive } from './video-live'
26 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
28 // ############################################################################
31 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
32 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
33 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions' | 'VideoLive'>
35 // ############################################################################
37 export type MVideoId = Pick<MVideo, 'id'>
38 export type MVideoUrl = Pick<MVideo, 'url'>
39 export type MVideoUUID = Pick<MVideo, 'uuid'>
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'>
45 // ############################################################################
47 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
49 // "With" to not confuse with the VideoFile model
50 export type MVideoWithFile =
52 Use<'VideoFiles', MVideoFile[]> &
53 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
55 export type MVideoThumbnail =
57 Use<'Thumbnails', MThumbnail[]>
59 export type MVideoIdThumbnail =
61 Use<'Thumbnails', MThumbnail[]>
63 export type MVideoWithFileThumbnail =
65 Use<'VideoFiles', MVideoFile[]> &
66 Use<'Thumbnails', MThumbnail[]>
68 export type MVideoThumbnailBlacklist =
70 Use<'Thumbnails', MThumbnail[]> &
71 Use<'VideoBlacklist', MVideoBlacklistLight>
73 export type MVideoTag =
77 export type MVideoWithSchedule =
79 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
81 export type MVideoWithCaptions =
83 Use<'VideoCaptions', MVideoCaptionLanguage[]>
85 export type MVideoWithStreamingPlaylist =
87 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
89 // ############################################################################
91 // Associations with not all their attributes
93 export type MVideoUserHistory =
95 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
97 export type MVideoWithBlacklistLight =
99 Use<'VideoBlacklist', MVideoBlacklistLight>
101 export type MVideoAccountLight =
103 Use<'VideoChannel', MChannelAccountLight>
105 export type MVideoWithRights =
107 Use<'VideoBlacklist', MVideoBlacklistLight> &
108 Use<'Thumbnails', MThumbnail[]> &
109 Use<'VideoChannel', MChannelUserId>
111 // ############################################################################
113 // All files with some additional associations
115 export type MVideoWithAllFiles =
117 Use<'VideoFiles', MVideoFile[]> &
118 Use<'Thumbnails', MThumbnail[]> &
119 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
121 export type MVideoAccountLightBlacklistAllFiles =
123 Use<'VideoFiles', MVideoFile[]> &
124 Use<'Thumbnails', MThumbnail[]> &
125 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
126 Use<'VideoChannel', MChannelAccountLight> &
127 Use<'VideoBlacklist', MVideoBlacklistLight>
129 // ############################################################################
133 export type MVideoAccountDefault =
135 Use<'VideoChannel', MChannelAccountDefault>
137 export type MVideoThumbnailAccountDefault =
139 Use<'Thumbnails', MThumbnail[]> &
140 Use<'VideoChannel', MChannelAccountDefault>
142 export type MVideoWithChannelActor =
144 Use<'VideoChannel', MChannelActor>
146 export type MVideoFullLight =
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>
158 // ############################################################################
162 export type MVideoAP =
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>
173 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
175 export type MVideoDetails =
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[]>
186 export type MVideoForUser =
188 Use<'VideoChannel', MChannelAccountDefault> &
189 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
190 Use<'VideoBlacklist', MVideoBlacklistLight> &
191 Use<'Thumbnails', MThumbnail[]>
193 export type MVideoForRedundancyAPI =
195 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
196 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
198 // ############################################################################
200 // Format for API or AP object
202 export type MVideoFormattable =
204 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
205 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
206 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
207 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
209 export type MVideoFormattableDetails =
211 Use<'VideoChannel', MChannelFormattable> &
212 Use<'Tags', MTag[]> &
213 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
214 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>