]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/typings/express/index.d.ts
Fix video update transaction
[github/Chocobozzz/PeerTube.git] / server / typings / express / index.d.ts
index b0004dc7b7818a48ed0355e7a94023c43147f26c..1a99b598aabacb6be95983d07e610c81ff5a726c 100644 (file)
@@ -1,12 +1,18 @@
+
+import { OutgoingHttpHeaders } from 'http'
 import { RegisterServerAuthExternalOptions } from '@server/types'
 import {
   MAbuseMessage,
   MAbuseReporter,
   MAccountBlocklist,
+  MActorFollowActorsDefault,
   MActorUrl,
+  MChannelBannerAccountDefault,
   MStreamingPlaylist,
   MVideoChangeOwnershipFull,
   MVideoFile,
+  MVideoFormattableDetails,
+  MVideoId,
   MVideoImmutable,
   MVideoLive,
   MVideoPlaylistFull,
@@ -17,106 +23,167 @@ import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
 import { MVideoImportDefault } from '@server/types/models/video/video-import'
 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
+import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
+import { File as UploadXFile, Metadata } from '@uploadx/core'
 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
 import {
   MAccountDefault,
   MActorAccountChannelId,
-  MActorFollowActorsDefault,
   MActorFollowActorsDefaultSubscription,
   MActorFull,
-  MChannelAccountDefault,
   MComment,
   MCommentOwnerVideoReply,
   MUserDefault,
   MVideoBlacklist,
   MVideoCaptionVideo,
   MVideoFullLight,
-  MVideoIdThumbnail,
   MVideoRedundancyVideo,
   MVideoShareActor,
-  MVideoThumbnail,
-  MVideoWithRights
+  MVideoThumbnail
 } from '../../types/models'
+import { Writable } from 'stream'
 
 declare module 'express' {
   export interface Request {
     query: any
+    method: HttpMethod
   }
-  interface Response {
-    locals: PeerTubeLocals
+
+  // Upload using multer or uploadx middleware
+  export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
+
+  export type UploadFiles = {
+    [fieldname: string]: MulterOrUploadXFile[]
+  } | MulterOrUploadXFile[]
+
+  // Partial object used by some functions to check the file mimetype/extension
+  export type UploadFileForCheck = {
+    originalname: string
+    mimetype: string
   }
-}
 
-interface PeerTubeLocals {
-  videoAll?: MVideoFullLight
-  onlyImmutableVideo?: MVideoImmutable
-  onlyVideo?: MVideoThumbnail
-  onlyVideoWithRights?: MVideoWithRights
-  videoId?: MVideoIdThumbnail
+  export type UploadFilesForCheck = {
+    [fieldname: string]: UploadFileForCheck[]
+  } | UploadFileForCheck[]
 
-  videoLive?: MVideoLive
+  // Upload file with a duration added by our middleware
+  export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
+    duration: number
+  }
 
-  videoShare?: MVideoShareActor
+  // Extends Metadata property of UploadX object
+  export type UploadXFileMetadata = Metadata & VideoCreate & {
+    previewfile: Express.Multer.File[]
+    thumbnailfile: Express.Multer.File[]
+  }
 
-  videoFile?: MVideoFile
+  // Our custom UploadXFile object using our custom metadata
+  export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
 
-  videoImport?: MVideoImportDefault
+  export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
+    duration: number
+    path: string
+    filename: string
+  }
 
-  videoBlacklist?: MVideoBlacklist
+  // Extends Response with added functions and potential variables passed by middlewares
+  interface Response {
+    fail: (options: {
+      message: string
 
-  videoCaption?: MVideoCaptionVideo
+      title?: string
+      status?: number
+      type?: ServerErrorCode
+      instance?: string
 
-  abuse?: MAbuseReporter
-  abuseMessage?: MAbuseMessage
+      data?: PeerTubeProblemDocumentData
+    }) => void
 
-  videoStreamingPlaylist?: MStreamingPlaylist
+    locals: {
+      apicache: {
+        content: string | Buffer
+        write: Writable['write']
+        writeHead: Response['writeHead']
+        end: Response['end']
+        cacheable: boolean
+        headers: OutgoingHttpHeaders
+      }
 
-  videoChannel?: MChannelAccountDefault
+      docUrl?: string
 
-  videoPlaylistFull?: MVideoPlaylistFull
-  videoPlaylistSummary?: MVideoPlaylistFullSummary
+      videoAPI?: MVideoFormattableDetails
+      videoAll?: MVideoFullLight
+      onlyImmutableVideo?: MVideoImmutable
+      onlyVideo?: MVideoThumbnail
+      videoId?: MVideoId
 
-  videoPlaylistElement?: MVideoPlaylistElement
-  videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
+      videoLive?: MVideoLive
 
-  accountVideoRate?: MAccountVideoRateAccountVideo
+      videoShare?: MVideoShareActor
 
-  videoCommentFull?: MCommentOwnerVideoReply
-  videoCommentThread?: MComment
+      videoFile?: MVideoFile
 
-  follow?: MActorFollowActorsDefault
-  subscription?: MActorFollowActorsDefaultSubscription
+      videoFileResumable?: EnhancedUploadXFile
 
-  nextOwner?: MAccountDefault
-  videoChangeOwnership?: MVideoChangeOwnershipFull
+      videoImport?: MVideoImportDefault
 
-  account?: MAccountDefault
+      videoBlacklist?: MVideoBlacklist
 
-  actorUrl?: MActorUrl
-  actorFull?: MActorFull
+      videoCaption?: MVideoCaptionVideo
 
-  user?: MUserDefault
+      abuse?: MAbuseReporter
+      abuseMessage?: MAbuseMessage
 
-  server?: MServer
+      videoStreamingPlaylist?: MStreamingPlaylist
 
-  videoRedundancy?: MVideoRedundancyVideo
+      videoChannel?: MChannelBannerAccountDefault
 
-  accountBlock?: MAccountBlocklist
-  serverBlock?: MServerBlocklist
+      videoPlaylistFull?: MVideoPlaylistFull
+      videoPlaylistSummary?: MVideoPlaylistFullSummary
 
-  oauth?: {
-    token: MOAuthTokenUser
-  }
+      videoPlaylistElement?: MVideoPlaylistElement
+      videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
 
-  signature?: {
-    actor: MActorAccountChannelId
-  }
+      accountVideoRate?: MAccountVideoRateAccountVideo
+
+      videoCommentFull?: MCommentOwnerVideoReply
+      videoCommentThread?: MComment
+
+      follow?: MActorFollowActorsDefault
+      subscription?: MActorFollowActorsDefaultSubscription
+
+      nextOwner?: MAccountDefault
+      videoChangeOwnership?: MVideoChangeOwnershipFull
+
+      account?: MAccountDefault
+
+      actorUrl?: MActorUrl
+      actorFull?: MActorFull
+
+      user?: MUserDefault
 
-  authenticated?: boolean
+      server?: MServer
 
-  registeredPlugin?: RegisteredPlugin
+      videoRedundancy?: MVideoRedundancyVideo
 
-  externalAuth?: RegisterServerAuthExternalOptions
+      accountBlock?: MAccountBlocklist
+      serverBlock?: MServerBlocklist
 
-  plugin?: MPlugin
+      oauth?: {
+        token: MOAuthTokenUser
+      }
+
+      signature?: {
+        actor: MActorAccountChannelId
+      }
+
+      authenticated?: boolean
+
+      registeredPlugin?: RegisteredPlugin
+
+      externalAuth?: RegisterServerAuthExternalOptions
+
+      plugin?: MPlugin
+    }
+  }
 }