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