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

105 lines
3.4 KiB
TypeScript
Raw Normal View History

import { MVideoPlaylistElementLight } from '@server/types/models/video/video-playlist-element'
import { PickWith } from '@shared/typescript-utils'
2019-08-15 11:53:26 +02:00
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
2019-08-20 19:05:31 +02:00
import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account'
2019-08-15 11:53:26 +02:00
import { MThumbnail } from './thumbnail'
2019-08-21 14:31:57 +02:00
import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels'
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
2019-08-20 13:52:49 +02:00
export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>
2019-08-20 19:05:31 +02:00
export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number }
2019-08-20 13:52:49 +02:00
// ############################################################################
// With elements
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistWithElements =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistIdWithElements =
MVideoPlaylistId &
2019-08-20 13:52:49 +02:00
Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
// ############################################################################
// With account
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistOwner =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccount>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistOwnerDefault =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccountDefault>
// ############################################################################
// With thumbnail
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistThumbnail =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'Thumbnail', MThumbnail>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistAccountThumbnail =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccountDefault> &
Use<'Thumbnail', MThumbnail>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// ############################################################################
// With channel
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistAccountChannelDefault =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccountDefault> &
Use<'VideoChannel', MChannelDefault>
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
// With all associations
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistFull =
2021-06-17 16:02:38 +02:00
MVideoPlaylistVideosLength &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccountDefault> &
Use<'VideoChannel', MChannelDefault> &
Use<'Thumbnail', MThumbnail>
// ############################################################################
// For API
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistAccountChannelSummary =
MVideoPlaylist &
2019-08-20 13:52:49 +02:00
Use<'OwnerAccount', MAccountSummary> &
Use<'VideoChannel', MChannelSummary>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistFullSummary =
2021-06-17 16:02:38 +02:00
MVideoPlaylistVideosLength &
2019-08-20 13:52:49 +02:00
Use<'Thumbnail', MThumbnail> &
Use<'OwnerAccount', MAccountSummary> &
Use<'VideoChannel', MChannelSummary>
2019-08-20 19:05:31 +02:00
// ############################################################################
// Format for API or AP object
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistFormattable =
MVideoPlaylistVideosLength &
2019-08-20 19:05:31 +02:00
Use<'OwnerAccount', MAccountSummaryFormattable> &
Use<'VideoChannel', MChannelSummaryFormattable>
2019-08-21 14:31:57 +02:00
2020-01-31 16:56:52 +01:00
export type MVideoPlaylistAP =
MVideoPlaylist &
2019-08-21 14:31:57 +02:00
Use<'Thumbnail', MThumbnail> &
Use<'VideoChannel', MChannelUrl>