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