1 import { VideoModel } from '../../../models/video/video'
2 import { PickWith, PickWithOpt } from '../../utils'
3 import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'
4 import { MTag } from './tag'
5 import { MVideoCaptionLanguage } from './video-caption'
6 import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
7 import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
8 import { MThumbnail } from './thumbnail'
9 import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
10 import { MScheduleVideoUpdate } from './schedule-video-update'
11 import { MUserVideoHistoryTime } from '../user/user-video-history'
13 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
15 // ############################################################################
17 export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
18 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
19 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
21 // ############################################################################
23 export type MVideoId = Pick<MVideo, 'id'>
24 export type MVideoUrl = Pick<MVideo, 'url'>
25 export type MVideoUUID = Pick<MVideo, 'uuid'>
27 export type MVideoIdUrl = MVideoId & MVideoUrl
28 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
30 // ############################################################################
32 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
34 // "With" to not confuse with the VideoFile model
35 export type MVideoWithFile = MVideo &
36 Use<'VideoFiles', MVideoFile[]>
38 export type MVideoThumbnail = MVideo &
39 Use<'Thumbnails', MThumbnail[]>
41 export type MVideoIdThumbnail = MVideoId &
42 Use<'Thumbnails', MThumbnail[]>
44 export type MVideoWithFileThumbnail = MVideo &
45 Use<'VideoFiles', MVideoFile[]> &
46 Use<'Thumbnails', MThumbnail[]>
48 export type MVideoTag = MVideo &
51 export type MVideoWithSchedule = MVideo &
52 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
54 export type MVideoWithCaptions = MVideo &
55 Use<'VideoCaptions', MVideoCaptionLanguage[]>
57 export type MVideoWithStreamingPlaylist = MVideo &
58 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
60 // ############################################################################
62 // Associations with not all their attributes
64 export type MVideoUserHistory = MVideo &
65 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
67 export type MVideoWithBlacklistLight = MVideo &
68 Use<'VideoBlacklist', MVideoBlacklistLight>
70 export type MVideoAccountLight = MVideo &
71 Use<'VideoChannel', MChannelAccountLight>
73 export type MVideoWithRights = MVideo &
74 Use<'VideoBlacklist', MVideoBlacklistLight> &
75 Use<'Thumbnails', MThumbnail[]> &
76 Use<'VideoChannel', MChannelUserId>
78 // ############################################################################
80 // All files with some additional associations
82 export type MVideoWithAllFiles = MVideo &
83 Use<'VideoFiles', MVideoFile[]> &
84 Use<'Thumbnails', MThumbnail[]> &
85 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
87 export type MVideoAccountLightBlacklistAllFiles = MVideo &
88 Use<'VideoFiles', MVideoFile[]> &
89 Use<'Thumbnails', MThumbnail[]> &
90 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
91 Use<'VideoChannel', MChannelAccountLight> &
92 Use<'VideoBlacklist', MVideoBlacklistLight>
94 // ############################################################################
98 export type MVideoAccountDefault = MVideo &
99 Use<'VideoChannel', MChannelAccountDefault>
101 export type MVideoThumbnailAccountDefault = MVideo &
102 Use<'Thumbnails', MThumbnail[]> &
103 Use<'VideoChannel', MChannelAccountDefault>
105 export type MVideoWithChannelActor = MVideo &
106 Use<'VideoChannel', MChannelActor>
108 export type MVideoFullLight = MVideo &
109 Use<'Thumbnails', MThumbnail[]> &
110 Use<'VideoBlacklist', MVideoBlacklistLight> &
111 Use<'Tags', MTag[]> &
112 Use<'VideoChannel', MChannelAccountLight> &
113 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
114 Use<'VideoFiles', MVideoFile[]> &
115 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
116 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
118 // ############################################################################
122 export type MVideoAP = MVideo &
123 Use<'Tags', MTag[]> &
124 Use<'VideoChannel', MChannelAccountLight> &
125 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
126 Use<'VideoCaptions', MVideoCaptionLanguage[]> &
127 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
128 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
130 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
132 export type MVideoDetails = MVideo &
133 Use<'VideoBlacklist', MVideoBlacklistLight> &
134 Use<'Tags', MTag[]> &
135 Use<'VideoChannel', MChannelAccountLight> &
136 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
137 Use<'Thumbnails', MThumbnail[]> &
138 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
139 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
140 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
142 export type MVideoForUser = MVideo &
143 Use<'VideoChannel', MChannelAccountDefault> &
144 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
145 Use<'VideoBlacklist', MVideoBlacklistLight> &
146 Use<'Thumbnails', MThumbnail[]>