From 0283eaac2a8e73006c66df3cf5bb9012e37450e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 13:52:49 +0200 Subject: Cleanup model types --- server/typings/models/video/video-channels.ts | 95 +++++++++++++++++---------- 1 file changed, 61 insertions(+), 34 deletions(-) (limited to 'server/typings/models/video/video-channels.ts') diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts index e10bd6842..b6506ed9f 100644 --- a/server/typings/models/video/video-channels.ts +++ b/server/typings/models/video/video-channels.ts @@ -1,70 +1,97 @@ -import { FunctionProperties, PickWith } from '../../utils' +import { PickWith } from '../../utils' import { VideoChannelModel } from '../../../models/video/video-channel' import { MAccountActor, MAccountAPI, - MAccountBlocks, MAccountDefault, MAccountLight, + MAccountSummaryBlocks, MAccountUserId, MActor, MActorAccountChannelId, MActorAPI, MActorDefault, - MActorDefaultLight, MActorLight, + MActorDefaultLight, + MActorLight, MActorSummary } from '../account' import { MVideo } from './video' -export type MChannelId = FunctionProperties -export type MChannelIdActor = MChannelId & - PickWith +type Use = PickWith + +// ############################################################################ export type MChannel = Omit +// ############################################################################ + +export type MChannelId = Pick + +// ############################################################################ + +export type MChannelIdActor = MChannelId & + Use<'Actor', MActorAccountChannelId> + export type MChannelUserId = Pick & - PickWith + Use<'Account', MAccountUserId> + +export type MChannelActor = MChannel & + Use<'Actor', MActor> // Default scope export type MChannelDefault = MChannel & - PickWith + Use<'Actor', MActorDefault> + +// ############################################################################ + +// Not all association attributes export type MChannelLight = MChannel & - PickWith + Use<'Actor', MActorDefaultLight> -export type MChannelAccountLight = MChannel & - PickWith & - PickWith +export type MChannelActorLight = MChannel & + Use<'Actor', MActorLight> -export type MChannelSummary = Pick & - PickWith +export type MChannelAccountLight = MChannel & + Use<'Actor', MActorDefaultLight> & + Use<'Account', MAccountLight> -export type MChannelSummaryAccount = MChannelSummary & - PickWith +// ############################################################################ -export type MChannelAPI = MChannel & - PickWith & - PickWith +// Account associations export type MChannelAccountActor = MChannel & - PickWith -export type MChannelAccountDefault = MChannelActor & - PickWith + Use<'Account', MAccountActor> + +export type MChannelAccountDefault = MChannel & + Use<'Actor', MActorDefault> & + Use<'Account', MAccountDefault> +export type MChannelActorAccountActor = MChannel & + Use<'Account', MAccountActor> & + Use<'Actor', MActor> + +// ############################################################################ + +// Videos associations export type MChannelVideos = MChannel & - PickWith + Use<'Videos', MVideo[]> -export type MChannelActor = MChannel & - PickWith -export type MChannelActorLight = MChannel & - PickWith -export type MChannelActorDefault = MChannel & - PickWith +export type MChannelActorAccountDefaultVideos = MChannel & + Use<'Actor', MActorDefault> & + Use<'Account', MAccountDefault> & + Use<'Videos', MVideo[]> + +// ############################################################################ + +// For API -export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor +export type MChannelSummary = Pick & + Use<'Actor', MActorSummary> -export type MChannelActorAccountDefault = MChannel & - PickWith & - PickWith +export type MChannelSummaryAccount = MChannelSummary & + Use<'Account', MAccountSummaryBlocks> -export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos +export type MChannelAPI = MChannel & + Use<'Actor', MActorAPI> & + Use<'Account', MAccountAPI> -- cgit v1.2.3