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

127 lines
3.7 KiB
TypeScript
Raw Normal View History

2019-08-20 19:05:31 +02:00
import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2019-08-15 11:53:26 +02:00
import { VideoChannelModel } from '../../../models/video/video-channel'
import {
MAccountActor,
MAccountAPI,
MAccountDefault,
2019-08-20 19:05:31 +02:00
MAccountFormattable,
2019-08-15 11:53:26 +02:00
MAccountLight,
2019-08-20 13:52:49 +02:00
MAccountSummaryBlocks,
2019-08-20 19:05:31 +02:00
MAccountSummaryFormattable,
2019-08-21 14:31:57 +02:00
MAccountUrl,
2019-08-15 11:53:26 +02:00
MAccountUserId,
MActor,
MActorAccountChannelId,
2019-08-21 14:31:57 +02:00
MActorAP,
2019-08-15 11:53:26 +02:00
MActorAPI,
MActorDefault,
2019-08-20 13:52:49 +02:00
MActorDefaultLight,
2019-08-20 19:05:31 +02:00
MActorFormattable,
2019-08-20 13:52:49 +02:00
MActorLight,
2019-08-20 19:05:31 +02:00
MActorSummary,
2019-08-21 14:31:57 +02:00
MActorSummaryFormattable, MActorUrl
2019-08-15 11:53:26 +02:00
} 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
2019-08-21 14:31:57 +02:00
export type MChannelUrl = Use<'Actor', MActorUrl>
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 19:05:31 +02:00
export type MChannelSummary = FunctionProperties<MChannel> &
Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
2019-08-20 13:52:49 +02:00
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>
2019-08-20 19:05:31 +02: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>
2019-08-21 14:31:57 +02:00
export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> &
Use<'Actor', MActorAP> &
Use<'Account', MAccountUrl>