@depup/wrangler 4.75.0-depup.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.
Files changed (44) hide show
  1. package/README.md +33 -0
  2. package/bin/wrangler.js +93 -0
  3. package/changes.json +18 -0
  4. package/config-schema.json +3222 -0
  5. package/kv-asset-handler.js +1 -0
  6. package/package.json +221 -0
  7. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  8. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  9. package/templates/__tests__/tsconfig.json +8 -0
  10. package/templates/checked-fetch.js +28 -0
  11. package/templates/facade.d.ts +19 -0
  12. package/templates/middleware/common.ts +67 -0
  13. package/templates/middleware/loader-modules.ts +134 -0
  14. package/templates/middleware/loader-sw.ts +229 -0
  15. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  16. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  17. package/templates/middleware/middleware-patch-console-prefix.d.ts +3 -0
  18. package/templates/middleware/middleware-patch-console-prefix.ts +21 -0
  19. package/templates/middleware/middleware-pretty-error.ts +40 -0
  20. package/templates/middleware/middleware-scheduled.ts +29 -0
  21. package/templates/modules-watch-stub.js +4 -0
  22. package/templates/new-worker-scheduled.js +17 -0
  23. package/templates/new-worker-scheduled.ts +32 -0
  24. package/templates/new-worker.js +15 -0
  25. package/templates/new-worker.ts +33 -0
  26. package/templates/no-op-worker.js +10 -0
  27. package/templates/pages-dev-pipeline.ts +33 -0
  28. package/templates/pages-dev-util.ts +55 -0
  29. package/templates/pages-shim.ts +9 -0
  30. package/templates/pages-template-plugin.ts +190 -0
  31. package/templates/pages-template-worker.ts +198 -0
  32. package/templates/remoteBindings/ProxyServerWorker.ts +143 -0
  33. package/templates/remoteBindings/wrangler.jsonc +4 -0
  34. package/templates/startDevWorker/InspectorProxyWorker.ts +699 -0
  35. package/templates/startDevWorker/ProxyWorker.ts +340 -0
  36. package/templates/tsconfig-sanity.ts +11 -0
  37. package/templates/tsconfig.init.json +22 -0
  38. package/templates/tsconfig.json +14 -0
  39. package/wrangler-dist/InspectorProxyWorker.js +486 -0
  40. package/wrangler-dist/ProxyServerWorker.js +3314 -0
  41. package/wrangler-dist/ProxyWorker.js +238 -0
  42. package/wrangler-dist/cli.d.ts +3154 -0
  43. package/wrangler-dist/cli.js +303399 -0
  44. package/wrangler-dist/metafile-cjs.json +1 -0
@@ -0,0 +1,3154 @@
1
+ import { Rule as Rule$1, CfModule, Environment as Environment$1, CfScriptFormat, CfModuleType, Config as Config$1, Binding, DurableObjectMigration as DurableObjectMigration$1, ContainerApp as ContainerApp$1, Trigger, CfTailConsumer, ServiceFetch, ContainerEngine as ContainerEngine$1, CfUnsafe, ConfigBindingFieldName, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, RawConfig as RawConfig$1, PackageJSON, ParseError, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
2
+ export { Binding, experimental_patchConfig, experimental_readRawConfig, defaultWranglerConfig as unstable_defaultWranglerConfig } from '@cloudflare/workers-utils';
3
+ import { Json as Json$1, WorkerRegistry, Miniflare, MiniflareOptions, Mutex, Response as Response$1, NodeJSCompatMode, DispatchFetch, RemoteProxyConnectionString, WorkerOptions, ModuleRule, Request } from 'miniflare';
4
+ import * as undici from 'undici';
5
+ import { RequestInfo, RequestInit, Response, FormData } from 'undici';
6
+ import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
7
+ import { Metafile } from 'esbuild';
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';
15
+
16
+ interface EnablePagesAssetsServiceBindingOptions {
17
+ proxyPort?: number;
18
+ directory?: string;
19
+ }
20
+
21
+ interface Unstable_DevOptions {
22
+ config?: string;
23
+ env?: string;
24
+ envFiles?: string[];
25
+ ip?: string;
26
+ port?: number;
27
+ bundle?: boolean;
28
+ inspectorPort?: number;
29
+ localProtocol?: "http" | "https";
30
+ httpsKeyPath?: string;
31
+ httpsCertPath?: string;
32
+ assets?: string;
33
+ site?: string;
34
+ siteInclude?: string[];
35
+ siteExclude?: string[];
36
+ compatibilityDate?: string;
37
+ compatibilityFlags?: string[];
38
+ persist?: boolean;
39
+ persistTo?: string;
40
+ vars?: Record<string, string | Json$1>;
41
+ kv?: {
42
+ binding: string;
43
+ id?: string;
44
+ preview_id?: string;
45
+ remote?: boolean;
46
+ }[];
47
+ durableObjects?: {
48
+ name: string;
49
+ class_name: string;
50
+ script_name?: string | undefined;
51
+ environment?: string | undefined;
52
+ }[];
53
+ services?: {
54
+ binding: string;
55
+ service: string;
56
+ environment?: string | undefined;
57
+ entrypoint?: string | undefined;
58
+ remote?: boolean;
59
+ }[];
60
+ r2?: {
61
+ binding: string;
62
+ bucket_name?: string;
63
+ preview_bucket_name?: string;
64
+ remote?: boolean;
65
+ }[];
66
+ ai?: {
67
+ binding: string;
68
+ };
69
+ version_metadata?: {
70
+ binding: string;
71
+ };
72
+ moduleRoot?: string;
73
+ rules?: Rule$1[];
74
+ logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
75
+ inspect?: boolean;
76
+ local?: boolean;
77
+ accountId?: string;
78
+ experimental?: {
79
+ processEntrypoint?: boolean;
80
+ additionalModules?: CfModule[];
81
+ d1Databases?: Environment$1["d1_databases"];
82
+ disableExperimentalWarning?: boolean;
83
+ disableDevRegistry?: boolean;
84
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
85
+ forceLocal?: boolean;
86
+ liveReload?: boolean;
87
+ showInteractiveDevSession?: boolean;
88
+ testMode?: boolean;
89
+ testScheduled?: boolean;
90
+ watch?: boolean;
91
+ fileBasedRegistry?: boolean;
92
+ enableIpc?: boolean;
93
+ enableContainers?: boolean;
94
+ dockerPath?: string;
95
+ containerEngine?: string;
96
+ };
97
+ }
98
+ interface Unstable_DevWorker {
99
+ port: number;
100
+ address: string;
101
+ stop: () => Promise<void>;
102
+ fetch: (input?: RequestInfo, init?: RequestInit) => Promise<Response>;
103
+ waitUntilExit: () => Promise<void>;
104
+ }
105
+ /**
106
+ * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
107
+ */
108
+ declare function unstable_dev(script: string, options?: Unstable_DevOptions, apiOptions?: unknown): Promise<Unstable_DevWorker>;
109
+
110
+ interface PagesDeployOptions {
111
+ /**
112
+ * Path to static assets to deploy to Pages
113
+ */
114
+ directory: string;
115
+ /**
116
+ * The Cloudflare Account ID that owns the project that's
117
+ * being published
118
+ */
119
+ accountId: string;
120
+ /**
121
+ * The name of the project to be published
122
+ */
123
+ projectName: string;
124
+ /**
125
+ * Branch name to use. Defaults to production branch
126
+ */
127
+ branch?: string;
128
+ /**
129
+ * Whether or not to skip local file upload result caching
130
+ */
131
+ skipCaching?: boolean;
132
+ /**
133
+ * Commit message associated to deployment
134
+ */
135
+ commitMessage?: string;
136
+ /**
137
+ * Commit hash associated to deployment
138
+ */
139
+ commitHash?: string;
140
+ /**
141
+ * Whether or not the deployment should be considered to be
142
+ * in a dirty commit state
143
+ */
144
+ commitDirty?: boolean;
145
+ /**
146
+ * Path to the project's functions directory. Default uses
147
+ * the current working directory + /functions since this is
148
+ * typically called in a CLI
149
+ */
150
+ functionsDirectory?: string;
151
+ /**
152
+ * Whether to run bundling on `_worker.js` before deploying.
153
+ * Default: true
154
+ */
155
+ bundle?: boolean;
156
+ /**
157
+ * Whether to upload any server-side sourcemaps with this deployment
158
+ */
159
+ sourceMaps: boolean;
160
+ /**
161
+ * Command line args passed to the `pages deploy` cmd
162
+ */
163
+ args?: Record<string, unknown>;
164
+ }
165
+ /**
166
+ * Publish a directory to an account/project.
167
+ * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
168
+ * variable set
169
+ */
170
+ declare function deploy({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, sourceMaps, args, }: PagesDeployOptions): Promise<{
171
+ deploymentResponse: {
172
+ url: string;
173
+ id: string;
174
+ environment: "production" | "preview";
175
+ build_config: {
176
+ build_command: string;
177
+ destination_dir: string;
178
+ root_dir: string;
179
+ web_analytics_tag?: string | undefined;
180
+ web_analytics_token?: string | undefined;
181
+ fast_builds?: boolean | undefined;
182
+ };
183
+ created_on: string;
184
+ production_branch: string;
185
+ project_id: string;
186
+ project_name: string;
187
+ deployment_trigger: {
188
+ type: string;
189
+ metadata: {
190
+ branch: string;
191
+ commit_hash: string;
192
+ commit_message: string;
193
+ };
194
+ };
195
+ latest_stage: {
196
+ status: "canceled" | "active" | "success" | "idle" | "failure" | "skipped";
197
+ name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
198
+ started_on: string | null;
199
+ ended_on: string | null;
200
+ };
201
+ stages: {
202
+ status: "canceled" | "active" | "success" | "idle" | "failure" | "skipped";
203
+ name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
204
+ started_on: string | null;
205
+ ended_on: string | null;
206
+ }[];
207
+ aliases: string[];
208
+ modified_on: string;
209
+ short_id: string;
210
+ build_image_major_version: number;
211
+ source?: {
212
+ type: "github" | "gitlab";
213
+ config: {
214
+ owner: string;
215
+ repo_name: string;
216
+ production_branch?: string | undefined;
217
+ pr_comments_enabled?: boolean | undefined;
218
+ deployments_enabled?: boolean | undefined;
219
+ production_deployments_enabled?: boolean | undefined;
220
+ preview_deployment_setting?: "custom" | "none" | "all" | undefined;
221
+ preview_branch_includes?: string[] | undefined;
222
+ preview_branch_excludes?: string[] | undefined;
223
+ };
224
+ } | undefined;
225
+ kv_namespaces?: any;
226
+ env_vars?: any;
227
+ durable_object_namespaces?: any;
228
+ is_skipped?: boolean | undefined;
229
+ files?: {
230
+ [x: string]: string | undefined;
231
+ } | undefined;
232
+ };
233
+ formData: FormData;
234
+ }>;
235
+
236
+ declare const unstable_pages: {
237
+ deploy: typeof deploy;
238
+ };
239
+
240
+ type AssetsOptions = {
241
+ directory: string;
242
+ binding?: string;
243
+ routerConfig: RouterConfig;
244
+ assetConfig: AssetConfig;
245
+ _redirects?: string;
246
+ _headers?: string;
247
+ run_worker_first?: boolean | string[];
248
+ };
249
+
250
+ type ApiCredentials = {
251
+ apiToken: string;
252
+ } | {
253
+ authKey: string;
254
+ authEmail: string;
255
+ };
256
+
257
+ /**
258
+ * An entry point for the Worker.
259
+ *
260
+ * It consists not just of a `file`, but also of a `directory` that is used to resolve relative paths.
261
+ */
262
+ type Entry = {
263
+ /** A worker's entrypoint */
264
+ file: string;
265
+ /** A worker's directory. Usually where the Wrangler configuration file is located */
266
+ projectRoot: string;
267
+ /** The path to the config file, if it exists. */
268
+ configPath: string | undefined;
269
+ /** Is this a module worker or a service worker? */
270
+ format: CfScriptFormat;
271
+ /** The directory that contains all of a `--no-bundle` worker's modules. Usually `${directory}/src`. Defaults to path.dirname(file) */
272
+ moduleRoot: string;
273
+ /**
274
+ * A worker's name
275
+ */
276
+ name?: string | undefined;
277
+ /** Export from a Worker's entrypoint */
278
+ exports: string[];
279
+ };
280
+
281
+ /**
282
+ * Information about Wrangler's bundling process that needs passed through
283
+ * for DevTools sourcemap transformation
284
+ */
285
+ interface SourceMapMetadata {
286
+ tmpDir: string;
287
+ entryDirectory: string;
288
+ }
289
+
290
+ type EsbuildBundle = {
291
+ id: number;
292
+ path: string;
293
+ entrypointSource: string;
294
+ entry: Entry;
295
+ type: CfModuleType;
296
+ modules: CfModule[];
297
+ dependencies: Metafile["outputs"][string]["inputs"];
298
+ sourceMapPath: string | undefined;
299
+ sourceMapMetadata: SourceMapMetadata | undefined;
300
+ };
301
+
302
+ /**
303
+ * A Cloudflare account.
304
+ */
305
+ interface CfAccount {
306
+ /**
307
+ * An API token.
308
+ *
309
+ * @link https://api.cloudflare.com/#user-api-tokens-properties
310
+ */
311
+ apiToken: ApiCredentials;
312
+ /**
313
+ * An account ID.
314
+ */
315
+ accountId: string;
316
+ }
317
+
318
+ type _Params<ParamsArray extends [unknown?]> = ParamsArray extends [infer P] ? P : undefined;
319
+ type _EventMethods = keyof Protocol.Events;
320
+ type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
321
+ method: Method;
322
+ params: _Params<Protocol.Events[Method]>;
323
+ } : never;
324
+
325
+ type ErrorEvent = BaseErrorEvent<"ConfigController" | "BundlerController" | "LocalRuntimeController" | "RemoteRuntimeController" | "ProxyWorker" | "InspectorProxyWorker" | "MultiworkerRuntimeController"> | BaseErrorEvent<"ProxyController", {
326
+ config?: StartDevWorkerOptions;
327
+ bundle?: Bundle;
328
+ }> | BaseErrorEvent<"BundlerController", {
329
+ config?: StartDevWorkerOptions;
330
+ filePath?: string;
331
+ }>;
332
+ type BaseErrorEvent<Source = string, Data = undefined> = {
333
+ type: "error";
334
+ reason: string;
335
+ cause: Error | SerializedError;
336
+ source: Source;
337
+ data: Data;
338
+ };
339
+ type ConfigUpdateEvent = {
340
+ type: "configUpdate";
341
+ config: StartDevWorkerOptions;
342
+ };
343
+ type BundleStartEvent = {
344
+ type: "bundleStart";
345
+ config: StartDevWorkerOptions;
346
+ };
347
+ type BundleCompleteEvent = {
348
+ type: "bundleComplete";
349
+ config: StartDevWorkerOptions;
350
+ bundle: Bundle;
351
+ };
352
+ type ReloadStartEvent = {
353
+ type: "reloadStart";
354
+ config: StartDevWorkerOptions;
355
+ bundle: Bundle;
356
+ };
357
+ type ReloadCompleteEvent = {
358
+ type: "reloadComplete";
359
+ config: StartDevWorkerOptions;
360
+ bundle: Bundle;
361
+ proxyData: ProxyData;
362
+ };
363
+ type DevRegistryUpdateEvent = {
364
+ type: "devRegistryUpdate";
365
+ registry: WorkerRegistry;
366
+ };
367
+ type PreviewTokenExpiredEvent = {
368
+ type: "previewTokenExpired";
369
+ proxyData: ProxyData;
370
+ };
371
+ type ReadyEvent = {
372
+ type: "ready";
373
+ proxyWorker: Miniflare;
374
+ url: URL;
375
+ inspectorUrl: URL | undefined;
376
+ };
377
+ type ProxyWorkerIncomingRequestBody = {
378
+ type: "play";
379
+ proxyData: ProxyData;
380
+ } | {
381
+ type: "pause";
382
+ };
383
+ type ProxyWorkerOutgoingRequestBody = {
384
+ type: "error";
385
+ error: SerializedError;
386
+ } | {
387
+ type: "previewTokenExpired";
388
+ proxyData: ProxyData;
389
+ } | {
390
+ type: "debug-log";
391
+ args: Parameters<typeof console.debug>;
392
+ };
393
+
394
+ type InspectorProxyWorkerIncomingWebSocketMessage = {
395
+ type: ReloadStartEvent["type"];
396
+ } | {
397
+ type: ReloadCompleteEvent["type"];
398
+ proxyData: ProxyData;
399
+ };
400
+ type InspectorProxyWorkerOutgoingWebsocketMessage = DevToolsEvent<"Runtime.consoleAPICalled"> | DevToolsEvent<"Runtime.exceptionThrown">;
401
+ type InspectorProxyWorkerOutgoingRequestBody = {
402
+ type: "error";
403
+ error: SerializedError;
404
+ } | {
405
+ type: "runtime-websocket-error";
406
+ error: SerializedError;
407
+ } | {
408
+ type: "debug-log";
409
+ args: Parameters<typeof console.debug>;
410
+ } | {
411
+ type: "load-network-resource";
412
+ url: string;
413
+ };
414
+ type SerializedError = {
415
+ message: string;
416
+ name?: string;
417
+ stack?: string | undefined;
418
+ cause?: unknown;
419
+ };
420
+ type UrlOriginParts = Pick<URL, "protocol" | "hostname" | "port">;
421
+ type UrlOriginAndPathnameParts = Pick<URL, "protocol" | "hostname" | "port" | "pathname">;
422
+ type ProxyData = {
423
+ userWorkerUrl: UrlOriginParts;
424
+ userWorkerInspectorUrl?: UrlOriginAndPathnameParts;
425
+ userWorkerInnerUrlOverrides?: Partial<UrlOriginParts>;
426
+ headers: Record<string, string>;
427
+ liveReload?: boolean;
428
+ proxyLogsToController?: boolean;
429
+ };
430
+
431
+ type ControllerEvent = ErrorEvent | ConfigUpdateEvent | BundleStartEvent | BundleCompleteEvent | ReloadStartEvent | ReloadCompleteEvent | DevRegistryUpdateEvent | PreviewTokenExpiredEvent;
432
+ interface ControllerBus {
433
+ dispatch(event: ControllerEvent): void;
434
+ }
435
+ declare abstract class Controller {
436
+ #private;
437
+ protected bus: ControllerBus;
438
+ constructor(bus: ControllerBus);
439
+ teardown(): Promise<void>;
440
+ protected emitErrorEvent(event: ErrorEvent): void;
441
+ }
442
+ declare abstract class RuntimeController extends Controller {
443
+ abstract onBundleStart(_: BundleStartEvent): void;
444
+ abstract onBundleComplete(_: BundleCompleteEvent): void;
445
+ abstract onPreviewTokenExpired(_: PreviewTokenExpiredEvent): void;
446
+ protected emitReloadStartEvent(data: ReloadStartEvent): void;
447
+ protected emitReloadCompleteEvent(data: ReloadCompleteEvent): void;
448
+ protected emitDevRegistryUpdateEvent(data: DevRegistryUpdateEvent): void;
449
+ }
450
+
451
+ declare class ConfigController extends Controller {
452
+ #private;
453
+ latestInput?: StartDevWorkerInput;
454
+ latestConfig?: StartDevWorkerOptions;
455
+ set(input: StartDevWorkerInput, throwErrors?: boolean): Promise<StartDevWorkerOptions | undefined>;
456
+ patch(input: Partial<StartDevWorkerInput>): Promise<StartDevWorkerOptions | undefined>;
457
+ onDevRegistryUpdate(event: DevRegistryUpdateEvent): void;
458
+ teardown(): Promise<void>;
459
+ emitConfigUpdateEvent(config: StartDevWorkerOptions): void;
460
+ }
461
+
462
+ declare class BundlerController extends Controller {
463
+ #private;
464
+ onConfigUpdate(event: ConfigUpdateEvent): void;
465
+ teardown(): Promise<void>;
466
+ emitBundleStartEvent(config: StartDevWorkerOptions): void;
467
+ emitBundleCompleteEvent(config: StartDevWorkerOptions, bundle: EsbuildBundle): void;
468
+ }
469
+
470
+ declare class ProxyController extends Controller {
471
+ ready: DeferredPromise<ReadyEvent>;
472
+ localServerReady: DeferredPromise<void>;
473
+ proxyWorker?: Miniflare;
474
+ proxyWorkerOptions?: MiniflareOptions;
475
+ private inspectorProxyWorkerWebSocket?;
476
+ protected latestConfig?: StartDevWorkerOptions;
477
+ protected latestBundle?: EsbuildBundle;
478
+ secret: `${string}-${string}-${string}-${string}-${string}`;
479
+ protected createProxyWorker(): void;
480
+ private reconnectInspectorProxyWorker;
481
+ runtimeMessageMutex: Mutex;
482
+ sendMessageToProxyWorker(message: ProxyWorkerIncomingRequestBody, retries?: number): Promise<void>;
483
+ sendMessageToInspectorProxyWorker(message: InspectorProxyWorkerIncomingWebSocketMessage, retries?: number): Promise<void>;
484
+ get inspectorEnabled(): boolean;
485
+ onConfigUpdate(data: ConfigUpdateEvent): void;
486
+ onBundleStart(data: BundleStartEvent): void;
487
+ onReloadStart(data: ReloadStartEvent): void;
488
+ onReloadComplete(data: ReloadCompleteEvent): void;
489
+ onProxyWorkerMessage(message: ProxyWorkerOutgoingRequestBody): void;
490
+ onInspectorProxyWorkerMessage(message: InspectorProxyWorkerOutgoingWebsocketMessage): void;
491
+ onInspectorProxyWorkerRequest(message: InspectorProxyWorkerOutgoingRequestBody): Promise<Response$1>;
492
+ _torndown: boolean;
493
+ teardown(): Promise<void>;
494
+ emitReadyEvent(proxyWorker: Miniflare, url: URL, inspectorUrl: URL | undefined): void;
495
+ emitPreviewTokenExpiredEvent(proxyData: ProxyData): void;
496
+ emitErrorEvent(data: ErrorEvent): void;
497
+ emitErrorEvent(reason: string, cause?: Error | SerializedError): void;
498
+ }
499
+
500
+ type ControllerFactory<C extends Controller> = (devEnv: DevEnv) => C;
501
+ declare class DevEnv extends EventEmitter implements ControllerBus {
502
+ config: ConfigController;
503
+ bundler: BundlerController;
504
+ runtimes: RuntimeController[];
505
+ proxy: ProxyController;
506
+ startWorker(options: StartDevWorkerInput): Promise<Worker>;
507
+ constructor({ configFactory, bundlerFactory, runtimeFactories, proxyFactory, }?: {
508
+ configFactory?: ControllerFactory<ConfigController>;
509
+ bundlerFactory?: ControllerFactory<BundlerController>;
510
+ runtimeFactories?: ControllerFactory<RuntimeController>[];
511
+ proxyFactory?: ControllerFactory<ProxyController>;
512
+ });
513
+ /**
514
+ * Central message bus dispatch method.
515
+ * All events from controllers flow through here, making the event routing explicit and traceable.
516
+ *
517
+ * Event flow:
518
+ * - ConfigController emits configUpdate → BundlerController, ProxyController
519
+ * - BundlerController emits bundleStart → ProxyController, RuntimeControllers
520
+ * - BundlerController emits bundleComplete → RuntimeControllers
521
+ * - RuntimeController emits reloadStart → ProxyController
522
+ * - RuntimeController emits reloadComplete → ProxyController
523
+ * - RuntimeController emits devRegistryUpdate → ConfigController
524
+ * - ProxyController emits previewTokenExpired → RuntimeControllers
525
+ * - Any controller emits error → DevEnv error handler
526
+ */
527
+ dispatch(event: ControllerEvent): void;
528
+ private handleErrorEvent;
529
+ teardown(): Promise<void>;
530
+ }
531
+
532
+ type MiniflareWorker = Awaited<ReturnType<Miniflare["getWorker"]>>;
533
+ interface Worker {
534
+ ready: Promise<void>;
535
+ url: Promise<URL>;
536
+ inspectorUrl: Promise<URL | undefined>;
537
+ config: StartDevWorkerOptions;
538
+ setConfig: ConfigController["set"];
539
+ patchConfig: ConfigController["patch"];
540
+ fetch: DispatchFetch;
541
+ scheduled: MiniflareWorker["scheduled"];
542
+ queue: MiniflareWorker["queue"];
543
+ dispose(): Promise<void>;
544
+ raw: DevEnv;
545
+ }
546
+ interface StartDevWorkerInput {
547
+ /** The name of the worker. */
548
+ name?: string;
549
+ /**
550
+ * The javascript or typescript entry-point of the worker.
551
+ * This is the `main` property of a Wrangler configuration file.
552
+ */
553
+ entrypoint?: string;
554
+ /** The configuration path of the worker. */
555
+ config?: string;
556
+ /** The compatibility date for the workerd runtime. */
557
+ compatibilityDate?: string;
558
+ /** The compatibility flags for the workerd runtime. */
559
+ compatibilityFlags?: string[];
560
+ /** Specify the compliance region mode of the Worker. */
561
+ complianceRegion?: Config$1["compliance_region"];
562
+ /** Configuration for Python modules. */
563
+ pythonModules?: {
564
+ /** A list of glob patterns to exclude files from the python_modules directory when bundling. */
565
+ exclude?: string[];
566
+ };
567
+ env?: string;
568
+ /**
569
+ * An array of paths to the .env files to load for this worker, relative to the project directory.
570
+ *
571
+ * If not specified, defaults to the standard `.env` files as given by `getDefaultEnvFiles()`.
572
+ * The project directory is where the Wrangler configuration file is located or the current working directory otherwise.
573
+ */
574
+ envFiles?: string[];
575
+ /** The bindings available to the worker. The specified bindind type will be exposed to the worker on the `env` object under the same key. */
576
+ bindings?: Record<string, Binding>;
577
+ /**
578
+ * Default bindings that can be overridden by config bindings.
579
+ * Useful for injecting environment-specific defaults like CF_PAGES variables.
580
+ */
581
+ defaultBindings?: Record<string, Extract<Binding, {
582
+ type: "plain_text";
583
+ }>>;
584
+ migrations?: DurableObjectMigration$1[];
585
+ containers?: ContainerApp$1[];
586
+ /** The triggers which will cause the worker's exported default handlers to be called. */
587
+ triggers?: Trigger[];
588
+ tailConsumers?: CfTailConsumer[];
589
+ streamingTailConsumers?: CfTailConsumer[];
590
+ /**
591
+ * Whether Wrangler should send usage metrics to Cloudflare for this project.
592
+ *
593
+ * When defined this will override any user settings.
594
+ * Otherwise, Wrangler will use the user's preference.
595
+ */
596
+ sendMetrics?: boolean;
597
+ /** Options applying to the worker's build step. Applies to deploy and dev. */
598
+ build?: {
599
+ /** Whether the worker and its dependencies are bundled. Defaults to true. */
600
+ bundle?: boolean;
601
+ additionalModules?: CfModule[];
602
+ findAdditionalModules?: boolean;
603
+ processEntrypoint?: boolean;
604
+ /** Specifies types of modules matched by globs. */
605
+ moduleRules?: Rule$1[];
606
+ /** Replace global identifiers with constant expressions, e.g. { debug: 'true', version: '"1.0.0"' }. Only takes effect if bundle: true. */
607
+ define?: Record<string, string>;
608
+ /** Alias modules */
609
+ alias?: Record<string, string>;
610
+ /** Whether the bundled worker is minified. Only takes effect if bundle: true. */
611
+ minify?: boolean;
612
+ /** Whether to keep function names after JavaScript transpilations. */
613
+ keepNames?: boolean;
614
+ /** Options controlling a custom build step. */
615
+ custom?: {
616
+ /** Custom shell command to run before bundling. Runs even if bundle. */
617
+ command?: string;
618
+ /** The cwd to run the command in. */
619
+ workingDirectory?: string;
620
+ /** Filepath(s) to watch for changes. Upon changes, the command will be rerun. */
621
+ watch?: string | string[];
622
+ };
623
+ jsxFactory?: string;
624
+ jsxFragment?: string;
625
+ tsconfig?: string;
626
+ nodejsCompatMode?: Hook<NodeJSCompatMode, [Config$1]>;
627
+ moduleRoot?: string;
628
+ };
629
+ /** Options applying to the worker's development preview environment. */
630
+ dev?: {
631
+ /** Options applying to the worker's inspector server. False disables the inspector server. */
632
+ inspector?: {
633
+ hostname?: string;
634
+ port?: number;
635
+ secure?: boolean;
636
+ } | false;
637
+ /** Whether the worker runs on the edge or locally. This has several options:
638
+ * - true | "minimal": Run your Worker's code & bindings in a remote preview session, optionally using minimal mode as an internal detail
639
+ * - false: Run your Worker's code & bindings in a local simulator
640
+ * - undefined (default): Run your Worker's code locally, and any configured remote bindings remotely
641
+ */
642
+ remote?: boolean | "minimal";
643
+ /** Cloudflare Account credentials. Can be provided upfront or as a function which will be called only when required. */
644
+ auth?: AsyncHook<CfAccount, [Pick<Config$1, "account_id">]>;
645
+ /** Whether local storage (KV, Durable Objects, R2, D1, etc) is persisted. You can also specify the directory to persist data to. Set to `false` to disable persistence. */
646
+ persist?: string | false;
647
+ /** Controls which logs are logged 🤙. */
648
+ logLevel?: LogLevel;
649
+ /** Whether the worker server restarts upon source/config file changes. */
650
+ watch?: boolean;
651
+ /** Whether a script tag is inserted on text/html responses which will reload the page upon file changes. Defaults to false. */
652
+ liveReload?: boolean;
653
+ /** The local address to reach your worker. Applies to remote: true (remote mode) and remote: false (local mode). */
654
+ server?: {
655
+ hostname?: string;
656
+ port?: number;
657
+ secure?: boolean;
658
+ httpsKeyPath?: string;
659
+ httpsCertPath?: string;
660
+ };
661
+ /** Controls what request.url looks like inside the worker. */
662
+ origin?: {
663
+ hostname?: string;
664
+ secure?: boolean;
665
+ };
666
+ /** A hook for outbound fetch calls from within the worker. */
667
+ outboundService?: ServiceFetch;
668
+ /** An undici MockAgent to declaratively mock fetch calls to particular resources. */
669
+ mockFetch?: undici.MockAgent;
670
+ testScheduled?: boolean;
671
+ /** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
672
+ multiworkerPrimary?: boolean;
673
+ containerBuildId?: string;
674
+ /** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */
675
+ enableContainers?: boolean;
676
+ /** Path to the dev registry directory */
677
+ registry?: string;
678
+ /** Path to the docker executable. Defaults to 'docker' */
679
+ dockerPath?: string;
680
+ /** Options for the container engine */
681
+ containerEngine?: ContainerEngine$1;
682
+ /** Re-generate your worker types when your Wrangler configuration file changes */
683
+ generateTypes?: boolean;
684
+ };
685
+ legacy?: {
686
+ site?: Hook<Config$1["site"], [Config$1]>;
687
+ useServiceEnvironments?: boolean;
688
+ };
689
+ unsafe?: Omit<CfUnsafe, "bindings">;
690
+ assets?: string;
691
+ experimental?: Record<string, never>;
692
+ }
693
+ type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "containers" | "dev"> & {
694
+ /** A worker's directory. Usually where the Wrangler configuration file is located */
695
+ projectRoot: string;
696
+ build: StartDevWorkerInput["build"] & {
697
+ nodejsCompatMode: NodeJSCompatMode;
698
+ format: CfScriptFormat;
699
+ moduleRoot: string;
700
+ moduleRules: Rule$1[];
701
+ define: Record<string, string>;
702
+ additionalModules: CfModule[];
703
+ exports: string[];
704
+ processEntrypoint: boolean;
705
+ };
706
+ legacy: StartDevWorkerInput["legacy"] & {
707
+ site?: Config$1["site"];
708
+ };
709
+ dev: StartDevWorkerInput["dev"] & {
710
+ persist: string | false;
711
+ auth?: AsyncHook<CfAccount>;
712
+ };
713
+ entrypoint: string;
714
+ assets?: AssetsOptions;
715
+ containers?: ContainerNormalizedConfig[];
716
+ name: string;
717
+ complianceRegion: Config$1["compliance_region"];
718
+ };
719
+ type HookValues = string | number | boolean | object | undefined | null;
720
+ type Hook<T extends HookValues, Args extends unknown[] = []> = T | ((...args: Args) => T);
721
+ type AsyncHook<T extends HookValues, Args extends unknown[] = []> = Hook<T, Args> | Hook<Promise<T>, Args>;
722
+ type Bundle = EsbuildBundle;
723
+ type LogLevel = "debug" | "info" | "log" | "warn" | "error" | "none";
724
+
725
+ type MaybePromise<T> = T | Promise<T>;
726
+ type DeferredPromise<T> = {
727
+ promise: Promise<T>;
728
+ resolve: (_: MaybePromise<T>) => void;
729
+ reject: (_: Error) => void;
730
+ };
731
+ declare function convertConfigBindingsToStartWorkerBindings(configBindings: Partial<Pick<Config$1, ConfigBindingFieldName>>): StartDevWorkerOptions["bindings"];
732
+
733
+ declare function startWorker(options: StartDevWorkerInput): Promise<Worker>;
734
+
735
+ type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & {
736
+ config?: string;
737
+ script?: string;
738
+ };
739
+ type ReadConfigOptions = ResolveConfigPathOptions & {
740
+ hideWarnings?: boolean;
741
+ preserveOriginalMain?: boolean;
742
+ };
743
+ /**
744
+ * Get the Wrangler configuration; read it from the give `configPath` if available.
745
+ */
746
+ declare function readConfig(args: ReadConfigCommandArgs, options?: ReadConfigOptions): Config$1;
747
+
748
+ /**
749
+ * Based on the migrations, infer what the current Durable Object class names are.
750
+ * This includes unbound (ctx.exports) and bound DOs.
751
+ * Returns class name mapped to whether it uses SQLite storage.
752
+ * This is imperfect because you can delete a migration after it has been applied.
753
+ */
754
+ declare function getDurableObjectClassNameToUseSQLiteMap(migrations: Config$1["migrations"] | undefined): Map<string, boolean>;
755
+
756
+ /**
757
+ * Note about this file:
758
+ *
759
+ * Here we are providing a no-op implementation of the runtime Cache API instead of using
760
+ * the miniflare implementation (via `mf.getCaches()`).
761
+ *
762
+ * We are not using miniflare's implementation because that would require the user to provide
763
+ * miniflare-specific Request objects and they would receive back miniflare-specific Response
764
+ * objects, this (in particular the Request part) is not really suitable for `getPlatformProxy`
765
+ * as people would ideally interact with their bindings in a very production-like manner and
766
+ * requiring them to deal with miniflare-specific classes defeats a bit the purpose of the utility.
767
+ *
768
+ * Similarly the Request and Response types here are set to `undefined` as not to use specific ones
769
+ * that would require us to make a choice right now or the user to adapt their code in order to work
770
+ * with the api.
771
+ *
772
+ * We need to find a better/generic manner in which we can reuse the miniflare cache implementation,
773
+ * but until then the no-op implementation below will have to do.
774
+ */
775
+ /**
776
+ * No-op implementation of CacheStorage
777
+ */
778
+ declare class CacheStorage {
779
+ constructor();
780
+ open(cacheName: string): Promise<Cache>;
781
+ get default(): Cache;
782
+ }
783
+ type CacheRequest = any;
784
+ type CacheResponse = any;
785
+ /**
786
+ * No-op implementation of Cache
787
+ */
788
+ declare class Cache {
789
+ delete(request: CacheRequest, options?: CacheQueryOptions): Promise<boolean>;
790
+ match(request: CacheRequest, options?: CacheQueryOptions): Promise<CacheResponse | undefined>;
791
+ put(request: CacheRequest, response: CacheResponse): Promise<void>;
792
+ }
793
+ type CacheQueryOptions = {
794
+ ignoreMethod?: boolean;
795
+ };
796
+
797
+ declare class ExecutionContext {
798
+ waitUntil(promise: Promise<any>): void;
799
+ passThroughOnException(): void;
800
+ props: any;
801
+ }
802
+
803
+ type Json = string | number | boolean | null | Json[] | {
804
+ [id: string]: Json;
805
+ };
806
+
807
+ /**
808
+ * The `Environment` interface declares all the configuration fields that
809
+ * can be specified for an environment.
810
+ *
811
+ * This could be the top-level default environment, or a specific named environment.
812
+ */
813
+ interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
814
+ }
815
+ type SimpleRoute = string;
816
+ type ZoneIdRoute = {
817
+ pattern: string;
818
+ zone_id: string;
819
+ custom_domain?: boolean;
820
+ };
821
+ type ZoneNameRoute = {
822
+ pattern: string;
823
+ zone_name: string;
824
+ custom_domain?: boolean;
825
+ };
826
+ type CustomDomainRoute = {
827
+ pattern: string;
828
+ custom_domain: boolean;
829
+ };
830
+ type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
831
+ /**
832
+ * Configuration in wrangler for Cloudchamber
833
+ */
834
+ type CloudchamberConfig = {
835
+ image?: string;
836
+ location?: string;
837
+ instance_type?: "dev" | "basic" | "standard" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4";
838
+ vcpu?: number;
839
+ memory?: string;
840
+ ipv4?: boolean;
841
+ };
842
+ type UnsafeBinding = {
843
+ /**
844
+ * The name of the binding provided to the Worker
845
+ */
846
+ name: string;
847
+ /**
848
+ * The 'type' of the unsafe binding.
849
+ */
850
+ type: string;
851
+ dev?: {
852
+ plugin: {
853
+ /**
854
+ * Package is the bare specifier of the package that exposes plugins to integrate into Miniflare via a named `plugins` export.
855
+ * @example "@cloudflare/my-external-miniflare-plugin"
856
+ */
857
+ package: string;
858
+ /**
859
+ * Plugin is the name of the plugin exposed by the package.
860
+ * @example "MY_UNSAFE_PLUGIN"
861
+ */
862
+ name: string;
863
+ };
864
+ /**
865
+ * Optional mapping of unsafe bindings names to options provided for the plugin.
866
+ */
867
+ options?: Record<string, unknown>;
868
+ };
869
+ [key: string]: unknown;
870
+ };
871
+ /**
872
+ * Configuration for a container application
873
+ */
874
+ type ContainerApp = {
875
+ /**
876
+ * Name of the application
877
+ * @optional Defaults to `worker_name-class_name` if not specified.
878
+ */
879
+ name?: string;
880
+ /**
881
+ * Number of application instances
882
+ * @deprecated
883
+ * @hidden
884
+ */
885
+ instances?: number;
886
+ /**
887
+ * Number of maximum application instances.
888
+ * @optional
889
+ */
890
+ max_instances?: number;
891
+ /**
892
+ * The path to a Dockerfile, or an image URI for the Cloudflare registry.
893
+ */
894
+ image: string;
895
+ /**
896
+ * Build context of the application.
897
+ * @optional - defaults to the directory of `image`.
898
+ */
899
+ image_build_context?: string;
900
+ /**
901
+ * Image variables available to the image at build-time only.
902
+ * For runtime env vars, refer to https://developers.cloudflare.com/containers/examples/env-vars-and-secrets/
903
+ * @optional
904
+ */
905
+ image_vars?: Record<string, string>;
906
+ /**
907
+ * The class name of the Durable Object the container is connected to.
908
+ */
909
+ class_name: string;
910
+ /**
911
+ * The scheduling policy of the application
912
+ * @optional
913
+ * @default "default"
914
+ */
915
+ scheduling_policy?: "default" | "moon" | "regional";
916
+ /**
917
+ * The instance type to be used for the container.
918
+ * Select from one of the following named instance types:
919
+ * - lite: 1/16 vCPU, 256 MiB memory, and 2 GB disk
920
+ * - basic: 1/4 vCPU, 1 GiB memory, and 4 GB disk
921
+ * - standard-1: 1/2 vCPU, 4 GiB memory, and 8 GB disk
922
+ * - standard-2: 1 vCPU, 6 GiB memory, and 12 GB disk
923
+ * - standard-3: 2 vCPU, 8 GiB memory, and 16 GB disk
924
+ * - standard-4: 4 vCPU, 12 GiB memory, and 20 GB disk
925
+ * - dev: 1/16 vCPU, 256 MiB memory, and 2 GB disk (deprecated, use "lite" instead)
926
+ * - standard: 1 vCPU, 4 GiB memory, and 4 GB disk (deprecated, use "standard-1" instead)
927
+ *
928
+ * Customers on an enterprise plan have the additional option to set custom limits.
929
+ *
930
+ * @optional
931
+ * @default "dev"
932
+ */
933
+ instance_type?: "dev" | "basic" | "standard" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4" | {
934
+ /** @defaults to 0.0625 (1/16 vCPU) */
935
+ vcpu?: number;
936
+ /** @defaults to 256 MiB */
937
+ memory_mib?: number;
938
+ /** @defaults to 2 GB */
939
+ disk_mb?: number;
940
+ };
941
+ wrangler_ssh?: {
942
+ /**
943
+ * If enabled, those with write access to a container will be able to SSH into it through Wrangler.
944
+ * @default false
945
+ */
946
+ enabled: boolean;
947
+ /**
948
+ * Port that the SSH service is running on
949
+ * @defaults to 22
950
+ */
951
+ port?: number;
952
+ };
953
+ /**
954
+ * SSH public keys to put in the container's authorized_keys file.
955
+ */
956
+ authorized_keys?: {
957
+ name: string;
958
+ public_key: string;
959
+ }[];
960
+ /**
961
+ * Trusted user CA keys to put in the container's trusted_user_ca_keys file.
962
+ */
963
+ trusted_user_ca_keys?: {
964
+ name?: string;
965
+ public_key: string;
966
+ }[];
967
+ /**
968
+ * @deprecated Use top level `containers` fields instead.
969
+ * `configuration.image` should be `image`
970
+ * limits should be set via `instance_type`
971
+ * @hidden
972
+ */
973
+ configuration?: {
974
+ image?: string;
975
+ labels?: {
976
+ name: string;
977
+ value: string;
978
+ }[];
979
+ secrets?: {
980
+ name: string;
981
+ type: "env";
982
+ secret: string;
983
+ }[];
984
+ disk?: {
985
+ size_mb: number;
986
+ };
987
+ vcpu?: number;
988
+ memory_mib?: number;
989
+ };
990
+ /**
991
+ * Scheduling constraints
992
+ * @hidden
993
+ */
994
+ constraints?: {
995
+ regions?: string[];
996
+ cities?: string[];
997
+ /**
998
+ * @deprecated Use `tiers` instead
999
+ */
1000
+ tier?: number;
1001
+ tiers?: number[];
1002
+ };
1003
+ /**
1004
+ * Scheduling affinities
1005
+ * @hidden
1006
+ */
1007
+ affinities?: {
1008
+ colocation?: "datacenter";
1009
+ hardware_generation?: "highest-overall-performance";
1010
+ };
1011
+ /**
1012
+ * @deprecated use the `class_name` field instead.
1013
+ * @hidden
1014
+ */
1015
+ durable_objects?: {
1016
+ namespace_id: string;
1017
+ };
1018
+ /**
1019
+ * Configures what percentage of instances should be updated at each step of a rollout.
1020
+ * You can specify this as a single number, or an array of numbers.
1021
+ *
1022
+ * If this is a single number, each step will progress by that percentage.
1023
+ * The options are 5, 10, 20, 25, 50 or 100.
1024
+ *
1025
+ * If this is an array, each step specifies the cumulative rollout progress.
1026
+ * The final step must be 100.
1027
+ *
1028
+ * This can be overridden adhoc by deploying with the `--containers-rollout=immediate` flag,
1029
+ * which will roll out to 100% of instances in one step.
1030
+ *
1031
+ * @optional
1032
+ * @default [10,100]
1033
+ * */
1034
+ rollout_step_percentage?: number | number[];
1035
+ /**
1036
+ * How a rollout should be created. It supports the following modes:
1037
+ * - full_auto: The container application will be rolled out fully automatically.
1038
+ * - none: The container application won't have a roll out or update.
1039
+ * - manual: The container application will be rollout fully by manually actioning progress steps.
1040
+ * @optional
1041
+ * @default "full_auto"
1042
+ * @hidden
1043
+ */
1044
+ rollout_kind?: "full_auto" | "none" | "full_manual";
1045
+ /**
1046
+ * Configures the grace period (in seconds) for active instances before being shutdown during a rollout.
1047
+ * @optional
1048
+ * @default 0
1049
+ */
1050
+ rollout_active_grace_period?: number;
1051
+ /**
1052
+ * Directly passed to the API without wrangler-side validation or transformation.
1053
+ * @hidden
1054
+ */
1055
+ unsafe?: Record<string, unknown>;
1056
+ };
1057
+ /**
1058
+ * Configuration in wrangler for Durable Object Migrations
1059
+ */
1060
+ type DurableObjectMigration = {
1061
+ /** A unique identifier for this migration. */
1062
+ tag: string;
1063
+ /** The new Durable Objects being defined. */
1064
+ new_classes?: string[];
1065
+ /** The new SQLite Durable Objects being defined. */
1066
+ new_sqlite_classes?: string[];
1067
+ /** The Durable Objects being renamed. */
1068
+ renamed_classes?: {
1069
+ from: string;
1070
+ to: string;
1071
+ }[];
1072
+ /** The Durable Objects being removed. */
1073
+ deleted_classes?: string[];
1074
+ };
1075
+ /**
1076
+ * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
1077
+ * that can be inherited (and overridden) from the top-level environment.
1078
+ */
1079
+ interface EnvironmentInheritable {
1080
+ /**
1081
+ * The name of your Worker. Alphanumeric + dashes only.
1082
+ *
1083
+ * @inheritable
1084
+ */
1085
+ name: string | undefined;
1086
+ /**
1087
+ * This is the ID of the account associated with your zone.
1088
+ * You might have more than one account, so make sure to use
1089
+ * the ID of the account associated with the zone/route you
1090
+ * provide, if you provide one. It can also be specified through
1091
+ * the CLOUDFLARE_ACCOUNT_ID environment variable.
1092
+ *
1093
+ * @inheritable
1094
+ */
1095
+ account_id: string | undefined;
1096
+ /**
1097
+ * A date in the form yyyy-mm-dd, which will be used to determine
1098
+ * which version of the Workers runtime is used.
1099
+ *
1100
+ * More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates
1101
+ *
1102
+ * @inheritable
1103
+ */
1104
+ compatibility_date: string | undefined;
1105
+ /**
1106
+ * A list of flags that enable features from upcoming features of
1107
+ * the Workers runtime, usually used together with compatibility_date.
1108
+ *
1109
+ * More details at https://developers.cloudflare.com/workers/configuration/compatibility-flags/
1110
+ *
1111
+ * @default []
1112
+ * @inheritable
1113
+ */
1114
+ compatibility_flags: string[];
1115
+ /**
1116
+ * The entrypoint/path to the JavaScript file that will be executed.
1117
+ *
1118
+ * @inheritable
1119
+ */
1120
+ main: string | undefined;
1121
+ /**
1122
+ * If true then Wrangler will traverse the file tree below `base_dir`;
1123
+ * Any files that match `rules` will be included in the deployed Worker.
1124
+ * Defaults to true if `no_bundle` is true, otherwise false.
1125
+ *
1126
+ * @inheritable
1127
+ */
1128
+ find_additional_modules: boolean | undefined;
1129
+ /**
1130
+ * Determines whether Wrangler will preserve bundled file names.
1131
+ * Defaults to false.
1132
+ * If left unset, files will be named using the pattern ${fileHash}-${basename},
1133
+ * for example, `34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico`.
1134
+ *
1135
+ * @inheritable
1136
+ */
1137
+ preserve_file_names: boolean | undefined;
1138
+ /**
1139
+ * The directory in which module rules should be evaluated when including additional files into a Worker deployment.
1140
+ * This defaults to the directory containing the `main` entry point of the Worker if not specified.
1141
+ *
1142
+ * @inheritable
1143
+ */
1144
+ base_dir: string | undefined;
1145
+ /**
1146
+ * Whether we use <name>.<subdomain>.workers.dev to
1147
+ * test and deploy your Worker.
1148
+ *
1149
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workersdev
1150
+ *
1151
+ * @default true
1152
+ * @breaking
1153
+ * @inheritable
1154
+ */
1155
+ workers_dev: boolean | undefined;
1156
+ /**
1157
+ * Whether we use <version>-<name>.<subdomain>.workers.dev to
1158
+ * serve Preview URLs for your Worker.
1159
+ *
1160
+ * @default false
1161
+ * @inheritable
1162
+ */
1163
+ preview_urls: boolean | undefined;
1164
+ /**
1165
+ * A list of routes that your Worker should be published to.
1166
+ * Only one of `routes` or `route` is required.
1167
+ *
1168
+ * Only required when workers_dev is false, and there's no scheduled Worker (see `triggers`)
1169
+ *
1170
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#types-of-routes
1171
+ *
1172
+ * @inheritable
1173
+ */
1174
+ routes: Route[] | undefined;
1175
+ /**
1176
+ * A route that your Worker should be published to. Literally
1177
+ * the same as routes, but only one.
1178
+ * Only one of `routes` or `route` is required.
1179
+ *
1180
+ * Only required when workers_dev is false, and there's no scheduled Worker
1181
+ *
1182
+ * @inheritable
1183
+ */
1184
+ route: Route | undefined;
1185
+ /**
1186
+ * Path to a custom tsconfig
1187
+ *
1188
+ * @inheritable
1189
+ */
1190
+ tsconfig: string | undefined;
1191
+ /**
1192
+ * The function to use to replace jsx syntax.
1193
+ *
1194
+ * @default "React.createElement"
1195
+ * @inheritable
1196
+ */
1197
+ jsx_factory: string;
1198
+ /**
1199
+ * The function to use to replace jsx fragment syntax.
1200
+ *
1201
+ * @default "React.Fragment"
1202
+ * @inheritable
1203
+ */
1204
+ jsx_fragment: string;
1205
+ /**
1206
+ * A list of migrations that should be uploaded with your Worker.
1207
+ *
1208
+ * These define changes in your Durable Object declarations.
1209
+ *
1210
+ * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
1211
+ *
1212
+ * @default []
1213
+ * @inheritable
1214
+ */
1215
+ migrations: DurableObjectMigration[];
1216
+ /**
1217
+ * "Cron" definitions to trigger a Worker's "scheduled" function.
1218
+ *
1219
+ * Lets you call Workers periodically, much like a cron job.
1220
+ *
1221
+ * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
1222
+ *
1223
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
1224
+ *
1225
+ * @default {crons:[]}
1226
+ * @inheritable
1227
+ */
1228
+ triggers: {
1229
+ crons: string[] | undefined;
1230
+ };
1231
+ /**
1232
+ * Specify limits for runtime behavior.
1233
+ * Only supported for the "standard" Usage Model
1234
+ *
1235
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#limits
1236
+ *
1237
+ * @inheritable
1238
+ */
1239
+ limits: UserLimits | undefined;
1240
+ /**
1241
+ * An ordered list of rules that define which modules to import,
1242
+ * and what type to import them as. You will need to specify rules
1243
+ * to use Text, Data, and CompiledWasm modules, or when you wish to
1244
+ * have a .js file be treated as an ESModule instead of CommonJS.
1245
+ *
1246
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#bundling
1247
+ *
1248
+ * @inheritable
1249
+ */
1250
+ rules: Rule[];
1251
+ /**
1252
+ * Configures a custom build step to be run by Wrangler when building your Worker.
1253
+ *
1254
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
1255
+ * for more details.
1256
+ *
1257
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#custom-builds
1258
+ *
1259
+ * @default {watch_dir:"./src"}
1260
+ */
1261
+ build: {
1262
+ /** 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. */
1263
+ command?: string;
1264
+ /** The directory in which the command is executed. */
1265
+ cwd?: string;
1266
+ /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
1267
+ watch_dir?: string | string[];
1268
+ };
1269
+ /**
1270
+ * Skip internal build steps and directly deploy script
1271
+ * @inheritable
1272
+ */
1273
+ no_bundle: boolean | undefined;
1274
+ /**
1275
+ * Minify the script before uploading.
1276
+ * @inheritable
1277
+ */
1278
+ minify: boolean | undefined;
1279
+ /**
1280
+ * Set the `name` property to the original name for functions and classes renamed during minification.
1281
+ *
1282
+ * See https://esbuild.github.io/api/#keep-names
1283
+ *
1284
+ * @default true
1285
+ * @inheritable
1286
+ */
1287
+ keep_names: boolean | undefined;
1288
+ /**
1289
+ * Designates this Worker as an internal-only "first-party" Worker.
1290
+ *
1291
+ * @inheritable
1292
+ */
1293
+ first_party_worker: boolean | undefined;
1294
+ /**
1295
+ * List of bindings that you will send to logfwdr
1296
+ *
1297
+ * @default {bindings:[]}
1298
+ * @inheritable
1299
+ */
1300
+ logfwdr: {
1301
+ bindings: {
1302
+ /** The binding name used to refer to logfwdr */
1303
+ name: string;
1304
+ /** The destination for this logged message */
1305
+ destination: string;
1306
+ }[];
1307
+ };
1308
+ /**
1309
+ * Send Trace Events from this Worker to Workers Logpush.
1310
+ *
1311
+ * This will not configure a corresponding Logpush job automatically.
1312
+ *
1313
+ * For more information about Workers Logpush, see:
1314
+ * https://blog.cloudflare.com/logpush-for-workers/
1315
+ *
1316
+ * @inheritable
1317
+ */
1318
+ logpush: boolean | undefined;
1319
+ /**
1320
+ * Include source maps when uploading this worker.
1321
+ *
1322
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#source-maps
1323
+ *
1324
+ * @inheritable
1325
+ */
1326
+ upload_source_maps: boolean | undefined;
1327
+ /**
1328
+ * Specify how the Worker should be located to minimize round-trip time.
1329
+ *
1330
+ * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
1331
+ *
1332
+ * @inheritable
1333
+ */
1334
+ placement: {
1335
+ mode: "off" | "smart";
1336
+ hint?: string;
1337
+ } | {
1338
+ mode?: "targeted";
1339
+ region: string;
1340
+ } | {
1341
+ mode?: "targeted";
1342
+ host: string;
1343
+ } | {
1344
+ mode?: "targeted";
1345
+ hostname: string;
1346
+ } | undefined;
1347
+ /**
1348
+ * Specify the directory of static assets to deploy/serve
1349
+ *
1350
+ * More details at https://developers.cloudflare.com/workers/frameworks/
1351
+ *
1352
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#assets
1353
+ *
1354
+ * @inheritable
1355
+ */
1356
+ assets: Assets | undefined;
1357
+ /**
1358
+ * Specify the observability behavior of the Worker.
1359
+ *
1360
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#observability
1361
+ *
1362
+ * @inheritable
1363
+ */
1364
+ observability: Observability | undefined;
1365
+ /**
1366
+ * Specify the cache behavior of the Worker.
1367
+ *
1368
+ * @inheritable
1369
+ * @hidden
1370
+ */
1371
+ cache: CacheOptions | undefined;
1372
+ /**
1373
+ * Specify the compliance region mode of the Worker.
1374
+ *
1375
+ * Although if the user does not specify a compliance region, the default is `public`,
1376
+ * it can be set to `undefined` in configuration to delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable.
1377
+ */
1378
+ compliance_region: "public" | "fedramp_high" | undefined;
1379
+ /**
1380
+ * Configuration for Python modules.
1381
+ *
1382
+ * @inheritable
1383
+ */
1384
+ python_modules: {
1385
+ /**
1386
+ * A list of glob patterns to exclude files from the python_modules directory when bundling.
1387
+ *
1388
+ * Patterns are relative to the python_modules directory and use glob syntax.
1389
+ *
1390
+ * @default ["**\*.pyc"]
1391
+ */
1392
+ exclude: string[];
1393
+ };
1394
+ }
1395
+ type DurableObjectBindings = {
1396
+ /** The name of the binding used to refer to the Durable Object */
1397
+ name: string;
1398
+ /** The exported class name of the Durable Object */
1399
+ class_name: string;
1400
+ /** The script where the Durable Object is defined (if it's external to this Worker) */
1401
+ script_name?: string;
1402
+ /** The service environment of the script_name to bind to */
1403
+ environment?: string;
1404
+ }[];
1405
+ type WorkflowBinding = {
1406
+ /** The name of the binding used to refer to the Workflow */
1407
+ binding: string;
1408
+ /** The name of the Workflow */
1409
+ name: string;
1410
+ /** The exported class name of the Workflow */
1411
+ class_name: string;
1412
+ /** The script where the Workflow is defined (if it's external to this Worker) */
1413
+ script_name?: string;
1414
+ /** Whether the Workflow should be remote or not in local development */
1415
+ remote?: boolean;
1416
+ /** Optional limits for the Workflow */
1417
+ limits?: {
1418
+ /** Maximum number of steps a Workflow instance can execute */
1419
+ steps?: number;
1420
+ };
1421
+ };
1422
+ /**
1423
+ * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
1424
+ * that cannot be inherited from the top-level environment, and must be defined specifically.
1425
+ *
1426
+ * If any of these fields are defined at the top-level then they should also be specifically defined
1427
+ * for each named environment.
1428
+ */
1429
+ interface EnvironmentNonInheritable {
1430
+ /**
1431
+ * A map of values to substitute when deploying your Worker.
1432
+ *
1433
+ * NOTE: This field is not automatically inherited from the top level environment,
1434
+ * and so must be specified in every named environment.
1435
+ *
1436
+ * @default {}
1437
+ * @nonInheritable
1438
+ */
1439
+ define: Record<string, string>;
1440
+ /**
1441
+ * A map of environment variables to set when deploying your Worker.
1442
+ *
1443
+ * NOTE: This field is not automatically inherited from the top level environment,
1444
+ * and so must be specified in every named environment.
1445
+ *
1446
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
1447
+ *
1448
+ * @default {}
1449
+ * @nonInheritable
1450
+ */
1451
+ vars: Record<string, string | Json>;
1452
+ /**
1453
+ * Secrets configuration (experimental).
1454
+ *
1455
+ * NOTE: This field is not automatically inherited from the top level environment,
1456
+ * and so must be specified in every named environment.
1457
+ *
1458
+ * @nonInheritable
1459
+ */
1460
+ secrets?: {
1461
+ /**
1462
+ * List of secret names that are required by your Worker.
1463
+ * When defined, this property:
1464
+ * - Replaces .dev.vars/.env/process.env inference for type generation
1465
+ * - Enables local dev validation with warnings for missing secrets
1466
+ */
1467
+ required?: string[];
1468
+ };
1469
+ /**
1470
+ * A list of durable objects that your Worker should be bound to.
1471
+ *
1472
+ * For more information about Durable Objects, see the documentation at
1473
+ * https://developers.cloudflare.com/workers/learning/using-durable-objects
1474
+ *
1475
+ * NOTE: This field is not automatically inherited from the top level environment,
1476
+ * and so must be specified in every named environment.
1477
+ *
1478
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
1479
+ *
1480
+ * @default {bindings:[]}
1481
+ * @nonInheritable
1482
+ */
1483
+ durable_objects: {
1484
+ bindings: DurableObjectBindings;
1485
+ };
1486
+ /**
1487
+ * A list of workflows that your Worker should be bound to.
1488
+ *
1489
+ * NOTE: This field is not automatically inherited from the top level environment,
1490
+ * and so must be specified in every named environment.
1491
+ *
1492
+ * @default []
1493
+ * @nonInheritable
1494
+ */
1495
+ workflows: WorkflowBinding[];
1496
+ /**
1497
+ * Cloudchamber configuration
1498
+ *
1499
+ * NOTE: This field is not automatically inherited from the top level environment,
1500
+ * and so must be specified in every named environment.
1501
+ *
1502
+ * @default {}
1503
+ * @nonInheritable
1504
+ */
1505
+ cloudchamber: CloudchamberConfig;
1506
+ /**
1507
+ * Container related configuration
1508
+ *
1509
+ * NOTE: This field is not automatically inherited from the top level environment,
1510
+ * and so must be specified in every named environment.
1511
+ *
1512
+ * @default []
1513
+ * @nonInheritable
1514
+ */
1515
+ containers?: ContainerApp[];
1516
+ /**
1517
+ * These specify any Workers KV Namespaces you want to
1518
+ * access from inside your Worker.
1519
+ *
1520
+ * To learn more about KV Namespaces,
1521
+ * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
1522
+ *
1523
+ * NOTE: This field is not automatically inherited from the top level environment,
1524
+ * and so must be specified in every named environment.
1525
+ *
1526
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
1527
+ *
1528
+ * @default []
1529
+ * @nonInheritable
1530
+ */
1531
+ kv_namespaces: {
1532
+ /** The binding name used to refer to the KV Namespace */
1533
+ binding: string;
1534
+ /** The ID of the KV namespace */
1535
+ id?: string;
1536
+ /** The ID of the KV namespace used during `wrangler dev` */
1537
+ preview_id?: string;
1538
+ /** Whether the KV namespace should be remote or not in local development */
1539
+ remote?: boolean;
1540
+ }[];
1541
+ /**
1542
+ * These specify bindings to send email from inside your Worker.
1543
+ *
1544
+ * NOTE: This field is not automatically inherited from the top level environment,
1545
+ * and so must be specified in every named environment.
1546
+ *
1547
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings
1548
+ *
1549
+ * @default []
1550
+ * @nonInheritable
1551
+ */
1552
+ send_email: {
1553
+ /** The binding name used to refer to the this binding */
1554
+ name: string;
1555
+ /** If this binding should be restricted to a specific verified address */
1556
+ destination_address?: string;
1557
+ /** If this binding should be restricted to a set of verified addresses */
1558
+ allowed_destination_addresses?: string[];
1559
+ /** If this binding should be restricted to a set of sender addresses */
1560
+ allowed_sender_addresses?: string[];
1561
+ /** Whether the binding should be remote or not in local development */
1562
+ remote?: boolean;
1563
+ }[];
1564
+ /**
1565
+ * Specifies Queues that are bound to this Worker environment.
1566
+ *
1567
+ * NOTE: This field is not automatically inherited from the top level environment,
1568
+ * and so must be specified in every named environment.
1569
+ *
1570
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#queues
1571
+ *
1572
+ * @default {consumers:[],producers:[]}
1573
+ * @nonInheritable
1574
+ */
1575
+ queues: {
1576
+ /** Producer bindings */
1577
+ producers?: {
1578
+ /** The binding name used to refer to the Queue in the Worker. */
1579
+ binding: string;
1580
+ /** The name of this Queue. */
1581
+ queue: string;
1582
+ /** The number of seconds to wait before delivering a message */
1583
+ delivery_delay?: number;
1584
+ /** Whether the Queue producer should be remote or not in local development */
1585
+ remote?: boolean;
1586
+ }[];
1587
+ /** Consumer configuration */
1588
+ consumers?: {
1589
+ /** The name of the queue from which this consumer should consume. */
1590
+ queue: string;
1591
+ /** The consumer type, e.g., worker, http-pull, r2-bucket, etc. Default is worker. */
1592
+ type?: string;
1593
+ /** The maximum number of messages per batch */
1594
+ max_batch_size?: number;
1595
+ /** The maximum number of seconds to wait to fill a batch with messages. */
1596
+ max_batch_timeout?: number;
1597
+ /** The maximum number of retries for each message. */
1598
+ max_retries?: number;
1599
+ /** The queue to send messages that failed to be consumed. */
1600
+ dead_letter_queue?: string;
1601
+ /** 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. */
1602
+ max_concurrency?: number | null;
1603
+ /** The number of milliseconds to wait for pulled messages to become visible again */
1604
+ visibility_timeout_ms?: number;
1605
+ /** The number of seconds to wait before retrying a message */
1606
+ retry_delay?: number;
1607
+ }[];
1608
+ };
1609
+ /**
1610
+ * Specifies R2 buckets that are bound to this Worker environment.
1611
+ *
1612
+ * NOTE: This field is not automatically inherited from the top level environment,
1613
+ * and so must be specified in every named environment.
1614
+ *
1615
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
1616
+ *
1617
+ * @default []
1618
+ * @nonInheritable
1619
+ */
1620
+ r2_buckets: {
1621
+ /** The binding name used to refer to the R2 bucket in the Worker. */
1622
+ binding: string;
1623
+ /** The name of this R2 bucket at the edge. */
1624
+ bucket_name?: string;
1625
+ /** The preview name of this R2 bucket at the edge. */
1626
+ preview_bucket_name?: string;
1627
+ /** The jurisdiction that the bucket exists in. Default if not present. */
1628
+ jurisdiction?: string;
1629
+ /** Whether the R2 bucket should be remote or not in local development */
1630
+ remote?: boolean;
1631
+ }[];
1632
+ /**
1633
+ * Specifies D1 databases that are bound to this Worker environment.
1634
+ *
1635
+ * NOTE: This field is not automatically inherited from the top level environment,
1636
+ * and so must be specified in every named environment.
1637
+ *
1638
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
1639
+ *
1640
+ * @default []
1641
+ * @nonInheritable
1642
+ */
1643
+ d1_databases: {
1644
+ /** The binding name used to refer to the D1 database in the Worker. */
1645
+ binding: string;
1646
+ /** The name of this D1 database. */
1647
+ database_name?: string;
1648
+ /** The UUID of this D1 database (not required). */
1649
+ database_id?: string;
1650
+ /** The UUID of this D1 database for Wrangler Dev (if specified). */
1651
+ preview_database_id?: string;
1652
+ /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
1653
+ migrations_table?: string;
1654
+ /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
1655
+ migrations_dir?: string;
1656
+ /** Internal use only. */
1657
+ database_internal_env?: string;
1658
+ /** Whether the D1 database should be remote or not in local development */
1659
+ remote?: boolean;
1660
+ }[];
1661
+ /**
1662
+ * Specifies Vectorize indexes that are bound to this Worker environment.
1663
+ *
1664
+ * NOTE: This field is not automatically inherited from the top level environment,
1665
+ * and so must be specified in every named environment.
1666
+ *
1667
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
1668
+ *
1669
+ * @default []
1670
+ * @nonInheritable
1671
+ */
1672
+ vectorize: {
1673
+ /** The binding name used to refer to the Vectorize index in the Worker. */
1674
+ binding: string;
1675
+ /** The name of the index. */
1676
+ index_name: string;
1677
+ /** Whether the Vectorize index should be remote or not in local development */
1678
+ remote?: boolean;
1679
+ }[];
1680
+ /**
1681
+ * Specifies Hyperdrive configs that are bound to this Worker environment.
1682
+ *
1683
+ * NOTE: This field is not automatically inherited from the top level environment,
1684
+ * and so must be specified in every named environment.
1685
+ *
1686
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
1687
+ *
1688
+ * @default []
1689
+ * @nonInheritable
1690
+ */
1691
+ hyperdrive: {
1692
+ /** The binding name used to refer to the project in the Worker. */
1693
+ binding: string;
1694
+ /** The id of the database. */
1695
+ id: string;
1696
+ /** The local database connection string for `wrangler dev` */
1697
+ localConnectionString?: string;
1698
+ }[];
1699
+ /**
1700
+ * Specifies service bindings (Worker-to-Worker) that are bound to this Worker environment.
1701
+ *
1702
+ * NOTE: This field is not automatically inherited from the top level environment,
1703
+ * and so must be specified in every named environment.
1704
+ *
1705
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
1706
+ *
1707
+ * @default []
1708
+ * @nonInheritable
1709
+ */
1710
+ services: {
1711
+ /** The binding name used to refer to the bound service. */
1712
+ binding: string;
1713
+ /**
1714
+ * The name of the service.
1715
+ * To bind to a worker in a specific environment,
1716
+ * you should use the format `<worker_name>-<environment_name>`.
1717
+ */
1718
+ service: string;
1719
+ /**
1720
+ * @hidden
1721
+ * @deprecated you should use `service: <worker_name>-<environment_name>` instead.
1722
+ * This refers to the deprecated concept of 'service environments'.
1723
+ * The environment of the service (e.g. production, staging, etc).
1724
+ */
1725
+ environment?: string;
1726
+ /** Optionally, the entrypoint (named export) of the service to bind to. */
1727
+ entrypoint?: string;
1728
+ /** Optional properties that will be made available to the service via ctx.props. */
1729
+ props?: Record<string, unknown>;
1730
+ /** Whether the service binding should be remote or not in local development */
1731
+ remote?: boolean;
1732
+ }[] | undefined;
1733
+ /**
1734
+ * Specifies analytics engine datasets that are bound to this Worker environment.
1735
+ *
1736
+ * NOTE: This field is not automatically inherited from the top level environment,
1737
+ * and so must be specified in every named environment.
1738
+ *
1739
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
1740
+ *
1741
+ * @default []
1742
+ * @nonInheritable
1743
+ */
1744
+ analytics_engine_datasets: {
1745
+ /** The binding name used to refer to the dataset in the Worker. */
1746
+ binding: string;
1747
+ /** The name of this dataset to write to. */
1748
+ dataset?: string;
1749
+ }[];
1750
+ /**
1751
+ * A browser that will be usable from the Worker.
1752
+ *
1753
+ * NOTE: This field is not automatically inherited from the top level environment,
1754
+ * and so must be specified in every named environment.
1755
+ *
1756
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
1757
+ *
1758
+ * @default {}
1759
+ * @nonInheritable
1760
+ */
1761
+ browser: {
1762
+ binding: string;
1763
+ /** Whether the Browser binding should be remote or not in local development */
1764
+ remote?: boolean;
1765
+ } | undefined;
1766
+ /**
1767
+ * Binding to the AI project.
1768
+ *
1769
+ * NOTE: This field is not automatically inherited from the top level environment,
1770
+ * and so must be specified in every named environment.
1771
+ *
1772
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
1773
+ *
1774
+ * @default {}
1775
+ * @nonInheritable
1776
+ */
1777
+ ai: {
1778
+ binding: string;
1779
+ staging?: boolean;
1780
+ /** Whether the AI binding should be remote or not in local development */
1781
+ remote?: boolean;
1782
+ } | undefined;
1783
+ /**
1784
+ * Binding to Cloudflare Images
1785
+ *
1786
+ * NOTE: This field is not automatically inherited from the top level environment,
1787
+ * and so must be specified in every named environment.
1788
+ *
1789
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#images
1790
+ *
1791
+ * @default {}
1792
+ * @nonInheritable
1793
+ */
1794
+ images: {
1795
+ binding: string;
1796
+ /** Whether the Images binding should be remote or not in local development */
1797
+ remote?: boolean;
1798
+ } | undefined;
1799
+ /**
1800
+ * Binding to Cloudflare Media Transformations
1801
+ *
1802
+ * NOTE: This field is not automatically inherited from the top level environment,
1803
+ * and so must be specified in every named environment.
1804
+ *
1805
+ * @default {}
1806
+ * @nonInheritable
1807
+ */
1808
+ media: {
1809
+ binding: string;
1810
+ /** Whether the Media binding should be remote or not */
1811
+ remote?: boolean;
1812
+ } | undefined;
1813
+ /**
1814
+ * Binding to the Worker Version's metadata
1815
+ */
1816
+ version_metadata: {
1817
+ binding: string;
1818
+ } | undefined;
1819
+ /**
1820
+ * "Unsafe" tables for features that aren't directly supported by wrangler.
1821
+ *
1822
+ * NOTE: This field is not automatically inherited from the top level environment,
1823
+ * and so must be specified in every named environment.
1824
+ *
1825
+ * @default {}
1826
+ * @nonInheritable
1827
+ */
1828
+ unsafe: {
1829
+ /**
1830
+ * A set of bindings that should be put into a Worker's upload metadata without changes. These
1831
+ * can be used to implement bindings for features that haven't released and aren't supported
1832
+ * directly by wrangler or miniflare.
1833
+ */
1834
+ bindings?: UnsafeBinding[];
1835
+ /**
1836
+ * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
1837
+ * here will always be applied to metadata last, so can add new or override existing fields.
1838
+ */
1839
+ metadata?: {
1840
+ [key: string]: unknown;
1841
+ };
1842
+ /**
1843
+ * Used for internal capnp uploads for the Workers runtime
1844
+ */
1845
+ capnp?: {
1846
+ base_path: string;
1847
+ source_schemas: string[];
1848
+ compiled_schema?: never;
1849
+ } | {
1850
+ base_path?: never;
1851
+ source_schemas?: never;
1852
+ compiled_schema: string;
1853
+ };
1854
+ };
1855
+ /**
1856
+ * Specifies a list of mTLS certificates that are bound to this Worker environment.
1857
+ *
1858
+ * NOTE: This field is not automatically inherited from the top level environment,
1859
+ * and so must be specified in every named environment.
1860
+ *
1861
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
1862
+ *
1863
+ * @default []
1864
+ * @nonInheritable
1865
+ */
1866
+ mtls_certificates: {
1867
+ /** The binding name used to refer to the certificate in the Worker */
1868
+ binding: string;
1869
+ /** The uuid of the uploaded mTLS certificate */
1870
+ certificate_id: string;
1871
+ /** Whether the mtls fetcher should be remote or not in local development */
1872
+ remote?: boolean;
1873
+ }[];
1874
+ /**
1875
+ * Specifies a list of Tail Workers that are bound to this Worker environment
1876
+ *
1877
+ * NOTE: This field is not automatically inherited from the top level environment,
1878
+ * and so must be specified in every named environment.
1879
+ *
1880
+ * @default []
1881
+ * @nonInheritable
1882
+ */
1883
+ tail_consumers?: TailConsumer[];
1884
+ /**
1885
+ * Specifies a list of Streaming Tail Workers that are bound to this Worker environment
1886
+ *
1887
+ * NOTE: This field is not automatically inherited from the top level environment,
1888
+ * and so must be specified in every named environment.
1889
+ *
1890
+ * @default []
1891
+ * @nonInheritable
1892
+ */
1893
+ streaming_tail_consumers?: StreamingTailConsumer[];
1894
+ /**
1895
+ * Specifies namespace bindings that are bound to this Worker environment.
1896
+ *
1897
+ * NOTE: This field is not automatically inherited from the top level environment,
1898
+ * and so must be specified in every named environment.
1899
+ *
1900
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
1901
+ *
1902
+ * @default []
1903
+ * @nonInheritable
1904
+ */
1905
+ dispatch_namespaces: {
1906
+ /** The binding name used to refer to the bound service. */
1907
+ binding: string;
1908
+ /** The namespace to bind to. */
1909
+ namespace: string;
1910
+ /** Details about the outbound Worker which will handle outbound requests from your namespace */
1911
+ outbound?: DispatchNamespaceOutbound;
1912
+ /** Whether the Dispatch Namespace should be remote or not in local development */
1913
+ remote?: boolean;
1914
+ }[];
1915
+ /**
1916
+ * Specifies list of Pipelines bound to this Worker environment
1917
+ *
1918
+ * NOTE: This field is not automatically inherited from the top level environment,
1919
+ * and so must be specified in every named environment.
1920
+ *
1921
+ * @default []
1922
+ * @nonInheritable
1923
+ */
1924
+ pipelines: {
1925
+ /** The binding name used to refer to the bound service. */
1926
+ binding: string;
1927
+ /** Name of the Pipeline to bind */
1928
+ pipeline: string;
1929
+ /** Whether the pipeline should be remote or not in local development */
1930
+ remote?: boolean;
1931
+ }[];
1932
+ /**
1933
+ * Specifies Secret Store bindings that are bound to this Worker environment.
1934
+ *
1935
+ * NOTE: This field is not automatically inherited from the top level environment,
1936
+ * and so must be specified in every named environment.
1937
+ *
1938
+ * @default []
1939
+ * @nonInheritable
1940
+ */
1941
+ secrets_store_secrets: {
1942
+ /** The binding name used to refer to the bound service. */
1943
+ binding: string;
1944
+ /** Id of the secret store */
1945
+ store_id: string;
1946
+ /** Name of the secret */
1947
+ secret_name: string;
1948
+ }[];
1949
+ /**
1950
+ * **DO NOT USE**. Hello World Binding Config to serve as an explanatory example.
1951
+ *
1952
+ * NOTE: This field is not automatically inherited from the top level environment,
1953
+ * and so must be specified in every named environment.
1954
+ *
1955
+ * @default []
1956
+ * @nonInheritable
1957
+ */
1958
+ unsafe_hello_world: {
1959
+ /** The binding name used to refer to the bound service. */
1960
+ binding: string;
1961
+ /** Whether the timer is enabled */
1962
+ enable_timer?: boolean;
1963
+ }[];
1964
+ /**
1965
+ * Specifies rate limit bindings that are bound to this Worker environment.
1966
+ *
1967
+ * NOTE: This field is not automatically inherited from the top level environment,
1968
+ * and so must be specified in every named environment.
1969
+ *
1970
+ * @default []
1971
+ * @nonInheritable
1972
+ */
1973
+ ratelimits: {
1974
+ /** The binding name used to refer to the rate limiter in the Worker. */
1975
+ name: string;
1976
+ /** The namespace ID for this rate limiter. */
1977
+ namespace_id: string;
1978
+ /** Simple rate limiting configuration. */
1979
+ simple: {
1980
+ /** The maximum number of requests allowed in the time period. */
1981
+ limit: number;
1982
+ /** The time period in seconds (10 for ten seconds, 60 for one minute). */
1983
+ period: 10 | 60;
1984
+ };
1985
+ }[];
1986
+ /**
1987
+ * Specifies Worker Loader bindings that are bound to this Worker environment.
1988
+ *
1989
+ * NOTE: This field is not automatically inherited from the top level environment,
1990
+ * and so must be specified in every named environment.
1991
+ *
1992
+ * @default []
1993
+ * @nonInheritable
1994
+ */
1995
+ worker_loaders: {
1996
+ /** The binding name used to refer to the Worker Loader in the Worker. */
1997
+ binding: string;
1998
+ }[];
1999
+ /**
2000
+ * Specifies VPC services that are bound to this Worker environment.
2001
+ *
2002
+ * NOTE: This field is not automatically inherited from the top level environment,
2003
+ * and so must be specified in every named environment.
2004
+ *
2005
+ * @default []
2006
+ * @nonInheritable
2007
+ */
2008
+ vpc_services: {
2009
+ /** The binding name used to refer to the VPC service in the Worker. */
2010
+ binding: string;
2011
+ /** The service ID of the VPC connectivity service. */
2012
+ service_id: string;
2013
+ /** Whether the VPC service is remote or not */
2014
+ remote?: boolean;
2015
+ }[];
2016
+ }
2017
+ /**
2018
+ * The raw environment configuration that we read from the config file.
2019
+ *
2020
+ * All the properties are optional, and will be replaced with defaults in the configuration that
2021
+ * is used in the rest of the codebase.
2022
+ */
2023
+ type RawEnvironment = Partial<Environment>;
2024
+ /**
2025
+ * A bundling resolver rule, defining the modules type for paths that match the specified globs.
2026
+ */
2027
+ type Rule = {
2028
+ type: ConfigModuleRuleType;
2029
+ globs: string[];
2030
+ fallthrough?: boolean;
2031
+ };
2032
+ /**
2033
+ * The possible types for a `Rule`.
2034
+ */
2035
+ type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data" | "PythonModule" | "PythonRequirement";
2036
+ type TailConsumer = {
2037
+ /** The name of the service tail events will be forwarded to. */
2038
+ service: string;
2039
+ /** (Optional) The environment of the service. */
2040
+ environment?: string;
2041
+ };
2042
+ type StreamingTailConsumer = {
2043
+ /** The name of the service streaming tail events will be forwarded to. */
2044
+ service: string;
2045
+ };
2046
+ interface DispatchNamespaceOutbound {
2047
+ /** Name of the service handling the outbound requests */
2048
+ service: string;
2049
+ /** (Optional) Name of the environment handling the outbound requests. */
2050
+ environment?: string;
2051
+ /** (Optional) List of parameter names, for sending context from your dispatch Worker to the outbound handler */
2052
+ parameters?: string[];
2053
+ }
2054
+ interface UserLimits {
2055
+ /** Maximum allowed CPU time for a Worker's invocation in milliseconds */
2056
+ cpu_ms?: number;
2057
+ /** Maximum allowed number of fetch requests that a Worker's invocation can execute */
2058
+ subrequests?: number;
2059
+ }
2060
+ type Assets = {
2061
+ /** Absolute path to assets directory */
2062
+ directory?: string;
2063
+ /** Name of `env` binding property in the User Worker. */
2064
+ binding?: string;
2065
+ /** How to handle HTML requests. */
2066
+ html_handling?: "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash" | "none";
2067
+ /** How to handle requests that do not match an asset. */
2068
+ not_found_handling?: "single-page-application" | "404-page" | "none";
2069
+ /**
2070
+ * Matches will be routed to the User Worker, and matches to negative rules will go to the Asset Worker.
2071
+ *
2072
+ * Can also be `true`, indicating that every request should be routed to the User Worker.
2073
+ */
2074
+ run_worker_first?: string[] | boolean;
2075
+ };
2076
+ interface Observability {
2077
+ /** If observability is enabled for this Worker */
2078
+ enabled?: boolean;
2079
+ /** The sampling rate */
2080
+ head_sampling_rate?: number;
2081
+ logs?: {
2082
+ enabled?: boolean;
2083
+ /** The sampling rate */
2084
+ head_sampling_rate?: number;
2085
+ /** Set to false to disable invocation logs */
2086
+ invocation_logs?: boolean;
2087
+ /**
2088
+ * If logs should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
2089
+ *
2090
+ * @default true
2091
+ */
2092
+ persist?: boolean;
2093
+ /**
2094
+ * What destinations logs emitted from the Worker should be sent to.
2095
+ *
2096
+ * @default []
2097
+ */
2098
+ destinations?: string[];
2099
+ };
2100
+ traces?: {
2101
+ enabled?: boolean;
2102
+ /** The sampling rate */
2103
+ head_sampling_rate?: number;
2104
+ /**
2105
+ * If traces should be persisted to the Cloudflare observability platform where they can be queried in the dashboard.
2106
+ *
2107
+ * @default true
2108
+ */
2109
+ persist?: boolean;
2110
+ /**
2111
+ * What destinations traces emitted from the Worker should be sent to.
2112
+ *
2113
+ * @default []
2114
+ */
2115
+ destinations?: string[];
2116
+ };
2117
+ }
2118
+ interface CacheOptions {
2119
+ /** If cache is enabled for this Worker */
2120
+ enabled: boolean;
2121
+ }
2122
+ type DockerConfiguration = {
2123
+ /** Socket used by miniflare to communicate with Docker */
2124
+ socketPath: string;
2125
+ /** Docker image name for the container egress interceptor sidecar */
2126
+ containerEgressInterceptorImage?: string;
2127
+ };
2128
+ type ContainerEngine = {
2129
+ localDocker: DockerConfiguration;
2130
+ } | string;
2131
+
2132
+ /**
2133
+ * This is the static type definition for the configuration object.
2134
+ *
2135
+ * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,
2136
+ * and optionally augment with arguments passed directly to wrangler.
2137
+ *
2138
+ * For more information about the configuration object, see the
2139
+ * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
2140
+ *
2141
+ * Notes:
2142
+ *
2143
+ * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
2144
+ * in the top level config and should not appear in any environments.
2145
+ * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects
2146
+ * - All top level fields in config and environments are optional in the Wrangler configuration file.
2147
+ *
2148
+ * Legend for the annotations:
2149
+ *
2150
+ * - `@breaking`: the deprecation/optionality is a breaking change from Wrangler v1.
2151
+ * - `@todo`: there's more work to be done (with details attached).
2152
+ */
2153
+ type Config = ComputedFields & ConfigFields<DevConfig> & PagesConfigFields & Environment;
2154
+ type RawConfig = Partial<ConfigFields<RawDevConfig>> & PagesConfigFields & RawEnvironment & EnvironmentMap & {
2155
+ $schema?: string;
2156
+ };
2157
+ interface ComputedFields {
2158
+ /** The path to the Wrangler configuration file (if any, and possibly redirected from the user Wrangler configuration) used to create this configuration. */
2159
+ configPath: string | undefined;
2160
+ /** 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. */
2161
+ userConfigPath: string | undefined;
2162
+ /**
2163
+ * The original top level name for the Worker in the raw configuration.
2164
+ *
2165
+ * When a raw configuration has been flattened to a single environment the worker name may have been replaced or transformed.
2166
+ * It can be useful to know what the top-level name was before the flattening.
2167
+ */
2168
+ topLevelName: string | undefined;
2169
+ /** A list of environment names declared in the raw configuration. */
2170
+ definedEnvironments: string[] | undefined;
2171
+ /** The name of the environment being targeted. */
2172
+ targetEnvironment: string | undefined;
2173
+ }
2174
+ interface ConfigFields<Dev extends RawDevConfig> {
2175
+ /**
2176
+ * A boolean to enable "legacy" style wrangler environments (from Wrangler v1).
2177
+ * These have been superseded by Services, but there may be projects that won't
2178
+ * (or can't) use them. If you're using a legacy environment, you can set this
2179
+ * to `true` to enable it.
2180
+ */
2181
+ legacy_env: boolean;
2182
+ /**
2183
+ * Whether Wrangler should send usage metrics to Cloudflare for this project.
2184
+ *
2185
+ * When defined this will override any user settings.
2186
+ * Otherwise, Wrangler will use the user's preference.
2187
+ */
2188
+ send_metrics: boolean | undefined;
2189
+ /**
2190
+ * Options to configure the development server that your worker will use.
2191
+ *
2192
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#local-development-settings
2193
+ */
2194
+ dev: Dev;
2195
+ /**
2196
+ * The definition of a Worker Site, a feature that lets you upload
2197
+ * static assets with your Worker.
2198
+ *
2199
+ * More details at https://developers.cloudflare.com/workers/platform/sites
2200
+ *
2201
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#workers-sites
2202
+ */
2203
+ site: {
2204
+ /**
2205
+ * The directory containing your static assets.
2206
+ *
2207
+ * It must be a path relative to your Wrangler configuration file.
2208
+ * Example: bucket = "./public"
2209
+ *
2210
+ * If there is a `site` field then it must contain this `bucket` field.
2211
+ */
2212
+ bucket: string;
2213
+ /**
2214
+ * The location of your Worker script.
2215
+ *
2216
+ * @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.
2217
+ * @breaking
2218
+ */
2219
+ "entry-point"?: string;
2220
+ /**
2221
+ * An exclusive list of .gitignore-style patterns that match file
2222
+ * or directory names from your bucket location. Only matched
2223
+ * items will be uploaded. Example: include = ["upload_dir"]
2224
+ *
2225
+ * @optional
2226
+ * @default []
2227
+ */
2228
+ include?: string[];
2229
+ /**
2230
+ * A list of .gitignore-style patterns that match files or
2231
+ * directories in your bucket that should be excluded from
2232
+ * uploads. Example: exclude = ["ignore_dir"]
2233
+ *
2234
+ * @optional
2235
+ * @default []
2236
+ */
2237
+ exclude?: string[];
2238
+ } | undefined;
2239
+ /**
2240
+ * A list of wasm modules that your worker should be bound to. This is
2241
+ * the "legacy" way of binding to a wasm module. ES module workers should
2242
+ * do proper module imports.
2243
+ */
2244
+ wasm_modules: {
2245
+ [key: string]: string;
2246
+ } | undefined;
2247
+ /**
2248
+ * A list of text files that your worker should be bound to. This is
2249
+ * the "legacy" way of binding to a text file. ES module workers should
2250
+ * do proper module imports.
2251
+ */
2252
+ text_blobs: {
2253
+ [key: string]: string;
2254
+ } | undefined;
2255
+ /**
2256
+ * A list of data files that your worker should be bound to. This is
2257
+ * the "legacy" way of binding to a data file. ES module workers should
2258
+ * do proper module imports.
2259
+ */
2260
+ data_blobs: {
2261
+ [key: string]: string;
2262
+ } | undefined;
2263
+ /**
2264
+ * A map of module aliases. Lets you swap out a module for any others.
2265
+ * Corresponds with esbuild's `alias` config
2266
+ *
2267
+ * For reference, see https://developers.cloudflare.com/workers/wrangler/configuration/#module-aliasing
2268
+ */
2269
+ alias: {
2270
+ [key: string]: string;
2271
+ } | undefined;
2272
+ /**
2273
+ * By default, the Wrangler configuration file is the source of truth for your environment configuration, like a terraform file.
2274
+ *
2275
+ * If you change your vars in the dashboard, wrangler *will* override/delete them on its next deploy.
2276
+ *
2277
+ * If you want to keep your dashboard vars when wrangler deploys, set this field to true.
2278
+ *
2279
+ * @default false
2280
+ * @nonInheritable
2281
+ */
2282
+ keep_vars?: boolean;
2283
+ }
2284
+ interface PagesConfigFields {
2285
+ /**
2286
+ * The directory of static assets to serve.
2287
+ *
2288
+ * The presence of this field in a Wrangler configuration file indicates a Pages project,
2289
+ * and will prompt the handling of the configuration file according to the
2290
+ * Pages-specific validation rules.
2291
+ */
2292
+ pages_build_output_dir?: string;
2293
+ }
2294
+ interface DevConfig {
2295
+ /**
2296
+ * IP address for the local dev server to listen on,
2297
+ *
2298
+ * @default localhost
2299
+ */
2300
+ ip: string;
2301
+ /**
2302
+ * Port for the local dev server to listen on
2303
+ *
2304
+ * @default 8787
2305
+ */
2306
+ port: number | undefined;
2307
+ /**
2308
+ * Port for the local dev server's inspector to listen on
2309
+ *
2310
+ * @default 9229
2311
+ */
2312
+ inspector_port: number | undefined;
2313
+ /**
2314
+ * IP address for the local dev server's inspector to listen on
2315
+ *
2316
+ * @default 127.0.0.1
2317
+ */
2318
+ inspector_ip: string | undefined;
2319
+ /**
2320
+ * Protocol that local wrangler dev server listens to requests on.
2321
+ *
2322
+ * @default http
2323
+ */
2324
+ local_protocol: "http" | "https";
2325
+ /**
2326
+ * Protocol that wrangler dev forwards requests on
2327
+ *
2328
+ * Setting this to `http` is not currently implemented for remote mode.
2329
+ * See https://github.com/cloudflare/workers-sdk/issues/583
2330
+ *
2331
+ * @default https
2332
+ */
2333
+ upstream_protocol: "https" | "http";
2334
+ /**
2335
+ * Host to forward requests to, defaults to the host of the first route of project
2336
+ */
2337
+ host: string | undefined;
2338
+ /**
2339
+ * When developing, whether to build and connect to containers. This requires a Docker daemon to be running.
2340
+ * Defaults to `true`.
2341
+ *
2342
+ * @default true
2343
+ */
2344
+ enable_containers: boolean;
2345
+ /**
2346
+ * Either the Docker unix socket i.e. `unix:///var/run/docker.sock` or a full configuration.
2347
+ * Note that windows is only supported via WSL at the moment
2348
+ */
2349
+ container_engine: ContainerEngine | undefined;
2350
+ /**
2351
+ * Re-generate your worker types when your Wrangler configuration file changes.
2352
+ *
2353
+ * @default false
2354
+ */
2355
+ generate_types: boolean;
2356
+ }
2357
+ type RawDevConfig = Partial<DevConfig>;
2358
+ interface EnvironmentMap {
2359
+ /**
2360
+ * The `env` section defines overrides for the configuration for different environments.
2361
+ *
2362
+ * All environment fields can be specified at the top level of the config indicating the default environment settings.
2363
+ *
2364
+ * - Some fields are inherited and overridable in each environment.
2365
+ * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
2366
+ *
2367
+ * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
2368
+ *
2369
+ * @default {}
2370
+ */
2371
+ env?: {
2372
+ [envName: string]: RawEnvironment;
2373
+ };
2374
+ }
2375
+
2376
+ /**
2377
+ * A binding type for vars - plain_text, json, or secret_text.
2378
+ * Used as the return type for getVarsForDev.
2379
+ */
2380
+ type VarBinding = Extract<Binding, {
2381
+ type: "plain_text" | "json" | "secret_text";
2382
+ }>;
2383
+ /**
2384
+ * Get the Worker `vars` bindings for a `wrangler dev` instance of a Worker.
2385
+ *
2386
+ * The `vars` bindings can be specified in the Wrangler configuration file.
2387
+ * But "secret" `vars` are usually only provided at the server -
2388
+ * either by creating them in the Dashboard UI, or using the `wrangler secret` command.
2389
+ *
2390
+ * It is useful during development, to provide these types of variable locally.
2391
+ * When running `wrangler dev` we will look for a file called `.dev.vars`, situated
2392
+ * next to the User's Wrangler configuration file (or in the current working directory if there is no
2393
+ * Wrangler configuration). If the `--env <env>` option is set, we'll first look for
2394
+ * `.dev.vars.<env>`.
2395
+ *
2396
+ * If there are no `.dev.vars*` file, (and CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV is not "false")
2397
+ * we will look for `.env*` files in the same directory.
2398
+ * If the `envFiles` option is set, we'll look for the `.env` files at those paths instead of the defaults.
2399
+ *
2400
+ * Any values in these files (all formatted like `.env` files) will add to or override `vars`
2401
+ * bindings provided in the Wrangler configuration file.
2402
+ *
2403
+ * When `secrets` is defined in the config, only the declared secret keys are loaded from
2404
+ * `.dev.vars`/`.env`/`process.env`. All other keys in those files are excluded. A warning
2405
+ * is emitted for any required secrets that are missing.
2406
+ *
2407
+ * @param configPath - The path to the Wrangler configuration file, if defined.
2408
+ * @param envFiles - An array of paths to .env files to load; if `undefined` the default .env files will be used (see `getDefaultEnvFiles()`).
2409
+ * The `envFiles` paths are resolved against the directory of the Wrangler configuration file, if there is one, otherwise against the current working directory.
2410
+ * @param vars - The existing `vars` bindings from the Wrangler configuration.
2411
+ * @param env - The specific environment name (e.g., "staging") or `undefined` if no specific environment is set.
2412
+ * @param silent - If true, will not log any messages about the loaded .dev.vars files or .env files.
2413
+ * @param secrets - If defined, only the declared secret keys are loaded from `.dev.vars` or `.env`/`process.env`.
2414
+ * @returns The merged `vars` as typed bindings. Config vars are `plain_text`/`json`, while `.dev.vars`/`.env` vars are `secret_text`.
2415
+ */
2416
+ declare function getVarsForDev(configPath: string | undefined, envFiles: string[] | undefined, vars: Config$1["vars"], env: string | undefined, silent?: boolean, secrets?: Config$1["secrets"]): Record<string, VarBinding>;
2417
+
2418
+ interface PackageManager {
2419
+ type: "npm" | "yarn" | "pnpm" | "bun";
2420
+ npx: string;
2421
+ dlx: string[];
2422
+ lockFiles: string[];
2423
+ }
2424
+
2425
+ /** Makes a subset of properties in a type optional
2426
+ *
2427
+ * @example
2428
+ * - type A = { s: string, b: boolean, n: number }
2429
+ * - Optional<A, 'b'|'n'> = { s: string, b?: boolean, n?: number }
2430
+ */
2431
+ type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>;
2432
+
2433
+ type FrameworkInfo = {
2434
+ id: string;
2435
+ name: string;
2436
+ class: typeof Framework;
2437
+ };
2438
+
2439
+ type ConfigurationOptions = {
2440
+ outputDir: string;
2441
+ projectPath: string;
2442
+ workerName: string;
2443
+ dryRun: boolean;
2444
+ packageManager: PackageManager;
2445
+ isWorkspaceRoot: boolean;
2446
+ };
2447
+ type PackageJsonScriptsOverrides = {
2448
+ preview?: string;
2449
+ deploy?: string;
2450
+ typegen?: string;
2451
+ };
2452
+ type ConfigurationResults = {
2453
+ /** The wrangler configuration that the framework's `configure()` hook should generate. `null` if autoconfig should not create the wrangler file (in case an external tool already does that) */
2454
+ wranglerConfig: RawConfig$1 | null;
2455
+ packageJsonScriptsOverrides?: PackageJsonScriptsOverrides;
2456
+ buildCommandOverride?: string;
2457
+ deployCommandOverride?: string;
2458
+ versionCommandOverride?: string;
2459
+ };
2460
+ declare abstract class Framework {
2461
+ readonly id: string;
2462
+ readonly name: string;
2463
+ constructor(frameworkInfo: Pick<FrameworkInfo, "id" | "name">);
2464
+ isConfigured(_projectPath: string): boolean;
2465
+ abstract configure(options: ConfigurationOptions): Promise<ConfigurationResults> | ConfigurationResults;
2466
+ configurationDescription?: string;
2467
+ autoConfigSupported: boolean;
2468
+ }
2469
+
2470
+ type AutoConfigDetailsBase = {
2471
+ /** The name of the worker */
2472
+ workerName: string;
2473
+ /** The path to the project (defaults to cwd) */
2474
+ projectPath: string;
2475
+ /** The content of the project's package.json file (if any) */
2476
+ packageJson?: PackageJSON;
2477
+ /** Whether the project is already configured (no autoconfig required) */
2478
+ configured: boolean;
2479
+ /** Details about the detected framework. It can be a JS framework or 'Static' if no actual JS framework is used. */
2480
+ framework: Framework;
2481
+ /** The build command used to build the project (if any) */
2482
+ buildCommand?: string;
2483
+ /** The output directory (if no framework is used, points to the raw asset files) */
2484
+ outputDir: string;
2485
+ /** The detected package manager for the project */
2486
+ packageManager: PackageManager;
2487
+ /** Whether the current path is at the root of a workspace */
2488
+ isWorkspaceRoot?: boolean;
2489
+ };
2490
+ type AutoConfigDetailsForConfiguredProject = Optional<AutoConfigDetailsBase, "framework" | "outputDir"> & {
2491
+ configured: true;
2492
+ };
2493
+ type AutoConfigDetailsForNonConfiguredProject = AutoConfigDetailsBase & {
2494
+ configured: false;
2495
+ };
2496
+ type AutoConfigDetails = AutoConfigDetailsForConfiguredProject | AutoConfigDetailsForNonConfiguredProject;
2497
+ type AutoConfigOptions = {
2498
+ /** Whether to run autoconfig without actually applying any filesystem modification (default: false) */
2499
+ dryRun?: boolean;
2500
+ /**
2501
+ * Whether the build command should be run (default: true)
2502
+ *
2503
+ * Note: When `dryRun` is `true` the build command is never run.
2504
+ */
2505
+ runBuild?: boolean;
2506
+ /**
2507
+ * Whether the confirmation prompts should be skipped (default: false)
2508
+ *
2509
+ * Note: When `dryRun` is `true` the the confirmation prompts are always skipped.
2510
+ */
2511
+ skipConfirmations?: boolean;
2512
+ /**
2513
+ * Whether to install Wrangler during autoconfig
2514
+ */
2515
+ enableWranglerInstallation?: boolean;
2516
+ };
2517
+ type AutoConfigSummary = {
2518
+ scripts: Record<string, string>;
2519
+ wranglerInstall: boolean;
2520
+ wranglerConfig?: RawConfig$1;
2521
+ frameworkConfiguration?: string;
2522
+ outputDir: string;
2523
+ frameworkId?: string;
2524
+ buildCommand?: string;
2525
+ deployCommand?: string;
2526
+ versionCommand?: string;
2527
+ };
2528
+
2529
+ /**
2530
+ * Derives a valid worker name from a project directory.
2531
+ *
2532
+ * The name is determined by (in order of precedence):
2533
+ * 1. The WRANGLER_CI_OVERRIDE_NAME environment variable (for CI environments)
2534
+ * 2. The `name` field from package.json in the project directory
2535
+ * 3. The directory basename
2536
+ *
2537
+ * The resulting name is sanitized to be a valid worker name.
2538
+ *
2539
+ * @param projectPath The path to the project directory
2540
+ * @returns A valid worker name
2541
+ */
2542
+ declare function getWorkerNameFromProject(projectPath: string): string;
2543
+ declare function getDetailsForAutoConfig({ projectPath, wranglerConfig, }?: {
2544
+ projectPath?: string;
2545
+ wranglerConfig?: Config$1;
2546
+ }): Promise<AutoConfigDetails>;
2547
+
2548
+ /**
2549
+ * @deprecated use `getLocalWorkerdCompatibilityDate` from "@cloudflare/workers-utils" instead.
2550
+ *
2551
+ * We're keeping this function only not to break the vite plugin that relies on it, we should remove it as soon as possible.
2552
+ */
2553
+ declare function unstable_getDevCompatibilityDate(): `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
2554
+
2555
+ /**
2556
+ * Options for the `getPlatformProxy` utility
2557
+ */
2558
+ type GetPlatformProxyOptions = {
2559
+ /**
2560
+ * The name of the environment to use
2561
+ */
2562
+ environment?: string;
2563
+ /**
2564
+ * The path to the config file to use.
2565
+ * If no path is specified the default behavior is to search from the
2566
+ * current directory up the filesystem for a Wrangler configuration file to use.
2567
+ *
2568
+ * Note: this field is optional but if a path is specified it must
2569
+ * point to a valid file on the filesystem
2570
+ */
2571
+ configPath?: string;
2572
+ /**
2573
+ * Paths to `.env` files to load environment variables from, relative to the project directory.
2574
+ *
2575
+ * The project directory is computed as the directory containing `configPath` or the current working directory if `configPath` is undefined.
2576
+ *
2577
+ * If `envFiles` is defined, only the files in the array will be considered for loading local dev variables.
2578
+ * If `undefined`, the default behavior is:
2579
+ * - compute the project directory as that containing the Wrangler configuration file,
2580
+ * or the current working directory if no Wrangler configuration file is specified.
2581
+ * - look for `.env` and `.env.local` files in the project directory.
2582
+ * - if the `environment` option is specified, also look for `.env.<environment>` and `.env.<environment>.local`
2583
+ * files in the project directory
2584
+ * - resulting in an `envFiles` array like: `[".env", ".env.local", ".env.<environment>", ".env.<environment>.local"]`.
2585
+ *
2586
+ * The values from files earlier in the `envFiles` array (e.g. `envFiles[x]`) will be overridden by values from files later in the array (e.g. `envFiles[x+1)`).
2587
+ */
2588
+ envFiles?: string[];
2589
+ /**
2590
+ * Indicates if and where to persist the bindings data, if not present or `true` it defaults to the same location
2591
+ * used by wrangler: `.wrangler/state/v3` (so that the same data can be easily used by the caller and wrangler).
2592
+ * If `false` is specified no data is persisted on the filesystem.
2593
+ */
2594
+ persist?: boolean | {
2595
+ path: string;
2596
+ };
2597
+ /**
2598
+ * Whether remote bindings should be enabled or not (defaults to `true`)
2599
+ */
2600
+ remoteBindings?: boolean;
2601
+ };
2602
+ /**
2603
+ * Result of the `getPlatformProxy` utility
2604
+ */
2605
+ type PlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties> = {
2606
+ /**
2607
+ * Environment object containing the various Cloudflare bindings
2608
+ */
2609
+ env: Env;
2610
+ /**
2611
+ * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
2612
+ */
2613
+ cf: CfProperties;
2614
+ /**
2615
+ * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
2616
+ */
2617
+ ctx: ExecutionContext;
2618
+ /**
2619
+ * Caches object emulating the Workers Cache runtime API
2620
+ */
2621
+ caches: CacheStorage;
2622
+ /**
2623
+ * Function used to dispose of the child process providing the bindings implementation
2624
+ */
2625
+ dispose: () => Promise<void>;
2626
+ };
2627
+ /**
2628
+ * By reading from a Wrangler configuration file this function generates proxy objects that can be
2629
+ * used to simulate the interaction with the Cloudflare platform during local development
2630
+ * in a Node.js environment
2631
+ *
2632
+ * @param options The various options that can tweak this function's behavior
2633
+ * @returns An Object containing the generated proxies alongside other related utilities
2634
+ */
2635
+ declare function getPlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties>(options?: GetPlatformProxyOptions): Promise<PlatformProxy<Env, CfProperties>>;
2636
+ type SourcelessWorkerOptions = Omit<WorkerOptions, "script" | "scriptPath" | "modules" | "modulesRoot"> & {
2637
+ modulesRules?: ModuleRule[];
2638
+ };
2639
+ interface Unstable_MiniflareWorkerOptions {
2640
+ workerOptions: SourcelessWorkerOptions;
2641
+ define: Record<string, string>;
2642
+ main?: string;
2643
+ externalWorkers: WorkerOptions[];
2644
+ }
2645
+ declare function unstable_getMiniflareWorkerOptions(configPath: string, env?: string, options?: {
2646
+ remoteProxyConnectionString?: RemoteProxyConnectionString;
2647
+ overrides?: {
2648
+ assets?: Partial<AssetsOptions>;
2649
+ enableContainers?: boolean;
2650
+ };
2651
+ containerBuildId?: string;
2652
+ }): Unstable_MiniflareWorkerOptions;
2653
+ declare function unstable_getMiniflareWorkerOptions(config: Config, env?: string, options?: {
2654
+ remoteProxyConnectionString?: RemoteProxyConnectionString;
2655
+ overrides?: {
2656
+ assets?: Partial<AssetsOptions>;
2657
+ enableContainers?: boolean;
2658
+ };
2659
+ containerBuildId?: string;
2660
+ }): Unstable_MiniflareWorkerOptions;
2661
+
2662
+ type StartRemoteProxySessionOptions = {
2663
+ workerName?: string;
2664
+ auth?: NonNullable<StartDevWorkerInput["dev"]>["auth"];
2665
+ /** If running in a non-public compliance region, set this here. */
2666
+ complianceRegion?: Config$1["compliance_region"];
2667
+ };
2668
+ declare function startRemoteProxySession(bindings: StartDevWorkerInput["bindings"], options?: StartRemoteProxySessionOptions): Promise<RemoteProxySession>;
2669
+ type RemoteProxySession = Pick<Worker, "ready" | "dispose"> & {
2670
+ updateBindings: (bindings: StartDevWorkerInput["bindings"]) => Promise<void>;
2671
+ remoteProxyConnectionString: RemoteProxyConnectionString;
2672
+ };
2673
+
2674
+ type WranglerConfigObject = {
2675
+ /** The path to the wrangler config file */
2676
+ path: string;
2677
+ /** The target environment */
2678
+ environment?: string;
2679
+ };
2680
+ type WorkerConfigObject = {
2681
+ /** The name of the worker */
2682
+ name?: string;
2683
+ /** The Worker's bindings */
2684
+ bindings: NonNullable<StartDevWorkerInput["bindings"]>;
2685
+ /** If running in a non-public compliance region, set this here. */
2686
+ complianceRegion?: Config$1["compliance_region"];
2687
+ /** Id of the account owning the worker */
2688
+ account_id?: Config$1["account_id"];
2689
+ };
2690
+ /**
2691
+ * Utility for potentially starting or updating a remote proxy session.
2692
+ *
2693
+ * @param wranglerOrWorkerConfigObject either a file path to a wrangler configuration file or an object containing the name of
2694
+ * the target worker alongside its bindings.
2695
+ * @param preExistingRemoteProxySessionData the optional data of a pre-existing remote proxy session if there was one, this
2696
+ * argument can be omitted or set to null if there is no pre-existing remote proxy session
2697
+ * @param auth the authentication information for establishing the remote proxy connection
2698
+ * @returns null if no existing remote proxy session was provided and one should not be created (because the worker is not
2699
+ * defining any remote bindings), the data associated to the created/updated remote proxy session otherwise.
2700
+ */
2701
+ declare function maybeStartOrUpdateRemoteProxySession(wranglerOrWorkerConfigObject: WranglerConfigObject | WorkerConfigObject, preExistingRemoteProxySessionData?: {
2702
+ session: RemoteProxySession;
2703
+ remoteBindings: Record<string, Binding>;
2704
+ auth?: CfAccount | undefined;
2705
+ } | null, auth?: CfAccount | undefined): Promise<{
2706
+ session: RemoteProxySession;
2707
+ remoteBindings: Record<string, Binding>;
2708
+ } | null>;
2709
+
2710
+ declare const LOGGER_LEVELS: {
2711
+ readonly none: -1;
2712
+ readonly error: 0;
2713
+ readonly warn: 1;
2714
+ readonly info: 2;
2715
+ readonly log: 3;
2716
+ readonly debug: 4;
2717
+ };
2718
+ type LoggerLevel = keyof typeof LOGGER_LEVELS;
2719
+ type TableRow<Keys extends string> = Record<Keys, string>;
2720
+ declare class Logger {
2721
+ #private;
2722
+ constructor();
2723
+ private overrideLoggerLevel?;
2724
+ private onceHistory;
2725
+ get loggerLevel(): "debug" | "none" | "error" | "info" | "log" | "warn";
2726
+ set loggerLevel(val: "debug" | "none" | "error" | "info" | "log" | "warn");
2727
+ resetLoggerLevel(): void;
2728
+ columns: number;
2729
+ json: (data: unknown) => void;
2730
+ debug: (...args: unknown[]) => void;
2731
+ debugWithSanitization: (label: string, ...args: unknown[]) => void;
2732
+ info: (...args: unknown[]) => void;
2733
+ log: (...args: unknown[]) => void;
2734
+ warn: (...args: unknown[]) => void;
2735
+ error(...args: unknown[]): void;
2736
+ error(error: ParseError): void;
2737
+ table<Keys extends string>(data: TableRow<Keys>[], options?: {
2738
+ wordWrap: boolean;
2739
+ head?: Keys[];
2740
+ }): void;
2741
+ console<M extends Exclude<keyof Console, "Console">>(method: M, ...args: Parameters<Console[M]>): void;
2742
+ get once(): {
2743
+ info: (...args: unknown[]) => void;
2744
+ log: (...args: unknown[]) => void;
2745
+ warn: (...args: unknown[]) => void;
2746
+ error: (...args: unknown[]) => void;
2747
+ };
2748
+ clearHistory(): void;
2749
+ doLogOnce(messageLevel: Exclude<LoggerLevel, "none">, args: unknown[]): void;
2750
+ private doLog;
2751
+ static registerBeforeLogHook(callback: (() => void) | undefined): void;
2752
+ static registerAfterLogHook(callback: (() => void) | undefined): void;
2753
+ private formatMessage;
2754
+ }
2755
+
2756
+ type PrintContext = {
2757
+ log?: (message: string) => void;
2758
+ registry?: WorkerRegistry | null;
2759
+ local?: boolean;
2760
+ isMultiWorker?: boolean;
2761
+ remoteBindingsDisabled?: boolean;
2762
+ name?: string;
2763
+ provisioning?: boolean;
2764
+ warnIfNoBindings?: boolean;
2765
+ unsafeMetadata?: Record<string, unknown>;
2766
+ };
2767
+ /**
2768
+ * Print all the bindings a worker would have access to.
2769
+ * Accepts StartDevWorkerInput["bindings"] format
2770
+ */
2771
+ declare function printBindings(bindings: StartDevWorkerInput["bindings"], tailConsumers?: CfTailConsumer[], streamingTailConsumers?: CfTailConsumer[], containers?: ContainerApp$1[], context?: PrintContext): void;
2772
+
2773
+ /**
2774
+ * Split an SQLQuery into an array of statements
2775
+ */
2776
+ declare function splitSqlQuery(sql: string): string[];
2777
+
2778
+ declare function runAutoConfig(autoConfigDetails: AutoConfigDetails, autoConfigOptions?: AutoConfigOptions): Promise<AutoConfigSummary>;
2779
+
2780
+ /**
2781
+ * Make a fetch request, and extract the `result` from the JSON response.
2782
+ */
2783
+ declare function fetchResult<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal, apiToken?: ApiCredentials): Promise<ResponseType>;
2784
+
2785
+ type ExperimentalFlags = {
2786
+ MULTIWORKER: boolean;
2787
+ RESOURCES_PROVISION: boolean;
2788
+ AUTOCREATE_RESOURCES: boolean;
2789
+ };
2790
+
2791
+ /**
2792
+ * Yargs options included in every wrangler command.
2793
+ */
2794
+ interface CommonYargsOptions {
2795
+ v: boolean | undefined;
2796
+ cwd: string | undefined;
2797
+ config: string | undefined;
2798
+ env: string | undefined;
2799
+ "env-file": string[] | undefined;
2800
+ "experimental-provision": boolean | undefined;
2801
+ "experimental-auto-create": boolean;
2802
+ }
2803
+ type CommonYargsArgv = Argv<CommonYargsOptions>;
2804
+ type RemoveIndex<T> = {
2805
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
2806
+ };
2807
+
2808
+ // Team names from https://wiki.cfdata.org/display/EW/Developer+Platform+Components+and+Pillar+Ownership
2809
+ type Teams =
2810
+ | "Workers: Onboarding & Integrations"
2811
+ | "Workers: Builds and Automation"
2812
+ | "Workers: Deploy and Config"
2813
+ | "Workers: Authoring and Testing"
2814
+ | "Workers: Frameworks and Runtime APIs"
2815
+ | "Workers: Runtime Platform"
2816
+ | "Workers: Workers Observability"
2817
+ | "Product: KV"
2818
+ | "Product: R2"
2819
+ | "Product: R2 Data Catalog"
2820
+ | "Product: R2 SQL"
2821
+ | "Product: D1"
2822
+ | "Product: Queues"
2823
+ | "Product: AI"
2824
+ | "Product: Hyperdrive"
2825
+ | "Product: Pipelines"
2826
+ | "Product: Vectorize"
2827
+ | "Product: Workflows"
2828
+ | "Product: Cloudchamber"
2829
+ | "Product: SSL"
2830
+ | "Product: WVPC"
2831
+ | "Product: Tunnels";
2832
+
2833
+ /** Convert literal string types like 'foo-bar' to 'FooBar' */
2834
+ type PascalCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${Capitalize<T>}${PascalCase<U>}` : Capitalize<S>;
2835
+ /** Convert literal string types like 'foo-bar' to 'fooBar' */
2836
+ type CamelCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${T}${PascalCase<U>}` : S;
2837
+ type CamelCaseKey<K extends PropertyKey> = K extends string ? Exclude<CamelCase<K>, ""> : K;
2838
+ type Alias<O extends Options | PositionalOptions> = O extends {
2839
+ alias: infer T;
2840
+ } ? T extends Exclude<string, T> ? {
2841
+ [key in T]: InferredOptionType<O>;
2842
+ } : {} : {};
2843
+ type StringKeyOf<T> = Extract<keyof T, string>;
2844
+ type DeepFlatten<T> = T extends object ? {
2845
+ [K in keyof T]: DeepFlatten<T[K]>;
2846
+ } : T;
2847
+ type MetadataCategory = "Account" | "Compute & AI" | "Storage & databases" | "Networking & security";
2848
+ type Command = `wrangler${string}`;
2849
+ type Metadata = {
2850
+ description: string;
2851
+ status: "experimental" | "alpha" | "private beta" | "open beta" | "stable";
2852
+ statusMessage?: string;
2853
+ deprecated?: boolean;
2854
+ deprecatedMessage?: string;
2855
+ hidden?: boolean;
2856
+ owner: Teams;
2857
+ /** Prints something at the bottom of the help */
2858
+ epilogue?: string;
2859
+ examples?: {
2860
+ command: string;
2861
+ description: string;
2862
+ }[];
2863
+ hideGlobalFlags?: string[];
2864
+ /**
2865
+ * Optional category for grouping commands in the help output.
2866
+ * Commands with the same category will be grouped together under a shared heading.
2867
+ * Commands without a category will appear under the default "COMMANDS" group.
2868
+ */
2869
+ category?: MetadataCategory;
2870
+ };
2871
+ type ArgDefinition = Omit<PositionalOptions, "type"> & Pick<Options, "hidden" | "requiresArg" | "deprecated" | "type">;
2872
+ type NamedArgDefinitions = {
2873
+ [key: string]: ArgDefinition;
2874
+ };
2875
+ type OnlyCamelCase<T = Record<string, never>> = {
2876
+ [key in keyof T as CamelCaseKey<key>]: T[key];
2877
+ };
2878
+ type HandlerArgs<Args extends NamedArgDefinitions> = DeepFlatten<OnlyCamelCase<RemoveIndex<ArgumentsCamelCase<CommonYargsOptions & InferredOptionTypes<Args> & Alias<Args>>>>>;
2879
+ type HandlerContext = {
2880
+ /**
2881
+ * The wrangler config file read from disk and parsed.
2882
+ */
2883
+ config: Config$1;
2884
+ /**
2885
+ * The logger instance provided to the command implementor as a convenience.
2886
+ */
2887
+ logger: Logger;
2888
+ /**
2889
+ * Use fetchResult to make *auth'd* requests to the Cloudflare API.
2890
+ */
2891
+ fetchResult: typeof fetchResult;
2892
+ /**
2893
+ * Error classes provided to the command implementor as a convenience
2894
+ * to aid discoverability and to encourage their usage.
2895
+ */
2896
+ errors: {
2897
+ UserError: typeof UserError;
2898
+ FatalError: typeof FatalError;
2899
+ };
2900
+ /**
2901
+ * API SDK
2902
+ */
2903
+ sdk: Cloudflare;
2904
+ };
2905
+ type CommandDefinition<NamedArgDefs extends NamedArgDefinitions = NamedArgDefinitions> = {
2906
+ /**
2907
+ * Descriptive information about the command which does not affect behaviour.
2908
+ * This is used for the CLI --help and subcommand --help output.
2909
+ * This should be used as the source-of-truth for status and ownership.
2910
+ */
2911
+ metadata: Metadata;
2912
+ /**
2913
+ * Controls shared behaviour across all commands.
2914
+ * This will allow wrangler commands to remain consistent and only diverge intentionally.
2915
+ */
2916
+ behaviour?: {
2917
+ /**
2918
+ * By default, wrangler's version banner will be printed before the handler is executed.
2919
+ * Set this value to `false` to skip printing the banner.
2920
+ *
2921
+ * @default true
2922
+ */
2923
+ printBanner?: boolean | ((args: HandlerArgs<NamedArgDefs>) => boolean);
2924
+ /**
2925
+ * Opt-in to printing a metrics banner for this command.
2926
+ * @default false
2927
+ */
2928
+ printMetricsBanner?: boolean;
2929
+ /**
2930
+ * By default, wrangler will print warnings about the Wrangler configuration file.
2931
+ * Set this value to `false` to skip printing these warnings.
2932
+ */
2933
+ printConfigWarnings?: boolean;
2934
+ /**
2935
+ * By default, wrangler will read & provide the wrangler.toml/wrangler.json configuration.
2936
+ * Set this value to `false` to skip this.
2937
+ */
2938
+ provideConfig?: boolean;
2939
+ /**
2940
+ * By default, wrangler will provide experimental flags in the handler context,
2941
+ * according to the default values in register-yargs.command.ts
2942
+ * Use this to override those defaults per command.
2943
+ */
2944
+ overrideExperimentalFlags?: (args: HandlerArgs<NamedArgDefs>) => ExperimentalFlags;
2945
+ /**
2946
+ * If true, then look for a redirect file at `.wrangler/deploy/config.json` and use that to find the Wrangler configuration file.
2947
+ */
2948
+ useConfigRedirectIfAvailable?: boolean;
2949
+ /**
2950
+ * If true, print a message about whether the command is operating on a local or remote resource
2951
+ */
2952
+ printResourceLocation?: ((args: HandlerArgs<NamedArgDefs>) => boolean) | boolean;
2953
+ /**
2954
+ * If true, check for environments in the wrangler config, if there are some and the user hasn't specified an environment
2955
+ * using the `-e|--env` cli flag, show a warning suggesting that one should instead be specified.
2956
+ */
2957
+ warnIfMultipleEnvsConfiguredButNoneSpecified?: boolean;
2958
+ /**
2959
+ * Opt out of sending metrics for this command
2960
+ * @default true
2961
+ */
2962
+ sendMetrics?: boolean;
2963
+ };
2964
+ /**
2965
+ * A plain key-value object describing the CLI args for this command.
2966
+ * Shared args can be defined as another plain object and spread into this.
2967
+ */
2968
+ args?: NamedArgDefs;
2969
+ /**
2970
+ * Optionally declare some of the named args as positional args.
2971
+ * The order of this array is the order they are expected in the command.
2972
+ * Use args[key].demandOption and args[key].array to declare required and variadic
2973
+ * positional args, respectively.
2974
+ */
2975
+ positionalArgs?: Array<StringKeyOf<NamedArgDefs>>;
2976
+ /**
2977
+ * A hook to implement custom validation of the args before the handler is called.
2978
+ * Throw `CommandLineArgsError` with actionable error message if args are invalid.
2979
+ * The return value is ignored.
2980
+ */
2981
+ validateArgs?: (args: HandlerArgs<NamedArgDefs>) => void | Promise<void>;
2982
+ /**
2983
+ * The implementation of the command which is given camelCase'd args
2984
+ * and a ctx object of convenience properties
2985
+ */
2986
+ handler: (args: HandlerArgs<NamedArgDefs>, ctx: HandlerContext) => void | Promise<void>;
2987
+ };
2988
+ type NamespaceDefinition = {
2989
+ metadata: Metadata;
2990
+ };
2991
+ type AliasDefinition = {
2992
+ aliasOf: Command;
2993
+ metadata?: Partial<Metadata>;
2994
+ };
2995
+ type InternalCommandDefinition = {
2996
+ type: "command";
2997
+ command: Command;
2998
+ } & CommandDefinition;
2999
+ type InternalNamespaceDefinition = {
3000
+ type: "namespace";
3001
+ command: Command;
3002
+ } & NamespaceDefinition;
3003
+ type InternalAliasDefinition = {
3004
+ type: "alias";
3005
+ command: Command;
3006
+ } & AliasDefinition;
3007
+ type InternalDefinition = InternalCommandDefinition | InternalNamespaceDefinition | InternalAliasDefinition;
3008
+ type DefinitionTreeNode = {
3009
+ definition?: InternalDefinition;
3010
+ subtree: DefinitionTree;
3011
+ };
3012
+ type DefinitionTree = Map<string, DefinitionTreeNode>;
3013
+
3014
+ type CreateCommandResult<NamedArgDefs extends NamedArgDefinitions> = DeepFlatten<{
3015
+ args: HandlerArgs<NamedArgDefs>;
3016
+ }>;
3017
+
3018
+ /**
3019
+ * Map of category names to the top-level command segments that belong to them.
3020
+ * Used for grouping commands in the help output.
3021
+ */
3022
+ type CategoryMap = Map<MetadataCategory, Array<string>>;
3023
+ /**
3024
+ * Class responsible for registering and managing commands within a command registry.
3025
+ */
3026
+ declare class CommandRegistry {
3027
+ #private;
3028
+ /**
3029
+ * Initializes the command registry with the given command registration function.
3030
+ */
3031
+ constructor(registerCommand: RegisterCommand);
3032
+ /**
3033
+ * Defines multiple commands and their corresponding definitions.
3034
+ */
3035
+ define(defs: {
3036
+ command: Command;
3037
+ definition: AliasDefinition | CreateCommandResult<NamedArgDefinitions> | NamespaceDefinition;
3038
+ }[]): void;
3039
+ getDefinitionTreeRoot(): DefinitionTreeNode;
3040
+ /**
3041
+ * Registers all commands in the command registry, walking through the definition tree.
3042
+ */
3043
+ registerAll(): void;
3044
+ /**
3045
+ * Registers a specific namespace if not already registered.
3046
+ * TODO: Remove this once all commands use the command registry.
3047
+ * See https://github.com/cloudflare/workers-sdk/pull/7357#discussion_r1862138470 for more details.
3048
+ */
3049
+ registerNamespace(namespace: string): void;
3050
+ /**
3051
+ * Get a set of all top-level command names.
3052
+ *
3053
+ * Includes both registry-defined commands & legacy commands.
3054
+ */
3055
+ get topLevelCommands(): Set<string>;
3056
+ /**
3057
+ * Returns the map of categories to command segments, ordered according to
3058
+ * the category order. Commands within each category are sorted alphabetically.
3059
+ * Used for grouping commands in the help output.
3060
+ */
3061
+ get orderedCategories(): CategoryMap;
3062
+ /**
3063
+ * Registers a legacy command that doesn't use the `CommandRegistry` class.
3064
+ * This is used for hidden commands like `cloudchamber` that use the old yargs pattern.
3065
+ */
3066
+ registerLegacyCommand(command: string): void;
3067
+ /**
3068
+ * Registers a category for a legacy command that doesn't use the CommandRegistry.
3069
+ * This is used for commands like `containers`, etc, that use the old yargs pattern.
3070
+ */
3071
+ registerLegacyCommandCategory(command: string, category: MetadataCategory): void;
3072
+ }
3073
+ /**
3074
+ * Type for the function used to register commands.
3075
+ */
3076
+ type RegisterCommand = (segment: string, def: InternalDefinition, registerSubTreeCallback: () => void) => void;
3077
+
3078
+ declare function createCLIParser(argv: string[]): {
3079
+ wrangler: CommonYargsArgv;
3080
+ registry: CommandRegistry;
3081
+ globalFlags: {
3082
+ readonly v: {
3083
+ readonly describe: "Show version number";
3084
+ readonly alias: "version";
3085
+ readonly type: "boolean";
3086
+ };
3087
+ readonly cwd: {
3088
+ readonly describe: "Run as if Wrangler was started in the specified directory instead of the current working directory";
3089
+ readonly type: "string";
3090
+ readonly requiresArg: true;
3091
+ };
3092
+ readonly config: {
3093
+ readonly alias: "c";
3094
+ readonly describe: "Path to Wrangler configuration file";
3095
+ readonly type: "string";
3096
+ readonly requiresArg: true;
3097
+ };
3098
+ readonly env: {
3099
+ readonly alias: "e";
3100
+ readonly describe: "Environment to use for operations, and for selecting .env and .dev.vars files";
3101
+ readonly type: "string";
3102
+ readonly requiresArg: true;
3103
+ };
3104
+ readonly "env-file": {
3105
+ readonly describe: "Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files";
3106
+ readonly type: "string";
3107
+ readonly array: true;
3108
+ readonly requiresArg: true;
3109
+ };
3110
+ readonly "experimental-provision": {
3111
+ readonly describe: "Experimental: Enable automatic resource provisioning";
3112
+ readonly type: "boolean";
3113
+ readonly default: true;
3114
+ readonly hidden: true;
3115
+ readonly alias: readonly ["x-provision"];
3116
+ };
3117
+ readonly "experimental-auto-create": {
3118
+ readonly describe: "Automatically provision draft bindings with new resources";
3119
+ readonly type: "boolean";
3120
+ readonly default: true;
3121
+ readonly hidden: true;
3122
+ readonly alias: "x-auto-create";
3123
+ };
3124
+ };
3125
+ showHelpWithCategories: () => Promise<void>;
3126
+ };
3127
+
3128
+ /**
3129
+ * EXPERIMENTAL: Get all registered Wrangler commands for documentation generation.
3130
+ * This API is experimental and may change without notice.
3131
+ *
3132
+ * @returns An object containing the command tree structure and global flags
3133
+ */
3134
+ declare function experimental_getWranglerCommands(): {
3135
+ registry: DefinitionTreeNode;
3136
+ globalFlags: ReturnType<typeof createCLIParser>["globalFlags"];
3137
+ };
3138
+
3139
+ /**
3140
+ * This file contains:
3141
+ *
3142
+ * - The main entrypoint for the CLI, which calls `main()` from `index.ts`.
3143
+ * - The exports for the public API of the package.
3144
+ */
3145
+
3146
+ interface Unstable_ASSETSBindingsOptions {
3147
+ log: Logger;
3148
+ proxyPort?: number;
3149
+ directory?: string;
3150
+ signal?: AbortSignal;
3151
+ }
3152
+ declare const unstable_generateASSETSBinding: (opts: Unstable_ASSETSBindingsOptions) => (request: Request) => Promise<Response$1>;
3153
+
3154
+ export { 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, 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, unstable_generateASSETSBinding, unstable_getDevCompatibilityDate, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, getWorkerNameFromProject as unstable_getWorkerNameFromProject, unstable_pages, printBindings as unstable_printBindings, readConfig as unstable_readConfig, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };