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/account/actor.ts | 93 ++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 32 deletions(-) (limited to 'server/typings/models/account/actor.ts') diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts index f3e752a98..7d99a433b 100644 --- a/server/typings/models/account/actor.ts +++ b/server/typings/models/account/actor.ts @@ -1,74 +1,103 @@ import { ActorModel } from '../../../models/activitypub/actor' import { PickWith } from '../../utils' -import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account' -import { MServerHost, MServerHostBlocks, MServer } from '../server' +import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' +import { MServer, MServerHost, MServerHostBlocks } from '../server' import { MAvatar } from './avatar' -import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video' +import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' + +type Use = PickWith + +// ############################################################################ export type MActor = Omit +// ############################################################################ + export type MActorUrl = Pick export type MActorId = Pick export type MActorUsername = Pick -export type MActorHost = PickWith export type MActorFollowersUrl = Pick export type MActorAudience = MActorUrl & MActorFollowersUrl +export type MActorFollowerException = Pick +export type MActorSignature = MActorAccountChannelId export type MActorLight = Omit +// ############################################################################ + +// Some association attributes + +export type MActorHost = Use<'Server', MServerHost> + export type MActorDefaultLight = MActorLight & - MActorHost & - PickWith + Use<'Server', MServerHost> & + Use<'Avatar', MAvatar> export type MActorAccountId = MActor & - PickWith + Use<'Account', MAccountId> export type MActorAccountIdActor = MActor & - PickWith + Use<'Account', MAccountIdActor> export type MActorChannelId = MActor & - PickWith + Use<'VideoChannel', MChannelId> export type MActorChannelIdActor = MActor & - PickWith + Use<'VideoChannel', MChannelIdActor> export type MActorAccountChannelId = MActorAccountId & MActorChannelId export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor +// ############################################################################ + +// Include raw account/channel/server + export type MActorAccount = MActor & - PickWith + Use<'Account', MAccount> export type MActorChannel = MActor & - PickWith + Use<'VideoChannel', MChannel> export type MActorAccountChannel = MActorAccount & MActorChannel -export type MActorChannelAccount = MActor & - PickWith - export type MActorServer = MActor & - PickWith + Use<'Server', MServer> -export type MActorDefault = MActorServer & - PickWith +// ############################################################################ -export type MActorFull = MActorDefault & - PickWith & - PickWith +// Complex actor associations -export type MActorFullActor = MActorDefault & - PickWith & - PickWith +export type MActorDefault = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> -export type MActorSummary = Pick & - MActorHost & - PickWith +// Actor with channel that is associated to an account and its actor +// Actor -> VideoChannel -> Account -> Actor +export type MActorChannelAccountActor = MActor & + Use<'VideoChannel', MChannelAccountActor> -export type MActorSummaryBlocks = Omit & - PickWith +export type MActorFull = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> & + Use<'Account', MAccount> & + Use<'VideoChannel', MChannelAccountActor> -export type MActorFollowerException = Pick +// Same than ActorFull, but the account and the channel have their actor +export type MActorFullActor = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> & + Use<'Account', MAccountDefault> & + Use<'VideoChannel', MChannelAccountDefault> + +// ############################################################################ + +// API + +export type MActorSummary = Pick & + Use<'Server', MServerHost> & + Use<'Avatar', MAvatar> + +export type MActorSummaryBlocks = MActorSummary & + Use<'Server', MServerHostBlocks> export type MActorAPI = Omit - -export type MActorSignature = MActorAccountChannelId -- cgit v1.2.3