From 1ca9f7c3f7afac2af4c4c25b98426731f7e789c6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 19:05:31 +0200 Subject: Type toFormattedJSON --- .../typings/models/video/schedule-video-update.ts | 6 +++++ server/typings/models/video/video-abuse.ts | 10 +++++++- server/typings/models/video/video-blacklist.ts | 9 +++++++- server/typings/models/video/video-caption.ts | 14 ++++++++--- .../typings/models/video/video-change-ownership.ts | 11 ++++++++- server/typings/models/video/video-channels.ts | 27 +++++++++++++++++++--- server/typings/models/video/video-comment.ts | 10 +++++++- server/typings/models/video/video-import.ts | 11 +++++++-- .../typings/models/video/video-playlist-element.ts | 11 +++++++-- server/typings/models/video/video-playlist.ts | 14 ++++++++--- server/typings/models/video/video-rate.ts | 9 +++++++- server/typings/models/video/video.ts | 27 ++++++++++++++++++++-- 12 files changed, 139 insertions(+), 20 deletions(-) (limited to 'server/typings/models/video') diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.ts index 069705536..ada9af06e 100644 --- a/server/typings/models/video/schedule-video-update.ts +++ b/server/typings/models/video/schedule-video-update.ts @@ -1,3 +1,9 @@ import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' export type MScheduleVideoUpdate = Omit + +// ############################################################################ + +// Format for API or AP object + +export type MScheduleVideoUpdateFormattable = Pick diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts index 0474cac5b..e38c3f586 100644 --- a/server/typings/models/video/video-abuse.ts +++ b/server/typings/models/video/video-abuse.ts @@ -1,7 +1,7 @@ import { VideoAbuseModel } from '../../../models/video/video-abuse' import { PickWith } from '../../utils' import { MVideo } from './video' -import { MAccountDefault } from '../account' +import { MAccountDefault, MAccountFormattable } from '../account' type Use = PickWith @@ -21,3 +21,11 @@ export type MVideoAbuseAccountVideo = MVideoAbuse & Pick & Use<'Video', MVideo> & Use<'Account', MAccountDefault> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoAbuseFormattable = MVideoAbuse & + Use<'Account', MAccountFormattable> & + Use<'Video', Pick> diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts index cc539f95c..1dedfa37f 100644 --- a/server/typings/models/video/video-blacklist.ts +++ b/server/typings/models/video/video-blacklist.ts @@ -1,6 +1,6 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' import { PickWith } from '@server/typings/utils' -import { MVideo } from '@server/typings/models' +import { MVideo, MVideoFormattable } from '@server/typings/models' type Use = PickWith @@ -15,3 +15,10 @@ export type MVideoBlacklistUnfederated = Pick export type MVideoBlacklistVideo = MVideoBlacklist & Use<'Video', MVideo> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoBlacklistFormattable = MVideoBlacklist & + Use<'Video', MVideoFormattable> diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts index fe0e664c2..7cb2a2ad3 100644 --- a/server/typings/models/video/video-caption.ts +++ b/server/typings/models/video/video-caption.ts @@ -1,6 +1,6 @@ import { VideoCaptionModel } from '../../../models/video/video-caption' -import { PickWith } from '@server/typings/utils' -import { VideoModel } from '@server/models/video/video' +import { FunctionProperties, PickWith } from '@server/typings/utils' +import { MVideo, MVideoUUID } from '@server/typings/models' type Use = PickWith @@ -13,4 +13,12 @@ export type MVideoCaption = Omit export type MVideoCaptionLanguage = Pick export type MVideoCaptionVideo = MVideoCaption & - Use<'Video', Pick> + Use<'Video', Pick> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoCaptionFormattable = FunctionProperties & + Pick & + Use<'Video', MVideoUUID> diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.ts index 0410115c6..72634cdb2 100644 --- a/server/typings/models/video/video-change-ownership.ts +++ b/server/typings/models/video/video-change-ownership.ts @@ -1,6 +1,6 @@ import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' import { PickWith } from '@server/typings/utils' -import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models' +import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models' type Use = PickWith @@ -12,3 +12,12 @@ export type MVideoChangeOwnershipFull = MVideoChangeOwnership & Use<'Initiator', MAccountDefault> & Use<'NextOwner', MAccountDefault> & Use<'Video', MVideoWithFileThumbnail> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoChangeOwnershipFormattable = Pick & + Use<'Initiator', MAccountFormattable> & + Use<'NextOwner', MAccountFormattable> & + Use<'Video', Pick> diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts index b6506ed9f..2be7dd7ed 100644 --- a/server/typings/models/video/video-channels.ts +++ b/server/typings/models/video/video-channels.ts @@ -1,19 +1,23 @@ -import { PickWith } from '../../utils' +import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' import { VideoChannelModel } from '../../../models/video/video-channel' import { MAccountActor, MAccountAPI, MAccountDefault, + MAccountFormattable, MAccountLight, MAccountSummaryBlocks, + MAccountSummaryFormattable, MAccountUserId, MActor, MActorAccountChannelId, MActorAPI, MActorDefault, MActorDefaultLight, + MActorFormattable, MActorLight, - MActorSummary + MActorSummary, + MActorSummaryFormattable } from '../account' import { MVideo } from './video' @@ -86,7 +90,8 @@ export type MChannelActorAccountDefaultVideos = MChannel & // For API -export type MChannelSummary = Pick & +export type MChannelSummary = FunctionProperties & + Pick & Use<'Actor', MActorSummary> export type MChannelSummaryAccount = MChannelSummary & @@ -95,3 +100,19 @@ export type MChannelSummaryAccount = MChannelSummary & export type MChannelAPI = MChannel & Use<'Actor', MActorAPI> & Use<'Account', MAccountAPI> + +// ############################################################################ + +// Format for API or AP object + +export type MChannelSummaryFormattable = FunctionProperties & + Pick & + Use<'Actor', MActorSummaryFormattable> + +export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable & + Use<'Account', MAccountSummaryFormattable> + +export type MChannelFormattable = FunctionProperties & + Pick & + Use<'Actor', MActorFormattable> & + PickWithOpt diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts index 187461213..e8bccba0f 100644 --- a/server/typings/models/video/video-comment.ts +++ b/server/typings/models/video/video-comment.ts @@ -1,6 +1,6 @@ import { VideoCommentModel } from '../../../models/video/video-comment' import { PickWith } from '../../utils' -import { MAccountDefault } from '../account' +import { MAccountDefault, MAccountFormattable } from '../account' import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' type Use = PickWith @@ -8,6 +8,7 @@ type Use = PickWith +export type MCommentTotalReplies = MComment & { totalReplies?: number } export type MCommentId = Pick // ############################################################################ @@ -41,3 +42,10 @@ export type MCommentOwnerVideoFeed = MCommentOwner & // ############################################################################ export type MCommentAPI = MComment & { totalReplies: number } + +// ############################################################################ + +// Format for API or AP object + +export type MCommentFormattable = MCommentTotalReplies & + Use<'Account', MAccountFormattable> diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts index ada723713..c6a1c5b66 100644 --- a/server/typings/models/video/video-import.ts +++ b/server/typings/models/video/video-import.ts @@ -1,6 +1,6 @@ import { VideoImportModel } from '@server/models/video/video-import' -import { PickWith } from '@server/typings/utils' -import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' +import { PickWith, PickWithOpt } from '@server/typings/utils' +import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' type Use = PickWith @@ -22,3 +22,10 @@ export type MVideoImportDefault = MVideoImport & export type MVideoImportDefaultFiles = MVideoImport & Use<'User', MUser> & Use<'Video', VideoAssociation & MVideoWithFile> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoImportFormattable = MVideoImport & + PickWithOpt diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts index 5a039d7b1..1c256fd25 100644 --- a/server/typings/models/video/video-playlist-element.ts +++ b/server/typings/models/video/video-playlist-element.ts @@ -1,6 +1,6 @@ import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' import { PickWith } from '@server/typings/utils' -import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' +import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' type Use = PickWith @@ -23,6 +23,13 @@ export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement & // For API -export type MVideoPlaylistAP = MVideoPlaylistElement & +export type MVideoPlaylistElementAP = MVideoPlaylistElement & Use<'Video', MVideoUrl> & Use<'VideoPlaylist', MVideoPlaylistPrivacy> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoPlaylistElementFormattable = MVideoPlaylistElement & + Use<'Video', MVideoFormattable> diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts index 633818405..a926106c5 100644 --- a/server/typings/models/video/video-playlist.ts +++ b/server/typings/models/video/video-playlist.ts @@ -1,8 +1,8 @@ import { VideoPlaylistModel } from '../../../models/video/video-playlist' import { PickWith } from '../../utils' -import { MAccount, MAccountDefault, MAccountSummary } from '../account' +import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' import { MThumbnail } from './thumbnail' -import { MChannelDefault, MChannelSummary } from './video-channels' +import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels' import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' type Use = PickWith @@ -16,7 +16,7 @@ export type MVideoPlaylist = Omit export type MVideoPlaylistPrivacy = Pick export type MVideoPlaylistUUID = Pick -export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } +export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number } // ############################################################################ @@ -78,3 +78,11 @@ export type MVideoPlaylistFullSummary = MVideoPlaylist & Use<'Thumbnail', MThumbnail> & Use<'OwnerAccount', MAccountSummary> & Use<'VideoChannel', MChannelSummary> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength & + Use<'OwnerAccount', MAccountSummaryFormattable> & + Use<'VideoChannel', MChannelSummaryFormattable> diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts index fc9329993..2ff8a625b 100644 --- a/server/typings/models/video/video-rate.ts +++ b/server/typings/models/video/video-rate.ts @@ -1,6 +1,6 @@ import { AccountVideoRateModel } from '@server/models/account/account-video-rate' import { PickWith } from '@server/typings/utils' -import { MAccountAudience, MAccountUrl, MVideo } from '..' +import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..' type Use = PickWith @@ -14,3 +14,10 @@ export type MAccountVideoRateAccountUrl = MAccountVideoRate & export type MAccountVideoRateAccountVideo = MAccountVideoRate & Use<'Account', MAccountAudience> & Use<'Video', MVideo> + +// ############################################################################ + +// Format for API or AP object + +export type MAccountVideoRateFormattable = Pick & + Use<'Video', MVideoFormattable> diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts index 914eb7f57..bc6d56607 100644 --- a/server/typings/models/video/video.ts +++ b/server/typings/models/video/video.ts @@ -1,12 +1,19 @@ import { VideoModel } from '../../../models/video/video' import { PickWith, PickWithOpt } from '../../utils' -import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels' +import { + MChannelAccountDefault, + MChannelAccountLight, + MChannelAccountSummaryFormattable, + MChannelActor, + MChannelFormattable, + MChannelUserId +} from './video-channels' import { MTag } from './tag' import { MVideoCaptionLanguage } from './video-caption' import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' import { MThumbnail } from './thumbnail' -import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' +import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' import { MScheduleVideoUpdate } from './schedule-video-update' import { MUserVideoHistoryTime } from '../user/user-video-history' @@ -144,3 +151,19 @@ export type MVideoForUser = MVideo & Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & Use<'VideoBlacklist', MVideoBlacklistLight> & Use<'Thumbnails', MThumbnail[]> + +// ############################################################################ + +// Format for API or AP object + +export type MVideoFormattable = MVideo & + PickWithOpt & + Use<'VideoChannel', MChannelAccountSummaryFormattable> & + PickWithOpt> & + PickWithOpt> + +export type MVideoFormattableDetails = MVideoFormattable & + Use<'VideoChannel', MChannelFormattable> & + Use<'Tags', MTag[]> & + Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & + Use<'VideoFiles', MVideoFileRedundanciesOpt[]> -- cgit v1.2.3