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