wrangler 0.0.0-e30d1013 → 0.0.0-e311bbbf

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 (236) hide show
  1. package/README.md +3 -3
  2. package/bin/wrangler.js +30 -10
  3. package/miniflare-dist/index.mjs +126 -74
  4. package/package.json +26 -19
  5. package/src/__tests__/api-dev.test.ts +65 -36
  6. package/src/__tests__/api-devregistry.test.ts +121 -0
  7. package/src/__tests__/api.test.ts +27 -5
  8. package/src/__tests__/configuration.test.ts +567 -39
  9. package/src/__tests__/d1/d1.test.ts +82 -0
  10. package/src/__tests__/d1/execute.test.ts +66 -0
  11. package/src/__tests__/d1/migrate.test.ts +157 -0
  12. package/src/__tests__/d1/splitter.test.ts +255 -0
  13. package/src/__tests__/delete.test.ts +91 -49
  14. package/src/__tests__/deployments.test.ts +330 -52
  15. package/src/__tests__/dev.test.tsx +198 -90
  16. package/src/__tests__/generate.test.ts +8 -5
  17. package/src/__tests__/guess-worker-format.test.ts +35 -0
  18. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  19. package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
  20. package/src/__tests__/helpers/mock-console.ts +6 -0
  21. package/src/__tests__/helpers/mock-dialogs.ts +71 -85
  22. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  23. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
  24. package/src/__tests__/helpers/mock-known-routes.ts +7 -2
  25. package/src/__tests__/helpers/mock-kv.ts +29 -16
  26. package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
  27. package/src/__tests__/helpers/mock-process.ts +8 -13
  28. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  29. package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
  30. package/src/__tests__/helpers/msw/handlers/deployments.ts +127 -26
  31. package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
  32. package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
  33. package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
  34. package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
  35. package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
  36. package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
  37. package/src/__tests__/helpers/msw/index.ts +32 -1
  38. package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
  39. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  40. package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
  41. package/src/__tests__/index.test.ts +90 -72
  42. package/src/__tests__/init.test.ts +927 -631
  43. package/src/__tests__/jest.setup.ts +19 -42
  44. package/src/__tests__/kv.test.ts +355 -231
  45. package/src/__tests__/logger.test.ts +68 -2
  46. package/src/__tests__/logout.test.ts +47 -0
  47. package/src/__tests__/metrics.test.ts +94 -51
  48. package/src/__tests__/middleware.scheduled.test.ts +42 -32
  49. package/src/__tests__/middleware.test.ts +212 -122
  50. package/src/__tests__/mtls-certificates.test.ts +588 -0
  51. package/src/__tests__/pages/deployment-list.test.ts +80 -0
  52. package/src/__tests__/pages/functions-build.test.ts +452 -0
  53. package/src/__tests__/pages/pages.test.ts +81 -0
  54. package/src/__tests__/pages/project-create.test.ts +63 -0
  55. package/src/__tests__/pages/project-list.test.ts +110 -0
  56. package/src/__tests__/pages/project-upload.test.ts +500 -0
  57. package/src/__tests__/pages/publish.test.ts +2864 -0
  58. package/src/__tests__/pages-deployment-tail.test.ts +955 -0
  59. package/src/__tests__/parse.test.ts +106 -0
  60. package/src/__tests__/publish.test.ts +1620 -830
  61. package/src/__tests__/pubsub.test.ts +226 -100
  62. package/src/__tests__/queues.test.ts +237 -76
  63. package/src/__tests__/r2.test.ts +37 -56
  64. package/src/__tests__/secret.test.ts +179 -130
  65. package/src/__tests__/tail.test.ts +267 -109
  66. package/src/__tests__/test-old-node-version.js +3 -3
  67. package/src/__tests__/traverse-module-graph.test.ts +220 -0
  68. package/src/__tests__/tsconfig-sanity.ts +12 -0
  69. package/src/__tests__/tsconfig.json +8 -0
  70. package/src/__tests__/tsconfig.tsbuildinfo +1 -0
  71. package/src/__tests__/type-generation.test.ts +11 -2
  72. package/src/__tests__/user.test.ts +35 -72
  73. package/src/__tests__/whoami.test.tsx +8 -114
  74. package/src/__tests__/worker-namespace.test.ts +83 -69
  75. package/src/api/dev.ts +168 -60
  76. package/src/api/index.ts +10 -1
  77. package/src/api/mtls-certificate.ts +148 -0
  78. package/src/api/pages/create-worker-bundle-contents.ts +76 -0
  79. package/src/api/pages/index.ts +5 -0
  80. package/src/api/pages/publish.tsx +355 -0
  81. package/src/bundle.ts +221 -128
  82. package/src/cfetch/index.ts +0 -2
  83. package/src/cfetch/internal.ts +16 -21
  84. package/src/cli.ts +4 -4
  85. package/src/config/config.ts +14 -7
  86. package/src/config/environment.ts +73 -16
  87. package/src/config/index.ts +99 -30
  88. package/src/config/validation-helpers.ts +1 -1
  89. package/src/config/validation.ts +248 -9
  90. package/src/create-worker-preview.ts +19 -8
  91. package/src/create-worker-upload-form.ts +48 -5
  92. package/src/d1/backups.tsx +43 -42
  93. package/src/d1/create.tsx +26 -21
  94. package/src/d1/{delete.tsx → delete.ts} +11 -14
  95. package/src/d1/execute.tsx +183 -170
  96. package/src/d1/index.ts +7 -6
  97. package/src/d1/list.tsx +22 -10
  98. package/src/d1/migrations/apply.tsx +212 -0
  99. package/src/d1/migrations/create.tsx +79 -0
  100. package/src/d1/migrations/helpers.ts +172 -0
  101. package/src/d1/migrations/index.ts +3 -0
  102. package/src/d1/migrations/list.tsx +95 -0
  103. package/src/d1/migrations/options.ts +23 -0
  104. package/src/d1/options.ts +3 -3
  105. package/src/d1/splitter.ts +161 -0
  106. package/src/d1/{types.tsx → types.ts} +1 -0
  107. package/src/d1/utils.ts +2 -1
  108. package/src/delete.ts +8 -16
  109. package/src/deployments.ts +333 -42
  110. package/src/deprecated/index.ts +8 -302
  111. package/src/dev/dev.tsx +57 -44
  112. package/src/dev/local.tsx +248 -74
  113. package/src/dev/remote.tsx +32 -3
  114. package/src/dev/start-server.ts +81 -66
  115. package/src/dev/use-esbuild.ts +17 -18
  116. package/src/dev/validate-dev-props.ts +9 -0
  117. package/src/{dev-registry.tsx → dev-registry.ts} +2 -1
  118. package/src/dev.tsx +178 -117
  119. package/src/dialogs.ts +136 -0
  120. package/src/dispatch-namespace.ts +21 -17
  121. package/src/docs/index.ts +97 -0
  122. package/src/entry.ts +19 -11
  123. package/src/environment-variables/factory.ts +88 -0
  124. package/src/environment-variables/misc-variables.ts +30 -0
  125. package/src/generate/index.ts +298 -0
  126. package/src/git-client.ts +15 -4
  127. package/src/{index.tsx → index.ts} +134 -59
  128. package/src/init.ts +249 -187
  129. package/src/inspect.ts +16 -1
  130. package/src/jest.d.ts +4 -0
  131. package/src/kv/index.ts +15 -17
  132. package/src/logger.ts +32 -5
  133. package/src/metrics/metrics-config.ts +3 -3
  134. package/src/metrics/send-event.ts +6 -1
  135. package/src/miniflare-cli/assets.ts +64 -28
  136. package/src/miniflare-cli/index.ts +4 -7
  137. package/src/miniflare-cli/tsconfig.json +9 -0
  138. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
  139. package/src/miniflare-cli/types.ts +11 -0
  140. package/src/module-collection.ts +91 -25
  141. package/src/mtls-certificate/cli.ts +155 -0
  142. package/src/pages/build.ts +410 -0
  143. package/src/pages/buildFunctions.ts +140 -0
  144. package/src/pages/deployment-tails.ts +281 -0
  145. package/src/pages/deployments.tsx +11 -33
  146. package/src/pages/{dev.tsx → dev.ts} +147 -139
  147. package/src/pages/errors.ts +1 -0
  148. package/src/pages/functions/buildPlugin.ts +61 -54
  149. package/src/pages/functions/buildWorker.ts +159 -33
  150. package/src/pages/functions/tsconfig.json +8 -0
  151. package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
  152. package/src/pages/{functions.tsx → functions.ts} +8 -4
  153. package/src/pages/{index.tsx → index.ts} +11 -3
  154. package/src/pages/projects.tsx +12 -22
  155. package/src/pages/prompt-select-project.tsx +31 -0
  156. package/src/pages/publish.tsx +46 -225
  157. package/src/pages/types.ts +6 -9
  158. package/src/pages/upload.tsx +58 -14
  159. package/src/pages/utils.ts +12 -1
  160. package/src/parse.ts +23 -1
  161. package/src/paths.ts +1 -1
  162. package/src/proxy.ts +5 -0
  163. package/src/publish/index.ts +20 -16
  164. package/src/publish/publish.ts +71 -46
  165. package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
  166. package/src/queues/cli/commands/consumer/add.ts +24 -24
  167. package/src/queues/cli/commands/consumer/index.ts +3 -6
  168. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  169. package/src/queues/cli/commands/create.ts +8 -8
  170. package/src/queues/cli/commands/delete.ts +8 -8
  171. package/src/queues/cli/commands/index.ts +6 -4
  172. package/src/queues/cli/commands/list.ts +8 -8
  173. package/src/queues/client.ts +1 -0
  174. package/src/queues/utils.ts +18 -0
  175. package/src/r2/helpers.ts +1 -0
  176. package/src/r2/index.ts +28 -28
  177. package/src/secret/index.ts +14 -16
  178. package/src/{sites.tsx → sites.ts} +1 -1
  179. package/src/tail/createTail.ts +94 -3
  180. package/src/tail/filters.ts +1 -1
  181. package/src/tail/index.ts +8 -11
  182. package/src/tail/printing.ts +15 -0
  183. package/src/traverse-module-graph.ts +53 -0
  184. package/src/tsconfig-sanity.ts +16 -0
  185. package/src/type-generation.ts +28 -20
  186. package/src/user/access.ts +0 -1
  187. package/src/user/auth-variables.ts +113 -0
  188. package/src/user/choose-account.tsx +1 -31
  189. package/src/user/index.ts +0 -1
  190. package/src/user/{user.tsx → user.ts} +123 -82
  191. package/src/utils/render.ts +93 -0
  192. package/src/{whoami.tsx → whoami.ts} +37 -71
  193. package/src/worker.ts +30 -1
  194. package/src/yargs-types.ts +22 -5
  195. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  196. package/templates/__tests__/tsconfig.json +8 -0
  197. package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
  198. package/templates/checked-fetch.js +9 -3
  199. package/templates/d1-beta-facade.js +51 -3
  200. package/templates/facade.d.ts +14 -0
  201. package/templates/first-party-worker-module-facade.ts +4 -3
  202. package/templates/format-dev-errors.ts +8 -6
  203. package/templates/gitignore +1 -0
  204. package/templates/init-tests/test-jest-new-worker.js +3 -5
  205. package/templates/init-tests/test-vitest-new-worker.js +3 -5
  206. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  207. package/templates/middleware/loader-modules.ts +2 -2
  208. package/templates/middleware/loader-sw.ts +51 -31
  209. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  210. package/templates/new-worker.ts +3 -0
  211. package/templates/pages-dev-pipeline.ts +4 -1
  212. package/templates/pages-shim.ts +4 -1
  213. package/templates/pages-template-plugin.ts +19 -10
  214. package/templates/serve-static-assets.ts +17 -14
  215. package/templates/service-bindings-module-facade.js +1 -0
  216. package/templates/tsconfig-sanity.ts +11 -0
  217. package/templates/tsconfig.init.json +105 -0
  218. package/templates/tsconfig.json +5 -103
  219. package/templates/tsconfig.tsbuildinfo +1 -0
  220. package/wrangler-dist/cli.d.ts +820 -70
  221. package/wrangler-dist/cli.js +68161 -78780
  222. package/wrangler-dist/wasm-sync.wasm +0 -0
  223. package/src/__tests__/api-devregistry.test.js +0 -56
  224. package/src/__tests__/d1.test.ts +0 -74
  225. package/src/__tests__/dialogs.test.tsx +0 -40
  226. package/src/__tests__/helpers/mock-cfetch.ts +0 -333
  227. package/src/__tests__/pages.test.ts +0 -2387
  228. package/src/d1/migrations.tsx +0 -446
  229. package/src/dialogs.tsx +0 -169
  230. package/src/environment-variables.ts +0 -50
  231. package/src/pages/build.tsx +0 -270
  232. package/src/user/env-vars.ts +0 -46
  233. package/templates/experimental-local-cache-stubs.js +0 -27
  234. /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
  235. /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
  236. /package/src/pages/{hash.tsx → hash.ts} +0 -0
@@ -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,63 +239,242 @@ declare interface DeprecatedUpload {
74
239
  rules?: Environment["rules"];
75
240
  }
76
241
 
77
- declare interface DevApiOptions {
78
- testMode?: boolean;
79
- disableExperimentalWarning?: boolean;
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;
80
321
  }
81
322
 
82
- declare interface DevOptions {
83
- config?: string;
84
- env?: string;
85
- ip?: string;
86
- port?: number;
87
- bundle?: boolean;
88
- inspectorPort?: number;
89
- localProtocol?: "http" | "https";
90
- assets?: string;
91
- site?: string;
92
- siteInclude?: string[];
93
- siteExclude?: string[];
94
- nodeCompat?: boolean;
95
- compatibilityDate?: string;
96
- compatibilityFlags?: string[];
97
- persist?: boolean;
98
- persistTo?: string;
99
- liveReload?: boolean;
100
- watch?: boolean;
101
- vars?: {
102
- [key: string]: unknown;
103
- };
104
- kv?: {
105
- binding: string;
106
- id: string;
107
- preview_id?: string;
108
- }[];
109
- durableObjects?: {
110
- name: string;
111
- class_name: string;
112
- script_name?: string | undefined;
113
- environment?: string | undefined;
114
- }[];
115
- r2?: {
116
- binding: string;
117
- bucket_name: string;
118
- preview_bucket_name?: string;
119
- }[];
120
- d1Databases?: Environment["d1_databases"];
121
- showInteractiveDevSession?: boolean;
122
- logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
123
- logPrefix?: string;
124
- inspect?: boolean;
125
- local?: boolean;
126
- forceLocal?: boolean;
127
- enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
128
- _?: (string | number)[];
129
- $0?: string;
130
- testScheduled?: boolean;
131
- experimentalLocal?: boolean;
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
+ }
132
465
  }
133
466
 
467
+ declare type DurableObjectBindings = {
468
+ /** The name of the binding used to refer to the Durable Object */
469
+ name: string;
470
+ /** The exported class name of the Durable Object */
471
+ class_name: string;
472
+ /** The script where the Durable Object is defined (if it's external to this worker) */
473
+ script_name?: string;
474
+ /** The service environment of the script_name to bind to */
475
+ environment?: string;
476
+ }[];
477
+
134
478
  declare interface EnablePagesAssetsServiceBindingOptions {
135
479
  proxyPort?: number;
136
480
  directory?: string;
@@ -188,11 +532,16 @@ declare interface EnvironmentInheritable {
188
532
  * The entrypoint/path to the JavaScript file that will be executed.
189
533
  */
190
534
  main: string | undefined;
535
+ /**
536
+ * The directory in which module rules should be evaluated in a `--no-bundle` worker
537
+ * This defaults to dirname(main) when left undefined
538
+ */
539
+ base_dir: string | undefined;
191
540
  /**
192
541
  * Whether we use <name>.<subdomain>.workers.dev to
193
542
  * test and deploy your worker.
194
543
  *
195
- * @default `true` (This is a breaking change from wrangler 1)
544
+ * @default `true` (This is a breaking change from Wrangler v1)
196
545
  * @breaking
197
546
  * @inheritable
198
547
  */
@@ -403,16 +752,7 @@ declare interface EnvironmentNonInheritable {
403
752
  * @nonInheritable
404
753
  */
405
754
  durable_objects: {
406
- bindings: {
407
- /** The name of the binding used to refer to the Durable Object */
408
- name: string;
409
- /** The exported class name of the Durable Object */
410
- class_name: string;
411
- /** The script where the Durable Object is defined (if it's external to this worker) */
412
- script_name?: string;
413
- /** The service environment of the script_name to bind to */
414
- environment?: string;
415
- }[];
755
+ bindings: DurableObjectBindings;
416
756
  };
417
757
  /**
418
758
  * These specify any Workers KV Namespaces you want to
@@ -435,6 +775,23 @@ declare interface EnvironmentNonInheritable {
435
775
  /** The ID of the KV namespace used during `wrangler dev` */
436
776
  preview_id?: string;
437
777
  }[];
778
+ /**
779
+ * These specify bindings to send email from inside your Worker.
780
+ *
781
+ * NOTE: This field is not automatically inherited from the top level environment,
782
+ * and so must be specified in every named environment.
783
+ *
784
+ * @default `[]`
785
+ * @nonInheritable
786
+ */
787
+ send_email: {
788
+ /** The binding name used to refer to the this binding */
789
+ name: string;
790
+ /** If this binding should be restricted to a specific verified address */
791
+ destination_address?: string;
792
+ /** If this binding should be restricted to a set of verified addresses */
793
+ allowed_destination_addresses?: string[];
794
+ }[];
438
795
  /**
439
796
  * Specifies Queues that are bound to this Worker environment.
440
797
  *
@@ -464,6 +821,8 @@ declare interface EnvironmentNonInheritable {
464
821
  max_retries?: number;
465
822
  /** The queue to send messages that failed to be consumed. */
466
823
  dead_letter_queue?: string;
824
+ /** The maximum number of concurrent consumer Worker invocations. Leaving this unset will allow your consumer to scale to the maximum concurrency needed to keep up with the message backlog. */
825
+ max_concurrency?: number | null;
467
826
  }[];
468
827
  };
469
828
  /**
@@ -525,13 +884,27 @@ declare interface EnvironmentNonInheritable {
525
884
  /** The environment of the service (e.g. production, staging, etc). */
526
885
  environment?: string;
527
886
  }[] | undefined;
887
+ /**
888
+ * Specifies analytics engine datasets that are bound to this Worker environment.
889
+ *
890
+ * NOTE: This field is not automatically inherited from the top level environment,
891
+ * and so must be specified in every named environment.
892
+ *
893
+ * @default `[]`
894
+ * @nonInheritable
895
+ */
896
+ analytics_engine_datasets: {
897
+ /** The binding name used to refer to the dataset in the worker. */
898
+ binding: string;
899
+ /** The name of this dataset to write to. */
900
+ dataset?: string;
901
+ }[];
528
902
  /**
529
903
  * "Unsafe" tables for features that aren't directly supported by wrangler.
530
904
  *
531
905
  * NOTE: This field is not automatically inherited from the top level environment,
532
906
  * and so must be specified in every named environment.
533
907
  *
534
- * @default `{ bindings: [] }`
535
908
  * @nonInheritable
536
909
  */
537
910
  unsafe: {
@@ -539,15 +912,141 @@ declare interface EnvironmentNonInheritable {
539
912
  * A set of bindings that should be put into a Worker's upload metadata without changes. These
540
913
  * can be used to implement bindings for features that haven't released and aren't supported
541
914
  * directly by wrangler or miniflare.
542
- *
543
- * @default []
544
915
  */
545
- bindings: {
916
+ bindings?: {
546
917
  name: string;
547
918
  type: string;
548
919
  [key: string]: unknown;
549
920
  }[];
921
+ /**
922
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
923
+ * here will always be applied to metadata last, so can add new or override existing fields.
924
+ */
925
+ metadata?: {
926
+ [key: string]: string;
927
+ };
550
928
  };
929
+ mtls_certificates: {
930
+ /** The binding name used to refer to the certificate in the worker */
931
+ binding: string;
932
+ /** The uuid of the uploaded mTLS certificate */
933
+ certificate_id: string;
934
+ }[];
935
+ }
936
+
937
+ declare namespace Errors {
938
+ class UndiciError extends Error { }
939
+
940
+ /** Connect timeout error. */
941
+ class ConnectTimeoutError extends UndiciError {
942
+ name: 'ConnectTimeoutError';
943
+ code: 'UND_ERR_CONNECT_TIMEOUT';
944
+ }
945
+
946
+ /** A header exceeds the `headersTimeout` option. */
947
+ class HeadersTimeoutError extends UndiciError {
948
+ name: 'HeadersTimeoutError';
949
+ code: 'UND_ERR_HEADERS_TIMEOUT';
950
+ }
951
+
952
+ /** Headers overflow error. */
953
+ class HeadersOverflowError extends UndiciError {
954
+ name: 'HeadersOverflowError'
955
+ code: 'UND_ERR_HEADERS_OVERFLOW'
956
+ }
957
+
958
+ /** A body exceeds the `bodyTimeout` option. */
959
+ class BodyTimeoutError extends UndiciError {
960
+ name: 'BodyTimeoutError';
961
+ code: 'UND_ERR_BODY_TIMEOUT';
962
+ }
963
+
964
+ class ResponseStatusCodeError extends UndiciError {
965
+ name: 'ResponseStatusCodeError';
966
+ code: 'UND_ERR_RESPONSE_STATUS_CODE';
967
+ body: null | Record<string, any> | string
968
+ status: number
969
+ statusCode: number
970
+ headers: IncomingHttpHeaders | string[] | null;
971
+ }
972
+
973
+ /** Passed an invalid argument. */
974
+ class InvalidArgumentError extends UndiciError {
975
+ name: 'InvalidArgumentError';
976
+ code: 'UND_ERR_INVALID_ARG';
977
+ }
978
+
979
+ /** Returned an invalid value. */
980
+ class InvalidReturnValueError extends UndiciError {
981
+ name: 'InvalidReturnValueError';
982
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
983
+ }
984
+
985
+ /** The request has been aborted by the user. */
986
+ class RequestAbortedError extends UndiciError {
987
+ name: 'AbortError';
988
+ code: 'UND_ERR_ABORTED';
989
+ }
990
+
991
+ /** Expected error with reason. */
992
+ class InformationalError extends UndiciError {
993
+ name: 'InformationalError';
994
+ code: 'UND_ERR_INFO';
995
+ }
996
+
997
+ /** Request body length does not match content-length header. */
998
+ class RequestContentLengthMismatchError extends UndiciError {
999
+ name: 'RequestContentLengthMismatchError';
1000
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
1001
+ }
1002
+
1003
+ /** Response body length does not match content-length header. */
1004
+ class ResponseContentLengthMismatchError extends UndiciError {
1005
+ name: 'ResponseContentLengthMismatchError';
1006
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
1007
+ }
1008
+
1009
+ /** Trying to use a destroyed client. */
1010
+ class ClientDestroyedError extends UndiciError {
1011
+ name: 'ClientDestroyedError';
1012
+ code: 'UND_ERR_DESTROYED';
1013
+ }
1014
+
1015
+ /** Trying to use a closed client. */
1016
+ class ClientClosedError extends UndiciError {
1017
+ name: 'ClientClosedError';
1018
+ code: 'UND_ERR_CLOSED';
1019
+ }
1020
+
1021
+ /** There is an error with the socket. */
1022
+ class SocketError extends UndiciError {
1023
+ name: 'SocketError';
1024
+ code: 'UND_ERR_SOCKET';
1025
+ socket: Client.SocketInfo | null
1026
+ }
1027
+
1028
+ /** Encountered unsupported functionality. */
1029
+ class NotSupportedError extends UndiciError {
1030
+ name: 'NotSupportedError';
1031
+ code: 'UND_ERR_NOT_SUPPORTED';
1032
+ }
1033
+
1034
+ /** No upstream has been added to the BalancedPool. */
1035
+ class BalancedPoolMissingUpstreamError extends UndiciError {
1036
+ name: 'MissingUpstreamError';
1037
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
1038
+ }
1039
+
1040
+ class HTTPParserError extends UndiciError {
1041
+ name: 'HTTPParserError';
1042
+ code: string;
1043
+ }
1044
+
1045
+ /** The response exceed the length allowed. */
1046
+ class ResponseExceededMaxSizeError extends UndiciError {
1047
+ name: 'ResponseExceededMaxSizeError';
1048
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
1049
+ }
551
1050
  }
552
1051
 
553
1052
  declare class File extends Blob_2 {
@@ -683,6 +1182,16 @@ declare class FormData {
683
1182
  */
684
1183
  declare type FormDataEntryValue = string | File
685
1184
 
1185
+ /**
1186
+ * fetches an mTLS certificate from the account mTLS certificate store by ID
1187
+ */
1188
+ export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
1189
+
1190
+ /**
1191
+ * 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
1192
+ */
1193
+ export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
1194
+
686
1195
  declare class Headers implements SpecIterable<[string, string]> {
687
1196
  constructor (init?: HeadersInit)
688
1197
  readonly append: (name: string, value: string) => void
@@ -690,6 +1199,7 @@ declare class Headers implements SpecIterable<[string, string]> {
690
1199
  readonly get: (name: string) => string | null
691
1200
  readonly has: (name: string) => boolean
692
1201
  readonly set: (name: string, value: string) => void
1202
+ readonly getSetCookie: () => string[]
693
1203
  readonly forEach: (
694
1204
  callbackfn: (value: string, key: string, iterable: Headers) => void,
695
1205
  thisArg?: unknown
@@ -703,6 +1213,172 @@ declare class Headers implements SpecIterable<[string, string]> {
703
1213
 
704
1214
  declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
705
1215
 
1216
+ /**
1217
+ * The header type declaration of `undici`.
1218
+ */
1219
+ declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1220
+
1221
+ /**
1222
+ * lists mTLS certificates for an account. filtering by name is supported
1223
+ */
1224
+ export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
1225
+
1226
+ /**
1227
+ * details for uploading an mTLS certificate via the ssl api
1228
+ */
1229
+ declare interface MTlsCertificateBody {
1230
+ certificateChain: string;
1231
+ privateKey: string;
1232
+ name?: string;
1233
+ }
1234
+
1235
+ /**
1236
+ * supported filters for listing mTLS certificates via the ssl api
1237
+ */
1238
+ declare interface MTlsCertificateListFilter {
1239
+ name?: string;
1240
+ }
1241
+
1242
+ /**
1243
+ * the representation of an mTLS certificate in the account certificate store
1244
+ */
1245
+ declare interface MTlsCertificateResponse {
1246
+ id: string;
1247
+ name?: string;
1248
+ ca: boolean;
1249
+ certificates: string;
1250
+ expires_on: string;
1251
+ issuer: string;
1252
+ serial_number: string;
1253
+ signature: string;
1254
+ uploaded_on: string;
1255
+ }
1256
+
1257
+ /**
1258
+ * details for uploading an mTLS certificate from disk
1259
+ */
1260
+ declare interface MTlsCertificateUploadDetails {
1261
+ certificateChainFilename: string;
1262
+ privateKeyFilename: string;
1263
+ name?: string;
1264
+ }
1265
+
1266
+ declare interface PagesPublishOptions {
1267
+ /**
1268
+ * Path to static assets to publish to Pages
1269
+ */
1270
+ directory: string;
1271
+ /**
1272
+ * The Cloudflare Account ID that owns the project that's
1273
+ * being published
1274
+ */
1275
+ accountId: string;
1276
+ /**
1277
+ * The name of the project to be published
1278
+ */
1279
+ projectName: string;
1280
+ /**
1281
+ * Branch name to use. Defaults to production branch
1282
+ */
1283
+ branch?: string;
1284
+ /**
1285
+ * Whether or not to skip local file upload result caching
1286
+ */
1287
+ skipCaching?: boolean;
1288
+ /**
1289
+ * Commit message associated to deployment
1290
+ */
1291
+ commitMessage?: string;
1292
+ /**
1293
+ * Commit hash associated to deployment
1294
+ */
1295
+ commitHash?: string;
1296
+ /**
1297
+ * Whether or not the deployment should be considered to be
1298
+ * in a dirty commit state
1299
+ */
1300
+ commitDirty?: boolean;
1301
+ /**
1302
+ * Path to the project's functions directory. Default uses
1303
+ * the current working directory + /functions since this is
1304
+ * typically called in a CLI
1305
+ */
1306
+ functionsDirectory?: string;
1307
+ /**
1308
+ * Whether to run bundling on `_worker.js` before deploying.
1309
+ * Default: false
1310
+ */
1311
+ bundle?: boolean;
1312
+ }
1313
+
1314
+ /**
1315
+ * Publish a directory to an account/project.
1316
+ * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
1317
+ * variable set
1318
+ */
1319
+ declare function publish({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesPublishOptions): Promise<{
1320
+ environment: "production" | "preview";
1321
+ id: string;
1322
+ url: string;
1323
+ project_name: string;
1324
+ build_config: {
1325
+ build_command: string;
1326
+ destination_dir: string;
1327
+ root_dir: string;
1328
+ web_analytics_tag?: string | undefined;
1329
+ web_analytics_token?: string | undefined;
1330
+ fast_builds?: boolean | undefined;
1331
+ };
1332
+ created_on: string;
1333
+ production_branch: string;
1334
+ project_id: string;
1335
+ deployment_trigger: {
1336
+ type: string;
1337
+ metadata: {
1338
+ branch: string;
1339
+ commit_hash: string;
1340
+ commit_message: string;
1341
+ };
1342
+ };
1343
+ latest_stage: {
1344
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1345
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1346
+ started_on: string | null;
1347
+ ended_on: string | null;
1348
+ };
1349
+ stages: {
1350
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1351
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1352
+ started_on: string | null;
1353
+ ended_on: string | null;
1354
+ }[];
1355
+ aliases: string[];
1356
+ modified_on: string;
1357
+ short_id: string;
1358
+ build_image_major_version: number;
1359
+ kv_namespaces?: any;
1360
+ source?: {
1361
+ type: "github" | "gitlab";
1362
+ config: {
1363
+ owner: string;
1364
+ repo_name: string;
1365
+ production_branch?: string | undefined;
1366
+ pr_comments_enabled?: boolean | undefined;
1367
+ deployments_enabled?: boolean | undefined;
1368
+ production_deployments_enabled?: boolean | undefined;
1369
+ preview_deployment_setting?: "none" | "all" | "custom" | undefined;
1370
+ preview_branch_includes?: string[] | undefined;
1371
+ preview_branch_excludes?: string[] | undefined;
1372
+ };
1373
+ } | undefined;
1374
+ env_vars?: any;
1375
+ durable_object_namespaces?: any;
1376
+ is_skipped?: boolean | undefined;
1377
+ files?: {
1378
+ [x: string]: string | undefined;
1379
+ } | undefined;
1380
+ }>;
1381
+
706
1382
  declare type ReferrerPolicy =
707
1383
  | ''
708
1384
  | 'no-referrer'
@@ -730,6 +1406,7 @@ declare class Request implements BodyMixin {
730
1406
 
731
1407
  readonly keepalive: boolean
732
1408
  readonly signal: AbortSignal
1409
+ readonly duplex: RequestDuplex
733
1410
 
734
1411
  readonly body: ReadableStream | null
735
1412
  readonly bodyUsed: boolean
@@ -773,6 +1450,8 @@ declare type RequestDestination =
773
1450
  | 'worker'
774
1451
  | 'xslt'
775
1452
 
1453
+ declare type RequestDuplex = 'half'
1454
+
776
1455
  declare type RequestInfo = string | URL_2 | Request
777
1456
 
778
1457
  declare interface RequestInit {
@@ -789,6 +1468,7 @@ declare interface RequestInit {
789
1468
  referrerPolicy?: ReferrerPolicy
790
1469
  window?: null
791
1470
  dispatcher?: Dispatcher
1471
+ duplex?: RequestDuplex
792
1472
  }
793
1473
 
794
1474
  declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
@@ -866,7 +1546,67 @@ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
866
1546
  /**
867
1547
  * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
868
1548
  */
869
- export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<UnstableDevWorker>;
1549
+ export declare function unstable_dev(script: string, options?: UnstableDevOptions, apiOptions?: unknown): Promise<UnstableDevWorker>;
1550
+
1551
+ export declare const unstable_pages: {
1552
+ publish: typeof publish;
1553
+ };
1554
+
1555
+ export declare interface UnstableDevOptions {
1556
+ config?: string;
1557
+ env?: string;
1558
+ ip?: string;
1559
+ port?: number;
1560
+ bundle?: boolean;
1561
+ inspectorPort?: number;
1562
+ localProtocol?: "http" | "https";
1563
+ assets?: string;
1564
+ site?: string;
1565
+ siteInclude?: string[];
1566
+ siteExclude?: string[];
1567
+ nodeCompat?: boolean;
1568
+ compatibilityDate?: string;
1569
+ compatibilityFlags?: string[];
1570
+ persist?: boolean;
1571
+ persistTo?: string;
1572
+ vars?: {
1573
+ [key: string]: unknown;
1574
+ };
1575
+ kv?: {
1576
+ binding: string;
1577
+ id: string;
1578
+ preview_id?: string;
1579
+ }[];
1580
+ durableObjects?: {
1581
+ name: string;
1582
+ class_name: string;
1583
+ script_name?: string | undefined;
1584
+ environment?: string | undefined;
1585
+ }[];
1586
+ r2?: {
1587
+ binding: string;
1588
+ bucket_name: string;
1589
+ preview_bucket_name?: string;
1590
+ }[];
1591
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
1592
+ inspect?: boolean;
1593
+ local?: boolean;
1594
+ accountId?: string;
1595
+ experimental?: {
1596
+ d1Databases?: Environment["d1_databases"];
1597
+ disableExperimentalWarning?: boolean;
1598
+ disableDevRegistry?: boolean;
1599
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
1600
+ experimentalLocal?: boolean;
1601
+ experimentalLocalRemoteKv?: boolean;
1602
+ forceLocal?: boolean;
1603
+ liveReload?: boolean;
1604
+ showInteractiveDevSession?: boolean;
1605
+ testMode?: boolean;
1606
+ testScheduled?: boolean;
1607
+ watch?: boolean;
1608
+ };
1609
+ }
870
1610
 
871
1611
  export declare interface UnstableDevWorker {
872
1612
  port: number;
@@ -876,6 +1616,16 @@ export declare interface UnstableDevWorker {
876
1616
  waitUntilExit: () => Promise<void>;
877
1617
  }
878
1618
 
1619
+ /**
1620
+ * uploads an mTLS certificate and private key pair to the account mTLS certificate store
1621
+ */
1622
+ export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
1623
+
1624
+ /**
1625
+ * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
1626
+ */
1627
+ export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
1628
+
879
1629
  declare type ZoneIdRoute = {
880
1630
  pattern: string;
881
1631
  zone_id: string;