wrangler 4.40.2 → 4.51.0

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.
@@ -1,1783 +1,17 @@
1
- import { Json, Request, Response as Response$1, DispatchFetch, NodeJSCompatMode, Miniflare, WorkerRegistry, MiniflareOptions, Mutex, WorkerOptions, ModuleRule, RemoteProxyConnectionString } from 'miniflare';
1
+ import { Rule, CfModule, Environment, CfScriptFormat, CfModuleType, Config, CfKvNamespace, CfSendEmailBindings, CfBrowserBinding, CfAIBinding, CfImagesBinding, CfDurableObject, CfWorkflow, CfQueue, CfR2Bucket, CfD1Database, CfVectorize, CfHyperdrive, CfService, CfAnalyticsEngineDataset, CfDispatchNamespace, CfMTlsCertificate, CfPipeline, CfSecretsStoreSecrets, CfLogfwdrBinding, CfHelloWorld, CfRateLimit, CfWorkerLoader, CfVpcService, CfMediaBinding, DurableObjectMigration, ContainerApp, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfTailConsumer, ContainerEngine, CfUnsafe, ConfigBindingOptions, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, ParseError, RawConfig, PackageJSON, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
2
+ export { ConfigBindingOptions as Experimental_ConfigBindingOptions, Config as Unstable_Config, RawConfig as Unstable_RawConfig, RawEnvironment as Unstable_RawEnvironment, experimental_patchConfig, experimental_readRawConfig } from '@cloudflare/workers-utils';
3
+ import { Json, Request, Response as Response$1, NodeJSCompatMode, DispatchFetch, Miniflare, WorkerRegistry, MiniflareOptions, Mutex, WorkerOptions, ModuleRule, RemoteProxyConnectionString } from 'miniflare';
2
4
  import * as undici from 'undici';
3
5
  import { RequestInfo, RequestInit, Response, FormData } from 'undici';
4
- import { CamelCaseKey, Argv, PositionalOptions, Options, ArgumentsCamelCase, InferredOptionTypes, Alias } from 'yargs';
5
6
  import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
6
7
  import { Metafile } from 'esbuild';
7
- import { EventEmitter } from 'node:events';
8
- import Protocol from 'devtools-protocol/types/protocol-mapping';
9
- import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
10
- import { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
11
- import { URLSearchParams } from 'node:url';
12
- import Cloudflare from 'cloudflare';
13
-
14
- /**
15
- * The `Environment` interface declares all the configuration fields that
16
- * can be specified for an environment.
17
- *
18
- * This could be the top-level default environment, or a specific named environment.
19
- */
20
- interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
21
- }
22
- type SimpleRoute = string;
23
- type ZoneIdRoute = {
24
- pattern: string;
25
- zone_id: string;
26
- custom_domain?: boolean;
27
- };
28
- type ZoneNameRoute = {
29
- pattern: string;
30
- zone_name: string;
31
- custom_domain?: boolean;
32
- };
33
- type CustomDomainRoute = {
34
- pattern: string;
35
- custom_domain: boolean;
36
- };
37
- type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
38
- /**
39
- * Configuration in wrangler for Cloudchamber
40
- */
41
- type CloudchamberConfig = {
42
- image?: string;
43
- location?: string;
44
- instance_type?: "dev" | "basic" | "standard";
45
- vcpu?: number;
46
- memory?: string;
47
- ipv4?: boolean;
48
- };
49
- type UnsafeBinding = {
50
- /**
51
- * The name of the binding provided to the Worker
52
- */
53
- name: string;
54
- /**
55
- * The 'type' of the unsafe binding.
56
- */
57
- type: string;
58
- dev?: {
59
- plugin: {
60
- /**
61
- * Package is the bare specifier of the package that exposes plugins to integrate into Miniflare via a named `plugins` export.
62
- * @example "@cloudflare/my-external-miniflare-plugin"
63
- */
64
- package: string;
65
- /**
66
- * Plugin is the name of the plugin exposed by the package.
67
- * @example "MY_UNSAFE_PLUGIN"
68
- */
69
- name: string;
70
- };
71
- /**
72
- * Optional mapping of unsafe bindings names to options provided for the plugin.
73
- */
74
- options?: Record<string, unknown>;
75
- };
76
- [key: string]: unknown;
77
- };
78
- /**
79
- * Configuration for a container application
80
- */
81
- type ContainerApp = {
82
- /**
83
- * Name of the application
84
- * @optional Defaults to `worker_name-class_name` if not specified.
85
- */
86
- name?: string;
87
- /**
88
- * Number of application instances
89
- * @deprecated
90
- * @hidden
91
- */
92
- instances?: number;
93
- /**
94
- * Number of maximum application instances.
95
- * @optional
96
- */
97
- max_instances?: number;
98
- /**
99
- * The path to a Dockerfile, or an image URI for the Cloudflare registry.
100
- */
101
- image: string;
102
- /**
103
- * Build context of the application.
104
- * @optional - defaults to the directory of `image`.
105
- */
106
- image_build_context?: string;
107
- /**
108
- * Image variables available to the image at build-time only.
109
- * For runtime env vars, refer to https://developers.cloudflare.com/containers/examples/env-vars-and-secrets/
110
- * @optional
111
- */
112
- image_vars?: Record<string, string>;
113
- /**
114
- * The class name of the Durable Object the container is connected to.
115
- */
116
- class_name: string;
117
- /**
118
- * The scheduling policy of the application
119
- * @optional
120
- * @default "default"
121
- */
122
- scheduling_policy?: "default" | "moon" | "regional";
123
- /**
124
- * The instance type to be used for the container.
125
- * Select from one of the following named instance types:
126
- * - dev: 1/16 vCPU, 256 MiB memory, and 2 GB disk
127
- * - basic: 1/4 vCPU, 1 GiB memory, and 4 GB disk
128
- * - standard: 1/2 vCPU, 4 GiB memory, and 4 GB disk
129
- *
130
- * Customers on an enterprise plan have the additional option to set custom limits.
131
- *
132
- * @optional
133
- * @default "dev"
134
- */
135
- instance_type?: "dev" | "basic" | "standard" | {
136
- /** @defaults to 0.0625 (1/16 vCPU) */
137
- vcpu?: number;
138
- /** @defaults to 256 MiB */
139
- memory_mib?: number;
140
- /** @defaults to 2 GB */
141
- disk_mb?: number;
142
- };
143
- /**
144
- * @deprecated Use top level `containers` fields instead.
145
- * `configuration.image` should be `image`
146
- * limits should be set via `instance_type`
147
- * @hidden
148
- */
149
- configuration?: {
150
- image?: string;
151
- labels?: {
152
- name: string;
153
- value: string;
154
- }[];
155
- secrets?: {
156
- name: string;
157
- type: "env";
158
- secret: string;
159
- }[];
160
- disk?: {
161
- size_mb: number;
162
- };
163
- vcpu?: number;
164
- memory_mib?: number;
165
- };
166
- /**
167
- * Scheduling constraints
168
- * @hidden
169
- */
170
- constraints?: {
171
- regions?: string[];
172
- cities?: string[];
173
- tier?: number;
174
- };
175
- /**
176
- * Scheduling affinities
177
- * @hidden
178
- */
179
- affinities?: {
180
- colocation?: "datacenter";
181
- hardware_generation?: "highest-overall-performance";
182
- };
183
- /**
184
- * @deprecated use the `class_name` field instead.
185
- * @hidden
186
- */
187
- durable_objects?: {
188
- namespace_id: string;
189
- };
190
- /**
191
- * Configures what percentage of instances should be updated at each step of a rollout.
192
- * You can specify this as a single number, or an array of numbers.
193
- *
194
- * If this is a single number, each step will progress by that percentage.
195
- * The options are 5, 10, 20, 25, 50 or 100.
196
- *
197
- * If this is an array, each step specifies the cumulative rollout progress.
198
- * The final step must be 100.
199
- *
200
- * This can be overridden adhoc by deploying with the `--containers-rollout=immediate` flag,
201
- * which will roll out to 100% of instances in one step.
202
- *
203
- * @optional
204
- * @default [10,100]
205
- * */
206
- rollout_step_percentage?: number | number[];
207
- /**
208
- * How a rollout should be created. It supports the following modes:
209
- * - full_auto: The container application will be rolled out fully automatically.
210
- * - none: The container application won't have a roll out or update.
211
- * - manual: The container application will be rollout fully by manually actioning progress steps.
212
- * @optional
213
- * @default "full_auto"
214
- * @hidden
215
- */
216
- rollout_kind?: "full_auto" | "none" | "full_manual";
217
- /**
218
- * Configures the grace period (in seconds) for active instances before being shutdown during a rollout.
219
- * @optional
220
- * @default 0
221
- */
222
- rollout_active_grace_period?: number;
223
- };
224
- /**
225
- * Configuration in wrangler for Durable Object Migrations
226
- */
227
- type DurableObjectMigration = {
228
- /** A unique identifier for this migration. */
229
- tag: string;
230
- /** The new Durable Objects being defined. */
231
- new_classes?: string[];
232
- /** The new SQLite Durable Objects being defined. */
233
- new_sqlite_classes?: string[];
234
- /** The Durable Objects being renamed. */
235
- renamed_classes?: {
236
- from: string;
237
- to: string;
238
- }[];
239
- /** The Durable Objects being removed. */
240
- deleted_classes?: string[];
241
- };
242
- /**
243
- * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
244
- * that can be inherited (and overridden) from the top-level environment.
245
- */
246
- interface EnvironmentInheritable {
247
- /**
248
- * The name of your Worker. Alphanumeric + dashes only.
249
- *
250
- * @inheritable
251
- */
252
- name: string | undefined;
253
- /**
254
- * This is the ID of the account associated with your zone.
255
- * You might have more than one account, so make sure to use
256
- * the ID of the account associated with the zone/route you
257
- * provide, if you provide one. It can also be specified through
258
- * the CLOUDFLARE_ACCOUNT_ID environment variable.
259
- *
260
- * @inheritable
261
- */
262
- account_id: string | undefined;
263
- /**
264
- * A date in the form yyyy-mm-dd, which will be used to determine
265
- * which version of the Workers runtime is used.
266
- *
267
- * More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
268
- *
269
- * @inheritable
270
- */
271
- compatibility_date: string | undefined;
272
- /**
273
- * A list of flags that enable features from upcoming features of
274
- * the Workers runtime, usually used together with compatibility_date.
275
- *
276
- * More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
277
- *
278
- * @default []
279
- * @inheritable
280
- */
281
- compatibility_flags: string[];
282
- /**
283
- * The entrypoint/path to the JavaScript file that will be executed.
284
- *
285
- * @inheritable
286
- */
287
- main: string | undefined;
288
- /**
289
- * If true then Wrangler will traverse the file tree below `base_dir`;
290
- * Any files that match `rules` will be included in the deployed Worker.
291
- * Defaults to true if `no_bundle` is true, otherwise false.
292
- *
293
- * @inheritable
294
- */
295
- find_additional_modules: boolean | undefined;
296
- /**
297
- * Determines whether Wrangler will preserve bundled file names.
298
- * Defaults to false.
299
- * If left unset, files will be named using the pattern ${fileHash}-${basename},
300
- * for example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
301
- *
302
- * @inheritable
303
- */
304
- preserve_file_names: boolean | undefined;
305
- /**
306
- * The directory in which module rules should be evaluated when including additional files into a Worker deployment.
307
- * This defaults to the directory containing the `main` entry point of the Worker if not specified.
308
- *
309
- * @inheritable
310
- */
311
- base_dir: string | undefined;
312
- /**
313
- * Whether we use <name>.<subdomain>.workers.dev to
314
- * test and deploy your Worker.
315
- *
316
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
317
- *
318
- * @default true
319
- * @breaking
320
- * @inheritable
321
- */
322
- workers_dev: boolean | undefined;
323
- /**
324
- * Whether we use <version>-<name>.<subdomain>.workers.dev to
325
- * serve Preview URLs for your Worker.
326
- *
327
- * @default false
328
- * @inheritable
329
- */
330
- preview_urls: boolean | undefined;
331
- /**
332
- * A list of routes that your Worker should be published to.
333
- * Only one of `routes` or `route` is required.
334
- *
335
- * Only required when workers_dev is false, and there's no scheduled Worker (see `triggers`)
336
- *
337
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
338
- *
339
- * @inheritable
340
- */
341
- routes: Route[] | undefined;
342
- /**
343
- * A route that your Worker should be published to. Literally
344
- * the same as routes, but only one.
345
- * Only one of `routes` or `route` is required.
346
- *
347
- * Only required when workers_dev is false, and there's no scheduled Worker
348
- *
349
- * @inheritable
350
- */
351
- route: Route | undefined;
352
- /**
353
- * Path to a custom tsconfig
354
- *
355
- * @inheritable
356
- */
357
- tsconfig: string | undefined;
358
- /**
359
- * The function to use to replace jsx syntax.
360
- *
361
- * @default "React.createElement"
362
- * @inheritable
363
- */
364
- jsx_factory: string;
365
- /**
366
- * The function to use to replace jsx fragment syntax.
367
- *
368
- * @default "React.Fragment"
369
- * @inheritable
370
- */
371
- jsx_fragment: string;
372
- /**
373
- * A list of migrations that should be uploaded with your Worker.
374
- *
375
- * These define changes in your Durable Object declarations.
376
- *
377
- * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
378
- *
379
- * @default []
380
- * @inheritable
381
- */
382
- migrations: DurableObjectMigration[];
383
- /**
384
- * "Cron" definitions to trigger a Worker's "scheduled" function.
385
- *
386
- * Lets you call Workers periodically, much like a cron job.
387
- *
388
- * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
389
- *
390
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
391
- *
392
- * @default {crons: undefined}
393
- * @inheritable
394
- */
395
- triggers: {
396
- crons: string[] | undefined;
397
- };
398
- /**
399
- * Specify limits for runtime behavior.
400
- * Only supported for the "standard" Usage Model
401
- *
402
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
403
- *
404
- * @inheritable
405
- */
406
- limits: UserLimits | undefined;
407
- /**
408
- * An ordered list of rules that define which modules to import,
409
- * and what type to import them as. You will need to specify rules
410
- * to use Text, Data, and CompiledWasm modules, or when you wish to
411
- * have a .js file be treated as an ESModule instead of CommonJS.
412
- *
413
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#bundling
414
- *
415
- * @inheritable
416
- */
417
- rules: Rule[];
418
- /**
419
- * Configures a custom build step to be run by Wrangler when building your Worker.
420
- *
421
- * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
422
- * for more details.
423
- *
424
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#custom-builds
425
- *
426
- * @default {watch_dir:"./src"}
427
- */
428
- build: {
429
- /** 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. */
430
- command?: string;
431
- /** The directory in which the command is executed. */
432
- cwd?: string;
433
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
434
- watch_dir?: string | string[];
435
- };
436
- /**
437
- * Skip internal build steps and directly deploy script
438
- * @inheritable
439
- */
440
- no_bundle: boolean | undefined;
441
- /**
442
- * Minify the script before uploading.
443
- * @inheritable
444
- */
445
- minify: boolean | undefined;
446
- /**
447
- * Set the `name` property to the original name for functions and classes renamed during minification.
448
- *
449
- * See https://esbuild.github.io/api/#keep-names
450
- *
451
- * @default true
452
- * @inheritable
453
- */
454
- keep_names: boolean | undefined;
455
- /**
456
- * Designates this Worker as an internal-only "first-party" Worker.
457
- *
458
- * @inheritable
459
- */
460
- first_party_worker: boolean | undefined;
461
- /**
462
- * List of bindings that you will send to logfwdr
463
- *
464
- * @default {bindings:[]}
465
- * @inheritable
466
- */
467
- logfwdr: {
468
- bindings: {
469
- /** The binding name used to refer to logfwdr */
470
- name: string;
471
- /** The destination for this logged message */
472
- destination: string;
473
- }[];
474
- };
475
- /**
476
- * Send Trace Events from this Worker to Workers Logpush.
477
- *
478
- * This will not configure a corresponding Logpush job automatically.
479
- *
480
- * For more information about Workers Logpush, see:
481
- * https://blog.cloudflare.com/logpush-for-workers/
482
- *
483
- * @inheritable
484
- */
485
- logpush: boolean | undefined;
486
- /**
487
- * Include source maps when uploading this worker.
488
- *
489
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#source-maps
490
- *
491
- * @inheritable
492
- */
493
- upload_source_maps: boolean | undefined;
494
- /**
495
- * Specify how the Worker should be located to minimize round-trip time.
496
- *
497
- * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
498
- *
499
- * @inheritable
500
- */
501
- placement: {
502
- mode: "off" | "smart";
503
- hint?: string;
504
- } | undefined;
505
- /**
506
- * Specify the directory of static assets to deploy/serve
507
- *
508
- * More details at https://developers.cloudflare.com/workers/frameworks/
509
- *
510
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
511
- *
512
- * @inheritable
513
- */
514
- assets: Assets | undefined;
515
- /**
516
- * Specify the observability behavior of the Worker.
517
- *
518
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
519
- *
520
- * @inheritable
521
- */
522
- observability: Observability | undefined;
523
- /**
524
- * Specify the compliance region mode of the Worker.
525
- *
526
- * Although if the user does not specify a compliance region, the default is `public`,
527
- * it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
528
- */
529
- compliance_region: "public" | "fedramp_high" | undefined;
530
- }
531
- type DurableObjectBindings = {
532
- /** The name of the binding used to refer to the Durable Object */
533
- name: string;
534
- /** The exported class name of the Durable Object */
535
- class_name: string;
536
- /** The script where the Durable Object is defined (if it's external to this Worker) */
537
- script_name?: string;
538
- /** The service environment of the script_name to bind to */
539
- environment?: string;
540
- }[];
541
- type WorkflowBinding = {
542
- /** The name of the binding used to refer to the Workflow */
543
- binding: string;
544
- /** The name of the Workflow */
545
- name: string;
546
- /** The exported class name of the Workflow */
547
- class_name: string;
548
- /** The script where the Workflow is defined (if it's external to this Worker) */
549
- script_name?: string;
550
- /** Whether the Workflow should be remote or not in local development */
551
- remote?: boolean;
552
- };
553
- /**
554
- * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
555
- * that cannot be inherited from the top-level environment, and must be defined specifically.
556
- *
557
- * If any of these fields are defined at the top-level then they should also be specifically defined
558
- * for each named environment.
559
- */
560
- interface EnvironmentNonInheritable {
561
- /**
562
- * A map of values to substitute when deploying your Worker.
563
- *
564
- * NOTE: This field is not automatically inherited from the top level environment,
565
- * and so must be specified in every named environment.
566
- *
567
- * @default {}
568
- * @nonInheritable
569
- */
570
- define: Record<string, string>;
571
- /**
572
- * A map of environment variables to set when deploying your Worker.
573
- *
574
- * NOTE: This field is not automatically inherited from the top level environment,
575
- * and so must be specified in every named environment.
576
- *
577
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
578
- *
579
- * @default {}
580
- * @nonInheritable
581
- */
582
- vars: Record<string, string | Json>;
583
- /**
584
- * A list of durable objects that your Worker should be bound to.
585
- *
586
- * For more information about Durable Objects, see the documentation at
587
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
588
- *
589
- * NOTE: This field is not automatically inherited from the top level environment,
590
- * and so must be specified in every named environment.
591
- *
592
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
593
- *
594
- * @default {bindings:[]}
595
- * @nonInheritable
596
- */
597
- durable_objects: {
598
- bindings: DurableObjectBindings;
599
- };
600
- /**
601
- * A list of workflows that your Worker should be bound to.
602
- *
603
- * NOTE: This field is not automatically inherited from the top level environment,
604
- * and so must be specified in every named environment.
605
- *
606
- * @default []
607
- * @nonInheritable
608
- */
609
- workflows: WorkflowBinding[];
610
- /**
611
- * Cloudchamber configuration
612
- *
613
- * NOTE: This field is not automatically inherited from the top level environment,
614
- * and so must be specified in every named environment.
615
- *
616
- * @default {}
617
- * @nonInheritable
618
- */
619
- cloudchamber: CloudchamberConfig;
620
- /**
621
- * Container related configuration
622
- *
623
- * NOTE: This field is not automatically inherited from the top level environment,
624
- * and so must be specified in every named environment.
625
- *
626
- * @default []
627
- * @nonInheritable
628
- */
629
- containers?: ContainerApp[];
630
- /**
631
- * These specify any Workers KV Namespaces you want to
632
- * access from inside your Worker.
633
- *
634
- * To learn more about KV Namespaces,
635
- * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
636
- *
637
- * NOTE: This field is not automatically inherited from the top level environment,
638
- * and so must be specified in every named environment.
639
- *
640
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
641
- *
642
- * @default []
643
- * @nonInheritable
644
- */
645
- kv_namespaces: {
646
- /** The binding name used to refer to the KV Namespace */
647
- binding: string;
648
- /** The ID of the KV namespace */
649
- id?: string;
650
- /** The ID of the KV namespace used during `wrangler dev` */
651
- preview_id?: string;
652
- /** Whether the KV namespace should be remote or not in local development */
653
- remote?: boolean;
654
- }[];
655
- /**
656
- * These specify bindings to send email from inside your Worker.
657
- *
658
- * NOTE: This field is not automatically inherited from the top level environment,
659
- * and so must be specified in every named environment.
660
- *
661
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
662
- *
663
- * @default []
664
- * @nonInheritable
665
- */
666
- send_email: {
667
- /** The binding name used to refer to the this binding */
668
- name: string;
669
- /** If this binding should be restricted to a specific verified address */
670
- destination_address?: string;
671
- /** If this binding should be restricted to a set of verified addresses */
672
- allowed_destination_addresses?: string[];
673
- /** If this binding should be restricted to a set of sender addresses */
674
- allowed_sender_addresses?: string[];
675
- /** Whether the binding should be remote or not in local development */
676
- remote?: boolean;
677
- }[];
678
- /**
679
- * Specifies Queues that are bound to this Worker environment.
680
- *
681
- * NOTE: This field is not automatically inherited from the top level environment,
682
- * and so must be specified in every named environment.
683
- *
684
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
685
- *
686
- * @default {consumers:[],producers:[]}
687
- * @nonInheritable
688
- */
689
- queues: {
690
- /** Producer bindings */
691
- producers?: {
692
- /** The binding name used to refer to the Queue in the Worker. */
693
- binding: string;
694
- /** The name of this Queue. */
695
- queue: string;
696
- /** The number of seconds to wait before delivering a message */
697
- delivery_delay?: number;
698
- /** Whether the Queue producer should be remote or not in local development */
699
- remote?: boolean;
700
- }[];
701
- /** Consumer configuration */
702
- consumers?: {
703
- /** The name of the queue from which this consumer should consume. */
704
- queue: string;
705
- /** The consumer type, e.g., worker, http-pull, r2-bucket, etc. Default is worker. */
706
- type?: string;
707
- /** The maximum number of messages per batch */
708
- max_batch_size?: number;
709
- /** The maximum number of seconds to wait to fill a batch with messages. */
710
- max_batch_timeout?: number;
711
- /** The maximum number of retries for each message. */
712
- max_retries?: number;
713
- /** The queue to send messages that failed to be consumed. */
714
- dead_letter_queue?: string;
715
- /** 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. */
716
- max_concurrency?: number | null;
717
- /** The number of milliseconds to wait for pulled messages to become visible again */
718
- visibility_timeout_ms?: number;
719
- /** The number of seconds to wait before retrying a message */
720
- retry_delay?: number;
721
- }[];
722
- };
723
- /**
724
- * Specifies R2 buckets that are bound to this Worker environment.
725
- *
726
- * NOTE: This field is not automatically inherited from the top level environment,
727
- * and so must be specified in every named environment.
728
- *
729
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
730
- *
731
- * @default []
732
- * @nonInheritable
733
- */
734
- r2_buckets: {
735
- /** The binding name used to refer to the R2 bucket in the Worker. */
736
- binding: string;
737
- /** The name of this R2 bucket at the edge. */
738
- bucket_name?: string;
739
- /** The preview name of this R2 bucket at the edge. */
740
- preview_bucket_name?: string;
741
- /** The jurisdiction that the bucket exists in. Default if not present. */
742
- jurisdiction?: string;
743
- /** Whether the R2 bucket should be remote or not in local development */
744
- remote?: boolean;
745
- }[];
746
- /**
747
- * Specifies D1 databases that are bound to this Worker environment.
748
- *
749
- * NOTE: This field is not automatically inherited from the top level environment,
750
- * and so must be specified in every named environment.
751
- *
752
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
753
- *
754
- * @default []
755
- * @nonInheritable
756
- */
757
- d1_databases: {
758
- /** The binding name used to refer to the D1 database in the Worker. */
759
- binding: string;
760
- /** The name of this D1 database. */
761
- database_name?: string;
762
- /** The UUID of this D1 database (not required). */
763
- database_id?: string;
764
- /** The UUID of this D1 database for Wrangler Dev (if specified). */
765
- preview_database_id?: string;
766
- /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
767
- migrations_table?: string;
768
- /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
769
- migrations_dir?: string;
770
- /** Internal use only. */
771
- database_internal_env?: string;
772
- /** Whether the D1 database should be remote or not in local development */
773
- remote?: boolean;
774
- }[];
775
- /**
776
- * Specifies Vectorize indexes that are bound to this Worker environment.
777
- *
778
- * NOTE: This field is not automatically inherited from the top level environment,
779
- * and so must be specified in every named environment.
780
- *
781
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
782
- *
783
- * @default []
784
- * @nonInheritable
785
- */
786
- vectorize: {
787
- /** The binding name used to refer to the Vectorize index in the Worker. */
788
- binding: string;
789
- /** The name of the index. */
790
- index_name: string;
791
- /** Whether the Vectorize index should be remote or not in local development */
792
- remote?: boolean;
793
- }[];
794
- /**
795
- * Specifies Hyperdrive configs that are bound to this Worker environment.
796
- *
797
- * NOTE: This field is not automatically inherited from the top level environment,
798
- * and so must be specified in every named environment.
799
- *
800
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
801
- *
802
- * @default []
803
- * @nonInheritable
804
- */
805
- hyperdrive: {
806
- /** The binding name used to refer to the project in the Worker. */
807
- binding: string;
808
- /** The id of the database. */
809
- id: string;
810
- /** The local database connection string for `wrangler dev` */
811
- localConnectionString?: string;
812
- }[];
813
- /**
814
- * Specifies service bindings (Worker-to-Worker) that are bound to this Worker environment.
815
- *
816
- * NOTE: This field is not automatically inherited from the top level environment,
817
- * and so must be specified in every named environment.
818
- *
819
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
820
- *
821
- * @default []
822
- * @nonInheritable
823
- */
824
- services: {
825
- /** The binding name used to refer to the bound service. */
826
- binding: string;
827
- /**
828
- * The name of the service.
829
- * To bind to a worker in a specific environment,
830
- * you should use the format `<worker_name>-<environment_name>`.
831
- */
832
- service: string;
833
- /**
834
- * @hidden
835
- * @deprecated you should use `service: <worker_name>-<environment_name>` instead.
836
- * This refers to the deprecated concept of 'service environments'.
837
- * The environment of the service (e.g. production, staging, etc).
838
- */
839
- environment?: string;
840
- /** Optionally, the entrypoint (named export) of the service to bind to. */
841
- entrypoint?: string;
842
- /** Optional properties that will be made available to the service via ctx.props. */
843
- props?: Record<string, unknown>;
844
- /** Whether the service binding should be remote or not in local development */
845
- remote?: boolean;
846
- }[] | undefined;
847
- /**
848
- * Specifies analytics engine datasets that are bound to this Worker environment.
849
- *
850
- * NOTE: This field is not automatically inherited from the top level environment,
851
- * and so must be specified in every named environment.
852
- *
853
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
854
- *
855
- * @default []
856
- * @nonInheritable
857
- */
858
- analytics_engine_datasets: {
859
- /** The binding name used to refer to the dataset in the Worker. */
860
- binding: string;
861
- /** The name of this dataset to write to. */
862
- dataset?: string;
863
- }[];
864
- /**
865
- * A browser that will be usable from the Worker.
866
- *
867
- * NOTE: This field is not automatically inherited from the top level environment,
868
- * and so must be specified in every named environment.
869
- *
870
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
871
- *
872
- * @default {}
873
- * @nonInheritable
874
- */
875
- browser: {
876
- binding: string;
877
- /** Whether the Browser binding should be remote or not in local development */
878
- remote?: boolean;
879
- } | undefined;
880
- /**
881
- * Binding to the AI project.
882
- *
883
- * NOTE: This field is not automatically inherited from the top level environment,
884
- * and so must be specified in every named environment.
885
- *
886
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
887
- *
888
- * @default {}
889
- * @nonInheritable
890
- */
891
- ai: {
892
- binding: string;
893
- staging?: boolean;
894
- /** Whether the AI binding should be remote or not in local development */
895
- remote?: boolean;
896
- } | undefined;
897
- /**
898
- * Binding to Cloudflare Images
899
- *
900
- * NOTE: This field is not automatically inherited from the top level environment,
901
- * and so must be specified in every named environment.
902
- *
903
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
904
- *
905
- * @default {}
906
- * @nonInheritable
907
- */
908
- images: {
909
- binding: string;
910
- /** Whether the Images binding should be remote or not in local development */
911
- remote?: boolean;
912
- } | undefined;
913
- /**
914
- * Binding to the Worker Version's metadata
915
- */
916
- version_metadata: {
917
- binding: string;
918
- } | undefined;
919
- /**
920
- * "Unsafe" tables for features that aren't directly supported by wrangler.
921
- *
922
- * NOTE: This field is not automatically inherited from the top level environment,
923
- * and so must be specified in every named environment.
924
- *
925
- * @default {}
926
- * @nonInheritable
927
- */
928
- unsafe: {
929
- /**
930
- * A set of bindings that should be put into a Worker's upload metadata without changes. These
931
- * can be used to implement bindings for features that haven't released and aren't supported
932
- * directly by wrangler or miniflare.
933
- */
934
- bindings?: UnsafeBinding[];
935
- /**
936
- * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
937
- * here will always be applied to metadata last, so can add new or override existing fields.
938
- */
939
- metadata?: {
940
- [key: string]: unknown;
941
- };
942
- /**
943
- * Used for internal capnp uploads for the Workers runtime
944
- */
945
- capnp?: {
946
- base_path: string;
947
- source_schemas: string[];
948
- compiled_schema?: never;
949
- } | {
950
- base_path?: never;
951
- source_schemas?: never;
952
- compiled_schema: string;
953
- };
954
- };
955
- /**
956
- * Specifies a list of mTLS certificates that are bound to this Worker environment.
957
- *
958
- * NOTE: This field is not automatically inherited from the top level environment,
959
- * and so must be specified in every named environment.
960
- *
961
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
962
- *
963
- * @default []
964
- * @nonInheritable
965
- */
966
- mtls_certificates: {
967
- /** The binding name used to refer to the certificate in the Worker */
968
- binding: string;
969
- /** The uuid of the uploaded mTLS certificate */
970
- certificate_id: string;
971
- /** Whether the mtls fetcher should be remote or not in local development */
972
- remote?: boolean;
973
- }[];
974
- /**
975
- * Specifies a list of Tail Workers that are bound to this Worker environment
976
- *
977
- * NOTE: This field is not automatically inherited from the top level environment,
978
- * and so must be specified in every named environment.
979
- *
980
- * @default []
981
- * @nonInheritable
982
- */
983
- tail_consumers?: TailConsumer[];
984
- /**
985
- * Specifies namespace bindings that are bound to this Worker environment.
986
- *
987
- * NOTE: This field is not automatically inherited from the top level environment,
988
- * and so must be specified in every named environment.
989
- *
990
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
991
- *
992
- * @default []
993
- * @nonInheritable
994
- */
995
- dispatch_namespaces: {
996
- /** The binding name used to refer to the bound service. */
997
- binding: string;
998
- /** The namespace to bind to. */
999
- namespace: string;
1000
- /** Details about the outbound Worker which will handle outbound requests from your namespace */
1001
- outbound?: DispatchNamespaceOutbound;
1002
- /** Whether the Dispatch Namespace should be remote or not in local development */
1003
- remote?: boolean;
1004
- }[];
1005
- /**
1006
- * Specifies list of Pipelines bound to this Worker environment
1007
- *
1008
- * NOTE: This field is not automatically inherited from the top level environment,
1009
- * and so must be specified in every named environment.
1010
- *
1011
- * @default []
1012
- * @nonInheritable
1013
- */
1014
- pipelines: {
1015
- /** The binding name used to refer to the bound service. */
1016
- binding: string;
1017
- /** Name of the Pipeline to bind */
1018
- pipeline: string;
1019
- /** Whether the pipeline should be remote or not in local development */
1020
- remote?: boolean;
1021
- }[];
1022
- /**
1023
- * Specifies Secret Store bindings that are bound to this Worker environment.
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
- secrets_store_secrets: {
1032
- /** The binding name used to refer to the bound service. */
1033
- binding: string;
1034
- /** Id of the secret store */
1035
- store_id: string;
1036
- /** Name of the secret */
1037
- secret_name: string;
1038
- }[];
1039
- /**
1040
- * **DO NOT USE**. Hello World Binding Config to serve as an explanatory example.
1041
- *
1042
- * NOTE: This field is not automatically inherited from the top level environment,
1043
- * and so must be specified in every named environment.
1044
- *
1045
- * @default []
1046
- * @nonInheritable
1047
- */
1048
- unsafe_hello_world: {
1049
- /** The binding name used to refer to the bound service. */
1050
- binding: string;
1051
- /** Whether the timer is enabled */
1052
- enable_timer?: boolean;
1053
- }[];
1054
- /**
1055
- * Specifies rate limit bindings that are bound to this Worker environment.
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
- ratelimits: {
1064
- /** The binding name used to refer to the rate limiter in the Worker. */
1065
- name: string;
1066
- /** The namespace ID for this rate limiter. */
1067
- namespace_id: string;
1068
- /** Simple rate limiting configuration. */
1069
- simple: {
1070
- /** The maximum number of requests allowed in the time period. */
1071
- limit: number;
1072
- /** The time period in seconds (10 for ten seconds, 60 for one minute). */
1073
- period: 10 | 60;
1074
- };
1075
- }[];
1076
- /**
1077
- * Specifies Worker Loader bindings that are bound to this Worker environment.
1078
- *
1079
- * NOTE: This field is not automatically inherited from the top level environment,
1080
- * and so must be specified in every named environment.
1081
- *
1082
- * @default []
1083
- * @nonInheritable
1084
- */
1085
- worker_loaders: {
1086
- /** The binding name used to refer to the Worker Loader in the Worker. */
1087
- binding: string;
1088
- }[];
1089
- /**
1090
- * Specifies VPC services that are bound to this Worker environment.
1091
- *
1092
- * NOTE: This field is not automatically inherited from the top level environment,
1093
- * and so must be specified in every named environment.
1094
- *
1095
- * @default []
1096
- * @nonInheritable
1097
- */
1098
- vpc_services: {
1099
- /** The binding name used to refer to the VPC service in the Worker. */
1100
- binding: string;
1101
- /** The service ID of the VPC connectivity service. */
1102
- service_id: string;
1103
- /** Whether the VPC service is remote or not */
1104
- remote?: boolean;
1105
- }[];
1106
- }
1107
- /**
1108
- * The raw environment configuration that we read from the config file.
1109
- *
1110
- * All the properties are optional, and will be replaced with defaults in the configuration that
1111
- * is used in the rest of the codebase.
1112
- */
1113
- type RawEnvironment = Partial<Environment>;
1114
- /**
1115
- * A bundling resolver rule, defining the modules type for paths that match the specified globs.
1116
- */
1117
- type Rule = {
1118
- type: ConfigModuleRuleType;
1119
- globs: string[];
1120
- fallthrough?: boolean;
1121
- };
1122
- /**
1123
- * The possible types for a `Rule`.
1124
- */
1125
- type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data" | "PythonModule" | "PythonRequirement";
1126
- type TailConsumer = {
1127
- /** The name of the service tail events will be forwarded to. */
1128
- service: string;
1129
- /** (Optional) The environment of the service. */
1130
- environment?: string;
1131
- };
1132
- interface DispatchNamespaceOutbound {
1133
- /** Name of the service handling the outbound requests */
1134
- service: string;
1135
- /** (Optional) Name of the environment handling the outbound requests. */
1136
- environment?: string;
1137
- /** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler */
1138
- parameters?: string[];
1139
- }
1140
- interface UserLimits {
1141
- /** Maximum allowed CPU time for a Worker's invocation in milliseconds */
1142
- cpu_ms: number;
1143
- }
1144
- type Assets = {
1145
- /** Absolute path to assets directory */
1146
- directory?: string;
1147
- /** Name of `env` binding property in the User Worker. */
1148
- binding?: string;
1149
- /** How to handle HTML requests. */
1150
- html_handling?: "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash" | "none";
1151
- /** How to handle requests that do not match an asset. */
1152
- not_found_handling?: "single-page-application" | "404-page" | "none";
1153
- /**
1154
- * Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
1155
- *
1156
- * Can also be `true`, indicating that every request should be routed to the User Worker.
1157
- */
1158
- run_worker_first?: string[] | boolean;
1159
- };
1160
- interface Observability {
1161
- /** If observability is enabled for this Worker */
1162
- enabled?: boolean;
1163
- /** The sampling rate */
1164
- head_sampling_rate?: number;
1165
- logs?: {
1166
- enabled?: boolean;
1167
- /** The sampling rate */
1168
- head_sampling_rate?: number;
1169
- /** Set to false to disable invocation logs */
1170
- invocation_logs?: boolean;
1171
- /**
1172
- * If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
1173
- *
1174
- * @default true
1175
- */
1176
- persist?: boolean;
1177
- /**
1178
- * What destinations logs emitted from the Worker should be sent to.
1179
- *
1180
- * @default []
1181
- */
1182
- destinations?: string[];
1183
- };
1184
- traces?: {
1185
- enabled?: boolean;
1186
- /** The sampling rate */
1187
- head_sampling_rate?: number;
1188
- /**
1189
- * If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
1190
- *
1191
- * @default true
1192
- */
1193
- persist?: boolean;
1194
- /**
1195
- * What destinations traces emitted from the Worker should be sent to.
1196
- *
1197
- * @default []
1198
- */
1199
- destinations?: string[];
1200
- };
1201
- }
1202
- type DockerConfiguration = {
1203
- /** Socket used by miniflare to communicate with Docker */
1204
- socketPath: string;
1205
- };
1206
- type ContainerEngine = {
1207
- localDocker: DockerConfiguration;
1208
- } | string;
1209
-
1210
- /**
1211
- * A symbol to inherit a binding from the deployed worker.
1212
- */
1213
- declare const INHERIT_SYMBOL: unique symbol;
1214
-
1215
- /**
1216
- * The type of Worker
1217
- */
1218
- type CfScriptFormat = "modules" | "service-worker";
1219
- /**
1220
- * A module type.
1221
- */
1222
- type CfModuleType = "esm" | "commonjs" | "compiled-wasm" | "text" | "buffer" | "python" | "python-requirement";
1223
- /**
1224
- * An imported module.
1225
- */
1226
- interface CfModule {
1227
- /**
1228
- * The module name.
1229
- *
1230
- * @example
1231
- * './src/index.js'
1232
- */
1233
- name: string;
1234
- /**
1235
- * The absolute path of the module on disk, or `undefined` if this is a
1236
- * virtual module. Used as the source URL for this module, so source maps are
1237
- * correctly resolved.
1238
- *
1239
- * @example
1240
- * '/path/to/src/index.js'
1241
- */
1242
- filePath: string | undefined;
1243
- /**
1244
- * The module content, usually JavaScript or WASM code.
1245
- *
1246
- * @example
1247
- * export default {
1248
- * async fetch(request) {
1249
- * return new Response('Ok')
1250
- * }
1251
- * }
1252
- */
1253
- content: string | Buffer<ArrayBuffer>;
1254
- /**
1255
- * An optional sourcemap for this module if it's of a ESM or CJS type, this will only be present
1256
- * if we're deploying with sourcemaps enabled. Since we copy extra modules that aren't bundled
1257
- * we need to also copy the relevant sourcemaps into the final out directory.
1258
- */
1259
- sourceMap?: CfWorkerSourceMap;
1260
- /**
1261
- * The module type.
1262
- *
1263
- * If absent, will default to the main module's type.
1264
- */
1265
- type?: CfModuleType;
1266
- }
1267
- /**
1268
- * A KV namespace.
1269
- */
1270
- interface CfKvNamespace {
1271
- binding: string;
1272
- id?: string | typeof INHERIT_SYMBOL;
1273
- remote?: boolean;
1274
- raw?: boolean;
1275
- }
1276
- /**
1277
- * A binding to send email.
1278
- */
1279
- type CfSendEmailBindings = {
1280
- name: string;
1281
- remote?: boolean;
1282
- } & ({
1283
- destination_address?: string;
1284
- } | {
1285
- allowed_destination_addresses?: string[];
1286
- } | {
1287
- allowed_sender_addresses?: string[];
1288
- });
1289
- /**
1290
- * A binding to a browser
1291
- */
1292
- interface CfBrowserBinding {
1293
- binding: string;
1294
- raw?: boolean;
1295
- remote?: boolean;
1296
- }
1297
- /**
1298
- * A binding to the AI project
1299
- */
1300
- interface CfAIBinding {
1301
- binding: string;
1302
- staging?: boolean;
1303
- remote?: boolean;
1304
- raw?: boolean;
1305
- }
1306
- /**
1307
- * A binding to Cloudflare Images
1308
- */
1309
- interface CfImagesBinding {
1310
- binding: string;
1311
- raw?: boolean;
1312
- remote?: boolean;
1313
- }
1314
- /**
1315
- * A Durable Object.
1316
- */
1317
- interface CfDurableObject {
1318
- name: string;
1319
- class_name: string;
1320
- script_name?: string;
1321
- environment?: string;
1322
- }
1323
- interface CfWorkflow {
1324
- name: string;
1325
- class_name: string;
1326
- binding: string;
1327
- script_name?: string;
1328
- remote?: boolean;
1329
- raw?: boolean;
1330
- }
1331
- interface CfQueue {
1332
- binding: string;
1333
- queue_name: string;
1334
- delivery_delay?: number;
1335
- remote?: boolean;
1336
- raw?: boolean;
1337
- }
1338
- interface CfR2Bucket {
1339
- binding: string;
1340
- bucket_name?: string | typeof INHERIT_SYMBOL;
1341
- jurisdiction?: string;
1342
- remote?: boolean;
1343
- raw?: boolean;
1344
- }
1345
- interface CfD1Database {
1346
- binding: string;
1347
- database_id?: string | typeof INHERIT_SYMBOL;
1348
- database_name?: string;
1349
- preview_database_id?: string;
1350
- database_internal_env?: string;
1351
- migrations_table?: string;
1352
- migrations_dir?: string;
1353
- remote?: boolean;
1354
- raw?: boolean;
1355
- }
1356
- interface CfVectorize {
1357
- binding: string;
1358
- index_name: string;
1359
- raw?: boolean;
1360
- remote?: boolean;
1361
- }
1362
- interface CfSecretsStoreSecrets {
1363
- binding: string;
1364
- store_id: string;
1365
- secret_name: string;
1366
- }
1367
- interface CfHelloWorld {
1368
- binding: string;
1369
- enable_timer?: boolean;
1370
- }
1371
- interface CfWorkerLoader {
1372
- binding: string;
1373
- }
1374
- interface CfRateLimit {
1375
- name: string;
1376
- namespace_id: string;
1377
- simple: {
1378
- limit: number;
1379
- period: 10 | 60;
1380
- };
1381
- }
1382
- interface CfHyperdrive {
1383
- binding: string;
1384
- id: string;
1385
- localConnectionString?: string;
1386
- }
1387
- interface CfService {
1388
- binding: string;
1389
- service: string;
1390
- environment?: string;
1391
- entrypoint?: string;
1392
- props?: Record<string, unknown>;
1393
- remote?: boolean;
1394
- }
1395
- interface CfVpcService {
1396
- binding: string;
1397
- service_id: string;
1398
- remote?: boolean;
1399
- }
1400
- interface CfAnalyticsEngineDataset {
1401
- binding: string;
1402
- dataset?: string;
1403
- }
1404
- interface CfDispatchNamespace {
1405
- binding: string;
1406
- namespace: string;
1407
- outbound?: {
1408
- service: string;
1409
- environment?: string;
1410
- parameters?: string[];
1411
- };
1412
- remote?: boolean;
1413
- }
1414
- interface CfMTlsCertificate {
1415
- binding: string;
1416
- certificate_id: string;
1417
- remote?: boolean;
1418
- }
1419
- interface CfLogfwdrBinding {
1420
- name: string;
1421
- destination: string;
1422
- }
1423
- interface CfPipeline {
1424
- binding: string;
1425
- pipeline: string;
1426
- remote?: boolean;
1427
- }
1428
- interface CfUnsafeBinding {
1429
- name: string;
1430
- type: string;
1431
- dev?: {
1432
- plugin: {
1433
- /**
1434
- * Package is the bare specifier of the package that exposes plugins to integrate into Miniflare via a named `plugins` export.
1435
- * @example "@cloudflare/my-external-miniflare-plugin"
1436
- */
1437
- package: string;
1438
- /**
1439
- * Plugin is the name of the plugin exposed by the package.
1440
- * @example "my-unsafe-plugin"
1441
- */
1442
- name: string;
1443
- };
1444
- /**
1445
- * dev-only options to pass to the plugin.
1446
- */
1447
- options?: Record<string, unknown>;
1448
- };
1449
- }
1450
- type CfUnsafeMetadata = Record<string, unknown>;
1451
- type CfCapnp = {
1452
- base_path?: never;
1453
- source_schemas?: never;
1454
- compiled_schema: string;
1455
- } | {
1456
- base_path: string;
1457
- source_schemas: string[];
1458
- compiled_schema?: never;
1459
- };
1460
- interface CfUnsafe {
1461
- bindings: CfUnsafeBinding[] | undefined;
1462
- metadata: CfUnsafeMetadata | undefined;
1463
- capnp: CfCapnp | undefined;
1464
- }
1465
- interface CfTailConsumer {
1466
- service: string;
1467
- environment?: string;
1468
- }
1469
- interface CfWorkerSourceMap {
1470
- /**
1471
- * The name of the source map.
1472
- *
1473
- * @example
1474
- * 'out.js.map'
1475
- */
1476
- name: string;
1477
- /**
1478
- * The content of the source map, which is a JSON object described by the v3
1479
- * spec.
1480
- *
1481
- * @example
1482
- * {
1483
- * "version" : 3,
1484
- * "file": "out.js",
1485
- * "sourceRoot": "",
1486
- * "sources": ["foo.js", "bar.js"],
1487
- * "sourcesContent": [null, null],
1488
- * "names": ["src", "maps", "are", "fun"],
1489
- * "mappings": "A,AAAB;;ABCDE;"
1490
- * }
1491
- */
1492
- content: string | Buffer;
1493
- }
1494
-
1495
- /**
1496
- * This is the static type definition for the configuration object.
1497
- *
1498
- * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,
1499
- * and optionally augment with arguments passed directly to wrangler.
1500
- *
1501
- * For more information about the configuration object, see the
1502
- * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
1503
- *
1504
- * Notes:
1505
- *
1506
- * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
1507
- * in the top level config and should not appear in any environments.
1508
- * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects
1509
- * - All top level fields in config and environments are optional in the Wrangler configuration file.
1510
- *
1511
- * Legend for the annotations:
1512
- *
1513
- * - `@breaking`: the deprecation/optionality is a breaking change from Wrangler v1.
1514
- * - `@todo`: there's more work to be done (with details attached).
1515
- */
1516
- type Config = ComputedFields & ConfigFields<DevConfig> & PagesConfigFields & Environment;
1517
- type RawConfig = Partial<ConfigFields<RawDevConfig>> & PagesConfigFields & RawEnvironment & EnvironmentMap & {
1518
- $schema?: string;
1519
- };
1520
- interface ComputedFields {
1521
- /** The path to the Wrangler configuration file (if any, and possibly redirected from the user Wrangler configuration) used to create this configuration. */
1522
- configPath: string | undefined;
1523
- /** The path to the user's Wrangler configuration file (if any), which may have been redirected to another file that used to create this configuration. */
1524
- userConfigPath: string | undefined;
1525
- /**
1526
- * The original top level name for the Worker in the raw configuration.
1527
- *
1528
- * When a raw configuration has been flattened to a single environment the worker name may have been replaced or transformed.
1529
- * It can be useful to know what the top-level name was before the flattening.
1530
- */
1531
- topLevelName: string | undefined;
1532
- /** A list of environment names declared in the raw configuration. */
1533
- definedEnvironments: string[] | undefined;
1534
- /** The name of the environment being targeted. */
1535
- targetEnvironment: string | undefined;
1536
- }
1537
- interface ConfigFields<Dev extends RawDevConfig> {
1538
- /**
1539
- * A boolean to enable "legacy" style wrangler environments (from Wrangler v1).
1540
- * These have been superseded by Services, but there may be projects that won't
1541
- * (or can't) use them. If you're using a legacy environment, you can set this
1542
- * to `true` to enable it.
1543
- */
1544
- legacy_env: boolean;
1545
- /**
1546
- * Whether Wrangler should send usage metrics to Cloudflare for this project.
1547
- *
1548
- * When defined this will override any user settings.
1549
- * Otherwise, Wrangler will use the user's preference.
1550
- */
1551
- send_metrics: boolean | undefined;
1552
- /**
1553
- * Options to configure the development server that your worker will use.
1554
- *
1555
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#local-development-settings
1556
- */
1557
- dev: Dev;
1558
- /**
1559
- * The definition of a Worker Site, a feature that lets you upload
1560
- * static assets with your Worker.
1561
- *
1562
- * More details at https://developers.cloudflare.com/workers/platform/sites
1563
- *
1564
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-sites
1565
- */
1566
- site: {
1567
- /**
1568
- * The directory containing your static assets.
1569
- *
1570
- * It must be a path relative to your Wrangler configuration file.
1571
- * Example: bucket = "./public"
1572
- *
1573
- * If there is a `site` field then it must contain this `bucket` field.
1574
- */
1575
- bucket: string;
1576
- /**
1577
- * The location of your Worker script.
1578
- *
1579
- * @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.
1580
- * @breaking
1581
- */
1582
- "entry-point"?: string;
1583
- /**
1584
- * An exclusive list of .gitignore-style patterns that match file
1585
- * or directory names from your bucket location. Only matched
1586
- * items will be uploaded. Example: include = ["upload_dir"]
1587
- *
1588
- * @optional
1589
- * @default []
1590
- */
1591
- include?: string[];
1592
- /**
1593
- * A list of .gitignore-style patterns that match files or
1594
- * directories in your bucket that should be excluded from
1595
- * uploads. Example: exclude = ["ignore_dir"]
1596
- *
1597
- * @optional
1598
- * @default []
1599
- */
1600
- exclude?: string[];
1601
- } | undefined;
1602
- /**
1603
- * A list of wasm modules that your worker should be bound to. This is
1604
- * the "legacy" way of binding to a wasm module. ES module workers should
1605
- * do proper module imports.
1606
- */
1607
- wasm_modules: {
1608
- [key: string]: string;
1609
- } | undefined;
1610
- /**
1611
- * A list of text files that your worker should be bound to. This is
1612
- * the "legacy" way of binding to a text file. ES module workers should
1613
- * do proper module imports.
1614
- */
1615
- text_blobs: {
1616
- [key: string]: string;
1617
- } | undefined;
1618
- /**
1619
- * A list of data files that your worker should be bound to. This is
1620
- * the "legacy" way of binding to a data file. ES module workers should
1621
- * do proper module imports.
1622
- */
1623
- data_blobs: {
1624
- [key: string]: string;
1625
- } | undefined;
1626
- /**
1627
- * A map of module aliases. Lets you swap out a module for any others.
1628
- * Corresponds with esbuild's `alias` config
1629
- *
1630
- * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#module-aliasing
1631
- */
1632
- alias: {
1633
- [key: string]: string;
1634
- } | undefined;
1635
- /**
1636
- * By default, the Wrangler configuration file is the source of truth for your environment configuration, like a terraform file.
1637
- *
1638
- * If you change your vars in the dashboard, wrangler *will* override/delete them on its next deploy.
1639
- *
1640
- * If you want to keep your dashboard vars when wrangler deploys, set this field to true.
1641
- *
1642
- * @default false
1643
- * @nonInheritable
1644
- */
1645
- keep_vars?: boolean;
1646
- }
1647
- interface PagesConfigFields {
1648
- /**
1649
- * The directory of static assets to serve.
1650
- *
1651
- * The presence of this field in a Wrangler configuration file indicates a Pages project,
1652
- * and will prompt the handling of the configuration file according to the
1653
- * Pages-specific validation rules.
1654
- */
1655
- pages_build_output_dir?: string;
1656
- }
1657
- interface DevConfig {
1658
- /**
1659
- * IP address for the local dev server to listen on,
1660
- *
1661
- * @default localhost
1662
- */
1663
- ip: string;
1664
- /**
1665
- * Port for the local dev server to listen on
1666
- *
1667
- * @default 8787
1668
- */
1669
- port: number | undefined;
1670
- /**
1671
- * Port for the local dev server's inspector to listen on
1672
- *
1673
- * @default 9229
1674
- */
1675
- inspector_port: number | undefined;
1676
- /**
1677
- * Protocol that local wrangler dev server listens to requests on.
1678
- *
1679
- * @default http
1680
- */
1681
- local_protocol: "http" | "https";
1682
- /**
1683
- * Protocol that wrangler dev forwards requests on
1684
- *
1685
- * Setting this to `http` is not currently implemented for remote mode.
1686
- * See https://github.com/cloudflare/workers-sdk/issues/583
1687
- *
1688
- * @default https
1689
- */
1690
- upstream_protocol: "https" | "http";
1691
- /**
1692
- * Host to forward requests to, defaults to the host of the first route of project
1693
- */
1694
- host: string | undefined;
1695
- /**
1696
- * When developing, whether to build and connect to containers. This requires a Docker daemon to be running.
1697
- * Defaults to `true`.
1698
- *
1699
- * @default true
1700
- */
1701
- enable_containers: boolean;
1702
- /**
1703
- * Either the Docker unix socket i.e. `unix:///var/run/docker.sock` or a full configuration.
1704
- * Note that windows is only supported via WSL at the moment
1705
- */
1706
- container_engine: ContainerEngine | undefined;
1707
- }
1708
- type RawDevConfig = Partial<DevConfig>;
1709
- interface EnvironmentMap {
1710
- /**
1711
- * The `env` section defines overrides for the configuration for different environments.
1712
- *
1713
- * All environment fields can be specified at the top level of the config indicating the default environment settings.
1714
- *
1715
- * - Some fields are inherited and overridable in each environment.
1716
- * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
1717
- *
1718
- * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
1719
- *
1720
- * @default {}
1721
- */
1722
- env?: {
1723
- [envName: string]: RawEnvironment;
1724
- };
1725
- }
1726
- type OnlyCamelCase<T = Record<string, never>> = {
1727
- [key in keyof T as CamelCaseKey<key>]: T[key];
1728
- };
1729
-
1730
- /**
1731
- * Yargs options included in every wrangler command.
1732
- */
1733
- interface CommonYargsOptions {
1734
- v: boolean | undefined;
1735
- cwd: string | undefined;
1736
- config: string | undefined;
1737
- env: string | undefined;
1738
- "env-file": string[] | undefined;
1739
- "experimental-provision": boolean | undefined;
1740
- "experimental-remote-bindings": boolean | undefined;
1741
- }
1742
- type CommonYargsArgv = Argv<CommonYargsOptions>;
1743
- type RemoveIndex<T> = {
1744
- [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
1745
- };
1746
-
1747
- type ResolveConfigPathOptions = {
1748
- useRedirectIfAvailable?: boolean;
1749
- };
1750
-
1751
- type NormalizeAndValidateConfigArgs = {
1752
- name?: string;
1753
- env?: string;
1754
- "legacy-env"?: boolean;
1755
- "dispatch-namespace"?: string;
1756
- remote?: boolean;
1757
- localProtocol?: string;
1758
- upstreamProtocol?: string;
1759
- script?: string;
1760
- enableContainers?: boolean;
1761
- };
1762
-
1763
- type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & {
1764
- config?: string;
1765
- script?: string;
1766
- };
1767
- type ReadConfigOptions = ResolveConfigPathOptions & {
1768
- hideWarnings?: boolean;
1769
- preserveOriginalMain?: boolean;
1770
- };
1771
- type ConfigBindingOptions = Pick<Config, "ai" | "browser" | "d1_databases" | "dispatch_namespaces" | "durable_objects" | "queues" | "r2_buckets" | "services" | "kv_namespaces" | "mtls_certificates" | "vectorize" | "workflows" | "vpc_services">;
1772
- /**
1773
- * Get the Wrangler configuration; read it from the give `configPath` if available.
1774
- */
1775
- declare function readConfig(args: ReadConfigCommandArgs, options?: ReadConfigOptions): Config;
1776
- declare const experimental_readRawConfig: (args: ReadConfigCommandArgs, options?: ReadConfigOptions) => {
1777
- rawConfig: RawConfig;
1778
- configPath: string | undefined;
1779
- userConfigPath: string | undefined;
1780
- };
8
+ import Protocol from 'devtools-protocol/types/protocol-mapping';
9
+ import { EventEmitter } from 'node:events';
10
+ import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
11
+ import { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
12
+ import { URLSearchParams } from 'node:url';
13
+ import { Argv, PositionalOptions, Options, ArgumentsCamelCase, InferredOptionTypes, InferredOptionType } from 'yargs';
14
+ import Cloudflare from 'cloudflare';
1781
15
 
1782
16
  interface EnablePagesAssetsServiceBindingOptions {
1783
17
  proxyPort?: number;
@@ -1856,8 +90,6 @@ interface Unstable_DevOptions {
1856
90
  watch?: boolean;
1857
91
  devEnv?: boolean;
1858
92
  fileBasedRegistry?: boolean;
1859
- vectorizeBindToProd?: boolean;
1860
- imagesLocalMode?: boolean;
1861
93
  enableIpc?: boolean;
1862
94
  enableContainers?: boolean;
1863
95
  dockerPath?: string;
@@ -1954,22 +186,22 @@ declare function deploy({ directory, accountId, projectName, branch, skipCaching
1954
186
  project_id: string;
1955
187
  project_name: string;
1956
188
  deployment_trigger: {
189
+ type: string;
1957
190
  metadata: {
1958
191
  branch: string;
1959
192
  commit_hash: string;
1960
193
  commit_message: string;
1961
194
  };
1962
- type: string;
1963
195
  };
1964
196
  latest_stage: {
1965
- name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
1966
197
  status: "canceled" | "active" | "idle" | "success" | "failure" | "skipped";
198
+ name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
1967
199
  started_on: string | null;
1968
200
  ended_on: string | null;
1969
201
  };
1970
202
  stages: {
1971
- name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
1972
203
  status: "canceled" | "active" | "idle" | "success" | "failure" | "skipped";
204
+ name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
1973
205
  started_on: string | null;
1974
206
  ended_on: string | null;
1975
207
  }[];
@@ -1987,7 +219,7 @@ declare function deploy({ directory, accountId, projectName, branch, skipCaching
1987
219
  pr_comments_enabled?: boolean | undefined;
1988
220
  deployments_enabled?: boolean | undefined;
1989
221
  production_deployments_enabled?: boolean | undefined;
1990
- preview_deployment_setting?: "none" | "custom" | "all" | undefined;
222
+ preview_deployment_setting?: "custom" | "none" | "all" | undefined;
1991
223
  preview_branch_includes?: string[] | undefined;
1992
224
  preview_branch_excludes?: string[] | undefined;
1993
225
  };
@@ -2006,11 +238,6 @@ declare const unstable_pages: {
2006
238
  deploy: typeof deploy;
2007
239
  };
2008
240
 
2009
- /**
2010
- * The compliance region to use for the API requests.
2011
- */
2012
- type ComplianceConfig = Partial<Pick<Config, "compliance_region">>;
2013
-
2014
241
  type _Params<ParamsArray extends [unknown?]> = ParamsArray extends [infer P] ? P : undefined;
2015
242
  type _EventMethods = keyof Protocol.Events;
2016
243
  type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
@@ -2018,29 +245,6 @@ type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
2018
245
  params: _Params<Protocol.Events[Method]>;
2019
246
  } : never;
2020
247
 
2021
- /**
2022
- * This is used to provide telemetry with a sanitised error
2023
- * message that could not have any user-identifying information.
2024
- * Set to `true` to duplicate `message`.
2025
- * */
2026
- type TelemetryMessage = {
2027
- telemetryMessage?: string | true;
2028
- };
2029
- /**
2030
- * Base class for errors where the user has done something wrong. These are not
2031
- * reported to Sentry. API errors are intentionally *not* `UserError`s, and are
2032
- * reported to Sentry. This will help us understand which API errors need better
2033
- * messaging.
2034
- */
2035
- declare class UserError extends Error {
2036
- telemetryMessage: string | undefined;
2037
- constructor(message?: string | undefined, options?: (ErrorOptions & TelemetryMessage) | undefined);
2038
- }
2039
- declare class FatalError extends UserError {
2040
- readonly code?: number | undefined;
2041
- constructor(message?: string, code?: number | undefined, options?: TelemetryMessage);
2042
- }
2043
-
2044
248
  type AssetsOptions = {
2045
249
  directory: string;
2046
250
  binding?: string;
@@ -2119,10 +323,7 @@ interface CfAccount {
2119
323
  accountId: string;
2120
324
  }
2121
325
 
2122
- type ConfigControllerEventMap = ControllerEventMap & {
2123
- configUpdate: [ConfigUpdateEvent];
2124
- };
2125
- declare class ConfigController extends Controller<ConfigControllerEventMap> {
326
+ declare class ConfigController extends Controller {
2126
327
  #private;
2127
328
  latestInput?: StartDevWorkerInput;
2128
329
  latestConfig?: StartDevWorkerOptions;
@@ -2163,6 +364,11 @@ interface StartDevWorkerInput {
2163
364
  compatibilityFlags?: string[];
2164
365
  /** Specify the compliance region mode of the Worker. */
2165
366
  complianceRegion?: Config["compliance_region"];
367
+ /** Configuration for Python modules. */
368
+ pythonModules?: {
369
+ /** A list of glob patterns to exclude files from the python_modules directory when bundling. */
370
+ exclude?: string[];
371
+ };
2166
372
  env?: string;
2167
373
  /**
2168
374
  * An array of paths to the .env files to load for this worker, relative to the project directory.
@@ -2178,6 +384,7 @@ interface StartDevWorkerInput {
2178
384
  /** The triggers which will cause the worker's exported default handlers to be called. */
2179
385
  triggers?: Trigger[];
2180
386
  tailConsumers?: CfTailConsumer[];
387
+ streamingTailConsumers?: CfTailConsumer[];
2181
388
  /**
2182
389
  * Whether Wrangler should send usage metrics to Cloudflare for this project.
2183
390
  *
@@ -2225,7 +432,11 @@ interface StartDevWorkerInput {
2225
432
  port?: number;
2226
433
  secure?: boolean;
2227
434
  } | false;
2228
- /** Whether the worker runs on the edge or locally. Can also be set to "minimal" for minimal mode. */
435
+ /** Whether the worker runs on the edge or locally. This has several options:
436
+ * - true | "minimal": Run your Worker's code & bindings in a remote preview session, optionally using minimal mode as an internal detail
437
+ * - false: Run your Worker's code & bindings in a local simulator
438
+ * - undefined (default): Run your Worker's code locally, and any configured remote bindings remotely
439
+ */
2229
440
  remote?: boolean | "minimal";
2230
441
  /** Cloudflare Account credentials. Can be provided upfront or as a function which will be called only when required. */
2231
442
  auth?: AsyncHook<CfAccount, [Pick<Config, "account_id">]>;
@@ -2255,14 +466,8 @@ interface StartDevWorkerInput {
2255
466
  /** An undici MockAgent to declaratively mock fetch calls to particular resources. */
2256
467
  mockFetch?: undici.MockAgent;
2257
468
  testScheduled?: boolean;
2258
- /** Whether to use Vectorize as a remote binding -- the worker is run locally but accesses to Vectorize are made remotely */
2259
- bindVectorizeToProd?: boolean;
2260
- /** Whether to use Images local mode -- this is lower fidelity, but doesn't require network access */
2261
- imagesLocalMode?: boolean;
2262
469
  /** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
2263
470
  multiworkerPrimary?: boolean;
2264
- /** Whether the experimental remote bindings feature should be enabled */
2265
- experimentalRemoteBindings?: boolean;
2266
471
  containerBuildId?: string;
2267
472
  /** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */
2268
473
  enableContainers?: boolean;
@@ -2275,10 +480,13 @@ interface StartDevWorkerInput {
2275
480
  };
2276
481
  legacy?: {
2277
482
  site?: Hook<Config["site"], [Config]>;
2278
- enableServiceEnvironments?: boolean;
483
+ useServiceEnvironments?: boolean;
2279
484
  };
2280
485
  unsafe?: Omit<CfUnsafe, "bindings">;
2281
486
  assets?: string;
487
+ experimental?: {
488
+ tailLogs: boolean;
489
+ };
2282
490
  }
2283
491
  type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "containers"> & {
2284
492
  /** A worker's directory. Usually where the Wrangler configuration file is located */
@@ -2404,7 +612,9 @@ type Binding = {
2404
612
  type: "worker_loader";
2405
613
  } & BindingOmit<CfWorkerLoader>) | ({
2406
614
  type: "vpc_service";
2407
- } & BindingOmit<CfVpcService>) | {
615
+ } & BindingOmit<CfVpcService>) | ({
616
+ type: "media";
617
+ } & BindingOmit<CfMediaBinding>) | {
2408
618
  type: `unsafe_${string}`;
2409
619
  } | {
2410
620
  type: "assets";
@@ -2517,48 +727,27 @@ type ProxyData = {
2517
727
  proxyLogsToController?: boolean;
2518
728
  };
2519
729
 
2520
- interface TypedEventEmitter<EventMap extends Record<string | symbol, unknown[]>> extends EventEmitter {
2521
- addListener<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2522
- on<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2523
- once<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2524
- removeListener<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2525
- off<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2526
- removeAllListeners(event?: keyof EventMap): this;
2527
- listeners<Name extends keyof EventMap>(eventName: Name): ((...args: EventMap[Name]) => void)[];
2528
- rawListeners<Name extends keyof EventMap>(eventName: Name): ((...args: EventMap[Name]) => void)[];
2529
- emit<Name extends keyof EventMap>(eventName: Name, ...args: EventMap[Name]): boolean;
2530
- listenerCount<Name extends keyof EventMap>(eventName: Name, listener?: (...args: EventMap[Name]) => void): number;
2531
- prependListener<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
2532
- prependOnceListener<Name extends keyof EventMap>(eventName: Name, listener: (...args: EventMap[Name]) => void): this;
730
+ type ControllerEvent = ErrorEvent | ConfigUpdateEvent | BundleStartEvent | BundleCompleteEvent | ReloadStartEvent | ReloadCompleteEvent | DevRegistryUpdateEvent | PreviewTokenExpiredEvent;
731
+ interface ControllerBus {
732
+ dispatch(event: ControllerEvent): void;
2533
733
  }
2534
- declare const TypedEventEmitterImpl: {
2535
- new <EventMap extends Record<string | symbol, unknown[]>>(): TypedEventEmitter<EventMap>;
2536
- };
2537
- type ControllerEventMap = {
2538
- error: [ErrorEvent];
2539
- };
2540
- declare abstract class Controller<EventMap extends ControllerEventMap = ControllerEventMap> extends TypedEventEmitterImpl<EventMap> {
2541
- emitErrorEvent(data: ErrorEvent): void;
734
+ declare abstract class Controller {
735
+ #private;
736
+ protected bus: ControllerBus;
737
+ constructor(bus: ControllerBus);
738
+ teardown(): Promise<void>;
739
+ protected emitErrorEvent(event: ErrorEvent): void;
2542
740
  }
2543
- type RuntimeControllerEventMap = ControllerEventMap & {
2544
- reloadStart: [ReloadStartEvent];
2545
- reloadComplete: [ReloadCompleteEvent];
2546
- devRegistryUpdate: [DevRegistryUpdateEvent];
2547
- };
2548
- declare abstract class RuntimeController extends Controller<RuntimeControllerEventMap> {
741
+ declare abstract class RuntimeController extends Controller {
2549
742
  abstract onBundleStart(_: BundleStartEvent): void;
2550
743
  abstract onBundleComplete(_: BundleCompleteEvent): void;
2551
744
  abstract onPreviewTokenExpired(_: PreviewTokenExpiredEvent): void;
2552
- abstract teardown(): Promise<void>;
2553
- abstract emitReloadStartEvent(data: ReloadStartEvent): void;
2554
- abstract emitReloadCompleteEvent(data: ReloadCompleteEvent): void;
745
+ protected emitReloadStartEvent(data: ReloadStartEvent): void;
746
+ protected emitReloadCompleteEvent(data: ReloadCompleteEvent): void;
747
+ protected emitDevRegistryUpdateEvent(data: DevRegistryUpdateEvent): void;
2555
748
  }
2556
749
 
2557
- type BundlerControllerEventMap = ControllerEventMap & {
2558
- bundleStart: [BundleStartEvent];
2559
- bundleComplete: [BundleCompleteEvent];
2560
- };
2561
- declare class BundlerController extends Controller<BundlerControllerEventMap> {
750
+ declare class BundlerController extends Controller {
2562
751
  #private;
2563
752
  onConfigUpdate(event: ConfigUpdateEvent): void;
2564
753
  teardown(): Promise<void>;
@@ -2574,11 +763,7 @@ type DeferredPromise<T> = {
2574
763
  };
2575
764
  declare function convertConfigBindingsToStartWorkerBindings(configBindings: ConfigBindingOptions): StartDevWorkerOptions["bindings"];
2576
765
 
2577
- type ProxyControllerEventMap = ControllerEventMap & {
2578
- ready: [ReadyEvent];
2579
- previewTokenExpired: [PreviewTokenExpiredEvent];
2580
- };
2581
- declare class ProxyController extends Controller<ProxyControllerEventMap> {
766
+ declare class ProxyController extends Controller {
2582
767
  ready: DeferredPromise<ReadyEvent>;
2583
768
  localServerReady: DeferredPromise<void>;
2584
769
  proxyWorker?: Miniflare;
@@ -2592,6 +777,7 @@ declare class ProxyController extends Controller<ProxyControllerEventMap> {
2592
777
  runtimeMessageMutex: Mutex;
2593
778
  sendMessageToProxyWorker(message: ProxyWorkerIncomingRequestBody, retries?: number): Promise<void>;
2594
779
  sendMessageToInspectorProxyWorker(message: InspectorProxyWorkerIncomingWebSocketMessage, retries?: number): Promise<void>;
780
+ get inspectorEnabled(): boolean;
2595
781
  onConfigUpdate(data: ConfigUpdateEvent): void;
2596
782
  onBundleStart(data: BundleStartEvent): void;
2597
783
  onReloadStart(data: ReloadStartEvent): void;
@@ -2607,24 +793,55 @@ declare class ProxyController extends Controller<ProxyControllerEventMap> {
2607
793
  emitErrorEvent(reason: string, cause?: Error | SerializedError): void;
2608
794
  }
2609
795
 
2610
- declare class DevEnv extends EventEmitter {
796
+ type ControllerFactory<C extends Controller> = (devEnv: DevEnv) => C;
797
+ declare class DevEnv extends EventEmitter implements ControllerBus {
2611
798
  config: ConfigController;
2612
799
  bundler: BundlerController;
2613
800
  runtimes: RuntimeController[];
2614
801
  proxy: ProxyController;
2615
802
  startWorker(options: StartDevWorkerInput): Promise<Worker>;
2616
- constructor({ config, bundler, runtimes, proxy, }?: {
2617
- config?: ConfigController | undefined;
2618
- bundler?: BundlerController | undefined;
2619
- runtimes?: RuntimeController[] | undefined;
2620
- proxy?: ProxyController | undefined;
803
+ constructor({ configFactory, bundlerFactory, runtimeFactories, proxyFactory, }?: {
804
+ configFactory?: ControllerFactory<ConfigController>;
805
+ bundlerFactory?: ControllerFactory<BundlerController>;
806
+ runtimeFactories?: ControllerFactory<RuntimeController>[];
807
+ proxyFactory?: ControllerFactory<ProxyController>;
2621
808
  });
809
+ /**
810
+ * Central message bus dispatch method.
811
+ * All events from controllers flow through here, making the event routing explicit and traceable.
812
+ *
813
+ * Event flow:
814
+ * - ConfigController emits configUpdate → BundlerController, ProxyController
815
+ * - BundlerController emits bundleStart → ProxyController, RuntimeControllers
816
+ * - BundlerController emits bundleComplete → RuntimeControllers
817
+ * - RuntimeController emits reloadStart → ProxyController
818
+ * - RuntimeController emits reloadComplete → ProxyController
819
+ * - RuntimeController emits devRegistryUpdate → ConfigController
820
+ * - ProxyController emits previewTokenExpired → RuntimeControllers
821
+ * - Any controller emits error → DevEnv error handler
822
+ */
823
+ dispatch(event: ControllerEvent): void;
824
+ private handleErrorEvent;
2622
825
  teardown(): Promise<void>;
2623
- emitErrorEvent(ev: ErrorEvent): void;
2624
826
  }
2625
827
 
2626
828
  declare function startWorker(options: StartDevWorkerInput): Promise<Worker>;
2627
829
 
830
+ type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & {
831
+ config?: string;
832
+ script?: string;
833
+ };
834
+ type ReadConfigOptions = ResolveConfigPathOptions & {
835
+ hideWarnings?: boolean;
836
+ preserveOriginalMain?: boolean;
837
+ };
838
+ /**
839
+ * Get the Wrangler configuration; read it from the give `configPath` if available.
840
+ */
841
+ declare function readConfig(args: ReadConfigCommandArgs, options?: ReadConfigOptions): Config;
842
+
843
+ declare function getDurableObjectClassNameToUseSQLiteMap(migrations: Config["migrations"] | undefined): Map<string, boolean>;
844
+
2628
845
  /**
2629
846
  * Note about this file:
2630
847
  *
@@ -2745,12 +962,9 @@ type GetPlatformProxyOptions = {
2745
962
  path: string;
2746
963
  };
2747
964
  /**
2748
- * Experimental flags (note: these can change at any time and are not version-controlled use at your own risk)
965
+ * Whether remote bindings should be enabled or not (defaults to `true`)
2749
966
  */
2750
- experimental?: {
2751
- /** whether access to remove bindings should be enabled */
2752
- remoteBindings?: boolean;
2753
- };
967
+ remoteBindings?: boolean;
2754
968
  };
2755
969
  /**
2756
970
  * Result of the `getPlatformProxy` utility
@@ -2796,9 +1010,7 @@ interface Unstable_MiniflareWorkerOptions {
2796
1010
  externalWorkers: WorkerOptions[];
2797
1011
  }
2798
1012
  declare function unstable_getMiniflareWorkerOptions(configPath: string, env?: string, options?: {
2799
- imagesLocalMode?: boolean;
2800
1013
  remoteProxyConnectionString?: RemoteProxyConnectionString;
2801
- remoteBindingsEnabled?: boolean;
2802
1014
  overrides?: {
2803
1015
  assets?: Partial<AssetsOptions>;
2804
1016
  enableContainers?: boolean;
@@ -2806,9 +1018,7 @@ declare function unstable_getMiniflareWorkerOptions(configPath: string, env?: st
2806
1018
  containerBuildId?: string;
2807
1019
  }): Unstable_MiniflareWorkerOptions;
2808
1020
  declare function unstable_getMiniflareWorkerOptions(config: Config, env?: string, options?: {
2809
- imagesLocalMode?: boolean;
2810
1021
  remoteProxyConnectionString?: RemoteProxyConnectionString;
2811
- remoteBindingsEnabled?: boolean;
2812
1022
  overrides?: {
2813
1023
  assets?: Partial<AssetsOptions>;
2814
1024
  enableContainers?: boolean;
@@ -2877,8 +1087,8 @@ declare class Logger {
2877
1087
  constructor();
2878
1088
  private overrideLoggerLevel?;
2879
1089
  private onceHistory;
2880
- get loggerLevel(): "none" | "debug" | "error" | "info" | "log" | "warn";
2881
- set loggerLevel(val: "none" | "debug" | "error" | "info" | "log" | "warn");
1090
+ get loggerLevel(): "debug" | "error" | "none" | "info" | "log" | "warn";
1091
+ set loggerLevel(val: "debug" | "error" | "none" | "info" | "log" | "warn");
2882
1092
  resetLoggerLevel(): void;
2883
1093
  columns: number;
2884
1094
  json: (data: unknown) => void;
@@ -2887,7 +1097,8 @@ declare class Logger {
2887
1097
  info: (...args: unknown[]) => void;
2888
1098
  log: (...args: unknown[]) => void;
2889
1099
  warn: (...args: unknown[]) => void;
2890
- error: (...args: unknown[]) => void;
1100
+ error(...args: unknown[]): void;
1101
+ error(error: ParseError): void;
2891
1102
  table<Keys extends string>(data: TableRow<Keys>[], options?: {
2892
1103
  wordWrap: boolean;
2893
1104
  head?: Keys[];
@@ -2912,16 +1123,62 @@ declare class Logger {
2912
1123
  */
2913
1124
  declare function splitSqlQuery(sql: string): string[];
2914
1125
 
2915
- declare const experimental_patchConfig: (configPath: string,
2916
- /**
2917
- * if you want to add something new, e.g. a binding, you can just provide that {kv_namespace:[{binding:"KV"}]}
2918
- * and set isArrayInsertion = true
2919
- *
2920
- * if you want to edit or delete existing array elements, you have to provide the whole array
2921
- * e.g. {kv_namespace:[{binding:"KV", id:"new-id"}, {binding:"KV2", id:"untouched"}]}
2922
- * and set isArrayInsertion = false
2923
- */
2924
- patch: RawConfig, isArrayInsertion?: boolean) => string;
1126
+ type ConfigurationOptions = {
1127
+ outputDir: string;
1128
+ projectPath: string;
1129
+ workerName: string;
1130
+ dryRun: boolean;
1131
+ };
1132
+ declare abstract class Framework {
1133
+ abstract name: string;
1134
+ preview?: string;
1135
+ deploy?: string;
1136
+ typegen?: string;
1137
+ /** Some frameworks (i.e. Nuxt) don't need additional configuration */
1138
+ get configured(): boolean;
1139
+ abstract configure(options: ConfigurationOptions): Promise<RawConfig> | RawConfig;
1140
+ configurationDescription?: string;
1141
+ }
1142
+
1143
+ type AutoConfigDetails = {
1144
+ /** The name of the worker */
1145
+ workerName: string;
1146
+ /** The path to the project (defaults to cwd) */
1147
+ projectPath: string;
1148
+ /** The content of the project's package.json file (if any) */
1149
+ packageJson?: PackageJSON;
1150
+ /** Whether the project is already configured (no autoconfig required) */
1151
+ configured: boolean;
1152
+ /** Details about the detected framework (if any) */
1153
+ framework?: Framework;
1154
+ /** The build command used to build the project (if any) */
1155
+ buildCommand?: string;
1156
+ /** The output directory (if no framework is used, points to the raw asset files) */
1157
+ outputDir?: string;
1158
+ };
1159
+ type AutoConfigOptions = {
1160
+ /** Whether to run autoconfig without actually applying any filesystem modification (default: false) */
1161
+ dryRun?: boolean;
1162
+ /**
1163
+ * Whether the build command should be run (default: true)
1164
+ *
1165
+ * Note: When `dryRun` is `true` the build command is never run.
1166
+ */
1167
+ runBuild?: boolean;
1168
+ /**
1169
+ * Whether the confirmation prompts should be skipped (default: false)
1170
+ *
1171
+ * Note: When `dryRun` is `true` the the confirmation prompts are always skipped.
1172
+ */
1173
+ skipConfirmations?: boolean;
1174
+ };
1175
+
1176
+ declare function getDetailsForAutoConfig({ projectPath, wranglerConfig, }?: {
1177
+ projectPath?: string;
1178
+ wranglerConfig?: Config;
1179
+ }): Promise<AutoConfigDetails>;
1180
+
1181
+ declare function runAutoConfig(autoConfigDetails: AutoConfigDetails, autoConfigOptions?: AutoConfigOptions): Promise<void>;
2925
1182
 
2926
1183
  /**
2927
1184
  * Make a fetch request, and extract the `result` from the JSON response.
@@ -2931,8 +1188,25 @@ declare function fetchResult<ResponseType>(complianceConfig: ComplianceConfig, r
2931
1188
  type ExperimentalFlags = {
2932
1189
  MULTIWORKER: boolean;
2933
1190
  RESOURCES_PROVISION: boolean;
2934
- REMOTE_BINDINGS: boolean;
2935
1191
  DEPLOY_REMOTE_DIFF_CHECK: boolean;
1192
+ AUTOCREATE_RESOURCES: boolean;
1193
+ };
1194
+
1195
+ /**
1196
+ * Yargs options included in every wrangler command.
1197
+ */
1198
+ interface CommonYargsOptions {
1199
+ v: boolean | undefined;
1200
+ cwd: string | undefined;
1201
+ config: string | undefined;
1202
+ env: string | undefined;
1203
+ "env-file": string[] | undefined;
1204
+ "experimental-provision": boolean | undefined;
1205
+ "experimental-auto-create": boolean;
1206
+ }
1207
+ type CommonYargsArgv = Argv<CommonYargsOptions>;
1208
+ type RemoveIndex<T> = {
1209
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
2936
1210
  };
2937
1211
 
2938
1212
  // Team names from https://wiki.cfdata.org/display/EW/Developer+Platform+Components+and+Pillar+Ownership
@@ -2959,6 +1233,16 @@ type Teams =
2959
1233
  | "Product: SSL"
2960
1234
  | "Product: WVPC";
2961
1235
 
1236
+ /** Convert literal string types like 'foo-bar' to 'FooBar' */
1237
+ type PascalCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${Capitalize<T>}${PascalCase<U>}` : Capitalize<S>;
1238
+ /** Convert literal string types like 'foo-bar' to 'fooBar' */
1239
+ type CamelCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${T}${PascalCase<U>}` : S;
1240
+ type CamelCaseKey<K extends PropertyKey> = K extends string ? Exclude<CamelCase<K>, ""> : K;
1241
+ type Alias<O extends Options | PositionalOptions> = O extends {
1242
+ alias: infer T;
1243
+ } ? T extends Exclude<string, T> ? {
1244
+ [key in T]: InferredOptionType<O>;
1245
+ } : {} : {};
2962
1246
  type StringKeyOf<T> = Extract<keyof T, string>;
2963
1247
  type DeepFlatten<T> = T extends object ? {
2964
1248
  [K in keyof T]: DeepFlatten<T[K]>;
@@ -2984,6 +1268,9 @@ type ArgDefinition = Omit<PositionalOptions, "type"> & Pick<Options, "hidden" |
2984
1268
  type NamedArgDefinitions = {
2985
1269
  [key: string]: ArgDefinition;
2986
1270
  };
1271
+ type OnlyCamelCase<T = Record<string, never>> = {
1272
+ [key in keyof T as CamelCaseKey<key>]: T[key];
1273
+ };
2987
1274
  type HandlerArgs<Args extends NamedArgDefinitions> = DeepFlatten<OnlyCamelCase<RemoveIndex<ArgumentsCamelCase<CommonYargsOptions & InferredOptionTypes<Args> & Alias<Args>>>>>;
2988
1275
  type HandlerContext = {
2989
1276
  /**
@@ -3053,7 +1340,7 @@ type CommandDefinition<NamedArgDefs extends NamedArgDefinitions = NamedArgDefini
3053
1340
  /**
3054
1341
  * If true, print a message about whether the command is operating on a local or remote resource
3055
1342
  */
3056
- printResourceLocation?: ((args?: HandlerArgs<NamedArgDefs>) => boolean) | boolean;
1343
+ printResourceLocation?: ((args: HandlerArgs<NamedArgDefs>) => boolean) | boolean;
3057
1344
  /**
3058
1345
  * If true, check for environments in the wrangler config, if there are some and the user hasn't specified an environment
3059
1346
  * using the `-e|--env` cli flag, show a warning suggesting that one should instead be specified.
@@ -3176,19 +1463,20 @@ declare function createCLIParser(argv: string[]): {
3176
1463
  readonly array: true;
3177
1464
  readonly requiresArg: true;
3178
1465
  };
3179
- readonly "experimental-remote-bindings": {
3180
- readonly describe: "Experimental: Enable Remote Bindings";
3181
- readonly type: "boolean";
3182
- readonly hidden: true;
3183
- readonly default: true;
3184
- readonly alias: readonly ["x-remote-bindings"];
3185
- };
3186
1466
  readonly "experimental-provision": {
3187
1467
  readonly describe: "Experimental: Enable automatic resource provisioning";
3188
1468
  readonly type: "boolean";
1469
+ readonly default: true;
3189
1470
  readonly hidden: true;
3190
1471
  readonly alias: readonly ["x-provision"];
3191
1472
  };
1473
+ readonly "experimental-auto-create": {
1474
+ readonly describe: "Automatically provision draft bindings with new resources";
1475
+ readonly type: "boolean";
1476
+ readonly default: true;
1477
+ readonly hidden: true;
1478
+ readonly alias: "x-auto-create";
1479
+ };
3192
1480
  };
3193
1481
  };
3194
1482
 
@@ -3210,4 +1498,4 @@ interface Unstable_ASSETSBindingsOptions {
3210
1498
  }
3211
1499
  declare const generateASSETSBinding: (opts: Unstable_ASSETSBindingsOptions) => (request: Request) => Promise<Response$1>;
3212
1500
 
3213
- export { type Binding, type ConfigBindingOptions as Experimental_ConfigBindingOptions, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type Unstable_ASSETSBindingsOptions, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, experimental_getWranglerCommands, experimental_patchConfig, experimental_readRawConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, generateASSETSBinding as unstable_generateASSETSBinding, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, unstable_pages, readConfig as unstable_readConfig, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };
1501
+ export { type Binding, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type Unstable_ASSETSBindingsOptions, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, Framework as experimental_AutoConfigFramework, getDetailsForAutoConfig as experimental_getDetailsForAutoConfig, experimental_getWranglerCommands, runAutoConfig as experimental_runAutoConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, generateASSETSBinding as unstable_generateASSETSBinding, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, unstable_pages, readConfig as unstable_readConfig, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };