wrangler 0.0.0-e6c9c5c0 → 0.0.0-e6e1daba

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 (126) hide show
  1. package/README.md +3 -3
  2. package/miniflare-dist/index.mjs +22 -18
  3. package/package.json +12 -12
  4. package/src/__tests__/configuration.test.ts +70 -0
  5. package/src/__tests__/d1/d1.test.ts +13 -58
  6. package/src/__tests__/d1/execute.test.ts +64 -0
  7. package/src/__tests__/d1/migrate.test.ts +155 -0
  8. package/src/__tests__/deployments.test.ts +40 -16
  9. package/src/__tests__/dev.test.tsx +8 -7
  10. package/src/__tests__/generate.test.ts +1 -1
  11. package/src/__tests__/guess-worker-format.test.ts +35 -0
  12. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  13. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  14. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  15. package/src/__tests__/helpers/msw/handlers/deployments.ts +40 -16
  16. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  17. package/src/__tests__/index.test.ts +38 -32
  18. package/src/__tests__/init.test.ts +1 -1
  19. package/src/__tests__/kv.test.ts +63 -52
  20. package/src/__tests__/middleware.test.ts +65 -0
  21. package/src/__tests__/mtls-certificates.test.ts +585 -0
  22. package/src/__tests__/pages/deployment-list.test.ts +78 -0
  23. package/src/__tests__/pages/functions-build.test.ts +402 -0
  24. package/src/__tests__/pages/pages.test.ts +81 -0
  25. package/src/__tests__/pages/project-create.test.ts +63 -0
  26. package/src/__tests__/pages/project-list.test.ts +108 -0
  27. package/src/__tests__/pages/project-upload.test.ts +481 -0
  28. package/src/__tests__/pages/publish.test.ts +2745 -0
  29. package/src/__tests__/parse.test.ts +106 -0
  30. package/src/__tests__/publish.test.ts +80 -30
  31. package/src/__tests__/pubsub.test.ts +15 -12
  32. package/src/__tests__/queues.test.ts +37 -30
  33. package/src/__tests__/r2.test.ts +25 -20
  34. package/src/__tests__/secret.test.ts +4 -4
  35. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  36. package/src/__tests__/user.test.ts +1 -1
  37. package/src/__tests__/whoami.test.tsx +1 -1
  38. package/src/__tests__/worker-namespace.test.ts +26 -21
  39. package/src/api/dev.ts +80 -11
  40. package/src/api/index.ts +8 -0
  41. package/src/api/mtls-certificate.ts +148 -0
  42. package/src/api/pages/create-worker-bundle-contents.ts +75 -0
  43. package/src/api/pages/publish.tsx +59 -12
  44. package/src/bundle.ts +9 -7
  45. package/src/config/config.ts +14 -7
  46. package/src/config/environment.ts +9 -2
  47. package/src/config/index.ts +37 -20
  48. package/src/config/validation.ts +50 -3
  49. package/src/create-worker-preview.ts +19 -8
  50. package/src/create-worker-upload-form.ts +9 -0
  51. package/src/d1/backups.tsx +20 -24
  52. package/src/d1/create.tsx +6 -5
  53. package/src/d1/delete.ts +7 -10
  54. package/src/d1/execute.tsx +174 -143
  55. package/src/d1/index.ts +5 -6
  56. package/src/d1/list.tsx +21 -9
  57. package/src/d1/migrations/apply.tsx +42 -33
  58. package/src/d1/migrations/create.tsx +16 -17
  59. package/src/d1/migrations/helpers.ts +63 -38
  60. package/src/d1/migrations/list.tsx +37 -24
  61. package/src/d1/migrations/options.ts +7 -2
  62. package/src/d1/options.ts +3 -3
  63. package/src/d1/types.ts +1 -0
  64. package/src/d1/utils.ts +2 -1
  65. package/src/delete.ts +5 -8
  66. package/src/deployments.ts +62 -39
  67. package/src/deprecated/index.ts +7 -8
  68. package/src/dev/dev.tsx +1 -15
  69. package/src/dev/local.tsx +5 -6
  70. package/src/dev/remote.tsx +2 -2
  71. package/src/dev.tsx +51 -86
  72. package/src/dispatch-namespace.ts +20 -16
  73. package/src/docs/index.ts +7 -8
  74. package/src/entry.ts +1 -2
  75. package/src/generate/index.ts +6 -8
  76. package/src/index.ts +37 -26
  77. package/src/init.ts +5 -7
  78. package/src/inspect.ts +16 -1
  79. package/src/kv/index.ts +15 -17
  80. package/src/miniflare-cli/assets.ts +9 -8
  81. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  82. package/src/mtls-certificate/cli.ts +155 -0
  83. package/src/pages/build.ts +109 -27
  84. package/src/pages/buildFunctions.ts +32 -31
  85. package/src/pages/deployment-tails.ts +7 -10
  86. package/src/pages/deployments.tsx +6 -4
  87. package/src/pages/dev.ts +19 -19
  88. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  89. package/src/pages/functions.ts +8 -4
  90. package/src/pages/index.ts +3 -3
  91. package/src/pages/projects.tsx +7 -12
  92. package/src/pages/publish.tsx +18 -5
  93. package/src/pages/types.ts +5 -0
  94. package/src/pages/upload.tsx +6 -4
  95. package/src/pages/utils.ts +1 -1
  96. package/src/parse.ts +23 -1
  97. package/src/publish/index.ts +19 -15
  98. package/src/publish/publish.ts +5 -4
  99. package/src/pubsub/pubsub-commands.ts +18 -19
  100. package/src/queues/cli/commands/consumer/add.ts +18 -24
  101. package/src/queues/cli/commands/consumer/index.ts +3 -6
  102. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  103. package/src/queues/cli/commands/create.ts +8 -8
  104. package/src/queues/cli/commands/delete.ts +8 -8
  105. package/src/queues/cli/commands/index.ts +3 -4
  106. package/src/queues/cli/commands/list.ts +8 -8
  107. package/src/r2/helpers.ts +1 -0
  108. package/src/r2/index.ts +28 -28
  109. package/src/secret/index.ts +10 -14
  110. package/src/sites.ts +1 -1
  111. package/src/tail/filters.ts +1 -1
  112. package/src/tail/index.ts +6 -8
  113. package/src/user/user.ts +4 -3
  114. package/src/worker.ts +6 -0
  115. package/src/yargs-types.ts +18 -5
  116. package/templates/checked-fetch.js +9 -1
  117. package/templates/format-dev-errors.ts +1 -0
  118. package/templates/new-worker.ts +3 -0
  119. package/templates/pages-template-plugin.ts +7 -3
  120. package/templates/serve-static-assets.ts +1 -0
  121. package/templates/service-bindings-module-facade.js +1 -0
  122. package/templates/tsconfig.init.json +1 -1
  123. package/templates/tsconfig.tsbuildinfo +1 -1
  124. package/wrangler-dist/cli.d.ts +596 -3
  125. package/wrangler-dist/cli.js +14276 -6748
  126. package/src/__tests__/pages.test.ts +0 -2898
@@ -1,10 +1,21 @@
1
1
  /// <reference types="node" />
2
2
 
3
3
  import { Blob as Blob_2 } from 'buffer';
4
- import Dispatcher = require('./dispatcher');
4
+ import { ConnectionOptions } from 'tls';
5
+ import { Duplex } from 'stream';
6
+ import { EventEmitter } from 'events';
7
+ import { IpcNetConnectOpts } from 'net';
8
+ import { Readable } from 'stream';
5
9
  import { ReadableStream } from 'stream/web';
10
+ import { Socket } from 'net';
11
+ import { TcpNetConnectOpts } from 'net';
12
+ import { TlsOptions } from 'tls';
13
+ import { TLSSocket } from 'tls';
6
14
  import { URL as URL_2 } from 'url';
7
15
  import { URLSearchParams as URLSearchParams_2 } from 'url';
16
+ import { Writable } from 'stream';
17
+
18
+ declare type AbortSignal_2 = unknown;
8
19
 
9
20
  declare interface BlobPropertyBag {
10
21
  type?: string
@@ -33,6 +44,158 @@ declare interface BodyMixin {
33
44
  readonly text: () => Promise<string>
34
45
  }
35
46
 
47
+ declare class BodyReadable extends Readable {
48
+ constructor(
49
+ resume?: (this: Readable, size: number) => void | null,
50
+ abort?: () => void | null,
51
+ contentType?: string
52
+ )
53
+
54
+ /** Consumes and returns the body as a string
55
+ * https://fetch.spec.whatwg.org/#dom-body-text
56
+ */
57
+ text(): Promise<string>
58
+
59
+ /** Consumes and returns the body as a JavaScript Object
60
+ * https://fetch.spec.whatwg.org/#dom-body-json
61
+ */
62
+ json(): Promise<any>
63
+
64
+ /** Consumes and returns the body as a Blob
65
+ * https://fetch.spec.whatwg.org/#dom-body-blob
66
+ */
67
+ blob(): Promise<Blob_2>
68
+
69
+ /** Consumes and returns the body as an ArrayBuffer
70
+ * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
71
+ */
72
+ arrayBuffer(): Promise<ArrayBuffer>
73
+
74
+ /** Not implemented
75
+ *
76
+ * https://fetch.spec.whatwg.org/#dom-body-formdata
77
+ */
78
+ formData(): Promise<never>
79
+
80
+ /** Returns true if the body is not null and the body has been consumed
81
+ *
82
+ * Otherwise, returns false
83
+ *
84
+ * https://fetch.spec.whatwg.org/#dom-body-bodyused
85
+ */
86
+ readonly bodyUsed: boolean
87
+
88
+ /** Throws on node 16.6.0
89
+ *
90
+ * If body is null, it should return null as the body
91
+ *
92
+ * If body is not null, should return the body as a ReadableStream
93
+ *
94
+ * https://fetch.spec.whatwg.org/#dom-body-body
95
+ */
96
+ readonly body: never | undefined
97
+
98
+ /** Dumps the response body by reading `limit` number of bytes.
99
+ * @param opts.limit Number of bytes to read (optional) - Default: 262144
100
+ */
101
+ dump(opts?: { limit: number }): Promise<void>
102
+ }
103
+
104
+ declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
105
+
106
+ declare namespace buildConnector {
107
+ type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
108
+ maxCachedSessions?: number | null;
109
+ socketPath?: string | null;
110
+ timeout?: number | null;
111
+ port?: number;
112
+ keepAlive?: boolean | null;
113
+ keepAliveInitialDelay?: number | null;
114
+ }
115
+
116
+ interface Options {
117
+ hostname: string
118
+ host?: string
119
+ protocol: string
120
+ port: string
121
+ servername?: string
122
+ localAddress?: string | null
123
+ httpSocket?: Socket
124
+ }
125
+
126
+ type Callback = (...args: CallbackArgs) => void
127
+ type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
128
+
129
+ type connector = connectorAsync | connectorSync
130
+
131
+ interface connectorSync {
132
+ (options: buildConnector.Options): Socket | TLSSocket
133
+ }
134
+
135
+ interface connectorAsync {
136
+ (options: buildConnector.Options, callback: buildConnector.Callback): void
137
+ }
138
+ }
139
+
140
+ /** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
141
+ declare class Client extends Dispatcher {
142
+ constructor(url: string | URL_2, options?: Client.Options);
143
+ /** Property to get and set the pipelining factor. */
144
+ pipelining: number;
145
+ /** `true` after `client.close()` has been called. */
146
+ closed: boolean;
147
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
148
+ destroyed: boolean;
149
+ }
150
+
151
+ declare namespace Client {
152
+ 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;
165
+ /** 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;
169
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
170
+ strictContentLength?: boolean;
171
+ /** @deprecated use the connect option instead */
172
+ tls?: TlsOptions | null;
173
+ /** */
174
+ maxRequestsPerClient?: number;
175
+ /** Max response body size in bytes, -1 is disabled */
176
+ maxResponseSize?: number | null;
177
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
178
+ autoSelectFamily?: boolean;
179
+ /** 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
+ autoSelectFamilyAttemptTimeout?: number;
181
+
182
+ interceptors?: {Client: readonly Dispatcher[] | undefined}
183
+ }
184
+
185
+ interface SocketInfo {
186
+ localAddress?: string
187
+ localPort?: number
188
+ remoteAddress?: string
189
+ remotePort?: number
190
+ remoteFamily?: string
191
+ timeout?: number
192
+ bytesWritten?: number
193
+ bytesRead?: number
194
+ }
195
+
196
+
197
+ }
198
+
36
199
  /**
37
200
  * The possible types for a `Rule`.
38
201
  */
@@ -43,6 +206,8 @@ declare type CustomDomainRoute = {
43
206
  custom_domain: boolean;
44
207
  };
45
208
 
209
+ export declare function deleteMTlsCertificate(accountId: string, certificateId: string): Promise<unknown>;
210
+
46
211
  /**
47
212
  * Deprecated upload configuration.
48
213
  */
@@ -74,6 +239,231 @@ declare interface DeprecatedUpload {
74
239
  rules?: Environment["rules"];
75
240
  }
76
241
 
242
+ /** Dispatcher is the core API used to dispatch requests. */
243
+ declare class Dispatcher extends EventEmitter {
244
+ /** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
245
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
246
+ /** Starts two-way communications with the requested resource. */
247
+ connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
248
+ connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
249
+ /** Performs an HTTP request. */
250
+ request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
251
+ request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
252
+ /** For easy use with `stream.pipeline`. */
253
+ pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
254
+ /** A faster version of `Dispatcher.request`. */
255
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
256
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
257
+ /** Upgrade to a different protocol. */
258
+ upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
259
+ upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
260
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
261
+ close(): Promise<void>;
262
+ close(callback: () => void): void;
263
+ /** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
264
+ destroy(): Promise<void>;
265
+ destroy(err: Error | null): Promise<void>;
266
+ destroy(callback: () => void): void;
267
+ destroy(err: Error | null, callback: () => void): void;
268
+
269
+ on(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
270
+ on(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
271
+ on(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
272
+ on(eventName: 'drain', callback: (origin: URL_2) => void): this;
273
+
274
+
275
+ once(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
276
+ once(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
277
+ once(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
278
+ once(eventName: 'drain', callback: (origin: URL_2) => void): this;
279
+
280
+
281
+ off(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
282
+ off(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
283
+ off(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
284
+ off(eventName: 'drain', callback: (origin: URL_2) => void): this;
285
+
286
+
287
+ addListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
288
+ addListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
289
+ addListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
290
+ addListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
291
+
292
+ removeListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
293
+ removeListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
294
+ removeListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
295
+ removeListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
296
+
297
+ prependListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
298
+ prependListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
299
+ prependListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
300
+ prependListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
301
+
302
+ prependOnceListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
303
+ prependOnceListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
304
+ prependOnceListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
305
+ prependOnceListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
306
+
307
+ listeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
308
+ listeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
309
+ listeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
310
+ listeners(eventName: 'drain'): ((origin: URL_2) => void)[];
311
+
312
+ rawListeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
313
+ rawListeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
314
+ rawListeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
315
+ rawListeners(eventName: 'drain'): ((origin: URL_2) => void)[];
316
+
317
+ emit(eventName: 'connect', origin: URL_2, targets: readonly Dispatcher[]): boolean;
318
+ emit(eventName: 'disconnect', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
319
+ emit(eventName: 'connectionError', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
320
+ emit(eventName: 'drain', origin: URL_2): boolean;
321
+ }
322
+
323
+ declare namespace Dispatcher {
324
+ interface DispatchOptions {
325
+ origin?: string | URL_2;
326
+ path: string;
327
+ method: HttpMethod;
328
+ /** Default: `null` */
329
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
330
+ /** Default: `null` */
331
+ headers?: IncomingHttpHeaders | string[] | null;
332
+ /** Query string params to be embedded in the request URL. Default: `null` */
333
+ query?: Record<string, any>;
334
+ /** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
335
+ idempotent?: boolean;
336
+ /** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. */
337
+ blocking?: boolean;
338
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
339
+ upgrade?: boolean | string | null;
340
+ /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
341
+ headersTimeout?: number | null;
342
+ /** 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
+ bodyTimeout?: number | null;
344
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
345
+ reset?: boolean;
346
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
347
+ throwOnError?: boolean;
348
+ }
349
+ interface ConnectOptions {
350
+ path: string;
351
+ /** Default: `null` */
352
+ headers?: IncomingHttpHeaders | string[] | null;
353
+ /** Default: `null` */
354
+ signal?: AbortSignal_2 | EventEmitter | null;
355
+ /** This argument parameter is passed through to `ConnectData` */
356
+ opaque?: unknown;
357
+ /** Default: 0 */
358
+ maxRedirections?: number;
359
+ /** Default: `null` */
360
+ responseHeader?: 'raw' | null;
361
+ }
362
+ interface RequestOptions extends DispatchOptions {
363
+ /** Default: `null` */
364
+ opaque?: unknown;
365
+ /** Default: `null` */
366
+ signal?: AbortSignal_2 | EventEmitter | null;
367
+ /** Default: 0 */
368
+ maxRedirections?: number;
369
+ /** Default: `null` */
370
+ onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
371
+ /** Default: `null` */
372
+ responseHeader?: 'raw' | null;
373
+ }
374
+ interface PipelineOptions extends RequestOptions {
375
+ /** `true` if the `handler` will return an object stream. Default: `false` */
376
+ objectMode?: boolean;
377
+ }
378
+ interface UpgradeOptions {
379
+ path: string;
380
+ /** Default: `'GET'` */
381
+ method?: string;
382
+ /** Default: `null` */
383
+ headers?: IncomingHttpHeaders | string[] | null;
384
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
385
+ protocol?: string;
386
+ /** Default: `null` */
387
+ signal?: AbortSignal_2 | EventEmitter | null;
388
+ /** Default: 0 */
389
+ maxRedirections?: number;
390
+ /** Default: `null` */
391
+ responseHeader?: 'raw' | null;
392
+ }
393
+ interface ConnectData {
394
+ statusCode: number;
395
+ headers: IncomingHttpHeaders;
396
+ socket: Duplex;
397
+ opaque: unknown;
398
+ }
399
+ interface ResponseData {
400
+ statusCode: number;
401
+ headers: IncomingHttpHeaders;
402
+ body: BodyReadable & BodyMixin;
403
+ trailers: Record<string, string>;
404
+ opaque: unknown;
405
+ context: object;
406
+ }
407
+ interface PipelineHandlerData {
408
+ statusCode: number;
409
+ headers: IncomingHttpHeaders;
410
+ opaque: unknown;
411
+ body: BodyReadable;
412
+ context: object;
413
+ }
414
+ interface StreamData {
415
+ opaque: unknown;
416
+ trailers: Record<string, string>;
417
+ }
418
+ interface UpgradeData {
419
+ headers: IncomingHttpHeaders;
420
+ socket: Duplex;
421
+ opaque: unknown;
422
+ }
423
+ interface StreamFactoryData {
424
+ statusCode: number;
425
+ headers: IncomingHttpHeaders;
426
+ opaque: unknown;
427
+ context: object;
428
+ }
429
+ type StreamFactory = (data: StreamFactoryData) => Writable;
430
+ interface DispatchHandlers {
431
+ /** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
432
+ onConnect?(abort: () => void): void;
433
+ /** Invoked when an error has occurred. */
434
+ onError?(err: Error): void;
435
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
436
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
437
+ /** 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;
439
+ /** Invoked when response payload data is received. */
440
+ onData?(chunk: Buffer): boolean;
441
+ /** Invoked when response payload and trailers have been received and the request has completed. */
442
+ onComplete?(trailers: string[] | null): void;
443
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
444
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
445
+ }
446
+ type PipelineHandler = (data: PipelineHandlerData) => Readable;
447
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
448
+
449
+ /**
450
+ * @link https://fetch.spec.whatwg.org/#body-mixin
451
+ */
452
+ interface BodyMixin {
453
+ readonly body?: never; // throws on node v16.6.0
454
+ readonly bodyUsed: boolean;
455
+ arrayBuffer(): Promise<ArrayBuffer>;
456
+ blob(): Promise<Blob_2>;
457
+ formData(): Promise<never>;
458
+ json(): Promise<any>;
459
+ text(): Promise<string>;
460
+ }
461
+
462
+ interface DispatchInterceptor {
463
+ (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
464
+ }
465
+ }
466
+
77
467
  declare type DurableObjectBindings = {
78
468
  /** The name of the binding used to refer to the Durable Object */
79
469
  name: string;
@@ -146,7 +536,7 @@ declare interface EnvironmentInheritable {
146
536
  * Whether we use <name>.<subdomain>.workers.dev to
147
537
  * test and deploy your worker.
148
538
  *
149
- * @default `true` (This is a breaking change from wrangler 1)
539
+ * @default `true` (This is a breaking change from Wrangler v1)
150
540
  * @breaking
151
541
  * @inheritable
152
542
  */
@@ -508,6 +898,127 @@ declare interface EnvironmentNonInheritable {
508
898
  [key: string]: unknown;
509
899
  }[];
510
900
  };
901
+ mtls_certificates: {
902
+ /** The binding name used to refer to the certificate in the worker */
903
+ binding: string;
904
+ /** The uuid of the uploaded mTLS certificate */
905
+ certificate_id: string;
906
+ }[];
907
+ }
908
+
909
+ declare namespace Errors {
910
+ class UndiciError extends Error { }
911
+
912
+ /** Connect timeout error. */
913
+ class ConnectTimeoutError extends UndiciError {
914
+ name: 'ConnectTimeoutError';
915
+ code: 'UND_ERR_CONNECT_TIMEOUT';
916
+ }
917
+
918
+ /** A header exceeds the `headersTimeout` option. */
919
+ class HeadersTimeoutError extends UndiciError {
920
+ name: 'HeadersTimeoutError';
921
+ code: 'UND_ERR_HEADERS_TIMEOUT';
922
+ }
923
+
924
+ /** Headers overflow error. */
925
+ class HeadersOverflowError extends UndiciError {
926
+ name: 'HeadersOverflowError'
927
+ code: 'UND_ERR_HEADERS_OVERFLOW'
928
+ }
929
+
930
+ /** A body exceeds the `bodyTimeout` option. */
931
+ class BodyTimeoutError extends UndiciError {
932
+ name: 'BodyTimeoutError';
933
+ code: 'UND_ERR_BODY_TIMEOUT';
934
+ }
935
+
936
+ class ResponseStatusCodeError extends UndiciError {
937
+ name: 'ResponseStatusCodeError';
938
+ code: 'UND_ERR_RESPONSE_STATUS_CODE';
939
+ body: null | Record<string, any> | string
940
+ status: number
941
+ statusCode: number
942
+ headers: IncomingHttpHeaders | string[] | null;
943
+ }
944
+
945
+ /** Passed an invalid argument. */
946
+ class InvalidArgumentError extends UndiciError {
947
+ name: 'InvalidArgumentError';
948
+ code: 'UND_ERR_INVALID_ARG';
949
+ }
950
+
951
+ /** Returned an invalid value. */
952
+ class InvalidReturnValueError extends UndiciError {
953
+ name: 'InvalidReturnValueError';
954
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
955
+ }
956
+
957
+ /** The request has been aborted by the user. */
958
+ class RequestAbortedError extends UndiciError {
959
+ name: 'AbortError';
960
+ code: 'UND_ERR_ABORTED';
961
+ }
962
+
963
+ /** Expected error with reason. */
964
+ class InformationalError extends UndiciError {
965
+ name: 'InformationalError';
966
+ code: 'UND_ERR_INFO';
967
+ }
968
+
969
+ /** Request body length does not match content-length header. */
970
+ class RequestContentLengthMismatchError extends UndiciError {
971
+ name: 'RequestContentLengthMismatchError';
972
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
973
+ }
974
+
975
+ /** Response body length does not match content-length header. */
976
+ class ResponseContentLengthMismatchError extends UndiciError {
977
+ name: 'ResponseContentLengthMismatchError';
978
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
979
+ }
980
+
981
+ /** Trying to use a destroyed client. */
982
+ class ClientDestroyedError extends UndiciError {
983
+ name: 'ClientDestroyedError';
984
+ code: 'UND_ERR_DESTROYED';
985
+ }
986
+
987
+ /** Trying to use a closed client. */
988
+ class ClientClosedError extends UndiciError {
989
+ name: 'ClientClosedError';
990
+ code: 'UND_ERR_CLOSED';
991
+ }
992
+
993
+ /** There is an error with the socket. */
994
+ class SocketError extends UndiciError {
995
+ name: 'SocketError';
996
+ code: 'UND_ERR_SOCKET';
997
+ socket: Client.SocketInfo | null
998
+ }
999
+
1000
+ /** Encountered unsupported functionality. */
1001
+ class NotSupportedError extends UndiciError {
1002
+ name: 'NotSupportedError';
1003
+ code: 'UND_ERR_NOT_SUPPORTED';
1004
+ }
1005
+
1006
+ /** No upstream has been added to the BalancedPool. */
1007
+ class BalancedPoolMissingUpstreamError extends UndiciError {
1008
+ name: 'MissingUpstreamError';
1009
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
1010
+ }
1011
+
1012
+ class HTTPParserError extends UndiciError {
1013
+ name: 'HTTPParserError';
1014
+ code: string;
1015
+ }
1016
+
1017
+ /** The response exceed the length allowed. */
1018
+ class ResponseExceededMaxSizeError extends UndiciError {
1019
+ name: 'ResponseExceededMaxSizeError';
1020
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
1021
+ }
511
1022
  }
512
1023
 
513
1024
  declare class File extends Blob_2 {
@@ -643,6 +1154,16 @@ declare class FormData {
643
1154
  */
644
1155
  declare type FormDataEntryValue = string | File
645
1156
 
1157
+ /**
1158
+ * fetches an mTLS certificate from the account mTLS certificate store by ID
1159
+ */
1160
+ export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
1161
+
1162
+ /**
1163
+ * fetches an mTLS certificate from the account mTLS certificate store by name. will throw an error if no certificates are found, or multiple are found with that name
1164
+ */
1165
+ export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
1166
+
646
1167
  declare class Headers implements SpecIterable<[string, string]> {
647
1168
  constructor (init?: HeadersInit)
648
1169
  readonly append: (name: string, value: string) => void
@@ -650,6 +1171,7 @@ declare class Headers implements SpecIterable<[string, string]> {
650
1171
  readonly get: (name: string) => string | null
651
1172
  readonly has: (name: string) => boolean
652
1173
  readonly set: (name: string, value: string) => void
1174
+ readonly getSetCookie: () => string[]
653
1175
  readonly forEach: (
654
1176
  callbackfn: (value: string, key: string, iterable: Headers) => void,
655
1177
  thisArg?: unknown
@@ -663,6 +1185,56 @@ declare class Headers implements SpecIterable<[string, string]> {
663
1185
 
664
1186
  declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
665
1187
 
1188
+ /**
1189
+ * The header type declaration of `undici`.
1190
+ */
1191
+ declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1192
+
1193
+ /**
1194
+ * lists mTLS certificates for an account. filtering by name is supported
1195
+ */
1196
+ export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
1197
+
1198
+ /**
1199
+ * details for uploading an mTLS certificate via the ssl api
1200
+ */
1201
+ declare interface MTlsCertificateBody {
1202
+ certificateChain: string;
1203
+ privateKey: string;
1204
+ name?: string;
1205
+ }
1206
+
1207
+ /**
1208
+ * supported filters for listing mTLS certificates via the ssl api
1209
+ */
1210
+ declare interface MTlsCertificateListFilter {
1211
+ name?: string;
1212
+ }
1213
+
1214
+ /**
1215
+ * the representation of an mTLS certificate in the account certificate store
1216
+ */
1217
+ declare interface MTlsCertificateResponse {
1218
+ id: string;
1219
+ name?: string;
1220
+ ca: boolean;
1221
+ certificates: string;
1222
+ expires_on: string;
1223
+ issuer: string;
1224
+ serial_number: string;
1225
+ signature: string;
1226
+ uploaded_on: string;
1227
+ }
1228
+
1229
+ /**
1230
+ * details for uploading an mTLS certificate from disk
1231
+ */
1232
+ declare interface MTlsCertificateUploadDetails {
1233
+ certificateChainFilename: string;
1234
+ privateKeyFilename: string;
1235
+ name?: string;
1236
+ }
1237
+
666
1238
  declare interface PagesPublishOptions {
667
1239
  /**
668
1240
  * Path to static assets to publish to Pages
@@ -709,6 +1281,13 @@ declare interface PagesPublishOptions {
709
1281
  * Default: false
710
1282
  */
711
1283
  bundle?: boolean;
1284
+ /**
1285
+ * Whether to process non-JS module imports or not, such as
1286
+ * wasm/text/binary, when we run bundling on `functions` or
1287
+ * `_worker.js`
1288
+ * Default: false
1289
+ */
1290
+ experimentalWorkerBundle?: boolean;
712
1291
  }
713
1292
 
714
1293
  /**
@@ -716,7 +1295,7 @@ declare interface PagesPublishOptions {
716
1295
  * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
717
1296
  * variable set
718
1297
  */
719
- declare function publish({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesPublishOptions): Promise<{
1298
+ declare function publish({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, experimentalWorkerBundle, }: PagesPublishOptions): Promise<{
720
1299
  environment: "production" | "preview";
721
1300
  id: string;
722
1301
  url: string;
@@ -806,6 +1385,7 @@ declare class Request implements BodyMixin {
806
1385
 
807
1386
  readonly keepalive: boolean
808
1387
  readonly signal: AbortSignal
1388
+ readonly duplex: RequestDuplex
809
1389
 
810
1390
  readonly body: ReadableStream | null
811
1391
  readonly bodyUsed: boolean
@@ -849,6 +1429,8 @@ declare type RequestDestination =
849
1429
  | 'worker'
850
1430
  | 'xslt'
851
1431
 
1432
+ declare type RequestDuplex = 'half'
1433
+
852
1434
  declare type RequestInfo = string | URL_2 | Request
853
1435
 
854
1436
  declare interface RequestInit {
@@ -865,6 +1447,7 @@ declare interface RequestInit {
865
1447
  referrerPolicy?: ReferrerPolicy
866
1448
  window?: null
867
1449
  dispatcher?: Dispatcher
1450
+ duplex?: RequestDuplex
868
1451
  }
869
1452
 
870
1453
  declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
@@ -1013,6 +1596,16 @@ export declare interface UnstableDevWorker {
1013
1596
  waitUntilExit: () => Promise<void>;
1014
1597
  }
1015
1598
 
1599
+ /**
1600
+ * uploads an mTLS certificate and private key pair to the account mTLS certificate store
1601
+ */
1602
+ export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
1603
+
1604
+ /**
1605
+ * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
1606
+ */
1607
+ export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
1608
+
1016
1609
  declare type ZoneIdRoute = {
1017
1610
  pattern: string;
1018
1611
  zone_id: string;