nitro 3.0.260429-beta → 3.0.260603-beta

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 (76) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  2. package/dist/_build/common.mjs +142 -35
  3. package/dist/_build/rolldown.mjs +12 -8
  4. package/dist/_build/rollup.mjs +11 -11
  5. package/dist/_build/vite.build.mjs +3 -3
  6. package/dist/_build/vite.dev.mjs +149 -0
  7. package/dist/_build/vite.env.mjs +177 -0
  8. package/dist/_chunks/nitro.mjs +252 -17
  9. package/dist/_chunks/nitro2.mjs +117 -90
  10. package/dist/_chunks/utils.mjs +4 -4
  11. package/dist/_common.mjs +1 -1
  12. package/dist/_dev.d.mts +1 -1
  13. package/dist/_dev.mjs +5 -5
  14. package/dist/_libs/c12+rc9.mjs +11 -10
  15. package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
  16. package/dist/_libs/citty.mjs +1 -1
  17. package/dist/_libs/common.d.mts +37 -0
  18. package/dist/_libs/commondir+is-reference.mjs +5 -5
  19. package/dist/_libs/compatx.d.mts +1 -1
  20. package/dist/_libs/compatx.mjs +1 -1
  21. package/dist/_libs/estree+pluginutils.d.mts +1 -1
  22. package/dist/_libs/estree-walker.mjs +1 -1
  23. package/dist/_libs/hasown+resolve+deepmerge.mjs +15 -15
  24. package/dist/_libs/httpxy.d.mts +2 -1
  25. package/dist/_libs/httpxy.mjs +8 -4
  26. package/dist/_libs/klona.mjs +1 -1
  27. package/dist/_libs/magic-string.d.mts +1 -1
  28. package/dist/_libs/mlly.d.mts +1 -1
  29. package/dist/_libs/nypm+tinyexec.mjs +150 -434
  30. package/dist/_libs/openapi-types.d.mts +730 -0
  31. package/dist/_libs/perfect-debounce.mjs +1 -1
  32. package/dist/_libs/pkg-types.d.mts +1 -1
  33. package/dist/_libs/plugin-alias.mjs +2 -2
  34. package/dist/_libs/plugin-inject.mjs +3 -3
  35. package/dist/_libs/plugin-json.mjs +2 -2
  36. package/dist/_libs/pluginutils.mjs +16 -5
  37. package/dist/_libs/readdirp+chokidar.mjs +2 -2
  38. package/dist/_libs/remapping.mjs +2 -2
  39. package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
  40. package/dist/_libs/rou3.d.mts +1 -1
  41. package/dist/_libs/rou3.mjs +1 -1
  42. package/dist/_libs/std-env.d.mts +1 -1
  43. package/dist/_libs/tsconfck.mjs +1 -1
  44. package/dist/_libs/ultrahtml.mjs +1 -1
  45. package/dist/_libs/undici+jsonc-parser.d.mts +2418 -0
  46. package/dist/_libs/{unimport+unplugin+oxc-parser.mjs → unimport+unplugin.mjs} +18 -8
  47. package/dist/_libs/unplugin+unimport.d.mts +3 -3
  48. package/dist/_libs/unwasm.d.mts +1 -1
  49. package/dist/_presets.mjs +131 -91
  50. package/dist/builder.d.mts +1 -1
  51. package/dist/builder.mjs +3 -3
  52. package/dist/cli/_chunks/build.mjs +3 -3
  53. package/dist/cli/_chunks/common.mjs +1 -1
  54. package/dist/cli/_chunks/deploy.mjs +2 -2
  55. package/dist/cli/_chunks/dev.mjs +4 -4
  56. package/dist/cli/_chunks/docs.mjs +1 -1
  57. package/dist/cli/_chunks/list.mjs +2 -2
  58. package/dist/cli/_chunks/prepare.mjs +3 -3
  59. package/dist/cli/_chunks/preview.mjs +4 -4
  60. package/dist/cli/_chunks/run.mjs +2 -2
  61. package/dist/cli/_chunks/task.mjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
  64. package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
  65. package/dist/docs/2.config/0.index/index.md +14 -0
  66. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
  67. package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
  68. package/dist/runtime/internal/app.mjs +4 -111
  69. package/dist/runtime/virtual/app.d.mts +4 -0
  70. package/dist/runtime/virtual/app.mjs +32 -0
  71. package/dist/types/index.d.mts +51 -1756
  72. package/dist/vite.mjs +29 -339
  73. package/package.json +39 -41
  74. package/dist/THIRD-PARTY-LICENSES.md +0 -1676
  75. package/dist/_chunks/nitro3.mjs +0 -136
  76. package/dist/_chunks/nitro4.mjs +0 -127
@@ -0,0 +1,2418 @@
1
+ /// <reference types="node" />
2
+ import { URL as URL$1, URLSearchParams } from "node:url";
3
+ import { EventEmitter } from "node:events";
4
+ import { Duplex, Readable, Writable } from "node:stream";
5
+ import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from "node:net";
6
+ import { Blob, File } from "node:buffer";
7
+ import { ConnectionOptions, TLSSocket } from "node:tls";
8
+ type Json = string | number | boolean | null | Json[] | {
9
+ [id: string]: Json;
10
+ };
11
+ /**
12
+ * The `Environment` interface declares all the configuration fields that
13
+ * can be specified for an environment.
14
+ *
15
+ * This could be the top-level default environment, or a specific named environment.
16
+ */
17
+ interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {}
18
+ type SimpleRoute = string;
19
+ type ZoneIdRoute = {
20
+ pattern: string;
21
+ zone_id: string;
22
+ custom_domain?: boolean;
23
+ };
24
+ type ZoneNameRoute = {
25
+ pattern: string;
26
+ zone_name: string;
27
+ custom_domain?: boolean;
28
+ };
29
+ type CustomDomainRoute = {
30
+ pattern: string;
31
+ custom_domain: boolean;
32
+ enabled?: boolean;
33
+ previews_enabled?: boolean;
34
+ };
35
+ type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
36
+ /**
37
+ * Configuration in wrangler for Cloudchamber
38
+ */
39
+ type CloudchamberConfig = {
40
+ image?: string;
41
+ location?: string;
42
+ instance_type?: "dev" | "basic" | "standard" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4";
43
+ vcpu?: number;
44
+ memory?: string;
45
+ ipv4?: boolean;
46
+ };
47
+ type UnsafeBinding = {
48
+ /**
49
+ * The name of the binding provided to the Worker
50
+ */
51
+ name: string;
52
+ /**
53
+ * The 'type' of the unsafe binding.
54
+ */
55
+ type: string;
56
+ dev?: {
57
+ plugin: {
58
+ /**
59
+ * Package is the bare specifier of the package that exposes plugins to integrate into Miniflare via a named `plugins` export.
60
+ * @example "@cloudflare/my-external-miniflare-plugin"
61
+ */
62
+ package: string;
63
+ /**
64
+ * Plugin is the name of the plugin exposed by the package.
65
+ * @example "MY_UNSAFE_PLUGIN"
66
+ */
67
+ name: string;
68
+ };
69
+ /**
70
+ * Optional mapping of unsafe bindings names to options provided for the plugin.
71
+ */
72
+ options?: Record<string, unknown>;
73
+ };
74
+ [key: string]: unknown;
75
+ };
76
+ /**
77
+ * Configuration for a container application
78
+ */
79
+ type ContainerApp = {
80
+ /**
81
+ * Name of the application
82
+ * @optional Defaults to `worker_name-class_name` if not specified.
83
+ */
84
+ name?: string;
85
+ /**
86
+ * Number of application instances
87
+ * @deprecated
88
+ * @hidden
89
+ */
90
+ instances?: number;
91
+ /**
92
+ * Number of maximum application instances.
93
+ * @optional
94
+ */
95
+ max_instances?: number;
96
+ /**
97
+ * The path to a Dockerfile, or an image URI for the Cloudflare registry.
98
+ */
99
+ image: string;
100
+ /**
101
+ * Build context of the application.
102
+ * @optional - defaults to the directory of `image`.
103
+ */
104
+ image_build_context?: string;
105
+ /**
106
+ * Image variables available to the image at build-time only.
107
+ * For runtime env vars, refer to https://developers.cloudflare.com/containers/examples/env-vars-and-secrets/
108
+ * @optional
109
+ */
110
+ image_vars?: Record<string, string>;
111
+ /**
112
+ * The class name of the Durable Object the container is connected to.
113
+ */
114
+ class_name: string;
115
+ /**
116
+ * The scheduling policy of the application
117
+ * @optional
118
+ * @default "default"
119
+ */
120
+ scheduling_policy?: "default" | "moon" | "regional";
121
+ /**
122
+ * The instance type to be used for the container.
123
+ * Select from one of the following named instance types:
124
+ * - lite: 1/16 vCPU, 256 MiB memory, and 2 GB disk
125
+ * - basic: 1/4 vCPU, 1 GiB memory, and 4 GB disk
126
+ * - standard-1: 1/2 vCPU, 4 GiB memory, and 8 GB disk
127
+ * - standard-2: 1 vCPU, 6 GiB memory, and 12 GB disk
128
+ * - standard-3: 2 vCPU, 8 GiB memory, and 16 GB disk
129
+ * - standard-4: 4 vCPU, 12 GiB memory, and 20 GB disk
130
+ * - dev: 1/16 vCPU, 256 MiB memory, and 2 GB disk (deprecated, use "lite" instead)
131
+ * - standard: 1 vCPU, 4 GiB memory, and 4 GB disk (deprecated, use "standard-1" instead)
132
+ *
133
+ * Customers on an enterprise plan have the additional option to set custom limits.
134
+ *
135
+ * @optional
136
+ * @default "dev"
137
+ */
138
+ instance_type?: "dev" | "basic" | "standard" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4" | {
139
+ /** @defaults to 0.0625 (1/16 vCPU) */vcpu?: number; /** @defaults to 256 MiB */
140
+ memory_mib?: number; /** @defaults to 2 GB */
141
+ disk_mb?: number;
142
+ };
143
+ ssh?: {
144
+ /**
145
+ * If enabled, those with write access to a container will be able to SSH into it through Wrangler.
146
+ * @default false
147
+ */
148
+ enabled: boolean;
149
+ /**
150
+ * Port that the SSH service is running on
151
+ * @defaults to 22
152
+ */
153
+ port?: number;
154
+ };
155
+ /**
156
+ * @deprecated Use `ssh` instead.
157
+ * @hidden
158
+ */
159
+ wrangler_ssh?: {
160
+ enabled: boolean;
161
+ port?: number;
162
+ };
163
+ /**
164
+ * SSH public keys to put in the container's authorized_keys file.
165
+ */
166
+ authorized_keys?: {
167
+ name: string;
168
+ public_key: string;
169
+ }[];
170
+ /**
171
+ * Trusted user CA keys to put in the container's trusted_user_ca_keys file.
172
+ */
173
+ trusted_user_ca_keys?: {
174
+ name?: string;
175
+ public_key: string;
176
+ }[];
177
+ /**
178
+ * @deprecated Use top level `containers` fields instead.
179
+ * `configuration.image` should be `image`
180
+ * limits should be set via `instance_type`
181
+ * @hidden
182
+ */
183
+ configuration?: {
184
+ image?: string;
185
+ labels?: {
186
+ name: string;
187
+ value: string;
188
+ }[];
189
+ secrets?: {
190
+ name: string;
191
+ type: "env";
192
+ secret: string;
193
+ }[];
194
+ disk?: {
195
+ size_mb: number;
196
+ };
197
+ vcpu?: number;
198
+ memory_mib?: number;
199
+ };
200
+ /**
201
+ * Scheduling constraints for container placement.
202
+ */
203
+ constraints?: {
204
+ /**
205
+ * Limit container placement to specific geographic regions.
206
+ */
207
+ regions?: ("ENAM" | "WNAM" | "EEUR" | "WEUR" | "APAC" | "SAM" | "ME" | "OC" | "AFR")[];
208
+ /**
209
+ * Restrict containers to compliance boundaries.
210
+ */
211
+ jurisdiction?: "eu" | "fedramp";
212
+ /**
213
+ * @hidden
214
+ */
215
+ cities?: string[];
216
+ /**
217
+ * @deprecated Use `tiers` instead
218
+ * @hidden
219
+ */
220
+ tier?: number;
221
+ /**
222
+ * @hidden
223
+ */
224
+ tiers?: number[];
225
+ };
226
+ /**
227
+ * Scheduling affinities
228
+ * @hidden
229
+ */
230
+ affinities?: {
231
+ colocation?: "datacenter";
232
+ hardware_generation?: "highest-overall-performance";
233
+ };
234
+ /**
235
+ * @deprecated use the `class_name` field instead.
236
+ * @hidden
237
+ */
238
+ durable_objects?: {
239
+ namespace_id: string;
240
+ };
241
+ /**
242
+ * Configures what percentage of instances should be updated at each step of a rollout.
243
+ * You can specify this as a single number, or an array of numbers.
244
+ *
245
+ * If this is a single number, each step will progress by that percentage.
246
+ * The options are 5, 10, 20, 25, 50 or 100.
247
+ *
248
+ * If this is an array, each step specifies the cumulative rollout progress.
249
+ * The final step must be 100.
250
+ *
251
+ * This can be overridden adhoc by deploying with the `--containers-rollout=immediate` flag,
252
+ * which will roll out to 100% of instances in one step.
253
+ *
254
+ * @optional
255
+ * @default [10,100]
256
+ * */
257
+ rollout_step_percentage?: number | number[];
258
+ /**
259
+ * How a rollout should be created. It supports the following modes:
260
+ * - full_auto: The container application will be rolled out fully automatically.
261
+ * - none: The container application won't have a roll out or update.
262
+ * - manual: The container application will be rollout fully by manually actioning progress steps.
263
+ * @optional
264
+ * @default "full_auto"
265
+ * @hidden
266
+ */
267
+ rollout_kind?: "full_auto" | "none" | "full_manual";
268
+ /**
269
+ * Configures the grace period (in seconds) for active instances before being shutdown during a rollout.
270
+ * @optional
271
+ * @default 0
272
+ */
273
+ rollout_active_grace_period?: number;
274
+ /**
275
+ * Directly passed to the API without wrangler-side validation or transformation.
276
+ * @hidden
277
+ */
278
+ unsafe?: Record<string, unknown>;
279
+ };
280
+ /**
281
+ * Configuration in wrangler for Durable Object Migrations
282
+ */
283
+ type DurableObjectMigration = {
284
+ /** A unique identifier for this migration. */tag: string; /** The new Durable Objects being defined. */
285
+ new_classes?: string[]; /** The new SQLite Durable Objects being defined. */
286
+ new_sqlite_classes?: string[]; /** The Durable Objects being renamed. */
287
+ renamed_classes?: {
288
+ from: string;
289
+ to: string;
290
+ }[]; /** The Durable Objects being removed. */
291
+ deleted_classes?: string[];
292
+ };
293
+ /**
294
+ * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
295
+ * that can be inherited (and overridden) from the top-level environment.
296
+ */
297
+ interface EnvironmentInheritable {
298
+ /**
299
+ * The name of your Worker. Alphanumeric + dashes only.
300
+ *
301
+ * @inheritable
302
+ */
303
+ name: string | undefined;
304
+ /**
305
+ * This is the ID of the account associated with your zone.
306
+ * You might have more than one account, so make sure to use
307
+ * the ID of the account associated with the zone/route you
308
+ * provide, if you provide one. It can also be specified through
309
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
310
+ *
311
+ * @inheritable
312
+ */
313
+ account_id: string | undefined;
314
+ /**
315
+ * A date in the form yyyy-mm-dd, which will be used to determine
316
+ * which version of the Workers runtime is used.
317
+ *
318
+ * More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
319
+ *
320
+ * @inheritable
321
+ */
322
+ compatibility_date: string | undefined;
323
+ /**
324
+ * A list of flags that enable features from upcoming features of
325
+ * the Workers runtime, usually used together with compatibility_date.
326
+ *
327
+ * More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
328
+ *
329
+ * @default []
330
+ * @inheritable
331
+ */
332
+ compatibility_flags: string[];
333
+ /**
334
+ * The entrypoint/path to the JavaScript file that will be executed.
335
+ *
336
+ * @inheritable
337
+ */
338
+ main: string | undefined;
339
+ /**
340
+ * If true then Wrangler will traverse the file tree below `base_dir`;
341
+ * Any files that match `rules` will be included in the deployed Worker.
342
+ * Defaults to true if `no_bundle` is true, otherwise false.
343
+ *
344
+ * @inheritable
345
+ */
346
+ find_additional_modules: boolean | undefined;
347
+ /**
348
+ * Determines whether Wrangler will preserve bundled file names.
349
+ * Defaults to false.
350
+ * If left unset, files will be named using the pattern ${fileHash}-${basename},
351
+ * for example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
352
+ *
353
+ * @inheritable
354
+ */
355
+ preserve_file_names: boolean | undefined;
356
+ /**
357
+ * The directory in which module rules should be evaluated when including additional files into a Worker deployment.
358
+ * This defaults to the directory containing the `main` entry point of the Worker if not specified.
359
+ *
360
+ * @inheritable
361
+ */
362
+ base_dir: string | undefined;
363
+ /**
364
+ * Whether we use <name>.<subdomain>.workers.dev to
365
+ * test and deploy your Worker.
366
+ *
367
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
368
+ *
369
+ * @default true
370
+ * @breaking
371
+ * @inheritable
372
+ */
373
+ workers_dev: boolean | undefined;
374
+ /**
375
+ * Whether we use <version>-<name>.<subdomain>.workers.dev to
376
+ * serve Preview URLs for your Worker.
377
+ *
378
+ * @default false
379
+ * @inheritable
380
+ */
381
+ preview_urls: boolean | undefined;
382
+ /**
383
+ * A list of routes that your Worker should be published to.
384
+ * Only one of `routes` or `route` is required.
385
+ *
386
+ * Only required when workers_dev is false, and there's no scheduled Worker (see `triggers`)
387
+ *
388
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
389
+ *
390
+ * @inheritable
391
+ */
392
+ routes: Route[] | undefined;
393
+ /**
394
+ * A route that your Worker should be published to. Literally
395
+ * the same as routes, but only one.
396
+ * Only one of `routes` or `route` is required.
397
+ *
398
+ * Only required when workers_dev is false, and there's no scheduled Worker
399
+ *
400
+ * @inheritable
401
+ */
402
+ route: Route | undefined;
403
+ /**
404
+ * Path to a custom tsconfig
405
+ *
406
+ * @inheritable
407
+ */
408
+ tsconfig: string | undefined;
409
+ /**
410
+ * The function to use to replace jsx syntax.
411
+ *
412
+ * @default "React.createElement"
413
+ * @inheritable
414
+ */
415
+ jsx_factory: string;
416
+ /**
417
+ * The function to use to replace jsx fragment syntax.
418
+ *
419
+ * @default "React.Fragment"
420
+ * @inheritable
421
+ */
422
+ jsx_fragment: string;
423
+ /**
424
+ * A list of migrations that should be uploaded with your Worker.
425
+ *
426
+ * These define changes in your Durable Object declarations.
427
+ *
428
+ * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
429
+ *
430
+ * @default []
431
+ * @inheritable
432
+ */
433
+ migrations: DurableObjectMigration[];
434
+ /**
435
+ * "Cron" definitions to trigger a Worker's "scheduled" function.
436
+ *
437
+ * Lets you call Workers periodically, much like a cron job.
438
+ *
439
+ * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
440
+ *
441
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
442
+ *
443
+ * @default {crons:[]}
444
+ * @inheritable
445
+ */
446
+ triggers: {
447
+ crons: string[] | undefined;
448
+ };
449
+ /**
450
+ * Specify limits for runtime behavior.
451
+ * Only supported for the "standard" Usage Model
452
+ *
453
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
454
+ *
455
+ * @inheritable
456
+ */
457
+ limits: UserLimits | undefined;
458
+ /**
459
+ * An ordered list of rules that define which modules to import,
460
+ * and what type to import them as. You will need to specify rules
461
+ * to use Text, Data, and CompiledWasm modules, or when you wish to
462
+ * have a .js file be treated as an ESModule instead of CommonJS.
463
+ *
464
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#bundling
465
+ *
466
+ * @inheritable
467
+ */
468
+ rules: Rule[];
469
+ /**
470
+ * Configures a custom build step to be run by Wrangler when building your Worker.
471
+ *
472
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
473
+ * for more details.
474
+ *
475
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#custom-builds
476
+ *
477
+ * @default {watch_dir:"./src"}
478
+ */
479
+ build: {
480
+ /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */command?: string; /** The directory in which the command is executed. */
481
+ cwd?: string; /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
482
+ watch_dir?: string | string[];
483
+ };
484
+ /**
485
+ * Skip internal build steps and directly deploy script
486
+ * @inheritable
487
+ */
488
+ no_bundle: boolean | undefined;
489
+ /**
490
+ * Minify the script before uploading.
491
+ * @inheritable
492
+ */
493
+ minify: boolean | undefined;
494
+ /**
495
+ * Set the `name` property to the original name for functions and classes renamed during minification.
496
+ *
497
+ * See https://esbuild.github.io/api/#keep-names
498
+ *
499
+ * @default true
500
+ * @inheritable
501
+ */
502
+ keep_names: boolean | undefined;
503
+ /**
504
+ * Designates this Worker as an internal-only "first-party" Worker.
505
+ *
506
+ * @inheritable
507
+ */
508
+ first_party_worker: boolean | undefined;
509
+ /**
510
+ * List of bindings that you will send to logfwdr
511
+ *
512
+ * @default {bindings:[]}
513
+ * @inheritable
514
+ */
515
+ logfwdr: {
516
+ bindings: {
517
+ /** The binding name used to refer to logfwdr */name: string; /** The destination for this logged message */
518
+ destination: string;
519
+ }[];
520
+ };
521
+ /**
522
+ * Send Trace Events from this Worker to Workers Logpush.
523
+ *
524
+ * This will not configure a corresponding Logpush job automatically.
525
+ *
526
+ * For more information about Workers Logpush, see:
527
+ * https://blog.cloudflare.com/logpush-for-workers/
528
+ *
529
+ * @inheritable
530
+ */
531
+ logpush: boolean | undefined;
532
+ /**
533
+ * Include source maps when uploading this worker.
534
+ *
535
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#source-maps
536
+ *
537
+ * @inheritable
538
+ */
539
+ upload_source_maps: boolean | undefined;
540
+ /**
541
+ * Specify how the Worker should be located to minimize round-trip time.
542
+ *
543
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
544
+ *
545
+ * @inheritable
546
+ */
547
+ placement: {
548
+ mode: "off" | "smart";
549
+ hint?: string;
550
+ } | {
551
+ mode?: "targeted";
552
+ region: string;
553
+ } | {
554
+ mode?: "targeted";
555
+ host: string;
556
+ } | {
557
+ mode?: "targeted";
558
+ hostname: string;
559
+ } | undefined;
560
+ /**
561
+ * Specify the directory of static assets to deploy/serve
562
+ *
563
+ * More details at https://developers.cloudflare.com/workers/frameworks/
564
+ *
565
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
566
+ *
567
+ * @inheritable
568
+ */
569
+ assets: Assets | undefined;
570
+ /**
571
+ * Specify the observability behavior of the Worker.
572
+ *
573
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
574
+ *
575
+ * @inheritable
576
+ */
577
+ observability: Observability | undefined;
578
+ /**
579
+ * Specify the cache behavior of the Worker.
580
+ *
581
+ * @inheritable
582
+ */
583
+ cache: CacheOptions$1 | undefined;
584
+ /**
585
+ * Specify the compliance region mode of the Worker.
586
+ *
587
+ * Although if the user does not specify a compliance region, the default is `public`,
588
+ * it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
589
+ */
590
+ compliance_region: "public" | "fedramp_high" | undefined;
591
+ /**
592
+ * Configuration for Python modules.
593
+ *
594
+ * @inheritable
595
+ */
596
+ python_modules: {
597
+ /**
598
+ * A list of glob patterns to exclude files from the python_modules directory when bundling.
599
+ *
600
+ * Patterns are relative to the python_modules directory and use glob syntax.
601
+ *
602
+ * @default ["**\*.pyc"]
603
+ */
604
+ exclude: string[];
605
+ };
606
+ /**
607
+ * Configuration for Worker Previews.
608
+ *
609
+ * Previews are branches of your Worker's main instance used to test features
610
+ * in development outside of production. This block defines the settings
611
+ * used when creating Preview deployments via `wrangler preview`.
612
+ *
613
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#previews
614
+ *
615
+ * @inheritable
616
+ */
617
+ previews: PreviewsConfig | undefined;
618
+ }
619
+ type DurableObjectBindings = {
620
+ /** The name of the binding used to refer to the Durable Object */name: string; /** The exported class name of the Durable Object */
621
+ class_name: string; /** The script where the Durable Object is defined (if it's external to this Worker) */
622
+ script_name?: string; /** The service environment of the script_name to bind to */
623
+ environment?: string;
624
+ }[];
625
+ type WorkflowBinding = {
626
+ /** The name of the binding used to refer to the Workflow */binding: string; /** The name of the Workflow */
627
+ name: string; /** The exported class name of the Workflow */
628
+ class_name: string; /** The script where the Workflow is defined (if it's external to this Worker) */
629
+ script_name?: string; /** Whether the Workflow should be remote or not in local development */
630
+ remote?: boolean; /** Optional limits for the Workflow */
631
+ limits?: {
632
+ /** Maximum number of steps a Workflow instance can execute */steps?: number;
633
+ }; /** Optional cron schedule(s) for automatically triggering workflow instances */
634
+ schedules?: string | string[];
635
+ };
636
+ /**
637
+ * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
638
+ * that cannot be inherited from the top-level environment, and must be defined specifically.
639
+ *
640
+ * If any of these fields are defined at the top-level then they should also be specifically defined
641
+ * for each named environment.
642
+ */
643
+ interface EnvironmentNonInheritable {
644
+ /**
645
+ * A map of values to substitute when deploying your Worker.
646
+ *
647
+ * NOTE: This field is not automatically inherited from the top level environment,
648
+ * and so must be specified in every named environment.
649
+ *
650
+ * @default {}
651
+ * @nonInheritable
652
+ */
653
+ define: Record<string, string>;
654
+ /**
655
+ * A map of environment variables to set when deploying your Worker.
656
+ *
657
+ * NOTE: This field is not automatically inherited from the top level environment,
658
+ * and so must be specified in every named environment.
659
+ *
660
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
661
+ *
662
+ * @default {}
663
+ * @nonInheritable
664
+ */
665
+ vars: Record<string, string | Json>;
666
+ /**
667
+ * Secrets configuration.
668
+ *
669
+ * NOTE: This field is not automatically inherited from the top level environment,
670
+ * and so must be specified in every named environment.
671
+ *
672
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#secrets-configuration-property
673
+ *
674
+ * @nonInheritable
675
+ */
676
+ secrets?: {
677
+ /**
678
+ * List of secret names that are required by your Worker.
679
+ * When defined, this property:
680
+ * - Replaces .dev.vars/.env/process.env inference for type generation
681
+ * - Enables local dev validation with warnings for missing secrets
682
+ */
683
+ required?: string[];
684
+ };
685
+ /**
686
+ * A list of durable objects that your Worker should be bound to.
687
+ *
688
+ * For more information about Durable Objects, see the documentation at
689
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
690
+ *
691
+ * NOTE: This field is not automatically inherited from the top level environment,
692
+ * and so must be specified in every named environment.
693
+ *
694
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
695
+ *
696
+ * @default {bindings:[]}
697
+ * @nonInheritable
698
+ */
699
+ durable_objects: {
700
+ bindings: DurableObjectBindings;
701
+ };
702
+ /**
703
+ * A list of workflows that your Worker should be bound to.
704
+ *
705
+ * NOTE: This field is not automatically inherited from the top level environment,
706
+ * and so must be specified in every named environment.
707
+ *
708
+ * @default []
709
+ * @nonInheritable
710
+ */
711
+ workflows: WorkflowBinding[];
712
+ /**
713
+ * Cloudchamber configuration
714
+ *
715
+ * NOTE: This field is not automatically inherited from the top level environment,
716
+ * and so must be specified in every named environment.
717
+ *
718
+ * @default {}
719
+ * @nonInheritable
720
+ */
721
+ cloudchamber: CloudchamberConfig;
722
+ /**
723
+ * Container related configuration
724
+ *
725
+ * NOTE: This field is not automatically inherited from the top level environment,
726
+ * and so must be specified in every named environment.
727
+ *
728
+ * @default []
729
+ * @nonInheritable
730
+ */
731
+ containers?: ContainerApp[];
732
+ /**
733
+ * These specify any Workers KV Namespaces you want to
734
+ * access from inside your Worker.
735
+ *
736
+ * To learn more about KV Namespaces,
737
+ * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
738
+ *
739
+ * NOTE: This field is not automatically inherited from the top level environment,
740
+ * and so must be specified in every named environment.
741
+ *
742
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
743
+ *
744
+ * @default []
745
+ * @nonInheritable
746
+ */
747
+ kv_namespaces: {
748
+ /** The binding name used to refer to the KV Namespace */binding: string; /** The ID of the KV namespace */
749
+ id?: string; /** The ID of the KV namespace used during `wrangler dev` */
750
+ preview_id?: string; /** Whether the KV namespace should be remote or not in local development */
751
+ remote?: boolean;
752
+ }[];
753
+ /**
754
+ * These specify bindings to send email from inside your Worker.
755
+ *
756
+ * NOTE: This field is not automatically inherited from the top level environment,
757
+ * and so must be specified in every named environment.
758
+ *
759
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
760
+ *
761
+ * @default []
762
+ * @nonInheritable
763
+ */
764
+ send_email: {
765
+ /** The binding name used to refer to the this binding */name: string; /** If this binding should be restricted to a specific verified address */
766
+ destination_address?: string; /** If this binding should be restricted to a set of verified addresses */
767
+ allowed_destination_addresses?: string[]; /** If this binding should be restricted to a set of sender addresses */
768
+ allowed_sender_addresses?: string[]; /** Whether the binding should be remote or not in local development */
769
+ remote?: boolean;
770
+ }[];
771
+ /**
772
+ * Specifies Queues that are bound to this Worker environment.
773
+ *
774
+ * NOTE: This field is not automatically inherited from the top level environment,
775
+ * and so must be specified in every named environment.
776
+ *
777
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
778
+ *
779
+ * @default {consumers:[],producers:[]}
780
+ * @nonInheritable
781
+ */
782
+ queues: {
783
+ /** Producer bindings */producers?: {
784
+ /** The binding name used to refer to the Queue in the Worker. */binding: string; /** The name of this Queue. */
785
+ queue: string; /** The number of seconds to wait before delivering a message */
786
+ delivery_delay?: number; /** Whether the Queue producer should be remote or not in local development */
787
+ remote?: boolean;
788
+ }[]; /** Consumer configuration */
789
+ consumers?: {
790
+ /** The name of the queue from which this consumer should consume. */queue: string; /** The consumer type. Only "worker" is supported in wrangler config. Default is "worker". */
791
+ type?: "worker"; /** The maximum number of messages per batch */
792
+ max_batch_size?: number; /** The maximum number of seconds to wait to fill a batch with messages. */
793
+ max_batch_timeout?: number; /** The maximum number of retries for each message. */
794
+ max_retries?: number; /** The queue to send messages that failed to be consumed. */
795
+ dead_letter_queue?: string; /** 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. */
796
+ max_concurrency?: number | null; /** The number of milliseconds to wait for pulled messages to become visible again */
797
+ visibility_timeout_ms?: number; /** The number of seconds to wait before retrying a message */
798
+ retry_delay?: number;
799
+ }[];
800
+ };
801
+ /**
802
+ * Specifies R2 buckets that are bound to this Worker environment.
803
+ *
804
+ * NOTE: This field is not automatically inherited from the top level environment,
805
+ * and so must be specified in every named environment.
806
+ *
807
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
808
+ *
809
+ * @default []
810
+ * @nonInheritable
811
+ */
812
+ r2_buckets: {
813
+ /** The binding name used to refer to the R2 bucket in the Worker. */binding: string; /** The name of this R2 bucket at the edge. */
814
+ bucket_name?: string; /** The preview name of this R2 bucket at the edge. */
815
+ preview_bucket_name?: string; /** The jurisdiction that the bucket exists in. Default if not present. */
816
+ jurisdiction?: string; /** Whether the R2 bucket should be remote or not in local development */
817
+ remote?: boolean;
818
+ }[];
819
+ /**
820
+ * Specifies D1 databases that are bound to this Worker environment.
821
+ *
822
+ * NOTE: This field is not automatically inherited from the top level environment,
823
+ * and so must be specified in every named environment.
824
+ *
825
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
826
+ *
827
+ * @default []
828
+ * @nonInheritable
829
+ */
830
+ d1_databases: {
831
+ /** The binding name used to refer to the D1 database in the Worker. */binding: string; /** The name of this D1 database. */
832
+ database_name?: string; /** The UUID of this D1 database (not required). */
833
+ database_id?: string; /** The UUID of this D1 database for Wrangler Dev (if specified). */
834
+ preview_database_id?: string; /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
835
+ migrations_table?: string; /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
836
+ migrations_dir?: string; /** Internal use only. */
837
+ database_internal_env?: string; /** Whether the D1 database should be remote or not in local development */
838
+ remote?: boolean;
839
+ }[];
840
+ /**
841
+ * Specifies Vectorize indexes that are bound to this Worker environment.
842
+ *
843
+ * NOTE: This field is not automatically inherited from the top level environment,
844
+ * and so must be specified in every named environment.
845
+ *
846
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
847
+ *
848
+ * @default []
849
+ * @nonInheritable
850
+ */
851
+ vectorize: {
852
+ /** The binding name used to refer to the Vectorize index in the Worker. */binding: string; /** The name of the index. */
853
+ index_name: string; /** Whether the Vectorize index should be remote or not in local development */
854
+ remote?: boolean;
855
+ }[];
856
+ /**
857
+ * Specifies AI Search namespace bindings that are bound to this Worker environment.
858
+ * Each binding is scoped to a namespace and allows dynamic instance CRUD within it.
859
+ *
860
+ * NOTE: This field is not automatically inherited from the top level environment,
861
+ * and so must be specified in every named environment.
862
+ *
863
+ * @default []
864
+ * @nonInheritable
865
+ */
866
+ ai_search_namespaces: {
867
+ /** The binding name used to refer to the AI Search namespace in the Worker. */binding: string; /** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
868
+ namespace: string; /** Whether the AI Search namespace binding should be remote in local development */
869
+ remote?: boolean;
870
+ }[];
871
+ /**
872
+ * Specifies AI Search instance bindings that are bound to this Worker environment.
873
+ * Each binding is bound directly to a single pre-existing instance within the "default" namespace.
874
+ *
875
+ * NOTE: This field is not automatically inherited from the top level environment,
876
+ * and so must be specified in every named environment.
877
+ *
878
+ * @default []
879
+ * @nonInheritable
880
+ */
881
+ ai_search: {
882
+ /** The binding name used to refer to the AI Search instance in the Worker. */binding: string; /** The user-chosen instance name. Must exist in Cloudflare at deploy time. */
883
+ instance_name: string; /** Whether the AI Search instance binding should be remote in local development */
884
+ remote?: boolean;
885
+ }[];
886
+ /**
887
+ * Specifies Agent Memory namespace bindings that are bound to this Worker environment.
888
+ *
889
+ * NOTE: This field is not automatically inherited from the top level environment,
890
+ * and so must be specified in every named environment.
891
+ *
892
+ * @default []
893
+ * @nonInheritable
894
+ */
895
+ agent_memory: {
896
+ /** The binding name used to refer to the Agent Memory namespace in the Worker. */binding: string; /** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
897
+ namespace: string; /** Whether the Agent Memory binding should be remote in local development */
898
+ remote?: boolean;
899
+ }[];
900
+ /**
901
+ * Cloudflare Web Search binding. There is exactly one shared web corpus, so the
902
+ * binding is zero-config -- only the variable name is required, declared as a
903
+ * single object (not an array).
904
+ *
905
+ * NOTE: This field is not automatically inherited from the top level environment,
906
+ * and so must be specified in every named environment.
907
+ *
908
+ * @default {}
909
+ * @nonInheritable
910
+ */
911
+ web_search: {
912
+ /** The binding name used to refer to Web Search in the Worker. */binding: string; /** Whether the Web Search binding should be remote or not in local development */
913
+ remote?: boolean;
914
+ } | undefined;
915
+ /**
916
+ * Specifies Hyperdrive configs that are bound to this Worker environment.
917
+ *
918
+ * NOTE: This field is not automatically inherited from the top level environment,
919
+ * and so must be specified in every named environment.
920
+ *
921
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
922
+ *
923
+ * @default []
924
+ * @nonInheritable
925
+ */
926
+ hyperdrive: {
927
+ /** The binding name used to refer to the project in the Worker. */binding: string; /** The id of the database. */
928
+ id: string; /** The local database connection string for `wrangler dev` */
929
+ localConnectionString?: string;
930
+ }[];
931
+ /**
932
+ * Specifies service bindings (Worker-to-Worker) that are bound to this Worker environment.
933
+ *
934
+ * NOTE: This field is not automatically inherited from the top level environment,
935
+ * and so must be specified in every named environment.
936
+ *
937
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
938
+ *
939
+ * @default []
940
+ * @nonInheritable
941
+ */
942
+ services: {
943
+ /** The binding name used to refer to the bound service. */binding: string;
944
+ /**
945
+ * The name of the service.
946
+ * To bind to a worker in a specific environment,
947
+ * you should use the format `<worker_name>-<environment_name>`.
948
+ */
949
+ service: string;
950
+ /**
951
+ * @hidden
952
+ * @deprecated you should use `service: <worker_name>-<environment_name>` instead.
953
+ * This refers to the deprecated concept of 'service environments'.
954
+ * The environment of the service (e.g. production, staging, etc).
955
+ */
956
+ environment?: string; /** Optionally, the entrypoint (named export) of the service to bind to. */
957
+ entrypoint?: string; /** Optional properties that will be made available to the service via ctx.props. */
958
+ props?: Record<string, unknown>; /** Whether the service binding should be remote or not in local development */
959
+ remote?: boolean;
960
+ }[] | undefined;
961
+ /**
962
+ * Specifies analytics engine datasets that are bound to this Worker environment.
963
+ *
964
+ * NOTE: This field is not automatically inherited from the top level environment,
965
+ * and so must be specified in every named environment.
966
+ *
967
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
968
+ *
969
+ * @default []
970
+ * @nonInheritable
971
+ */
972
+ analytics_engine_datasets: {
973
+ /** The binding name used to refer to the dataset in the Worker. */binding: string; /** The name of this dataset to write to. */
974
+ dataset?: string;
975
+ }[];
976
+ /**
977
+ * A browser that will be usable from the Worker.
978
+ *
979
+ * NOTE: This field is not automatically inherited from the top level environment,
980
+ * and so must be specified in every named environment.
981
+ *
982
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
983
+ *
984
+ * @default {}
985
+ * @nonInheritable
986
+ */
987
+ browser: {
988
+ binding: string; /** Whether the Browser binding should be remote or not in local development */
989
+ remote?: boolean;
990
+ } | undefined;
991
+ /**
992
+ * Binding to the AI project.
993
+ *
994
+ * NOTE: This field is not automatically inherited from the top level environment,
995
+ * and so must be specified in every named environment.
996
+ *
997
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
998
+ *
999
+ * @default {}
1000
+ * @nonInheritable
1001
+ */
1002
+ ai: {
1003
+ binding: string;
1004
+ staging?: boolean; /** Whether the AI binding should be remote or not in local development */
1005
+ remote?: boolean;
1006
+ } | undefined;
1007
+ /**
1008
+ * Binding to Cloudflare Images
1009
+ *
1010
+ * NOTE: This field is not automatically inherited from the top level environment,
1011
+ * and so must be specified in every named environment.
1012
+ *
1013
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
1014
+ *
1015
+ * @default {}
1016
+ * @nonInheritable
1017
+ */
1018
+ images: {
1019
+ binding: string; /** Whether the Images binding should be remote or not in local development */
1020
+ remote?: boolean;
1021
+ } | undefined;
1022
+ /**
1023
+ * Binding to Cloudflare Media Transformations
1024
+ *
1025
+ * NOTE: This field is not automatically inherited from the top level environment,
1026
+ * and so must be specified in every named environment.
1027
+ *
1028
+ * @default {}
1029
+ * @nonInheritable
1030
+ */
1031
+ media: {
1032
+ binding: string; /** Whether the Media binding should be remote or not */
1033
+ remote?: boolean;
1034
+ } | undefined;
1035
+ /**
1036
+ * Binding to Cloudflare Stream
1037
+ *
1038
+ * NOTE: This field is not automatically inherited from the top level environment,
1039
+ * and so must be specified in every named environment.
1040
+ *
1041
+ * @default {}
1042
+ * @nonInheritable
1043
+ */
1044
+ stream: {
1045
+ binding: string; /** Whether the Stream binding should be remote or not in local development */
1046
+ remote?: boolean;
1047
+ } | undefined;
1048
+ /**
1049
+ * Binding to the Worker Version's metadata
1050
+ */
1051
+ version_metadata: {
1052
+ binding: string;
1053
+ } | undefined;
1054
+ /**
1055
+ * "Unsafe" tables for features that aren't directly supported by wrangler.
1056
+ *
1057
+ * NOTE: This field is not automatically inherited from the top level environment,
1058
+ * and so must be specified in every named environment.
1059
+ *
1060
+ * @default {}
1061
+ * @nonInheritable
1062
+ */
1063
+ unsafe: {
1064
+ /**
1065
+ * A set of bindings that should be put into a Worker's upload metadata without changes. These
1066
+ * can be used to implement bindings for features that haven't released and aren't supported
1067
+ * directly by wrangler or miniflare.
1068
+ */
1069
+ bindings?: UnsafeBinding[];
1070
+ /**
1071
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
1072
+ * here will always be applied to metadata last, so can add new or override existing fields.
1073
+ */
1074
+ metadata?: {
1075
+ [key: string]: unknown;
1076
+ };
1077
+ /**
1078
+ * Used for internal capnp uploads for the Workers runtime
1079
+ */
1080
+ capnp?: {
1081
+ base_path: string;
1082
+ source_schemas: string[];
1083
+ compiled_schema?: never;
1084
+ } | {
1085
+ base_path?: never;
1086
+ source_schemas?: never;
1087
+ compiled_schema: string;
1088
+ };
1089
+ };
1090
+ /**
1091
+ * Specifies a list of mTLS certificates that are bound to this Worker environment.
1092
+ *
1093
+ * NOTE: This field is not automatically inherited from the top level environment,
1094
+ * and so must be specified in every named environment.
1095
+ *
1096
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
1097
+ *
1098
+ * @default []
1099
+ * @nonInheritable
1100
+ */
1101
+ mtls_certificates: {
1102
+ /** The binding name used to refer to the certificate in the Worker */binding: string; /** The uuid of the uploaded mTLS certificate */
1103
+ certificate_id: string; /** Whether the mtls fetcher should be remote or not in local development */
1104
+ remote?: boolean;
1105
+ }[];
1106
+ /**
1107
+ * Specifies a list of Tail Workers that are bound to this Worker environment
1108
+ *
1109
+ * NOTE: This field is not automatically inherited from the top level environment,
1110
+ * and so must be specified in every named environment.
1111
+ *
1112
+ * @default []
1113
+ * @nonInheritable
1114
+ */
1115
+ tail_consumers?: TailConsumer[];
1116
+ /**
1117
+ * Specifies a list of Streaming Tail Workers that are bound to this Worker environment
1118
+ *
1119
+ * NOTE: This field is not automatically inherited from the top level environment,
1120
+ * and so must be specified in every named environment.
1121
+ *
1122
+ * @default []
1123
+ * @nonInheritable
1124
+ */
1125
+ streaming_tail_consumers?: StreamingTailConsumer[];
1126
+ /**
1127
+ * Specifies namespace bindings that are bound to this Worker environment.
1128
+ *
1129
+ * NOTE: This field is not automatically inherited from the top level environment,
1130
+ * and so must be specified in every named environment.
1131
+ *
1132
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
1133
+ *
1134
+ * @default []
1135
+ * @nonInheritable
1136
+ */
1137
+ dispatch_namespaces: {
1138
+ /** The binding name used to refer to the bound service. */binding: string; /** The namespace to bind to. */
1139
+ namespace: string; /** Details about the outbound Worker which will handle outbound requests from your namespace */
1140
+ outbound?: DispatchNamespaceOutbound; /** Whether the Dispatch Namespace should be remote or not in local development */
1141
+ remote?: boolean;
1142
+ }[];
1143
+ /**
1144
+ * Specifies list of Pipelines bound to this Worker environment
1145
+ *
1146
+ * NOTE: This field is not automatically inherited from the top level environment,
1147
+ * and so must be specified in every named environment.
1148
+ *
1149
+ * @default []
1150
+ * @nonInheritable
1151
+ */
1152
+ pipelines: {
1153
+ /** The binding name used to refer to the bound service. */binding: string; /** Id of the Stream to bind */
1154
+ stream?: string;
1155
+ /**
1156
+ * Id of the Stream to bind
1157
+ * @deprecated Use `stream` instead.
1158
+ */
1159
+ pipeline?: string; /** Whether the pipeline should be remote or not in local development */
1160
+ remote?: boolean;
1161
+ }[];
1162
+ /**
1163
+ * Specifies Secret Store bindings that are bound to this Worker environment.
1164
+ *
1165
+ * NOTE: This field is not automatically inherited from the top level environment,
1166
+ * and so must be specified in every named environment.
1167
+ *
1168
+ * @default []
1169
+ * @nonInheritable
1170
+ */
1171
+ secrets_store_secrets: {
1172
+ /** The binding name used to refer to the bound service. */binding: string; /** Id of the secret store */
1173
+ store_id: string; /** Name of the secret */
1174
+ secret_name: string;
1175
+ }[];
1176
+ /**
1177
+ * Specifies Artifacts bindings that are bound to this Worker environment.
1178
+ * Artifacts provides git-compatible file storage on Cloudflare Workers.
1179
+ *
1180
+ * NOTE: This field is not automatically inherited from the top level environment,
1181
+ * and so must be specified in every named environment.
1182
+ *
1183
+ * @default []
1184
+ * @nonInheritable
1185
+ */
1186
+ artifacts: {
1187
+ /** The binding name used to refer to the Artifacts instance. */binding: string; /** The namespace to use. */
1188
+ namespace: string; /** Whether to use the remote Artifacts service in local dev. */
1189
+ remote?: boolean;
1190
+ }[];
1191
+ /**
1192
+ * **DO NOT USE**. Hello World Binding Config to serve as an explanatory example.
1193
+ *
1194
+ * NOTE: This field is not automatically inherited from the top level environment,
1195
+ * and so must be specified in every named environment.
1196
+ *
1197
+ * @default []
1198
+ * @nonInheritable
1199
+ */
1200
+ unsafe_hello_world: {
1201
+ /** The binding name used to refer to the bound service. */binding: string; /** Whether the timer is enabled */
1202
+ enable_timer?: boolean;
1203
+ }[];
1204
+ /**
1205
+ * Specifies Flagship feature flag bindings that are bound to this Worker environment.
1206
+ *
1207
+ * NOTE: This field is not automatically inherited from the top level environment,
1208
+ * and so must be specified in every named environment.
1209
+ *
1210
+ * @default []
1211
+ * @nonInheritable
1212
+ */
1213
+ flagship: {
1214
+ /** The binding name used to refer to the bound Flagship service. */binding: string; /** The Flagship app ID to bind to. */
1215
+ app_id: string; /** Set to `true` to suppress the remote binding warning in local dev. Flagship bindings are always remote. */
1216
+ remote?: boolean;
1217
+ }[];
1218
+ /**
1219
+ * Specifies rate limit bindings that are bound to this Worker environment.
1220
+ *
1221
+ * NOTE: This field is not automatically inherited from the top level environment,
1222
+ * and so must be specified in every named environment.
1223
+ *
1224
+ * @default []
1225
+ * @nonInheritable
1226
+ */
1227
+ ratelimits: {
1228
+ /** The binding name used to refer to the rate limiter in the Worker. */name: string; /** The namespace ID for this rate limiter. */
1229
+ namespace_id: string; /** Simple rate limiting configuration. */
1230
+ simple: {
1231
+ /** The maximum number of requests allowed in the time period. */limit: number; /** The time period in seconds (10 for ten seconds, 60 for one minute). */
1232
+ period: 10 | 60;
1233
+ };
1234
+ }[];
1235
+ /**
1236
+ * Specifies Worker Loader bindings that are bound to this Worker environment.
1237
+ *
1238
+ * NOTE: This field is not automatically inherited from the top level environment,
1239
+ * and so must be specified in every named environment.
1240
+ *
1241
+ * @default []
1242
+ * @nonInheritable
1243
+ */
1244
+ worker_loaders: {
1245
+ /** The binding name used to refer to the Worker Loader in the Worker. */binding: string;
1246
+ }[];
1247
+ /**
1248
+ * Specifies VPC services that are bound to this Worker environment.
1249
+ *
1250
+ * NOTE: This field is not automatically inherited from the top level environment,
1251
+ * and so must be specified in every named environment.
1252
+ *
1253
+ * @default []
1254
+ * @nonInheritable
1255
+ */
1256
+ vpc_services: {
1257
+ /** The binding name used to refer to the VPC service in the Worker. */binding: string; /** The service ID of the VPC connectivity service. */
1258
+ service_id: string; /** Whether the VPC service is remote or not */
1259
+ remote?: boolean;
1260
+ }[];
1261
+ /**
1262
+ * Specifies VPC networks that are bound to this Worker environment.
1263
+ *
1264
+ * NOTE: This field is not automatically inherited from the top level environment,
1265
+ * and so must be specified in every named environment.
1266
+ *
1267
+ * @default []
1268
+ * @nonInheritable
1269
+ */
1270
+ vpc_networks: ({
1271
+ /** The binding name used to refer to the VPC network in the Worker. */binding: string; /** The tunnel ID of the Cloudflare Tunnel to route traffic through. Mutually exclusive with network_id. */
1272
+ tunnel_id: string; /** Whether the VPC network is remote or not */
1273
+ remote?: boolean;
1274
+ } | {
1275
+ /** The binding name used to refer to the VPC network in the Worker. */binding: string; /** The network ID to route traffic through. Mutually exclusive with tunnel_id. */
1276
+ network_id: string; /** Whether the VPC network is remote or not */
1277
+ remote?: boolean;
1278
+ })[];
1279
+ }
1280
+ /**
1281
+ * The raw environment configuration that we read from the config file.
1282
+ *
1283
+ * All the properties are optional, and will be replaced with defaults in the configuration that
1284
+ * is used in the rest of the codebase.
1285
+ */
1286
+ type RawEnvironment = Partial<Environment>;
1287
+ /**
1288
+ * A bundling resolver rule, defining the modules type for paths that match the specified globs.
1289
+ */
1290
+ type Rule = {
1291
+ type: ConfigModuleRuleType;
1292
+ globs: string[];
1293
+ fallthrough?: boolean;
1294
+ };
1295
+ /**
1296
+ * The possible types for a `Rule`.
1297
+ */
1298
+ type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data" | "PythonModule" | "PythonRequirement";
1299
+ type TailConsumer = {
1300
+ /** The name of the service tail events will be forwarded to. */service: string; /** (Optional) The environment of the service. */
1301
+ environment?: string;
1302
+ };
1303
+ type StreamingTailConsumer = {
1304
+ /** The name of the service streaming tail events will be forwarded to. */service: string;
1305
+ };
1306
+ interface DispatchNamespaceOutbound {
1307
+ /** Name of the service handling the outbound requests */
1308
+ service: string;
1309
+ /** (Optional) Name of the environment handling the outbound requests. */
1310
+ environment?: string;
1311
+ /** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler */
1312
+ parameters?: string[];
1313
+ }
1314
+ interface UserLimits {
1315
+ /** Maximum allowed CPU time for a Worker's invocation in milliseconds */
1316
+ cpu_ms?: number;
1317
+ /** Maximum allowed number of fetch requests that a Worker's invocation can execute */
1318
+ subrequests?: number;
1319
+ }
1320
+ type Assets = {
1321
+ /** Absolute path to assets directory */directory?: string; /** Name of `env` binding property in the User Worker. */
1322
+ binding?: string; /** How to handle HTML requests. */
1323
+ html_handling?: "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash" | "none"; /** How to handle requests that do not match an asset. */
1324
+ not_found_handling?: "single-page-application" | "404-page" | "none";
1325
+ /**
1326
+ * Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
1327
+ *
1328
+ * Can also be `true`, indicating that every request should be routed to the User Worker.
1329
+ */
1330
+ run_worker_first?: string[] | boolean;
1331
+ };
1332
+ interface Observability {
1333
+ /** If observability is enabled for this Worker */
1334
+ enabled?: boolean;
1335
+ /** The sampling rate */
1336
+ head_sampling_rate?: number;
1337
+ logs?: {
1338
+ enabled?: boolean; /** The sampling rate */
1339
+ head_sampling_rate?: number; /** Set to false to disable invocation logs */
1340
+ invocation_logs?: boolean;
1341
+ /**
1342
+ * If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
1343
+ *
1344
+ * @default true
1345
+ */
1346
+ persist?: boolean;
1347
+ /**
1348
+ * What destinations logs emitted from the Worker should be sent to.
1349
+ *
1350
+ * @default []
1351
+ */
1352
+ destinations?: string[];
1353
+ };
1354
+ traces?: {
1355
+ enabled?: boolean; /** The sampling rate */
1356
+ head_sampling_rate?: number;
1357
+ /**
1358
+ * If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
1359
+ *
1360
+ * @default true
1361
+ */
1362
+ persist?: boolean;
1363
+ /**
1364
+ * What destinations traces emitted from the Worker should be sent to.
1365
+ *
1366
+ * @default []
1367
+ */
1368
+ destinations?: string[];
1369
+ };
1370
+ }
1371
+ interface CacheOptions$1 {
1372
+ /** If cache is enabled for this Worker */
1373
+ enabled: boolean;
1374
+ }
1375
+ type DockerConfiguration = {
1376
+ /** Socket used by miniflare to communicate with Docker */socketPath: string; /** Docker image name for the container egress interceptor sidecar */
1377
+ containerEgressInterceptorImage?: string;
1378
+ };
1379
+ type ContainerEngine = {
1380
+ localDocker: DockerConfiguration;
1381
+ } | string;
1382
+ /**
1383
+ * Configuration for Worker Previews.
1384
+ *
1385
+ * This defines the settings used when creating Preview deployments.
1386
+ * Previews are branches of your Worker's main instance used to test features
1387
+ * during feature development outside of production.
1388
+ *
1389
+ * The `previews` block contains any intentionally divergent configuration intended solely for Previews, including:
1390
+ * - All non-inheritable properties (environment variables and bindings like KV, D1, R2, etc.)
1391
+ * - Select inheritable properties: `logpush`, `observability`, `limits`, `cache`
1392
+ *
1393
+ * @inheritable
1394
+ */
1395
+ interface PreviewsConfig extends Partial<EnvironmentNonInheritable>, Partial<Pick<EnvironmentInheritable, "logpush" | "observability" | "limits" | "cache">> {}
1396
+ /**
1397
+ * This is the static type definition for the configuration object.
1398
+ *
1399
+ * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,
1400
+ * and optionally augment with arguments passed directly to wrangler.
1401
+ *
1402
+ * For more information about the configuration object, see the
1403
+ * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
1404
+ *
1405
+ * Notes:
1406
+ *
1407
+ * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
1408
+ * in the top level config and should not appear in any environments.
1409
+ * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects
1410
+ * - All top level fields in config and environments are optional in the Wrangler configuration file.
1411
+ *
1412
+ * Legend for the annotations:
1413
+ *
1414
+ * - `@breaking`: the deprecation/optionality is a breaking change from Wrangler v1.
1415
+ * - `@todo`: there's more work to be done (with details attached).
1416
+ */
1417
+ type RawConfig = Partial<ConfigFields<RawDevConfig>> & PagesConfigFields & RawEnvironment & EnvironmentMap & {
1418
+ $schema?: string;
1419
+ };
1420
+ interface ConfigFields<Dev extends RawDevConfig> {
1421
+ /**
1422
+ * A boolean to enable "legacy" style wrangler environments (from Wrangler v1).
1423
+ * These have been superseded by Services, but there may be projects that won't
1424
+ * (or can't) use them. If you're using a legacy environment, you can set this
1425
+ * to `true` to enable it.
1426
+ */
1427
+ legacy_env: boolean;
1428
+ /**
1429
+ * Whether Wrangler should send usage metrics to Cloudflare for this project.
1430
+ *
1431
+ * When defined this will override any user settings.
1432
+ * Otherwise, Wrangler will use the user's preference.
1433
+ */
1434
+ send_metrics: boolean | undefined;
1435
+ /**
1436
+ * Options to configure the development server that your worker will use.
1437
+ *
1438
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#local-development-settings
1439
+ */
1440
+ dev: Dev;
1441
+ /**
1442
+ * The definition of a Worker Site, a feature that lets you upload
1443
+ * static assets with your Worker.
1444
+ *
1445
+ * More details at https://developers.cloudflare.com/workers/platform/sites
1446
+ *
1447
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-sites
1448
+ */
1449
+ site: {
1450
+ /**
1451
+ * The directory containing your static assets.
1452
+ *
1453
+ * It must be a path relative to your Wrangler configuration file.
1454
+ * Example: bucket = "./public"
1455
+ *
1456
+ * If there is a `site` field then it must contain this `bucket` field.
1457
+ */
1458
+ bucket: string;
1459
+ /**
1460
+ * The location of your Worker script.
1461
+ *
1462
+ * @deprecated DO NOT use this (it's a holdover from Wrangler v1.x). Either use the top level `main` field, or pass the path to your entry file as a command line argument.
1463
+ * @breaking
1464
+ */
1465
+ "entry-point"?: string;
1466
+ /**
1467
+ * An exclusive list of .gitignore-style patterns that match file
1468
+ * or directory names from your bucket location. Only matched
1469
+ * items will be uploaded. Example: include = ["upload_dir"]
1470
+ *
1471
+ * @optional
1472
+ * @default []
1473
+ */
1474
+ include?: string[];
1475
+ /**
1476
+ * A list of .gitignore-style patterns that match files or
1477
+ * directories in your bucket that should be excluded from
1478
+ * uploads. Example: exclude = ["ignore_dir"]
1479
+ *
1480
+ * @optional
1481
+ * @default []
1482
+ */
1483
+ exclude?: string[];
1484
+ } | undefined;
1485
+ /**
1486
+ * A list of wasm modules that your worker should be bound to. This is
1487
+ * the "legacy" way of binding to a wasm module. ES module workers should
1488
+ * do proper module imports.
1489
+ */
1490
+ wasm_modules: {
1491
+ [key: string]: string;
1492
+ } | undefined;
1493
+ /**
1494
+ * A list of text files that your worker should be bound to. This is
1495
+ * the "legacy" way of binding to a text file. ES module workers should
1496
+ * do proper module imports.
1497
+ */
1498
+ text_blobs: {
1499
+ [key: string]: string;
1500
+ } | undefined;
1501
+ /**
1502
+ * A list of data files that your worker should be bound to. This is
1503
+ * the "legacy" way of binding to a data file. ES module workers should
1504
+ * do proper module imports.
1505
+ */
1506
+ data_blobs: {
1507
+ [key: string]: string;
1508
+ } | undefined;
1509
+ /**
1510
+ * A map of module aliases. Lets you swap out a module for any others.
1511
+ * Corresponds with esbuild's `alias` config
1512
+ *
1513
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#module-aliasing
1514
+ */
1515
+ alias: {
1516
+ [key: string]: string;
1517
+ } | undefined;
1518
+ /**
1519
+ * By default, the Wrangler configuration file is the source of truth for your environment configuration, like a terraform file.
1520
+ *
1521
+ * If you change your vars in the dashboard, wrangler *will* override/delete them on its next deploy.
1522
+ *
1523
+ * If you want to keep your dashboard vars when wrangler deploys, set this field to true.
1524
+ *
1525
+ * @default false
1526
+ * @nonInheritable
1527
+ */
1528
+ keep_vars?: boolean;
1529
+ }
1530
+ interface PagesConfigFields {
1531
+ /**
1532
+ * The directory of static assets to serve.
1533
+ *
1534
+ * The presence of this field in a Wrangler configuration file indicates a Pages project,
1535
+ * and will prompt the handling of the configuration file according to the
1536
+ * Pages-specific validation rules.
1537
+ */
1538
+ pages_build_output_dir?: string;
1539
+ }
1540
+ interface DevConfig {
1541
+ /**
1542
+ * IP address for the local dev server to listen on,
1543
+ *
1544
+ * @default localhost
1545
+ */
1546
+ ip: string;
1547
+ /**
1548
+ * Port for the local dev server to listen on
1549
+ *
1550
+ * @default 8787
1551
+ */
1552
+ port: number | undefined;
1553
+ /**
1554
+ * Port for the local dev server's inspector to listen on
1555
+ *
1556
+ * @default 9229
1557
+ */
1558
+ inspector_port: number | undefined;
1559
+ /**
1560
+ * IP address for the local dev server's inspector to listen on
1561
+ *
1562
+ * @default 127.0.0.1
1563
+ */
1564
+ inspector_ip: string | undefined;
1565
+ /**
1566
+ * Protocol that local wrangler dev server listens to requests on.
1567
+ *
1568
+ * @default http
1569
+ */
1570
+ local_protocol: "http" | "https";
1571
+ /**
1572
+ * Protocol that wrangler dev forwards requests on
1573
+ *
1574
+ * Setting this to `http` is not currently implemented for remote mode.
1575
+ * See https://github.com/cloudflare/workers-sdk/issues/583
1576
+ *
1577
+ * @default https
1578
+ */
1579
+ upstream_protocol: "https" | "http";
1580
+ /**
1581
+ * Host to forward requests to, defaults to the host of the first route of project
1582
+ */
1583
+ host: string | undefined;
1584
+ /**
1585
+ * When developing, whether to build and connect to containers. This requires a Docker daemon to be running.
1586
+ * Defaults to `true`.
1587
+ *
1588
+ * @default true
1589
+ */
1590
+ enable_containers: boolean;
1591
+ /**
1592
+ * Either the Docker unix socket i.e. `unix:///var/run/docker.sock` or a full configuration.
1593
+ * Note that windows is only supported via WSL at the moment
1594
+ */
1595
+ container_engine: ContainerEngine | undefined;
1596
+ /**
1597
+ * Re-generate your worker types when your Wrangler configuration file changes.
1598
+ *
1599
+ * @default false
1600
+ */
1601
+ generate_types: boolean;
1602
+ }
1603
+ type RawDevConfig = Partial<DevConfig>;
1604
+ interface EnvironmentMap {
1605
+ /**
1606
+ * The `env` section defines overrides for the configuration for different environments.
1607
+ *
1608
+ * All environment fields can be specified at the top level of the config indicating the default environment settings.
1609
+ *
1610
+ * - Some fields are inherited and overridable in each environment.
1611
+ * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
1612
+ *
1613
+ * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
1614
+ *
1615
+ * @default {}
1616
+ */
1617
+ env?: {
1618
+ [envName: string]: RawEnvironment;
1619
+ };
1620
+ }
1621
+ type AutocompletePrimitiveBaseType<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : never;
1622
+ type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>);
1623
+ /**
1624
+ * The header type declaration of `undici`.
1625
+ */
1626
+ type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
1627
+ type HeaderNames = Autocomplete<'Accept' | 'Accept-CH' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges' | 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Age' | 'Allow' | 'Alt-Svc' | 'Alt-Used' | 'Authorization' | 'Cache-Control' | 'Clear-Site-Data' | 'Connection' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'Device-Memory' | 'ETag' | 'Expect' | 'Expect-CT' | 'Expires' | 'Forwarded' | 'From' | 'Host' | 'If-Match' | 'If-Modified-Since' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Keep-Alive' | 'Last-Modified' | 'Link' | 'Location' | 'Max-Forwards' | 'Origin' | 'Permissions-Policy' | 'Priority' | 'Proxy-Authenticate' | 'Proxy-Authorization' | 'Range' | 'Referer' | 'Referrer-Policy' | 'Retry-After' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-Purpose' | 'Sec-WebSocket-Accept' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'SourceMap' | 'Strict-Transport-Security' | 'TE' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Upgrade-Insecure-Requests' | 'User-Agent' | 'Vary' | 'Via' | 'WWW-Authenticate' | 'X-Content-Type-Options' | 'X-Frame-Options'>;
1628
+ type IANARegisteredMimeType = Autocomplete<'audio/aac' | 'video/x-msvideo' | 'image/avif' | 'video/av1' | 'application/octet-stream' | 'image/bmp' | 'text/css' | 'text/csv' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'application/gzip' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'image/jpeg' | 'text/javascript' | 'application/json' | 'application/ld+json' | 'audio/x-midi' | 'audio/mpeg' | 'video/mp4' | 'video/mpeg' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'audio/opus' | 'font/otf' | 'application/pdf' | 'image/png' | 'application/rtf' | 'image/svg+xml' | 'image/tiff' | 'video/mp2t' | 'font/ttf' | 'text/plain' | 'application/wasm' | 'video/webm' | 'audio/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'video/3gpp' | 'video/3gpp2' | 'model/gltf+json' | 'model/gltf-binary'>;
1629
+ type KnownHeaderValues = {
1630
+ 'content-type': IANARegisteredMimeType;
1631
+ };
1632
+ type HeaderRecord = { [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues ? KnownHeaderValues[Lowercase<K>] : string };
1633
+ declare class BodyReadable extends Readable {
1634
+ constructor(opts: {
1635
+ resume: (this: Readable, size: number) => void | null;
1636
+ abort: () => void | null;
1637
+ contentType?: string;
1638
+ contentLength?: number;
1639
+ highWaterMark?: number;
1640
+ });
1641
+ /** Consumes and returns the body as a string
1642
+ * https://fetch.spec.whatwg.org/#dom-body-text
1643
+ */
1644
+ text(): Promise<string>;
1645
+ /** Consumes and returns the body as a JavaScript Object
1646
+ * https://fetch.spec.whatwg.org/#dom-body-json
1647
+ */
1648
+ json(): Promise<unknown>;
1649
+ /** Consumes and returns the body as a Blob
1650
+ * https://fetch.spec.whatwg.org/#dom-body-blob
1651
+ */
1652
+ blob(): Promise<Blob>;
1653
+ /** Consumes and returns the body as an Uint8Array
1654
+ * https://fetch.spec.whatwg.org/#dom-body-bytes
1655
+ */
1656
+ bytes(): Promise<Uint8Array>;
1657
+ /** Consumes and returns the body as an ArrayBuffer
1658
+ * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
1659
+ */
1660
+ arrayBuffer(): Promise<ArrayBuffer>;
1661
+ /** Not implemented
1662
+ *
1663
+ * https://fetch.spec.whatwg.org/#dom-body-formdata
1664
+ */
1665
+ formData(): Promise<never>;
1666
+ /** Returns true if the body is not null and the body has been consumed
1667
+ *
1668
+ * Otherwise, returns false
1669
+ *
1670
+ * https://fetch.spec.whatwg.org/#dom-body-bodyused
1671
+ */
1672
+ readonly bodyUsed: boolean;
1673
+ /**
1674
+ * If body is null, it should return null as the body
1675
+ *
1676
+ * If body is not null, should return the body as a ReadableStream
1677
+ *
1678
+ * https://fetch.spec.whatwg.org/#dom-body-body
1679
+ */
1680
+ readonly body: never | undefined;
1681
+ /** Dumps the response body by reading `limit` number of bytes.
1682
+ * @param opts.limit Number of bytes to read (optional) - Default: 131072
1683
+ * @param opts.signal AbortSignal to cancel the operation (optional)
1684
+ */
1685
+ dump(opts?: {
1686
+ limit: number;
1687
+ signal?: AbortSignal;
1688
+ }): Promise<void>;
1689
+ }
1690
+ type BodyInit = ArrayBuffer | AsyncIterable<Uint8Array> | Blob | FormData | Iterable<Uint8Array> | NodeJS.ArrayBufferView | URLSearchParams | null | string;
1691
+ interface SpecIterator<T, TReturn = any, TNext = undefined> {
1692
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
1693
+ }
1694
+ interface SpecIteratorObject<T, TReturn = undefined, TNext = unknown> extends SpecIterator<T, TReturn, TNext> {
1695
+ [Symbol.iterator](): SpecIteratorObject<T, TReturn, TNext>;
1696
+ map<U>(callbackfn: (value: T, index: number) => U): SpecIteratorObject<U>;
1697
+ filter<S extends T>(predicate: (value: T, index: number) => value is S): SpecIteratorObject<S>;
1698
+ filter(predicate: (value: T, index: number) => unknown): SpecIteratorObject<T>;
1699
+ take(limit: number): SpecIteratorObject<T>;
1700
+ drop(count: number): SpecIteratorObject<T>;
1701
+ flatMap<U>(callbackfn: (value: T, index: number) => Iterator<U> | Iterable<U>): SpecIteratorObject<U>;
1702
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T;
1703
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T;
1704
+ reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
1705
+ toArray(): T[];
1706
+ forEach(callbackfn: (value: T, index: number) => void): void;
1707
+ some(predicate: (value: T, index: number) => unknown): boolean;
1708
+ every(predicate: (value: T, index: number) => unknown): boolean;
1709
+ find<S extends T>(predicate: (value: T, index: number) => value is S): S | undefined;
1710
+ find(predicate: (value: T, index: number) => unknown): T | undefined;
1711
+ readonly [Symbol.toStringTag]: string;
1712
+ }
1713
+ interface SpecIterableIterator<T> extends SpecIteratorObject<T> {
1714
+ [Symbol.iterator](): SpecIterableIterator<T>;
1715
+ }
1716
+ interface SpecIterable<T> {
1717
+ [Symbol.iterator](): SpecIterableIterator<T>;
1718
+ }
1719
+ type HeadersInit = [string, string][] | HeaderRecord | Headers;
1720
+ declare class Headers implements SpecIterable<[string, string]> {
1721
+ constructor(init?: HeadersInit);
1722
+ readonly append: (name: string, value: string) => void;
1723
+ readonly delete: (name: string) => void;
1724
+ readonly get: (name: string) => string | null;
1725
+ readonly has: (name: string) => boolean;
1726
+ readonly set: (name: string, value: string) => void;
1727
+ readonly getSetCookie: () => string[];
1728
+ readonly forEach: (callbackfn: (value: string, key: string, iterable: Headers) => void, thisArg?: unknown) => void;
1729
+ readonly keys: () => SpecIterableIterator<string>;
1730
+ readonly values: () => SpecIterableIterator<string>;
1731
+ readonly entries: () => SpecIterableIterator<[string, string]>;
1732
+ readonly [Symbol.iterator]: () => SpecIterableIterator<[string, string]>;
1733
+ }
1734
+ declare module 'node:buffer' {
1735
+ interface File {
1736
+ readonly [Symbol.toStringTag]: string;
1737
+ }
1738
+ }
1739
+ /**
1740
+ * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
1741
+ */
1742
+ declare type FormDataEntryValue = string | File;
1743
+ /**
1744
+ * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().
1745
+ */
1746
+ declare class FormData {
1747
+ /**
1748
+ * Appends a new value onto an existing key inside a FormData object,
1749
+ * or adds the key if it does not already exist.
1750
+ *
1751
+ * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
1752
+ *
1753
+ * @param name The name of the field whose data is contained in `value`.
1754
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
1755
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
1756
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
1757
+ */
1758
+ append(name: string, value: unknown, fileName?: string): void;
1759
+ /**
1760
+ * Set a new value for an existing key inside FormData,
1761
+ * or add the new field if it does not already exist.
1762
+ *
1763
+ * @param name The name of the field whose data is contained in `value`.
1764
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
1765
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
1766
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
1767
+ *
1768
+ */
1769
+ set(name: string, value: unknown, fileName?: string): void;
1770
+ /**
1771
+ * Returns the first value associated with a given key from within a `FormData` object.
1772
+ * If you expect multiple values and want all of them, use the `getAll()` method instead.
1773
+ *
1774
+ * @param {string} name A name of the value you want to retrieve.
1775
+ *
1776
+ * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
1777
+ */
1778
+ get(name: string): FormDataEntryValue | null;
1779
+ /**
1780
+ * Returns all the values associated with a given key from within a `FormData` object.
1781
+ *
1782
+ * @param {string} name A name of the value you want to retrieve.
1783
+ *
1784
+ * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
1785
+ */
1786
+ getAll(name: string): FormDataEntryValue[];
1787
+ /**
1788
+ * Returns a boolean stating whether a `FormData` object contains a certain key.
1789
+ *
1790
+ * @param name A string representing the name of the key you want to test for.
1791
+ *
1792
+ * @return A boolean value.
1793
+ */
1794
+ has(name: string): boolean;
1795
+ /**
1796
+ * Deletes a key and its value(s) from a `FormData` object.
1797
+ *
1798
+ * @param name The name of the key you want to delete.
1799
+ */
1800
+ delete(name: string): void;
1801
+ /**
1802
+ * Executes given callback function for each field of the FormData instance
1803
+ */
1804
+ forEach: (callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void, thisArg?: unknown) => void;
1805
+ /**
1806
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
1807
+ * Each key is a `string`.
1808
+ */
1809
+ keys: () => SpecIterableIterator<string>;
1810
+ /**
1811
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
1812
+ * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
1813
+ */
1814
+ values: () => SpecIterableIterator<FormDataEntryValue>;
1815
+ /**
1816
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
1817
+ * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
1818
+ */
1819
+ entries: () => SpecIterableIterator<[string, FormDataEntryValue]>;
1820
+ /**
1821
+ * An alias for FormData#entries()
1822
+ */
1823
+ [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>;
1824
+ readonly [Symbol.toStringTag]: string;
1825
+ }
1826
+ declare function buildConnector(options?: buildConnector.BuildOptions): buildConnector.connector;
1827
+ declare namespace buildConnector {
1828
+ export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
1829
+ allowH2?: boolean;
1830
+ maxCachedSessions?: number | null;
1831
+ socketPath?: string | null;
1832
+ timeout?: number | null;
1833
+ port?: number;
1834
+ keepAlive?: boolean | null;
1835
+ keepAliveInitialDelay?: number | null;
1836
+ typeOfService?: number | null;
1837
+ };
1838
+ export interface Options {
1839
+ hostname: string;
1840
+ host?: string;
1841
+ protocol: string;
1842
+ port: string;
1843
+ servername?: string;
1844
+ localAddress?: string | null;
1845
+ socketPath?: string | null;
1846
+ httpSocket?: Socket;
1847
+ }
1848
+ export type Callback = (...args: CallbackArgs) => void;
1849
+ type CallbackArgs = [null, Socket | TLSSocket] | [Error, null];
1850
+ export interface connector {
1851
+ (options: buildConnector.Options, callback: buildConnector.Callback): void;
1852
+ }
1853
+ }
1854
+ declare class ClientStats {
1855
+ constructor(pool: Client);
1856
+ /** If socket has open connection. */
1857
+ connected: boolean;
1858
+ /** Number of open socket connections in this client that do not have an active request. */
1859
+ pending: number;
1860
+ /** Number of currently active requests of this client. */
1861
+ running: number;
1862
+ /** Number of active, pending, or queued requests of this client. */
1863
+ size: number;
1864
+ }
1865
+ type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>;
1866
+ /**
1867
+ * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
1868
+ */
1869
+ declare class Client extends Dispatcher {
1870
+ constructor(url: string | URL$1, options?: Client.Options);
1871
+ /** Property to get and set the pipelining factor. */
1872
+ pipelining: number;
1873
+ /** `true` after `client.close()` has been called. */
1874
+ closed: boolean;
1875
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
1876
+ destroyed: boolean;
1877
+ /** Aggregate stats for a Client. */
1878
+ readonly stats: ClientStats; // Override dispatcher APIs.
1879
+ override connect(options: ClientConnectOptions): Promise<Dispatcher.ConnectData>;
1880
+ override connect(options: ClientConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
1881
+ }
1882
+ declare namespace Client {
1883
+ export interface OptionsInterceptors {
1884
+ Client: readonly Dispatcher.DispatchInterceptor[];
1885
+ }
1886
+ export interface Options {
1887
+ /** TODO */
1888
+ interceptors?: OptionsInterceptors;
1889
+ /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
1890
+ maxHeaderSize?: number;
1891
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
1892
+ headersTimeout?: number;
1893
+ /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
1894
+ socketTimeout?: never;
1895
+ /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
1896
+ requestTimeout?: never;
1897
+ /** TODO */
1898
+ connectTimeout?: number;
1899
+ /** 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). */
1900
+ bodyTimeout?: number;
1901
+ /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
1902
+ idleTimeout?: never;
1903
+ /** @deprecated unsupported keepAlive, use pipelining=0 instead */
1904
+ keepAlive?: never;
1905
+ /** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
1906
+ keepAliveTimeout?: number;
1907
+ /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
1908
+ maxKeepAliveTimeout?: never;
1909
+ /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
1910
+ keepAliveMaxTimeout?: number;
1911
+ /** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
1912
+ keepAliveTimeoutThreshold?: number;
1913
+ /** TODO */
1914
+ socketPath?: string;
1915
+ /** 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`. */
1916
+ pipelining?: number;
1917
+ /** @deprecated use the connect option instead */
1918
+ tls?: never;
1919
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
1920
+ strictContentLength?: boolean;
1921
+ /** TODO */
1922
+ maxCachedSessions?: number;
1923
+ /** TODO */
1924
+ connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
1925
+ /** TODO */
1926
+ maxRequestsPerClient?: number;
1927
+ /** TODO */
1928
+ localAddress?: string;
1929
+ /** Max response body size in bytes, -1 is disabled */
1930
+ maxResponseSize?: number;
1931
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
1932
+ autoSelectFamily?: boolean;
1933
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
1934
+ autoSelectFamilyAttemptTimeout?: number;
1935
+ /**
1936
+ * @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
1937
+ * @default false
1938
+ */
1939
+ allowH2?: boolean;
1940
+ /**
1941
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
1942
+ * @default 100
1943
+ */
1944
+ maxConcurrentStreams?: number;
1945
+ /**
1946
+ * @description Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE).
1947
+ * @default 262144
1948
+ */
1949
+ initialWindowSize?: number;
1950
+ /**
1951
+ * @description Sets the HTTP/2 connection-level flow-control window size (ClientHttp2Session.setLocalWindowSize).
1952
+ * @default 524288
1953
+ */
1954
+ connectionWindowSize?: number;
1955
+ /**
1956
+ * @description Time interval between PING frames dispatch
1957
+ * @default 60000
1958
+ */
1959
+ pingInterval?: number;
1960
+ }
1961
+ export interface SocketInfo {
1962
+ localAddress?: string;
1963
+ localPort?: number;
1964
+ remoteAddress?: string;
1965
+ remotePort?: number;
1966
+ remoteFamily?: string;
1967
+ timeout?: number;
1968
+ bytesWritten?: number;
1969
+ bytesRead?: number;
1970
+ }
1971
+ }
1972
+ declare namespace Errors {
1973
+ export class UndiciError extends Error {
1974
+ name: string;
1975
+ code: string;
1976
+ }
1977
+ /** Connect timeout error. */
1978
+ export class ConnectTimeoutError extends UndiciError {
1979
+ name: 'ConnectTimeoutError';
1980
+ code: 'UND_ERR_CONNECT_TIMEOUT';
1981
+ }
1982
+ /** A header exceeds the `headersTimeout` option. */
1983
+ export class HeadersTimeoutError extends UndiciError {
1984
+ name: 'HeadersTimeoutError';
1985
+ code: 'UND_ERR_HEADERS_TIMEOUT';
1986
+ }
1987
+ /** Headers overflow error. */
1988
+ export class HeadersOverflowError extends UndiciError {
1989
+ name: 'HeadersOverflowError';
1990
+ code: 'UND_ERR_HEADERS_OVERFLOW';
1991
+ }
1992
+ /** A body exceeds the `bodyTimeout` option. */
1993
+ export class BodyTimeoutError extends UndiciError {
1994
+ name: 'BodyTimeoutError';
1995
+ code: 'UND_ERR_BODY_TIMEOUT';
1996
+ }
1997
+ export class ResponseError extends UndiciError {
1998
+ constructor(message: string, code: number, options: {
1999
+ headers?: IncomingHttpHeaders | string[] | null;
2000
+ body?: null | Record<string, any> | string;
2001
+ });
2002
+ name: 'ResponseError';
2003
+ code: 'UND_ERR_RESPONSE';
2004
+ statusCode: number;
2005
+ body: null | Record<string, any> | string;
2006
+ headers: IncomingHttpHeaders | string[] | null;
2007
+ }
2008
+ /** Passed an invalid argument. */
2009
+ export class InvalidArgumentError extends UndiciError {
2010
+ name: 'InvalidArgumentError';
2011
+ code: 'UND_ERR_INVALID_ARG';
2012
+ }
2013
+ /** Returned an invalid value. */
2014
+ export class InvalidReturnValueError extends UndiciError {
2015
+ name: 'InvalidReturnValueError';
2016
+ code: 'UND_ERR_INVALID_RETURN_VALUE';
2017
+ }
2018
+ /** The request has been aborted by the user. */
2019
+ export class RequestAbortedError extends UndiciError {
2020
+ name: 'AbortError';
2021
+ code: 'UND_ERR_ABORTED';
2022
+ }
2023
+ /** Expected error with reason. */
2024
+ export class InformationalError extends UndiciError {
2025
+ name: 'InformationalError';
2026
+ code: 'UND_ERR_INFO';
2027
+ }
2028
+ /** Request body length does not match content-length header. */
2029
+ export class RequestContentLengthMismatchError extends UndiciError {
2030
+ name: 'RequestContentLengthMismatchError';
2031
+ code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
2032
+ }
2033
+ /** Response body length does not match content-length header. */
2034
+ export class ResponseContentLengthMismatchError extends UndiciError {
2035
+ name: 'ResponseContentLengthMismatchError';
2036
+ code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
2037
+ }
2038
+ /** Trying to use a destroyed client. */
2039
+ export class ClientDestroyedError extends UndiciError {
2040
+ name: 'ClientDestroyedError';
2041
+ code: 'UND_ERR_DESTROYED';
2042
+ }
2043
+ /** Trying to use a closed client. */
2044
+ export class ClientClosedError extends UndiciError {
2045
+ name: 'ClientClosedError';
2046
+ code: 'UND_ERR_CLOSED';
2047
+ }
2048
+ /** There is an error with the socket. */
2049
+ export class SocketError extends UndiciError {
2050
+ name: 'SocketError';
2051
+ code: 'UND_ERR_SOCKET';
2052
+ socket: Client.SocketInfo | null;
2053
+ }
2054
+ /** Encountered unsupported functionality. */
2055
+ export class NotSupportedError extends UndiciError {
2056
+ name: 'NotSupportedError';
2057
+ code: 'UND_ERR_NOT_SUPPORTED';
2058
+ }
2059
+ /** No upstream has been added to the BalancedPool. */
2060
+ export class BalancedPoolMissingUpstreamError extends UndiciError {
2061
+ name: 'MissingUpstreamError';
2062
+ code: 'UND_ERR_BPL_MISSING_UPSTREAM';
2063
+ }
2064
+ export class HTTPParserError extends UndiciError {
2065
+ name: 'HTTPParserError';
2066
+ code: string;
2067
+ }
2068
+ /** The response exceed the length allowed. */
2069
+ export class ResponseExceededMaxSizeError extends UndiciError {
2070
+ name: 'ResponseExceededMaxSizeError';
2071
+ code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
2072
+ }
2073
+ export class RequestRetryError extends UndiciError {
2074
+ constructor(message: string, statusCode: number, headers?: IncomingHttpHeaders | string[] | null, body?: null | Record<string, any> | string);
2075
+ name: 'RequestRetryError';
2076
+ code: 'UND_ERR_REQ_RETRY';
2077
+ statusCode: number;
2078
+ data: {
2079
+ count: number;
2080
+ };
2081
+ headers: Record<string, string | string[]>;
2082
+ }
2083
+ export class SecureProxyConnectionError extends UndiciError {
2084
+ constructor(cause?: Error, message?: string, options?: Record<any, any>);
2085
+ name: 'SecureProxyConnectionError';
2086
+ code: 'UND_ERR_PRX_TLS';
2087
+ }
2088
+ export class MaxOriginsReachedError extends UndiciError {
2089
+ name: 'MaxOriginsReachedError';
2090
+ code: 'UND_ERR_MAX_ORIGINS_REACHED';
2091
+ }
2092
+ /** SOCKS5 proxy related error. */
2093
+ export class Socks5ProxyError extends UndiciError {
2094
+ constructor(message?: string, code?: string);
2095
+ name: 'Socks5ProxyError';
2096
+ code: string;
2097
+ }
2098
+ /** WebSocket decompressed message exceeded maximum size. */
2099
+ export class MessageSizeExceededError extends UndiciError {
2100
+ name: 'MessageSizeExceededError';
2101
+ code: 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED';
2102
+ }
2103
+ }
2104
+ type AbortSignal$1 = unknown;
2105
+ type UndiciHeaders = Record<string, string | string[]> | IncomingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
2106
+ /** Dispatcher is the core API used to dispatch requests. */
2107
+ declare class Dispatcher extends EventEmitter {
2108
+ /** 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. */
2109
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean;
2110
+ /** Starts two-way communications with the requested resource. */
2111
+ connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void;
2112
+ connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>;
2113
+ /** Compose a chain of dispatchers */
2114
+ compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
2115
+ compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
2116
+ /** Performs an HTTP request. */
2117
+ request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void;
2118
+ request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>;
2119
+ /** For easy use with `stream.pipeline`. */
2120
+ pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex;
2121
+ /** A faster version of `Dispatcher.request`. */
2122
+ stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void;
2123
+ stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>;
2124
+ /** Upgrade to a different protocol. */
2125
+ upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
2126
+ upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
2127
+ /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
2128
+ close(callback: () => void): void;
2129
+ close(): Promise<void>;
2130
+ /** 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. */
2131
+ destroy(err: Error | null, callback: () => void): void;
2132
+ destroy(callback: () => void): void;
2133
+ destroy(err: Error | null): Promise<void>;
2134
+ destroy(): Promise<void>;
2135
+ on(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2136
+ on(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2137
+ on(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2138
+ on(eventName: 'drain', callback: (origin: URL$1) => void): this;
2139
+ once(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2140
+ once(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2141
+ once(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2142
+ once(eventName: 'drain', callback: (origin: URL$1) => void): this;
2143
+ off(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2144
+ off(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2145
+ off(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2146
+ off(eventName: 'drain', callback: (origin: URL$1) => void): this;
2147
+ addListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2148
+ addListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2149
+ addListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2150
+ addListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
2151
+ removeListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2152
+ removeListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2153
+ removeListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2154
+ removeListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
2155
+ prependListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2156
+ prependListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2157
+ prependListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2158
+ prependListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
2159
+ prependOnceListener(eventName: 'connect', callback: (origin: URL$1, targets: readonly Dispatcher[]) => void): this;
2160
+ prependOnceListener(eventName: 'disconnect', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2161
+ prependOnceListener(eventName: 'connectionError', callback: (origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
2162
+ prependOnceListener(eventName: 'drain', callback: (origin: URL$1) => void): this;
2163
+ listeners(eventName: 'connect'): ((origin: URL$1, targets: readonly Dispatcher[]) => void)[];
2164
+ listeners(eventName: 'disconnect'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
2165
+ listeners(eventName: 'connectionError'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
2166
+ listeners(eventName: 'drain'): ((origin: URL$1) => void)[];
2167
+ rawListeners(eventName: 'connect'): ((origin: URL$1, targets: readonly Dispatcher[]) => void)[];
2168
+ rawListeners(eventName: 'disconnect'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
2169
+ rawListeners(eventName: 'connectionError'): ((origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
2170
+ rawListeners(eventName: 'drain'): ((origin: URL$1) => void)[];
2171
+ emit(eventName: 'connect', origin: URL$1, targets: readonly Dispatcher[]): boolean;
2172
+ emit(eventName: 'disconnect', origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
2173
+ emit(eventName: 'connectionError', origin: URL$1, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
2174
+ emit(eventName: 'drain', origin: URL$1): boolean;
2175
+ }
2176
+ declare namespace Dispatcher {
2177
+ export interface ComposedDispatcher extends Dispatcher {}
2178
+ export type Dispatch = Dispatcher['dispatch'];
2179
+ export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch;
2180
+ export interface DispatchOptions {
2181
+ origin?: string | URL$1;
2182
+ path: string;
2183
+ method: HttpMethod;
2184
+ /** Default: `null` */
2185
+ body?: string | Buffer | Uint8Array | Readable | null | FormData;
2186
+ /** Default: `null` */
2187
+ headers?: UndiciHeaders;
2188
+ /** Query string params to be embedded in the request URL. Default: `null` */
2189
+ query?: Record<string, any>;
2190
+ /** 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`. */
2191
+ idempotent?: boolean;
2192
+ /** 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. Defaults to `method !== 'HEAD'`. */
2193
+ blocking?: boolean;
2194
+ /** The IP Type of Service (ToS) value for the request socket. Must be an integer between 0 and 255. Default: `0` */
2195
+ typeOfService?: number | null;
2196
+ /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
2197
+ upgrade?: boolean | string | null;
2198
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
2199
+ headersTimeout?: number | null;
2200
+ /** 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. */
2201
+ bodyTimeout?: number | null;
2202
+ /** Whether the request should stablish a keep-alive or not. Default `false` */
2203
+ reset?: boolean;
2204
+ /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
2205
+ throwOnError?: boolean;
2206
+ /** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
2207
+ expectContinue?: boolean;
2208
+ }
2209
+ export interface ConnectOptions<TOpaque = null> {
2210
+ origin: string | URL$1;
2211
+ path: string;
2212
+ /** Default: `null` */
2213
+ headers?: UndiciHeaders;
2214
+ /** Default: `null` */
2215
+ signal?: AbortSignal$1 | EventEmitter | null;
2216
+ /** This argument parameter is passed through to `ConnectData` */
2217
+ opaque?: TOpaque;
2218
+ /** Default: `null` */
2219
+ responseHeaders?: 'raw' | null;
2220
+ }
2221
+ export interface RequestOptions<TOpaque = null> extends DispatchOptions {
2222
+ /** Default: `null` */
2223
+ opaque?: TOpaque;
2224
+ /** Default: `null` */
2225
+ signal?: AbortSignal$1 | EventEmitter | null;
2226
+ /** Default: `null` */
2227
+ onInfo?: (info: {
2228
+ statusCode: number;
2229
+ headers: Record<string, string | string[]>;
2230
+ }) => void;
2231
+ /** Default: `null` */
2232
+ responseHeaders?: 'raw' | null;
2233
+ /** Default: `64 KiB` */
2234
+ highWaterMark?: number;
2235
+ }
2236
+ export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
2237
+ /** `true` if the `handler` will return an object stream. Default: `false` */
2238
+ objectMode?: boolean;
2239
+ }
2240
+ export interface UpgradeOptions {
2241
+ path: string;
2242
+ /** Default: `'GET'` */
2243
+ method?: string;
2244
+ /** Default: `null` */
2245
+ headers?: UndiciHeaders;
2246
+ /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
2247
+ protocol?: string;
2248
+ /** Default: `null` */
2249
+ signal?: AbortSignal$1 | EventEmitter | null;
2250
+ /** Default: `null` */
2251
+ responseHeaders?: 'raw' | null;
2252
+ }
2253
+ export interface ConnectData<TOpaque = null> {
2254
+ statusCode: number;
2255
+ headers: IncomingHttpHeaders;
2256
+ socket: Duplex;
2257
+ opaque: TOpaque;
2258
+ }
2259
+ export interface ResponseData<TOpaque = null> {
2260
+ statusCode: number;
2261
+ statusText: string;
2262
+ headers: IncomingHttpHeaders;
2263
+ body: BodyReadable & BodyMixin;
2264
+ trailers: Record<string, string>;
2265
+ opaque: TOpaque;
2266
+ context: object;
2267
+ }
2268
+ export interface PipelineHandlerData<TOpaque = null> {
2269
+ statusCode: number;
2270
+ headers: IncomingHttpHeaders;
2271
+ opaque: TOpaque;
2272
+ body: BodyReadable;
2273
+ context: object;
2274
+ }
2275
+ export interface StreamData<TOpaque = null> {
2276
+ opaque: TOpaque;
2277
+ trailers: Record<string, string>;
2278
+ }
2279
+ export interface UpgradeData<TOpaque = null> {
2280
+ headers: IncomingHttpHeaders;
2281
+ socket: Duplex;
2282
+ opaque: TOpaque;
2283
+ }
2284
+ export interface StreamFactoryData<TOpaque = null> {
2285
+ statusCode: number;
2286
+ headers: IncomingHttpHeaders;
2287
+ opaque: TOpaque;
2288
+ context: object;
2289
+ }
2290
+ export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable;
2291
+ export interface DispatchController {
2292
+ get aborted(): boolean;
2293
+ get paused(): boolean;
2294
+ get reason(): Error | null;
2295
+ abort(reason: Error): void;
2296
+ pause(): void;
2297
+ resume(): void;
2298
+ }
2299
+ export interface DispatchHandler {
2300
+ onRequestStart?(controller: DispatchController, context: any): void;
2301
+ onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
2302
+ onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
2303
+ onResponseData?(controller: DispatchController, chunk: Buffer): void;
2304
+ onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
2305
+ onResponseError?(controller: DispatchController, error: Error): void;
2306
+ /** 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. */
2307
+ /** @deprecated */
2308
+ onConnect?(abort: (err?: Error) => void): void;
2309
+ /** Invoked when an error has occurred. */
2310
+ /** @deprecated */
2311
+ onError?(err: Error): void;
2312
+ /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
2313
+ /** @deprecated */
2314
+ onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
2315
+ /** Invoked when response is received, before headers have been read. **/
2316
+ /** @deprecated */
2317
+ onResponseStarted?(): void;
2318
+ /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
2319
+ /** @deprecated */
2320
+ onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
2321
+ /** Invoked when response payload data is received. */
2322
+ /** @deprecated */
2323
+ onData?(chunk: Buffer): boolean;
2324
+ /** Invoked when response payload and trailers have been received and the request has completed. */
2325
+ /** @deprecated */
2326
+ onComplete?(trailers: string[] | null): void;
2327
+ /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
2328
+ /** @deprecated */
2329
+ onBodySent?(chunkSize: number, totalBytesSent: number): void;
2330
+ }
2331
+ export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable;
2332
+ export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>;
2333
+ /**
2334
+ * @link https://fetch.spec.whatwg.org/#body-mixin
2335
+ */
2336
+ interface BodyMixin {
2337
+ readonly body?: never;
2338
+ readonly bodyUsed: boolean;
2339
+ arrayBuffer(): Promise<ArrayBuffer>;
2340
+ blob(): Promise<Blob>;
2341
+ bytes(): Promise<Uint8Array>;
2342
+ formData(): Promise<never>;
2343
+ json(): Promise<unknown>;
2344
+ text(): Promise<string>;
2345
+ }
2346
+ export interface DispatchInterceptor {
2347
+ (dispatch: Dispatch): Dispatch;
2348
+ }
2349
+ }
2350
+ /** The scope associated with a mock dispatch. */
2351
+ declare class MockScope<TData extends object = object> {
2352
+ constructor(mockDispatch: MockInterceptor.MockDispatch<TData>);
2353
+ /** Delay a reply by a set amount of time in ms. */
2354
+ delay(waitInMs: number): MockScope<TData>;
2355
+ /** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
2356
+ persist(): MockScope<TData>;
2357
+ /** Define a reply for a set amount of matching requests. */
2358
+ times(repeatTimes: number): MockScope<TData>;
2359
+ }
2360
+ /** The interceptor for a Mock. */
2361
+ declare class MockInterceptor {
2362
+ constructor(options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[]);
2363
+ /** Mock an undici request with the defined reply. */
2364
+ reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>;
2365
+ reply<TData extends object = object>(statusCode: number, data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>, responseOptions?: MockInterceptor.MockResponseOptions): MockScope<TData>;
2366
+ /** Mock an undici request by throwing the defined reply error. */
2367
+ replyWithError<TError extends Error = Error>(error: TError): MockScope;
2368
+ /** Set default reply headers on the interceptor for subsequent mocked replies. */
2369
+ defaultReplyHeaders(headers: IncomingHttpHeaders): MockInterceptor;
2370
+ /** Set default reply trailers on the interceptor for subsequent mocked replies. */
2371
+ defaultReplyTrailers(trailers: Record<string, string>): MockInterceptor;
2372
+ /** Set automatically calculated content-length header on subsequent mocked replies. */
2373
+ replyContentLength(): MockInterceptor;
2374
+ }
2375
+ declare namespace MockInterceptor {
2376
+ /** MockInterceptor options. */
2377
+ export interface Options {
2378
+ /** Path to intercept on. */
2379
+ path: string | RegExp | ((path: string) => boolean);
2380
+ /** Method to intercept on. Defaults to GET. */
2381
+ method?: string | RegExp | ((method: string) => boolean);
2382
+ /** Body to intercept on. */
2383
+ body?: string | RegExp | ((body: string) => boolean);
2384
+ /** Headers to intercept on. */
2385
+ headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
2386
+ /** Query params to intercept on */
2387
+ query?: Record<string, any>;
2388
+ }
2389
+ export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
2390
+ times: number | null;
2391
+ persist: boolean;
2392
+ consumed: boolean;
2393
+ data: MockDispatchData<TData, TError>;
2394
+ }
2395
+ export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
2396
+ error: TError | null;
2397
+ statusCode?: number;
2398
+ data?: TData | string;
2399
+ }
2400
+ export interface MockResponseOptions {
2401
+ headers?: IncomingHttpHeaders;
2402
+ trailers?: Record<string, string>;
2403
+ }
2404
+ export interface MockResponseCallbackOptions {
2405
+ path: string;
2406
+ method: string;
2407
+ headers?: Headers | Record<string, string>;
2408
+ origin?: string;
2409
+ body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
2410
+ }
2411
+ export type MockResponseDataHandler<TData extends object = object> = (opts: MockResponseCallbackOptions) => TData | Buffer | string;
2412
+ export type MockReplyOptionsCallback<TData extends object = object> = (opts: MockResponseCallbackOptions) => {
2413
+ statusCode: number;
2414
+ data?: TData | Buffer | string;
2415
+ responseOptions?: MockResponseOptions;
2416
+ };
2417
+ }
2418
+ export { RawConfig };