wrangler 2.20.2 → 2.21.0

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.
@@ -9,7 +9,6 @@ import { Readable } from 'stream';
9
9
  import { ReadableStream } from 'stream/web';
10
10
  import { Socket } from 'net';
11
11
  import { TcpNetConnectOpts } from 'net';
12
- import { TlsOptions } from 'tls';
13
12
  import { TLSSocket } from 'tls';
14
13
  import { URL as URL_2 } from 'url';
15
14
  import { URLSearchParams as URLSearchParams_2 } from 'url';
@@ -59,7 +58,7 @@ declare class BodyReadable extends Readable {
59
58
  /** Consumes and returns the body as a JavaScript Object
60
59
  * https://fetch.spec.whatwg.org/#dom-body-json
61
60
  */
62
- json(): Promise<any>
61
+ json(): Promise<unknown>
63
62
 
64
63
  /** Consumes and returns the body as a Blob
65
64
  * https://fetch.spec.whatwg.org/#dom-body-blob
@@ -105,6 +104,7 @@ declare function buildConnector (options?: buildConnector.BuildOptions): buildCo
105
104
 
106
105
  declare namespace buildConnector {
107
106
  type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
107
+ allowH2?: boolean;
108
108
  maxCachedSessions?: number | null;
109
109
  socketPath?: string | null;
110
110
  timeout?: number | null;
@@ -126,18 +126,14 @@ declare namespace buildConnector {
126
126
  type Callback = (...args: CallbackArgs) => void
127
127
  type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
128
128
 
129
- type connector = connectorAsync | connectorSync
130
-
131
- interface connectorSync {
132
- (options: buildConnector.Options): Socket | TLSSocket
133
- }
134
-
135
- interface connectorAsync {
129
+ interface connector {
136
130
  (options: buildConnector.Options, callback: buildConnector.Callback): void
137
131
  }
138
132
  }
139
133
 
140
- /** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
134
+ /**
135
+ * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
136
+ */
141
137
  declare class Client extends Dispatcher {
142
138
  constructor(url: string | URL_2, options?: Client.Options);
143
139
  /** Property to get and set the pipelining factor. */
@@ -149,39 +145,71 @@ declare class Client extends Dispatcher {
149
145
  }
150
146
 
151
147
  declare namespace Client {
148
+ interface OptionsInterceptors {
149
+ Client: readonly Dispatcher.DispatchInterceptor[];
150
+ }
152
151
  interface Options {
153
- /** the timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
154
- keepAliveTimeout?: number | null;
155
- /** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
156
- keepAliveMaxTimeout?: number | null;
157
- /** A number subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
158
- keepAliveTimeoutThreshold?: number | null;
159
- /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
160
- pipelining?: number | null;
161
- /** **/
162
- connect?: buildConnector.BuildOptions | buildConnector.connector | null;
163
- /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
164
- maxHeaderSize?: number | null;
152
+ /** TODO */
153
+ interceptors?: OptionsInterceptors;
154
+ /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
155
+ maxHeaderSize?: number;
156
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
157
+ headersTimeout?: number;
158
+ /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
159
+ socketTimeout?: never;
160
+ /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
161
+ requestTimeout?: never;
162
+ /** TODO */
163
+ connectTimeout?: number;
165
164
  /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
166
- bodyTimeout?: number | null;
167
- /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
168
- headersTimeout?: number | null;
165
+ bodyTimeout?: number;
166
+ /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
167
+ idleTimeout?: never;
168
+ /** @deprecated unsupported keepAlive, use pipelining=0 instead */
169
+ keepAlive?: never;
170
+ /** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
171
+ keepAliveTimeout?: number;
172
+ /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
173
+ maxKeepAliveTimeout?: never;
174
+ /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
175
+ keepAliveMaxTimeout?: number;
176
+ /** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
177
+ keepAliveTimeoutThreshold?: number;
178
+ /** TODO */
179
+ socketPath?: string;
180
+ /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
181
+ pipelining?: number;
182
+ /** @deprecated use the connect option instead */
183
+ tls?: never;
169
184
  /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
170
185
  strictContentLength?: boolean;
171
- /** @deprecated use the connect option instead */
172
- tls?: TlsOptions | null;
173
- /** */
186
+ /** TODO */
187
+ maxCachedSessions?: number;
188
+ /** TODO */
189
+ maxRedirections?: number;
190
+ /** TODO */
191
+ connect?: buildConnector.BuildOptions | buildConnector.connector;
192
+ /** TODO */
174
193
  maxRequestsPerClient?: number;
194
+ /** TODO */
195
+ localAddress?: string;
175
196
  /** Max response body size in bytes, -1 is disabled */
176
- maxResponseSize?: number | null;
197
+ maxResponseSize?: number;
177
198
  /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
178
199
  autoSelectFamily?: boolean;
179
200
  /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
180
201
  autoSelectFamilyAttemptTimeout?: number;
181
-
182
- interceptors?: {Client: readonly Dispatcher[] | undefined}
202
+ /**
203
+ * @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
204
+ * @default false
205
+ */
206
+ allowH2?: boolean;
207
+ /**
208
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
209
+ * @default 100
210
+ */
211
+ maxConcurrentStreams?: number
183
212
  }
184
-
185
213
  interface SocketInfo {
186
214
  localAddress?: string
187
215
  localPort?: number
@@ -192,8 +220,6 @@ declare namespace Client {
192
220
  bytesWritten?: number
193
221
  bytesRead?: number
194
222
  }
195
-
196
-
197
223
  }
198
224
 
199
225
  /**
@@ -337,7 +363,7 @@ declare namespace Dispatcher {
337
363
  blocking?: boolean;
338
364
  /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
339
365
  upgrade?: boolean | string | null;
340
- /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
366
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
341
367
  headersTimeout?: number | null;
342
368
  /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
343
369
  bodyTimeout?: number | null;
@@ -345,6 +371,8 @@ declare namespace Dispatcher {
345
371
  reset?: boolean;
346
372
  /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
347
373
  throwOnError?: boolean;
374
+ /** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server*/
375
+ expectContinue?: boolean;
348
376
  }
349
377
  interface ConnectOptions {
350
378
  path: string;
@@ -370,6 +398,8 @@ declare namespace Dispatcher {
370
398
  onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
371
399
  /** Default: `null` */
372
400
  responseHeader?: 'raw' | null;
401
+ /** Default: `64 KiB` */
402
+ highWaterMark?: number;
373
403
  }
374
404
  interface PipelineOptions extends RequestOptions {
375
405
  /** `true` if the `handler` will return an object stream. Default: `false` */
@@ -435,7 +465,7 @@ declare namespace Dispatcher {
435
465
  /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
436
466
  onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
437
467
  /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
438
- onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void): boolean;
468
+ onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void, statusText: string): boolean;
439
469
  /** Invoked when response payload data is received. */
440
470
  onData?(chunk: Buffer): boolean;
441
471
  /** Invoked when response payload and trailers have been received and the request has completed. */
@@ -455,7 +485,7 @@ declare namespace Dispatcher {
455
485
  arrayBuffer(): Promise<ArrayBuffer>;
456
486
  blob(): Promise<Blob_2>;
457
487
  formData(): Promise<never>;
458
- json(): Promise<any>;
488
+ json(): Promise<unknown>;
459
489
  text(): Promise<string>;
460
490
  }
461
491
 
@@ -943,7 +973,10 @@ declare interface EnvironmentNonInheritable {
943
973
  }
944
974
 
945
975
  declare namespace Errors {
946
- class UndiciError extends Error { }
976
+ class UndiciError extends Error {
977
+ name: string;
978
+ code: string;
979
+ }
947
980
 
948
981
  /** Connect timeout error. */
949
982
  class ConnectTimeoutError extends UndiciError {
@@ -970,6 +1003,12 @@ declare namespace Errors {
970
1003
  }
971
1004
 
972
1005
  class ResponseStatusCodeError extends UndiciError {
1006
+ constructor (
1007
+ message?: string,
1008
+ statusCode?: number,
1009
+ headers?: IncomingHttpHeaders | string[] | null,
1010
+ body?: null | Record<string, any> | string
1011
+ );
973
1012
  name: 'ResponseStatusCodeError';
974
1013
  code: 'UND_ERR_RESPONSE_STATUS_CODE';
975
1014
  body: null | Record<string, any> | string
@@ -1469,7 +1508,7 @@ declare interface RequestInit {
1469
1508
  body?: BodyInit
1470
1509
  redirect?: RequestRedirect
1471
1510
  integrity?: string
1472
- signal?: AbortSignal
1511
+ signal?: AbortSignal | null
1473
1512
  credentials?: RequestCredentials
1474
1513
  mode?: RequestMode
1475
1514
  referrer?: string