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