From b5fecbf44192144d1ca27c23a0b53922de288c10 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Aug 2019 14:31:57 +0200 Subject: Type toActivityPubObject functions --- server/typings/express.ts | 3 ++- server/typings/models/account/account.ts | 4 ++++ server/typings/models/account/actor.ts | 9 ++++++--- server/typings/models/video/video-channels.ts | 10 +++++++++- server/typings/models/video/video-comment.ts | 12 +++++++++--- server/typings/models/video/video-playlist-element.ts | 9 ++++----- server/typings/models/video/video-playlist.ts | 6 +++++- server/typings/models/video/video-redundancy.ts | 16 ++++++++++++++-- server/typings/models/video/video-streaming-playlist.ts | 7 +++++-- server/typings/models/video/video.ts | 4 ++-- 10 files changed, 60 insertions(+), 20 deletions(-) (limited to 'server/typings') diff --git a/server/typings/express.ts b/server/typings/express.ts index 1fd809c1b..3cc7c7632 100644 --- a/server/typings/express.ts +++ b/server/typings/express.ts @@ -22,7 +22,7 @@ import { import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist' import { MVideoImportDefault } from '@server/typings/models/video/video-import' import { MAccountBlocklist, MStreamingPlaylist, MVideoFile } from '@server/typings/models' -import { MVideoPlaylistElement } from '@server/typings/models/video/video-playlist-element' +import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/typings/models/video/video-playlist-element' import { MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate' import { MVideoChangeOwnershipFull } from './models/video/video-change-ownership' import { MPlugin, MServer } from '@server/typings/models/server' @@ -59,6 +59,7 @@ declare module 'express' { videoPlaylistSummary?: MVideoPlaylistFullSummary videoPlaylistElement?: MVideoPlaylistElement + videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy accountVideoRate?: MAccountVideoRateAccountVideo diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts index cd20fe81b..ec78fece8 100644 --- a/server/typings/models/account/account.ts +++ b/server/typings/models/account/account.ts @@ -1,6 +1,7 @@ import { AccountModel } from '../../../models/account/account' import { MActor, + MActorAP, MActorAPI, MActorAudience, MActorDefault, @@ -89,3 +90,6 @@ export type MAccountSummaryFormattable = FunctionProperties & export type MAccountFormattable = FunctionProperties & Pick & Use<'Actor', MActorFormattable> + +export type MAccountAP = Pick & + Use<'Actor', MActorAP> diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts index 14ab2cd5b..d4bcac4a3 100644 --- a/server/typings/models/account/actor.ts +++ b/server/typings/models/account/actor.ts @@ -1,5 +1,5 @@ import { ActorModel } from '../../../models/activitypub/actor' -import { FunctionProperties, PickWith } from '../../utils' +import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' import { MAvatar, MAvatarFormattable } from './avatar' @@ -29,7 +29,7 @@ export type MActorLight = Omit // Some association attributes export type MActorHost = Use<'Server', MServerHost> -export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed> +export type MActorRedundancyAllowedOpt = PickWithOpt export type MActorDefaultLight = MActorLight & Use<'Server', MServerHost> & @@ -115,4 +115,7 @@ export type MActorSummaryFormattable = FunctionProperties & export type MActorFormattable = MActorSummaryFormattable & Pick & - Use<'Server', MServer> + Use<'Server', MServerHost & Partial>> + +export type MActorAP = MActor & + Use<'Avatar', MAvatar> diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts index 2be7dd7ed..292d0ac95 100644 --- a/server/typings/models/video/video-channels.ts +++ b/server/typings/models/video/video-channels.ts @@ -8,16 +8,18 @@ import { MAccountLight, MAccountSummaryBlocks, MAccountSummaryFormattable, + MAccountUrl, MAccountUserId, MActor, MActorAccountChannelId, + MActorAP, MActorAPI, MActorDefault, MActorDefaultLight, MActorFormattable, MActorLight, MActorSummary, - MActorSummaryFormattable + MActorSummaryFormattable, MActorUrl } from '../account' import { MVideo } from './video' @@ -42,6 +44,8 @@ export type MChannelUserId = Pick & export type MChannelActor = MChannel & Use<'Actor', MActor> +export type MChannelUrl = Use<'Actor', MActorUrl> + // Default scope export type MChannelDefault = MChannel & Use<'Actor', MActorDefault> @@ -116,3 +120,7 @@ export type MChannelFormattable = FunctionProperties & Pick & Use<'Actor', MActorFormattable> & PickWithOpt + +export type MChannelAP = Pick & + Use<'Actor', MActorAP> & + Use<'Account', MAccountUrl> diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts index e8bccba0f..4fd1c29e8 100644 --- a/server/typings/models/video/video-comment.ts +++ b/server/typings/models/video/video-comment.ts @@ -1,7 +1,7 @@ import { VideoCommentModel } from '../../../models/video/video-comment' -import { PickWith } from '../../utils' -import { MAccountDefault, MAccountFormattable } from '../account' -import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' +import { PickWith, PickWithOpt } from '../../utils' +import { MAccountDefault, MAccountFormattable, MAccountUrl, MActorUrl } from '../account' +import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' type Use = PickWith @@ -10,6 +10,7 @@ type Use = PickWith export type MCommentTotalReplies = MComment & { totalReplies?: number } export type MCommentId = Pick +export type MCommentUrl = Pick // ############################################################################ @@ -49,3 +50,8 @@ export type MCommentAPI = MComment & { totalReplies: number } export type MCommentFormattable = MCommentTotalReplies & Use<'Account', MAccountFormattable> + +export type MCommentAP = MComment & + Use<'Account', MAccountUrl> & + PickWithOpt & + PickWithOpt diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts index 1c256fd25..7b1b993ce 100644 --- a/server/typings/models/video/video-playlist-element.ts +++ b/server/typings/models/video/video-playlist-element.ts @@ -19,11 +19,7 @@ export type MVideoPlaylistElementLight = Pick -// ############################################################################ - -// For API - -export type MVideoPlaylistElementAP = MVideoPlaylistElement & +export type MVideoPlaylistElementVideoUrlPlaylistPrivacy = MVideoPlaylistElement & Use<'Video', MVideoUrl> & Use<'VideoPlaylist', MVideoPlaylistPrivacy> @@ -33,3 +29,6 @@ export type MVideoPlaylistElementAP = MVideoPlaylistElement & export type MVideoPlaylistElementFormattable = MVideoPlaylistElement & Use<'Video', MVideoFormattable> + +export type MVideoPlaylistElementAP = MVideoPlaylistElement & + Use<'Video', MVideoUrl> diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts index a926106c5..a40c7aca9 100644 --- a/server/typings/models/video/video-playlist.ts +++ b/server/typings/models/video/video-playlist.ts @@ -2,7 +2,7 @@ import { VideoPlaylistModel } from '../../../models/video/video-playlist' import { PickWith } from '../../utils' import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' import { MThumbnail } from './thumbnail' -import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels' +import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' type Use = PickWith @@ -86,3 +86,7 @@ export type MVideoPlaylistFullSummary = MVideoPlaylist & export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength & Use<'OwnerAccount', MAccountSummaryFormattable> & Use<'VideoChannel', MChannelSummaryFormattable> + +export type MVideoPlaylistAP = MVideoPlaylist & + Use<'Thumbnail', MThumbnail> & + Use<'VideoChannel', MChannelUrl> diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts index c25eb9c09..f3846afd7 100644 --- a/server/typings/models/video/video-redundancy.ts +++ b/server/typings/models/video/video-redundancy.ts @@ -1,6 +1,10 @@ import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' -import { PickWith } from '@server/typings/utils' -import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models' +import { PickWith, PickWithOpt } from '@server/typings/utils' +import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo, MVideoUrl } from '@server/typings/models' +import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model' +import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' +import { VideoFile } from '../../../../shared/models/videos' +import { VideoFileModel } from '@server/models/video/video-file' type Use = PickWith @@ -24,3 +28,11 @@ export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy & export type MVideoRedundancyVideo = MVideoRedundancy & Use<'VideoFile', MVideoFileVideo> & Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoRedundancyAP = MVideoRedundancy & + PickWithOpt> & + PickWithOpt> diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts index f1b3438b6..79696bcff 100644 --- a/server/typings/models/video/video-streaming-playlist.ts +++ b/server/typings/models/video/video-streaming-playlist.ts @@ -1,7 +1,7 @@ import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' -import { PickWith } from '../../utils' +import { PickWith, PickWithOpt } from '../../utils' import { MVideoRedundancyFileUrl } from './video-redundancy' -import { MVideo } from '@server/typings/models' +import { MVideo, MVideoUrl } from '@server/typings/models' type Use = PickWith @@ -14,3 +14,6 @@ export type MStreamingPlaylistVideo = MStreamingPlaylist & export type MStreamingPlaylistRedundancies = MStreamingPlaylist & Use<'RedundancyVideos', MVideoRedundancyFileUrl[]> + +export type MStreamingPlaylistRedundanciesOpt = MStreamingPlaylist & + PickWithOpt diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts index bc6d56607..be32d4617 100644 --- a/server/typings/models/video/video.ts +++ b/server/typings/models/video/video.ts @@ -10,7 +10,7 @@ import { } from './video-channels' import { MTag } from './tag' import { MVideoCaptionLanguage } from './video-caption' -import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' +import { MStreamingPlaylist, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist' import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' import { MThumbnail } from './thumbnail' import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' @@ -165,5 +165,5 @@ export type MVideoFormattable = MVideo & export type MVideoFormattableDetails = MVideoFormattable & Use<'VideoChannel', MChannelFormattable> & Use<'Tags', MTag[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & + Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & Use<'VideoFiles', MVideoFileRedundanciesOpt[]> -- cgit v1.2.3