]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/video/video-streaming-playlist.ts
Fix tests
[github/Chocobozzz/PeerTube.git] / server / typings / models / video / video-streaming-playlist.ts
1 import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist'
2 import { PickWith, PickWithOpt } from '../../utils'
3 import { MVideoRedundancyFileUrl, MVideoRedundancy } from './video-redundancy'
4 import { MVideo } from './video'
5 import { MVideoFile } from './video-file'
6
7 type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M>
8
9 // ############################################################################
10
11 export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos' | 'VideoFiles'>
12
13 export type MStreamingPlaylistFiles = MStreamingPlaylist &
14 Use<'VideoFiles', MVideoFile[]>
15
16 export type MStreamingPlaylistVideo = MStreamingPlaylist &
17 Use<'Video', MVideo>
18
19 export type MStreamingPlaylistFilesVideo = MStreamingPlaylist &
20 Use<'VideoFiles', MVideoFile[]> &
21 Use<'Video', MVideo>
22
23 export type MStreamingPlaylistRedundanciesAll = MStreamingPlaylist &
24 Use<'VideoFiles', MVideoFile[]> &
25 Use<'RedundancyVideos', MVideoRedundancy[]>
26
27 export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
28 Use<'VideoFiles', MVideoFile[]> &
29 Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>
30
31 export type MStreamingPlaylistRedundanciesOpt = MStreamingPlaylist &
32 Use<'VideoFiles', MVideoFile[]> &
33 PickWithOpt<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
34
35 export function isStreamingPlaylist (value: MVideo | MStreamingPlaylistVideo): value is MStreamingPlaylistVideo {
36 return !!(value as MStreamingPlaylist).playlistUrl
37 }