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

105 lines
3.3 KiB
TypeScript
Raw Normal View History

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