From 1ca9f7c3f7afac2af4c4c25b98426731f7e789c6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 19:05:31 +0200 Subject: Type toFormattedJSON --- server/typings/models/account/account-blocklist.ts | 10 +++++++++- server/typings/models/account/account.ts | 21 +++++++++++++++++--- server/typings/models/account/actor-follow.ts | 16 +++++++++++++-- server/typings/models/account/actor.ts | 23 ++++++++++++++++++---- server/typings/models/account/avatar.ts | 8 ++++++++ 5 files changed, 68 insertions(+), 10 deletions(-) (limited to 'server/typings/models/account') diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts index d20d97aa8..c9cb55332 100644 --- a/server/typings/models/account/account-blocklist.ts +++ b/server/typings/models/account/account-blocklist.ts @@ -1,6 +1,6 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist' import { PickWith } from '../../utils' -import { MAccountDefault } from './account' +import { MAccountDefault, MAccountFormattable } from './account' type Use = PickWith @@ -15,3 +15,11 @@ export type MAccountBlocklistId = Pick export type MAccountBlocklistAccounts = MAccountBlocklist & Use<'ByAccount', MAccountDefault> & Use<'BlockedAccount', MAccountDefault> + +// ############################################################################ + +// Format for API or AP object + +export type MAccountBlocklistFormattable = Pick & + Use<'ByAccount', MAccountFormattable> & + Use<'BlockedAccount', MAccountFormattable> diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts index 9a8784e6b..33940517e 100644 --- a/server/typings/models/account/account.ts +++ b/server/typings/models/account/account.ts @@ -9,9 +9,11 @@ import { MActorId, MActorServer, MActorSummary, - MActorUrl + MActorSummaryFormattable, + MActorUrl, + MActorFormattable } from './actor' -import { PickWith } from '../../utils' +import { FunctionProperties, PickWith } from '../../utils' import { MAccountBlocklistId } from './account-blocklist' import { MChannelDefault } from '@server/typings/models' @@ -67,7 +69,8 @@ export type MAccountServer = MAccount & // For API -export type MAccountSummary = Pick & +export type MAccountSummary = FunctionProperties & + Pick & Use<'Actor', MActorSummary> export type MAccountSummaryBlocks = MAccountSummary & @@ -75,3 +78,15 @@ export type MAccountSummaryBlocks = MAccountSummary & export type MAccountAPI = MAccount & Use<'Actor', MActorAPI> + +// ############################################################################ + +// Format for API or AP object + +export type MAccountSummaryFormattable = FunctionProperties & + Pick & + Use<'Actor', MActorSummaryFormattable> + +export type MAccountFormattable = FunctionProperties & + Pick & + Use<'Actor', MActorFormattable> diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts index 87050ac63..17a47b8df 100644 --- a/server/typings/models/account/actor-follow.ts +++ b/server/typings/models/account/actor-follow.ts @@ -3,14 +3,15 @@ import { MActor, MActorAccount, MActorAccountChannel, - MActorChannel, MActorChannelAccountActor, MActorDefault, + MActorFormattable, MActorHost, MActorUsername } from './actor' import { PickWith } from '../../utils' import { ActorModel } from '@server/models/activitypub/actor' +import { MChannelDefault } from '@server/typings/models' type Use = PickWith @@ -43,9 +44,12 @@ export type MActorFollowFull = MActorFollow & // For subscriptions +type SubscriptionFollowing = MActorDefault & + PickWith + export type MActorFollowActorsDefaultSubscription = MActorFollow & Use<'ActorFollower', MActorDefault> & - Use<'ActorFollowing', MActorDefault & MActorChannel> + Use<'ActorFollowing', SubscriptionFollowing> export type MActorFollowFollowingFullFollowerAccount = MActorFollow & Use<'ActorFollower', MActorAccount> & @@ -53,3 +57,11 @@ export type MActorFollowFollowingFullFollowerAccount = MActorFollow & export type MActorFollowSubscriptions = MActorFollow & Use<'ActorFollowing', MActorChannelAccountActor> + +// ############################################################################ + +// Format for API or AP object + +export type MActorFollowFormattable = Pick & + Use<'ActorFollower', MActorFormattable> & + Use<'ActorFollowing', MActorFormattable> diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts index 7d99a433b..14ab2cd5b 100644 --- a/server/typings/models/account/actor.ts +++ b/server/typings/models/account/actor.ts @@ -1,8 +1,8 @@ import { ActorModel } from '../../../models/activitypub/actor' -import { PickWith } from '../../utils' +import { FunctionProperties, PickWith } from '../../utils' import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' -import { MServer, MServerHost, MServerHostBlocks } from '../server' -import { MAvatar } from './avatar' +import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' +import { MAvatar, MAvatarFormattable } from './avatar' import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' type Use = PickWith @@ -29,6 +29,7 @@ export type MActorLight = Omit // Some association attributes export type MActorHost = Use<'Server', MServerHost> +export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed> export type MActorDefaultLight = MActorLight & Use<'Server', MServerHost> & @@ -92,7 +93,8 @@ export type MActorFullActor = MActor & // API -export type MActorSummary = Pick & +export type MActorSummary = FunctionProperties & + Pick & Use<'Server', MServerHost> & Use<'Avatar', MAvatar> @@ -101,3 +103,16 @@ export type MActorSummaryBlocks = MActorSummary & export type MActorAPI = Omit + +// ############################################################################ + +// Format for API or AP object + +export type MActorSummaryFormattable = FunctionProperties & + Pick & + Use<'Server', MServerHost> & + Use<'Avatar', MAvatarFormattable> + +export type MActorFormattable = MActorSummaryFormattable & + Pick & + Use<'Server', MServer> diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts index 257c48bfc..8af6cc787 100644 --- a/server/typings/models/account/avatar.ts +++ b/server/typings/models/account/avatar.ts @@ -1,3 +1,11 @@ import { AvatarModel } from '../../../models/avatar/avatar' +import { FunctionProperties } from '@server/typings/utils' export type MAvatar = AvatarModel + +// ############################################################################ + +// Format for API or AP object + +export type MAvatarFormattable = FunctionProperties & + Pick -- cgit v1.2.3