aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/models/video/video.ts')
-rw-r--r--server/typings/models/video/video.ts141
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 @@
1import { VideoModel } from '../../../models/video/video' 1import { VideoModel } from '../../../models/video/video'
2import { PickWith, PickWithOpt } from '../../utils' 2import { PickWith, PickWithOpt } from '../../utils'
3import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels' 3import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'
4import { MTag } from './tag' 4import { MTag } from './tag'
5import { MVideoCaptionLanguage } from './video-caption' 5import { MVideoCaptionLanguage } from './video-caption'
6import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' 6import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
@@ -10,10 +10,16 @@ import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blackl
10import { MScheduleVideoUpdate } from './schedule-video-update' 10import { MScheduleVideoUpdate } from './schedule-video-update'
11import { MUserVideoHistoryTime } from '../user/user-video-history' 11import { MUserVideoHistoryTime } from '../user/user-video-history'
12 12
13type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
14
15// ############################################################################
16
13export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | 17export 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
17export type MVideoId = Pick<MVideo, 'id'> 23export type MVideoId = Pick<MVideo, 'id'>
18export type MVideoUrl = Pick<MVideo, 'url'> 24export type MVideoUrl = Pick<MVideo, 'url'>
19export type MVideoUUID = Pick<MVideo, 'uuid'> 25export type MVideoUUID = Pick<MVideo, 'uuid'>
@@ -21,83 +27,120 @@ export type MVideoUUID = Pick<MVideo, 'uuid'>
21export type MVideoIdUrl = MVideoId & MVideoUrl 27export type MVideoIdUrl = MVideoId & MVideoUrl
22export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> 28export 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
24export type MVideoWithFile = MVideo & 35export type MVideoWithFile = MVideo &
25 PickWith<VideoModel, 'VideoFiles', MVideoFile[]> 36 Use<'VideoFiles', MVideoFile[]>
26 37
27export type MVideoThumbnail = MVideo & 38export type MVideoThumbnail = MVideo &
28 PickWith<VideoModel, 'Thumbnails', MThumbnail[]> 39 Use<'Thumbnails', MThumbnail[]>
29export type MVideoIdThumbnail = MVideoThumbnail & MVideoId 40
41export type MVideoIdThumbnail = MVideoId &
42 Use<'Thumbnails', MThumbnail[]>
43
44export type MVideoWithFileThumbnail = MVideo &
45 Use<'VideoFiles', MVideoFile[]> &
46 Use<'Thumbnails', MThumbnail[]>
30 47
31export type MVideoTag = MVideo & 48export type MVideoTag = MVideo &
32 PickWith<VideoModel, 'Tags', MTag[]> 49 Use<'Tags', MTag[]>
33 50
34export type MVideoWithSchedule = MVideo & 51export type MVideoWithSchedule = MVideo &
35 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> 52 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
36 53
37export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail 54export type MVideoWithCaptions = MVideo &
55 Use<'VideoCaptions', MVideoCaptionLanguage[]>
38 56
39export type MVideoUser = MVideo & 57export type MVideoWithStreamingPlaylist = MVideo &
40 PickWith<VideoModel, 'VideoChannel', MChannelUserId> 58 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
41 59
42export type MVideoWithCaptions = MVideo & 60// ############################################################################
43 PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]> 61
62// Associations with not all their attributes
63
64export type MVideoUserHistory = MVideo &
65 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
44 66
45export type MVideoWithBlacklistLight = MVideo & 67export type MVideoWithBlacklistLight = MVideo &
46 PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight> 68 Use<'VideoBlacklist', MVideoBlacklistLight>
47 69
48export type MVideoAccountLight = MVideo & 70export type MVideoAccountLight = MVideo &
49 PickWith<VideoModel, 'VideoChannel', MChannelAccountLight> 71 Use<'VideoChannel', MChannelAccountLight>
50 72
51export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser 73export type MVideoWithRights = MVideo &
74 Use<'VideoBlacklist', MVideoBlacklistLight> &
75 Use<'Thumbnails', MThumbnail[]> &
76 Use<'VideoChannel', MChannelUserId>
52 77
53export type MVideoWithStreamingPlaylist = MVideo & 78// ############################################################################
54 PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]>
55 79
56export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist 80// All files with some additional associations
57 81
58export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight 82export type MVideoWithAllFiles = MVideo &
59export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions 83 Use<'VideoFiles', MVideoFile[]> &
84 Use<'Thumbnails', MThumbnail[]> &
85 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
60 86
61export type MVideoUserHistory = MVideo & 87export 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
64export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail 94// ############################################################################
95
96// With account
65 97
66export type MVideoAccountDefault = MVideo & 98export type MVideoAccountDefault = MVideo &
67 PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> 99 Use<'VideoChannel', MChannelAccountDefault>
68 100
69export type MVideoThumbnailAccountDefault = MVideoThumbnail & 101export type MVideoThumbnailAccountDefault = MVideo &
70 PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> 102 Use<'Thumbnails', MThumbnail[]> &
103 Use<'VideoChannel', MChannelAccountDefault>
71 104
72export type MVideoWithChannelActor = MVideo & 105export type MVideoWithChannelActor = MVideo &
73 PickWith<VideoModel, 'VideoChannel', MChannelActor> 106 Use<'VideoChannel', MChannelActor>
74 107
75export type MVideoFullLight = MVideoThumbnail & 108export 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
85export type MVideoAP = MVideo & 122export 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
93export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> 130export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
94 131
95export type MVideoDetails = MVideo & 132export 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
142export type MVideoForUser = MVideo &
143 Use<'VideoChannel', MChannelAccountDefault> &
144 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
145 Use<'VideoBlacklist', MVideoBlacklistLight> &
146 Use<'Thumbnails', MThumbnail[]>