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