]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/video/video.ts
Cleanup model types
[github/Chocobozzz/PeerTube.git] / server / typings / models / video / video.ts
1 import { VideoModel } from '../../../models/video/video'
2 import { PickWith, PickWithOpt } from '../../utils'
3 import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'
4 import { MTag } from './tag'
5 import { MVideoCaptionLanguage } from './video-caption'
6 import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
7 import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
8 import { MThumbnail } from './thumbnail'
9 import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
10 import { MScheduleVideoUpdate } from './schedule-video-update'
11 import { MUserVideoHistoryTime } from '../user/user-video-history'
12
13 type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
14
15 // ############################################################################
16
17 export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
18 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
19 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
20
21 // ############################################################################
22
23 export type MVideoId = Pick<MVideo, 'id'>
24 export type MVideoUrl = Pick<MVideo, 'url'>
25 export type MVideoUUID = Pick<MVideo, 'uuid'>
26
27 export type MVideoIdUrl = MVideoId & MVideoUrl
28 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
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
35 export type MVideoWithFile = MVideo &
36 Use<'VideoFiles', MVideoFile[]>
37
38 export type MVideoThumbnail = MVideo &
39 Use<'Thumbnails', MThumbnail[]>
40
41 export type MVideoIdThumbnail = MVideoId &
42 Use<'Thumbnails', MThumbnail[]>
43
44 export type MVideoWithFileThumbnail = MVideo &
45 Use<'VideoFiles', MVideoFile[]> &
46 Use<'Thumbnails', MThumbnail[]>
47
48 export type MVideoTag = MVideo &
49 Use<'Tags', MTag[]>
50
51 export type MVideoWithSchedule = MVideo &
52 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
53
54 export type MVideoWithCaptions = MVideo &
55 Use<'VideoCaptions', MVideoCaptionLanguage[]>
56
57 export type MVideoWithStreamingPlaylist = MVideo &
58 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
59
60 // ############################################################################
61
62 // Associations with not all their attributes
63
64 export type MVideoUserHistory = MVideo &
65 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
66
67 export type MVideoWithBlacklistLight = MVideo &
68 Use<'VideoBlacklist', MVideoBlacklistLight>
69
70 export type MVideoAccountLight = MVideo &
71 Use<'VideoChannel', MChannelAccountLight>
72
73 export type MVideoWithRights = MVideo &
74 Use<'VideoBlacklist', MVideoBlacklistLight> &
75 Use<'Thumbnails', MThumbnail[]> &
76 Use<'VideoChannel', MChannelUserId>
77
78 // ############################################################################
79
80 // All files with some additional associations
81
82 export type MVideoWithAllFiles = MVideo &
83 Use<'VideoFiles', MVideoFile[]> &
84 Use<'Thumbnails', MThumbnail[]> &
85 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
86
87 export type MVideoAccountLightBlacklistAllFiles = MVideo &
88 Use<'VideoFiles', MVideoFile[]> &
89 Use<'Thumbnails', MThumbnail[]> &
90 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
91 Use<'VideoChannel', MChannelAccountLight> &
92 Use<'VideoBlacklist', MVideoBlacklistLight>
93
94 // ############################################################################
95
96 // With account
97
98 export type MVideoAccountDefault = MVideo &
99 Use<'VideoChannel', MChannelAccountDefault>
100
101 export type MVideoThumbnailAccountDefault = MVideo &
102 Use<'Thumbnails', MThumbnail[]> &
103 Use<'VideoChannel', MChannelAccountDefault>
104
105 export type MVideoWithChannelActor = MVideo &
106 Use<'VideoChannel', MChannelActor>
107
108 export type MVideoFullLight = MVideo &
109 Use<'Thumbnails', MThumbnail[]> &
110 Use<'VideoBlacklist', MVideoBlacklistLight> &
111 Use<'Tags', MTag[]> &
112 Use<'VideoChannel', MChannelAccountLight> &
113 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
114 Use<'VideoFiles', MVideoFile[]> &
115 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
116 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
117
118 // ############################################################################
119
120 // API
121
122 export type MVideoAP = MVideo &
123 Use<'Tags', MTag[]> &
124 Use<'VideoChannel', MChannelAccountLight> &
125 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
126 Use<'VideoCaptions', MVideoCaptionLanguage[]> &
127 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
128 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
129
130 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
131
132 export type MVideoDetails = MVideo &
133 Use<'VideoBlacklist', MVideoBlacklistLight> &
134 Use<'Tags', MTag[]> &
135 Use<'VideoChannel', MChannelAccountLight> &
136 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
137 Use<'Thumbnails', MThumbnail[]> &
138 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
139 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
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[]>