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