aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/video/video.ts
blob: 7f69a91dea37b770ee0f7d2c6ecb036af601ecb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { VideoModel } from '../../../models/video/video'
import { PickWith, PickWithOpt } from '../../utils'
import {
  MChannelAccountDefault,
  MChannelAccountLight,
  MChannelAccountSummaryFormattable,
  MChannelActor,
  MChannelFormattable,
  MChannelUserId
} from './video-channels'
import { MTag } from './tag'
import { MVideoCaptionLanguage } from './video-caption'
import { MStreamingPlaylistFiles, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist'
import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
import { MThumbnail } from './thumbnail'
import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
import { MScheduleVideoUpdate } from './schedule-video-update'
import { MUserVideoHistoryTime } from '../user/user-video-history'

type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>

// ############################################################################

export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
  'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
  'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>

// ############################################################################

export type MVideoId = Pick<MVideo, 'id'>
export type MVideoUrl = Pick<MVideo, 'url'>
export type MVideoUUID = Pick<MVideo, 'uuid'>

export type MVideoIdUrl = MVideoId & MVideoUrl
export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>

// ############################################################################

// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists

// "With" to not confuse with the VideoFile model
export type MVideoWithFile = MVideo &
  Use<'VideoFiles', MVideoFile[]> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>

export type MVideoThumbnail = MVideo &
  Use<'Thumbnails', MThumbnail[]>

export type MVideoIdThumbnail = MVideoId &
  Use<'Thumbnails', MThumbnail[]>

export type MVideoWithFileThumbnail = MVideo &
  Use<'VideoFiles', MVideoFile[]> &
  Use<'Thumbnails', MThumbnail[]>

export type MVideoThumbnailBlacklist = MVideo &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoBlacklist', MVideoBlacklistLight>

export type MVideoTag = MVideo &
  Use<'Tags', MTag[]>

export type MVideoWithSchedule = MVideo &
  PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>

export type MVideoWithCaptions = MVideo &
  Use<'VideoCaptions', MVideoCaptionLanguage[]>

export type MVideoWithStreamingPlaylist = MVideo &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>

// ############################################################################

// Associations with not all their attributes

export type MVideoUserHistory = MVideo &
  Use<'UserVideoHistories', MUserVideoHistoryTime[]>

export type MVideoWithBlacklistLight = MVideo &
  Use<'VideoBlacklist', MVideoBlacklistLight>

export type MVideoAccountLight = MVideo &
  Use<'VideoChannel', MChannelAccountLight>

export type MVideoWithRights = MVideo &
  Use<'VideoBlacklist', MVideoBlacklistLight> &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoChannel', MChannelUserId>

// ############################################################################

// All files with some additional associations

export type MVideoWithAllFiles = MVideo &
  Use<'VideoFiles', MVideoFile[]> &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>

export type MVideoAccountLightBlacklistAllFiles = MVideo &
  Use<'VideoFiles', MVideoFile[]> &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
  Use<'VideoChannel', MChannelAccountLight> &
  Use<'VideoBlacklist', MVideoBlacklistLight>

// ############################################################################

// With account

export type MVideoAccountDefault = MVideo &
  Use<'VideoChannel', MChannelAccountDefault>

export type MVideoThumbnailAccountDefault = MVideo &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoChannel', MChannelAccountDefault>

export type MVideoWithChannelActor = MVideo &
  Use<'VideoChannel', MChannelActor>

export type MVideoFullLight = MVideo &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'VideoBlacklist', MVideoBlacklistLight> &
  Use<'Tags', MTag[]> &
  Use<'VideoChannel', MChannelAccountLight> &
  Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
  Use<'VideoFiles', MVideoFile[]> &
  Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>

// ############################################################################

// API

export type MVideoAP = MVideo &
  Use<'Tags', MTag[]> &
  Use<'VideoChannel', MChannelAccountLight> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
  Use<'VideoCaptions', MVideoCaptionLanguage[]> &
  Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
  Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
  Use<'Thumbnails', MThumbnail[]>

export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>

export type MVideoDetails = MVideo &
  Use<'VideoBlacklist', MVideoBlacklistLight> &
  Use<'Tags', MTag[]> &
  Use<'VideoChannel', MChannelAccountLight> &
  Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  Use<'Thumbnails', MThumbnail[]> &
  Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
  Use<'VideoFiles', MVideoFileRedundanciesOpt[]>

export type MVideoForUser = MVideo &
  Use<'VideoChannel', MChannelAccountDefault> &
  Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  Use<'VideoBlacklist', MVideoBlacklistLight> &
  Use<'Thumbnails', MThumbnail[]>

// ############################################################################

// Format for API or AP object

export type MVideoFormattable = MVideo &
  PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
  Use<'VideoChannel', MChannelAccountSummaryFormattable> &
  PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
  PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>

export type MVideoFormattableDetails = MVideoFormattable &
  Use<'VideoChannel', MChannelFormattable> &
  Use<'Tags', MTag[]> &
  Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
  Use<'VideoFiles', MVideoFileRedundanciesOpt[]>