]>
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 C |
54 | |
55 | export type MVideoTag = MVideo & | |
0283eaac | 56 | Use<'Tags', MTag[]> |
453e83ea C |
57 | |
58 | export type MVideoWithSchedule = MVideo & | |
59 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | |
60 | ||
0283eaac C |
61 | export type MVideoWithCaptions = MVideo & |
62 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | |
453e83ea | 63 | |
0283eaac C |
64 | export type MVideoWithStreamingPlaylist = MVideo & |
65 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | |
453e83ea | 66 | |
0283eaac C |
67 | // ############################################################################ |
68 | ||
69 | // Associations with not all their attributes | |
70 | ||
71 | export type MVideoUserHistory = MVideo & | |
72 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | |
453e83ea C |
73 | |
74 | export type MVideoWithBlacklistLight = MVideo & | |
0283eaac | 75 | Use<'VideoBlacklist', MVideoBlacklistLight> |
453e83ea C |
76 | |
77 | export type MVideoAccountLight = MVideo & | |
0283eaac | 78 | Use<'VideoChannel', MChannelAccountLight> |
453e83ea | 79 | |
0283eaac C |
80 | export 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 |
89 | export type MVideoWithAllFiles = MVideo & |
90 | Use<'VideoFiles', MVideoFile[]> & | |
91 | Use<'Thumbnails', MThumbnail[]> & | |
92 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | |
453e83ea | 93 | |
0283eaac C |
94 | export 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 | |
105 | export type MVideoAccountDefault = MVideo & | |
0283eaac | 106 | Use<'VideoChannel', MChannelAccountDefault> |
453e83ea | 107 | |
0283eaac C |
108 | export type MVideoThumbnailAccountDefault = MVideo & |
109 | Use<'Thumbnails', MThumbnail[]> & | |
110 | Use<'VideoChannel', MChannelAccountDefault> | |
453e83ea C |
111 | |
112 | export type MVideoWithChannelActor = MVideo & | |
0283eaac C |
113 | Use<'VideoChannel', MChannelActor> |
114 | ||
115 | export 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 | |
129 | export 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 | |
137 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | |
138 | ||
139 | export 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 | ||
149 | export 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 | ||
159 | export 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 | ||
165 | export type MVideoFormattableDetails = MVideoFormattable & | |
166 | Use<'VideoChannel', MChannelFormattable> & | |
167 | Use<'Tags', MTag[]> & | |
b5fecbf4 | 168 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & |
1ca9f7c3 | 169 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |