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