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