@zuplo/cli 6.72.2 → 6.72.3

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