]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/video/video.ts
Add video file size info in admin videos list
[github/Chocobozzz/PeerTube.git] / server / types / models / video / video.ts
CommitLineData
67ed6552 1import { PickWith, PickWithOpt } from '@shared/core-utils'
90a8bd30 2import { VideoModel } from '../../../models/video/video'
d9a2a031 3import { MTrackerUrl } from '../server/tracker'
90a8bd30
C
4import { MUserVideoHistoryTime } from '../user/user-video-history'
5import { MScheduleVideoUpdate } from './schedule-video-update'
6import { MTag } from './tag'
7import { MThumbnail } from './thumbnail'
8import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
9import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
1ca9f7c3
C
10import {
11 MChannelAccountDefault,
12 MChannelAccountLight,
13 MChannelAccountSummaryFormattable,
14 MChannelActor,
15 MChannelFormattable,
90a8bd30 16 MChannelHost,
1ca9f7c3
C
17 MChannelUserId
18} from './video-channels'
90a8bd30
C
19import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
20import { MVideoLive } from './video-live'
b764380a
C
21import {
22 MStreamingPlaylistFiles,
23 MStreamingPlaylistRedundancies,
24 MStreamingPlaylistRedundanciesAll,
25 MStreamingPlaylistRedundanciesOpt
26} from './video-streaming-playlist'
453e83ea 27
0283eaac
C
28type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
29
30// ############################################################################
31
a1587156
C
32export type MVideo =
33 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
453e83ea 34 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
42ec411b 35 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions' | 'VideoLive' | 'Trackers'>
453e83ea 36
0283eaac
C
37// ############################################################################
38
453e83ea
C
39export type MVideoId = Pick<MVideo, 'id'>
40export type MVideoUrl = Pick<MVideo, 'url'>
41export type MVideoUUID = Pick<MVideo, 'uuid'>
42
943e5193 43export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
453e83ea
C
44export type MVideoIdUrl = MVideoId & MVideoUrl
45export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
46
0283eaac
C
47// ############################################################################
48
49// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
50
51// "With" to not confuse with the VideoFile model
a1587156
C
52export type MVideoWithFile =
53 MVideo &
d7a25329
C
54 Use<'VideoFiles', MVideoFile[]> &
55 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
453e83ea 56
a1587156
C
57export type MVideoThumbnail =
58 MVideo &
0283eaac
C
59 Use<'Thumbnails', MThumbnail[]>
60
a1587156
C
61export type MVideoIdThumbnail =
62 MVideoId &
0283eaac
C
63 Use<'Thumbnails', MThumbnail[]>
64
a1587156
C
65export type MVideoWithFileThumbnail =
66 MVideo &
0283eaac
C
67 Use<'VideoFiles', MVideoFile[]> &
68 Use<'Thumbnails', MThumbnail[]>
453e83ea 69
a1587156
C
70export type MVideoThumbnailBlacklist =
71 MVideo &
d636ab58
C
72 Use<'Thumbnails', MThumbnail[]> &
73 Use<'VideoBlacklist', MVideoBlacklistLight>
74
a1587156
C
75export type MVideoTag =
76 MVideo &
0283eaac 77 Use<'Tags', MTag[]>
453e83ea 78
a1587156
C
79export type MVideoWithSchedule =
80 MVideo &
453e83ea
C
81 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
82
a1587156
C
83export type MVideoWithCaptions =
84 MVideo &
0283eaac 85 Use<'VideoCaptions', MVideoCaptionLanguage[]>
453e83ea 86
a1587156
C
87export type MVideoWithStreamingPlaylist =
88 MVideo &
d7a25329 89 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
453e83ea 90
0283eaac
C
91// ############################################################################
92
93// Associations with not all their attributes
94
a1587156
C
95export type MVideoUserHistory =
96 MVideo &
0283eaac 97 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
453e83ea 98
a1587156
C
99export type MVideoWithBlacklistLight =
100 MVideo &
0283eaac 101 Use<'VideoBlacklist', MVideoBlacklistLight>
453e83ea 102
a1587156
C
103export type MVideoAccountLight =
104 MVideo &
0283eaac 105 Use<'VideoChannel', MChannelAccountLight>
453e83ea 106
a1587156
C
107export type MVideoWithRights =
108 MVideo &
0283eaac 109 Use<'VideoBlacklist', MVideoBlacklistLight> &
0283eaac 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[]> &
42ec411b
C
189 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
190 Use<'Trackers', MTrackerUrl[]>
0283eaac 191
a1587156
C
192export type MVideoForUser =
193 MVideo &
0283eaac
C
194 Use<'VideoChannel', MChannelAccountDefault> &
195 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
196 Use<'VideoBlacklist', MVideoBlacklistLight> &
197 Use<'Thumbnails', MThumbnail[]>
1ca9f7c3 198
a1587156
C
199export type MVideoForRedundancyAPI =
200 MVideo &
b764380a
C
201 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
202 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
203
1ca9f7c3
C
204// ############################################################################
205
206// Format for API or AP object
207
a1587156
C
208export type MVideoFormattable =
209 MVideo &
1ca9f7c3
C
210 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
211 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
212 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
3c10840f
C
213 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>> &
214 PickWithOpt<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
215 PickWithOpt<VideoModel, 'VideoFiles', MVideoFile[]>
1ca9f7c3 216
a1587156
C
217export type MVideoFormattableDetails =
218 MVideoFormattable &
1ca9f7c3
C
219 Use<'VideoChannel', MChannelFormattable> &
220 Use<'Tags', MTag[]> &
b5fecbf4 221 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
d9a2a031 222 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
42ec411b 223 PickWithOpt<VideoModel, 'Trackers', MTrackerUrl[]>