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