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