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