wrangler 0.0.0-e7a0cd5b → 0.0.0-e87ad068

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 (255) hide show
  1. package/README.md +3 -3
  2. package/bin/wrangler.js +30 -10
  3. package/miniflare-dist/index.mjs +254 -128
  4. package/package.json +27 -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 +797 -98
  9. package/src/__tests__/constellation.test.ts +371 -0
  10. package/src/__tests__/d1/d1.test.ts +82 -0
  11. package/src/__tests__/d1/execute.test.ts +66 -0
  12. package/src/__tests__/d1/migrate.test.ts +257 -0
  13. package/src/__tests__/d1/splitter.test.ts +255 -0
  14. package/src/__tests__/delete.test.ts +91 -49
  15. package/src/__tests__/deployments.test.ts +330 -56
  16. package/src/__tests__/dev.test.tsx +198 -90
  17. package/src/__tests__/generate.test.ts +12 -10
  18. package/src/__tests__/guess-worker-format.test.ts +35 -0
  19. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  20. package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
  21. package/src/__tests__/helpers/mock-console.ts +6 -0
  22. package/src/__tests__/helpers/mock-dialogs.ts +71 -85
  23. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  24. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
  25. package/src/__tests__/helpers/mock-known-routes.ts +7 -2
  26. package/src/__tests__/helpers/mock-kv.ts +29 -16
  27. package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
  28. package/src/__tests__/helpers/mock-process.ts +8 -13
  29. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  30. package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
  31. package/src/__tests__/helpers/msw/handlers/deployments.ts +128 -27
  32. package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
  33. package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
  34. package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
  35. package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
  36. package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
  37. package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
  38. package/src/__tests__/helpers/msw/index.ts +32 -1
  39. package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
  40. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  41. package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
  42. package/src/__tests__/index.test.ts +92 -72
  43. package/src/__tests__/init.test.ts +1033 -631
  44. package/src/__tests__/jest.setup.ts +19 -42
  45. package/src/__tests__/kv.test.ts +355 -231
  46. package/src/__tests__/logger.test.ts +68 -2
  47. package/src/__tests__/logout.test.ts +47 -0
  48. package/src/__tests__/metrics.test.ts +94 -51
  49. package/src/__tests__/middleware.scheduled.test.ts +42 -32
  50. package/src/__tests__/middleware.test.ts +212 -122
  51. package/src/__tests__/mtls-certificates.test.ts +589 -0
  52. package/src/__tests__/pages/deployment-list.test.ts +80 -0
  53. package/src/__tests__/pages/functions-build.test.ts +529 -0
  54. package/src/__tests__/pages/pages.test.ts +81 -0
  55. package/src/__tests__/pages/project-create.test.ts +63 -0
  56. package/src/__tests__/pages/project-list.test.ts +110 -0
  57. package/src/__tests__/pages/project-upload.test.ts +500 -0
  58. package/src/__tests__/pages/publish.test.ts +2864 -0
  59. package/src/__tests__/pages-deployment-tail.test.ts +957 -0
  60. package/src/__tests__/parse.test.ts +106 -0
  61. package/src/__tests__/publish.test.ts +2227 -1005
  62. package/src/__tests__/pubsub.test.ts +226 -100
  63. package/src/__tests__/queues.test.ts +238 -77
  64. package/src/__tests__/r2.test.ts +55 -57
  65. package/src/__tests__/secret.test.ts +179 -130
  66. package/src/__tests__/tail.test.ts +313 -113
  67. package/src/__tests__/test-old-node-version.js +3 -3
  68. package/src/__tests__/traverse-module-graph.test.ts +220 -0
  69. package/src/__tests__/tsconfig-sanity.ts +12 -0
  70. package/src/__tests__/tsconfig.json +8 -0
  71. package/src/__tests__/tsconfig.tsbuildinfo +1 -0
  72. package/src/__tests__/type-generation.test.ts +43 -26
  73. package/src/__tests__/unstableDev.test.ts +61 -0
  74. package/src/__tests__/user.test.ts +35 -72
  75. package/src/__tests__/whoami.test.tsx +8 -114
  76. package/src/__tests__/worker-namespace.test.ts +83 -69
  77. package/src/api/dev.ts +180 -60
  78. package/src/api/index.ts +10 -1
  79. package/src/api/mtls-certificate.ts +148 -0
  80. package/src/api/pages/create-worker-bundle-contents.ts +80 -0
  81. package/src/api/pages/index.ts +5 -0
  82. package/src/api/pages/publish.tsx +371 -0
  83. package/src/bundle.ts +315 -148
  84. package/src/cfetch/index.ts +0 -2
  85. package/src/cfetch/internal.ts +33 -33
  86. package/src/cli.ts +4 -4
  87. package/src/config/config.ts +14 -7
  88. package/src/config/environment.ts +120 -24
  89. package/src/config/index.ts +117 -35
  90. package/src/config/validation-helpers.ts +1 -1
  91. package/src/config/validation.ts +430 -19
  92. package/src/constellation/createProject.tsx +51 -0
  93. package/src/constellation/deleteProject.ts +51 -0
  94. package/src/constellation/deleteProjectModel.ts +76 -0
  95. package/src/constellation/index.ts +75 -0
  96. package/src/constellation/listCatalog.tsx +35 -0
  97. package/src/constellation/listModel.tsx +49 -0
  98. package/src/constellation/listProject.tsx +28 -0
  99. package/src/constellation/listRuntime.tsx +28 -0
  100. package/src/constellation/options.ts +17 -0
  101. package/src/constellation/types.ts +17 -0
  102. package/src/constellation/uploadModel.tsx +84 -0
  103. package/src/constellation/utils.ts +90 -0
  104. package/src/create-worker-preview.ts +19 -8
  105. package/src/create-worker-upload-form.ts +81 -18
  106. package/src/d1/backups.tsx +47 -46
  107. package/src/d1/constants.ts +5 -0
  108. package/src/d1/create.tsx +85 -37
  109. package/src/d1/{delete.tsx → delete.ts} +12 -15
  110. package/src/d1/execute.tsx +228 -156
  111. package/src/d1/index.ts +31 -7
  112. package/src/d1/list.tsx +27 -13
  113. package/src/d1/migrations/apply.tsx +235 -0
  114. package/src/d1/migrations/create.tsx +79 -0
  115. package/src/d1/migrations/helpers.ts +171 -0
  116. package/src/d1/migrations/index.ts +3 -0
  117. package/src/d1/migrations/list.tsx +95 -0
  118. package/src/d1/migrations/options.ts +23 -0
  119. package/src/d1/options.ts +12 -2
  120. package/src/d1/splitter.ts +161 -0
  121. package/src/d1/types.ts +32 -0
  122. package/src/d1/utils.ts +12 -2
  123. package/src/delete.ts +8 -16
  124. package/src/deployments.ts +340 -46
  125. package/src/deprecated/index.ts +8 -302
  126. package/src/dev/dev.tsx +66 -46
  127. package/src/dev/local.tsx +339 -104
  128. package/src/dev/remote.tsx +36 -3
  129. package/src/dev/start-server.ts +146 -101
  130. package/src/dev/use-esbuild.ts +82 -56
  131. package/src/dev/validate-dev-props.ts +9 -0
  132. package/src/{dev-registry.tsx → dev-registry.ts} +13 -1
  133. package/src/dev.tsx +202 -125
  134. package/src/dialogs.ts +136 -0
  135. package/src/dispatch-namespace.ts +21 -17
  136. package/src/docs/helpers.ts +50 -0
  137. package/src/docs/index.ts +54 -0
  138. package/src/entry.ts +26 -11
  139. package/src/environment-variables/factory.ts +89 -0
  140. package/src/environment-variables/misc-variables.ts +30 -0
  141. package/src/generate/index.ts +303 -0
  142. package/src/git-client.ts +15 -4
  143. package/src/{index.tsx → index.ts} +148 -63
  144. package/src/init.ts +301 -197
  145. package/src/inspect.ts +122 -6
  146. package/src/jest.d.ts +4 -0
  147. package/src/kv/helpers.ts +7 -4
  148. package/src/kv/index.ts +15 -17
  149. package/src/logger.ts +36 -5
  150. package/src/metrics/metrics-config.ts +3 -3
  151. package/src/metrics/send-event.ts +6 -1
  152. package/src/miniflare-cli/assets.ts +64 -28
  153. package/src/miniflare-cli/index.ts +6 -9
  154. package/src/miniflare-cli/tsconfig.json +9 -0
  155. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
  156. package/src/miniflare-cli/types.ts +11 -0
  157. package/src/module-collection.ts +92 -26
  158. package/src/mtls-certificate/cli.ts +155 -0
  159. package/src/pages/build.ts +423 -0
  160. package/src/pages/buildFunctions.ts +140 -0
  161. package/src/pages/deployment-tails.ts +281 -0
  162. package/src/pages/deployments.tsx +11 -33
  163. package/src/pages/{dev.tsx → dev.ts} +192 -126
  164. package/src/pages/errors.ts +1 -0
  165. package/src/pages/functions/buildPlugin.ts +73 -69
  166. package/src/pages/functions/buildWorker.ts +342 -117
  167. package/src/pages/functions/tsconfig.json +8 -0
  168. package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
  169. package/src/pages/{functions.tsx → functions.ts} +8 -4
  170. package/src/pages/{index.tsx → index.ts} +11 -3
  171. package/src/pages/projects.tsx +12 -22
  172. package/src/pages/prompt-select-project.tsx +31 -0
  173. package/src/pages/publish.tsx +45 -214
  174. package/src/pages/types.ts +6 -9
  175. package/src/pages/upload.tsx +58 -14
  176. package/src/pages/utils.ts +14 -3
  177. package/src/parse.ts +23 -1
  178. package/src/paths.ts +1 -1
  179. package/src/proxy.ts +5 -0
  180. package/src/publish/index.ts +20 -16
  181. package/src/publish/publish.ts +81 -48
  182. package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
  183. package/src/queues/cli/commands/consumer/add.ts +24 -24
  184. package/src/queues/cli/commands/consumer/index.ts +3 -6
  185. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  186. package/src/queues/cli/commands/create.ts +8 -8
  187. package/src/queues/cli/commands/delete.ts +8 -8
  188. package/src/queues/cli/commands/index.ts +6 -4
  189. package/src/queues/cli/commands/list.ts +8 -8
  190. package/src/queues/client.ts +1 -0
  191. package/src/queues/utils.ts +18 -0
  192. package/src/r2/constants.ts +4 -0
  193. package/src/r2/helpers.ts +1 -0
  194. package/src/r2/index.ts +40 -28
  195. package/src/secret/index.ts +18 -17
  196. package/src/{sites.tsx → sites.ts} +165 -53
  197. package/src/tail/createTail.ts +103 -3
  198. package/src/tail/filters.ts +1 -1
  199. package/src/tail/index.ts +8 -11
  200. package/src/tail/printing.ts +27 -0
  201. package/src/traverse-module-graph.ts +54 -0
  202. package/src/tsconfig-sanity.ts +16 -0
  203. package/src/type-generation.ts +85 -57
  204. package/src/user/access.ts +0 -1
  205. package/src/user/auth-variables.ts +113 -0
  206. package/src/user/choose-account.tsx +1 -31
  207. package/src/user/index.ts +0 -1
  208. package/src/user/{user.tsx → user.ts} +124 -82
  209. package/src/utils/render.ts +93 -0
  210. package/src/{whoami.tsx → whoami.ts} +37 -71
  211. package/src/worker.ts +61 -3
  212. package/src/yargs-types.ts +22 -5
  213. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  214. package/templates/__tests__/tsconfig.json +8 -0
  215. package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
  216. package/templates/checked-fetch.js +9 -3
  217. package/templates/d1-beta-facade.js +95 -25
  218. package/templates/facade.d.ts +14 -0
  219. package/templates/first-party-worker-module-facade.ts +4 -3
  220. package/templates/format-dev-errors.ts +8 -6
  221. package/templates/gitignore +1 -0
  222. package/templates/init-tests/test-jest-new-worker.js +3 -5
  223. package/templates/init-tests/test-vitest-new-worker.js +3 -5
  224. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  225. package/templates/middleware/loader-modules.ts +2 -2
  226. package/templates/middleware/loader-sw.ts +51 -31
  227. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  228. package/templates/new-worker.ts +3 -0
  229. package/templates/pages-dev-pipeline.ts +4 -1
  230. package/templates/pages-dev-util.ts +4 -1
  231. package/templates/pages-shim.ts +4 -1
  232. package/templates/pages-template-plugin.ts +19 -10
  233. package/templates/serve-static-assets.ts +17 -14
  234. package/templates/service-bindings-module-facade.js +1 -0
  235. package/templates/tsconfig-sanity.ts +11 -0
  236. package/templates/tsconfig.init.json +105 -0
  237. package/templates/tsconfig.json +5 -103
  238. package/templates/tsconfig.tsbuildinfo +1 -0
  239. package/wrangler-dist/cli.d.ts +902 -77
  240. package/wrangler-dist/cli.js +131685 -140615
  241. package/wrangler-dist/wasm-sync.wasm +0 -0
  242. package/src/__tests__/api-devregistry.test.js +0 -57
  243. package/src/__tests__/d1.test.ts +0 -72
  244. package/src/__tests__/dialogs.test.tsx +0 -40
  245. package/src/__tests__/helpers/mock-cfetch.ts +0 -333
  246. package/src/__tests__/pages.test.ts +0 -2223
  247. package/src/d1/types.tsx +0 -14
  248. package/src/dialogs.tsx +0 -163
  249. package/src/environment-variables.ts +0 -50
  250. package/src/pages/build.tsx +0 -238
  251. package/src/user/env-vars.ts +0 -46
  252. package/templates/experimental-local-cache-stubs.js +0 -27
  253. /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
  254. /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
  255. /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,193 @@ 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
+ /**
141
+ * An imported module.
142
+ */
143
+ declare interface CfModule {
144
+ /**
145
+ * The module name.
146
+ *
147
+ * @example
148
+ * './src/index.js'
149
+ */
150
+ name: string;
151
+ /**
152
+ * The module content, usually JavaScript or WASM code.
153
+ *
154
+ * @example
155
+ * export default {
156
+ * async fetch(request) {
157
+ * return new Response('Ok')
158
+ * }
159
+ * }
160
+ */
161
+ content: string | Buffer;
162
+ /**
163
+ * The module type.
164
+ *
165
+ * If absent, will default to the main module's type.
166
+ */
167
+ type?: CfModuleType;
168
+ }
169
+
170
+ /**
171
+ * A module type.
172
+ */
173
+ declare type CfModuleType = "esm" | "commonjs" | "compiled-wasm" | "text" | "buffer";
174
+
175
+ /** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
176
+ declare class Client extends Dispatcher {
177
+ constructor(url: string | URL_2, options?: Client.Options);
178
+ /** Property to get and set the pipelining factor. */
179
+ pipelining: number;
180
+ /** `true` after `client.close()` has been called. */
181
+ closed: boolean;
182
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
183
+ destroyed: boolean;
184
+ }
185
+
186
+ declare namespace Client {
187
+ interface Options {
188
+ /** 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). */
189
+ keepAliveTimeout?: number | null;
190
+ /** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
191
+ keepAliveMaxTimeout?: number | null;
192
+ /** 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). */
193
+ keepAliveTimeoutThreshold?: number | null;
194
+ /** 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`. */
195
+ pipelining?: number | null;
196
+ /** **/
197
+ connect?: buildConnector.BuildOptions | buildConnector.connector | null;
198
+ /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
199
+ maxHeaderSize?: number | null;
200
+ /** 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). */
201
+ bodyTimeout?: number | null;
202
+ /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
203
+ headersTimeout?: number | null;
204
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
205
+ strictContentLength?: boolean;
206
+ /** @deprecated use the connect option instead */
207
+ tls?: TlsOptions | null;
208
+ /** */
209
+ maxRequestsPerClient?: number;
210
+ /** Max response body size in bytes, -1 is disabled */
211
+ maxResponseSize?: number | null;
212
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
213
+ autoSelectFamily?: boolean;
214
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
215
+ autoSelectFamilyAttemptTimeout?: number;
216
+
217
+ interceptors?: {Client: readonly Dispatcher[] | undefined}
218
+ }
219
+
220
+ interface SocketInfo {
221
+ localAddress?: string
222
+ localPort?: number
223
+ remoteAddress?: string
224
+ remotePort?: number
225
+ remoteFamily?: string
226
+ timeout?: number
227
+ bytesWritten?: number
228
+ bytesRead?: number
229
+ }
230
+
231
+
232
+ }
233
+
36
234
  /**
37
235
  * The possible types for a `Rule`.
38
236
  */
@@ -43,6 +241,8 @@ declare type CustomDomainRoute = {
43
241
  custom_domain: boolean;
44
242
  };
45
243
 
244
+ export declare function deleteMTlsCertificate(accountId: string, certificateId: string): Promise<unknown>;
245
+
46
246
  /**
47
247
  * Deprecated upload configuration.
48
248
  */
@@ -74,63 +274,242 @@ declare interface DeprecatedUpload {
74
274
  rules?: Environment["rules"];
75
275
  }
76
276
 
77
- declare interface DevApiOptions {
78
- testMode?: boolean;
79
- disableExperimentalWarning?: boolean;
277
+ /** Dispatcher is the core API used to dispatch requests. */
278
+ declare class Dispatcher extends EventEmitter {
279
+ /** 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. */
280
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
281
+ /** Starts two-way communications with the requested resource. */
282
+ connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
283
+ connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
284
+ /** Performs an HTTP request. */
285
+ request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
286
+ request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
287
+ /** For easy use with `stream.pipeline`. */
288
+ pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
289
+ /** A faster version of `Dispatcher.request`. */
290
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
291
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
292
+ /** Upgrade to a different protocol. */
293
+ upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
294
+ upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
295
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
296
+ close(): Promise<void>;
297
+ close(callback: () => void): void;
298
+ /** 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. */
299
+ destroy(): Promise<void>;
300
+ destroy(err: Error | null): Promise<void>;
301
+ destroy(callback: () => void): void;
302
+ destroy(err: Error | null, callback: () => void): void;
303
+
304
+ on(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
305
+ on(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
306
+ on(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
307
+ on(eventName: 'drain', callback: (origin: URL_2) => void): this;
308
+
309
+
310
+ once(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
311
+ once(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
312
+ once(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
313
+ once(eventName: 'drain', callback: (origin: URL_2) => void): this;
314
+
315
+
316
+ off(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
317
+ off(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
318
+ off(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
319
+ off(eventName: 'drain', callback: (origin: URL_2) => void): this;
320
+
321
+
322
+ addListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
323
+ addListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
324
+ addListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
325
+ addListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
326
+
327
+ removeListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
328
+ removeListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
329
+ removeListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
330
+ removeListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
331
+
332
+ prependListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
333
+ prependListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
334
+ prependListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
335
+ prependListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
336
+
337
+ prependOnceListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
338
+ prependOnceListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
339
+ prependOnceListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
340
+ prependOnceListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
341
+
342
+ listeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
343
+ listeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
344
+ listeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
345
+ listeners(eventName: 'drain'): ((origin: URL_2) => void)[];
346
+
347
+ rawListeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
348
+ rawListeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
349
+ rawListeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
350
+ rawListeners(eventName: 'drain'): ((origin: URL_2) => void)[];
351
+
352
+ emit(eventName: 'connect', origin: URL_2, targets: readonly Dispatcher[]): boolean;
353
+ emit(eventName: 'disconnect', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
354
+ emit(eventName: 'connectionError', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
355
+ emit(eventName: 'drain', origin: URL_2): boolean;
80
356
  }
81
357
 
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;
358
+ declare namespace Dispatcher {
359
+ interface DispatchOptions {
360
+ origin?: string | URL_2;
361
+ path: string;
362
+ method: HttpMethod;
363
+ /** Default: `null` */
364
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
365
+ /** Default: `null` */
366
+ headers?: IncomingHttpHeaders | string[] | null;
367
+ /** Query string params to be embedded in the request URL. Default: `null` */
368
+ query?: Record<string, any>;
369
+ /** 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`. */
370
+ idempotent?: boolean;
371
+ /** 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. */
372
+ blocking?: boolean;
373
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
374
+ upgrade?: boolean | string | null;
375
+ /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
376
+ headersTimeout?: number | null;
377
+ /** 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. */
378
+ bodyTimeout?: number | null;
379
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
380
+ reset?: boolean;
381
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
382
+ throwOnError?: boolean;
383
+ }
384
+ interface ConnectOptions {
385
+ path: string;
386
+ /** Default: `null` */
387
+ headers?: IncomingHttpHeaders | string[] | null;
388
+ /** Default: `null` */
389
+ signal?: AbortSignal_2 | EventEmitter | null;
390
+ /** This argument parameter is passed through to `ConnectData` */
391
+ opaque?: unknown;
392
+ /** Default: 0 */
393
+ maxRedirections?: number;
394
+ /** Default: `null` */
395
+ responseHeader?: 'raw' | null;
396
+ }
397
+ interface RequestOptions extends DispatchOptions {
398
+ /** Default: `null` */
399
+ opaque?: unknown;
400
+ /** Default: `null` */
401
+ signal?: AbortSignal_2 | EventEmitter | null;
402
+ /** Default: 0 */
403
+ maxRedirections?: number;
404
+ /** Default: `null` */
405
+ onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
406
+ /** Default: `null` */
407
+ responseHeader?: 'raw' | null;
408
+ }
409
+ interface PipelineOptions extends RequestOptions {
410
+ /** `true` if the `handler` will return an object stream. Default: `false` */
411
+ objectMode?: boolean;
412
+ }
413
+ interface UpgradeOptions {
414
+ path: string;
415
+ /** Default: `'GET'` */
416
+ method?: string;
417
+ /** Default: `null` */
418
+ headers?: IncomingHttpHeaders | string[] | null;
419
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
420
+ protocol?: string;
421
+ /** Default: `null` */
422
+ signal?: AbortSignal_2 | EventEmitter | null;
423
+ /** Default: 0 */
424
+ maxRedirections?: number;
425
+ /** Default: `null` */
426
+ responseHeader?: 'raw' | null;
427
+ }
428
+ interface ConnectData {
429
+ statusCode: number;
430
+ headers: IncomingHttpHeaders;
431
+ socket: Duplex;
432
+ opaque: unknown;
433
+ }
434
+ interface ResponseData {
435
+ statusCode: number;
436
+ headers: IncomingHttpHeaders;
437
+ body: BodyReadable & BodyMixin;
438
+ trailers: Record<string, string>;
439
+ opaque: unknown;
440
+ context: object;
441
+ }
442
+ interface PipelineHandlerData {
443
+ statusCode: number;
444
+ headers: IncomingHttpHeaders;
445
+ opaque: unknown;
446
+ body: BodyReadable;
447
+ context: object;
448
+ }
449
+ interface StreamData {
450
+ opaque: unknown;
451
+ trailers: Record<string, string>;
452
+ }
453
+ interface UpgradeData {
454
+ headers: IncomingHttpHeaders;
455
+ socket: Duplex;
456
+ opaque: unknown;
457
+ }
458
+ interface StreamFactoryData {
459
+ statusCode: number;
460
+ headers: IncomingHttpHeaders;
461
+ opaque: unknown;
462
+ context: object;
463
+ }
464
+ type StreamFactory = (data: StreamFactoryData) => Writable;
465
+ interface DispatchHandlers {
466
+ /** 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. */
467
+ onConnect?(abort: () => void): void;
468
+ /** Invoked when an error has occurred. */
469
+ onError?(err: Error): void;
470
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
471
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
472
+ /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
473
+ onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void): boolean;
474
+ /** Invoked when response payload data is received. */
475
+ onData?(chunk: Buffer): boolean;
476
+ /** Invoked when response payload and trailers have been received and the request has completed. */
477
+ onComplete?(trailers: string[] | null): void;
478
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
479
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
480
+ }
481
+ type PipelineHandler = (data: PipelineHandlerData) => Readable;
482
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
483
+
484
+ /**
485
+ * @link https://fetch.spec.whatwg.org/#body-mixin
486
+ */
487
+ interface BodyMixin {
488
+ readonly body?: never; // throws on node v16.6.0
489
+ readonly bodyUsed: boolean;
490
+ arrayBuffer(): Promise<ArrayBuffer>;
491
+ blob(): Promise<Blob_2>;
492
+ formData(): Promise<never>;
493
+ json(): Promise<any>;
494
+ text(): Promise<string>;
495
+ }
496
+
497
+ interface DispatchInterceptor {
498
+ (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
499
+ }
132
500
  }
133
501
 
502
+ declare type DurableObjectBindings = {
503
+ /** The name of the binding used to refer to the Durable Object */
504
+ name: string;
505
+ /** The exported class name of the Durable Object */
506
+ class_name: string;
507
+ /** The script where the Durable Object is defined (if it's external to this worker) */
508
+ script_name?: string;
509
+ /** The service environment of the script_name to bind to */
510
+ environment?: string;
511
+ }[];
512
+
134
513
  declare interface EnablePagesAssetsServiceBindingOptions {
135
514
  proxyPort?: number;
136
515
  directory?: string;
@@ -188,11 +567,16 @@ declare interface EnvironmentInheritable {
188
567
  * The entrypoint/path to the JavaScript file that will be executed.
189
568
  */
190
569
  main: string | undefined;
570
+ /**
571
+ * The directory in which module rules should be evaluated in a `--no-bundle` worker
572
+ * This defaults to dirname(main) when left undefined
573
+ */
574
+ base_dir: string | undefined;
191
575
  /**
192
576
  * Whether we use <name>.<subdomain>.workers.dev to
193
577
  * test and deploy your worker.
194
578
  *
195
- * @default `true` (This is a breaking change from wrangler 1)
579
+ * @default `true` (This is a breaking change from Wrangler v1)
196
580
  * @breaking
197
581
  * @inheritable
198
582
  */
@@ -358,6 +742,14 @@ declare interface EnvironmentInheritable {
358
742
  * @inheritable
359
743
  */
360
744
  logpush: boolean | undefined;
745
+ /**
746
+ * Specify how the worker should be located to minimize round-trip time.
747
+ *
748
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
749
+ */
750
+ placement: {
751
+ mode: "off" | "smart";
752
+ } | undefined;
361
753
  }
362
754
 
363
755
  /**
@@ -390,13 +782,6 @@ declare interface EnvironmentNonInheritable {
390
782
  vars: {
391
783
  [key: string]: unknown;
392
784
  };
393
- /**
394
- * Specifies namespace binding that is bound to this Worker environment.
395
- * It allows for access at runtime to the Workers metadata.
396
- * @default `undefined`
397
- * @nonInheritable
398
- **/
399
- metadata_binding: string | undefined;
400
785
  /**
401
786
  * A list of durable objects that your worker should be bound to.
402
787
  *
@@ -410,16 +795,7 @@ declare interface EnvironmentNonInheritable {
410
795
  * @nonInheritable
411
796
  */
412
797
  durable_objects: {
413
- bindings: {
414
- /** The name of the binding used to refer to the Durable Object */
415
- name: string;
416
- /** The exported class name of the Durable Object */
417
- class_name: string;
418
- /** The script where the Durable Object is defined (if it's external to this worker) */
419
- script_name?: string;
420
- /** The service environment of the script_name to bind to */
421
- environment?: string;
422
- }[];
798
+ bindings: DurableObjectBindings;
423
799
  };
424
800
  /**
425
801
  * These specify any Workers KV Namespaces you want to
@@ -442,6 +818,23 @@ declare interface EnvironmentNonInheritable {
442
818
  /** The ID of the KV namespace used during `wrangler dev` */
443
819
  preview_id?: string;
444
820
  }[];
821
+ /**
822
+ * These specify bindings to send email from inside your Worker.
823
+ *
824
+ * NOTE: This field is not automatically inherited from the top level environment,
825
+ * and so must be specified in every named environment.
826
+ *
827
+ * @default `[]`
828
+ * @nonInheritable
829
+ */
830
+ send_email: {
831
+ /** The binding name used to refer to the this binding */
832
+ name: string;
833
+ /** If this binding should be restricted to a specific verified address */
834
+ destination_address?: string;
835
+ /** If this binding should be restricted to a set of verified addresses */
836
+ allowed_destination_addresses?: string[];
837
+ }[];
445
838
  /**
446
839
  * Specifies Queues that are bound to this Worker environment.
447
840
  *
@@ -471,6 +864,8 @@ declare interface EnvironmentNonInheritable {
471
864
  max_retries?: number;
472
865
  /** The queue to send messages that failed to be consumed. */
473
866
  dead_letter_queue?: string;
867
+ /** 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. */
868
+ max_concurrency?: number | null;
474
869
  }[];
475
870
  };
476
871
  /**
@@ -508,6 +903,27 @@ declare interface EnvironmentNonInheritable {
508
903
  database_id: string;
509
904
  /** The UUID of this D1 database for Wrangler Dev (if specified). */
510
905
  preview_database_id?: string;
906
+ /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
907
+ migrations_table?: string;
908
+ /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
909
+ migrations_dir?: string;
910
+ /** Internal use only. */
911
+ database_internal_env?: string;
912
+ }[];
913
+ /**
914
+ * Specifies Constellation projects that are bound to this Worker environment.
915
+ *
916
+ * NOTE: This field is not automatically inherited from the top level environment,
917
+ * and so must be specified in every named environment.
918
+ *
919
+ * @default `[]`
920
+ * @nonInheritable
921
+ */
922
+ constellation: {
923
+ /** The binding name used to refer to the project in the worker. */
924
+ binding: string;
925
+ /** The id of the project. */
926
+ project_id: string;
511
927
  }[];
512
928
  /**
513
929
  * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
@@ -526,13 +942,33 @@ declare interface EnvironmentNonInheritable {
526
942
  /** The environment of the service (e.g. production, staging, etc). */
527
943
  environment?: string;
528
944
  }[] | undefined;
945
+ /**
946
+ * Specifies analytics engine datasets that are bound to this Worker environment.
947
+ *
948
+ * NOTE: This field is not automatically inherited from the top level environment,
949
+ * and so must be specified in every named environment.
950
+ *
951
+ * @default `[]`
952
+ * @nonInheritable
953
+ */
954
+ analytics_engine_datasets: {
955
+ /** The binding name used to refer to the dataset in the worker. */
956
+ binding: string;
957
+ /** The name of this dataset to write to. */
958
+ dataset?: string;
959
+ }[];
960
+ /**
961
+ * A browser that will be usable from the worker.
962
+ */
963
+ browser: {
964
+ binding: string;
965
+ } | undefined;
529
966
  /**
530
967
  * "Unsafe" tables for features that aren't directly supported by wrangler.
531
968
  *
532
969
  * NOTE: This field is not automatically inherited from the top level environment,
533
970
  * and so must be specified in every named environment.
534
971
  *
535
- * @default `{ bindings: [] }`
536
972
  * @nonInheritable
537
973
  */
538
974
  unsafe: {
@@ -540,15 +976,142 @@ declare interface EnvironmentNonInheritable {
540
976
  * A set of bindings that should be put into a Worker's upload metadata without changes. These
541
977
  * can be used to implement bindings for features that haven't released and aren't supported
542
978
  * directly by wrangler or miniflare.
543
- *
544
- * @default []
545
979
  */
546
- bindings: {
980
+ bindings?: {
547
981
  name: string;
548
982
  type: string;
549
983
  [key: string]: unknown;
550
984
  }[];
985
+ /**
986
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
987
+ * here will always be applied to metadata last, so can add new or override existing fields.
988
+ */
989
+ metadata?: {
990
+ [key: string]: string;
991
+ };
551
992
  };
993
+ mtls_certificates: {
994
+ /** The binding name used to refer to the certificate in the worker */
995
+ binding: string;
996
+ /** The uuid of the uploaded mTLS certificate */
997
+ certificate_id: string;
998
+ }[];
999
+ tail_consumers?: TailConsumer[];
1000
+ }
1001
+
1002
+ declare namespace Errors {
1003
+ class UndiciError extends Error { }
1004
+
1005
+ /** Connect timeout error. */
1006
+ class ConnectTimeoutError extends UndiciError {
1007
+ name: 'ConnectTimeoutError';
1008
+ code: 'UND_ERR_CONNECT_TIMEOUT';
1009
+ }
1010
+
1011
+ /** A header exceeds the `headersTimeout` option. */
1012
+ class HeadersTimeoutError extends UndiciError {
1013
+ name: 'HeadersTimeoutError';
1014
+ code: 'UND_ERR_HEADERS_TIMEOUT';
1015
+ }
1016
+
1017
+ /** Headers overflow error. */
1018
+ class HeadersOverflowError extends UndiciError {
1019
+ name: 'HeadersOverflowError'
1020
+ code: 'UND_ERR_HEADERS_OVERFLOW'
1021
+ }
1022
+
1023
+ /** A body exceeds the `bodyTimeout` option. */
1024
+ class BodyTimeoutError extends UndiciError {
1025
+ name: 'BodyTimeoutError';
1026
+ code: 'UND_ERR_BODY_TIMEOUT';
1027
+ }
1028
+
1029
+ class ResponseStatusCodeError extends UndiciError {
1030
+ name: 'ResponseStatusCodeError';
1031
+ code: 'UND_ERR_RESPONSE_STATUS_CODE';
1032
+ body: null | Record<string, any> | string
1033
+ status: number
1034
+ statusCode: number
1035
+ headers: IncomingHttpHeaders | string[] | null;
1036
+ }
1037
+
1038
+ /** Passed an invalid argument. */
1039
+ class InvalidArgumentError extends UndiciError {
1040
+ name: 'InvalidArgumentError';
1041
+ code: 'UND_ERR_INVALID_ARG';
1042
+ }
1043
+
1044
+ /** Returned an invalid value. */
1045
+ class InvalidReturnValueError extends UndiciError {
1046
+ name: 'InvalidReturnValueError';
1047
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
1048
+ }
1049
+
1050
+ /** The request has been aborted by the user. */
1051
+ class RequestAbortedError extends UndiciError {
1052
+ name: 'AbortError';
1053
+ code: 'UND_ERR_ABORTED';
1054
+ }
1055
+
1056
+ /** Expected error with reason. */
1057
+ class InformationalError extends UndiciError {
1058
+ name: 'InformationalError';
1059
+ code: 'UND_ERR_INFO';
1060
+ }
1061
+
1062
+ /** Request body length does not match content-length header. */
1063
+ class RequestContentLengthMismatchError extends UndiciError {
1064
+ name: 'RequestContentLengthMismatchError';
1065
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
1066
+ }
1067
+
1068
+ /** Response body length does not match content-length header. */
1069
+ class ResponseContentLengthMismatchError extends UndiciError {
1070
+ name: 'ResponseContentLengthMismatchError';
1071
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
1072
+ }
1073
+
1074
+ /** Trying to use a destroyed client. */
1075
+ class ClientDestroyedError extends UndiciError {
1076
+ name: 'ClientDestroyedError';
1077
+ code: 'UND_ERR_DESTROYED';
1078
+ }
1079
+
1080
+ /** Trying to use a closed client. */
1081
+ class ClientClosedError extends UndiciError {
1082
+ name: 'ClientClosedError';
1083
+ code: 'UND_ERR_CLOSED';
1084
+ }
1085
+
1086
+ /** There is an error with the socket. */
1087
+ class SocketError extends UndiciError {
1088
+ name: 'SocketError';
1089
+ code: 'UND_ERR_SOCKET';
1090
+ socket: Client.SocketInfo | null
1091
+ }
1092
+
1093
+ /** Encountered unsupported functionality. */
1094
+ class NotSupportedError extends UndiciError {
1095
+ name: 'NotSupportedError';
1096
+ code: 'UND_ERR_NOT_SUPPORTED';
1097
+ }
1098
+
1099
+ /** No upstream has been added to the BalancedPool. */
1100
+ class BalancedPoolMissingUpstreamError extends UndiciError {
1101
+ name: 'MissingUpstreamError';
1102
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
1103
+ }
1104
+
1105
+ class HTTPParserError extends UndiciError {
1106
+ name: 'HTTPParserError';
1107
+ code: string;
1108
+ }
1109
+
1110
+ /** The response exceed the length allowed. */
1111
+ class ResponseExceededMaxSizeError extends UndiciError {
1112
+ name: 'ResponseExceededMaxSizeError';
1113
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
1114
+ }
552
1115
  }
553
1116
 
554
1117
  declare class File extends Blob_2 {
@@ -684,6 +1247,16 @@ declare class FormData {
684
1247
  */
685
1248
  declare type FormDataEntryValue = string | File
686
1249
 
1250
+ /**
1251
+ * fetches an mTLS certificate from the account mTLS certificate store by ID
1252
+ */
1253
+ export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
1254
+
1255
+ /**
1256
+ * 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
1257
+ */
1258
+ export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
1259
+
687
1260
  declare class Headers implements SpecIterable<[string, string]> {
688
1261
  constructor (init?: HeadersInit)
689
1262
  readonly append: (name: string, value: string) => void
@@ -691,6 +1264,7 @@ declare class Headers implements SpecIterable<[string, string]> {
691
1264
  readonly get: (name: string) => string | null
692
1265
  readonly has: (name: string) => boolean
693
1266
  readonly set: (name: string, value: string) => void
1267
+ readonly getSetCookie: () => string[]
694
1268
  readonly forEach: (
695
1269
  callbackfn: (value: string, key: string, iterable: Headers) => void,
696
1270
  thisArg?: unknown
@@ -704,6 +1278,172 @@ declare class Headers implements SpecIterable<[string, string]> {
704
1278
 
705
1279
  declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
706
1280
 
1281
+ /**
1282
+ * The header type declaration of `undici`.
1283
+ */
1284
+ declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1285
+
1286
+ /**
1287
+ * lists mTLS certificates for an account. filtering by name is supported
1288
+ */
1289
+ export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
1290
+
1291
+ /**
1292
+ * details for uploading an mTLS certificate via the ssl api
1293
+ */
1294
+ declare interface MTlsCertificateBody {
1295
+ certificateChain: string;
1296
+ privateKey: string;
1297
+ name?: string;
1298
+ }
1299
+
1300
+ /**
1301
+ * supported filters for listing mTLS certificates via the ssl api
1302
+ */
1303
+ declare interface MTlsCertificateListFilter {
1304
+ name?: string;
1305
+ }
1306
+
1307
+ /**
1308
+ * the representation of an mTLS certificate in the account certificate store
1309
+ */
1310
+ declare interface MTlsCertificateResponse {
1311
+ id: string;
1312
+ name?: string;
1313
+ ca: boolean;
1314
+ certificates: string;
1315
+ expires_on: string;
1316
+ issuer: string;
1317
+ serial_number: string;
1318
+ signature: string;
1319
+ uploaded_on: string;
1320
+ }
1321
+
1322
+ /**
1323
+ * details for uploading an mTLS certificate from disk
1324
+ */
1325
+ declare interface MTlsCertificateUploadDetails {
1326
+ certificateChainFilename: string;
1327
+ privateKeyFilename: string;
1328
+ name?: string;
1329
+ }
1330
+
1331
+ declare interface PagesPublishOptions {
1332
+ /**
1333
+ * Path to static assets to publish to Pages
1334
+ */
1335
+ directory: string;
1336
+ /**
1337
+ * The Cloudflare Account ID that owns the project that's
1338
+ * being published
1339
+ */
1340
+ accountId: string;
1341
+ /**
1342
+ * The name of the project to be published
1343
+ */
1344
+ projectName: string;
1345
+ /**
1346
+ * Branch name to use. Defaults to production branch
1347
+ */
1348
+ branch?: string;
1349
+ /**
1350
+ * Whether or not to skip local file upload result caching
1351
+ */
1352
+ skipCaching?: boolean;
1353
+ /**
1354
+ * Commit message associated to deployment
1355
+ */
1356
+ commitMessage?: string;
1357
+ /**
1358
+ * Commit hash associated to deployment
1359
+ */
1360
+ commitHash?: string;
1361
+ /**
1362
+ * Whether or not the deployment should be considered to be
1363
+ * in a dirty commit state
1364
+ */
1365
+ commitDirty?: boolean;
1366
+ /**
1367
+ * Path to the project's functions directory. Default uses
1368
+ * the current working directory + /functions since this is
1369
+ * typically called in a CLI
1370
+ */
1371
+ functionsDirectory?: string;
1372
+ /**
1373
+ * Whether to run bundling on `_worker.js` before deploying.
1374
+ * Default: true
1375
+ */
1376
+ bundle?: boolean;
1377
+ }
1378
+
1379
+ /**
1380
+ * Publish a directory to an account/project.
1381
+ * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
1382
+ * variable set
1383
+ */
1384
+ declare function publish({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesPublishOptions): Promise<{
1385
+ environment: "production" | "preview";
1386
+ id: string;
1387
+ project_id: string;
1388
+ url: string;
1389
+ project_name: string;
1390
+ build_config: {
1391
+ build_command: string;
1392
+ destination_dir: string;
1393
+ root_dir: string;
1394
+ web_analytics_tag?: string | undefined;
1395
+ web_analytics_token?: string | undefined;
1396
+ fast_builds?: boolean | undefined;
1397
+ };
1398
+ created_on: string;
1399
+ production_branch: string;
1400
+ deployment_trigger: {
1401
+ type: string;
1402
+ metadata: {
1403
+ branch: string;
1404
+ commit_hash: string;
1405
+ commit_message: string;
1406
+ };
1407
+ };
1408
+ latest_stage: {
1409
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1410
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1411
+ started_on: string | null;
1412
+ ended_on: string | null;
1413
+ };
1414
+ stages: {
1415
+ name: "build" | "queued" | "initialize" | "clone_repo" | "deploy";
1416
+ status: "active" | "canceled" | "success" | "idle" | "failure" | "skipped";
1417
+ started_on: string | null;
1418
+ ended_on: string | null;
1419
+ }[];
1420
+ aliases: string[];
1421
+ modified_on: string;
1422
+ short_id: string;
1423
+ build_image_major_version: number;
1424
+ kv_namespaces?: any;
1425
+ source?: {
1426
+ type: "github" | "gitlab";
1427
+ config: {
1428
+ owner: string;
1429
+ repo_name: string;
1430
+ production_branch?: string | undefined;
1431
+ pr_comments_enabled?: boolean | undefined;
1432
+ deployments_enabled?: boolean | undefined;
1433
+ production_deployments_enabled?: boolean | undefined;
1434
+ preview_deployment_setting?: "none" | "all" | "custom" | undefined;
1435
+ preview_branch_includes?: string[] | undefined;
1436
+ preview_branch_excludes?: string[] | undefined;
1437
+ };
1438
+ } | undefined;
1439
+ env_vars?: any;
1440
+ durable_object_namespaces?: any;
1441
+ is_skipped?: boolean | undefined;
1442
+ files?: {
1443
+ [x: string]: string | undefined;
1444
+ } | undefined;
1445
+ }>;
1446
+
707
1447
  declare type ReferrerPolicy =
708
1448
  | ''
709
1449
  | 'no-referrer'
@@ -731,6 +1471,7 @@ declare class Request implements BodyMixin {
731
1471
 
732
1472
  readonly keepalive: boolean
733
1473
  readonly signal: AbortSignal
1474
+ readonly duplex: RequestDuplex
734
1475
 
735
1476
  readonly body: ReadableStream | null
736
1477
  readonly bodyUsed: boolean
@@ -774,6 +1515,8 @@ declare type RequestDestination =
774
1515
  | 'worker'
775
1516
  | 'xslt'
776
1517
 
1518
+ declare type RequestDuplex = 'half'
1519
+
777
1520
  declare type RequestInfo = string | URL_2 | Request
778
1521
 
779
1522
  declare interface RequestInit {
@@ -790,6 +1533,7 @@ declare interface RequestInit {
790
1533
  referrerPolicy?: ReferrerPolicy
791
1534
  window?: null
792
1535
  dispatcher?: Dispatcher
1536
+ duplex?: RequestDuplex
793
1537
  }
794
1538
 
795
1539
  declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
@@ -864,10 +1608,81 @@ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
864
1608
  next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
865
1609
  }
866
1610
 
1611
+ declare type TailConsumer = {
1612
+ /** The name of the service tail events will be forwarded to. */
1613
+ service: string;
1614
+ /** (Optional) The environt of the service. */
1615
+ environment?: string;
1616
+ };
1617
+
867
1618
  /**
868
1619
  * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
869
1620
  */
870
- export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<UnstableDevWorker>;
1621
+ export declare function unstable_dev(script: string, options?: UnstableDevOptions, apiOptions?: unknown): Promise<UnstableDevWorker>;
1622
+
1623
+ export declare const unstable_pages: {
1624
+ publish: typeof publish;
1625
+ };
1626
+
1627
+ export declare interface UnstableDevOptions {
1628
+ config?: string;
1629
+ env?: string;
1630
+ ip?: string;
1631
+ port?: number;
1632
+ bundle?: boolean;
1633
+ inspectorPort?: number;
1634
+ localProtocol?: "http" | "https";
1635
+ assets?: string;
1636
+ site?: string;
1637
+ siteInclude?: string[];
1638
+ siteExclude?: string[];
1639
+ nodeCompat?: boolean;
1640
+ compatibilityDate?: string;
1641
+ compatibilityFlags?: string[];
1642
+ persist?: boolean;
1643
+ persistTo?: string;
1644
+ vars?: {
1645
+ [key: string]: unknown;
1646
+ };
1647
+ kv?: {
1648
+ binding: string;
1649
+ id: string;
1650
+ preview_id?: string;
1651
+ }[];
1652
+ durableObjects?: {
1653
+ name: string;
1654
+ class_name: string;
1655
+ script_name?: string | undefined;
1656
+ environment?: string | undefined;
1657
+ }[];
1658
+ r2?: {
1659
+ binding: string;
1660
+ bucket_name: string;
1661
+ preview_bucket_name?: string;
1662
+ }[];
1663
+ moduleRoot?: string;
1664
+ rules?: Rule[];
1665
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
1666
+ inspect?: boolean;
1667
+ local?: boolean;
1668
+ accountId?: string;
1669
+ experimental?: {
1670
+ processEntrypoint?: boolean;
1671
+ additionalModules?: CfModule[];
1672
+ d1Databases?: Environment["d1_databases"];
1673
+ disableExperimentalWarning?: boolean;
1674
+ disableDevRegistry?: boolean;
1675
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
1676
+ experimentalLocal?: boolean;
1677
+ experimentalLocalRemoteKv?: boolean;
1678
+ forceLocal?: boolean;
1679
+ liveReload?: boolean;
1680
+ showInteractiveDevSession?: boolean;
1681
+ testMode?: boolean;
1682
+ testScheduled?: boolean;
1683
+ watch?: boolean;
1684
+ };
1685
+ }
871
1686
 
872
1687
  export declare interface UnstableDevWorker {
873
1688
  port: number;
@@ -877,6 +1692,16 @@ export declare interface UnstableDevWorker {
877
1692
  waitUntilExit: () => Promise<void>;
878
1693
  }
879
1694
 
1695
+ /**
1696
+ * uploads an mTLS certificate and private key pair to the account mTLS certificate store
1697
+ */
1698
+ export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
1699
+
1700
+ /**
1701
+ * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
1702
+ */
1703
+ export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
1704
+
880
1705
  declare type ZoneIdRoute = {
881
1706
  pattern: string;
882
1707
  zone_id: string;