From 26d6bf6533023326fa017812cf31bbe20c752d36 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Jun 2020 10:45:25 +0200 Subject: Split types and typings --- server/typings/activitypub-processor.model.ts | 9 - server/typings/express.d.ts | 128 +++++++++++++ server/typings/express.ts | 128 ------------- server/typings/models/account/account-blocklist.ts | 27 --- server/typings/models/account/account.ts | 109 ----------- server/typings/models/account/actor-follow.ts | 70 ------- server/typings/models/account/actor.ts | 139 -------------- server/typings/models/account/avatar.ts | 12 -- server/typings/models/account/index.ts | 5 - server/typings/models/index.ts | 5 - server/typings/models/oauth/index.ts | 2 - server/typings/models/oauth/oauth-client.ts | 3 - server/typings/models/oauth/oauth-token.ts | 14 -- server/typings/models/server/index.ts | 3 - server/typings/models/server/plugin.ts | 11 -- server/typings/models/server/server-blocklist.ts | 26 --- server/typings/models/server/server.ts | 26 --- server/typings/models/user/index.ts | 4 - .../models/user/user-notification-setting.ts | 9 - server/typings/models/user/user-notification.ts | 92 --------- server/typings/models/user/user-video-history.ts | 5 - server/typings/models/user/user.ts | 89 --------- server/typings/models/video/index.ts | 18 -- .../typings/models/video/schedule-video-update.ts | 19 -- server/typings/models/video/tag.ts | 3 - server/typings/models/video/thumbnail.ts | 3 - server/typings/models/video/video-abuse.ts | 35 ---- server/typings/models/video/video-blacklist.ts | 30 --- server/typings/models/video/video-caption.ts | 27 --- .../typings/models/video/video-change-ownership.ts | 26 --- server/typings/models/video/video-channels.ts | 145 -------------- server/typings/models/video/video-comment.ts | 66 ------- server/typings/models/video/video-file.ts | 43 ----- server/typings/models/video/video-import.ts | 36 ---- .../typings/models/video/video-playlist-element.ts | 39 ---- server/typings/models/video/video-playlist.ts | 104 ---------- server/typings/models/video/video-rate.ts | 27 --- server/typings/models/video/video-redundancy.ts | 43 ----- server/typings/models/video/video-share.ts | 19 -- .../models/video/video-streaming-playlist.ts | 43 ----- server/typings/models/video/video.ts | 211 --------------------- .../plugins/register-server-option.model.ts | 2 +- server/typings/sequelize.ts | 18 -- server/typings/utils.ts | 24 --- 44 files changed, 129 insertions(+), 1768 deletions(-) delete mode 100644 server/typings/activitypub-processor.model.ts create mode 100644 server/typings/express.d.ts delete mode 100644 server/typings/express.ts delete mode 100644 server/typings/models/account/account-blocklist.ts delete mode 100644 server/typings/models/account/account.ts delete mode 100644 server/typings/models/account/actor-follow.ts delete mode 100644 server/typings/models/account/actor.ts delete mode 100644 server/typings/models/account/avatar.ts delete mode 100644 server/typings/models/account/index.ts delete mode 100644 server/typings/models/index.ts delete mode 100644 server/typings/models/oauth/index.ts delete mode 100644 server/typings/models/oauth/oauth-client.ts delete mode 100644 server/typings/models/oauth/oauth-token.ts delete mode 100644 server/typings/models/server/index.ts delete mode 100644 server/typings/models/server/plugin.ts delete mode 100644 server/typings/models/server/server-blocklist.ts delete mode 100644 server/typings/models/server/server.ts delete mode 100644 server/typings/models/user/index.ts delete mode 100644 server/typings/models/user/user-notification-setting.ts delete mode 100644 server/typings/models/user/user-notification.ts delete mode 100644 server/typings/models/user/user-video-history.ts delete mode 100644 server/typings/models/user/user.ts delete mode 100644 server/typings/models/video/index.ts delete mode 100644 server/typings/models/video/schedule-video-update.ts delete mode 100644 server/typings/models/video/tag.ts delete mode 100644 server/typings/models/video/thumbnail.ts delete mode 100644 server/typings/models/video/video-abuse.ts delete mode 100644 server/typings/models/video/video-blacklist.ts delete mode 100644 server/typings/models/video/video-caption.ts delete mode 100644 server/typings/models/video/video-change-ownership.ts delete mode 100644 server/typings/models/video/video-channels.ts delete mode 100644 server/typings/models/video/video-comment.ts delete mode 100644 server/typings/models/video/video-file.ts delete mode 100644 server/typings/models/video/video-import.ts delete mode 100644 server/typings/models/video/video-playlist-element.ts delete mode 100644 server/typings/models/video/video-playlist.ts delete mode 100644 server/typings/models/video/video-rate.ts delete mode 100644 server/typings/models/video/video-redundancy.ts delete mode 100644 server/typings/models/video/video-share.ts delete mode 100644 server/typings/models/video/video-streaming-playlist.ts delete mode 100644 server/typings/models/video/video.ts delete mode 100644 server/typings/sequelize.ts delete mode 100644 server/typings/utils.ts (limited to 'server/typings') diff --git a/server/typings/activitypub-processor.model.ts b/server/typings/activitypub-processor.model.ts deleted file mode 100644 index 7ed3a65b1..000000000 --- a/server/typings/activitypub-processor.model.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Activity } from '../../shared/models/activitypub' -import { MActorDefault, MActorSignature } from './models' - -export type APProcessorOptions = { - activity: T - byActor: MActorSignature - inboxActor?: MActorDefault - fromFetch?: boolean -} diff --git a/server/typings/express.d.ts b/server/typings/express.d.ts new file mode 100644 index 000000000..451bf9103 --- /dev/null +++ b/server/typings/express.d.ts @@ -0,0 +1,128 @@ +import { RegisteredPlugin } from '../lib/plugins/plugin-manager' +import { + MAccountDefault, + MActorAccountChannelId, + MActorFollowActorsDefault, + MActorFollowActorsDefaultSubscription, + MActorFull, + MChannelAccountDefault, + MComment, + MCommentOwnerVideoReply, + MUserDefault, + MVideoAbuse, + MVideoBlacklist, + MVideoCaptionVideo, + MVideoFullLight, + MVideoIdThumbnail, + MVideoRedundancyVideo, + MVideoShareActor, + MVideoThumbnail, + MVideoWithRights +} from '../types/models' +import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from '../types/models/video/video-playlist' +import { MVideoImportDefault } from '@server/types/models/video/video-import' +import { MAccountBlocklist, MActorUrl, MStreamingPlaylist, MVideoFile, MVideoImmutable } from '@server/types/models' +import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' +import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' +import { MVideoChangeOwnershipFull } from '../types/models/video/video-change-ownership' +import { MPlugin, MServer } from '@server/types/models/server' +import { MServerBlocklist } from '../types/models/server/server-blocklist' +import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' +import { UserRole } from '@shared/models' +import { RegisterServerAuthExternalOptions } from '@shared/models/plugins/register-server-auth.model' + +declare module 'express' { + export interface Request { + query: any + } + + interface Response { + + locals: { + bypassLogin?: { + bypass: boolean + pluginName: string + authName?: string + user: { + username: string + email: string + displayName: string + role: UserRole + } + } + + refreshTokenAuthName?: string + + explicitLogout: boolean + + videoAll?: MVideoFullLight + onlyImmutableVideo?: MVideoImmutable + onlyVideo?: MVideoThumbnail + onlyVideoWithRights?: MVideoWithRights + videoId?: MVideoIdThumbnail + + videoShare?: MVideoShareActor + + videoFile?: MVideoFile + + videoImport?: MVideoImportDefault + + videoBlacklist?: MVideoBlacklist + + videoCaption?: MVideoCaptionVideo + + videoAbuse?: MVideoAbuse + + videoStreamingPlaylist?: MStreamingPlaylist + + videoChannel?: MChannelAccountDefault + + videoPlaylistFull?: MVideoPlaylistFull + videoPlaylistSummary?: MVideoPlaylistFullSummary + + videoPlaylistElement?: MVideoPlaylistElement + videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy + + accountVideoRate?: MAccountVideoRateAccountVideo + + videoCommentFull?: MCommentOwnerVideoReply + videoCommentThread?: MComment + + follow?: MActorFollowActorsDefault + subscription?: MActorFollowActorsDefaultSubscription + + nextOwner?: MAccountDefault + videoChangeOwnership?: MVideoChangeOwnershipFull + + account?: MAccountDefault + + actorUrl?: MActorUrl + actorFull?: MActorFull + + user?: MUserDefault + + server?: MServer + + videoRedundancy?: MVideoRedundancyVideo + + accountBlock?: MAccountBlocklist + serverBlock?: MServerBlocklist + + oauth?: { + token: MOAuthTokenUser + } + + signature?: { + actor: MActorAccountChannelId + } + + authenticated?: boolean + + registeredPlugin?: RegisteredPlugin + + externalAuth?: RegisterServerAuthExternalOptions + + plugin?: MPlugin + } + } +} diff --git a/server/typings/express.ts b/server/typings/express.ts deleted file mode 100644 index 15d445c2d..000000000 --- a/server/typings/express.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { RegisteredPlugin } from '../lib/plugins/plugin-manager' -import { - MAccountDefault, - MActorAccountChannelId, - MActorFollowActorsDefault, - MActorFollowActorsDefaultSubscription, - MActorFull, - MChannelAccountDefault, - MComment, - MCommentOwnerVideoReply, - MUserDefault, - MVideoAbuse, - MVideoBlacklist, - MVideoCaptionVideo, - MVideoFullLight, - MVideoIdThumbnail, - MVideoRedundancyVideo, - MVideoShareActor, - MVideoThumbnail, - MVideoWithRights -} from './models' -import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist' -import { MVideoImportDefault } from '@server/typings/models/video/video-import' -import { MAccountBlocklist, MActorUrl, MStreamingPlaylist, MVideoFile, MVideoImmutable } from '@server/typings/models' -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' -import { MServerBlocklist } from './models/server/server-blocklist' -import { MOAuthTokenUser } from '@server/typings/models/oauth/oauth-token' -import { UserRole } from '@shared/models' -import { RegisterServerAuthExternalOptions } from '@shared/models/plugins/register-server-auth.model' - -declare module 'express' { - interface Request { - query: any - } - - interface Response { - - locals: { - bypassLogin?: { - bypass: boolean - pluginName: string - authName?: string - user: { - username: string - email: string - displayName: string - role: UserRole - } - } - - refreshTokenAuthName?: string - - explicitLogout: boolean - - videoAll?: MVideoFullLight - onlyImmutableVideo?: MVideoImmutable - onlyVideo?: MVideoThumbnail - onlyVideoWithRights?: MVideoWithRights - videoId?: MVideoIdThumbnail - - videoShare?: MVideoShareActor - - videoFile?: MVideoFile - - videoImport?: MVideoImportDefault - - videoBlacklist?: MVideoBlacklist - - videoCaption?: MVideoCaptionVideo - - videoAbuse?: MVideoAbuse - - videoStreamingPlaylist?: MStreamingPlaylist - - videoChannel?: MChannelAccountDefault - - videoPlaylistFull?: MVideoPlaylistFull - videoPlaylistSummary?: MVideoPlaylistFullSummary - - videoPlaylistElement?: MVideoPlaylistElement - videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy - - accountVideoRate?: MAccountVideoRateAccountVideo - - videoCommentFull?: MCommentOwnerVideoReply - videoCommentThread?: MComment - - follow?: MActorFollowActorsDefault - subscription?: MActorFollowActorsDefaultSubscription - - nextOwner?: MAccountDefault - videoChangeOwnership?: MVideoChangeOwnershipFull - - account?: MAccountDefault - - actorUrl?: MActorUrl - actorFull?: MActorFull - - user?: MUserDefault - - server?: MServer - - videoRedundancy?: MVideoRedundancyVideo - - accountBlock?: MAccountBlocklist - serverBlock?: MServerBlocklist - - oauth?: { - token: MOAuthTokenUser - } - - signature?: { - actor: MActorAccountChannelId - } - - authenticated?: boolean - - registeredPlugin?: RegisteredPlugin - - externalAuth?: RegisterServerAuthExternalOptions - - plugin?: MPlugin - } - } -} diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts deleted file mode 100644 index 0d8bf11bd..000000000 --- a/server/typings/models/account/account-blocklist.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { AccountBlocklistModel } from '../../../models/account/account-blocklist' -import { PickWith } from '../../utils' -import { MAccountDefault, MAccountFormattable } from './account' - -type Use = PickWith - -// ############################################################################ - -export type MAccountBlocklist = Omit - -// ############################################################################ - -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 deleted file mode 100644 index 7b826ee04..000000000 --- a/server/typings/models/account/account.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { AccountModel } from '../../../models/account/account' -import { - MActor, - MActorAP, - MActorAPI, - MActorAudience, - MActorDefault, - MActorDefaultLight, - MActorFormattable, - MActorId, - MActorServer, - MActorSummary, - MActorSummaryFormattable, - MActorUrl -} from './actor' -import { FunctionProperties, PickWith } from '../../utils' -import { MAccountBlocklistId } from './account-blocklist' -import { MChannelDefault } from '../video/video-channels' - -type Use = PickWith - -// ############################################################################ - -export type MAccount = - Omit - -// ############################################################################ - -// Only some attributes -export type MAccountId = Pick -export type MAccountUserId = Pick - -// Only some Actor attributes -export type MAccountUrl = Use<'Actor', MActorUrl> -export type MAccountAudience = Use<'Actor', MActorAudience> - -export type MAccountIdActor = - MAccountId & - Use<'Actor', MActor> - -export type MAccountIdActorId = - MAccountId & - Use<'Actor', MActorId> - -// ############################################################################ - -// Default scope -export type MAccountDefault = - MAccount & - Use<'Actor', MActorDefault> - -// Default with default association scopes -export type MAccountDefaultChannelDefault = - MAccount & - Use<'Actor', MActorDefault> & - Use<'VideoChannels', MChannelDefault[]> - -// We don't need some actors attributes -export type MAccountLight = - MAccount & - Use<'Actor', MActorDefaultLight> - -// ############################################################################ - -// Full actor -export type MAccountActor = - MAccount & - Use<'Actor', MActor> - -// Full actor with server -export type MAccountServer = - MAccount & - Use<'Actor', MActorServer> - -// ############################################################################ - -// For API - -export type MAccountSummary = - FunctionProperties & - Pick & - Use<'Actor', MActorSummary> - -export type MAccountSummaryBlocks = - MAccountSummary & - Use<'BlockedAccounts', MAccountBlocklistId[]> - -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> - -export type MAccountAP = - Pick & - Use<'Actor', MActorAP> diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts deleted file mode 100644 index 5d0c03c8d..000000000 --- a/server/typings/models/account/actor-follow.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { - MActor, - MActorChannelAccountActor, - MActorDefault, - MActorDefaultAccountChannel, - MActorFormattable, - MActorHost, - MActorUsername -} from './actor' -import { PickWith } from '../../utils' -import { ActorModel } from '@server/models/activitypub/actor' -import { MChannelDefault } from '../video/video-channels' - -type Use = PickWith - -// ############################################################################ - -export type MActorFollow = Omit - -// ############################################################################ - -export type MActorFollowFollowingHost = - MActorFollow & - Use<'ActorFollowing', MActorUsername & MActorHost> - -// ############################################################################ - -// With actors or actors default - -export type MActorFollowActors = - MActorFollow & - Use<'ActorFollower', MActor> & - Use<'ActorFollowing', MActor> - -export type MActorFollowActorsDefault = - MActorFollow & - Use<'ActorFollower', MActorDefault> & - Use<'ActorFollowing', MActorDefault> - -export type MActorFollowFull = - MActorFollow & - Use<'ActorFollower', MActorDefaultAccountChannel> & - Use<'ActorFollowing', MActorDefaultAccountChannel> - -// ############################################################################ - -// For subscriptions - -type SubscriptionFollowing = - MActorDefault & - PickWith - -export type MActorFollowActorsDefaultSubscription = - MActorFollow & - Use<'ActorFollower', MActorDefault> & - Use<'ActorFollowing', SubscriptionFollowing> - -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 deleted file mode 100644 index 1160e84cb..000000000 --- a/server/typings/models/account/actor.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { ActorModel } from '../../../models/activitypub/actor' -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' -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 MActorFollowersUrl = Pick -export type MActorAudience = MActorUrl & MActorFollowersUrl -export type MActorWithInboxes = Pick -export type MActorSignature = MActorAccountChannelId - -export type MActorLight = Omit - -// ############################################################################ - -// Some association attributes - -export type MActorHost = Use<'Server', MServerHost> -export type MActorRedundancyAllowedOpt = PickWithOpt - -export type MActorDefaultLight = - MActorLight & - Use<'Server', MServerHost> & - Use<'Avatar', MAvatar> - -export type MActorAccountId = - MActor & - Use<'Account', MAccountId> -export type MActorAccountIdActor = - MActor & - Use<'Account', MAccountIdActor> - -export type MActorChannelId = - MActor & - Use<'VideoChannel', MChannelId> -export type MActorChannelIdActor = - MActor & - Use<'VideoChannel', MChannelIdActor> - -export type MActorAccountChannelId = MActorAccountId & MActorChannelId -export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor - -// ############################################################################ - -// Include raw account/channel/server - -export type MActorAccount = - MActor & - Use<'Account', MAccount> - -export type MActorChannel = - MActor & - Use<'VideoChannel', MChannel> - -export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel - -export type MActorServer = - MActor & - Use<'Server', MServer> - -// ############################################################################ - -// Complex actor associations - -export type MActorDefault = - MActor & - Use<'Server', MServer> & - Use<'Avatar', MAvatar> - -// 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 MActorFull = - MActor & - Use<'Server', MServer> & - Use<'Avatar', MAvatar> & - Use<'Account', MAccount> & - Use<'VideoChannel', MChannelAccountActor> - -// 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 = - FunctionProperties & - Pick & - Use<'Server', MServerHost> & - Use<'Avatar', MAvatar> - -export type MActorSummaryBlocks = - MActorSummary & - Use<'Server', MServerHostBlocks> - -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', MServerHost & Partial>> - -export type MActorAP = - MActor & - Use<'Avatar', MAvatar> diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts deleted file mode 100644 index 21b47180f..000000000 --- a/server/typings/models/account/avatar.ts +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/server/typings/models/account/index.ts b/server/typings/models/account/index.ts deleted file mode 100644 index 513c09c40..000000000 --- a/server/typings/models/account/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './account' -export * from './account-blocklist' -export * from './actor' -export * from './actor-follow' -export * from './avatar' diff --git a/server/typings/models/index.ts b/server/typings/models/index.ts deleted file mode 100644 index 78b4948ce..000000000 --- a/server/typings/models/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './account' -export * from './oauth' -export * from './server' -export * from './user' -export * from './video' diff --git a/server/typings/models/oauth/index.ts b/server/typings/models/oauth/index.ts deleted file mode 100644 index 36b7ea8ca..000000000 --- a/server/typings/models/oauth/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './oauth-client' -export * from './oauth-token' diff --git a/server/typings/models/oauth/oauth-client.ts b/server/typings/models/oauth/oauth-client.ts deleted file mode 100644 index 904a07863..000000000 --- a/server/typings/models/oauth/oauth-client.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { OAuthClientModel } from '@server/models/oauth/oauth-client' - -export type MOAuthClient = Omit diff --git a/server/typings/models/oauth/oauth-token.ts b/server/typings/models/oauth/oauth-token.ts deleted file mode 100644 index b24a95fd8..000000000 --- a/server/typings/models/oauth/oauth-token.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { OAuthTokenModel } from '@server/models/oauth/oauth-token' -import { PickWith } from '@server/typings/utils' -import { MUserAccountUrl } from '../user/user' - -type Use = PickWith - -// ############################################################################ - -export type MOAuthToken = Omit - -export type MOAuthTokenUser = - MOAuthToken & - Use<'User', MUserAccountUrl> & - { user?: MUserAccountUrl } diff --git a/server/typings/models/server/index.ts b/server/typings/models/server/index.ts deleted file mode 100644 index c853795ad..000000000 --- a/server/typings/models/server/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './plugin' -export * from './server' -export * from './server-blocklist' diff --git a/server/typings/models/server/plugin.ts b/server/typings/models/server/plugin.ts deleted file mode 100644 index 83eb83794..000000000 --- a/server/typings/models/server/plugin.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PluginModel } from '@server/models/server/plugin' - -export type MPlugin = PluginModel - -// ############################################################################ - -// Format for API or AP object - -export type MPluginFormattable = - Pick diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts deleted file mode 100644 index ff6f49176..000000000 --- a/server/typings/models/server/server-blocklist.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { PickWith } from '@server/typings/utils' -import { MAccountDefault, MAccountFormattable } from '../account/account' -import { MServer, MServerFormattable } from './server' - -type Use = PickWith - -// ############################################################################ - -export type MServerBlocklist = Omit - -// ############################################################################ - -export type MServerBlocklistAccountServer = - MServerBlocklist & - Use<'ByAccount', MAccountDefault> & - Use<'BlockedServer', MServer> - -// ############################################################################ - -// Format for API or AP object - -export type MServerBlocklistFormattable = - Pick & - Use<'ByAccount', MAccountFormattable> & - Use<'BlockedServer', MServerFormattable> diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts deleted file mode 100644 index b35e55aeb..000000000 --- a/server/typings/models/server/server.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ServerModel } from '../../../models/server/server' -import { FunctionProperties, PickWith } from '../../utils' -import { MAccountBlocklistId } from '../account' - -type Use = PickWith - -// ############################################################################ - -export type MServer = Omit - -// ############################################################################ - -export type MServerHost = Pick -export type MServerRedundancyAllowed = Pick - -export type MServerHostBlocks = - MServerHost & - Use<'BlockedByAccounts', MAccountBlocklistId[]> - -// ############################################################################ - -// Format for API or AP object - -export type MServerFormattable = - FunctionProperties & - Pick diff --git a/server/typings/models/user/index.ts b/server/typings/models/user/index.ts deleted file mode 100644 index 6657b2128..000000000 --- a/server/typings/models/user/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './user' -export * from './user-notification' -export * from './user-notification-setting' -export * from './user-video-history' diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts deleted file mode 100644 index c674add1b..000000000 --- a/server/typings/models/user/user-notification-setting.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' - -export type MNotificationSetting = Omit - -// ############################################################################ - -// Format for API or AP object - -export type MNotificationSettingFormattable = MNotificationSetting diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts deleted file mode 100644 index 2080360e1..000000000 --- a/server/typings/models/user/user-notification.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { UserNotificationModel } from '../../../models/account/user-notification' -import { PickWith, PickWithOpt } from '../../utils' -import { VideoModel } from '../../../models/video/video' -import { ActorModel } from '../../../models/activitypub/actor' -import { ServerModel } from '../../../models/server/server' -import { AvatarModel } from '../../../models/avatar/avatar' -import { VideoChannelModel } from '../../../models/video/video-channel' -import { AccountModel } from '../../../models/account/account' -import { VideoCommentModel } from '../../../models/video/video-comment' -import { VideoAbuseModel } from '../../../models/video/video-abuse' -import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { VideoImportModel } from '../../../models/video/video-import' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' - -type Use = PickWith - -// ############################################################################ - -export module UserNotificationIncludes { - - export type VideoInclude = Pick - export type VideoIncludeChannel = - VideoInclude & - PickWith - - export type ActorInclude = - Pick & - PickWith> & - PickWith> - - export type VideoChannelInclude = Pick - export type VideoChannelIncludeActor = - VideoChannelInclude & - PickWith - - export type AccountInclude = Pick - export type AccountIncludeActor = - AccountInclude & - PickWith - - export type VideoCommentInclude = - Pick & - PickWith & - PickWith - - export type VideoAbuseInclude = - Pick & - PickWith - - export type VideoBlacklistInclude = - Pick & - PickWith - - export type VideoImportInclude = - Pick & - PickWith - - export type ActorFollower = - Pick & - PickWith & - PickWith> & - PickWithOpt> - - export type ActorFollowing = - Pick & - PickWith & - PickWith & - PickWith> - - export type ActorFollowInclude = - Pick & - PickWith & - PickWith -} - -// ############################################################################ - -export type MUserNotification = - Omit - -// ############################################################################ - -export type UserNotificationModelForApi = - MUserNotification & - Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & - Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & - Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & - Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & - Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & - Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & - Use<'Account', UserNotificationIncludes.AccountIncludeActor> diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts deleted file mode 100644 index 62673ab1b..000000000 --- a/server/typings/models/user/user-video-history.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { UserVideoHistoryModel } from '../../../models/account/user-video-history' - -export type MUserVideoHistory = Omit - -export type MUserVideoHistoryTime = Pick diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts deleted file mode 100644 index 31cf075ef..000000000 --- a/server/typings/models/user/user.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { UserModel } from '../../../models/account/user' -import { PickWith, PickWithOpt } from '../../utils' -import { - MAccount, - MAccountDefault, - MAccountDefaultChannelDefault, - MAccountFormattable, - MAccountId, - MAccountIdActorId, - MAccountUrl -} from '../account' -import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' -import { AccountModel } from '@server/models/account/account' -import { MChannelFormattable } from '../video/video-channels' -import { MVideoPlaylist } from '@server/typings/models' - -type Use = PickWith - -// ############################################################################ - -export type MUser = Omit - -// ############################################################################ - -export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number } -export type MUserId = Pick - -// ############################################################################ - -// With account - -export type MUserAccountId = - MUser & - Use<'Account', MAccountId> - -export type MUserAccountUrl = - MUser & - Use<'Account', MAccountUrl & MAccountIdActorId> - -export type MUserAccount = - MUser & - Use<'Account', MAccount> - -export type MUserAccountDefault = - MUser & - Use<'Account', MAccountDefault> - -// With channel - -export type MUserNotifSettingChannelDefault = - MUser & - Use<'NotificationSetting', MNotificationSetting> & - Use<'Account', MAccountDefaultChannelDefault> - -// With notification settings - -export type MUserWithNotificationSetting = - MUser & - Use<'NotificationSetting', MNotificationSetting> - -export type MUserNotifSettingAccount = - MUser & - Use<'NotificationSetting', MNotificationSetting> & - Use<'Account', MAccount> - -// Default scope - -export type MUserDefault = - MUser & - Use<'NotificationSetting', MNotificationSetting> & - Use<'Account', MAccountDefault> - -// ############################################################################ - -// Format for API or AP object - -type MAccountWithChannels = MAccountFormattable & PickWithOpt -type MAccountWithChannelsAndSpecialPlaylists = - MAccountWithChannels & - PickWithOpt - -export type MUserFormattable = - MUserQuotaUsed & - Use<'Account', MAccountWithChannels> & - PickWithOpt - -export type MMyUserFormattable = - MUserFormattable & - Use<'Account', MAccountWithChannelsAndSpecialPlaylists> diff --git a/server/typings/models/video/index.ts b/server/typings/models/video/index.ts deleted file mode 100644 index bd69c8a4b..000000000 --- a/server/typings/models/video/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -export * from './schedule-video-update' -export * from './tag' -export * from './thumbnail' -export * from './video' -export * from './video-abuse' -export * from './video-blacklist' -export * from './video-caption' -export * from './video-change-ownership' -export * from './video-channels' -export * from './video-comment' -export * from './video-file' -export * from './video-import' -export * from './video-playlist' -export * from './video-playlist-element' -export * from './video-rate' -export * from './video-redundancy' -export * from './video-share' -export * from './video-streaming-playlist' diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.ts deleted file mode 100644 index 95a53d139..000000000 --- a/server/typings/models/video/schedule-video-update.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' -import { PickWith } from '@server/typings/utils' -import { MVideoAPWithoutCaption, MVideoWithBlacklistLight } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MScheduleVideoUpdate = Omit - -// ############################################################################ - -export type MScheduleVideoUpdateVideoAll = - MScheduleVideoUpdate & - Use<'Video', MVideoAPWithoutCaption & MVideoWithBlacklistLight> - -// Format for API or AP object - -export type MScheduleVideoUpdateFormattable = Pick diff --git a/server/typings/models/video/tag.ts b/server/typings/models/video/tag.ts deleted file mode 100644 index 64a68873e..000000000 --- a/server/typings/models/video/tag.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { TagModel } from '../../../models/video/tag' - -export type MTag = Omit diff --git a/server/typings/models/video/thumbnail.ts b/server/typings/models/video/thumbnail.ts deleted file mode 100644 index c03ba55ac..000000000 --- a/server/typings/models/video/thumbnail.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ThumbnailModel } from '../../../models/video/thumbnail' - -export type MThumbnail = Omit diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts deleted file mode 100644 index d60f05e4c..000000000 --- a/server/typings/models/video/video-abuse.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { VideoAbuseModel } from '../../../models/video/video-abuse' -import { PickWith } from '../../utils' -import { MVideoAccountLightBlacklistAllFiles, MVideo } from './video' -import { MAccountDefault, MAccountFormattable } from '../account' - -type Use = PickWith - -// ############################################################################ - -export type MVideoAbuse = Omit - -// ############################################################################ - -export type MVideoAbuseId = Pick - -export type MVideoAbuseVideo = - MVideoAbuse & - Pick & - Use<'Video', MVideo> - -export type MVideoAbuseAccountVideo = - MVideoAbuse & - Pick & - Use<'Video', MVideoAccountLightBlacklistAllFiles> & - 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 deleted file mode 100644 index ddb4db832..000000000 --- a/server/typings/models/video/video-blacklist.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { PickWith } from '@server/typings/utils' -import { MVideo, MVideoFormattable } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MVideoBlacklist = Omit - -export type MVideoBlacklistLight = Pick -export type MVideoBlacklistUnfederated = Pick - -// ############################################################################ - -export type MVideoBlacklistLightVideo = - MVideoBlacklistLight & - Use<'Video', MVideo> - -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 deleted file mode 100644 index e7aff6956..000000000 --- a/server/typings/models/video/video-caption.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { VideoCaptionModel } from '../../../models/video/video-caption' -import { FunctionProperties, PickWith } from '@server/typings/utils' -import { MVideo, MVideoUUID } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MVideoCaption = Omit - -// ############################################################################ - -export type MVideoCaptionLanguage = Pick -export type MVideoCaptionLanguageUrl = Pick - -export type MVideoCaptionVideo = - MVideoCaption & - 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 deleted file mode 100644 index 971dc3db5..000000000 --- a/server/typings/models/video/video-change-ownership.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' -import { PickWith } from '@server/typings/utils' -import { MAccountDefault, MAccountFormattable } from '../account/account' -import { MVideo, MVideoWithAllFiles } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MVideoChangeOwnership = Omit - -export type MVideoChangeOwnershipFull = - MVideoChangeOwnership & - Use<'Initiator', MAccountDefault> & - Use<'NextOwner', MAccountDefault> & - Use<'Video', MVideoWithAllFiles> - -// ############################################################################ - -// 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 deleted file mode 100644 index 50f7c2d8a..000000000 --- a/server/typings/models/video/video-channels.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' -import { VideoChannelModel } from '../../../models/video/video-channel' -import { - MAccountActor, - MAccountAPI, - MAccountDefault, - MAccountFormattable, - MAccountLight, - MAccountSummaryBlocks, - MAccountSummaryFormattable, - MAccountUrl, - MAccountUserId, - MActor, - MActorAccountChannelId, - MActorAP, - MActorAPI, - MActorDefault, - MActorDefaultLight, - MActorFormattable, - MActorLight, - MActorSummary, - MActorSummaryFormattable, MActorUrl -} from '../account' -import { MVideo } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MChannel = Omit - -// ############################################################################ - -export type MChannelId = Pick - -// ############################################################################ - -export type MChannelIdActor = - MChannelId & - Use<'Actor', MActorAccountChannelId> - -export type MChannelUserId = - Pick & - Use<'Account', MAccountUserId> - -export type MChannelActor = - MChannel & - Use<'Actor', MActor> - -export type MChannelUrl = Use<'Actor', MActorUrl> - -// Default scope -export type MChannelDefault = - MChannel & - Use<'Actor', MActorDefault> - -// ############################################################################ - -// Not all association attributes - -export type MChannelLight = - MChannel & - Use<'Actor', MActorDefaultLight> - -export type MChannelActorLight = - MChannel & - Use<'Actor', MActorLight> - -export type MChannelAccountLight = - MChannel & - Use<'Actor', MActorDefaultLight> & - Use<'Account', MAccountLight> - -// ############################################################################ - -// Account associations - -export type MChannelAccountActor = - MChannel & - 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 & - Use<'Videos', MVideo[]> - -export type MChannelActorAccountDefaultVideos = - MChannel & - Use<'Actor', MActorDefault> & - Use<'Account', MAccountDefault> & - Use<'Videos', MVideo[]> - -// ############################################################################ - -// For API - -export type MChannelSummary = - FunctionProperties & - Pick & - Use<'Actor', MActorSummary> - -export type MChannelSummaryAccount = - MChannelSummary & - Use<'Account', MAccountSummaryBlocks> - -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 - -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 deleted file mode 100644 index d6e0b66f5..000000000 --- a/server/typings/models/video/video-comment.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { VideoCommentModel } from '../../../models/video/video-comment' -import { PickWith, PickWithOpt } from '../../utils' -import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account' -import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MComment = Omit -export type MCommentTotalReplies = MComment & { totalReplies?: number } -export type MCommentId = Pick -export type MCommentUrl = Pick - -// ############################################################################ - -export type MCommentOwner = - MComment & - Use<'Account', MAccountDefault> - -export type MCommentVideo = - MComment & - Use<'Video', MVideoAccountLight> - -export type MCommentReply = - MComment & - Use<'InReplyToVideoComment', MComment> - -export type MCommentOwnerVideo = - MComment & - Use<'Account', MAccountDefault> & - Use<'Video', MVideoAccountLight> - -export type MCommentOwnerVideoReply = - MComment & - Use<'Account', MAccountDefault> & - Use<'Video', MVideoAccountLight> & - Use<'InReplyToVideoComment', MComment> - -export type MCommentOwnerReplyVideoLight = - MComment & - Use<'Account', MAccountDefault> & - Use<'InReplyToVideoComment', MComment> & - Use<'Video', MVideoIdUrl> - -export type MCommentOwnerVideoFeed = - MCommentOwner & - Use<'Video', MVideoFeed> - -// ############################################################################ - -export type MCommentAPI = MComment & { totalReplies: number } - -// ############################################################################ - -// Format for API or AP object - -export type MCommentFormattable = - MCommentTotalReplies & - Use<'Account', MAccountFormattable> - -export type MCommentAP = - MComment & - Use<'Account', MAccountUrl> & - PickWithOpt & - PickWithOpt diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts deleted file mode 100644 index 3fcaca78f..000000000 --- a/server/typings/models/video/video-file.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { VideoFileModel } from '../../../models/video/video-file' -import { PickWith, PickWithOpt } from '../../utils' -import { MVideo, MVideoUUID } from './video' -import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy' -import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist' - -type Use = PickWith - -// ############################################################################ - -export type MVideoFile = Omit - -export type MVideoFileVideo = - MVideoFile & - Use<'Video', MVideo> - -export type MVideoFileStreamingPlaylist = - MVideoFile & - Use<'VideoStreamingPlaylist', MStreamingPlaylist> - -export type MVideoFileStreamingPlaylistVideo = - MVideoFile & - Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> - -export type MVideoFileVideoUUID = - MVideoFile & - Use<'Video', MVideoUUID> - -export type MVideoFileRedundanciesAll = - MVideoFile & - PickWithOpt - -export type MVideoFileRedundanciesOpt = - MVideoFile & - PickWithOpt - -export function isStreamingPlaylistFile (file: any): file is MVideoFileStreamingPlaylist { - return !!file.videoStreamingPlaylistId -} - -export function isWebtorrentFile (file: any): file is MVideoFileVideo { - return !!file.videoId -} diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts deleted file mode 100644 index 4e5c2e4f0..000000000 --- a/server/typings/models/video/video-import.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { VideoImportModel } from '@server/models/video/video-import' -import { PickWith, PickWithOpt } from '@server/typings/utils' -import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video' -import { MUser } from '../user/user' - -type Use = PickWith - -// ############################################################################ - -export type MVideoImport = Omit - -export type MVideoImportVideo = - MVideoImport & - Use<'Video', MVideo> - -// ############################################################################ - -type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail - -export type MVideoImportDefault = - MVideoImport & - Use<'User', MUser> & - Use<'Video', VideoAssociation> - -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 deleted file mode 100644 index f33c76594..000000000 --- a/server/typings/models/video/video-playlist-element.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' -import { PickWith } from '@server/typings/utils' -import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video' -import { MVideoPlaylistPrivacy } from './video-playlist' - -type Use = PickWith - -// ############################################################################ - -export type MVideoPlaylistElement = Omit - -// ############################################################################ - -export type MVideoPlaylistElementId = Pick - -export type MVideoPlaylistElementLight = Pick - -// ############################################################################ - -export type MVideoPlaylistVideoThumbnail = - MVideoPlaylistElement & - Use<'Video', MVideoThumbnail> - -export type MVideoPlaylistElementVideoUrlPlaylistPrivacy = - MVideoPlaylistElement & - Use<'Video', MVideoUrl> & - Use<'VideoPlaylist', MVideoPlaylistPrivacy> - -// ############################################################################ - -// Format for API or AP object - -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 deleted file mode 100644 index 49c27f4a7..000000000 --- a/server/typings/models/video/video-playlist.ts +++ /dev/null @@ -1,104 +0,0 @@ -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, MChannelUrl } from './video-channels' -import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' - -type Use = PickWith - -// ############################################################################ - -export type MVideoPlaylist = Omit - -// ############################################################################ - -export type MVideoPlaylistId = Pick -export type MVideoPlaylistPrivacy = Pick -export type MVideoPlaylistUUID = Pick -export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number } - -// ############################################################################ - -// With elements - -export type MVideoPlaylistWithElements = - MVideoPlaylist & - Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> - -export type MVideoPlaylistIdWithElements = - MVideoPlaylistId & - Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> - -// ############################################################################ - -// With account - -export type MVideoPlaylistOwner = - MVideoPlaylist & - Use<'OwnerAccount', MAccount> - -export type MVideoPlaylistOwnerDefault = - MVideoPlaylist & - Use<'OwnerAccount', MAccountDefault> - -// ############################################################################ - -// With thumbnail - -export type MVideoPlaylistThumbnail = - MVideoPlaylist & - Use<'Thumbnail', MThumbnail> - -export type MVideoPlaylistAccountThumbnail = - MVideoPlaylist & - Use<'OwnerAccount', MAccountDefault> & - Use<'Thumbnail', MThumbnail> - -// ############################################################################ - -// With channel - -export type MVideoPlaylistAccountChannelDefault = - MVideoPlaylist & - Use<'OwnerAccount', MAccountDefault> & - Use<'VideoChannel', MChannelDefault> - -// ############################################################################ - -// With all associations - -export type MVideoPlaylistFull = - MVideoPlaylist & - Use<'OwnerAccount', MAccountDefault> & - Use<'VideoChannel', MChannelDefault> & - Use<'Thumbnail', MThumbnail> - -// ############################################################################ - -// For API - -export type MVideoPlaylistAccountChannelSummary = - MVideoPlaylist & - Use<'OwnerAccount', MAccountSummary> & - Use<'VideoChannel', MChannelSummary> - -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> - -export type MVideoPlaylistAP = - MVideoPlaylist & - Use<'Thumbnail', MThumbnail> & - Use<'VideoChannel', MChannelUrl> diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts deleted file mode 100644 index 64ce4965b..000000000 --- a/server/typings/models/video/video-rate.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { AccountVideoRateModel } from '@server/models/account/account-video-rate' -import { PickWith } from '@server/typings/utils' -import { MAccountAudience, MAccountUrl } from '../account/account' -import { MVideo, MVideoFormattable } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MAccountVideoRate = Omit - -export type MAccountVideoRateAccountUrl = - MAccountVideoRate & - Use<'Account', MAccountUrl> - -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-redundancy.ts b/server/typings/models/video/video-redundancy.ts deleted file mode 100644 index 5107aa7f4..000000000 --- a/server/typings/models/video/video-redundancy.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' -import { PickWith, PickWithOpt } from '@server/typings/utils' -import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { VideoFileModel } from '@server/models/video/video-file' -import { MVideoFile, MVideoFileVideo } from './video-file' -import { MStreamingPlaylistVideo } from './video-streaming-playlist' -import { MVideoUrl } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MVideoRedundancy = Omit - -export type MVideoRedundancyFileUrl = Pick - -// ############################################################################ - -export type MVideoRedundancyFile = - MVideoRedundancy & - Use<'VideoFile', MVideoFile> - -export type MVideoRedundancyFileVideo = - MVideoRedundancy & - Use<'VideoFile', MVideoFileVideo> - -export type MVideoRedundancyStreamingPlaylistVideo = - MVideoRedundancy & - Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> - -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-share.ts b/server/typings/models/video/video-share.ts deleted file mode 100644 index 50ca75d26..000000000 --- a/server/typings/models/video/video-share.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { VideoShareModel } from '../../../models/video/video-share' -import { PickWith } from '../../utils' -import { MActorDefault } from '../account' -import { MVideo } from './video' - -type Use = PickWith - -// ############################################################################ - -export type MVideoShare = Omit - -export type MVideoShareActor = - MVideoShare & - Use<'Actor', MActorDefault> - -export type MVideoShareFull = - MVideoShare & - Use<'Actor', MActorDefault> & - Use<'Video', MVideo> diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts deleted file mode 100644 index 3f54aa560..000000000 --- a/server/typings/models/video/video-streaming-playlist.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' -import { PickWith, PickWithOpt } from '../../utils' -import { MVideoRedundancyFileUrl, MVideoRedundancy } from './video-redundancy' -import { MVideo } from './video' -import { MVideoFile } from './video-file' - -type Use = PickWith - -// ############################################################################ - -export type MStreamingPlaylist = Omit - -export type MStreamingPlaylistFiles = - MStreamingPlaylist & - Use<'VideoFiles', MVideoFile[]> - -export type MStreamingPlaylistVideo = - MStreamingPlaylist & - Use<'Video', MVideo> - -export type MStreamingPlaylistFilesVideo = - MStreamingPlaylist & - Use<'VideoFiles', MVideoFile[]> & - Use<'Video', MVideo> - -export type MStreamingPlaylistRedundanciesAll = - MStreamingPlaylist & - Use<'VideoFiles', MVideoFile[]> & - Use<'RedundancyVideos', MVideoRedundancy[]> - -export type MStreamingPlaylistRedundancies = - MStreamingPlaylist & - Use<'VideoFiles', MVideoFile[]> & - Use<'RedundancyVideos', MVideoRedundancyFileUrl[]> - -export type MStreamingPlaylistRedundanciesOpt = - MStreamingPlaylist & - Use<'VideoFiles', MVideoFile[]> & - PickWithOpt - -export function isStreamingPlaylist (value: MVideo | MStreamingPlaylistVideo): value is MStreamingPlaylistVideo { - return !!(value as MStreamingPlaylist).playlistUrl -} diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts deleted file mode 100644 index 022a9566d..000000000 --- a/server/typings/models/video/video.ts +++ /dev/null @@ -1,211 +0,0 @@ -import { VideoModel } from '../../../models/video/video' -import { PickWith, PickWithOpt } from '../../utils' -import { - MChannelAccountDefault, - MChannelAccountLight, - MChannelAccountSummaryFormattable, - MChannelActor, - MChannelFormattable, - MChannelUserId -} from './video-channels' -import { MTag } from './tag' -import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption' -import { - MStreamingPlaylistFiles, - MStreamingPlaylistRedundancies, - MStreamingPlaylistRedundanciesAll, - MStreamingPlaylistRedundanciesOpt -} from './video-streaming-playlist' -import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file' -import { MThumbnail } from './thumbnail' -import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' -import { MScheduleVideoUpdate } from './schedule-video-update' -import { MUserVideoHistoryTime } from '../user/user-video-history' - -type Use = PickWith - -// ############################################################################ - -export type MVideo = - Omit - -// ############################################################################ - -export type MVideoId = Pick -export type MVideoUrl = Pick -export type MVideoUUID = Pick - -export type MVideoImmutable = Pick -export type MVideoIdUrl = MVideoId & MVideoUrl -export type MVideoFeed = Pick - -// ############################################################################ - -// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists - -// "With" to not confuse with the VideoFile model -export type MVideoWithFile = - MVideo & - Use<'VideoFiles', MVideoFile[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> - -export type MVideoThumbnail = - MVideo & - Use<'Thumbnails', MThumbnail[]> - -export type MVideoIdThumbnail = - MVideoId & - Use<'Thumbnails', MThumbnail[]> - -export type MVideoWithFileThumbnail = - MVideo & - Use<'VideoFiles', MVideoFile[]> & - Use<'Thumbnails', MThumbnail[]> - -export type MVideoThumbnailBlacklist = - MVideo & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoBlacklist', MVideoBlacklistLight> - -export type MVideoTag = - MVideo & - Use<'Tags', MTag[]> - -export type MVideoWithSchedule = - MVideo & - PickWithOpt - -export type MVideoWithCaptions = - MVideo & - Use<'VideoCaptions', MVideoCaptionLanguage[]> - -export type MVideoWithStreamingPlaylist = - MVideo & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> - -// ############################################################################ - -// Associations with not all their attributes - -export type MVideoUserHistory = - MVideo & - Use<'UserVideoHistories', MUserVideoHistoryTime[]> - -export type MVideoWithBlacklistLight = - MVideo & - Use<'VideoBlacklist', MVideoBlacklistLight> - -export type MVideoAccountLight = - MVideo & - Use<'VideoChannel', MChannelAccountLight> - -export type MVideoWithRights = - MVideo & - Use<'VideoBlacklist', MVideoBlacklistLight> & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoChannel', MChannelUserId> - -// ############################################################################ - -// All files with some additional associations - -export type MVideoWithAllFiles = - MVideo & - Use<'VideoFiles', MVideoFile[]> & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> - -export type MVideoAccountLightBlacklistAllFiles = - MVideo & - Use<'VideoFiles', MVideoFile[]> & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & - Use<'VideoChannel', MChannelAccountLight> & - Use<'VideoBlacklist', MVideoBlacklistLight> - -// ############################################################################ - -// With account - -export type MVideoAccountDefault = - MVideo & - Use<'VideoChannel', MChannelAccountDefault> - -export type MVideoThumbnailAccountDefault = - MVideo & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoChannel', MChannelAccountDefault> - -export type MVideoWithChannelActor = - MVideo & - Use<'VideoChannel', MChannelActor> - -export type MVideoFullLight = - MVideo & - Use<'Thumbnails', MThumbnail[]> & - Use<'VideoBlacklist', MVideoBlacklistLight> & - Use<'Tags', MTag[]> & - Use<'VideoChannel', MChannelAccountLight> & - Use<'UserVideoHistories', MUserVideoHistoryTime[]> & - Use<'VideoFiles', MVideoFile[]> & - Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> - -// ############################################################################ - -// API - -export type MVideoAP = - MVideo & - Use<'Tags', MTag[]> & - Use<'VideoChannel', MChannelAccountLight> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> & - Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> & - Use<'VideoBlacklist', MVideoBlacklistUnfederated> & - Use<'VideoFiles', MVideoFileRedundanciesOpt[]> & - Use<'Thumbnails', MThumbnail[]> - -export type MVideoAPWithoutCaption = Omit - -export type MVideoDetails = - MVideo & - Use<'VideoBlacklist', MVideoBlacklistLight> & - Use<'Tags', MTag[]> & - Use<'VideoChannel', MChannelAccountLight> & - Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & - Use<'Thumbnails', MThumbnail[]> & - Use<'UserVideoHistories', MUserVideoHistoryTime[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & - Use<'VideoFiles', MVideoFileRedundanciesOpt[]> - -export type MVideoForUser = - MVideo & - Use<'VideoChannel', MChannelAccountDefault> & - Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & - Use<'VideoBlacklist', MVideoBlacklistLight> & - Use<'Thumbnails', MThumbnail[]> - -export type MVideoForRedundancyAPI = - MVideo & - Use<'VideoFiles', MVideoFileRedundanciesAll[]> & - Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]> - -// ############################################################################ - -// 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', MStreamingPlaylistRedundanciesOpt[]> & - Use<'VideoFiles', MVideoFileRedundanciesOpt[]> diff --git a/server/typings/plugins/register-server-option.model.ts b/server/typings/plugins/register-server-option.model.ts index 8f1d66007..b4594c6cd 100644 --- a/server/typings/plugins/register-server-option.model.ts +++ b/server/typings/plugins/register-server-option.model.ts @@ -17,7 +17,7 @@ import { PluginVideoLanguageManager } from '../../../shared/models/plugins/plugi import { PluginVideoLicenceManager } from '../../../shared/models/plugins/plugin-video-licence-manager.model' import { RegisterServerHookOptions } from '../../../shared/models/plugins/register-server-hook.model' import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model' -import { MVideoThumbnail } from '../models' +import { MVideoThumbnail } from '../../types/models' export type PeerTubeHelpers = { logger: Logger diff --git a/server/typings/sequelize.ts b/server/typings/sequelize.ts deleted file mode 100644 index 9cd83612d..000000000 --- a/server/typings/sequelize.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Model } from 'sequelize-typescript' - -// Thanks to sequelize-typescript: https://github.com/RobinBuschmann/sequelize-typescript - -export type Diff = - ({ [P in T]: P } & { [P in U]: never } & { [ x: string ]: never })[T] - -export type Omit = { [P in Diff]: T[P] } - -export type RecursivePartial = { [P in keyof T]?: RecursivePartial } - -export type FilteredModelAttributes> = RecursivePartial>> & { - id?: number | any - createdAt?: Date | any - updatedAt?: Date | any - deletedAt?: Date | any - version?: number | any -} diff --git a/server/typings/utils.ts b/server/typings/utils.ts deleted file mode 100644 index 55500d8c4..000000000 --- a/server/typings/utils.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/array-type */ - -export type FunctionPropertyNames = { - [K in keyof T]: T[K] extends Function ? K : never -}[keyof T] - -export type FunctionProperties = Pick> - -export type PickWith = { - [P in KT]: T[P] extends V ? V : never -} - -export type PickWithOpt = { - [P in KT]?: T[P] extends V ? V : never -} - -// https://github.com/krzkaczor/ts-essentials Rocks! -export type DeepPartial = { - [P in keyof T]?: T[P] extends Array - ? Array> - : T[P] extends ReadonlyArray - ? ReadonlyArray> - : DeepPartial -} -- cgit v1.2.3