diff options
Diffstat (limited to 'server/typings/models/video/video.ts')
-rw-r--r-- | server/typings/models/video/video.ts | 141 |
1 files changed, 92 insertions, 49 deletions
diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts index 0ffd0c302..914eb7f57 100644 --- a/server/typings/models/video/video.ts +++ b/server/typings/models/video/video.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | 1 | import { VideoModel } from '../../../models/video/video' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '../../utils' |
3 | import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels' | 3 | import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels' |
4 | import { MTag } from './tag' | 4 | import { MTag } from './tag' |
5 | import { MVideoCaptionLanguage } from './video-caption' | 5 | import { MVideoCaptionLanguage } from './video-caption' |
6 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' | 6 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' |
@@ -10,10 +10,16 @@ import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blackl | |||
10 | import { MScheduleVideoUpdate } from './schedule-video-update' | 10 | import { MScheduleVideoUpdate } from './schedule-video-update' |
11 | import { MUserVideoHistoryTime } from '../user/user-video-history' | 11 | import { MUserVideoHistoryTime } from '../user/user-video-history' |
12 | 12 | ||
13 | type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M> | ||
14 | |||
15 | // ############################################################################ | ||
16 | |||
13 | export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | | 17 | export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | |
14 | 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' | | 18 | 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' | |
15 | 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'> | 19 | 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'> |
16 | 20 | ||
21 | // ############################################################################ | ||
22 | |||
17 | export type MVideoId = Pick<MVideo, 'id'> | 23 | export type MVideoId = Pick<MVideo, 'id'> |
18 | export type MVideoUrl = Pick<MVideo, 'url'> | 24 | export type MVideoUrl = Pick<MVideo, 'url'> |
19 | export type MVideoUUID = Pick<MVideo, 'uuid'> | 25 | export type MVideoUUID = Pick<MVideo, 'uuid'> |
@@ -21,83 +27,120 @@ export type MVideoUUID = Pick<MVideo, 'uuid'> | |||
21 | export type MVideoIdUrl = MVideoId & MVideoUrl | 27 | export type MVideoIdUrl = MVideoId & MVideoUrl |
22 | export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> | 28 | export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> |
23 | 29 | ||
30 | // ############################################################################ | ||
31 | |||
32 | // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists | ||
33 | |||
34 | // "With" to not confuse with the VideoFile model | ||
24 | export type MVideoWithFile = MVideo & | 35 | export type MVideoWithFile = MVideo & |
25 | PickWith<VideoModel, 'VideoFiles', MVideoFile[]> | 36 | Use<'VideoFiles', MVideoFile[]> |
26 | 37 | ||
27 | export type MVideoThumbnail = MVideo & | 38 | export type MVideoThumbnail = MVideo & |
28 | PickWith<VideoModel, 'Thumbnails', MThumbnail[]> | 39 | Use<'Thumbnails', MThumbnail[]> |
29 | export type MVideoIdThumbnail = MVideoThumbnail & MVideoId | 40 | |
41 | export type MVideoIdThumbnail = MVideoId & | ||
42 | Use<'Thumbnails', MThumbnail[]> | ||
43 | |||
44 | export type MVideoWithFileThumbnail = MVideo & | ||
45 | Use<'VideoFiles', MVideoFile[]> & | ||
46 | Use<'Thumbnails', MThumbnail[]> | ||
30 | 47 | ||
31 | export type MVideoTag = MVideo & | 48 | export type MVideoTag = MVideo & |
32 | PickWith<VideoModel, 'Tags', MTag[]> | 49 | Use<'Tags', MTag[]> |
33 | 50 | ||
34 | export type MVideoWithSchedule = MVideo & | 51 | export type MVideoWithSchedule = MVideo & |
35 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | 52 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> |
36 | 53 | ||
37 | export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail | 54 | export type MVideoWithCaptions = MVideo & |
55 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | ||
38 | 56 | ||
39 | export type MVideoUser = MVideo & | 57 | export type MVideoWithStreamingPlaylist = MVideo & |
40 | PickWith<VideoModel, 'VideoChannel', MChannelUserId> | 58 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> |
41 | 59 | ||
42 | export type MVideoWithCaptions = MVideo & | 60 | // ############################################################################ |
43 | PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]> | 61 | |
62 | // Associations with not all their attributes | ||
63 | |||
64 | export type MVideoUserHistory = MVideo & | ||
65 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | ||
44 | 66 | ||
45 | export type MVideoWithBlacklistLight = MVideo & | 67 | export type MVideoWithBlacklistLight = MVideo & |
46 | PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight> | 68 | Use<'VideoBlacklist', MVideoBlacklistLight> |
47 | 69 | ||
48 | export type MVideoAccountLight = MVideo & | 70 | export type MVideoAccountLight = MVideo & |
49 | PickWith<VideoModel, 'VideoChannel', MChannelAccountLight> | 71 | Use<'VideoChannel', MChannelAccountLight> |
50 | 72 | ||
51 | export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser | 73 | export type MVideoWithRights = MVideo & |
74 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
75 | Use<'Thumbnails', MThumbnail[]> & | ||
76 | Use<'VideoChannel', MChannelUserId> | ||
52 | 77 | ||
53 | export type MVideoWithStreamingPlaylist = MVideo & | 78 | // ############################################################################ |
54 | PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
55 | 79 | ||
56 | export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist | 80 | // All files with some additional associations |
57 | 81 | ||
58 | export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight | 82 | export type MVideoWithAllFiles = MVideo & |
59 | export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions | 83 | Use<'VideoFiles', MVideoFile[]> & |
84 | Use<'Thumbnails', MThumbnail[]> & | ||
85 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
60 | 86 | ||
61 | export type MVideoUserHistory = MVideo & | 87 | export type MVideoAccountLightBlacklistAllFiles = MVideo & |
62 | PickWith<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> | 88 | Use<'VideoFiles', MVideoFile[]> & |
89 | Use<'Thumbnails', MThumbnail[]> & | ||
90 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & | ||
91 | Use<'VideoChannel', MChannelAccountLight> & | ||
92 | Use<'VideoBlacklist', MVideoBlacklistLight> | ||
63 | 93 | ||
64 | export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail | 94 | // ############################################################################ |
95 | |||
96 | // With account | ||
65 | 97 | ||
66 | export type MVideoAccountDefault = MVideo & | 98 | export type MVideoAccountDefault = MVideo & |
67 | PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> | 99 | Use<'VideoChannel', MChannelAccountDefault> |
68 | 100 | ||
69 | export type MVideoThumbnailAccountDefault = MVideoThumbnail & | 101 | export type MVideoThumbnailAccountDefault = MVideo & |
70 | PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> | 102 | Use<'Thumbnails', MThumbnail[]> & |
103 | Use<'VideoChannel', MChannelAccountDefault> | ||
71 | 104 | ||
72 | export type MVideoWithChannelActor = MVideo & | 105 | export type MVideoWithChannelActor = MVideo & |
73 | PickWith<VideoModel, 'VideoChannel', MChannelActor> | 106 | Use<'VideoChannel', MChannelActor> |
74 | 107 | ||
75 | export type MVideoFullLight = MVideoThumbnail & | 108 | export type MVideoFullLight = MVideo & |
76 | MVideoWithBlacklistLight & | 109 | Use<'Thumbnails', MThumbnail[]> & |
77 | MVideoTag & | 110 | Use<'VideoBlacklist', MVideoBlacklistLight> & |
78 | MVideoAccountLight & | 111 | Use<'Tags', MTag[]> & |
79 | MVideoUserHistory & | 112 | Use<'VideoChannel', MChannelAccountLight> & |
80 | MVideoWithFile & | 113 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & |
81 | MVideoWithSchedule & | 114 | Use<'VideoFiles', MVideoFile[]> & |
82 | MVideoWithStreamingPlaylist & | 115 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & |
83 | MVideoUserHistory | 116 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> |
117 | |||
118 | // ############################################################################ | ||
119 | |||
120 | // API | ||
84 | 121 | ||
85 | export type MVideoAP = MVideo & | 122 | export type MVideoAP = MVideo & |
86 | MVideoTag & | 123 | Use<'Tags', MTag[]> & |
87 | MVideoAccountLight & | 124 | Use<'VideoChannel', MChannelAccountLight> & |
88 | MVideoWithStreamingPlaylist & | 125 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & |
89 | MVideoWithCaptions & | 126 | Use<'VideoCaptions', MVideoCaptionLanguage[]> & |
90 | PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistUnfederated> & | 127 | Use<'VideoBlacklist', MVideoBlacklistUnfederated> & |
91 | PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]> | 128 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |
92 | 129 | ||
93 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | 130 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> |
94 | 131 | ||
95 | export type MVideoDetails = MVideo & | 132 | export type MVideoDetails = MVideo & |
96 | MVideoWithBlacklistLight & | 133 | Use<'VideoBlacklist', MVideoBlacklistLight> & |
97 | MVideoTag & | 134 | Use<'Tags', MTag[]> & |
98 | MVideoAccountLight & | 135 | Use<'VideoChannel', MChannelAccountLight> & |
99 | MVideoWithSchedule & | 136 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & |
100 | MVideoThumbnail & | 137 | Use<'Thumbnails', MThumbnail[]> & |
101 | MVideoUserHistory & | 138 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & |
102 | PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | 139 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & |
103 | PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]> | 140 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> |
141 | |||
142 | export type MVideoForUser = MVideo & | ||
143 | Use<'VideoChannel', MChannelAccountDefault> & | ||
144 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | ||
145 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
146 | Use<'Thumbnails', MThumbnail[]> | ||