diff options
Diffstat (limited to 'server/typings/models/video/video.ts')
-rw-r--r-- | server/typings/models/video/video.ts | 173 |
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 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { | ||
4 | MChannelAccountDefault, | ||
5 | MChannelAccountLight, | ||
6 | MChannelAccountSummaryFormattable, | ||
7 | MChannelActor, | ||
8 | MChannelFormattable, | ||
9 | MChannelUserId | ||
10 | } from './video-channels' | ||
11 | import { MTag } from './tag' | ||
12 | import { MVideoCaptionLanguage } from './video-caption' | ||
13 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist' | ||
14 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' | ||
15 | import { MThumbnail } from './thumbnail' | ||
16 | import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' | ||
17 | import { MScheduleVideoUpdate } from './schedule-video-update' | ||
18 | import { MUserVideoHistoryTime } from '../user/user-video-history' | ||
19 | |||
20 | type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export 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 | |||
30 | export type MVideoId = Pick<MVideo, 'id'> | ||
31 | export type MVideoUrl = Pick<MVideo, 'url'> | ||
32 | export type MVideoUUID = Pick<MVideo, 'uuid'> | ||
33 | |||
34 | export type MVideoIdUrl = MVideoId & MVideoUrl | ||
35 | export 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 | ||
42 | export type MVideoWithFile = MVideo & | ||
43 | Use<'VideoFiles', MVideoFile[]> | ||
44 | |||
45 | export type MVideoThumbnail = MVideo & | ||
46 | Use<'Thumbnails', MThumbnail[]> | ||
47 | |||
48 | export type MVideoIdThumbnail = MVideoId & | ||
49 | Use<'Thumbnails', MThumbnail[]> | ||
50 | |||
51 | export type MVideoWithFileThumbnail = MVideo & | ||
52 | Use<'VideoFiles', MVideoFile[]> & | ||
53 | Use<'Thumbnails', MThumbnail[]> | ||
54 | |||
55 | export type MVideoThumbnailBlacklist = MVideo & | ||
56 | Use<'Thumbnails', MThumbnail[]> & | ||
57 | Use<'VideoBlacklist', MVideoBlacklistLight> | ||
58 | |||
59 | export type MVideoTag = MVideo & | ||
60 | Use<'Tags', MTag[]> | ||
61 | |||
62 | export type MVideoWithSchedule = MVideo & | ||
63 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | ||
64 | |||
65 | export type MVideoWithCaptions = MVideo & | ||
66 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | ||
67 | |||
68 | export type MVideoWithStreamingPlaylist = MVideo & | ||
69 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
70 | |||
71 | // ############################################################################ | ||
72 | |||
73 | // Associations with not all their attributes | ||
74 | |||
75 | export type MVideoUserHistory = MVideo & | ||
76 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | ||
77 | |||
78 | export type MVideoWithBlacklistLight = MVideo & | ||
79 | Use<'VideoBlacklist', MVideoBlacklistLight> | ||
80 | |||
81 | export type MVideoAccountLight = MVideo & | ||
82 | Use<'VideoChannel', MChannelAccountLight> | ||
83 | |||
84 | export 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 | |||
93 | export type MVideoWithAllFiles = MVideo & | ||
94 | Use<'VideoFiles', MVideoFile[]> & | ||
95 | Use<'Thumbnails', MThumbnail[]> & | ||
96 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
97 | |||
98 | export 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 | |||
109 | export type MVideoAccountDefault = MVideo & | ||
110 | Use<'VideoChannel', MChannelAccountDefault> | ||
111 | |||
112 | export type MVideoThumbnailAccountDefault = MVideo & | ||
113 | Use<'Thumbnails', MThumbnail[]> & | ||
114 | Use<'VideoChannel', MChannelAccountDefault> | ||
115 | |||
116 | export type MVideoWithChannelActor = MVideo & | ||
117 | Use<'VideoChannel', MChannelActor> | ||
118 | |||
119 | export 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 | |||
133 | export 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 | |||
141 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | ||
142 | |||
143 | export 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 | |||
153 | export 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 | |||
163 | export 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 | |||
169 | export type MVideoFormattableDetails = MVideoFormattable & | ||
170 | Use<'VideoChannel', MChannelFormattable> & | ||
171 | Use<'Tags', MTag[]> & | ||
172 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & | ||
173 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | ||