]>
Commit | Line | Data |
---|---|---|
453e83ea C |
1 | import { VideoModel } from '../../../models/video/video' |
2 | import { PickWith, PickWithOpt } from '../../utils' | |
1ca9f7c3 C |
3 | import { |
4 | MChannelAccountDefault, | |
5 | MChannelAccountLight, | |
6 | MChannelAccountSummaryFormattable, | |
7 | MChannelActor, | |
8 | MChannelFormattable, | |
9 | MChannelUserId | |
10 | } from './video-channels' | |
453e83ea C |
11 | import { MTag } from './tag' |
12 | import { MVideoCaptionLanguage } from './video-caption' | |
d7a25329 | 13 | import { MStreamingPlaylistFiles, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist' |
453e83ea C |
14 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' |
15 | import { MThumbnail } from './thumbnail' | |
1ca9f7c3 | 16 | import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' |
453e83ea C |
17 | import { MScheduleVideoUpdate } from './schedule-video-update' |
18 | import { MUserVideoHistoryTime } from '../user/user-video-history' | |
19 | ||
0283eaac C |
20 | type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M> |
21 | ||
22 | // ############################################################################ | |
23 | ||
453e83ea C |
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 | ||
0283eaac C |
28 | // ############################################################################ |
29 | ||
453e83ea C |
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 | ||
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 | 42 | export type MVideoWithFile = MVideo & |
d7a25329 C |
43 | Use<'VideoFiles', MVideoFile[]> & |
44 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> | |
453e83ea C |
45 | |
46 | export type MVideoThumbnail = MVideo & | |
0283eaac C |
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[]> | |
453e83ea | 55 | |
d636ab58 C |
56 | export type MVideoThumbnailBlacklist = MVideo & |
57 | Use<'Thumbnails', MThumbnail[]> & | |
58 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
59 | ||
453e83ea | 60 | export type MVideoTag = MVideo & |
0283eaac | 61 | Use<'Tags', MTag[]> |
453e83ea C |
62 | |
63 | export type MVideoWithSchedule = MVideo & | |
64 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | |
65 | ||
0283eaac C |
66 | export type MVideoWithCaptions = MVideo & |
67 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | |
453e83ea | 68 | |
0283eaac | 69 | export type MVideoWithStreamingPlaylist = MVideo & |
d7a25329 | 70 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
453e83ea | 71 | |
0283eaac C |
72 | // ############################################################################ |
73 | ||
74 | // Associations with not all their attributes | |
75 | ||
76 | export type MVideoUserHistory = MVideo & | |
77 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | |
453e83ea C |
78 | |
79 | export type MVideoWithBlacklistLight = MVideo & | |
0283eaac | 80 | Use<'VideoBlacklist', MVideoBlacklistLight> |
453e83ea C |
81 | |
82 | export type MVideoAccountLight = MVideo & | |
0283eaac | 83 | Use<'VideoChannel', MChannelAccountLight> |
453e83ea | 84 | |
0283eaac C |
85 | export type MVideoWithRights = MVideo & |
86 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
87 | Use<'Thumbnails', MThumbnail[]> & | |
88 | Use<'VideoChannel', MChannelUserId> | |
453e83ea | 89 | |
0283eaac | 90 | // ############################################################################ |
453e83ea | 91 | |
0283eaac | 92 | // All files with some additional associations |
453e83ea | 93 | |
0283eaac C |
94 | export type MVideoWithAllFiles = MVideo & |
95 | Use<'VideoFiles', MVideoFile[]> & | |
96 | Use<'Thumbnails', MThumbnail[]> & | |
d7a25329 | 97 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
453e83ea | 98 | |
0283eaac C |
99 | export type MVideoAccountLightBlacklistAllFiles = MVideo & |
100 | Use<'VideoFiles', MVideoFile[]> & | |
101 | Use<'Thumbnails', MThumbnail[]> & | |
d7a25329 | 102 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & |
0283eaac C |
103 | Use<'VideoChannel', MChannelAccountLight> & |
104 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
453e83ea | 105 | |
0283eaac C |
106 | // ############################################################################ |
107 | ||
108 | // With account | |
453e83ea C |
109 | |
110 | export type MVideoAccountDefault = MVideo & | |
0283eaac | 111 | Use<'VideoChannel', MChannelAccountDefault> |
453e83ea | 112 | |
0283eaac C |
113 | export type MVideoThumbnailAccountDefault = MVideo & |
114 | Use<'Thumbnails', MThumbnail[]> & | |
115 | Use<'VideoChannel', MChannelAccountDefault> | |
453e83ea C |
116 | |
117 | export type MVideoWithChannelActor = MVideo & | |
0283eaac C |
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> & | |
d7a25329 | 128 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> |
0283eaac C |
129 | |
130 | // ############################################################################ | |
131 | ||
132 | // API | |
453e83ea C |
133 | |
134 | export type MVideoAP = MVideo & | |
0283eaac C |
135 | Use<'Tags', MTag[]> & |
136 | Use<'VideoChannel', MChannelAccountLight> & | |
d7a25329 | 137 | Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & |
0283eaac C |
138 | Use<'VideoCaptions', MVideoCaptionLanguage[]> & |
139 | Use<'VideoBlacklist', MVideoBlacklistUnfederated> & | |
d7a25329 C |
140 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> & |
141 | Use<'Thumbnails', MThumbnail[]> | |
453e83ea C |
142 | |
143 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | |
144 | ||
145 | export type MVideoDetails = MVideo & | |
0283eaac C |
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[]> | |
1ca9f7c3 C |
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[]> & | |
b5fecbf4 | 174 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & |
1ca9f7c3 | 175 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |