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