]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/express/index.d.ts
Fetch directly all video attributes for get API
[github/Chocobozzz/PeerTube.git] / server / typings / express / index.d.ts
1
2 import { RegisterServerAuthExternalOptions } from '@server/types'
3 import {
4 MAbuseMessage,
5 MAbuseReporter,
6 MAccountBlocklist,
7 MActorFollowActorsDefault,
8 MActorUrl,
9 MChannelBannerAccountDefault,
10 MStreamingPlaylist,
11 MVideoChangeOwnershipFull,
12 MVideoFile,
13 MVideoFormattableDetails,
14 MVideoImmutable,
15 MVideoLive,
16 MVideoPlaylistFull,
17 MVideoPlaylistFullSummary
18 } from '@server/types/models'
19 import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
20 import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
21 import { MVideoImportDefault } from '@server/types/models/video/video-import'
22 import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
23 import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
24 import { HttpMethod } from '@shared/core-utils/miscs/http-methods'
25 import { PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
26 import { File as UploadXFile, Metadata } from '@uploadx/core'
27 import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
28 import {
29 MAccountDefault,
30 MActorAccountChannelId,
31 MActorFollowActorsDefaultSubscription,
32 MActorFull,
33 MComment,
34 MCommentOwnerVideoReply,
35 MUserDefault,
36 MVideoBlacklist,
37 MVideoCaptionVideo,
38 MVideoFullLight,
39 MVideoIdThumbnail,
40 MVideoRedundancyVideo,
41 MVideoShareActor,
42 MVideoThumbnail,
43 MVideoWithRights
44 } from '../../types/models'
45
46 declare module 'express' {
47 export interface Request {
48 query: any
49 method: HttpMethod
50 }
51
52 // Upload using multer or uploadx middleware
53 export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
54
55 export type UploadFiles = {
56 [fieldname: string]: MulterOrUploadXFile[]
57 } | MulterOrUploadXFile[]
58
59 // Partial object used by some functions to check the file mimetype/extension
60 export type UploadFileForCheck = {
61 originalname: string
62 mimetype: string
63 }
64
65 export type UploadFilesForCheck = {
66 [fieldname: string]: UploadFileForCheck[]
67 } | UploadFileForCheck[]
68
69 // Upload file with a duration added by our middleware
70 export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
71 duration: number
72 }
73
74 // Extends Metadata property of UploadX object
75 export type UploadXFileMetadata = Metadata & VideoCreate & {
76 previewfile: Express.Multer.File[]
77 thumbnailfile: Express.Multer.File[]
78 }
79
80 // Our custom UploadXFile object using our custom metadata
81 export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
82
83 export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
84 duration: number
85 path: string
86 filename: string
87 }
88
89 // Extends Response with added functions and potential variables passed by middlewares
90 interface Response {
91 fail: (options: {
92 message: string
93
94 title?: string
95 status?: number
96 type?: ServerErrorCode
97 instance?: string
98
99 data?: PeerTubeProblemDocumentData
100 }) => void
101
102 locals: {
103 docUrl?: string
104
105 videoAPI?: MVideoFormattableDetails
106 videoAll?: MVideoFullLight
107 onlyImmutableVideo?: MVideoImmutable
108 onlyVideo?: MVideoThumbnail
109 onlyVideoWithRights?: MVideoWithRights
110 videoId?: MVideoIdThumbnail
111
112 videoLive?: MVideoLive
113
114 videoShare?: MVideoShareActor
115
116 videoFile?: MVideoFile
117
118 videoFileResumable?: EnhancedUploadXFile
119
120 videoImport?: MVideoImportDefault
121
122 videoBlacklist?: MVideoBlacklist
123
124 videoCaption?: MVideoCaptionVideo
125
126 abuse?: MAbuseReporter
127 abuseMessage?: MAbuseMessage
128
129 videoStreamingPlaylist?: MStreamingPlaylist
130
131 videoChannel?: MChannelBannerAccountDefault
132
133 videoPlaylistFull?: MVideoPlaylistFull
134 videoPlaylistSummary?: MVideoPlaylistFullSummary
135
136 videoPlaylistElement?: MVideoPlaylistElement
137 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
138
139 accountVideoRate?: MAccountVideoRateAccountVideo
140
141 videoCommentFull?: MCommentOwnerVideoReply
142 videoCommentThread?: MComment
143
144 follow?: MActorFollowActorsDefault
145 subscription?: MActorFollowActorsDefaultSubscription
146
147 nextOwner?: MAccountDefault
148 videoChangeOwnership?: MVideoChangeOwnershipFull
149
150 account?: MAccountDefault
151
152 actorUrl?: MActorUrl
153 actorFull?: MActorFull
154
155 user?: MUserDefault
156
157 server?: MServer
158
159 videoRedundancy?: MVideoRedundancyVideo
160
161 accountBlock?: MAccountBlocklist
162 serverBlock?: MServerBlocklist
163
164 oauth?: {
165 token: MOAuthTokenUser
166 }
167
168 signature?: {
169 actor: MActorAccountChannelId
170 }
171
172 authenticated?: boolean
173
174 registeredPlugin?: RegisteredPlugin
175
176 externalAuth?: RegisterServerAuthExternalOptions
177
178 plugin?: MPlugin
179 }
180 }
181 }