PeerTube/server/core/types/models/video/video-redundancy.ts

44 lines
1.8 KiB
TypeScript
Raw Normal View History

import { VideoFileModel } from '@server/models/video/video-file.js'
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js'
import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils'
import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy.js'
import { MVideoUrl } from './video.js'
import { MVideoFile, MVideoFileVideo } from './video-file.js'
import { MStreamingPlaylistVideo } from './video-streaming-playlist.js'
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'>
export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2020-01-31 16:56:52 +01:00
export type MVideoRedundancyFile =
MVideoRedundancy &
2019-08-20 13:52:49 +02:00
Use<'VideoFile', MVideoFile>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoRedundancyFileVideo =
MVideoRedundancy &
2019-08-20 13:52:49 +02:00
Use<'VideoFile', MVideoFileVideo>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoRedundancyStreamingPlaylistVideo =
MVideoRedundancy &
2019-08-20 13:52:49 +02:00
Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoRedundancyVideo =
MVideoRedundancy &
2019-08-20 13:52:49 +02:00
Use<'VideoFile', MVideoFileVideo> &
Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
2019-08-21 14:31:57 +02:00
// ############################################################################
// Format for API or AP object
2020-01-31 16:56:52 +01:00
export type MVideoRedundancyAP =
MVideoRedundancy &
2019-08-21 14:31:57 +02:00
PickWithOpt<VideoRedundancyModel, 'VideoFile', MVideoFile & PickWith<VideoFileModel, 'Video', MVideoUrl>> &
PickWithOpt<VideoRedundancyModel, 'VideoStreamingPlaylist', PickWith<VideoStreamingPlaylistModel, 'Video', MVideoUrl>>