]>
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' | |
b5fecbf4 | 13 | import { MStreamingPlaylist, 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 & |
0283eaac | 43 | Use<'VideoFiles', MVideoFile[]> |
453e83ea C |
44 | |
45 | export type MVideoThumbnail = MVideo & | |
0283eaac C |
46 | Use<'Thumbnails', MThumbnail[]> |
47 | ||
48 | export type MVideoIdThumbnail = MVideoId & | |
49 | Use<'Thumbnails', MThumbnail[]> | |
50 | ||
51 | export type MVideoWithFileThumbnail = MVideo & | |
52 | Use<'VideoFiles', MVideoFile[]> & | |
53 | Use<'Thumbnails', MThumbnail[]> | |
453e83ea | 54 | |
d636ab58 C |
55 | export type MVideoThumbnailBlacklist = MVideo & |
56 | Use<'Thumbnails', MThumbnail[]> & | |
57 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
58 | ||
453e83ea | 59 | export type MVideoTag = MVideo & |
0283eaac | 60 | Use<'Tags', MTag[]> |
453e83ea C |
61 | |
62 | export type MVideoWithSchedule = MVideo & | |
63 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | |
64 | ||
0283eaac C |
65 | export type MVideoWithCaptions = MVideo & |
66 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | |
453e83ea | 67 | |
0283eaac C |
68 | export type MVideoWithStreamingPlaylist = MVideo & |
69 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | |
453e83ea | 70 | |
0283eaac C |
71 | // ############################################################################ |
72 | ||
73 | // Associations with not all their attributes | |
74 | ||
75 | export type MVideoUserHistory = MVideo & | |
76 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | |
453e83ea C |
77 | |
78 | export type MVideoWithBlacklistLight = MVideo & | |
0283eaac | 79 | Use<'VideoBlacklist', MVideoBlacklistLight> |
453e83ea C |
80 | |
81 | export type MVideoAccountLight = MVideo & | |
0283eaac | 82 | Use<'VideoChannel', MChannelAccountLight> |
453e83ea | 83 | |
0283eaac C |
84 | export type MVideoWithRights = MVideo & |
85 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
86 | Use<'Thumbnails', MThumbnail[]> & | |
87 | Use<'VideoChannel', MChannelUserId> | |
453e83ea | 88 | |
0283eaac | 89 | // ############################################################################ |
453e83ea | 90 | |
0283eaac | 91 | // All files with some additional associations |
453e83ea | 92 | |
0283eaac C |
93 | export type MVideoWithAllFiles = MVideo & |
94 | Use<'VideoFiles', MVideoFile[]> & | |
95 | Use<'Thumbnails', MThumbnail[]> & | |
96 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | |
453e83ea | 97 | |
0283eaac C |
98 | export type MVideoAccountLightBlacklistAllFiles = MVideo & |
99 | Use<'VideoFiles', MVideoFile[]> & | |
100 | Use<'Thumbnails', MThumbnail[]> & | |
101 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & | |
102 | Use<'VideoChannel', MChannelAccountLight> & | |
103 | Use<'VideoBlacklist', MVideoBlacklistLight> | |
453e83ea | 104 | |
0283eaac C |
105 | // ############################################################################ |
106 | ||
107 | // With account | |
453e83ea C |
108 | |
109 | export type MVideoAccountDefault = MVideo & | |
0283eaac | 110 | Use<'VideoChannel', MChannelAccountDefault> |
453e83ea | 111 | |
0283eaac C |
112 | export type MVideoThumbnailAccountDefault = MVideo & |
113 | Use<'Thumbnails', MThumbnail[]> & | |
114 | Use<'VideoChannel', MChannelAccountDefault> | |
453e83ea C |
115 | |
116 | export type MVideoWithChannelActor = MVideo & | |
0283eaac C |
117 | Use<'VideoChannel', MChannelActor> |
118 | ||
119 | export type MVideoFullLight = MVideo & | |
120 | Use<'Thumbnails', MThumbnail[]> & | |
121 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
122 | Use<'Tags', MTag[]> & | |
123 | Use<'VideoChannel', MChannelAccountLight> & | |
124 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | |
125 | Use<'VideoFiles', MVideoFile[]> & | |
126 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
127 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | |
128 | ||
129 | // ############################################################################ | |
130 | ||
131 | // API | |
453e83ea C |
132 | |
133 | export type MVideoAP = MVideo & | |
0283eaac C |
134 | Use<'Tags', MTag[]> & |
135 | Use<'VideoChannel', MChannelAccountLight> & | |
136 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & | |
137 | Use<'VideoCaptions', MVideoCaptionLanguage[]> & | |
138 | Use<'VideoBlacklist', MVideoBlacklistUnfederated> & | |
139 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | |
453e83ea C |
140 | |
141 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | |
142 | ||
143 | export type MVideoDetails = MVideo & | |
0283eaac C |
144 | Use<'VideoBlacklist', MVideoBlacklistLight> & |
145 | Use<'Tags', MTag[]> & | |
146 | Use<'VideoChannel', MChannelAccountLight> & | |
147 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
148 | Use<'Thumbnails', MThumbnail[]> & | |
149 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | |
150 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | |
151 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | |
152 | ||
153 | export type MVideoForUser = MVideo & | |
154 | Use<'VideoChannel', MChannelAccountDefault> & | |
155 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | |
156 | Use<'VideoBlacklist', MVideoBlacklistLight> & | |
157 | Use<'Thumbnails', MThumbnail[]> | |
1ca9f7c3 C |
158 | |
159 | // ############################################################################ | |
160 | ||
161 | // Format for API or AP object | |
162 | ||
163 | export type MVideoFormattable = MVideo & | |
164 | PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> & | |
165 | Use<'VideoChannel', MChannelAccountSummaryFormattable> & | |
166 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> & | |
167 | PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>> | |
168 | ||
169 | export type MVideoFormattableDetails = MVideoFormattable & | |
170 | Use<'VideoChannel', MChannelFormattable> & | |
171 | Use<'Tags', MTag[]> & | |
b5fecbf4 | 172 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & |
1ca9f7c3 | 173 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |