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