PeerTube/server/types/models/video/video.ts

224 lines
7.3 KiB
TypeScript
Raw Normal View History

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