]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/types/models/video/video.ts
Dissociate video file names and video uuid
[github/Chocobozzz/PeerTube.git] / server / types / models / video / video.ts
... / ...
CommitLineData
1import { PickWith, PickWithOpt } from '@shared/core-utils'
2import { VideoModel } from '../../../models/video/video'
3import { MUserVideoHistoryTime } from '../user/user-video-history'
4import { MScheduleVideoUpdate } from './schedule-video-update'
5import { MTag } from './tag'
6import { MThumbnail } from './thumbnail'
7import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
8import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
9import {
10 MChannelAccountDefault,
11 MChannelAccountLight,
12 MChannelAccountSummaryFormattable,
13 MChannelActor,
14 MChannelFormattable,
15 MChannelHost,
16 MChannelUserId
17} from './video-channels'
18import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
19import { MVideoLive } from './video-live'
20import {
21 MStreamingPlaylistFiles,
22 MStreamingPlaylistRedundancies,
23 MStreamingPlaylistRedundanciesAll,
24 MStreamingPlaylistRedundanciesOpt
25} from './video-streaming-playlist'
26
27type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
28
29// ############################################################################
30
31export type MVideo =
32 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
33 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
34 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions' | 'VideoLive'>
35
36// ############################################################################
37
38export type MVideoId = Pick<MVideo, 'id'>
39export type MVideoUrl = Pick<MVideo, 'url'>
40export type MVideoUUID = Pick<MVideo, 'uuid'>
41
42export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
43export type MVideoIdUrl = MVideoId & MVideoUrl
44export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
45
46// ############################################################################
47
48// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
49
50// "With" to not confuse with the VideoFile model
51export type MVideoWithFile =
52 MVideo &
53 Use<'VideoFiles', MVideoFile[]> &
54 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
55
56export type MVideoThumbnail =
57 MVideo &
58 Use<'Thumbnails', MThumbnail[]>
59
60export type MVideoIdThumbnail =
61 MVideoId &
62 Use<'Thumbnails', MThumbnail[]>
63
64export type MVideoWithFileThumbnail =
65 MVideo &
66 Use<'VideoFiles', MVideoFile[]> &
67 Use<'Thumbnails', MThumbnail[]>
68
69export type MVideoThumbnailBlacklist =
70 MVideo &
71 Use<'Thumbnails', MThumbnail[]> &
72 Use<'VideoBlacklist', MVideoBlacklistLight>
73
74export type MVideoTag =
75 MVideo &
76 Use<'Tags', MTag[]>
77
78export type MVideoWithSchedule =
79 MVideo &
80 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
81
82export type MVideoWithCaptions =
83 MVideo &
84 Use<'VideoCaptions', MVideoCaptionLanguage[]>
85
86export type MVideoWithStreamingPlaylist =
87 MVideo &
88 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
89
90// ############################################################################
91
92// Associations with not all their attributes
93
94export type MVideoUserHistory =
95 MVideo &
96 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
97
98export type MVideoWithBlacklistLight =
99 MVideo &
100 Use<'VideoBlacklist', MVideoBlacklistLight>
101
102export type MVideoAccountLight =
103 MVideo &
104 Use<'VideoChannel', MChannelAccountLight>
105
106export type MVideoWithRights =
107 MVideo &
108 Use<'VideoBlacklist', MVideoBlacklistLight> &
109 Use<'Thumbnails', MThumbnail[]> &
110 Use<'VideoChannel', MChannelUserId>
111
112// ############################################################################
113
114// All files with some additional associations
115
116export type MVideoWithAllFiles =
117 MVideo &
118 Use<'VideoFiles', MVideoFile[]> &
119 Use<'Thumbnails', MThumbnail[]> &
120 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
121
122export type MVideoAccountLightBlacklistAllFiles =
123 MVideo &
124 Use<'VideoFiles', MVideoFile[]> &
125 Use<'Thumbnails', MThumbnail[]> &
126 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
127 Use<'VideoChannel', MChannelAccountLight> &
128 Use<'VideoBlacklist', MVideoBlacklistLight>
129
130// ############################################################################
131
132// With account
133
134export type MVideoAccountDefault =
135 MVideo &
136 Use<'VideoChannel', MChannelAccountDefault>
137
138export type MVideoThumbnailAccountDefault =
139 MVideo &
140 Use<'Thumbnails', MThumbnail[]> &
141 Use<'VideoChannel', MChannelAccountDefault>
142
143export type MVideoWithChannelActor =
144 MVideo &
145 Use<'VideoChannel', MChannelActor>
146
147export type MVideoWithHost =
148 MVideo &
149 Use<'VideoChannel', MChannelHost>
150
151export type MVideoFullLight =
152 MVideo &
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>
162
163// ############################################################################
164
165// API
166
167export type MVideoAP =
168 MVideo &
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>
177
178export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
179
180export type MVideoDetails =
181 MVideo &
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[]>
190
191export type MVideoForUser =
192 MVideo &
193 Use<'VideoChannel', MChannelAccountDefault> &
194 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
195 Use<'VideoBlacklist', MVideoBlacklistLight> &
196 Use<'Thumbnails', MThumbnail[]>
197
198export type MVideoForRedundancyAPI =
199 MVideo &
200 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
201 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
202
203// ############################################################################
204
205// Format for API or AP object
206
207export type MVideoFormattable =
208 MVideo &
209 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
210 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
211 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
212 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
213
214export type MVideoFormattableDetails =
215 MVideoFormattable &
216 Use<'VideoChannel', MChannelFormattable> &
217 Use<'Tags', MTag[]> &
218 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
219 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>