]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/video/video.ts
Dissociate video file names and video uuid
[github/Chocobozzz/PeerTube.git] / server / types / models / video / video.ts
1 import { PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoModel } from '../../../models/video/video'
3 import { MUserVideoHistoryTime } from '../user/user-video-history'
4 import { MScheduleVideoUpdate } from './schedule-video-update'
5 import { MTag } from './tag'
6 import { MThumbnail } from './thumbnail'
7 import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
8 import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
9 import {
10 MChannelAccountDefault,
11 MChannelAccountLight,
12 MChannelAccountSummaryFormattable,
13 MChannelActor,
14 MChannelFormattable,
15 MChannelHost,
16 MChannelUserId
17 } from './video-channels'
18 import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
19 import { MVideoLive } from './video-live'
20 import {
21 MStreamingPlaylistFiles,
22 MStreamingPlaylistRedundancies,
23 MStreamingPlaylistRedundanciesAll,
24 MStreamingPlaylistRedundanciesOpt
25 } from './video-streaming-playlist'
26
27 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
28
29 // ############################################################################
30
31 export 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
38 export type MVideoId = Pick<MVideo, 'id'>
39 export type MVideoUrl = Pick<MVideo, 'url'>
40 export type MVideoUUID = Pick<MVideo, 'uuid'>
41
42 export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
43 export type MVideoIdUrl = MVideoId & MVideoUrl
44 export 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
51 export type MVideoWithFile =
52 MVideo &
53 Use<'VideoFiles', MVideoFile[]> &
54 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
55
56 export type MVideoThumbnail =
57 MVideo &
58 Use<'Thumbnails', MThumbnail[]>
59
60 export type MVideoIdThumbnail =
61 MVideoId &
62 Use<'Thumbnails', MThumbnail[]>
63
64 export type MVideoWithFileThumbnail =
65 MVideo &
66 Use<'VideoFiles', MVideoFile[]> &
67 Use<'Thumbnails', MThumbnail[]>
68
69 export type MVideoThumbnailBlacklist =
70 MVideo &
71 Use<'Thumbnails', MThumbnail[]> &
72 Use<'VideoBlacklist', MVideoBlacklistLight>
73
74 export type MVideoTag =
75 MVideo &
76 Use<'Tags', MTag[]>
77
78 export type MVideoWithSchedule =
79 MVideo &
80 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
81
82 export type MVideoWithCaptions =
83 MVideo &
84 Use<'VideoCaptions', MVideoCaptionLanguage[]>
85
86 export type MVideoWithStreamingPlaylist =
87 MVideo &
88 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
89
90 // ############################################################################
91
92 // Associations with not all their attributes
93
94 export type MVideoUserHistory =
95 MVideo &
96 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
97
98 export type MVideoWithBlacklistLight =
99 MVideo &
100 Use<'VideoBlacklist', MVideoBlacklistLight>
101
102 export type MVideoAccountLight =
103 MVideo &
104 Use<'VideoChannel', MChannelAccountLight>
105
106 export 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
116 export type MVideoWithAllFiles =
117 MVideo &
118 Use<'VideoFiles', MVideoFile[]> &
119 Use<'Thumbnails', MThumbnail[]> &
120 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
121
122 export 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
134 export type MVideoAccountDefault =
135 MVideo &
136 Use<'VideoChannel', MChannelAccountDefault>
137
138 export type MVideoThumbnailAccountDefault =
139 MVideo &
140 Use<'Thumbnails', MThumbnail[]> &
141 Use<'VideoChannel', MChannelAccountDefault>
142
143 export type MVideoWithChannelActor =
144 MVideo &
145 Use<'VideoChannel', MChannelActor>
146
147 export type MVideoWithHost =
148 MVideo &
149 Use<'VideoChannel', MChannelHost>
150
151 export 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
167 export 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
178 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
179
180 export 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
191 export type MVideoForUser =
192 MVideo &
193 Use<'VideoChannel', MChannelAccountDefault> &
194 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
195 Use<'VideoBlacklist', MVideoBlacklistLight> &
196 Use<'Thumbnails', MThumbnail[]>
197
198 export type MVideoForRedundancyAPI =
199 MVideo &
200 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
201 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
202
203 // ############################################################################
204
205 // Format for API or AP object
206
207 export 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
214 export type MVideoFormattableDetails =
215 MVideoFormattable &
216 Use<'VideoChannel', MChannelFormattable> &
217 Use<'Tags', MTag[]> &
218 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
219 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>