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

98 lines
2.7 KiB
TypeScript
Raw Normal View History

2019-08-20 13:52:49 +02:00
import { PickWith } from '../../utils'
2019-08-15 11:53:26 +02:00
import { VideoChannelModel } from '../../../models/video/video-channel'
import {
MAccountActor,
MAccountAPI,
MAccountDefault,
MAccountLight,
2019-08-20 13:52:49 +02:00
MAccountSummaryBlocks,
2019-08-15 11:53:26 +02:00
MAccountUserId,
MActor,
MActorAccountChannelId,
MActorAPI,
MActorDefault,
2019-08-20 13:52:49 +02:00
MActorDefaultLight,
MActorLight,
2019-08-15 11:53:26 +02:00
MActorSummary
} from '../account'
import { MVideo } from './video'
2019-08-20 13:52:49 +02:00
type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
2019-08-20 13:52:49 +02:00
// ############################################################################
export type MChannelId = Pick<MChannel, 'id'>
// ############################################################################
export type MChannelIdActor = MChannelId &
Use<'Actor', MActorAccountChannelId>
2019-08-15 11:53:26 +02:00
export type MChannelUserId = Pick<MChannel, 'accountId'> &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountUserId>
export type MChannelActor = MChannel &
Use<'Actor', MActor>
2019-08-15 11:53:26 +02:00
// Default scope
export type MChannelDefault = MChannel &
2019-08-20 13:52:49 +02:00
Use<'Actor', MActorDefault>
// ############################################################################
// Not all association attributes
2019-08-15 11:53:26 +02:00
export type MChannelLight = MChannel &
2019-08-20 13:52:49 +02:00
Use<'Actor', MActorDefaultLight>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelActorLight = MChannel &
Use<'Actor', MActorLight>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelAccountLight = MChannel &
Use<'Actor', MActorDefaultLight> &
Use<'Account', MAccountLight>
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
// Account associations
2019-08-15 11:53:26 +02:00
export type MChannelAccountActor = MChannel &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountActor>
export type MChannelAccountDefault = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelActorAccountActor = MChannel &
Use<'Account', MAccountActor> &
Use<'Actor', MActor>
// ############################################################################
// Videos associations
2019-08-15 11:53:26 +02:00
export type MChannelVideos = MChannel &
2019-08-20 13:52:49 +02:00
Use<'Videos', MVideo[]>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelActorAccountDefaultVideos = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault> &
Use<'Videos', MVideo[]>
// ############################################################################
// For API
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
Use<'Actor', MActorSummary>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelSummaryAccount = MChannelSummary &
Use<'Account', MAccountSummaryBlocks>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
export type MChannelAPI = MChannel &
Use<'Actor', MActorAPI> &
Use<'Account', MAccountAPI>