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

93 lines
3.3 KiB
TypeScript
Raw Normal View History

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