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