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