wrangler 0.0.0-afdb7e49 → 0.0.0-b032bf2e

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 (262) hide show
  1. package/README.md +12 -14
  2. package/bin/wrangler.js +19 -65
  3. package/package.json +28 -25
  4. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  5. package/templates/__tests__/tsconfig.json +8 -0
  6. package/templates/checked-fetch.js +19 -6
  7. package/templates/facade.d.ts +17 -0
  8. package/templates/gitignore +1 -0
  9. package/templates/init-tests/test-jest-new-worker.js +3 -5
  10. package/templates/init-tests/test-vitest-new-worker.js +3 -5
  11. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  12. package/templates/middleware/common.ts +9 -4
  13. package/templates/middleware/loader-modules.ts +52 -9
  14. package/templates/middleware/loader-sw.ts +47 -32
  15. package/templates/middleware/middleware-d1-beta.d.ts +3 -0
  16. package/templates/{d1-beta-facade.js → middleware/middleware-d1-beta.ts} +106 -67
  17. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  18. package/templates/middleware/middleware-multiworker-dev.d.ts +4 -0
  19. package/templates/middleware/middleware-multiworker-dev.ts +59 -0
  20. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  21. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  22. package/templates/new-worker-scheduled.ts +1 -1
  23. package/templates/new-worker.ts +4 -1
  24. package/templates/pages-dev-pipeline.ts +4 -1
  25. package/templates/pages-dev-util.ts +4 -1
  26. package/templates/pages-shim.ts +1 -1
  27. package/templates/pages-template-plugin.ts +31 -12
  28. package/templates/pages-template-worker.ts +11 -2
  29. package/templates/tsconfig-sanity.ts +11 -0
  30. package/templates/tsconfig.init.json +105 -0
  31. package/templates/tsconfig.json +5 -103
  32. package/wrangler-dist/cli.d.ts +906 -73
  33. package/wrangler-dist/cli.js +129660 -143899
  34. package/wrangler-dist/wasm-sync.wasm +0 -0
  35. package/import_meta_url.js +0 -3
  36. package/miniflare-config-stubs/.env.empty +0 -0
  37. package/miniflare-config-stubs/package.empty.json +0 -1
  38. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  39. package/miniflare-dist/index.mjs +0 -6316
  40. package/src/__tests__/access.test.ts +0 -25
  41. package/src/__tests__/api-dev.test.ts +0 -209
  42. package/src/__tests__/api-devregistry.test.js +0 -56
  43. package/src/__tests__/api.test.ts +0 -80
  44. package/src/__tests__/config-cache-without-cache-dir.test.ts +0 -38
  45. package/src/__tests__/config-cache.test.ts +0 -42
  46. package/src/__tests__/configuration.test.ts +0 -3981
  47. package/src/__tests__/d1.test.ts +0 -74
  48. package/src/__tests__/delete.test.ts +0 -230
  49. package/src/__tests__/deployments.test.ts +0 -91
  50. package/src/__tests__/dev.test.tsx +0 -1535
  51. package/src/__tests__/dialogs.test.tsx +0 -40
  52. package/src/__tests__/generate.test.ts +0 -235
  53. package/src/__tests__/get-host-from-url.test.ts +0 -16
  54. package/src/__tests__/guess-worker-format.test.ts +0 -85
  55. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  56. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  57. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  58. package/src/__tests__/helpers/mock-bin.ts +0 -36
  59. package/src/__tests__/helpers/mock-cfetch.ts +0 -333
  60. package/src/__tests__/helpers/mock-console.ts +0 -106
  61. package/src/__tests__/helpers/mock-dialogs.ts +0 -153
  62. package/src/__tests__/helpers/mock-get-zone-from-host.ts +0 -8
  63. package/src/__tests__/helpers/mock-http-server.ts +0 -46
  64. package/src/__tests__/helpers/mock-istty.ts +0 -74
  65. package/src/__tests__/helpers/mock-known-routes.ts +0 -7
  66. package/src/__tests__/helpers/mock-kv.ts +0 -33
  67. package/src/__tests__/helpers/mock-oauth-flow.ts +0 -252
  68. package/src/__tests__/helpers/mock-process.ts +0 -39
  69. package/src/__tests__/helpers/mock-stdin.ts +0 -108
  70. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  71. package/src/__tests__/helpers/msw/handlers/access.ts +0 -13
  72. package/src/__tests__/helpers/msw/handlers/deployments.ts +0 -59
  73. package/src/__tests__/helpers/msw/handlers/namespaces.ts +0 -104
  74. package/src/__tests__/helpers/msw/handlers/oauth.ts +0 -36
  75. package/src/__tests__/helpers/msw/handlers/r2.ts +0 -80
  76. package/src/__tests__/helpers/msw/handlers/script.ts +0 -75
  77. package/src/__tests__/helpers/msw/handlers/user.ts +0 -63
  78. package/src/__tests__/helpers/msw/handlers/zones.ts +0 -22
  79. package/src/__tests__/helpers/msw/index.ts +0 -21
  80. package/src/__tests__/helpers/run-in-tmp.ts +0 -38
  81. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  82. package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +0 -1
  83. package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +0 -5
  84. package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +0 -1
  85. package/src/__tests__/helpers/worker-scripts/parent-worker.js +0 -8
  86. package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +0 -5
  87. package/src/__tests__/helpers/write-worker-source.ts +0 -31
  88. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  89. package/src/__tests__/https-options.test.ts +0 -163
  90. package/src/__tests__/index.test.ts +0 -264
  91. package/src/__tests__/init.test.ts +0 -2900
  92. package/src/__tests__/jest.setup.ts +0 -202
  93. package/src/__tests__/kv.test.ts +0 -1675
  94. package/src/__tests__/logger.test.ts +0 -141
  95. package/src/__tests__/metrics.test.ts +0 -450
  96. package/src/__tests__/middleware.scheduled.test.ts +0 -135
  97. package/src/__tests__/middleware.test.ts +0 -726
  98. package/src/__tests__/package-manager.test.ts +0 -353
  99. package/src/__tests__/pages-deployment-tail.test.ts +0 -820
  100. package/src/__tests__/pages.test.ts +0 -2442
  101. package/src/__tests__/parse.test.ts +0 -330
  102. package/src/__tests__/paths.test.ts +0 -39
  103. package/src/__tests__/publish.test.ts +0 -7633
  104. package/src/__tests__/pubsub.test.ts +0 -370
  105. package/src/__tests__/queues.test.ts +0 -371
  106. package/src/__tests__/r2.test.ts +0 -393
  107. package/src/__tests__/route.test.ts +0 -45
  108. package/src/__tests__/secret.test.ts +0 -644
  109. package/src/__tests__/tail.test.ts +0 -800
  110. package/src/__tests__/test-old-node-version.js +0 -31
  111. package/src/__tests__/type-generation.test.ts +0 -225
  112. package/src/__tests__/user.test.ts +0 -155
  113. package/src/__tests__/utils-collectKeyValues.test.ts +0 -47
  114. package/src/__tests__/validate-dev-props.test.ts +0 -56
  115. package/src/__tests__/version.test.ts +0 -35
  116. package/src/__tests__/whoami.test.tsx +0 -278
  117. package/src/__tests__/worker-namespace.test.ts +0 -326
  118. package/src/abort.d.ts +0 -3
  119. package/src/api/dev.ts +0 -210
  120. package/src/api/index.ts +0 -2
  121. package/src/bundle-reporter.tsx +0 -68
  122. package/src/bundle.ts +0 -808
  123. package/src/cfetch/index.ts +0 -160
  124. package/src/cfetch/internal.ts +0 -263
  125. package/src/cli.ts +0 -28
  126. package/src/config/README.md +0 -107
  127. package/src/config/config.ts +0 -275
  128. package/src/config/diagnostics.ts +0 -80
  129. package/src/config/environment.ts +0 -561
  130. package/src/config/index.ts +0 -334
  131. package/src/config/validation-helpers.ts +0 -597
  132. package/src/config/validation.ts +0 -2103
  133. package/src/config-cache.ts +0 -85
  134. package/src/create-worker-preview.ts +0 -282
  135. package/src/create-worker-upload-form.ts +0 -316
  136. package/src/d1/backups.tsx +0 -218
  137. package/src/d1/constants.ts +0 -2
  138. package/src/d1/create.tsx +0 -63
  139. package/src/d1/delete.tsx +0 -56
  140. package/src/d1/execute.tsx +0 -352
  141. package/src/d1/formatTimeAgo.ts +0 -14
  142. package/src/d1/index.ts +0 -99
  143. package/src/d1/list.tsx +0 -48
  144. package/src/d1/migrations.tsx +0 -446
  145. package/src/d1/options.ts +0 -22
  146. package/src/d1/types.tsx +0 -24
  147. package/src/d1/utils.ts +0 -48
  148. package/src/delete.ts +0 -108
  149. package/src/deployments.ts +0 -77
  150. package/src/deprecated/index.ts +0 -438
  151. package/src/dev/dev-vars.ts +0 -39
  152. package/src/dev/dev.tsx +0 -589
  153. package/src/dev/get-local-persistence-path.tsx +0 -31
  154. package/src/dev/local.tsx +0 -862
  155. package/src/dev/remote.tsx +0 -603
  156. package/src/dev/start-server.ts +0 -528
  157. package/src/dev/use-esbuild.ts +0 -200
  158. package/src/dev/validate-dev-props.ts +0 -31
  159. package/src/dev-registry.tsx +0 -201
  160. package/src/dev.tsx +0 -885
  161. package/src/dialogs.tsx +0 -168
  162. package/src/dispatch-namespace.ts +0 -207
  163. package/src/durable.ts +0 -102
  164. package/src/entry.ts +0 -329
  165. package/src/environment-variables.ts +0 -50
  166. package/src/errors.ts +0 -11
  167. package/src/git-client.ts +0 -124
  168. package/src/global-wrangler-config-path.ts +0 -26
  169. package/src/https-options.ts +0 -127
  170. package/src/index.tsx +0 -682
  171. package/src/init.ts +0 -970
  172. package/src/inspect.ts +0 -767
  173. package/src/intl-polyfill.d.ts +0 -139
  174. package/src/is-ci.ts +0 -14
  175. package/src/is-interactive.ts +0 -16
  176. package/src/kv/helpers.ts +0 -430
  177. package/src/kv/index.ts +0 -596
  178. package/src/logger.ts +0 -92
  179. package/src/metrics/index.ts +0 -5
  180. package/src/metrics/metrics-config.ts +0 -239
  181. package/src/metrics/metrics-dispatcher.ts +0 -96
  182. package/src/metrics/metrics-usage-headers.ts +0 -24
  183. package/src/metrics/send-event.ts +0 -96
  184. package/src/miniflare-cli/README.md +0 -30
  185. package/src/miniflare-cli/assets.ts +0 -215
  186. package/src/miniflare-cli/index.ts +0 -213
  187. package/src/miniflare-cli/request-context.ts +0 -40
  188. package/src/module-collection.ts +0 -267
  189. package/src/open-in-browser.ts +0 -17
  190. package/src/package-manager.ts +0 -219
  191. package/src/pages/build.tsx +0 -270
  192. package/src/pages/constants.ts +0 -18
  193. package/src/pages/deployment-tails.tsx +0 -284
  194. package/src/pages/deployments.tsx +0 -84
  195. package/src/pages/dev.tsx +0 -708
  196. package/src/pages/errors.ts +0 -66
  197. package/src/pages/functions/buildPlugin.ts +0 -106
  198. package/src/pages/functions/buildWorker.ts +0 -165
  199. package/src/pages/functions/filepath-routing.test.ts +0 -234
  200. package/src/pages/functions/filepath-routing.ts +0 -189
  201. package/src/pages/functions/identifiers.ts +0 -78
  202. package/src/pages/functions/routes-consolidation.test.ts +0 -250
  203. package/src/pages/functions/routes-consolidation.ts +0 -73
  204. package/src/pages/functions/routes-transformation.test.ts +0 -282
  205. package/src/pages/functions/routes-transformation.ts +0 -115
  206. package/src/pages/functions/routes-validation.test.ts +0 -403
  207. package/src/pages/functions/routes-validation.ts +0 -202
  208. package/src/pages/functions/routes.ts +0 -151
  209. package/src/pages/functions.tsx +0 -82
  210. package/src/pages/hash.tsx +0 -13
  211. package/src/pages/index.tsx +0 -102
  212. package/src/pages/projects.tsx +0 -169
  213. package/src/pages/prompt-select-project.tsx +0 -31
  214. package/src/pages/publish.tsx +0 -451
  215. package/src/pages/types.ts +0 -41
  216. package/src/pages/upload.tsx +0 -426
  217. package/src/pages/utils.ts +0 -23
  218. package/src/parse.ts +0 -286
  219. package/src/paths.ts +0 -71
  220. package/src/proxy.ts +0 -689
  221. package/src/publish/index.ts +0 -270
  222. package/src/publish/publish.ts +0 -1034
  223. package/src/pubsub/index.ts +0 -286
  224. package/src/pubsub/pubsub-commands.tsx +0 -624
  225. package/src/queues/cli/commands/consumer/add.ts +0 -71
  226. package/src/queues/cli/commands/consumer/index.ts +0 -22
  227. package/src/queues/cli/commands/consumer/remove.ts +0 -38
  228. package/src/queues/cli/commands/create.ts +0 -25
  229. package/src/queues/cli/commands/delete.ts +0 -26
  230. package/src/queues/cli/commands/index.ts +0 -33
  231. package/src/queues/cli/commands/list.ts +0 -25
  232. package/src/queues/client.ts +0 -135
  233. package/src/r2/constants.ts +0 -4
  234. package/src/r2/helpers.ts +0 -131
  235. package/src/r2/index.ts +0 -289
  236. package/src/routes.ts +0 -140
  237. package/src/secret/index.ts +0 -378
  238. package/src/selfsigned.d.ts +0 -29
  239. package/src/sites.tsx +0 -372
  240. package/src/tail/createTail.ts +0 -379
  241. package/src/tail/filters.ts +0 -277
  242. package/src/tail/index.ts +0 -214
  243. package/src/tail/printing.ts +0 -107
  244. package/src/type-generation.ts +0 -173
  245. package/src/update-check.ts +0 -19
  246. package/src/user/access.ts +0 -69
  247. package/src/user/choose-account.tsx +0 -69
  248. package/src/user/env-vars.ts +0 -46
  249. package/src/user/generate-auth-url.ts +0 -33
  250. package/src/user/generate-random-state.ts +0 -16
  251. package/src/user/index.ts +0 -3
  252. package/src/user/user.tsx +0 -1192
  253. package/src/utils/collectKeyValues.ts +0 -14
  254. package/src/whoami.tsx +0 -169
  255. package/src/worker.ts +0 -245
  256. package/src/yargs-types.ts +0 -24
  257. package/src/zones.ts +0 -191
  258. package/templates/first-party-worker-module-facade.ts +0 -18
  259. package/templates/format-dev-errors.ts +0 -32
  260. package/templates/serve-static-assets.ts +0 -63
  261. package/templates/service-bindings-module-facade.js +0 -54
  262. package/templates/service-bindings-sw-facade.js +0 -42
@@ -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,76 @@ declare type CustomDomainRoute = {
43
241
  custom_domain: boolean;
44
242
  };
45
243
 
244
+ export declare function deleteMTlsCertificate(accountId: string, certificateId: string): Promise<unknown>;
245
+
246
+ /**
247
+ * Publish a directory to an account/project.
248
+ * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
249
+ * variable set
250
+ */
251
+ declare function deploy({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesDeployOptions): Promise<{
252
+ environment: "production" | "preview";
253
+ id: string;
254
+ project_id: string;
255
+ url: string;
256
+ project_name: string;
257
+ build_config: {
258
+ build_command: string;
259
+ destination_dir: string;
260
+ root_dir: string;
261
+ web_analytics_tag?: string | undefined;
262
+ web_analytics_token?: string | undefined;
263
+ fast_builds?: boolean | undefined;
264
+ };
265
+ created_on: string;
266
+ production_branch: string;
267
+ deployment_trigger: {
268
+ type: string;
269
+ metadata: {
270
+ branch: string;
271
+ commit_hash: string;
272
+ commit_message: string;
273
+ };
274
+ };
275
+ latest_stage: {
276
+ name: "build" | "deploy" | "queued" | "initialize" | "clone_repo";
277
+ status: "active" | "idle" | "canceled" | "success" | "failure" | "skipped";
278
+ started_on: string | null;
279
+ ended_on: string | null;
280
+ };
281
+ stages: {
282
+ name: "build" | "deploy" | "queued" | "initialize" | "clone_repo";
283
+ status: "active" | "idle" | "canceled" | "success" | "failure" | "skipped";
284
+ started_on: string | null;
285
+ ended_on: string | null;
286
+ }[];
287
+ aliases: string[];
288
+ modified_on: string;
289
+ short_id: string;
290
+ build_image_major_version: number;
291
+ kv_namespaces?: any;
292
+ source?: {
293
+ type: "github" | "gitlab";
294
+ config: {
295
+ owner: string;
296
+ repo_name: string;
297
+ production_branch?: string | undefined;
298
+ pr_comments_enabled?: boolean | undefined;
299
+ deployments_enabled?: boolean | undefined;
300
+ production_deployments_enabled?: boolean | undefined;
301
+ preview_deployment_setting?: "none" | "all" | "custom" | undefined;
302
+ preview_branch_includes?: string[] | undefined;
303
+ preview_branch_excludes?: string[] | undefined;
304
+ };
305
+ } | undefined;
306
+ env_vars?: any;
307
+ durable_object_namespaces?: any;
308
+ is_skipped?: boolean | undefined;
309
+ files?: {
310
+ [x: string]: string | undefined;
311
+ } | undefined;
312
+ }>;
313
+
46
314
  /**
47
315
  * Deprecated upload configuration.
48
316
  */
@@ -74,65 +342,251 @@ declare interface DeprecatedUpload {
74
342
  rules?: Environment["rules"];
75
343
  }
76
344
 
77
- declare interface DevApiOptions {
78
- testMode?: boolean;
79
- disableExperimentalWarning?: boolean;
345
+ /** Dispatcher is the core API used to dispatch requests. */
346
+ declare class Dispatcher extends EventEmitter {
347
+ /** 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. */
348
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
349
+ /** Starts two-way communications with the requested resource. */
350
+ connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
351
+ connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
352
+ /** Performs an HTTP request. */
353
+ request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
354
+ request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
355
+ /** For easy use with `stream.pipeline`. */
356
+ pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
357
+ /** A faster version of `Dispatcher.request`. */
358
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
359
+ stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
360
+ /** Upgrade to a different protocol. */
361
+ upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
362
+ upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
363
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
364
+ close(): Promise<void>;
365
+ close(callback: () => void): void;
366
+ /** 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. */
367
+ destroy(): Promise<void>;
368
+ destroy(err: Error | null): Promise<void>;
369
+ destroy(callback: () => void): void;
370
+ destroy(err: Error | null, callback: () => void): void;
371
+
372
+ on(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
373
+ on(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
374
+ on(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
375
+ on(eventName: 'drain', callback: (origin: URL_2) => void): this;
376
+
377
+
378
+ once(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
379
+ once(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
380
+ once(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
381
+ once(eventName: 'drain', callback: (origin: URL_2) => void): this;
382
+
383
+
384
+ off(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
385
+ off(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
386
+ off(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
387
+ off(eventName: 'drain', callback: (origin: URL_2) => void): this;
388
+
389
+
390
+ addListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
391
+ addListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
392
+ addListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
393
+ addListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
394
+
395
+ removeListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
396
+ removeListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
397
+ removeListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
398
+ removeListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
399
+
400
+ prependListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
401
+ prependListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
402
+ prependListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
403
+ prependListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
404
+
405
+ prependOnceListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
406
+ prependOnceListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
407
+ prependOnceListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
408
+ prependOnceListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
409
+
410
+ listeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
411
+ listeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
412
+ listeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
413
+ listeners(eventName: 'drain'): ((origin: URL_2) => void)[];
414
+
415
+ rawListeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
416
+ rawListeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
417
+ rawListeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
418
+ rawListeners(eventName: 'drain'): ((origin: URL_2) => void)[];
419
+
420
+ emit(eventName: 'connect', origin: URL_2, targets: readonly Dispatcher[]): boolean;
421
+ emit(eventName: 'disconnect', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
422
+ emit(eventName: 'connectionError', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
423
+ emit(eventName: 'drain', origin: URL_2): boolean;
80
424
  }
81
425
 
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;
132
- accountId?: string;
133
- experimentalLocalRemoteKv?: boolean;
426
+ declare namespace Dispatcher {
427
+ interface DispatchOptions {
428
+ origin?: string | URL_2;
429
+ path: string;
430
+ method: HttpMethod;
431
+ /** Default: `null` */
432
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
433
+ /** Default: `null` */
434
+ headers?: IncomingHttpHeaders | string[] | null;
435
+ /** Query string params to be embedded in the request URL. Default: `null` */
436
+ query?: Record<string, any>;
437
+ /** 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`. */
438
+ idempotent?: boolean;
439
+ /** 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. */
440
+ blocking?: boolean;
441
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
442
+ upgrade?: boolean | string | null;
443
+ /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
444
+ headersTimeout?: number | null;
445
+ /** 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. */
446
+ bodyTimeout?: number | null;
447
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
448
+ reset?: boolean;
449
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
450
+ throwOnError?: boolean;
451
+ }
452
+ interface ConnectOptions {
453
+ path: string;
454
+ /** Default: `null` */
455
+ headers?: IncomingHttpHeaders | string[] | null;
456
+ /** Default: `null` */
457
+ signal?: AbortSignal_2 | EventEmitter | null;
458
+ /** This argument parameter is passed through to `ConnectData` */
459
+ opaque?: unknown;
460
+ /** Default: 0 */
461
+ maxRedirections?: number;
462
+ /** Default: `null` */
463
+ responseHeader?: 'raw' | null;
464
+ }
465
+ interface RequestOptions extends DispatchOptions {
466
+ /** Default: `null` */
467
+ opaque?: unknown;
468
+ /** Default: `null` */
469
+ signal?: AbortSignal_2 | EventEmitter | null;
470
+ /** Default: 0 */
471
+ maxRedirections?: number;
472
+ /** Default: `null` */
473
+ onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
474
+ /** Default: `null` */
475
+ responseHeader?: 'raw' | null;
476
+ }
477
+ interface PipelineOptions extends RequestOptions {
478
+ /** `true` if the `handler` will return an object stream. Default: `false` */
479
+ objectMode?: boolean;
480
+ }
481
+ interface UpgradeOptions {
482
+ path: string;
483
+ /** Default: `'GET'` */
484
+ method?: string;
485
+ /** Default: `null` */
486
+ headers?: IncomingHttpHeaders | string[] | null;
487
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
488
+ protocol?: string;
489
+ /** Default: `null` */
490
+ signal?: AbortSignal_2 | EventEmitter | null;
491
+ /** Default: 0 */
492
+ maxRedirections?: number;
493
+ /** Default: `null` */
494
+ responseHeader?: 'raw' | null;
495
+ }
496
+ interface ConnectData {
497
+ statusCode: number;
498
+ headers: IncomingHttpHeaders;
499
+ socket: Duplex;
500
+ opaque: unknown;
501
+ }
502
+ interface ResponseData {
503
+ statusCode: number;
504
+ headers: IncomingHttpHeaders;
505
+ body: BodyReadable & BodyMixin;
506
+ trailers: Record<string, string>;
507
+ opaque: unknown;
508
+ context: object;
509
+ }
510
+ interface PipelineHandlerData {
511
+ statusCode: number;
512
+ headers: IncomingHttpHeaders;
513
+ opaque: unknown;
514
+ body: BodyReadable;
515
+ context: object;
516
+ }
517
+ interface StreamData {
518
+ opaque: unknown;
519
+ trailers: Record<string, string>;
520
+ }
521
+ interface UpgradeData {
522
+ headers: IncomingHttpHeaders;
523
+ socket: Duplex;
524
+ opaque: unknown;
525
+ }
526
+ interface StreamFactoryData {
527
+ statusCode: number;
528
+ headers: IncomingHttpHeaders;
529
+ opaque: unknown;
530
+ context: object;
531
+ }
532
+ type StreamFactory = (data: StreamFactoryData) => Writable;
533
+ interface DispatchHandlers {
534
+ /** 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. */
535
+ onConnect?(abort: () => void): void;
536
+ /** Invoked when an error has occurred. */
537
+ onError?(err: Error): void;
538
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
539
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
540
+ /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
541
+ onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void): boolean;
542
+ /** Invoked when response payload data is received. */
543
+ onData?(chunk: Buffer): boolean;
544
+ /** Invoked when response payload and trailers have been received and the request has completed. */
545
+ onComplete?(trailers: string[] | null): void;
546
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
547
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
548
+ }
549
+ type PipelineHandler = (data: PipelineHandlerData) => Readable;
550
+ type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
551
+
552
+ /**
553
+ * @link https://fetch.spec.whatwg.org/#body-mixin
554
+ */
555
+ interface BodyMixin {
556
+ readonly body?: never; // throws on node v16.6.0
557
+ readonly bodyUsed: boolean;
558
+ arrayBuffer(): Promise<ArrayBuffer>;
559
+ blob(): Promise<Blob_2>;
560
+ formData(): Promise<never>;
561
+ json(): Promise<any>;
562
+ text(): Promise<string>;
563
+ }
564
+
565
+ interface DispatchInterceptor {
566
+ (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
567
+ }
568
+ }
569
+
570
+ declare interface DispatchNamespaceOutbound {
571
+ /** Name of the service handling the outbound requests */
572
+ service: string;
573
+ /** (Optional) Name of the environment handling the outbound requests. */
574
+ environment?: string;
575
+ /** (Optional) List of parameter names, for sending context from your dispatch worker to the outbound handler */
576
+ parameters?: string[];
134
577
  }
135
578
 
579
+ declare type DurableObjectBindings = {
580
+ /** The name of the binding used to refer to the Durable Object */
581
+ name: string;
582
+ /** The exported class name of the Durable Object */
583
+ class_name: string;
584
+ /** The script where the Durable Object is defined (if it's external to this worker) */
585
+ script_name?: string;
586
+ /** The service environment of the script_name to bind to */
587
+ environment?: string;
588
+ }[];
589
+
136
590
  declare interface EnablePagesAssetsServiceBindingOptions {
137
591
  proxyPort?: number;
138
592
  directory?: string;
@@ -190,11 +644,16 @@ declare interface EnvironmentInheritable {
190
644
  * The entrypoint/path to the JavaScript file that will be executed.
191
645
  */
192
646
  main: string | undefined;
647
+ /**
648
+ * The directory in which module rules should be evaluated in a `--no-bundle` worker
649
+ * This defaults to dirname(main) when left undefined
650
+ */
651
+ base_dir: string | undefined;
193
652
  /**
194
653
  * Whether we use <name>.<subdomain>.workers.dev to
195
654
  * test and deploy your worker.
196
655
  *
197
- * @default `true` (This is a breaking change from wrangler 1)
656
+ * @default `true` (This is a breaking change from Wrangler v1)
198
657
  * @breaking
199
658
  * @inheritable
200
659
  */
@@ -292,7 +751,7 @@ declare interface EnvironmentInheritable {
292
751
  upload?: DeprecatedUpload;
293
752
  };
294
753
  /**
295
- * Skip internal build steps and directly publish script
754
+ * Skip internal build steps and directly deploy script
296
755
  * @inheritable
297
756
  */
298
757
  no_bundle: boolean | undefined;
@@ -320,6 +779,8 @@ declare interface EnvironmentInheritable {
320
779
  binding: string;
321
780
  /** The namespace to bind to. */
322
781
  namespace: string;
782
+ /** Details about the outbound worker which will handle outbound requests from your namespace */
783
+ outbound?: DispatchNamespaceOutbound;
323
784
  }[];
324
785
  /**
325
786
  * Designates this worker as an internal-only "first-party" worker.
@@ -360,6 +821,14 @@ declare interface EnvironmentInheritable {
360
821
  * @inheritable
361
822
  */
362
823
  logpush: boolean | undefined;
824
+ /**
825
+ * Specify how the worker should be located to minimize round-trip time.
826
+ *
827
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
828
+ */
829
+ placement: {
830
+ mode: "off" | "smart";
831
+ } | undefined;
363
832
  }
364
833
 
365
834
  /**
@@ -405,16 +874,7 @@ declare interface EnvironmentNonInheritable {
405
874
  * @nonInheritable
406
875
  */
407
876
  durable_objects: {
408
- bindings: {
409
- /** The name of the binding used to refer to the Durable Object */
410
- name: string;
411
- /** The exported class name of the Durable Object */
412
- class_name: string;
413
- /** The script where the Durable Object is defined (if it's external to this worker) */
414
- script_name?: string;
415
- /** The service environment of the script_name to bind to */
416
- environment?: string;
417
- }[];
877
+ bindings: DurableObjectBindings;
418
878
  };
419
879
  /**
420
880
  * These specify any Workers KV Namespaces you want to
@@ -437,6 +897,23 @@ declare interface EnvironmentNonInheritable {
437
897
  /** The ID of the KV namespace used during `wrangler dev` */
438
898
  preview_id?: string;
439
899
  }[];
900
+ /**
901
+ * These specify bindings to send email from inside your Worker.
902
+ *
903
+ * NOTE: This field is not automatically inherited from the top level environment,
904
+ * and so must be specified in every named environment.
905
+ *
906
+ * @default `[]`
907
+ * @nonInheritable
908
+ */
909
+ send_email: {
910
+ /** The binding name used to refer to the this binding */
911
+ name: string;
912
+ /** If this binding should be restricted to a specific verified address */
913
+ destination_address?: string;
914
+ /** If this binding should be restricted to a set of verified addresses */
915
+ allowed_destination_addresses?: string[];
916
+ }[];
440
917
  /**
441
918
  * Specifies Queues that are bound to this Worker environment.
442
919
  *
@@ -466,6 +943,8 @@ declare interface EnvironmentNonInheritable {
466
943
  max_retries?: number;
467
944
  /** The queue to send messages that failed to be consumed. */
468
945
  dead_letter_queue?: string;
946
+ /** 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. */
947
+ max_concurrency?: number | null;
469
948
  }[];
470
949
  };
471
950
  /**
@@ -510,6 +989,21 @@ declare interface EnvironmentNonInheritable {
510
989
  /** Internal use only. */
511
990
  database_internal_env?: string;
512
991
  }[];
992
+ /**
993
+ * Specifies Constellation projects that are bound to this Worker environment.
994
+ *
995
+ * NOTE: This field is not automatically inherited from the top level environment,
996
+ * and so must be specified in every named environment.
997
+ *
998
+ * @default `[]`
999
+ * @nonInheritable
1000
+ */
1001
+ constellation: {
1002
+ /** The binding name used to refer to the project in the worker. */
1003
+ binding: string;
1004
+ /** The id of the project. */
1005
+ project_id: string;
1006
+ }[];
513
1007
  /**
514
1008
  * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
515
1009
  *
@@ -527,13 +1021,33 @@ declare interface EnvironmentNonInheritable {
527
1021
  /** The environment of the service (e.g. production, staging, etc). */
528
1022
  environment?: string;
529
1023
  }[] | undefined;
1024
+ /**
1025
+ * Specifies analytics engine datasets that are bound to this Worker environment.
1026
+ *
1027
+ * NOTE: This field is not automatically inherited from the top level environment,
1028
+ * and so must be specified in every named environment.
1029
+ *
1030
+ * @default `[]`
1031
+ * @nonInheritable
1032
+ */
1033
+ analytics_engine_datasets: {
1034
+ /** The binding name used to refer to the dataset in the worker. */
1035
+ binding: string;
1036
+ /** The name of this dataset to write to. */
1037
+ dataset?: string;
1038
+ }[];
1039
+ /**
1040
+ * A browser that will be usable from the worker.
1041
+ */
1042
+ browser: {
1043
+ binding: string;
1044
+ } | undefined;
530
1045
  /**
531
1046
  * "Unsafe" tables for features that aren't directly supported by wrangler.
532
1047
  *
533
1048
  * NOTE: This field is not automatically inherited from the top level environment,
534
1049
  * and so must be specified in every named environment.
535
1050
  *
536
- * @default `{ bindings: [] }`
537
1051
  * @nonInheritable
538
1052
  */
539
1053
  unsafe: {
@@ -541,15 +1055,142 @@ declare interface EnvironmentNonInheritable {
541
1055
  * A set of bindings that should be put into a Worker's upload metadata without changes. These
542
1056
  * can be used to implement bindings for features that haven't released and aren't supported
543
1057
  * directly by wrangler or miniflare.
544
- *
545
- * @default []
546
1058
  */
547
- bindings: {
1059
+ bindings?: {
548
1060
  name: string;
549
1061
  type: string;
550
1062
  [key: string]: unknown;
551
1063
  }[];
1064
+ /**
1065
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
1066
+ * here will always be applied to metadata last, so can add new or override existing fields.
1067
+ */
1068
+ metadata?: {
1069
+ [key: string]: string;
1070
+ };
552
1071
  };
1072
+ mtls_certificates: {
1073
+ /** The binding name used to refer to the certificate in the worker */
1074
+ binding: string;
1075
+ /** The uuid of the uploaded mTLS certificate */
1076
+ certificate_id: string;
1077
+ }[];
1078
+ tail_consumers?: TailConsumer[];
1079
+ }
1080
+
1081
+ declare namespace Errors {
1082
+ class UndiciError extends Error { }
1083
+
1084
+ /** Connect timeout error. */
1085
+ class ConnectTimeoutError extends UndiciError {
1086
+ name: 'ConnectTimeoutError';
1087
+ code: 'UND_ERR_CONNECT_TIMEOUT';
1088
+ }
1089
+
1090
+ /** A header exceeds the `headersTimeout` option. */
1091
+ class HeadersTimeoutError extends UndiciError {
1092
+ name: 'HeadersTimeoutError';
1093
+ code: 'UND_ERR_HEADERS_TIMEOUT';
1094
+ }
1095
+
1096
+ /** Headers overflow error. */
1097
+ class HeadersOverflowError extends UndiciError {
1098
+ name: 'HeadersOverflowError'
1099
+ code: 'UND_ERR_HEADERS_OVERFLOW'
1100
+ }
1101
+
1102
+ /** A body exceeds the `bodyTimeout` option. */
1103
+ class BodyTimeoutError extends UndiciError {
1104
+ name: 'BodyTimeoutError';
1105
+ code: 'UND_ERR_BODY_TIMEOUT';
1106
+ }
1107
+
1108
+ class ResponseStatusCodeError extends UndiciError {
1109
+ name: 'ResponseStatusCodeError';
1110
+ code: 'UND_ERR_RESPONSE_STATUS_CODE';
1111
+ body: null | Record<string, any> | string
1112
+ status: number
1113
+ statusCode: number
1114
+ headers: IncomingHttpHeaders | string[] | null;
1115
+ }
1116
+
1117
+ /** Passed an invalid argument. */
1118
+ class InvalidArgumentError extends UndiciError {
1119
+ name: 'InvalidArgumentError';
1120
+ code: 'UND_ERR_INVALID_ARG';
1121
+ }
1122
+
1123
+ /** Returned an invalid value. */
1124
+ class InvalidReturnValueError extends UndiciError {
1125
+ name: 'InvalidReturnValueError';
1126
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
1127
+ }
1128
+
1129
+ /** The request has been aborted by the user. */
1130
+ class RequestAbortedError extends UndiciError {
1131
+ name: 'AbortError';
1132
+ code: 'UND_ERR_ABORTED';
1133
+ }
1134
+
1135
+ /** Expected error with reason. */
1136
+ class InformationalError extends UndiciError {
1137
+ name: 'InformationalError';
1138
+ code: 'UND_ERR_INFO';
1139
+ }
1140
+
1141
+ /** Request body length does not match content-length header. */
1142
+ class RequestContentLengthMismatchError extends UndiciError {
1143
+ name: 'RequestContentLengthMismatchError';
1144
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
1145
+ }
1146
+
1147
+ /** Response body length does not match content-length header. */
1148
+ class ResponseContentLengthMismatchError extends UndiciError {
1149
+ name: 'ResponseContentLengthMismatchError';
1150
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
1151
+ }
1152
+
1153
+ /** Trying to use a destroyed client. */
1154
+ class ClientDestroyedError extends UndiciError {
1155
+ name: 'ClientDestroyedError';
1156
+ code: 'UND_ERR_DESTROYED';
1157
+ }
1158
+
1159
+ /** Trying to use a closed client. */
1160
+ class ClientClosedError extends UndiciError {
1161
+ name: 'ClientClosedError';
1162
+ code: 'UND_ERR_CLOSED';
1163
+ }
1164
+
1165
+ /** There is an error with the socket. */
1166
+ class SocketError extends UndiciError {
1167
+ name: 'SocketError';
1168
+ code: 'UND_ERR_SOCKET';
1169
+ socket: Client.SocketInfo | null
1170
+ }
1171
+
1172
+ /** Encountered unsupported functionality. */
1173
+ class NotSupportedError extends UndiciError {
1174
+ name: 'NotSupportedError';
1175
+ code: 'UND_ERR_NOT_SUPPORTED';
1176
+ }
1177
+
1178
+ /** No upstream has been added to the BalancedPool. */
1179
+ class BalancedPoolMissingUpstreamError extends UndiciError {
1180
+ name: 'MissingUpstreamError';
1181
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
1182
+ }
1183
+
1184
+ class HTTPParserError extends UndiciError {
1185
+ name: 'HTTPParserError';
1186
+ code: string;
1187
+ }
1188
+
1189
+ /** The response exceed the length allowed. */
1190
+ class ResponseExceededMaxSizeError extends UndiciError {
1191
+ name: 'ResponseExceededMaxSizeError';
1192
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
1193
+ }
553
1194
  }
554
1195
 
555
1196
  declare class File extends Blob_2 {
@@ -685,6 +1326,16 @@ declare class FormData {
685
1326
  */
686
1327
  declare type FormDataEntryValue = string | File
687
1328
 
1329
+ /**
1330
+ * fetches an mTLS certificate from the account mTLS certificate store by ID
1331
+ */
1332
+ export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
1333
+
1334
+ /**
1335
+ * 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
1336
+ */
1337
+ export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
1338
+
688
1339
  declare class Headers implements SpecIterable<[string, string]> {
689
1340
  constructor (init?: HeadersInit)
690
1341
  readonly append: (name: string, value: string) => void
@@ -692,6 +1343,7 @@ declare class Headers implements SpecIterable<[string, string]> {
692
1343
  readonly get: (name: string) => string | null
693
1344
  readonly has: (name: string) => boolean
694
1345
  readonly set: (name: string, value: string) => void
1346
+ readonly getSetCookie: () => string[]
695
1347
  readonly forEach: (
696
1348
  callbackfn: (value: string, key: string, iterable: Headers) => void,
697
1349
  thisArg?: unknown
@@ -705,6 +1357,104 @@ declare class Headers implements SpecIterable<[string, string]> {
705
1357
 
706
1358
  declare type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
707
1359
 
1360
+ /**
1361
+ * The header type declaration of `undici`.
1362
+ */
1363
+ declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1364
+
1365
+ /**
1366
+ * lists mTLS certificates for an account. filtering by name is supported
1367
+ */
1368
+ export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
1369
+
1370
+ /**
1371
+ * details for uploading an mTLS certificate via the ssl api
1372
+ */
1373
+ declare interface MTlsCertificateBody {
1374
+ certificateChain: string;
1375
+ privateKey: string;
1376
+ name?: string;
1377
+ }
1378
+
1379
+ /**
1380
+ * supported filters for listing mTLS certificates via the ssl api
1381
+ */
1382
+ declare interface MTlsCertificateListFilter {
1383
+ name?: string;
1384
+ }
1385
+
1386
+ /**
1387
+ * the representation of an mTLS certificate in the account certificate store
1388
+ */
1389
+ declare interface MTlsCertificateResponse {
1390
+ id: string;
1391
+ name?: string;
1392
+ ca: boolean;
1393
+ certificates: string;
1394
+ expires_on: string;
1395
+ issuer: string;
1396
+ serial_number: string;
1397
+ signature: string;
1398
+ uploaded_on: string;
1399
+ }
1400
+
1401
+ /**
1402
+ * details for uploading an mTLS certificate from disk
1403
+ */
1404
+ declare interface MTlsCertificateUploadDetails {
1405
+ certificateChainFilename: string;
1406
+ privateKeyFilename: string;
1407
+ name?: string;
1408
+ }
1409
+
1410
+ declare interface PagesDeployOptions {
1411
+ /**
1412
+ * Path to static assets to deploy to Pages
1413
+ */
1414
+ directory: string;
1415
+ /**
1416
+ * The Cloudflare Account ID that owns the project that's
1417
+ * being published
1418
+ */
1419
+ accountId: string;
1420
+ /**
1421
+ * The name of the project to be published
1422
+ */
1423
+ projectName: string;
1424
+ /**
1425
+ * Branch name to use. Defaults to production branch
1426
+ */
1427
+ branch?: string;
1428
+ /**
1429
+ * Whether or not to skip local file upload result caching
1430
+ */
1431
+ skipCaching?: boolean;
1432
+ /**
1433
+ * Commit message associated to deployment
1434
+ */
1435
+ commitMessage?: string;
1436
+ /**
1437
+ * Commit hash associated to deployment
1438
+ */
1439
+ commitHash?: string;
1440
+ /**
1441
+ * Whether or not the deployment should be considered to be
1442
+ * in a dirty commit state
1443
+ */
1444
+ commitDirty?: boolean;
1445
+ /**
1446
+ * Path to the project's functions directory. Default uses
1447
+ * the current working directory + /functions since this is
1448
+ * typically called in a CLI
1449
+ */
1450
+ functionsDirectory?: string;
1451
+ /**
1452
+ * Whether to run bundling on `_worker.js` before deploying.
1453
+ * Default: true
1454
+ */
1455
+ bundle?: boolean;
1456
+ }
1457
+
708
1458
  declare type ReferrerPolicy =
709
1459
  | ''
710
1460
  | 'no-referrer'
@@ -732,6 +1482,7 @@ declare class Request implements BodyMixin {
732
1482
 
733
1483
  readonly keepalive: boolean
734
1484
  readonly signal: AbortSignal
1485
+ readonly duplex: RequestDuplex
735
1486
 
736
1487
  readonly body: ReadableStream | null
737
1488
  readonly bodyUsed: boolean
@@ -775,6 +1526,8 @@ declare type RequestDestination =
775
1526
  | 'worker'
776
1527
  | 'xslt'
777
1528
 
1529
+ declare type RequestDuplex = 'half'
1530
+
778
1531
  declare type RequestInfo = string | URL_2 | Request
779
1532
 
780
1533
  declare interface RequestInit {
@@ -791,6 +1544,7 @@ declare interface RequestInit {
791
1544
  referrerPolicy?: ReferrerPolicy
792
1545
  window?: null
793
1546
  dispatcher?: Dispatcher
1547
+ duplex?: RequestDuplex
794
1548
  }
795
1549
 
796
1550
  declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
@@ -865,10 +1619,79 @@ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
865
1619
  next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
866
1620
  }
867
1621
 
1622
+ declare type TailConsumer = {
1623
+ /** The name of the service tail events will be forwarded to. */
1624
+ service: string;
1625
+ /** (Optional) The environt of the service. */
1626
+ environment?: string;
1627
+ };
1628
+
868
1629
  /**
869
1630
  * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
870
1631
  */
871
- export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<UnstableDevWorker>;
1632
+ export declare function unstable_dev(script: string, options?: UnstableDevOptions, apiOptions?: unknown): Promise<UnstableDevWorker>;
1633
+
1634
+ export declare const unstable_pages: {
1635
+ deploy: typeof deploy;
1636
+ };
1637
+
1638
+ export declare interface UnstableDevOptions {
1639
+ config?: string;
1640
+ env?: string;
1641
+ ip?: string;
1642
+ port?: number;
1643
+ bundle?: boolean;
1644
+ inspectorPort?: number;
1645
+ localProtocol?: "http" | "https";
1646
+ assets?: string;
1647
+ site?: string;
1648
+ siteInclude?: string[];
1649
+ siteExclude?: string[];
1650
+ nodeCompat?: boolean;
1651
+ compatibilityDate?: string;
1652
+ compatibilityFlags?: string[];
1653
+ persist?: boolean;
1654
+ persistTo?: string;
1655
+ vars?: {
1656
+ [key: string]: unknown;
1657
+ };
1658
+ kv?: {
1659
+ binding: string;
1660
+ id: string;
1661
+ preview_id?: string;
1662
+ }[];
1663
+ durableObjects?: {
1664
+ name: string;
1665
+ class_name: string;
1666
+ script_name?: string | undefined;
1667
+ environment?: string | undefined;
1668
+ }[];
1669
+ r2?: {
1670
+ binding: string;
1671
+ bucket_name: string;
1672
+ preview_bucket_name?: string;
1673
+ }[];
1674
+ moduleRoot?: string;
1675
+ rules?: Rule[];
1676
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
1677
+ inspect?: boolean;
1678
+ local?: boolean;
1679
+ accountId?: string;
1680
+ experimental?: {
1681
+ processEntrypoint?: boolean;
1682
+ additionalModules?: CfModule[];
1683
+ d1Databases?: Environment["d1_databases"];
1684
+ disableExperimentalWarning?: boolean;
1685
+ disableDevRegistry?: boolean;
1686
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
1687
+ forceLocal?: boolean;
1688
+ liveReload?: boolean;
1689
+ showInteractiveDevSession?: boolean;
1690
+ testMode?: boolean;
1691
+ testScheduled?: boolean;
1692
+ watch?: boolean;
1693
+ };
1694
+ }
872
1695
 
873
1696
  export declare interface UnstableDevWorker {
874
1697
  port: number;
@@ -878,6 +1701,16 @@ export declare interface UnstableDevWorker {
878
1701
  waitUntilExit: () => Promise<void>;
879
1702
  }
880
1703
 
1704
+ /**
1705
+ * uploads an mTLS certificate and private key pair to the account mTLS certificate store
1706
+ */
1707
+ export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
1708
+
1709
+ /**
1710
+ * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
1711
+ */
1712
+ export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
1713
+
881
1714
  declare type ZoneIdRoute = {
882
1715
  pattern: string;
883
1716
  zone_id: string;