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

119 lines
3.5 KiB
TypeScript
Raw Normal View History

2019-08-20 12:05:31 -05:00
import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2019-08-15 04:53:26 -05:00
import { VideoChannelModel } from '../../../models/video/video-channel'
import {
MAccountActor,
MAccountAPI,
MAccountDefault,
2019-08-20 12:05:31 -05:00
MAccountFormattable,
2019-08-15 04:53:26 -05:00
MAccountLight,
2019-08-20 06:52:49 -05:00
MAccountSummaryBlocks,
2019-08-20 12:05:31 -05:00
MAccountSummaryFormattable,
2019-08-15 04:53:26 -05:00
MAccountUserId,
MActor,
MActorAccountChannelId,
MActorAPI,
MActorDefault,
2019-08-20 06:52:49 -05:00
MActorDefaultLight,
2019-08-20 12:05:31 -05:00
MActorFormattable,
2019-08-20 06:52:49 -05:00
MActorLight,
2019-08-20 12:05:31 -05:00
MActorSummary,
MActorSummaryFormattable
2019-08-15 04:53:26 -05:00
} from '../account'
import { MVideo } from './video'
2019-08-20 06:52:49 -05:00
type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
// ############################################################################
2019-08-15 04:53:26 -05:00
export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
2019-08-20 06:52:49 -05:00
// ############################################################################
export type MChannelId = Pick<MChannel, 'id'>
// ############################################################################
export type MChannelIdActor = MChannelId &
Use<'Actor', MActorAccountChannelId>
2019-08-15 04:53:26 -05:00
export type MChannelUserId = Pick<MChannel, 'accountId'> &
2019-08-20 06:52:49 -05:00
Use<'Account', MAccountUserId>
export type MChannelActor = MChannel &
Use<'Actor', MActor>
2019-08-15 04:53:26 -05:00
// Default scope
export type MChannelDefault = MChannel &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorDefault>
// ############################################################################
// Not all association attributes
2019-08-15 04:53:26 -05:00
export type MChannelLight = MChannel &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorDefaultLight>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelActorLight = MChannel &
Use<'Actor', MActorLight>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelAccountLight = MChannel &
Use<'Actor', MActorDefaultLight> &
Use<'Account', MAccountLight>
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
// Account associations
2019-08-15 04:53:26 -05:00
export type MChannelAccountActor = MChannel &
2019-08-20 06:52:49 -05:00
Use<'Account', MAccountActor>
export type MChannelAccountDefault = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelActorAccountActor = MChannel &
Use<'Account', MAccountActor> &
Use<'Actor', MActor>
// ############################################################################
// Videos associations
2019-08-15 04:53:26 -05:00
export type MChannelVideos = MChannel &
2019-08-20 06:52:49 -05:00
Use<'Videos', MVideo[]>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelActorAccountDefaultVideos = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault> &
Use<'Videos', MVideo[]>
// ############################################################################
// For API
2019-08-15 04:53:26 -05:00
2019-08-20 12:05:31 -05:00
export type MChannelSummary = FunctionProperties<MChannel> &
Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
2019-08-20 06:52:49 -05:00
Use<'Actor', MActorSummary>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelSummaryAccount = MChannelSummary &
Use<'Account', MAccountSummaryBlocks>
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
export type MChannelAPI = MChannel &
Use<'Actor', MActorAPI> &
Use<'Account', MAccountAPI>
2019-08-20 12:05:31 -05:00
// ############################################################################
// Format for API or AP object
export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
Pick<MChannel, 'id' | 'name'> &
Use<'Actor', MActorSummaryFormattable>
export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
Use<'Account', MAccountSummaryFormattable>
export type MChannelFormattable = FunctionProperties<MChannel> &
Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
Use<'Actor', MActorFormattable> &
PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>