aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/types/models/video/video.ts')
-rw-r--r--server/types/models/video/video.ts211
1 files changed, 211 insertions, 0 deletions
diff --git a/server/types/models/video/video.ts b/server/types/models/video/video.ts
new file mode 100644
index 000000000..022a9566d
--- /dev/null
+++ b/server/types/models/video/video.ts
@@ -0,0 +1,211 @@
1import { VideoModel } from '../../../models/video/video'
2import { PickWith, PickWithOpt } from '../../utils'
3import {
4 MChannelAccountDefault,
5 MChannelAccountLight,
6 MChannelAccountSummaryFormattable,
7 MChannelActor,
8 MChannelFormattable,
9 MChannelUserId
10} from './video-channels'
11import { MTag } from './tag'
12import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
13import {
14 MStreamingPlaylistFiles,
15 MStreamingPlaylistRedundancies,
16 MStreamingPlaylistRedundanciesAll,
17 MStreamingPlaylistRedundanciesOpt
18} from './video-streaming-playlist'
19import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
20import { MThumbnail } from './thumbnail'
21import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
22import { MScheduleVideoUpdate } from './schedule-video-update'
23import { MUserVideoHistoryTime } from '../user/user-video-history'
24
25type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
26
27// ############################################################################
28
29export type MVideo =
30 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
31 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
32 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
33
34// ############################################################################
35
36export type MVideoId = Pick<MVideo, 'id'>
37export type MVideoUrl = Pick<MVideo, 'url'>
38export type MVideoUUID = Pick<MVideo, 'uuid'>
39
40export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
41export type MVideoIdUrl = MVideoId & MVideoUrl
42export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
43
44// ############################################################################
45
46// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
47
48// "With" to not confuse with the VideoFile model
49export type MVideoWithFile =
50 MVideo &
51 Use<'VideoFiles', MVideoFile[]> &
52 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
53
54export type MVideoThumbnail =
55 MVideo &
56 Use<'Thumbnails', MThumbnail[]>
57
58export type MVideoIdThumbnail =
59 MVideoId &
60 Use<'Thumbnails', MThumbnail[]>
61
62export type MVideoWithFileThumbnail =
63 MVideo &
64 Use<'VideoFiles', MVideoFile[]> &
65 Use<'Thumbnails', MThumbnail[]>
66
67export type MVideoThumbnailBlacklist =
68 MVideo &
69 Use<'Thumbnails', MThumbnail[]> &
70 Use<'VideoBlacklist', MVideoBlacklistLight>
71
72export type MVideoTag =
73 MVideo &
74 Use<'Tags', MTag[]>
75
76export type MVideoWithSchedule =
77 MVideo &
78 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
79
80export type MVideoWithCaptions =
81 MVideo &
82 Use<'VideoCaptions', MVideoCaptionLanguage[]>
83
84export type MVideoWithStreamingPlaylist =
85 MVideo &
86 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
87
88// ############################################################################
89
90// Associations with not all their attributes
91
92export type MVideoUserHistory =
93 MVideo &
94 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
95
96export type MVideoWithBlacklistLight =
97 MVideo &
98 Use<'VideoBlacklist', MVideoBlacklistLight>
99
100export type MVideoAccountLight =
101 MVideo &
102 Use<'VideoChannel', MChannelAccountLight>
103
104export type MVideoWithRights =
105 MVideo &
106 Use<'VideoBlacklist', MVideoBlacklistLight> &
107 Use<'Thumbnails', MThumbnail[]> &
108 Use<'VideoChannel', MChannelUserId>
109
110// ############################################################################
111
112// All files with some additional associations
113
114export type MVideoWithAllFiles =
115 MVideo &
116 Use<'VideoFiles', MVideoFile[]> &
117 Use<'Thumbnails', MThumbnail[]> &
118 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
119
120export type MVideoAccountLightBlacklistAllFiles =
121 MVideo &
122 Use<'VideoFiles', MVideoFile[]> &
123 Use<'Thumbnails', MThumbnail[]> &
124 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
125 Use<'VideoChannel', MChannelAccountLight> &
126 Use<'VideoBlacklist', MVideoBlacklistLight>
127
128// ############################################################################
129
130// With account
131
132export type MVideoAccountDefault =
133 MVideo &
134 Use<'VideoChannel', MChannelAccountDefault>
135
136export type MVideoThumbnailAccountDefault =
137 MVideo &
138 Use<'Thumbnails', MThumbnail[]> &
139 Use<'VideoChannel', MChannelAccountDefault>
140
141export type MVideoWithChannelActor =
142 MVideo &
143 Use<'VideoChannel', MChannelActor>
144
145export type MVideoFullLight =
146 MVideo &
147 Use<'Thumbnails', MThumbnail[]> &
148 Use<'VideoBlacklist', MVideoBlacklistLight> &
149 Use<'Tags', MTag[]> &
150 Use<'VideoChannel', MChannelAccountLight> &
151 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
152 Use<'VideoFiles', MVideoFile[]> &
153 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
154 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
155
156// ############################################################################
157
158// API
159
160export type MVideoAP =
161 MVideo &
162 Use<'Tags', MTag[]> &
163 Use<'VideoChannel', MChannelAccountLight> &
164 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
165 Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
166 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
167 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
168 Use<'Thumbnails', MThumbnail[]>
169
170export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
171
172export type MVideoDetails =
173 MVideo &
174 Use<'VideoBlacklist', MVideoBlacklistLight> &
175 Use<'Tags', MTag[]> &
176 Use<'VideoChannel', MChannelAccountLight> &
177 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
178 Use<'Thumbnails', MThumbnail[]> &
179 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
180 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
181 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
182
183export type MVideoForUser =
184 MVideo &
185 Use<'VideoChannel', MChannelAccountDefault> &
186 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
187 Use<'VideoBlacklist', MVideoBlacklistLight> &
188 Use<'Thumbnails', MThumbnail[]>
189
190export type MVideoForRedundancyAPI =
191 MVideo &
192 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
193 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
194
195// ############################################################################
196
197// Format for API or AP object
198
199export type MVideoFormattable =
200 MVideo &
201 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
202 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
203 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
204 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
205
206export type MVideoFormattableDetails =
207 MVideoFormattable &
208 Use<'VideoChannel', MChannelFormattable> &
209 Use<'Tags', MTag[]> &
210 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
211 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>