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