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