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