]>
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: { |
20bafcb6 C |
106 | apicache: { |
107 | content: string | Buffer | |
108 | write: Writable['write'] | |
109 | writeHead: Response['writeHead'] | |
110 | end: Response['end'] | |
111 | cacheable: boolean | |
112 | headers: OutgoingHttpHeaders | |
113 | } | |
114 | ||
e030bfb5 C |
115 | docUrl?: string |
116 | ||
ca4b4b2e | 117 | videoAPI?: MVideoFormattableDetails |
f6d6e7f8 | 118 | videoAll?: MVideoFullLight |
119 | onlyImmutableVideo?: MVideoImmutable | |
120 | onlyVideo?: MVideoThumbnail | |
71d4af1e | 121 | videoId?: MVideoId |
453e83ea | 122 | |
f6d6e7f8 | 123 | videoLive?: MVideoLive |
26e3e98f | 124 | videoLiveSession?: MVideoLiveSession |
453e83ea | 125 | |
f6d6e7f8 | 126 | videoShare?: MVideoShareActor |
dae86118 | 127 | |
2e401e85 | 128 | videoSource?: MVideoSource |
129 | ||
f6d6e7f8 | 130 | videoFile?: MVideoFile |
dae86118 | 131 | |
f6d6e7f8 | 132 | videoFileResumable?: EnhancedUploadXFile |
dae86118 | 133 | |
f6d6e7f8 | 134 | videoImport?: MVideoImportDefault |
dae86118 | 135 | |
f6d6e7f8 | 136 | videoBlacklist?: MVideoBlacklist |
dae86118 | 137 | |
f6d6e7f8 | 138 | videoCaption?: MVideoCaptionVideo |
dae86118 | 139 | |
f6d6e7f8 | 140 | abuse?: MAbuseReporter |
141 | abuseMessage?: MAbuseMessage | |
dae86118 | 142 | |
f6d6e7f8 | 143 | videoStreamingPlaylist?: MStreamingPlaylist |
dae86118 | 144 | |
f6d6e7f8 | 145 | videoChannel?: MChannelBannerAccountDefault |
dae86118 | 146 | |
f6d6e7f8 | 147 | videoPlaylistFull?: MVideoPlaylistFull |
148 | videoPlaylistSummary?: MVideoPlaylistFullSummary | |
dae86118 | 149 | |
f6d6e7f8 | 150 | videoPlaylistElement?: MVideoPlaylistElement |
151 | videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy | |
dae86118 | 152 | |
f6d6e7f8 | 153 | accountVideoRate?: MAccountVideoRateAccountVideo |
dae86118 | 154 | |
f6d6e7f8 | 155 | videoCommentFull?: MCommentOwnerVideoReply |
156 | videoCommentThread?: MComment | |
dae86118 | 157 | |
f6d6e7f8 | 158 | follow?: MActorFollowActorsDefault |
159 | subscription?: MActorFollowActorsDefaultSubscription | |
dae86118 | 160 | |
f6d6e7f8 | 161 | nextOwner?: MAccountDefault |
162 | videoChangeOwnership?: MVideoChangeOwnershipFull | |
dae86118 | 163 | |
f6d6e7f8 | 164 | account?: MAccountDefault |
dae86118 | 165 | |
f6d6e7f8 | 166 | actorUrl?: MActorUrl |
167 | actorFull?: MActorFull | |
168 | ||
169 | user?: MUserDefault | |
170 | ||
171 | server?: MServer | |
172 | ||
173 | videoRedundancy?: MVideoRedundancyVideo | |
dae86118 | 174 | |
f6d6e7f8 | 175 | accountBlock?: MAccountBlocklist |
176 | serverBlock?: MServerBlocklist | |
345da516 | 177 | |
f6d6e7f8 | 178 | oauth?: { |
179 | token: MOAuthTokenUser | |
180 | } | |
ad91e700 | 181 | |
f6d6e7f8 | 182 | signature?: { |
183 | actor: MActorAccountChannelId | |
184 | } | |
4a8d113b | 185 | |
f6d6e7f8 | 186 | authenticated?: boolean |
187 | ||
188 | registeredPlugin?: RegisteredPlugin | |
189 | ||
190 | externalAuth?: RegisterServerAuthExternalOptions | |
191 | ||
192 | plugin?: MPlugin | |
b2111066 C |
193 | |
194 | localViewerFull?: MLocalVideoViewerWithWatchSections | |
f6d6e7f8 | 195 | } |
196 | } | |
dae86118 | 197 | } |