PeerTube/server/typings/models/video/video.ts

212 lines
6.9 KiB
TypeScript
Raw Normal View History

2019-08-15 04:53:26 -05:00
import { VideoModel } from '../../../models/video/video'
import { PickWith, PickWithOpt } from '../../utils'
2019-08-20 12:05:31 -05:00
import {
MChannelAccountDefault,
MChannelAccountLight,
MChannelAccountSummaryFormattable,
MChannelActor,
MChannelFormattable,
MChannelUserId
} from './video-channels'
2019-08-15 04:53:26 -05:00
import { MTag } from './tag'
import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
2020-01-10 03:11:28 -06:00
import {
MStreamingPlaylistFiles,
MStreamingPlaylistRedundancies,
MStreamingPlaylistRedundanciesAll,
MStreamingPlaylistRedundanciesOpt
} from './video-streaming-playlist'
import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
2019-08-15 04:53:26 -05:00
import { MThumbnail } from './thumbnail'
2019-08-20 12:05:31 -05:00
import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
2019-08-15 04:53:26 -05:00
import { MScheduleVideoUpdate } from './schedule-video-update'
import { MUserVideoHistoryTime } from '../user/user-video-history'
2019-08-20 06:52:49 -05:00
type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
// ############################################################################
2020-01-31 09:56:52 -06:00
export type MVideo =
Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
2019-08-15 04:53:26 -05:00
'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
2019-08-20 06:52:49 -05:00
// ############################################################################
2019-08-15 04:53:26 -05:00
export type MVideoId = Pick<MVideo, 'id'>
export type MVideoUrl = Pick<MVideo, 'url'>
export type MVideoUUID = Pick<MVideo, 'uuid'>
export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid'>
2019-08-15 04:53:26 -05:00
export type MVideoIdUrl = MVideoId & MVideoUrl
export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
2019-08-20 06:52:49 -05:00
// ############################################################################
// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
// "With" to not confuse with the VideoFile model
2020-01-31 09:56:52 -06:00
export type MVideoWithFile =
MVideo &
Use<'VideoFiles', MVideoFile[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoThumbnail =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'Thumbnails', MThumbnail[]>
2020-01-31 09:56:52 -06:00
export type MVideoIdThumbnail =
MVideoId &
2019-08-20 06:52:49 -05:00
Use<'Thumbnails', MThumbnail[]>
2020-01-31 09:56:52 -06:00
export type MVideoWithFileThumbnail =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoThumbnailBlacklist =
MVideo &
2019-08-22 03:46:54 -05:00
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoBlacklist', MVideoBlacklistLight>
2020-01-31 09:56:52 -06:00
export type MVideoTag =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'Tags', MTag[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithSchedule =
MVideo &
2019-08-15 04:53:26 -05:00
PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
2020-01-31 09:56:52 -06:00
export type MVideoWithCaptions =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoCaptions', MVideoCaptionLanguage[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithStreamingPlaylist =
MVideo &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// ############################################################################
// Associations with not all their attributes
2020-01-31 09:56:52 -06:00
export type MVideoUserHistory =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'UserVideoHistories', MUserVideoHistoryTime[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithBlacklistLight =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoBlacklist', MVideoBlacklistLight>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoAccountLight =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelAccountLight>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithRights =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoChannel', MChannelUserId>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// ############################################################################
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// All files with some additional associations
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithAllFiles =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoAccountLightBlacklistAllFiles =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelAccountLight> &
Use<'VideoBlacklist', MVideoBlacklistLight>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
// ############################################################################
// With account
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoAccountDefault =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelAccountDefault>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoThumbnailAccountDefault =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoChannel', MChannelAccountDefault>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoWithChannelActor =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelActor>
2020-01-31 09:56:52 -06:00
export type MVideoFullLight =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
Use<'VideoFiles', MVideoFile[]> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
2019-08-20 06:52:49 -05:00
// ############################################################################
// API
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoAP =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
2019-08-20 06:52:49 -05:00
Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
Use<'Thumbnails', MThumbnail[]>
2019-08-15 04:53:26 -05:00
export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
2020-01-31 09:56:52 -06:00
export type MVideoDetails =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'Thumbnails', MThumbnail[]> &
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
2020-01-31 09:56:52 -06:00
export type MVideoForUser =
MVideo &
2019-08-20 06:52:49 -05:00
Use<'VideoChannel', MChannelAccountDefault> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Thumbnails', MThumbnail[]>
2019-08-20 12:05:31 -05:00
2020-01-31 09:56:52 -06:00
export type MVideoForRedundancyAPI =
MVideo &
2020-01-10 03:11:28 -06:00
Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
2019-08-20 12:05:31 -05:00
// ############################################################################
// Format for API or AP object
2020-01-31 09:56:52 -06:00
export type MVideoFormattable =
MVideo &
2019-08-20 12:05:31 -05:00
PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
Use<'VideoChannel', MChannelAccountSummaryFormattable> &
PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
2020-01-31 09:56:52 -06:00
export type MVideoFormattableDetails =
MVideoFormattable &
2019-08-20 12:05:31 -05:00
Use<'VideoChannel', MChannelFormattable> &
Use<'Tags', MTag[]> &
2019-08-21 07:31:57 -05:00
Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
2019-08-20 12:05:31 -05:00
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>