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