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 } from './video-caption'
13 import { MStreamingPlaylistFiles, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist'
14 import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
15 import { MThumbnail } from './thumbnail'
16 import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
17 import { MScheduleVideoUpdate } from './schedule-video-update'
18 import { MUserVideoHistoryTime } from '../user/user-video-history'
20 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
22 // ############################################################################
24 export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
25 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
26 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
28 // ############################################################################
30 export type MVideoId = Pick<MVideo, 'id'>
31 export type MVideoUrl = Pick<MVideo, 'url'>
32 export type MVideoUUID = Pick<MVideo, 'uuid'>
34 export type MVideoIdUrl = MVideoId & MVideoUrl
35 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
37 // ############################################################################
39 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
41 // "With" to not confuse with the VideoFile model
42 export type MVideoWithFile = MVideo &
43 Use<'VideoFiles', MVideoFile[]> &
44 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
46 export type MVideoThumbnail = MVideo &
47 Use<'Thumbnails', MThumbnail[]>
49 export type MVideoIdThumbnail = MVideoId &
50 Use<'Thumbnails', MThumbnail[]>
52 export type MVideoWithFileThumbnail = MVideo &
53 Use<'VideoFiles', MVideoFile[]> &
54 Use<'Thumbnails', MThumbnail[]>
56 export type MVideoThumbnailBlacklist = MVideo &
57 Use<'Thumbnails', MThumbnail[]> &
58 Use<'VideoBlacklist', MVideoBlacklistLight>
60 export type MVideoTag = MVideo &
63 export type MVideoWithSchedule = MVideo &
64 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
66 export type MVideoWithCaptions = MVideo &
67 Use<'VideoCaptions', MVideoCaptionLanguage[]>
69 export type MVideoWithStreamingPlaylist = MVideo &
70 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
72 // ############################################################################
74 // Associations with not all their attributes
76 export type MVideoUserHistory = MVideo &
77 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
79 export type MVideoWithBlacklistLight = MVideo &
80 Use<'VideoBlacklist', MVideoBlacklistLight>
82 export type MVideoAccountLight = MVideo &
83 Use<'VideoChannel', MChannelAccountLight>
85 export type MVideoWithRights = MVideo &
86 Use<'VideoBlacklist', MVideoBlacklistLight> &
87 Use<'Thumbnails', MThumbnail[]> &
88 Use<'VideoChannel', MChannelUserId>
90 // ############################################################################
92 // All files with some additional associations
94 export type MVideoWithAllFiles = MVideo &
95 Use<'VideoFiles', MVideoFile[]> &
96 Use<'Thumbnails', MThumbnail[]> &
97 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
99 export type MVideoAccountLightBlacklistAllFiles = MVideo &
100 Use<'VideoFiles', MVideoFile[]> &
101 Use<'Thumbnails', MThumbnail[]> &
102 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
103 Use<'VideoChannel', MChannelAccountLight> &
104 Use<'VideoBlacklist', MVideoBlacklistLight>
106 // ############################################################################
110 export type MVideoAccountDefault = MVideo &
111 Use<'VideoChannel', MChannelAccountDefault>
113 export type MVideoThumbnailAccountDefault = MVideo &
114 Use<'Thumbnails', MThumbnail[]> &
115 Use<'VideoChannel', MChannelAccountDefault>
117 export type MVideoWithChannelActor = MVideo &
118 Use<'VideoChannel', MChannelActor>
120 export type MVideoFullLight = MVideo &
121 Use<'Thumbnails', MThumbnail[]> &
122 Use<'VideoBlacklist', MVideoBlacklistLight> &
123 Use<'Tags', MTag[]> &
124 Use<'VideoChannel', MChannelAccountLight> &
125 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
126 Use<'VideoFiles', MVideoFile[]> &
127 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
128 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
130 // ############################################################################
134 export type MVideoAP = MVideo &
135 Use<'Tags', MTag[]> &
136 Use<'VideoChannel', MChannelAccountLight> &
137 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
138 Use<'VideoCaptions', MVideoCaptionLanguage[]> &
139 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
140 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
141 Use<'Thumbnails', MThumbnail[]>
143 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
145 export type MVideoDetails = MVideo &
146 Use<'VideoBlacklist', MVideoBlacklistLight> &
147 Use<'Tags', MTag[]> &
148 Use<'VideoChannel', MChannelAccountLight> &
149 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
150 Use<'Thumbnails', MThumbnail[]> &
151 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
152 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
153 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
155 export type MVideoForUser = MVideo &
156 Use<'VideoChannel', MChannelAccountDefault> &
157 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
158 Use<'VideoBlacklist', MVideoBlacklistLight> &
159 Use<'Thumbnails', MThumbnail[]>
161 // ############################################################################
163 // Format for API or AP object
165 export type MVideoFormattable = MVideo &
166 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
167 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
168 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
169 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
171 export type MVideoFormattableDetails = MVideoFormattable &
172 Use<'VideoChannel', MChannelFormattable> &
173 Use<'Tags', MTag[]> &
174 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
175 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>