aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/video/video-file.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-18 10:45:25 +0200
committerChocobozzz <me@florianbigard.com>2020-06-18 10:46:27 +0200
commit26d6bf6533023326fa017812cf31bbe20c752d36 (patch)
tree9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types/models/video/video-file.ts
parentd6d951ddc0c492f3261065b5dcb4df0534d252fc (diff)
downloadPeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip
Split types and typings
Diffstat (limited to 'server/types/models/video/video-file.ts')
-rw-r--r--server/types/models/video/video-file.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/server/types/models/video/video-file.ts b/server/types/models/video/video-file.ts
new file mode 100644
index 000000000..3fcaca78f
--- /dev/null
+++ b/server/types/models/video/video-file.ts
@@ -0,0 +1,43 @@
1import { VideoFileModel } from '../../../models/video/video-file'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideo, MVideoUUID } from './video'
4import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy'
5import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist'
6
7type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
8
9// ############################################################################
10
11export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos' | 'VideoStreamingPlaylist'>
12
13export type MVideoFileVideo =
14 MVideoFile &
15 Use<'Video', MVideo>
16
17export type MVideoFileStreamingPlaylist =
18 MVideoFile &
19 Use<'VideoStreamingPlaylist', MStreamingPlaylist>
20
21export type MVideoFileStreamingPlaylistVideo =
22 MVideoFile &
23 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
24
25export type MVideoFileVideoUUID =
26 MVideoFile &
27 Use<'Video', MVideoUUID>
28
29export type MVideoFileRedundanciesAll =
30 MVideoFile &
31 PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancy[]>
32
33export type MVideoFileRedundanciesOpt =
34 MVideoFile &
35 PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
36
37export function isStreamingPlaylistFile (file: any): file is MVideoFileStreamingPlaylist {
38 return !!file.videoStreamingPlaylistId
39}
40
41export function isWebtorrentFile (file: any): file is MVideoFileVideo {
42 return !!file.videoId
43}