@zuplo/cli 6.72.15 → 6.72.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@fastify/reply-from/CLAUDE.md +66 -0
- package/node_modules/@fastify/reply-from/index.js +8 -4
- package/node_modules/@fastify/reply-from/package.json +1 -1
- package/node_modules/@fastify/reply-from/test/fix-GHSA-v574-6498-x57v.test.js +219 -0
- package/node_modules/@fastify/reply-from/test/http1-aborted-request.test.js +61 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-2WLR6ZDZ.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-2WLR6ZDZ.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-52N4KSHA.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-4QJJMELB.js.map → chunk-52N4KSHA.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-FPZAMUNA.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-FPZAMUNA.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-SQVIQSIN.js → chunk-KH6FKZ3E.js} +108 -108
- package/node_modules/@zuplo/runtime/out/esm/chunk-KH6FKZ3E.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-J6K7HSIK.js → chunk-QWO5UTVQ.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-J6K7HSIK.js.map → chunk-QWO5UTVQ.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-SNZSLL63.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-SNZSLL63.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-US6ITPGV.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-32F3RZS4.js.map → chunk-US6ITPGV.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-DSZS6PZJ.js → chunk-VCMIY3WJ.js} +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-VCMIY3WJ.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +13 -13
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/types/mcp/messages/index.d.ts +2438 -0
- package/node_modules/@zuplo/runtime/package.json +5 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-32F3RZS4.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-4QJJMELB.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-DSZS6PZJ.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-SQVIQSIN.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-SQVIQSIN.js.LEGAL.txt → chunk-KH6FKZ3E.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DSZS6PZJ.js.LEGAL.txt → chunk-VCMIY3WJ.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,2438 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base logger interface with methods for each log level.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
declare interface BaseLogger {
|
|
6
|
+
debug(...messages: unknown[]): void;
|
|
7
|
+
info(...messages: unknown[]): void;
|
|
8
|
+
log(...messages: unknown[]): void;
|
|
9
|
+
warn(...messages: unknown[]): void;
|
|
10
|
+
error(...messages: unknown[]): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare interface BuildRouteConfiguration {
|
|
17
|
+
path: string;
|
|
18
|
+
methods: HttpMethod[];
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated This property is not used and will be removed in future versions
|
|
21
|
+
*/
|
|
22
|
+
label?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated This property is not used and will be removed in future versions
|
|
25
|
+
*/
|
|
26
|
+
key?: string;
|
|
27
|
+
handler: HandlerDefinition;
|
|
28
|
+
corsPolicy?: CorsPolicy;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated This property is deprecated. Use route.raw() instead.
|
|
31
|
+
*/
|
|
32
|
+
custom?: any;
|
|
33
|
+
mcp?: {
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
policies?: {
|
|
37
|
+
inbound?: string[];
|
|
38
|
+
outbound?: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated This property is not used and will be removed in future versions
|
|
42
|
+
*/
|
|
43
|
+
excludeFromOpenApi?: boolean;
|
|
44
|
+
pathPattern?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Build-time metadata for this route.
|
|
47
|
+
*/
|
|
48
|
+
metadata?: {
|
|
49
|
+
/**
|
|
50
|
+
* The source file this route was generated from.
|
|
51
|
+
*/
|
|
52
|
+
filepath: string;
|
|
53
|
+
};
|
|
54
|
+
/* Excluded from this release type: raw */
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The 2-letter continent codes Cloudflare uses
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
declare type CorsPolicy = string | "anything-goes" | "none";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Answer an MCP envelope with a JSON-RPC error, protocol-correctly.
|
|
70
|
+
*
|
|
71
|
+
* The two-argument form rejects the whole envelope: every request id gets
|
|
72
|
+
* `error`. The three-argument form targets one request: the named message
|
|
73
|
+
* gets `error` and every other request gets `-32001 Not processed`. In both
|
|
74
|
+
* forms invalid members are answered with their own parse error,
|
|
75
|
+
* notifications get no reply entry, and the wire shape (single object vs
|
|
76
|
+
* batch array) mirrors the incoming envelope.
|
|
77
|
+
*
|
|
78
|
+
* @beta
|
|
79
|
+
*/
|
|
80
|
+
export declare function createErrorResponse(
|
|
81
|
+
envelope: McpEnvelope,
|
|
82
|
+
error: McpErrorDetail
|
|
83
|
+
): Response;
|
|
84
|
+
|
|
85
|
+
export declare function createErrorResponse(
|
|
86
|
+
envelope: McpEnvelope,
|
|
87
|
+
message: McpAnyRequestMessage,
|
|
88
|
+
error: McpErrorDetail
|
|
89
|
+
): Response;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Answer an MCP envelope's only request with a JSON-RPC result, without
|
|
93
|
+
* calling the upstream. Throws when the envelope contains more than one
|
|
94
|
+
* request — answering one request of a batch requires the partial-forwarding
|
|
95
|
+
* engine (`processMessages`), not a whole-exchange response.
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
export declare function createResultResponse(
|
|
100
|
+
envelope: McpEnvelope,
|
|
101
|
+
message: McpAnyRequestMessage,
|
|
102
|
+
result: McpResult
|
|
103
|
+
): Response;
|
|
104
|
+
|
|
105
|
+
declare const EventType: {
|
|
106
|
+
readonly AI_GATEWAY_COST_SUM: "ai_gateway_cost_sum";
|
|
107
|
+
readonly AI_GATEWAY_REQUEST_COUNT: "ai_gateway_request_count";
|
|
108
|
+
readonly AI_GATEWAY_TOKEN_SUM: "ai_gateway_token_sum";
|
|
109
|
+
readonly AI_GATEWAY_LATENCY_HISTOGRAM: "ai_gateway_latency_histogram";
|
|
110
|
+
readonly AI_GATEWAY_WARNING_COUNT: "ai_gateway_warning_count";
|
|
111
|
+
readonly AI_GATEWAY_BLOCKED_COUNT: "ai_gateway_blocked_count";
|
|
112
|
+
readonly AI_GATEWAY_FALLBACK_COUNT: "ai_gateway_fallback_count";
|
|
113
|
+
readonly MCP_REQUEST_RECEIVED: "mcp_request_received";
|
|
114
|
+
readonly MCP_REQUEST_COMPLETED: "mcp_request_completed";
|
|
115
|
+
readonly MCP_REQUEST_REJECTED: "mcp_request_rejected";
|
|
116
|
+
readonly MCP_INITIALIZE_NEGOTIATED: "mcp_initialize_negotiated";
|
|
117
|
+
readonly MCP_CLIENT_UNSUPPORTED_BEHAVIOR: "mcp_client_unsupported_behavior";
|
|
118
|
+
readonly MCP_CAPABILITY_LISTED: "mcp_capability_listed";
|
|
119
|
+
readonly MCP_CAPABILITY_INVOKED: "mcp_capability_invoked";
|
|
120
|
+
readonly MCP_CAPABILITY_COMPLETED: "mcp_capability_completed";
|
|
121
|
+
readonly MCP_CAPABILITY_FAILED: "mcp_capability_failed";
|
|
122
|
+
readonly MCP_CAPABILITY_CONNECT_REQUIRED: "mcp_capability_connect_required";
|
|
123
|
+
readonly MCP_AUTH_DOWNSTREAM_TOKEN_VALIDATED: "mcp_auth_downstream_token_validated";
|
|
124
|
+
readonly MCP_AUTH_DOWNSTREAM_TOKEN_REJECTED: "mcp_auth_downstream_token_rejected";
|
|
125
|
+
readonly MCP_OAUTH_CLIENT_REGISTERED: "mcp_oauth_client_registered";
|
|
126
|
+
readonly MCP_OAUTH_AUTHORIZE_STARTED: "mcp_oauth_authorize_started";
|
|
127
|
+
readonly MCP_OAUTH_AUTHORIZE_AWAITING_SETUP: "mcp_oauth_authorize_awaiting_setup";
|
|
128
|
+
readonly MCP_OAUTH_TOKEN_ISSUED: "mcp_oauth_token_issued";
|
|
129
|
+
readonly MCP_OAUTH_TOKEN_REFRESH_ROTATED: "mcp_oauth_token_refresh_rotated";
|
|
130
|
+
readonly MCP_OAUTH_TOKEN_REVOKED: "mcp_oauth_token_revoked";
|
|
131
|
+
readonly MCP_AUTH_UPSTREAM_CONNECT_REQUIRED: "mcp_auth_upstream_connect_required";
|
|
132
|
+
readonly MCP_AUTH_UPSTREAM_CONNECT_STARTED: "mcp_auth_upstream_connect_started";
|
|
133
|
+
readonly MCP_AUTH_UPSTREAM_CALLBACK_RECEIVED: "mcp_auth_upstream_callback_received";
|
|
134
|
+
readonly MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_SUCCEEDED: "mcp_auth_upstream_token_exchange_succeeded";
|
|
135
|
+
readonly MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_FAILED: "mcp_auth_upstream_token_exchange_failed";
|
|
136
|
+
readonly MCP_AUTH_UPSTREAM_CREDENTIAL_RESOLVED: "mcp_auth_upstream_credential_resolved";
|
|
137
|
+
readonly MCP_AUTH_UPSTREAM_CREDENTIAL_MISSING: "mcp_auth_upstream_credential_missing";
|
|
138
|
+
readonly MCP_AUTH_UPSTREAM_RECONSENT_REQUIRED: "mcp_auth_upstream_reconsent_required";
|
|
139
|
+
readonly GRAPHQL_OPERATION: "graphql_operation";
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
declare type EventType = (typeof EventType)[keyof typeof EventType];
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Parse a request body as MCP (JSON-RPC) messages.
|
|
146
|
+
*
|
|
147
|
+
* Returns `null` when the body is not MCP-shaped — wrong content type, not
|
|
148
|
+
* valid JSON, no `jsonrpc: "2.0"` marker, or larger than the parse limit —
|
|
149
|
+
* so policies can let non-MCP traffic pass through untouched.
|
|
150
|
+
*
|
|
151
|
+
* The parse is cached per request instance: any number of policies can call
|
|
152
|
+
* this on the same request and the body is read and classified once.
|
|
153
|
+
*
|
|
154
|
+
* @beta
|
|
155
|
+
*/
|
|
156
|
+
export declare function getRequest(
|
|
157
|
+
request: Request
|
|
158
|
+
): Promise<McpEnvelope | null>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
declare interface HandlerDefinition {
|
|
164
|
+
module: any;
|
|
165
|
+
export: string;
|
|
166
|
+
options?: unknown;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare type HandlerResult = McpMessageVerdict | Promise<McpMessageVerdict>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
declare type HttpMethod =
|
|
175
|
+
| "GET"
|
|
176
|
+
| "HEAD"
|
|
177
|
+
| "POST"
|
|
178
|
+
| "PUT"
|
|
179
|
+
| "DELETE"
|
|
180
|
+
| "CONNECT"
|
|
181
|
+
| "OPTIONS"
|
|
182
|
+
| "TRACE"
|
|
183
|
+
| "PATCH";
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @beta
|
|
187
|
+
*/
|
|
188
|
+
declare enum HttpStatusCode {
|
|
189
|
+
/**
|
|
190
|
+
* The server has received the request headers and the client should proceed to send the request body
|
|
191
|
+
* (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
192
|
+
* Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
|
|
193
|
+
* To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
|
|
194
|
+
* and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.
|
|
195
|
+
*/
|
|
196
|
+
CONTINUE = 100,
|
|
197
|
+
/**
|
|
198
|
+
* The requester has asked the server to switch protocols and the server has agreed to do so.
|
|
199
|
+
*/
|
|
200
|
+
SWITCHING_PROTOCOLS = 101,
|
|
201
|
+
/**
|
|
202
|
+
* A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
|
|
203
|
+
* This code indicates that the server has received and is processing the request, but no response is available yet.
|
|
204
|
+
* This prevents the client from timing out and assuming the request was lost.
|
|
205
|
+
* @deprecated This status code is deprecated and shouldn't be sent any more. Clients may still accept it, but simply ignore them.
|
|
206
|
+
*/
|
|
207
|
+
PROCESSING = 102,
|
|
208
|
+
/**
|
|
209
|
+
* This response may be sent by a server while it is still preparing a
|
|
210
|
+
* response, with hints about the resources that the server is expecting
|
|
211
|
+
* the final response will link. This allows a browser to start preloading
|
|
212
|
+
* resources even before the server has prepared and sent that final response.
|
|
213
|
+
*/
|
|
214
|
+
EARLY_HINTS = 103,
|
|
215
|
+
/**
|
|
216
|
+
* Standard response for successful HTTP requests.
|
|
217
|
+
* The actual response will depend on the request method used.
|
|
218
|
+
* In a GET request, the response will contain an entity corresponding to the requested resource.
|
|
219
|
+
* In a POST request, the response will contain an entity describing or containing the result of the action.
|
|
220
|
+
*/
|
|
221
|
+
OK = 200,
|
|
222
|
+
/**
|
|
223
|
+
* The request has been fulfilled, resulting in the creation of a new resource.
|
|
224
|
+
*/
|
|
225
|
+
CREATED = 201,
|
|
226
|
+
/**
|
|
227
|
+
* The request has been accepted for processing, but the processing has not been completed.
|
|
228
|
+
* The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
|
|
229
|
+
*/
|
|
230
|
+
ACCEPTED = 202,
|
|
231
|
+
/**
|
|
232
|
+
* SINCE HTTP/1.1
|
|
233
|
+
* The server is a transforming proxy that received a 200 OK from its origin,
|
|
234
|
+
* but is returning a modified version of the origin's response.
|
|
235
|
+
*/
|
|
236
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
237
|
+
/**
|
|
238
|
+
* The server successfully processed the request and is not returning any content.
|
|
239
|
+
*/
|
|
240
|
+
NO_CONTENT = 204,
|
|
241
|
+
/**
|
|
242
|
+
* The server successfully processed the request, but is not returning any content.
|
|
243
|
+
* Unlike a 204 response, this response requires that the requester reset the document view.
|
|
244
|
+
*/
|
|
245
|
+
RESET_CONTENT = 205,
|
|
246
|
+
/**
|
|
247
|
+
* The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
|
|
248
|
+
* The range header is used by HTTP clients to enable resuming of interrupted downloads,
|
|
249
|
+
* or split a download into multiple simultaneous streams.
|
|
250
|
+
*/
|
|
251
|
+
PARTIAL_CONTENT = 206,
|
|
252
|
+
/**
|
|
253
|
+
* The message body that follows is an XML message and can contain a number of separate response codes,
|
|
254
|
+
* depending on how many sub-requests were made.
|
|
255
|
+
*/
|
|
256
|
+
MULTI_STATUS = 207,
|
|
257
|
+
/**
|
|
258
|
+
* The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
|
|
259
|
+
* and are not being included again.
|
|
260
|
+
*/
|
|
261
|
+
ALREADY_REPORTED = 208,
|
|
262
|
+
/**
|
|
263
|
+
* The server has fulfilled a request for the resource,
|
|
264
|
+
* and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
|
|
265
|
+
*/
|
|
266
|
+
IM_USED = 226,
|
|
267
|
+
/**
|
|
268
|
+
* Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
|
|
269
|
+
* For example, this code could be used to present multiple video format options,
|
|
270
|
+
* to list files with different filename extensions, or to suggest word-sense disambiguation.
|
|
271
|
+
*/
|
|
272
|
+
MULTIPLE_CHOICES = 300,
|
|
273
|
+
/**
|
|
274
|
+
* This and all future requests should be directed to the given URI.
|
|
275
|
+
*/
|
|
276
|
+
MOVED_PERMANENTLY = 301,
|
|
277
|
+
/**
|
|
278
|
+
* This is an example of industry practice contradicting the standard.
|
|
279
|
+
* The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
|
|
280
|
+
* (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
|
|
281
|
+
* with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
|
|
282
|
+
* to distinguish between the two behaviours. However, some Web applications and frameworks
|
|
283
|
+
* use the 302 status code as if it were the 303.
|
|
284
|
+
*/
|
|
285
|
+
FOUND = 302,
|
|
286
|
+
/**
|
|
287
|
+
* SINCE HTTP/1.1
|
|
288
|
+
* The response to the request can be found under another URI using a GET method.
|
|
289
|
+
* When received in response to a POST (or PUT/DELETE), the client should presume that
|
|
290
|
+
* the server has received the data and should issue a redirect with a separate GET message.
|
|
291
|
+
*/
|
|
292
|
+
SEE_OTHER = 303,
|
|
293
|
+
/**
|
|
294
|
+
* Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
|
|
295
|
+
* In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
|
|
296
|
+
*/
|
|
297
|
+
NOT_MODIFIED = 304,
|
|
298
|
+
/**
|
|
299
|
+
* SINCE HTTP/1.1
|
|
300
|
+
* The requested resource is available only through a proxy, the address for which is provided in the response.
|
|
301
|
+
* Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
|
|
302
|
+
*/
|
|
303
|
+
USE_PROXY = 305,
|
|
304
|
+
/**
|
|
305
|
+
* No longer used. Originally meant "Subsequent requests should use the specified proxy."
|
|
306
|
+
* @deprecated No longer used
|
|
307
|
+
*/
|
|
308
|
+
SWITCH_PROXY = 306,
|
|
309
|
+
/**
|
|
310
|
+
* SINCE HTTP/1.1
|
|
311
|
+
* In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
|
|
312
|
+
* In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
|
|
313
|
+
* For example, a POST request should be repeated using another POST request.
|
|
314
|
+
*/
|
|
315
|
+
TEMPORARY_REDIRECT = 307,
|
|
316
|
+
/**
|
|
317
|
+
* The request and all future requests should be repeated using another URI.
|
|
318
|
+
* 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
|
|
319
|
+
* So, for example, submitting a form to a permanently redirected resource may continue smoothly.
|
|
320
|
+
*/
|
|
321
|
+
PERMANENT_REDIRECT = 308,
|
|
322
|
+
/**
|
|
323
|
+
* The server cannot or will not process the request due to an apparent client error
|
|
324
|
+
* (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
|
|
325
|
+
*/
|
|
326
|
+
BAD_REQUEST = 400,
|
|
327
|
+
/**
|
|
328
|
+
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
|
|
329
|
+
* been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
|
|
330
|
+
* requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
|
|
331
|
+
* "unauthenticated",i.e. the user does not have the necessary credentials.
|
|
332
|
+
*/
|
|
333
|
+
UNAUTHORIZED = 401,
|
|
334
|
+
/**
|
|
335
|
+
* Reserved for future use. The original intention was that this code might be used as part of some form of digital
|
|
336
|
+
* cash or micro payment scheme, but that has not happened, and this code is not usually used.
|
|
337
|
+
* Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
|
|
338
|
+
*/
|
|
339
|
+
PAYMENT_REQUIRED = 402,
|
|
340
|
+
/**
|
|
341
|
+
* The request was valid, but the server is refusing action.
|
|
342
|
+
* The user might not have the necessary permissions for a resource.
|
|
343
|
+
*/
|
|
344
|
+
FORBIDDEN = 403,
|
|
345
|
+
/**
|
|
346
|
+
* The requested resource could not be found but may be available in the future.
|
|
347
|
+
* Subsequent requests by the client are permissible.
|
|
348
|
+
*/
|
|
349
|
+
NOT_FOUND = 404,
|
|
350
|
+
/**
|
|
351
|
+
* A request method is not supported for the requested resource;
|
|
352
|
+
* for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
|
|
353
|
+
*/
|
|
354
|
+
METHOD_NOT_ALLOWED = 405,
|
|
355
|
+
/**
|
|
356
|
+
* The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
|
|
357
|
+
*/
|
|
358
|
+
NOT_ACCEPTABLE = 406,
|
|
359
|
+
/**
|
|
360
|
+
* The client must first authenticate itself with the proxy.
|
|
361
|
+
*/
|
|
362
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
363
|
+
/**
|
|
364
|
+
* The server timed out waiting for the request.
|
|
365
|
+
* According to HTTP specifications:
|
|
366
|
+
* "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
|
|
367
|
+
*/
|
|
368
|
+
REQUEST_TIMEOUT = 408,
|
|
369
|
+
/**
|
|
370
|
+
* Indicates that the request could not be processed because of conflict in the request,
|
|
371
|
+
* such as an edit conflict between multiple simultaneous updates.
|
|
372
|
+
*/
|
|
373
|
+
CONFLICT = 409,
|
|
374
|
+
/**
|
|
375
|
+
* Indicates that the resource requested is no longer available and will not be available again.
|
|
376
|
+
* This should be used when a resource has been intentionally removed and the resource should be purged.
|
|
377
|
+
* Upon receiving a 410 status code, the client should not request the resource in the future.
|
|
378
|
+
* Clients such as search engines should remove the resource from their indices.
|
|
379
|
+
* Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
|
|
380
|
+
*/
|
|
381
|
+
GONE = 410,
|
|
382
|
+
/**
|
|
383
|
+
* The request did not specify the length of its content, which is required by the requested resource.
|
|
384
|
+
*/
|
|
385
|
+
LENGTH_REQUIRED = 411,
|
|
386
|
+
/**
|
|
387
|
+
* The server does not meet one of the preconditions that the requester put on the request.
|
|
388
|
+
*/
|
|
389
|
+
PRECONDITION_FAILED = 412,
|
|
390
|
+
/**
|
|
391
|
+
* The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
|
|
392
|
+
*/
|
|
393
|
+
CONTENT_TOO_LARGE = 413,
|
|
394
|
+
/* Excluded from this release type: PAYLOAD_TOO_LARGE */
|
|
395
|
+
/**
|
|
396
|
+
* The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,
|
|
397
|
+
* in which case it should be converted to a POST request.
|
|
398
|
+
* Called "Request-URI Too Long" previously.
|
|
399
|
+
*/
|
|
400
|
+
URI_TOO_LONG = 414,
|
|
401
|
+
/**
|
|
402
|
+
* The request entity has a media type which the server or resource does not support.
|
|
403
|
+
* For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
|
|
404
|
+
*/
|
|
405
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
406
|
+
/**
|
|
407
|
+
* The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
|
|
408
|
+
* For example, if the client asked for a part of the file that lies beyond the end of the file.
|
|
409
|
+
* Called "Requested Range Not Satisfiable" previously.
|
|
410
|
+
*/
|
|
411
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
412
|
+
/**
|
|
413
|
+
* The server cannot meet the requirements of the Expect request-header field.
|
|
414
|
+
*/
|
|
415
|
+
EXPECTATION_FAILED = 417,
|
|
416
|
+
/**
|
|
417
|
+
* This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,
|
|
418
|
+
* and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
|
|
419
|
+
* teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
|
|
420
|
+
*/
|
|
421
|
+
I_AM_A_TEAPOT = 418,
|
|
422
|
+
/**
|
|
423
|
+
* The request was directed at a server that is not able to produce a response (for example because a connection reuse).
|
|
424
|
+
*/
|
|
425
|
+
MISDIRECTED_REQUEST = 421,
|
|
426
|
+
/* Excluded from this release type: UNPROCESSABLE_ENTITY */
|
|
427
|
+
/**
|
|
428
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
429
|
+
*/
|
|
430
|
+
UNPROCESSABLE_CONTENT = 422,
|
|
431
|
+
/**
|
|
432
|
+
* The resource that is being accessed is locked.
|
|
433
|
+
*/
|
|
434
|
+
LOCKED = 423,
|
|
435
|
+
/**
|
|
436
|
+
* The request failed due to failure of a previous request (e.g., a PROPPATCH).
|
|
437
|
+
*/
|
|
438
|
+
FAILED_DEPENDENCY = 424,
|
|
439
|
+
/**
|
|
440
|
+
* The server is unwilling to risk processing a request that might be
|
|
441
|
+
* replayed, which creates the potential for a replay attack.
|
|
442
|
+
*/
|
|
443
|
+
TOO_EARLY = 425,
|
|
444
|
+
/**
|
|
445
|
+
* The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
|
|
446
|
+
*/
|
|
447
|
+
UPGRADE_REQUIRED = 426,
|
|
448
|
+
/**
|
|
449
|
+
* The origin server requires the request to be conditional.
|
|
450
|
+
* Intended to prevent "the 'lost update' problem, where a client
|
|
451
|
+
* GETs a resource's state, modifies it, and PUTs it back to the server,
|
|
452
|
+
* when meanwhile a third party has modified the state on the server, leading to a conflict."
|
|
453
|
+
*/
|
|
454
|
+
PRECONDITION_REQUIRED = 428,
|
|
455
|
+
/**
|
|
456
|
+
* The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
|
|
457
|
+
*/
|
|
458
|
+
TOO_MANY_REQUESTS = 429,
|
|
459
|
+
/**
|
|
460
|
+
* The server is unwilling to process the request because either an individual header field,
|
|
461
|
+
* or all the header fields collectively, are too large.
|
|
462
|
+
*/
|
|
463
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
464
|
+
/**
|
|
465
|
+
* A server operator has received a legal demand to deny access to a resource or to a set of resources
|
|
466
|
+
* that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
|
|
467
|
+
*/
|
|
468
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
469
|
+
/**
|
|
470
|
+
* A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
|
|
471
|
+
*/
|
|
472
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
473
|
+
/**
|
|
474
|
+
* The server either does not recognize the request method, or it lacks the ability to fulfill the request.
|
|
475
|
+
* Usually this implies future availability (e.g., a new feature of a web-service API).
|
|
476
|
+
*/
|
|
477
|
+
NOT_IMPLEMENTED = 501,
|
|
478
|
+
/**
|
|
479
|
+
* The server was acting as a gateway or proxy and received an invalid response from the upstream server.
|
|
480
|
+
*/
|
|
481
|
+
BAD_GATEWAY = 502,
|
|
482
|
+
/**
|
|
483
|
+
* The server is currently unavailable (because it is overloaded or down for maintenance).
|
|
484
|
+
* Generally, this is a temporary state.
|
|
485
|
+
*/
|
|
486
|
+
SERVICE_UNAVAILABLE = 503,
|
|
487
|
+
/**
|
|
488
|
+
* The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
|
|
489
|
+
*/
|
|
490
|
+
GATEWAY_TIMEOUT = 504,
|
|
491
|
+
/**
|
|
492
|
+
* The server does not support the HTTP protocol version used in the request
|
|
493
|
+
*/
|
|
494
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
495
|
+
/**
|
|
496
|
+
* Transparent content negotiation for the request results in a circular reference.
|
|
497
|
+
*/
|
|
498
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
499
|
+
/**
|
|
500
|
+
* The server is unable to store the representation needed to complete the request.
|
|
501
|
+
*/
|
|
502
|
+
INSUFFICIENT_STORAGE = 507,
|
|
503
|
+
/**
|
|
504
|
+
* The server detected an infinite loop while processing the request.
|
|
505
|
+
*/
|
|
506
|
+
LOOP_DETECTED = 508,
|
|
507
|
+
/**
|
|
508
|
+
* Further extensions to the request are required for the server to fulfill it.
|
|
509
|
+
*/
|
|
510
|
+
NOT_EXTENDED = 510,
|
|
511
|
+
/**
|
|
512
|
+
* The client needs to authenticate to gain network access.
|
|
513
|
+
* Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
|
|
514
|
+
* to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
|
|
515
|
+
*/
|
|
516
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
declare type HttpStatusCodeRangeDefinition =
|
|
520
|
+
| "1XX"
|
|
521
|
+
| "2XX"
|
|
522
|
+
| "3XX"
|
|
523
|
+
| "4XX"
|
|
524
|
+
| "5XX";
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* A function-based inbound policy that can modify the incoming HTTP request.
|
|
528
|
+
* This is the simplest way to create custom policies without extending a class.
|
|
529
|
+
*
|
|
530
|
+
* @param request - The incoming Request
|
|
531
|
+
* @param context - The current context of the Request
|
|
532
|
+
* @param options - The configuration options for the policy
|
|
533
|
+
* @param policyName - The name set on the policy in the configuration
|
|
534
|
+
* @returns A Response to short-circuit or a Request to continue
|
|
535
|
+
*
|
|
536
|
+
* @public
|
|
537
|
+
* @example
|
|
538
|
+
* ```typescript
|
|
539
|
+
* import { InboundPolicyHandler } from "@zuplo/runtime";
|
|
540
|
+
*
|
|
541
|
+
* interface RateLimitOptions {
|
|
542
|
+
* requests: number;
|
|
543
|
+
* windowMs: number;
|
|
544
|
+
* }
|
|
545
|
+
*
|
|
546
|
+
* export const rateLimitPolicy: InboundPolicyHandler<RateLimitOptions> = async (
|
|
547
|
+
* request,
|
|
548
|
+
* context,
|
|
549
|
+
* options,
|
|
550
|
+
* policyName
|
|
551
|
+
* ) => {
|
|
552
|
+
* const key = request.headers.get("x-api-key") || "anonymous";
|
|
553
|
+
* const count = await incrementCounter(key, options.windowMs);
|
|
554
|
+
*
|
|
555
|
+
* if (count > options.requests) {
|
|
556
|
+
* return new Response("Too Many Requests", { status: 429 });
|
|
557
|
+
* }
|
|
558
|
+
*
|
|
559
|
+
* // Add rate limit headers
|
|
560
|
+
* request.headers.set("X-RateLimit-Limit", options.requests.toString());
|
|
561
|
+
* request.headers.set("X-RateLimit-Remaining", (options.requests - count).toString());
|
|
562
|
+
*
|
|
563
|
+
* return request;
|
|
564
|
+
* };
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
declare interface InboundPolicyHandler<TOptions = any> {
|
|
568
|
+
(
|
|
569
|
+
request: ZuploRequest,
|
|
570
|
+
context: ZuploContext,
|
|
571
|
+
options: TOptions,
|
|
572
|
+
policyName: string
|
|
573
|
+
): Promise<ZuploRequest | Response>;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
declare interface IncomingRequestProperties {
|
|
580
|
+
/**
|
|
581
|
+
* ASN of the incoming request, for example, 395747.
|
|
582
|
+
*/
|
|
583
|
+
readonly asn: number | undefined;
|
|
584
|
+
/**
|
|
585
|
+
* The organization which owns the ASN of the incoming request,
|
|
586
|
+
* for example, Google Cloud.
|
|
587
|
+
*/
|
|
588
|
+
readonly asOrganization: string | undefined;
|
|
589
|
+
/**
|
|
590
|
+
* City of the incoming request, for example, "Austin".
|
|
591
|
+
*/
|
|
592
|
+
readonly city: string | undefined;
|
|
593
|
+
/**
|
|
594
|
+
* Continent of the incoming request, for example, "NA".
|
|
595
|
+
*/
|
|
596
|
+
readonly continent: ContinentCode | undefined;
|
|
597
|
+
/**
|
|
598
|
+
* The two-letter country code in the request.
|
|
599
|
+
* @see {@link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2|ISO 3166-1 alpha-2}
|
|
600
|
+
*/
|
|
601
|
+
readonly country: Iso3166Alpha2Code | undefined;
|
|
602
|
+
/**
|
|
603
|
+
* Latitude of the incoming request, for example, "30.27130".
|
|
604
|
+
*/
|
|
605
|
+
readonly latitude: string | undefined;
|
|
606
|
+
/**
|
|
607
|
+
* Longitude of the incoming request, for example, "-97.74260".
|
|
608
|
+
*/
|
|
609
|
+
readonly longitude: string | undefined;
|
|
610
|
+
/**
|
|
611
|
+
* The three-letter IATA airport code of the data center that the request hit,
|
|
612
|
+
* for example, "DFW".
|
|
613
|
+
* @see {@link https://en.wikipedia.org/wiki/IATA_airport_code|IATA airport code}
|
|
614
|
+
*/
|
|
615
|
+
readonly colo: string | undefined;
|
|
616
|
+
/**
|
|
617
|
+
* Postal code of the incoming request, for example, "78701".
|
|
618
|
+
*/
|
|
619
|
+
readonly postalCode: string | undefined;
|
|
620
|
+
/**
|
|
621
|
+
* Metro code (DMA) of the incoming request, for example, "635".
|
|
622
|
+
*/
|
|
623
|
+
readonly metroCode: string | undefined;
|
|
624
|
+
/**
|
|
625
|
+
* If known, the ISO 3166-2 name for the first level region associated with
|
|
626
|
+
* the IP address of the incoming request, for example, "Texas".
|
|
627
|
+
* @see {@link https://en.wikipedia.org/wiki/ISO_3166-2|ISO 3166-2}
|
|
628
|
+
*/
|
|
629
|
+
readonly region: string | undefined;
|
|
630
|
+
/**
|
|
631
|
+
* If known, the ISO 3166-2 code for the first-level region associated with
|
|
632
|
+
* the IP address of the incoming request, for example, "TX".
|
|
633
|
+
* @see {@link https://en.wikipedia.org/wiki/ISO_3166-2|ISO 3166-2}
|
|
634
|
+
*/
|
|
635
|
+
readonly regionCode: string | undefined;
|
|
636
|
+
/**
|
|
637
|
+
* Timezone of the incoming request, for example, "America/Chicago".
|
|
638
|
+
*/
|
|
639
|
+
readonly timezone: string | undefined;
|
|
640
|
+
/**
|
|
641
|
+
* If available, the HTTP protocol of the incoming request, for example, "HTTP/1.1".
|
|
642
|
+
*/
|
|
643
|
+
readonly httpProtocol: string | undefined;
|
|
644
|
+
/* Excluded from this release type: clientCert */
|
|
645
|
+
/* Excluded from this release type: clientMtlsVerificationStatus */
|
|
646
|
+
/* Excluded from this release type: clientMtlsVerificationReason */
|
|
647
|
+
/* Excluded from this release type: clientCertFingerprintSha256 */
|
|
648
|
+
/* Excluded from this release type: clientCertNotBefore */
|
|
649
|
+
/* Excluded from this release type: clientCertNotAfter */
|
|
650
|
+
/* Excluded from this release type: clientCertIssuerDn */
|
|
651
|
+
/* Excluded from this release type: clientCertSubjectDn */
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* ISO 3166-1 Alpha-2 codes
|
|
656
|
+
* @public
|
|
657
|
+
*/
|
|
658
|
+
declare type Iso3166Alpha2Code =
|
|
659
|
+
| "AD"
|
|
660
|
+
| "AE"
|
|
661
|
+
| "AF"
|
|
662
|
+
| "AG"
|
|
663
|
+
| "AI"
|
|
664
|
+
| "AL"
|
|
665
|
+
| "AM"
|
|
666
|
+
| "AO"
|
|
667
|
+
| "AQ"
|
|
668
|
+
| "AR"
|
|
669
|
+
| "AS"
|
|
670
|
+
| "AT"
|
|
671
|
+
| "AU"
|
|
672
|
+
| "AW"
|
|
673
|
+
| "AX"
|
|
674
|
+
| "AZ"
|
|
675
|
+
| "BA"
|
|
676
|
+
| "BB"
|
|
677
|
+
| "BD"
|
|
678
|
+
| "BE"
|
|
679
|
+
| "BF"
|
|
680
|
+
| "BG"
|
|
681
|
+
| "BH"
|
|
682
|
+
| "BI"
|
|
683
|
+
| "BJ"
|
|
684
|
+
| "BL"
|
|
685
|
+
| "BM"
|
|
686
|
+
| "BN"
|
|
687
|
+
| "BO"
|
|
688
|
+
| "BQ"
|
|
689
|
+
| "BR"
|
|
690
|
+
| "BS"
|
|
691
|
+
| "BT"
|
|
692
|
+
| "BV"
|
|
693
|
+
| "BW"
|
|
694
|
+
| "BY"
|
|
695
|
+
| "BZ"
|
|
696
|
+
| "CA"
|
|
697
|
+
| "CC"
|
|
698
|
+
| "CD"
|
|
699
|
+
| "CF"
|
|
700
|
+
| "CG"
|
|
701
|
+
| "CH"
|
|
702
|
+
| "CI"
|
|
703
|
+
| "CK"
|
|
704
|
+
| "CL"
|
|
705
|
+
| "CM"
|
|
706
|
+
| "CN"
|
|
707
|
+
| "CO"
|
|
708
|
+
| "CR"
|
|
709
|
+
| "CU"
|
|
710
|
+
| "CV"
|
|
711
|
+
| "CW"
|
|
712
|
+
| "CX"
|
|
713
|
+
| "CY"
|
|
714
|
+
| "CZ"
|
|
715
|
+
| "DE"
|
|
716
|
+
| "DJ"
|
|
717
|
+
| "DK"
|
|
718
|
+
| "DM"
|
|
719
|
+
| "DO"
|
|
720
|
+
| "DZ"
|
|
721
|
+
| "EC"
|
|
722
|
+
| "EE"
|
|
723
|
+
| "EG"
|
|
724
|
+
| "EH"
|
|
725
|
+
| "ER"
|
|
726
|
+
| "ES"
|
|
727
|
+
| "ET"
|
|
728
|
+
| "FI"
|
|
729
|
+
| "FJ"
|
|
730
|
+
| "FK"
|
|
731
|
+
| "FM"
|
|
732
|
+
| "FO"
|
|
733
|
+
| "FR"
|
|
734
|
+
| "GA"
|
|
735
|
+
| "GB"
|
|
736
|
+
| "GD"
|
|
737
|
+
| "GE"
|
|
738
|
+
| "GF"
|
|
739
|
+
| "GG"
|
|
740
|
+
| "GH"
|
|
741
|
+
| "GI"
|
|
742
|
+
| "GL"
|
|
743
|
+
| "GM"
|
|
744
|
+
| "GN"
|
|
745
|
+
| "GP"
|
|
746
|
+
| "GQ"
|
|
747
|
+
| "GR"
|
|
748
|
+
| "GS"
|
|
749
|
+
| "GT"
|
|
750
|
+
| "GU"
|
|
751
|
+
| "GW"
|
|
752
|
+
| "GY"
|
|
753
|
+
| "HK"
|
|
754
|
+
| "HM"
|
|
755
|
+
| "HN"
|
|
756
|
+
| "HR"
|
|
757
|
+
| "HT"
|
|
758
|
+
| "HU"
|
|
759
|
+
| "ID"
|
|
760
|
+
| "IE"
|
|
761
|
+
| "IL"
|
|
762
|
+
| "IM"
|
|
763
|
+
| "IN"
|
|
764
|
+
| "IO"
|
|
765
|
+
| "IQ"
|
|
766
|
+
| "IR"
|
|
767
|
+
| "IS"
|
|
768
|
+
| "IT"
|
|
769
|
+
| "JE"
|
|
770
|
+
| "JM"
|
|
771
|
+
| "JO"
|
|
772
|
+
| "JP"
|
|
773
|
+
| "KE"
|
|
774
|
+
| "KG"
|
|
775
|
+
| "KH"
|
|
776
|
+
| "KI"
|
|
777
|
+
| "KM"
|
|
778
|
+
| "KN"
|
|
779
|
+
| "KP"
|
|
780
|
+
| "KR"
|
|
781
|
+
| "KW"
|
|
782
|
+
| "KY"
|
|
783
|
+
| "KZ"
|
|
784
|
+
| "LA"
|
|
785
|
+
| "LB"
|
|
786
|
+
| "LC"
|
|
787
|
+
| "LI"
|
|
788
|
+
| "LK"
|
|
789
|
+
| "LR"
|
|
790
|
+
| "LS"
|
|
791
|
+
| "LT"
|
|
792
|
+
| "LU"
|
|
793
|
+
| "LV"
|
|
794
|
+
| "LY"
|
|
795
|
+
| "MA"
|
|
796
|
+
| "MC"
|
|
797
|
+
| "MD"
|
|
798
|
+
| "ME"
|
|
799
|
+
| "MF"
|
|
800
|
+
| "MG"
|
|
801
|
+
| "MH"
|
|
802
|
+
| "MK"
|
|
803
|
+
| "ML"
|
|
804
|
+
| "MM"
|
|
805
|
+
| "MN"
|
|
806
|
+
| "MO"
|
|
807
|
+
| "MP"
|
|
808
|
+
| "MQ"
|
|
809
|
+
| "MR"
|
|
810
|
+
| "MS"
|
|
811
|
+
| "MT"
|
|
812
|
+
| "MU"
|
|
813
|
+
| "MV"
|
|
814
|
+
| "MW"
|
|
815
|
+
| "MX"
|
|
816
|
+
| "MY"
|
|
817
|
+
| "MZ"
|
|
818
|
+
| "NA"
|
|
819
|
+
| "NC"
|
|
820
|
+
| "NE"
|
|
821
|
+
| "NF"
|
|
822
|
+
| "NG"
|
|
823
|
+
| "NI"
|
|
824
|
+
| "NL"
|
|
825
|
+
| "NO"
|
|
826
|
+
| "NP"
|
|
827
|
+
| "NR"
|
|
828
|
+
| "NU"
|
|
829
|
+
| "NZ"
|
|
830
|
+
| "OM"
|
|
831
|
+
| "PA"
|
|
832
|
+
| "PE"
|
|
833
|
+
| "PF"
|
|
834
|
+
| "PG"
|
|
835
|
+
| "PH"
|
|
836
|
+
| "PK"
|
|
837
|
+
| "PL"
|
|
838
|
+
| "PM"
|
|
839
|
+
| "PN"
|
|
840
|
+
| "PR"
|
|
841
|
+
| "PS"
|
|
842
|
+
| "PT"
|
|
843
|
+
| "PW"
|
|
844
|
+
| "PY"
|
|
845
|
+
| "QA"
|
|
846
|
+
| "RE"
|
|
847
|
+
| "RO"
|
|
848
|
+
| "RS"
|
|
849
|
+
| "RU"
|
|
850
|
+
| "RW"
|
|
851
|
+
| "SA"
|
|
852
|
+
| "SB"
|
|
853
|
+
| "SC"
|
|
854
|
+
| "SD"
|
|
855
|
+
| "SE"
|
|
856
|
+
| "SG"
|
|
857
|
+
| "SH"
|
|
858
|
+
| "SI"
|
|
859
|
+
| "SJ"
|
|
860
|
+
| "SK"
|
|
861
|
+
| "SL"
|
|
862
|
+
| "SM"
|
|
863
|
+
| "SN"
|
|
864
|
+
| "SO"
|
|
865
|
+
| "SR"
|
|
866
|
+
| "SS"
|
|
867
|
+
| "ST"
|
|
868
|
+
| "SV"
|
|
869
|
+
| "SX"
|
|
870
|
+
| "SY"
|
|
871
|
+
| "SZ"
|
|
872
|
+
| "TC"
|
|
873
|
+
| "TD"
|
|
874
|
+
| "TF"
|
|
875
|
+
| "TG"
|
|
876
|
+
| "TH"
|
|
877
|
+
| "TJ"
|
|
878
|
+
| "TK"
|
|
879
|
+
| "TL"
|
|
880
|
+
| "TM"
|
|
881
|
+
| "TN"
|
|
882
|
+
| "TO"
|
|
883
|
+
| "TR"
|
|
884
|
+
| "TT"
|
|
885
|
+
| "TV"
|
|
886
|
+
| "TW"
|
|
887
|
+
| "TZ"
|
|
888
|
+
| "UA"
|
|
889
|
+
| "UG"
|
|
890
|
+
| "UM"
|
|
891
|
+
| "US"
|
|
892
|
+
| "UY"
|
|
893
|
+
| "UZ"
|
|
894
|
+
| "VA"
|
|
895
|
+
| "VC"
|
|
896
|
+
| "VE"
|
|
897
|
+
| "VG"
|
|
898
|
+
| "VI"
|
|
899
|
+
| "VN"
|
|
900
|
+
| "VU"
|
|
901
|
+
| "WF"
|
|
902
|
+
| "WS"
|
|
903
|
+
| "YE"
|
|
904
|
+
| "YT"
|
|
905
|
+
| "ZA"
|
|
906
|
+
| "ZM"
|
|
907
|
+
| "ZW";
|
|
908
|
+
|
|
909
|
+
declare type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
Matches a JSON object.
|
|
913
|
+
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
914
|
+
*/
|
|
915
|
+
declare type JsonObject = {
|
|
916
|
+
[Key in string]: JsonValue;
|
|
917
|
+
} & {
|
|
918
|
+
[Key in string]?: JsonValue | undefined;
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
declare type JsonPrimitive = string | number | boolean | null;
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
Matches any valid JSON value.
|
|
925
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
926
|
+
*/
|
|
927
|
+
declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Logger to be used in the runtime via context.log.
|
|
931
|
+
* You can set per-request properties that will be included in all log entries for this request.
|
|
932
|
+
* @beta
|
|
933
|
+
*/
|
|
934
|
+
declare interface Logger extends BaseLogger {
|
|
935
|
+
/**
|
|
936
|
+
* Set properties that will be included in all subsequent log entries for this request.
|
|
937
|
+
* Properties are merged with existing properties and any static fields configured in the logging plugin.
|
|
938
|
+
* Per-request properties take precedence over static fields with the same name.
|
|
939
|
+
*
|
|
940
|
+
* @param properties - Key-value pairs to include in log entries. Values must be string, number, or boolean.
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```ts
|
|
944
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
945
|
+
* // Set properties that will be included in all logs for this request
|
|
946
|
+
* context.log.setLogProperties({ http_status_code: 400, user_id: "123" });
|
|
947
|
+
*
|
|
948
|
+
* context.log.error("Request failed"); // Will include http_status_code and user_id
|
|
949
|
+
*
|
|
950
|
+
* return new Response("Error", { status: 400 });
|
|
951
|
+
* }
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
setLogProperties?(
|
|
955
|
+
properties: Record<string, string | number | boolean>
|
|
956
|
+
): void;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Any request-type message (known or unknown method).
|
|
961
|
+
*
|
|
962
|
+
* @beta
|
|
963
|
+
*/
|
|
964
|
+
export declare type McpAnyRequestMessage =
|
|
965
|
+
| McpKnownRequestMessage
|
|
966
|
+
| McpUnknownRequestMessage;
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Params for `notifications/cancelled`.
|
|
970
|
+
*
|
|
971
|
+
* @beta
|
|
972
|
+
*/
|
|
973
|
+
export declare interface McpCancelledParams extends McpParams {
|
|
974
|
+
readonly requestId?: string | number;
|
|
975
|
+
readonly reason?: string;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* A client→server JSON-RPC error — the client answering a server-initiated
|
|
980
|
+
* request with an error. Always forwarded untouched by `processMessages`.
|
|
981
|
+
*
|
|
982
|
+
* @beta
|
|
983
|
+
*/
|
|
984
|
+
export declare interface McpClientErrorMessage {
|
|
985
|
+
readonly type: "error";
|
|
986
|
+
readonly method?: never;
|
|
987
|
+
readonly id: McpRequestId | null;
|
|
988
|
+
readonly error: McpErrorDetail;
|
|
989
|
+
readonly params?: never;
|
|
990
|
+
readonly raw: unknown;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* A client→server JSON-RPC result — the client answering a server-initiated
|
|
995
|
+
* request (for example a sampling or elicitation round-trip). These are
|
|
996
|
+
* always forwarded untouched by `processMessages`.
|
|
997
|
+
*
|
|
998
|
+
* @beta
|
|
999
|
+
*/
|
|
1000
|
+
export declare interface McpClientResultMessage {
|
|
1001
|
+
readonly type: "result";
|
|
1002
|
+
readonly method?: never;
|
|
1003
|
+
readonly id: McpRequestId;
|
|
1004
|
+
readonly result: McpResult;
|
|
1005
|
+
readonly params?: never;
|
|
1006
|
+
readonly raw: unknown;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Params for `completion/complete`.
|
|
1011
|
+
*
|
|
1012
|
+
* @beta
|
|
1013
|
+
*/
|
|
1014
|
+
export declare interface McpCompleteParams extends McpParams {
|
|
1015
|
+
readonly ref?: {
|
|
1016
|
+
readonly type?: string;
|
|
1017
|
+
readonly name?: string;
|
|
1018
|
+
readonly uri?: string;
|
|
1019
|
+
readonly [key: string]: unknown;
|
|
1020
|
+
};
|
|
1021
|
+
readonly argument?: {
|
|
1022
|
+
readonly name?: string;
|
|
1023
|
+
readonly value?: string;
|
|
1024
|
+
readonly [key: string]: unknown;
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* A parsed view of an MCP HTTP request body.
|
|
1030
|
+
*
|
|
1031
|
+
* @beta
|
|
1032
|
+
*/
|
|
1033
|
+
export declare interface McpEnvelope {
|
|
1034
|
+
/** Only JSON bodies are parsed today. */
|
|
1035
|
+
readonly transport: "json";
|
|
1036
|
+
/**
|
|
1037
|
+
* Whether the wire body was a single message or a JSON-RPC batch array.
|
|
1038
|
+
* The runtime preserves this shape when it rewrites the upstream request —
|
|
1039
|
+
* a batch stays a batch, even with one surviving message.
|
|
1040
|
+
*/
|
|
1041
|
+
readonly shape: "single" | "batch";
|
|
1042
|
+
/** The messages in wire order. A single body has exactly one entry. */
|
|
1043
|
+
readonly messages: readonly McpMessage[];
|
|
1044
|
+
/**
|
|
1045
|
+
* The MCP protocol version the client declared on the HTTP request
|
|
1046
|
+
* (`MCP-Protocol-Version` header), when present. The runtime never infers
|
|
1047
|
+
* a version from message shapes.
|
|
1048
|
+
*/
|
|
1049
|
+
readonly protocolVersion?: string;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* A JSON-RPC error object.
|
|
1054
|
+
*
|
|
1055
|
+
* @beta
|
|
1056
|
+
*/
|
|
1057
|
+
export declare interface McpErrorDetail {
|
|
1058
|
+
readonly code: number;
|
|
1059
|
+
readonly message: string;
|
|
1060
|
+
readonly data?: unknown;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* A message that reaches `processMessages` handlers. Invalid members never
|
|
1065
|
+
* do — the runtime answers them automatically — and client-supplied JSON-RPC
|
|
1066
|
+
* results/errors are always forwarded untouched.
|
|
1067
|
+
*
|
|
1068
|
+
* @beta
|
|
1069
|
+
*/
|
|
1070
|
+
export declare type McpHandlerMessage =
|
|
1071
|
+
| McpKnownRequestMessage
|
|
1072
|
+
| McpUnknownRequestMessage
|
|
1073
|
+
| McpKnownNotificationMessage
|
|
1074
|
+
| McpUnknownNotificationMessage;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Params for `initialize`. All fields are optional because the gateway
|
|
1078
|
+
* observes traffic rather than validating it against the full MCP schema.
|
|
1079
|
+
*
|
|
1080
|
+
* @beta
|
|
1081
|
+
*/
|
|
1082
|
+
export declare interface McpInitializeParams extends McpParams {
|
|
1083
|
+
readonly protocolVersion?: string;
|
|
1084
|
+
readonly capabilities?: Record<string, unknown>;
|
|
1085
|
+
readonly clientInfo?: {
|
|
1086
|
+
readonly name?: string;
|
|
1087
|
+
readonly title?: string;
|
|
1088
|
+
readonly version?: string;
|
|
1089
|
+
readonly [key: string]: unknown;
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* A body member that is not a usable JSON-RPC message: not an object, missing
|
|
1095
|
+
* `jsonrpc: "2.0"`, a request with a `null` (uncorrelatable) id, or a known
|
|
1096
|
+
* method whose required params are malformed. `error` is the JSON-RPC error
|
|
1097
|
+
* the runtime answers it with — `processMessages` does this automatically and
|
|
1098
|
+
* never dispatches invalid members to handlers.
|
|
1099
|
+
*
|
|
1100
|
+
* @beta
|
|
1101
|
+
*/
|
|
1102
|
+
export declare interface McpInvalidMessage {
|
|
1103
|
+
readonly type: "invalid";
|
|
1104
|
+
readonly method?: string;
|
|
1105
|
+
readonly id: McpRequestId | null;
|
|
1106
|
+
readonly error: McpErrorDetail;
|
|
1107
|
+
readonly params?: never;
|
|
1108
|
+
readonly raw: unknown;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* The union of all known notification messages.
|
|
1113
|
+
*
|
|
1114
|
+
* @beta
|
|
1115
|
+
*/
|
|
1116
|
+
export declare type McpKnownNotificationMessage = {
|
|
1117
|
+
[M in McpNotificationMethod]: McpNotificationMessage<M>;
|
|
1118
|
+
}[McpNotificationMethod];
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* The union of all known request messages, each with a literal `method`, so
|
|
1122
|
+
* `if`/`switch` on `message.method` narrows `params` to the right shape.
|
|
1123
|
+
*
|
|
1124
|
+
* @beta
|
|
1125
|
+
*/
|
|
1126
|
+
export declare type McpKnownRequestMessage = {
|
|
1127
|
+
[M in McpRequestMethod]: McpRequestMessage<M>;
|
|
1128
|
+
}[McpRequestMethod];
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Any message that can appear in a parsed MCP envelope. Narrow on `type`
|
|
1132
|
+
* first; within `"request"`/`"notification"`, narrowing on `method` gives
|
|
1133
|
+
* fully typed params for known methods.
|
|
1134
|
+
*
|
|
1135
|
+
* @beta
|
|
1136
|
+
*/
|
|
1137
|
+
export declare type McpMessage =
|
|
1138
|
+
| McpKnownRequestMessage
|
|
1139
|
+
| McpUnknownRequestMessage
|
|
1140
|
+
| McpKnownNotificationMessage
|
|
1141
|
+
| McpUnknownNotificationMessage
|
|
1142
|
+
| McpClientResultMessage
|
|
1143
|
+
| McpClientErrorMessage
|
|
1144
|
+
| McpInvalidMessage;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* The arguments passed to every `processMessages` handler: the parsed
|
|
1148
|
+
* message plus the ordinary Zuplo policy pipeline objects.
|
|
1149
|
+
*
|
|
1150
|
+
* @beta
|
|
1151
|
+
*/
|
|
1152
|
+
export declare interface McpMessageHandlerArgs<
|
|
1153
|
+
TMessage extends McpHandlerMessage = McpHandlerMessage,
|
|
1154
|
+
TOptions = unknown,
|
|
1155
|
+
> {
|
|
1156
|
+
readonly message: TMessage;
|
|
1157
|
+
readonly request: ZuploRequest;
|
|
1158
|
+
readonly context: ZuploContext;
|
|
1159
|
+
/** The full parsed envelope, for handlers that need batch siblings. */
|
|
1160
|
+
readonly envelope: McpEnvelope;
|
|
1161
|
+
readonly options: TOptions;
|
|
1162
|
+
readonly policyName: string;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* What a `processMessages` handler may return for a message:
|
|
1167
|
+
*
|
|
1168
|
+
* - `void` — the message continues unchanged.
|
|
1169
|
+
* - `{ params }` — the message is forwarded with replaced params.
|
|
1170
|
+
* - `{ error }` — the message is answered locally with a JSON-RPC error
|
|
1171
|
+
* (a blocked notification is dropped silently instead — notifications
|
|
1172
|
+
* have no replies).
|
|
1173
|
+
* - `{ result }` — the message is answered locally with a result.
|
|
1174
|
+
*
|
|
1175
|
+
* Raw HTTP `Response` values are deliberately not verdicts: mixing
|
|
1176
|
+
* HTTP-level and message-level outcomes inside a batch is ambiguous. To
|
|
1177
|
+
* gate a whole exchange, use `getRequest` + `createErrorResponse` directly.
|
|
1178
|
+
*
|
|
1179
|
+
* @beta
|
|
1180
|
+
*/
|
|
1181
|
+
export declare type McpMessageVerdict =
|
|
1182
|
+
| void
|
|
1183
|
+
| undefined
|
|
1184
|
+
| {
|
|
1185
|
+
readonly params: Record<string, unknown>;
|
|
1186
|
+
}
|
|
1187
|
+
| {
|
|
1188
|
+
readonly error: McpErrorDetail;
|
|
1189
|
+
}
|
|
1190
|
+
| {
|
|
1191
|
+
readonly result: McpResult;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* A typed MCP notification (a client→server message with no reply).
|
|
1196
|
+
*
|
|
1197
|
+
* @beta
|
|
1198
|
+
*/
|
|
1199
|
+
export declare interface McpNotificationMessage<
|
|
1200
|
+
TMethod extends McpNotificationMethod = McpNotificationMethod,
|
|
1201
|
+
> {
|
|
1202
|
+
readonly type: "notification";
|
|
1203
|
+
readonly method: TMethod;
|
|
1204
|
+
readonly id?: never;
|
|
1205
|
+
readonly params: McpNotificationParamsMap[TMethod];
|
|
1206
|
+
readonly raw: unknown;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* A known client→server notification method.
|
|
1211
|
+
*
|
|
1212
|
+
* @beta
|
|
1213
|
+
*/
|
|
1214
|
+
export declare type McpNotificationMethod = keyof McpNotificationParamsMap;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* The client→server notification methods this module types explicitly.
|
|
1218
|
+
*
|
|
1219
|
+
* @beta
|
|
1220
|
+
*/
|
|
1221
|
+
export declare interface McpNotificationParamsMap {
|
|
1222
|
+
readonly "notifications/initialized": McpParams;
|
|
1223
|
+
readonly "notifications/cancelled": McpCancelledParams;
|
|
1224
|
+
readonly "notifications/progress": McpProgressParams;
|
|
1225
|
+
readonly "notifications/roots/list_changed": McpParams;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Params for paginated list requests (`tools/list`, `prompts/list`, ...).
|
|
1230
|
+
*
|
|
1231
|
+
* @beta
|
|
1232
|
+
*/
|
|
1233
|
+
export declare interface McpPaginatedParams extends McpParams {
|
|
1234
|
+
readonly cursor?: string;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Base shape for MCP request and notification params. Fields the MCP schema
|
|
1239
|
+
* defines are typed explicitly on each method's params interface; everything
|
|
1240
|
+
* else stays reachable through the index signature (and `message.raw`).
|
|
1241
|
+
*
|
|
1242
|
+
* @beta
|
|
1243
|
+
*/
|
|
1244
|
+
export declare interface McpParams {
|
|
1245
|
+
readonly _meta?: Record<string, unknown>;
|
|
1246
|
+
readonly [key: string]: unknown;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* Configuration for {@link processMessages}. `requests` handles the
|
|
1251
|
+
* client→server phase; response-phase handlers are a later addition.
|
|
1252
|
+
*
|
|
1253
|
+
* @beta
|
|
1254
|
+
*/
|
|
1255
|
+
export declare interface McpProcessMessagesConfig<TOptions = unknown> {
|
|
1256
|
+
readonly requests?: McpRequestHandlers<TOptions>;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Params for `notifications/progress`.
|
|
1261
|
+
*
|
|
1262
|
+
* @beta
|
|
1263
|
+
*/
|
|
1264
|
+
export declare interface McpProgressParams extends McpParams {
|
|
1265
|
+
readonly progressToken?: string | number;
|
|
1266
|
+
readonly progress?: number;
|
|
1267
|
+
readonly total?: number;
|
|
1268
|
+
readonly message?: string;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Params for `prompts/get`. `name` is guaranteed by the parser.
|
|
1273
|
+
*
|
|
1274
|
+
* @beta
|
|
1275
|
+
*/
|
|
1276
|
+
export declare interface McpPromptGetParams extends McpParams {
|
|
1277
|
+
readonly name: string;
|
|
1278
|
+
readonly arguments?: Record<string, unknown>;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* The per-method handler map for `processMessages`. Keys are MCP method
|
|
1283
|
+
* names; `"*"` matches any message without a more specific handler. Each
|
|
1284
|
+
* message runs at most one handler.
|
|
1285
|
+
*
|
|
1286
|
+
* @beta
|
|
1287
|
+
*/
|
|
1288
|
+
export declare type McpRequestHandlers<TOptions = unknown> = {
|
|
1289
|
+
readonly [M in McpRequestMethod]?: (
|
|
1290
|
+
args: McpMessageHandlerArgs<
|
|
1291
|
+
Extract<
|
|
1292
|
+
McpKnownRequestMessage,
|
|
1293
|
+
{
|
|
1294
|
+
method: M;
|
|
1295
|
+
}
|
|
1296
|
+
>,
|
|
1297
|
+
TOptions
|
|
1298
|
+
>
|
|
1299
|
+
) => HandlerResult;
|
|
1300
|
+
} & {
|
|
1301
|
+
readonly [M in McpNotificationMethod]?: (
|
|
1302
|
+
args: McpMessageHandlerArgs<
|
|
1303
|
+
Extract<
|
|
1304
|
+
McpKnownNotificationMessage,
|
|
1305
|
+
{
|
|
1306
|
+
method: M;
|
|
1307
|
+
}
|
|
1308
|
+
>,
|
|
1309
|
+
TOptions
|
|
1310
|
+
>
|
|
1311
|
+
) => HandlerResult;
|
|
1312
|
+
} & {
|
|
1313
|
+
readonly "*"?: (
|
|
1314
|
+
args: McpMessageHandlerArgs<McpHandlerMessage, TOptions>
|
|
1315
|
+
) => HandlerResult;
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Zuplo-owned wire model for MCP (Model Context Protocol) JSON-RPC messages.
|
|
1320
|
+
*
|
|
1321
|
+
* These types are structurally compatible with the official MCP schema, but
|
|
1322
|
+
* Zuplo owns the public surface so policy-author code does not track a third
|
|
1323
|
+
* party's release cadence. Every message keeps the untyped wire value on
|
|
1324
|
+
* `raw` as the escape hatch.
|
|
1325
|
+
*/
|
|
1326
|
+
/**
|
|
1327
|
+
* A correlatable JSON-RPC request id. JSON-RPC also permits `null`, but a
|
|
1328
|
+
* null id cannot be correlated to a reply, so the parser classifies null-id
|
|
1329
|
+
* requests as {@link McpInvalidMessage} members instead.
|
|
1330
|
+
*
|
|
1331
|
+
* @beta
|
|
1332
|
+
*/
|
|
1333
|
+
export declare type McpRequestId = string | number;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* A typed MCP request (a client→server message that expects a reply). For
|
|
1337
|
+
* known methods the parser normalizes absent params to `{}`, so `params` is
|
|
1338
|
+
* always an object.
|
|
1339
|
+
*
|
|
1340
|
+
* @beta
|
|
1341
|
+
*/
|
|
1342
|
+
export declare interface McpRequestMessage<
|
|
1343
|
+
TMethod extends McpRequestMethod = McpRequestMethod,
|
|
1344
|
+
> {
|
|
1345
|
+
readonly type: "request";
|
|
1346
|
+
readonly method: TMethod;
|
|
1347
|
+
readonly id: McpRequestId;
|
|
1348
|
+
readonly params: McpRequestParamsMap[TMethod];
|
|
1349
|
+
/** The untyped wire value of this message. */
|
|
1350
|
+
readonly raw: unknown;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* A known client→server request method.
|
|
1355
|
+
*
|
|
1356
|
+
* @beta
|
|
1357
|
+
*/
|
|
1358
|
+
export declare type McpRequestMethod = keyof McpRequestParamsMap;
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* The client→server request methods this module types explicitly, mapped to
|
|
1362
|
+
* their params shapes. Unknown or future methods still surface as requests
|
|
1363
|
+
* (with `method: string`); they are never dropped.
|
|
1364
|
+
*
|
|
1365
|
+
* @beta
|
|
1366
|
+
*/
|
|
1367
|
+
export declare interface McpRequestParamsMap {
|
|
1368
|
+
readonly initialize: McpInitializeParams;
|
|
1369
|
+
readonly ping: McpParams;
|
|
1370
|
+
readonly "tools/list": McpPaginatedParams;
|
|
1371
|
+
readonly "tools/call": McpToolCallParams;
|
|
1372
|
+
readonly "prompts/list": McpPaginatedParams;
|
|
1373
|
+
readonly "prompts/get": McpPromptGetParams;
|
|
1374
|
+
readonly "resources/list": McpPaginatedParams;
|
|
1375
|
+
readonly "resources/templates/list": McpPaginatedParams;
|
|
1376
|
+
readonly "resources/read": McpResourceParams;
|
|
1377
|
+
readonly "resources/subscribe": McpResourceParams;
|
|
1378
|
+
readonly "resources/unsubscribe": McpResourceParams;
|
|
1379
|
+
readonly "completion/complete": McpCompleteParams;
|
|
1380
|
+
readonly "logging/setLevel": McpSetLevelParams;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Params for resource requests that address a resource by URI. `uri` is
|
|
1385
|
+
* guaranteed by the parser.
|
|
1386
|
+
*
|
|
1387
|
+
* @beta
|
|
1388
|
+
*/
|
|
1389
|
+
export declare interface McpResourceParams extends McpParams {
|
|
1390
|
+
readonly uri: string;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* A JSON-RPC result object. MCP results are always JSON objects.
|
|
1395
|
+
*
|
|
1396
|
+
* @beta
|
|
1397
|
+
*/
|
|
1398
|
+
export declare type McpResult = Record<string, unknown>;
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Params for `logging/setLevel`. `level` is guaranteed by the parser.
|
|
1402
|
+
*
|
|
1403
|
+
* @beta
|
|
1404
|
+
*/
|
|
1405
|
+
export declare interface McpSetLevelParams extends McpParams {
|
|
1406
|
+
readonly level: string;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Params for `tools/call`. `name` is guaranteed: a `tools/call` request
|
|
1411
|
+
* without a string `name` is classified as an invalid member instead of a
|
|
1412
|
+
* typed request.
|
|
1413
|
+
*
|
|
1414
|
+
* @beta
|
|
1415
|
+
*/
|
|
1416
|
+
export declare interface McpToolCallParams extends McpParams {
|
|
1417
|
+
readonly name: string;
|
|
1418
|
+
readonly arguments?: Record<string, unknown>;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* A notification whose method this module does not type. Read the wire value
|
|
1423
|
+
* through `raw`.
|
|
1424
|
+
*
|
|
1425
|
+
* @beta
|
|
1426
|
+
*/
|
|
1427
|
+
export declare interface McpUnknownNotificationMessage {
|
|
1428
|
+
readonly type: "notification";
|
|
1429
|
+
readonly method: string;
|
|
1430
|
+
readonly id?: never;
|
|
1431
|
+
readonly params: never;
|
|
1432
|
+
readonly raw: unknown;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* A request whose method this module does not type. The parser guarantees an
|
|
1437
|
+
* unknown request never carries a method listed in {@link McpRequestParamsMap}
|
|
1438
|
+
* (a known method with malformed params becomes an invalid member instead) —
|
|
1439
|
+
* that guarantee is what makes narrowing on `message.method` sound. `params`
|
|
1440
|
+
* is deliberately not part of the typed surface; read the wire value through
|
|
1441
|
+
* `raw`.
|
|
1442
|
+
*
|
|
1443
|
+
* @beta
|
|
1444
|
+
*/
|
|
1445
|
+
export declare interface McpUnknownRequestMessage {
|
|
1446
|
+
readonly type: "request";
|
|
1447
|
+
readonly method: string;
|
|
1448
|
+
readonly id: McpRequestId;
|
|
1449
|
+
readonly params: never;
|
|
1450
|
+
readonly raw: unknown;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* @public
|
|
1457
|
+
*/
|
|
1458
|
+
declare interface OnResponseSendingFinalHook {
|
|
1459
|
+
(
|
|
1460
|
+
response: Response,
|
|
1461
|
+
request: ZuploRequest,
|
|
1462
|
+
context: ZuploContext
|
|
1463
|
+
): Promise<void> | void;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* @public
|
|
1468
|
+
*/
|
|
1469
|
+
declare interface OnResponseSendingHook {
|
|
1470
|
+
(
|
|
1471
|
+
response: Response,
|
|
1472
|
+
request: ZuploRequest,
|
|
1473
|
+
context: ZuploContext
|
|
1474
|
+
): Promise<Response> | Response;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
declare namespace OpenAPIV3 {
|
|
1478
|
+
interface Document<T extends {} = {}> {
|
|
1479
|
+
openapi: string;
|
|
1480
|
+
info: InfoObject;
|
|
1481
|
+
servers?: ServerObject[];
|
|
1482
|
+
paths: PathsObject<T>;
|
|
1483
|
+
components?: ComponentsObject;
|
|
1484
|
+
security?: SecurityRequirementObject[];
|
|
1485
|
+
tags?: TagObject[];
|
|
1486
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1487
|
+
"x-express-openapi-additional-middleware"?: (
|
|
1488
|
+
| ((request: any, response: any, next: any) => Promise<void>)
|
|
1489
|
+
| ((request: any, response: any, next: any) => void)
|
|
1490
|
+
)[];
|
|
1491
|
+
"x-express-openapi-validation-strict"?: boolean;
|
|
1492
|
+
}
|
|
1493
|
+
interface InfoObject {
|
|
1494
|
+
title: string;
|
|
1495
|
+
description?: string;
|
|
1496
|
+
termsOfService?: string;
|
|
1497
|
+
contact?: ContactObject;
|
|
1498
|
+
license?: LicenseObject;
|
|
1499
|
+
version: string;
|
|
1500
|
+
}
|
|
1501
|
+
interface ContactObject {
|
|
1502
|
+
name?: string;
|
|
1503
|
+
url?: string;
|
|
1504
|
+
email?: string;
|
|
1505
|
+
}
|
|
1506
|
+
interface LicenseObject {
|
|
1507
|
+
name: string;
|
|
1508
|
+
url?: string;
|
|
1509
|
+
}
|
|
1510
|
+
interface ServerObject {
|
|
1511
|
+
url: string;
|
|
1512
|
+
description?: string;
|
|
1513
|
+
variables?: {
|
|
1514
|
+
[variable: string]: ServerVariableObject;
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
interface ServerVariableObject {
|
|
1518
|
+
enum?: string[];
|
|
1519
|
+
default: string;
|
|
1520
|
+
description?: string;
|
|
1521
|
+
}
|
|
1522
|
+
interface PathsObject<T extends {} = {}, P extends {} = {}> {
|
|
1523
|
+
[pattern: string]: (PathItemObject<T> & P) | undefined;
|
|
1524
|
+
}
|
|
1525
|
+
enum HttpMethods {
|
|
1526
|
+
GET = "get",
|
|
1527
|
+
PUT = "put",
|
|
1528
|
+
POST = "post",
|
|
1529
|
+
DELETE = "delete",
|
|
1530
|
+
OPTIONS = "options",
|
|
1531
|
+
HEAD = "head",
|
|
1532
|
+
PATCH = "patch",
|
|
1533
|
+
TRACE = "trace",
|
|
1534
|
+
}
|
|
1535
|
+
type PathItemObject<T extends {} = {}> = {
|
|
1536
|
+
$ref?: string;
|
|
1537
|
+
summary?: string;
|
|
1538
|
+
description?: string;
|
|
1539
|
+
servers?: ServerObject[];
|
|
1540
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
1541
|
+
} & {
|
|
1542
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
1543
|
+
};
|
|
1544
|
+
type OperationObject<T extends {} = {}> = {
|
|
1545
|
+
tags?: string[];
|
|
1546
|
+
summary?: string;
|
|
1547
|
+
description?: string;
|
|
1548
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1549
|
+
operationId?: string;
|
|
1550
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
1551
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
1552
|
+
responses: ResponsesObject;
|
|
1553
|
+
callbacks?: {
|
|
1554
|
+
[callback: string]: ReferenceObject | CallbackObject;
|
|
1555
|
+
};
|
|
1556
|
+
deprecated?: boolean;
|
|
1557
|
+
security?: SecurityRequirementObject[];
|
|
1558
|
+
servers?: ServerObject[];
|
|
1559
|
+
} & T;
|
|
1560
|
+
interface ExternalDocumentationObject {
|
|
1561
|
+
description?: string;
|
|
1562
|
+
url: string;
|
|
1563
|
+
}
|
|
1564
|
+
interface ParameterObject extends ParameterBaseObject {
|
|
1565
|
+
name: string;
|
|
1566
|
+
in: string;
|
|
1567
|
+
}
|
|
1568
|
+
interface HeaderObject extends ParameterBaseObject {}
|
|
1569
|
+
interface ParameterBaseObject {
|
|
1570
|
+
description?: string;
|
|
1571
|
+
required?: boolean;
|
|
1572
|
+
deprecated?: boolean;
|
|
1573
|
+
allowEmptyValue?: boolean;
|
|
1574
|
+
style?: string;
|
|
1575
|
+
explode?: boolean;
|
|
1576
|
+
allowReserved?: boolean;
|
|
1577
|
+
schema?: ReferenceObject | SchemaObject;
|
|
1578
|
+
example?: any;
|
|
1579
|
+
examples?: {
|
|
1580
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
1581
|
+
};
|
|
1582
|
+
content?: {
|
|
1583
|
+
[media: string]: MediaTypeObject;
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
type NonArraySchemaObjectType =
|
|
1587
|
+
| "boolean"
|
|
1588
|
+
| "object"
|
|
1589
|
+
| "number"
|
|
1590
|
+
| "string"
|
|
1591
|
+
| "integer";
|
|
1592
|
+
type ArraySchemaObjectType = "array";
|
|
1593
|
+
type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
|
|
1594
|
+
interface ArraySchemaObject extends BaseSchemaObject {
|
|
1595
|
+
type: ArraySchemaObjectType;
|
|
1596
|
+
items: ReferenceObject | SchemaObject;
|
|
1597
|
+
}
|
|
1598
|
+
interface NonArraySchemaObject extends BaseSchemaObject {
|
|
1599
|
+
type?: NonArraySchemaObjectType;
|
|
1600
|
+
}
|
|
1601
|
+
interface BaseSchemaObject {
|
|
1602
|
+
title?: string;
|
|
1603
|
+
description?: string;
|
|
1604
|
+
format?: string;
|
|
1605
|
+
default?: any;
|
|
1606
|
+
multipleOf?: number;
|
|
1607
|
+
maximum?: number;
|
|
1608
|
+
exclusiveMaximum?: boolean;
|
|
1609
|
+
minimum?: number;
|
|
1610
|
+
exclusiveMinimum?: boolean;
|
|
1611
|
+
maxLength?: number;
|
|
1612
|
+
minLength?: number;
|
|
1613
|
+
pattern?: string;
|
|
1614
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
1615
|
+
maxItems?: number;
|
|
1616
|
+
minItems?: number;
|
|
1617
|
+
uniqueItems?: boolean;
|
|
1618
|
+
maxProperties?: number;
|
|
1619
|
+
minProperties?: number;
|
|
1620
|
+
required?: string[];
|
|
1621
|
+
enum?: any[];
|
|
1622
|
+
properties?: {
|
|
1623
|
+
[name: string]: ReferenceObject | SchemaObject;
|
|
1624
|
+
};
|
|
1625
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
|
1626
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
1627
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
1628
|
+
not?: ReferenceObject | SchemaObject;
|
|
1629
|
+
nullable?: boolean;
|
|
1630
|
+
discriminator?: DiscriminatorObject;
|
|
1631
|
+
readOnly?: boolean;
|
|
1632
|
+
writeOnly?: boolean;
|
|
1633
|
+
xml?: XMLObject;
|
|
1634
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1635
|
+
example?: any;
|
|
1636
|
+
deprecated?: boolean;
|
|
1637
|
+
}
|
|
1638
|
+
interface DiscriminatorObject {
|
|
1639
|
+
propertyName: string;
|
|
1640
|
+
mapping?: {
|
|
1641
|
+
[value: string]: string;
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1644
|
+
interface XMLObject {
|
|
1645
|
+
name?: string;
|
|
1646
|
+
namespace?: string;
|
|
1647
|
+
prefix?: string;
|
|
1648
|
+
attribute?: boolean;
|
|
1649
|
+
wrapped?: boolean;
|
|
1650
|
+
}
|
|
1651
|
+
interface ReferenceObject {
|
|
1652
|
+
$ref: string;
|
|
1653
|
+
}
|
|
1654
|
+
interface ExampleObject {
|
|
1655
|
+
summary?: string;
|
|
1656
|
+
description?: string;
|
|
1657
|
+
value?: any;
|
|
1658
|
+
externalValue?: string;
|
|
1659
|
+
}
|
|
1660
|
+
interface MediaTypeObject {
|
|
1661
|
+
schema?: ReferenceObject | SchemaObject;
|
|
1662
|
+
example?: any;
|
|
1663
|
+
examples?: {
|
|
1664
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
1665
|
+
};
|
|
1666
|
+
encoding?: {
|
|
1667
|
+
[media: string]: EncodingObject;
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
interface EncodingObject {
|
|
1671
|
+
contentType?: string;
|
|
1672
|
+
headers?: {
|
|
1673
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
1674
|
+
};
|
|
1675
|
+
style?: string;
|
|
1676
|
+
explode?: boolean;
|
|
1677
|
+
allowReserved?: boolean;
|
|
1678
|
+
}
|
|
1679
|
+
interface RequestBodyObject {
|
|
1680
|
+
description?: string;
|
|
1681
|
+
content: {
|
|
1682
|
+
[media: string]: MediaTypeObject;
|
|
1683
|
+
};
|
|
1684
|
+
required?: boolean;
|
|
1685
|
+
}
|
|
1686
|
+
interface ResponsesObject {
|
|
1687
|
+
[code: string]: ReferenceObject | ResponseObject;
|
|
1688
|
+
}
|
|
1689
|
+
interface ResponseObject {
|
|
1690
|
+
description: string;
|
|
1691
|
+
headers?: {
|
|
1692
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
1693
|
+
};
|
|
1694
|
+
content?: {
|
|
1695
|
+
[media: string]: MediaTypeObject;
|
|
1696
|
+
};
|
|
1697
|
+
links?: {
|
|
1698
|
+
[link: string]: ReferenceObject | LinkObject;
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
interface LinkObject {
|
|
1702
|
+
operationRef?: string;
|
|
1703
|
+
operationId?: string;
|
|
1704
|
+
parameters?: {
|
|
1705
|
+
[parameter: string]: any;
|
|
1706
|
+
};
|
|
1707
|
+
requestBody?: any;
|
|
1708
|
+
description?: string;
|
|
1709
|
+
server?: ServerObject;
|
|
1710
|
+
}
|
|
1711
|
+
interface CallbackObject {
|
|
1712
|
+
[url: string]: PathItemObject;
|
|
1713
|
+
}
|
|
1714
|
+
interface SecurityRequirementObject {
|
|
1715
|
+
[name: string]: string[];
|
|
1716
|
+
}
|
|
1717
|
+
interface ComponentsObject {
|
|
1718
|
+
schemas?: {
|
|
1719
|
+
[key: string]: ReferenceObject | SchemaObject;
|
|
1720
|
+
};
|
|
1721
|
+
responses?: {
|
|
1722
|
+
[key: string]: ReferenceObject | ResponseObject;
|
|
1723
|
+
};
|
|
1724
|
+
parameters?: {
|
|
1725
|
+
[key: string]: ReferenceObject | ParameterObject;
|
|
1726
|
+
};
|
|
1727
|
+
examples?: {
|
|
1728
|
+
[key: string]: ReferenceObject | ExampleObject;
|
|
1729
|
+
};
|
|
1730
|
+
requestBodies?: {
|
|
1731
|
+
[key: string]: ReferenceObject | RequestBodyObject;
|
|
1732
|
+
};
|
|
1733
|
+
headers?: {
|
|
1734
|
+
[key: string]: ReferenceObject | HeaderObject;
|
|
1735
|
+
};
|
|
1736
|
+
securitySchemes?: {
|
|
1737
|
+
[key: string]: ReferenceObject | SecuritySchemeObject;
|
|
1738
|
+
};
|
|
1739
|
+
links?: {
|
|
1740
|
+
[key: string]: ReferenceObject | LinkObject;
|
|
1741
|
+
};
|
|
1742
|
+
callbacks?: {
|
|
1743
|
+
[key: string]: ReferenceObject | CallbackObject;
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
type SecuritySchemeObject =
|
|
1747
|
+
| HttpSecurityScheme
|
|
1748
|
+
| ApiKeySecurityScheme
|
|
1749
|
+
| OAuth2SecurityScheme
|
|
1750
|
+
| OpenIdSecurityScheme;
|
|
1751
|
+
interface HttpSecurityScheme {
|
|
1752
|
+
type: "http";
|
|
1753
|
+
description?: string;
|
|
1754
|
+
scheme: string;
|
|
1755
|
+
bearerFormat?: string;
|
|
1756
|
+
}
|
|
1757
|
+
interface ApiKeySecurityScheme {
|
|
1758
|
+
type: "apiKey";
|
|
1759
|
+
description?: string;
|
|
1760
|
+
name: string;
|
|
1761
|
+
in: string;
|
|
1762
|
+
}
|
|
1763
|
+
interface OAuth2SecurityScheme {
|
|
1764
|
+
type: "oauth2";
|
|
1765
|
+
description?: string;
|
|
1766
|
+
flows: {
|
|
1767
|
+
implicit?: {
|
|
1768
|
+
authorizationUrl: string;
|
|
1769
|
+
refreshUrl?: string;
|
|
1770
|
+
scopes: {
|
|
1771
|
+
[scope: string]: string;
|
|
1772
|
+
};
|
|
1773
|
+
};
|
|
1774
|
+
password?: {
|
|
1775
|
+
tokenUrl: string;
|
|
1776
|
+
refreshUrl?: string;
|
|
1777
|
+
scopes: {
|
|
1778
|
+
[scope: string]: string;
|
|
1779
|
+
};
|
|
1780
|
+
};
|
|
1781
|
+
clientCredentials?: {
|
|
1782
|
+
tokenUrl: string;
|
|
1783
|
+
refreshUrl?: string;
|
|
1784
|
+
scopes: {
|
|
1785
|
+
[scope: string]: string;
|
|
1786
|
+
};
|
|
1787
|
+
};
|
|
1788
|
+
authorizationCode?: {
|
|
1789
|
+
authorizationUrl: string;
|
|
1790
|
+
tokenUrl: string;
|
|
1791
|
+
refreshUrl?: string;
|
|
1792
|
+
scopes: {
|
|
1793
|
+
[scope: string]: string;
|
|
1794
|
+
};
|
|
1795
|
+
};
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
interface OpenIdSecurityScheme {
|
|
1799
|
+
type: "openIdConnect";
|
|
1800
|
+
description?: string;
|
|
1801
|
+
openIdConnectUrl: string;
|
|
1802
|
+
}
|
|
1803
|
+
interface TagObject {
|
|
1804
|
+
name: string;
|
|
1805
|
+
description?: string;
|
|
1806
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
declare namespace OpenAPIV3_1 {
|
|
1811
|
+
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
1812
|
+
type PathsWebhooksComponents<T extends {} = {}> = {
|
|
1813
|
+
paths: PathsObject<T>;
|
|
1814
|
+
webhooks: Record<string, PathItemObject | ReferenceObject>;
|
|
1815
|
+
components: ComponentsObject;
|
|
1816
|
+
};
|
|
1817
|
+
type Document<T extends {} = {}> = Modify<
|
|
1818
|
+
Omit<OpenAPIV3.Document<T>, "paths" | "components">,
|
|
1819
|
+
{
|
|
1820
|
+
info: InfoObject;
|
|
1821
|
+
jsonSchemaDialect?: string;
|
|
1822
|
+
servers?: ServerObject[];
|
|
1823
|
+
} & (
|
|
1824
|
+
| (Pick<PathsWebhooksComponents<T>, "paths"> &
|
|
1825
|
+
Omit<Partial<PathsWebhooksComponents<T>>, "paths">)
|
|
1826
|
+
| (Pick<PathsWebhooksComponents<T>, "webhooks"> &
|
|
1827
|
+
Omit<Partial<PathsWebhooksComponents<T>>, "webhooks">)
|
|
1828
|
+
| (Pick<PathsWebhooksComponents<T>, "components"> &
|
|
1829
|
+
Omit<Partial<PathsWebhooksComponents<T>>, "components">)
|
|
1830
|
+
)
|
|
1831
|
+
>;
|
|
1832
|
+
type InfoObject = Modify<
|
|
1833
|
+
OpenAPIV3.InfoObject,
|
|
1834
|
+
{
|
|
1835
|
+
summary?: string;
|
|
1836
|
+
license?: LicenseObject;
|
|
1837
|
+
}
|
|
1838
|
+
>;
|
|
1839
|
+
type ContactObject = OpenAPIV3.ContactObject;
|
|
1840
|
+
type LicenseObject = Modify<
|
|
1841
|
+
OpenAPIV3.LicenseObject,
|
|
1842
|
+
{
|
|
1843
|
+
identifier?: string;
|
|
1844
|
+
}
|
|
1845
|
+
>;
|
|
1846
|
+
type ServerObject = Modify<
|
|
1847
|
+
OpenAPIV3.ServerObject,
|
|
1848
|
+
{
|
|
1849
|
+
url: string;
|
|
1850
|
+
description?: string;
|
|
1851
|
+
variables?: Record<string, ServerVariableObject>;
|
|
1852
|
+
}
|
|
1853
|
+
>;
|
|
1854
|
+
type ServerVariableObject = Modify<
|
|
1855
|
+
OpenAPIV3.ServerVariableObject,
|
|
1856
|
+
{
|
|
1857
|
+
enum?: [string, ...string[]];
|
|
1858
|
+
}
|
|
1859
|
+
>;
|
|
1860
|
+
type PathsObject<T extends {} = {}, P extends {} = {}> = Record<
|
|
1861
|
+
string,
|
|
1862
|
+
(PathItemObject<T> & P) | undefined
|
|
1863
|
+
>;
|
|
1864
|
+
type HttpMethods = OpenAPIV3.HttpMethods;
|
|
1865
|
+
type PathItemObject<T extends {} = {}> = Modify<
|
|
1866
|
+
OpenAPIV3.PathItemObject<T>,
|
|
1867
|
+
{
|
|
1868
|
+
servers?: ServerObject[];
|
|
1869
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
1870
|
+
}
|
|
1871
|
+
> & {
|
|
1872
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
1873
|
+
};
|
|
1874
|
+
type OperationObject<T extends {} = {}> = Modify<
|
|
1875
|
+
OpenAPIV3.OperationObject<T>,
|
|
1876
|
+
{
|
|
1877
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
1878
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
1879
|
+
responses?: ResponsesObject;
|
|
1880
|
+
callbacks?: Record<string, ReferenceObject | CallbackObject>;
|
|
1881
|
+
servers?: ServerObject[];
|
|
1882
|
+
}
|
|
1883
|
+
> &
|
|
1884
|
+
T;
|
|
1885
|
+
type ExternalDocumentationObject = OpenAPIV3.ExternalDocumentationObject;
|
|
1886
|
+
type ParameterObject = OpenAPIV3.ParameterObject;
|
|
1887
|
+
type HeaderObject = OpenAPIV3.HeaderObject;
|
|
1888
|
+
type ParameterBaseObject = OpenAPIV3.ParameterBaseObject;
|
|
1889
|
+
type NonArraySchemaObjectType = OpenAPIV3.NonArraySchemaObjectType | "null";
|
|
1890
|
+
type ArraySchemaObjectType = OpenAPIV3.ArraySchemaObjectType;
|
|
1891
|
+
/**
|
|
1892
|
+
* There is no way to tell typescript to require items when type is either 'array' or array containing 'array' type
|
|
1893
|
+
* 'items' will be always visible as optional
|
|
1894
|
+
* Casting schema object to ArraySchemaObject or NonArraySchemaObject will work fine
|
|
1895
|
+
*/
|
|
1896
|
+
type SchemaObject =
|
|
1897
|
+
| ArraySchemaObject
|
|
1898
|
+
| NonArraySchemaObject
|
|
1899
|
+
| MixedSchemaObject;
|
|
1900
|
+
interface ArraySchemaObject extends BaseSchemaObject {
|
|
1901
|
+
type: ArraySchemaObjectType;
|
|
1902
|
+
items: ReferenceObject | SchemaObject;
|
|
1903
|
+
}
|
|
1904
|
+
interface NonArraySchemaObject extends BaseSchemaObject {
|
|
1905
|
+
type?: NonArraySchemaObjectType;
|
|
1906
|
+
}
|
|
1907
|
+
interface MixedSchemaObject extends BaseSchemaObject {
|
|
1908
|
+
type?: (ArraySchemaObjectType | NonArraySchemaObjectType)[];
|
|
1909
|
+
items?: ReferenceObject | SchemaObject;
|
|
1910
|
+
}
|
|
1911
|
+
type BaseSchemaObject = Modify<
|
|
1912
|
+
Omit<OpenAPIV3.BaseSchemaObject, "nullable">,
|
|
1913
|
+
{
|
|
1914
|
+
examples?: OpenAPIV3.BaseSchemaObject["example"][];
|
|
1915
|
+
exclusiveMinimum?: boolean | number;
|
|
1916
|
+
exclusiveMaximum?: boolean | number;
|
|
1917
|
+
contentMediaType?: string;
|
|
1918
|
+
$schema?: string;
|
|
1919
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
1920
|
+
properties?: {
|
|
1921
|
+
[name: string]: ReferenceObject | SchemaObject;
|
|
1922
|
+
};
|
|
1923
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
|
1924
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
1925
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
1926
|
+
not?: ReferenceObject | SchemaObject;
|
|
1927
|
+
discriminator?: DiscriminatorObject;
|
|
1928
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1929
|
+
xml?: XMLObject;
|
|
1930
|
+
const?: any;
|
|
1931
|
+
}
|
|
1932
|
+
>;
|
|
1933
|
+
type DiscriminatorObject = OpenAPIV3.DiscriminatorObject;
|
|
1934
|
+
type XMLObject = OpenAPIV3.XMLObject;
|
|
1935
|
+
type ReferenceObject = Modify<
|
|
1936
|
+
OpenAPIV3.ReferenceObject,
|
|
1937
|
+
{
|
|
1938
|
+
summary?: string;
|
|
1939
|
+
description?: string;
|
|
1940
|
+
}
|
|
1941
|
+
>;
|
|
1942
|
+
type ExampleObject = OpenAPIV3.ExampleObject;
|
|
1943
|
+
type MediaTypeObject = Modify<
|
|
1944
|
+
OpenAPIV3.MediaTypeObject,
|
|
1945
|
+
{
|
|
1946
|
+
schema?: SchemaObject | ReferenceObject;
|
|
1947
|
+
examples?: Record<string, ReferenceObject | ExampleObject>;
|
|
1948
|
+
}
|
|
1949
|
+
>;
|
|
1950
|
+
type EncodingObject = OpenAPIV3.EncodingObject;
|
|
1951
|
+
type RequestBodyObject = Modify<
|
|
1952
|
+
OpenAPIV3.RequestBodyObject,
|
|
1953
|
+
{
|
|
1954
|
+
content: {
|
|
1955
|
+
[media: string]: MediaTypeObject;
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
>;
|
|
1959
|
+
type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
|
|
1960
|
+
type ResponseObject = Modify<
|
|
1961
|
+
OpenAPIV3.ResponseObject,
|
|
1962
|
+
{
|
|
1963
|
+
headers?: {
|
|
1964
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
1965
|
+
};
|
|
1966
|
+
content?: {
|
|
1967
|
+
[media: string]: MediaTypeObject;
|
|
1968
|
+
};
|
|
1969
|
+
links?: {
|
|
1970
|
+
[link: string]: ReferenceObject | LinkObject;
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
>;
|
|
1974
|
+
type LinkObject = Modify<
|
|
1975
|
+
OpenAPIV3.LinkObject,
|
|
1976
|
+
{
|
|
1977
|
+
server?: ServerObject;
|
|
1978
|
+
}
|
|
1979
|
+
>;
|
|
1980
|
+
type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
|
|
1981
|
+
type SecurityRequirementObject = OpenAPIV3.SecurityRequirementObject;
|
|
1982
|
+
type ComponentsObject = Modify<
|
|
1983
|
+
OpenAPIV3.ComponentsObject,
|
|
1984
|
+
{
|
|
1985
|
+
schemas?: Record<string, SchemaObject>;
|
|
1986
|
+
responses?: Record<string, ReferenceObject | ResponseObject>;
|
|
1987
|
+
parameters?: Record<string, ReferenceObject | ParameterObject>;
|
|
1988
|
+
examples?: Record<string, ReferenceObject | ExampleObject>;
|
|
1989
|
+
requestBodies?: Record<string, ReferenceObject | RequestBodyObject>;
|
|
1990
|
+
headers?: Record<string, ReferenceObject | HeaderObject>;
|
|
1991
|
+
securitySchemes?: Record<string, ReferenceObject | SecuritySchemeObject>;
|
|
1992
|
+
links?: Record<string, ReferenceObject | LinkObject>;
|
|
1993
|
+
callbacks?: Record<string, ReferenceObject | CallbackObject>;
|
|
1994
|
+
pathItems?: Record<string, ReferenceObject | PathItemObject>;
|
|
1995
|
+
}
|
|
1996
|
+
>;
|
|
1997
|
+
type SecuritySchemeObject = OpenAPIV3.SecuritySchemeObject;
|
|
1998
|
+
type HttpSecurityScheme = OpenAPIV3.HttpSecurityScheme;
|
|
1999
|
+
type ApiKeySecurityScheme = OpenAPIV3.ApiKeySecurityScheme;
|
|
2000
|
+
type OAuth2SecurityScheme = OpenAPIV3.OAuth2SecurityScheme;
|
|
2001
|
+
type OpenIdSecurityScheme = OpenAPIV3.OpenIdSecurityScheme;
|
|
2002
|
+
type TagObject = OpenAPIV3.TagObject;
|
|
2003
|
+
{
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Base object for parameter definitions
|
|
2009
|
+
* @public
|
|
2010
|
+
*/
|
|
2011
|
+
declare type ParameterBaseObject = Modify<
|
|
2012
|
+
Omit<
|
|
2013
|
+
OpenAPIV3_1.ParameterBaseObject,
|
|
2014
|
+
| "content"
|
|
2015
|
+
| "allowEmptyValue"
|
|
2016
|
+
| "style"
|
|
2017
|
+
| "allowReserved"
|
|
2018
|
+
| "explode"
|
|
2019
|
+
| "example"
|
|
2020
|
+
| "examples"
|
|
2021
|
+
>,
|
|
2022
|
+
{
|
|
2023
|
+
schema: OpenAPIV3_1.SchemaObject;
|
|
2024
|
+
}
|
|
2025
|
+
>;
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* Definition of a parameter
|
|
2029
|
+
* @public
|
|
2030
|
+
*/
|
|
2031
|
+
declare interface ParameterDefinition extends ParameterBaseObject {
|
|
2032
|
+
name: string;
|
|
2033
|
+
in: string;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* Build an inbound policy handler that runs per-message MCP logic while the
|
|
2038
|
+
* runtime owns the batch mechanics.
|
|
2039
|
+
*
|
|
2040
|
+
* The runtime parses the envelope once, runs at most one handler per message
|
|
2041
|
+
* (exact method key first, then `"*"`), forwards surviving messages —
|
|
2042
|
+
* preserving the wire shape, so a batch stays a batch — correlates upstream
|
|
2043
|
+
* replies by JSON-RPC id, inserts locally generated errors and results, and
|
|
2044
|
+
* rebuilds the response in the original request order.
|
|
2045
|
+
*
|
|
2046
|
+
* Contracts:
|
|
2047
|
+
*
|
|
2048
|
+
* - Invalid members (no `jsonrpc: "2.0"`, null/malformed ids, known methods
|
|
2049
|
+
* with malformed required params) are answered automatically and never
|
|
2050
|
+
* reach handlers.
|
|
2051
|
+
* - A batch containing duplicate request ids is rejected before forwarding —
|
|
2052
|
+
* stitching duplicates would be guesswork.
|
|
2053
|
+
* - A thrown handler fails only its own message (`-32603`); siblings
|
|
2054
|
+
* continue. The thrown error is logged, never sent to the client.
|
|
2055
|
+
* - Blocked notifications are dropped silently (notifications have no
|
|
2056
|
+
* replies).
|
|
2057
|
+
* - Client-supplied JSON-RPC results/errors are forwarded untouched.
|
|
2058
|
+
* - If every message resolves locally the upstream is never called.
|
|
2059
|
+
* - Non-MCP bodies pass through untouched.
|
|
2060
|
+
*
|
|
2061
|
+
* @beta
|
|
2062
|
+
*/
|
|
2063
|
+
export declare function processMessages<TOptions = unknown>(
|
|
2064
|
+
config: McpProcessMessagesConfig<TOptions>
|
|
2065
|
+
): InboundPolicyHandler<TOptions>;
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* Generic type parameters for a request.
|
|
2069
|
+
* Extends RequestInitGeneric and adds query parameter typing.
|
|
2070
|
+
* @public
|
|
2071
|
+
*/
|
|
2072
|
+
declare interface RequestGeneric extends RequestInitGeneric {
|
|
2073
|
+
Query?: RequestQueryDefault;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* Generic type parameters for request initialization.
|
|
2078
|
+
* Used to strongly type the user data and path parameters.
|
|
2079
|
+
* @public
|
|
2080
|
+
*/
|
|
2081
|
+
declare interface RequestInitGeneric {
|
|
2082
|
+
UserData?: UserDataDefault;
|
|
2083
|
+
Params?: RequestParamsDefault;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
declare type RequestParamsDefault = Record<string, string>;
|
|
2087
|
+
|
|
2088
|
+
declare type RequestQueryDefault = Record<string, string>;
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Represents an authenticated user on the request.
|
|
2092
|
+
* Set by authentication policies like API key, JWT, or OAuth.
|
|
2093
|
+
*
|
|
2094
|
+
* @public
|
|
2095
|
+
* @example
|
|
2096
|
+
* ```typescript
|
|
2097
|
+
* // Access user info in a handler
|
|
2098
|
+
* export function myHandler(request: ZuploRequest, context: ZuploContext) {
|
|
2099
|
+
* if (!request.user) {
|
|
2100
|
+
* return new Response("Unauthorized", { status: 401 });
|
|
2101
|
+
* }
|
|
2102
|
+
*
|
|
2103
|
+
* const userId = request.user.sub;
|
|
2104
|
+
* const customData = request.user.data as { role: string; tenantId: string };
|
|
2105
|
+
*
|
|
2106
|
+
* context.log.info(`Request from user ${userId} with role ${customData.role}`);
|
|
2107
|
+
* }
|
|
2108
|
+
* ```
|
|
2109
|
+
*/
|
|
2110
|
+
declare interface RequestUser<TUserData> {
|
|
2111
|
+
sub: string;
|
|
2112
|
+
data: TUserData;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
declare type ResolveRequestParams<
|
|
2116
|
+
TParams extends RequestParamsDefault | undefined,
|
|
2117
|
+
> = TParams extends RequestParamsDefault ? TParams : RequestParamsDefault;
|
|
2118
|
+
|
|
2119
|
+
declare type ResolveRequestQuery<
|
|
2120
|
+
TQuery extends RequestQueryDefault | undefined,
|
|
2121
|
+
> = TQuery extends RequestQueryDefault ? TQuery : RequestQueryDefault;
|
|
2122
|
+
|
|
2123
|
+
declare type ResolveUserData<TUserData extends UserDataDefault | undefined> =
|
|
2124
|
+
TUserData extends UserDataDefault ? TUserData : UserDataDefault;
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* Definition of responses for a route
|
|
2128
|
+
* @public
|
|
2129
|
+
*/
|
|
2130
|
+
declare type ResponsesDefinition = Record<
|
|
2131
|
+
HttpStatusCode | HttpStatusCodeRangeDefinition,
|
|
2132
|
+
Modify<
|
|
2133
|
+
Omit<OpenAPIV3_1.ResponseObject, "links">,
|
|
2134
|
+
{
|
|
2135
|
+
headers?: {
|
|
2136
|
+
[header: string]: ParameterBaseObject;
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
>
|
|
2140
|
+
>;
|
|
2141
|
+
|
|
2142
|
+
/**
|
|
2143
|
+
* @public
|
|
2144
|
+
*/
|
|
2145
|
+
declare interface RouteConfiguration extends Omit<
|
|
2146
|
+
BuildRouteConfiguration,
|
|
2147
|
+
"raw"
|
|
2148
|
+
> {
|
|
2149
|
+
/**
|
|
2150
|
+
* @deprecated Please switch to "raw().operationId"
|
|
2151
|
+
*/
|
|
2152
|
+
operationId?: string;
|
|
2153
|
+
/**
|
|
2154
|
+
* @deprecated Please switch to "raw().summary"
|
|
2155
|
+
*/
|
|
2156
|
+
summary?: string;
|
|
2157
|
+
/**
|
|
2158
|
+
* @deprecated Please switch to "raw().tags"
|
|
2159
|
+
*/
|
|
2160
|
+
tags?: string[];
|
|
2161
|
+
/**
|
|
2162
|
+
* @deprecated Please switch to "raw().parameters"
|
|
2163
|
+
*/
|
|
2164
|
+
parameters?: ParameterDefinition[];
|
|
2165
|
+
/**
|
|
2166
|
+
* @deprecated Please switch to "raw().responses"
|
|
2167
|
+
*/
|
|
2168
|
+
responses?: ResponsesDefinition;
|
|
2169
|
+
/**
|
|
2170
|
+
* Gets the raw route configuration object
|
|
2171
|
+
*/
|
|
2172
|
+
raw<T = any>(): T;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
declare type UserDataDefault = any;
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* @public
|
|
2179
|
+
*/
|
|
2180
|
+
declare interface WaitUntilFunc {
|
|
2181
|
+
(promise: Promise<any>): void;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
declare interface ZuploAnalyticsContext {
|
|
2185
|
+
addAnalyticsEvent(
|
|
2186
|
+
value: number,
|
|
2187
|
+
eventType: EventType,
|
|
2188
|
+
metadata: JsonObject,
|
|
2189
|
+
unit?: string,
|
|
2190
|
+
eventId?: string
|
|
2191
|
+
): void;
|
|
2192
|
+
flushAnalyticsEvents(): ZuploAnalyticsEvent[];
|
|
2193
|
+
getAnalyticsEvents(): ZuploAnalyticsEvent[];
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
declare interface ZuploAnalyticsEvent<T extends JsonObject = JsonObject> {
|
|
2197
|
+
eventId: string;
|
|
2198
|
+
requestId: string;
|
|
2199
|
+
timestamp: Date;
|
|
2200
|
+
accountName: string;
|
|
2201
|
+
projectName: string;
|
|
2202
|
+
deploymentName: string;
|
|
2203
|
+
eventType: EventType;
|
|
2204
|
+
metadata: T;
|
|
2205
|
+
unit?: string;
|
|
2206
|
+
value: number;
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
/**
|
|
2210
|
+
* The ZuploContext provides information about the current request and helper methods.
|
|
2211
|
+
* @public
|
|
2212
|
+
*/
|
|
2213
|
+
declare interface ZuploContext extends EventTarget {
|
|
2214
|
+
/**
|
|
2215
|
+
* The unique identifier of this context
|
|
2216
|
+
*/
|
|
2217
|
+
readonly contextId: Readonly<string>;
|
|
2218
|
+
/**
|
|
2219
|
+
* The unique identifier of the incoming request
|
|
2220
|
+
*/
|
|
2221
|
+
readonly requestId: Readonly<string>;
|
|
2222
|
+
/**
|
|
2223
|
+
* Request based logger
|
|
2224
|
+
*/
|
|
2225
|
+
readonly log: Readonly<Logger>;
|
|
2226
|
+
/**
|
|
2227
|
+
* The route that is being processed
|
|
2228
|
+
*/
|
|
2229
|
+
readonly route: Readonly<RouteConfiguration>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Custom data stored on the ZuploContext
|
|
2232
|
+
*/
|
|
2233
|
+
readonly custom: Record<string, any>;
|
|
2234
|
+
readonly incomingRequestProperties: IncomingRequestProperties;
|
|
2235
|
+
/**
|
|
2236
|
+
* The parent context that spawned this context
|
|
2237
|
+
* @beta
|
|
2238
|
+
*/
|
|
2239
|
+
readonly parentContext: ZuploContext | undefined;
|
|
2240
|
+
/* Excluded from this release type: analyticsContext */
|
|
2241
|
+
readonly invokeInboundPolicy: (
|
|
2242
|
+
policyName: string,
|
|
2243
|
+
request: ZuploRequest
|
|
2244
|
+
) => Promise<Response | ZuploRequest>;
|
|
2245
|
+
readonly invokeOutboundPolicy: (
|
|
2246
|
+
policyName: string,
|
|
2247
|
+
response: Response,
|
|
2248
|
+
request: ZuploRequest
|
|
2249
|
+
) => Promise<Response>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Invokes a route based on a Request without going back out to HTTP.
|
|
2252
|
+
* Can take a relative route path to invoke on the Gateway
|
|
2253
|
+
* Example: "/my/route" will invoke http://localhost/my/route on the Gateway
|
|
2254
|
+
* without having to rebuild the Request's protocol and host.
|
|
2255
|
+
* @beta
|
|
2256
|
+
*/
|
|
2257
|
+
readonly invokeRoute: <TOptions extends RequestGeneric = RequestGeneric>(
|
|
2258
|
+
input: string | URL | Request,
|
|
2259
|
+
init?: ZuploRequestInit<TOptions>
|
|
2260
|
+
) => Promise<Response>;
|
|
2261
|
+
readonly waitUntil: WaitUntilFunc;
|
|
2262
|
+
/**
|
|
2263
|
+
* Fires just before the response is sent. Response can be modified.
|
|
2264
|
+
*/
|
|
2265
|
+
readonly addResponseSendingHook: (hook: OnResponseSendingHook) => void;
|
|
2266
|
+
/**
|
|
2267
|
+
* Fires immediately after the response is sent. Response cannot be modified.
|
|
2268
|
+
*/
|
|
2269
|
+
readonly addResponseSendingFinalHook: (
|
|
2270
|
+
hook: OnResponseSendingFinalHook
|
|
2271
|
+
) => void;
|
|
2272
|
+
/**
|
|
2273
|
+
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
|
|
2274
|
+
*
|
|
2275
|
+
* The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
|
|
2276
|
+
*
|
|
2277
|
+
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
|
|
2278
|
+
*
|
|
2279
|
+
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
|
|
2280
|
+
*
|
|
2281
|
+
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
|
|
2282
|
+
*
|
|
2283
|
+
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
|
|
2284
|
+
*
|
|
2285
|
+
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
|
|
2286
|
+
* @deprecated This will be removed in the future. Use hooks instead. See {@link https://zuplo.com/docs/programmable-api/runtime-extensions}
|
|
2287
|
+
*/
|
|
2288
|
+
addEventListener<Type extends keyof Record<string, Event>>(
|
|
2289
|
+
type: Type,
|
|
2290
|
+
handler: EventListenerOrEventListenerObject,
|
|
2291
|
+
options?: AddEventListenerOptions | boolean
|
|
2292
|
+
): void;
|
|
2293
|
+
/**
|
|
2294
|
+
* @deprecated This will be removed in the future. See {@link https://zuplo.com/docs/programmable-api/runtime-extensions}
|
|
2295
|
+
*/
|
|
2296
|
+
removeEventListener<Type extends keyof Record<string, Event>>(
|
|
2297
|
+
type: Type,
|
|
2298
|
+
handler: EventListenerOrEventListenerObject,
|
|
2299
|
+
options?: AddEventListenerOptions | boolean
|
|
2300
|
+
): void;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Enhanced Request class that extends the standard Web Request API with
|
|
2305
|
+
* convenient properties for accessing path parameters, query strings, and user data.
|
|
2306
|
+
* This is the request type passed to all handlers and policies in Zuplo.
|
|
2307
|
+
*
|
|
2308
|
+
* @public
|
|
2309
|
+
* @example
|
|
2310
|
+
* ```typescript
|
|
2311
|
+
* import { ZuploRequest, ZuploContext } from "@zuplo/runtime";
|
|
2312
|
+
*
|
|
2313
|
+
* export function myHandler(request: ZuploRequest, context: ZuploContext) {
|
|
2314
|
+
* // Access query parameters
|
|
2315
|
+
* const page = request.query.page || "1";
|
|
2316
|
+
* const limit = request.query.limit || "10";
|
|
2317
|
+
*
|
|
2318
|
+
* // Access path parameters (e.g., from /users/:userId)
|
|
2319
|
+
* const userId = request.params.userId;
|
|
2320
|
+
*
|
|
2321
|
+
* // Access authenticated user
|
|
2322
|
+
* const user = request.user;
|
|
2323
|
+
*
|
|
2324
|
+
* // Standard Request properties still available
|
|
2325
|
+
* const contentType = request.headers.get("content-type");
|
|
2326
|
+
* const method = request.method;
|
|
2327
|
+
*
|
|
2328
|
+
* return Response.json({
|
|
2329
|
+
* userId,
|
|
2330
|
+
* page,
|
|
2331
|
+
* limit,
|
|
2332
|
+
* authenticated: !!user
|
|
2333
|
+
* });
|
|
2334
|
+
* }
|
|
2335
|
+
* ```
|
|
2336
|
+
*
|
|
2337
|
+
* @example
|
|
2338
|
+
* ```typescript
|
|
2339
|
+
* // Strongly typed request parameters
|
|
2340
|
+
* interface MyParams {
|
|
2341
|
+
* userId: string;
|
|
2342
|
+
* orderId: string;
|
|
2343
|
+
* }
|
|
2344
|
+
*
|
|
2345
|
+
* interface MyQuery {
|
|
2346
|
+
* include?: string;
|
|
2347
|
+
* format?: "json" | "xml";
|
|
2348
|
+
* }
|
|
2349
|
+
*
|
|
2350
|
+
* interface MyUserData {
|
|
2351
|
+
* role: "admin" | "user";
|
|
2352
|
+
* tenantId: string;
|
|
2353
|
+
* }
|
|
2354
|
+
*
|
|
2355
|
+
* type MyRequest = ZuploRequest<{
|
|
2356
|
+
* Params: MyParams;
|
|
2357
|
+
* Query: MyQuery;
|
|
2358
|
+
* UserData: MyUserData;
|
|
2359
|
+
* }>;
|
|
2360
|
+
*
|
|
2361
|
+
* export function typedHandler(request: MyRequest, context: ZuploContext) {
|
|
2362
|
+
* // All properties are now strongly typed
|
|
2363
|
+
* const userId = request.params.userId; // string
|
|
2364
|
+
* const format = request.query.format; // "json" | "xml" | undefined
|
|
2365
|
+
* const role = request.user?.data.role; // "admin" | "user" | undefined
|
|
2366
|
+
* }
|
|
2367
|
+
* ```
|
|
2368
|
+
*/
|
|
2369
|
+
declare class ZuploRequest<
|
|
2370
|
+
TOptions extends RequestGeneric = RequestGeneric,
|
|
2371
|
+
> extends Request {
|
|
2372
|
+
#private;
|
|
2373
|
+
constructor(
|
|
2374
|
+
input: string | URL | Request,
|
|
2375
|
+
init?: ZuploRequestInit<TOptions>,
|
|
2376
|
+
originalRequest?: Request
|
|
2377
|
+
);
|
|
2378
|
+
/* Excluded from this release type: originalRequest */
|
|
2379
|
+
/**
|
|
2380
|
+
* A dictionary of query-string values
|
|
2381
|
+
*
|
|
2382
|
+
* @example
|
|
2383
|
+
* The url `https://example.com?foo=bar` would return
|
|
2384
|
+
* the following query object:
|
|
2385
|
+
*
|
|
2386
|
+
* ```
|
|
2387
|
+
* const foo = request.query.foo;
|
|
2388
|
+
* ```
|
|
2389
|
+
*
|
|
2390
|
+
* @readonly
|
|
2391
|
+
*/
|
|
2392
|
+
get query(): Readonly<ResolveRequestQuery<TOptions["Query"]>>;
|
|
2393
|
+
/**
|
|
2394
|
+
* If you use tokens in your route’s URL, they are
|
|
2395
|
+
* automatically parsed into properties on the params
|
|
2396
|
+
* property of your request.
|
|
2397
|
+
*
|
|
2398
|
+
* @example
|
|
2399
|
+
* The route `/products/:productId/vendors/:vendorId`
|
|
2400
|
+
* would include two params:
|
|
2401
|
+
*
|
|
2402
|
+
* ```
|
|
2403
|
+
* const productId = request.params.productId;
|
|
2404
|
+
* const vendorId = request.params.vendorId;
|
|
2405
|
+
* ```
|
|
2406
|
+
* @readonly
|
|
2407
|
+
*/
|
|
2408
|
+
get params(): Readonly<ResolveRequestParams<TOptions["Params"]>>;
|
|
2409
|
+
/**
|
|
2410
|
+
* An optional object identifying a ‘user’.
|
|
2411
|
+
*
|
|
2412
|
+
* @remarks
|
|
2413
|
+
* If undefined this typically means the request is
|
|
2414
|
+
* anonymous. If present, the user object will have
|
|
2415
|
+
* a sub property that is a unique identifier for
|
|
2416
|
+
* that user. There is also an optional data property
|
|
2417
|
+
* that is of any type that typically contains other
|
|
2418
|
+
* information about the user. When using JWT tokens
|
|
2419
|
+
* you’ll usually find all the claims here.
|
|
2420
|
+
*
|
|
2421
|
+
* @readonly
|
|
2422
|
+
*/
|
|
2423
|
+
user?: RequestUser<ResolveUserData<TOptions["UserData"]>>;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/**
|
|
2427
|
+
* Options for creating a new ZuploRequest.
|
|
2428
|
+
* Extends the standard RequestInit with Zuplo-specific properties.
|
|
2429
|
+
* @public
|
|
2430
|
+
*/
|
|
2431
|
+
declare interface ZuploRequestInit<
|
|
2432
|
+
TOptions extends RequestInitGeneric = RequestInitGeneric,
|
|
2433
|
+
> extends RequestInit {
|
|
2434
|
+
params?: ResolveRequestParams<TOptions["Params"]>;
|
|
2435
|
+
user?: ResolveUserData<TOptions["UserData"]>;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
export {};
|