wrangler 4.28.0 → 4.29.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.28.0",
3
+ "version": "4.29.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -55,9 +55,9 @@
55
55
  "path-to-regexp": "6.3.0",
56
56
  "unenv": "2.0.0-rc.19",
57
57
  "workerd": "1.20250803.0",
58
- "miniflare": "4.20250803.0",
59
- "@cloudflare/unenv-preset": "2.6.0",
60
- "@cloudflare/kv-asset-handler": "0.4.0"
58
+ "@cloudflare/kv-asset-handler": "0.4.0",
59
+ "@cloudflare/unenv-preset": "2.6.1",
60
+ "miniflare": "4.20250803.1"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@aws-sdk/client-s3": "^3.721.0",
@@ -137,9 +137,9 @@
137
137
  "xxhash-wasm": "^1.0.1",
138
138
  "yargs": "^17.7.2",
139
139
  "@cloudflare/cli": "1.1.1",
140
- "@cloudflare/containers-shared": "0.2.8",
140
+ "@cloudflare/containers-shared": "0.2.9",
141
141
  "@cloudflare/eslint-config-worker": "1.1.0",
142
- "@cloudflare/pages-shared": "^0.13.60",
142
+ "@cloudflare/pages-shared": "^0.13.61",
143
143
  "@cloudflare/workers-shared": "0.18.5",
144
144
  "@cloudflare/workers-tsconfig": "0.0.0"
145
145
  },
@@ -1,12 +1,14 @@
1
1
  import { Json, Request, Response as Response$1, DispatchFetch, NodeJSCompatMode, Miniflare, MiniflareOptions, Mutex, WorkerOptions, ModuleRule, RemoteProxyConnectionString } from 'miniflare';
2
2
  import * as undici from 'undici';
3
3
  import { RequestInfo, RequestInit, Response, FormData } from 'undici';
4
+ import { CamelCaseKey, ArgumentsCamelCase, InferredOptionTypes, Alias, PositionalOptions, Options } from 'yargs';
4
5
  import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
5
6
  import { EventEmitter } from 'node:events';
6
7
  import Protocol from 'devtools-protocol/types/protocol-mapping';
7
8
  import { Metafile } from 'esbuild';
8
9
  import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
9
10
  import { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
11
+ import { URLSearchParams } from 'node:url';
10
12
 
11
13
  /**
12
14
  * The `Environment` interface declares all the configuration fields that
@@ -1284,6 +1286,25 @@ interface EnvironmentMap {
1284
1286
  [envName: string]: RawEnvironment;
1285
1287
  };
1286
1288
  }
1289
+ type OnlyCamelCase<T = Record<string, never>> = {
1290
+ [key in keyof T as CamelCaseKey<key>]: T[key];
1291
+ };
1292
+
1293
+ /**
1294
+ * Yargs options included in every wrangler command.
1295
+ */
1296
+ interface CommonYargsOptions {
1297
+ v: boolean | undefined;
1298
+ cwd: string | undefined;
1299
+ config: string | undefined;
1300
+ env: string | undefined;
1301
+ "env-file": string[] | undefined;
1302
+ "experimental-provision": boolean | undefined;
1303
+ "experimental-remote-bindings": boolean | undefined;
1304
+ }
1305
+ type RemoveIndex<T> = {
1306
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
1307
+ };
1287
1308
 
1288
1309
  type ResolveConfigPathOptions = {
1289
1310
  useRedirectIfAvailable?: boolean;
@@ -1395,6 +1416,15 @@ type CfSendEmailBindings = {
1395
1416
  } | {
1396
1417
  allowed_destination_addresses?: string[];
1397
1418
  });
1419
+ /**
1420
+ * A binding to the AI project
1421
+ */
1422
+ interface CfAIBinding {
1423
+ binding: string;
1424
+ staging?: boolean;
1425
+ experimental_remote?: boolean;
1426
+ raw?: boolean;
1427
+ }
1398
1428
  /**
1399
1429
  * A Durable Object.
1400
1430
  */
@@ -1768,6 +1798,11 @@ declare const unstable_pages: {
1768
1798
  deploy: typeof deploy;
1769
1799
  };
1770
1800
 
1801
+ /**
1802
+ * The compliance region to use for the API requests.
1803
+ */
1804
+ type ComplianceConfig = Partial<Pick<Config, "compliance_region">>;
1805
+
1771
1806
  type WorkerRegistry = Record<string, WorkerDefinition>;
1772
1807
  type WorkerEntrypointsDefinition = Record<"default" | string, {
1773
1808
  host: string;
@@ -1795,6 +1830,29 @@ type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
1795
1830
  params: _Params<Protocol.Events[Method]>;
1796
1831
  } : never;
1797
1832
 
1833
+ /**
1834
+ * This is used to provide telemetry with a sanitised error
1835
+ * message that could not have any user-identifying information.
1836
+ * Set to `true` to duplicate `message`.
1837
+ * */
1838
+ type TelemetryMessage = {
1839
+ telemetryMessage?: string | true;
1840
+ };
1841
+ /**
1842
+ * Base class for errors where the user has done something wrong. These are not
1843
+ * reported to Sentry. API errors are intentionally *not* `UserError`s, and are
1844
+ * reported to Sentry. This will help us understand which API errors need better
1845
+ * messaging.
1846
+ */
1847
+ declare class UserError extends Error {
1848
+ telemetryMessage: string | undefined;
1849
+ constructor(message?: string | undefined, options?: (ErrorOptions & TelemetryMessage) | undefined);
1850
+ }
1851
+ declare class FatalError extends UserError {
1852
+ readonly code?: number | undefined;
1853
+ constructor(message?: string, code?: number | undefined, options?: TelemetryMessage);
1854
+ }
1855
+
1798
1856
  type AssetsOptions = {
1799
1857
  directory: string;
1800
1858
  binding?: string;
@@ -2109,9 +2167,9 @@ type Binding = {
2109
2167
  source: File;
2110
2168
  } | {
2111
2169
  type: "browser";
2112
- } | {
2170
+ } | ({
2113
2171
  type: "ai";
2114
- } | {
2172
+ } & BindingOmit<CfAIBinding>) | {
2115
2173
  type: "images";
2116
2174
  } | {
2117
2175
  type: "version_metadata";
@@ -2545,6 +2603,7 @@ declare function unstable_getMiniflareWorkerOptions(configPath: string, env?: st
2545
2603
  remoteBindingsEnabled?: boolean;
2546
2604
  overrides?: {
2547
2605
  assets?: Partial<AssetsOptions>;
2606
+ enableContainers?: boolean;
2548
2607
  };
2549
2608
  containerBuildId?: string;
2550
2609
  }): Unstable_MiniflareWorkerOptions;
@@ -2554,6 +2613,7 @@ declare function unstable_getMiniflareWorkerOptions(config: Config, env?: string
2554
2613
  remoteBindingsEnabled?: boolean;
2555
2614
  overrides?: {
2556
2615
  assets?: Partial<AssetsOptions>;
2616
+ enableContainers?: boolean;
2557
2617
  };
2558
2618
  containerBuildId?: string;
2559
2619
  }): Unstable_MiniflareWorkerOptions;
@@ -2570,28 +2630,39 @@ type StartRemoteProxySessionOptions = {
2570
2630
  };
2571
2631
  declare function startRemoteProxySession(bindings: StartDevWorkerInput["bindings"], options?: StartRemoteProxySessionOptions): Promise<RemoteProxySession>;
2572
2632
  declare function pickRemoteBindings(bindings: Record<string, Binding>): Record<string, Binding>;
2633
+ type WranglerConfigObject = {
2634
+ /** The path to the wrangler config file */
2635
+ path: string;
2636
+ /** The target environment */
2637
+ environment?: string;
2638
+ };
2639
+ type WorkerConfigObject = {
2640
+ /** The name of the worker */
2641
+ name?: string;
2642
+ /** The Worker's bindings */
2643
+ bindings: NonNullable<StartDevWorkerInput["bindings"]>;
2644
+ /** If running in a non-public compliance region, set this here. */
2645
+ complianceRegion?: Config["compliance_region"];
2646
+ };
2573
2647
  /**
2574
2648
  * Utility for potentially starting or updating a remote proxy session.
2575
2649
  *
2576
2650
  * It uses an internal map for storing existing remote proxy session indexed by worker names. If no worker name is provided
2577
2651
  * the remote proxy session won't be retrieved nor saved to/from the internal map.
2578
2652
  *
2579
- * @param configPathOrWorkerConfig either a file path to a wrangler configuration file or an object containing the name of
2653
+ * @param wranglerOrWorkerConfigObject either a file path to a wrangler configuration file or an object containing the name of
2580
2654
  * the target worker alongside its bindings.
2581
2655
  * @param preExistingRemoteProxySessionData the optional data of a pre-existing remote proxy session if there was one, this
2582
2656
  * argument can be omitted or set to null if there is no pre-existing remote proxy session
2657
+ * @param auth the authentication information for establishing the remote proxy connection
2583
2658
  * @returns null if no existing remote proxy session was provided and one should not be created (because the worker is not
2584
2659
  * defining any remote bindings), the data associated to the created/updated remote proxy session otherwise.
2585
2660
  */
2586
- declare function maybeStartOrUpdateRemoteProxySession(configPathOrWorkerConfig: string | {
2587
- name?: string;
2588
- /** If running in a non-public compliance region, set this here. */
2589
- complianceRegion?: Config["compliance_region"];
2590
- bindings: NonNullable<StartDevWorkerInput["bindings"]>;
2591
- }, preExistingRemoteProxySessionData?: {
2661
+ declare function maybeStartOrUpdateRemoteProxySession(wranglerOrWorkerConfigObject: WranglerConfigObject | WorkerConfigObject, preExistingRemoteProxySessionData?: {
2592
2662
  session: RemoteProxySession;
2593
2663
  remoteBindings: Record<string, Binding>;
2594
- } | null): Promise<{
2664
+ auth?: CfAccount | undefined;
2665
+ } | null, auth?: CfAccount | undefined): Promise<{
2595
2666
  session: RemoteProxySession;
2596
2667
  remoteBindings: Record<string, Binding>;
2597
2668
  } | null>;
@@ -2654,6 +2725,191 @@ declare const experimental_patchConfig: (configPath: string,
2654
2725
  */
2655
2726
  patch: RawConfig, isArrayInsertion?: boolean) => string;
2656
2727
 
2728
+ /**
2729
+ * Make a fetch request, and extract the `result` from the JSON response.
2730
+ */
2731
+ declare function fetchResult<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal, apiToken?: ApiCredentials): Promise<ResponseType>;
2732
+
2733
+ type ExperimentalFlags = {
2734
+ MULTIWORKER: boolean;
2735
+ RESOURCES_PROVISION: boolean;
2736
+ REMOTE_BINDINGS: boolean;
2737
+ };
2738
+
2739
+ // Team names from https://wiki.cfdata.org/display/EW/Developer+Platform+Components+and+Pillar+Ownership
2740
+ type Teams =
2741
+ | "Workers: Onboarding & Integrations"
2742
+ | "Workers: Builds and Automation"
2743
+ | "Workers: Deploy and Config"
2744
+ | "Workers: Authoring and Testing"
2745
+ | "Workers: Frameworks and Runtime APIs"
2746
+ | "Workers: Runtime Platform"
2747
+ | "Workers: Workers Observability"
2748
+ | "Product: KV"
2749
+ | "Product: R2"
2750
+ | "Product: R2 Data Catalog"
2751
+ | "Product: D1"
2752
+ | "Product: Queues"
2753
+ | "Product: AI"
2754
+ | "Product: Hyperdrive"
2755
+ | "Product: Pipelines"
2756
+ | "Product: Vectorize"
2757
+ | "Product: Workflows"
2758
+ | "Product: Cloudchamber"
2759
+ | "Product: SSL";
2760
+
2761
+ type StringKeyOf<T> = Extract<keyof T, string>;
2762
+ type DeepFlatten<T> = T extends object ? {
2763
+ [K in keyof T]: DeepFlatten<T[K]>;
2764
+ } : T;
2765
+ type Command = `wrangler${string}`;
2766
+ type Metadata = {
2767
+ description: string;
2768
+ status: "experimental" | "alpha" | "private-beta" | "open-beta" | "stable";
2769
+ statusMessage?: string;
2770
+ deprecated?: boolean;
2771
+ deprecatedMessage?: string;
2772
+ hidden?: boolean;
2773
+ owner: Teams;
2774
+ /** Prints something at the bottom of the help */
2775
+ epilogue?: string;
2776
+ examples?: {
2777
+ command: string;
2778
+ description: string;
2779
+ }[];
2780
+ hideGlobalFlags?: string[];
2781
+ };
2782
+ type ArgDefinition = Omit<PositionalOptions, "type"> & Pick<Options, "hidden" | "requiresArg" | "deprecated" | "type">;
2783
+ type NamedArgDefinitions = {
2784
+ [key: string]: ArgDefinition;
2785
+ };
2786
+ type HandlerArgs<Args extends NamedArgDefinitions> = DeepFlatten<OnlyCamelCase<RemoveIndex<ArgumentsCamelCase<CommonYargsOptions & InferredOptionTypes<Args> & Alias<Args>>>>>;
2787
+ type HandlerContext = {
2788
+ /**
2789
+ * The wrangler config file read from disk and parsed.
2790
+ */
2791
+ config: Config;
2792
+ /**
2793
+ * The logger instance provided to the command implementor as a convenience.
2794
+ */
2795
+ logger: Logger;
2796
+ /**
2797
+ * Use fetchResult to make *auth'd* requests to the Cloudflare API.
2798
+ */
2799
+ fetchResult: typeof fetchResult;
2800
+ /**
2801
+ * Error classes provided to the command implementor as a convenience
2802
+ * to aid discoverability and to encourage their usage.
2803
+ */
2804
+ errors: {
2805
+ UserError: typeof UserError;
2806
+ FatalError: typeof FatalError;
2807
+ };
2808
+ };
2809
+ type CommandDefinition<NamedArgDefs extends NamedArgDefinitions = NamedArgDefinitions> = {
2810
+ /**
2811
+ * Descriptive information about the command which does not affect behaviour.
2812
+ * This is used for the CLI --help and subcommand --help output.
2813
+ * This should be used as the source-of-truth for status and ownership.
2814
+ */
2815
+ metadata: Metadata;
2816
+ /**
2817
+ * Controls shared behaviour across all commands.
2818
+ * This will allow wrangler commands to remain consistent and only diverge intentionally.
2819
+ */
2820
+ behaviour?: {
2821
+ /**
2822
+ * By default, wrangler's version banner will be printed before the handler is executed.
2823
+ * Set this value to `false` to skip printing the banner.
2824
+ *
2825
+ * @default true
2826
+ */
2827
+ printBanner?: boolean | ((args: HandlerArgs<NamedArgDefs>) => boolean);
2828
+ /**
2829
+ * By default, wrangler will print warnings about the Wrangler configuration file.
2830
+ * Set this value to `false` to skip printing these warnings.
2831
+ */
2832
+ printConfigWarnings?: boolean;
2833
+ /**
2834
+ * By default, wrangler will read & provide the wrangler.toml/wrangler.json configuration.
2835
+ * Set this value to `false` to skip this.
2836
+ */
2837
+ provideConfig?: boolean;
2838
+ /**
2839
+ * By default, wrangler will provide experimental flags in the handler context,
2840
+ * according to the default values in register-yargs.command.ts
2841
+ * Use this to override those defaults per command.
2842
+ */
2843
+ overrideExperimentalFlags?: (args: HandlerArgs<NamedArgDefs>) => ExperimentalFlags;
2844
+ /**
2845
+ * If true, then look for a redirect file at `.wrangler/deploy/config.json` and use that to find the Wrangler configuration file.
2846
+ */
2847
+ useConfigRedirectIfAvailable?: boolean;
2848
+ /**
2849
+ * If true, print a message about whether the command is operating on a local or remote resource
2850
+ */
2851
+ printResourceLocation?: ((args?: HandlerArgs<NamedArgDefs>) => boolean) | boolean;
2852
+ /**
2853
+ * If true, check for environments in the wrangler config, if there are some and the user hasn't specified an environment
2854
+ * using the `-e|--env` cli flag, show a warning suggesting that one should instead be specified.
2855
+ */
2856
+ warnIfMultipleEnvsConfiguredButNoneSpecified?: boolean;
2857
+ };
2858
+ /**
2859
+ * A plain key-value object describing the CLI args for this command.
2860
+ * Shared args can be defined as another plain object and spread into this.
2861
+ */
2862
+ args?: NamedArgDefs;
2863
+ /**
2864
+ * Optionally declare some of the named args as positional args.
2865
+ * The order of this array is the order they are expected in the command.
2866
+ * Use args[key].demandOption and args[key].array to declare required and variadic
2867
+ * positional args, respectively.
2868
+ */
2869
+ positionalArgs?: Array<StringKeyOf<NamedArgDefs>>;
2870
+ /**
2871
+ * A hook to implement custom validation of the args before the handler is called.
2872
+ * Throw `CommandLineArgsError` with actionable error message if args are invalid.
2873
+ * The return value is ignored.
2874
+ */
2875
+ validateArgs?: (args: HandlerArgs<NamedArgDefs>) => void | Promise<void>;
2876
+ /**
2877
+ * The implementation of the command which is given camelCase'd args
2878
+ * and a ctx object of convenience properties
2879
+ */
2880
+ handler: (args: HandlerArgs<NamedArgDefs>, ctx: HandlerContext) => void | Promise<void>;
2881
+ };
2882
+ type NamespaceDefinition = {
2883
+ metadata: Metadata;
2884
+ };
2885
+ type AliasDefinition = {
2886
+ aliasOf: Command;
2887
+ metadata?: Partial<Metadata>;
2888
+ };
2889
+ type InternalDefinition = ({
2890
+ type: "command";
2891
+ command: Command;
2892
+ } & CommandDefinition) | ({
2893
+ type: "namespace";
2894
+ command: Command;
2895
+ } & NamespaceDefinition) | ({
2896
+ type: "alias";
2897
+ command: Command;
2898
+ } & AliasDefinition);
2899
+ type DefinitionTreeNode = {
2900
+ definition?: InternalDefinition;
2901
+ subtree: DefinitionTree;
2902
+ };
2903
+ type DefinitionTree = Map<string, DefinitionTreeNode>;
2904
+
2905
+ /**
2906
+ * EXPERIMENTAL: Get all registered Wrangler commands for documentation generation.
2907
+ * This API is experimental and may change without notice.
2908
+ *
2909
+ * @returns The complete command tree structure with all metadata
2910
+ */
2911
+ declare function experimental_getWranglerCommands(): DefinitionTreeNode;
2912
+
2657
2913
  interface Unstable_ASSETSBindingsOptions {
2658
2914
  log: Logger;
2659
2915
  proxyPort?: number;
@@ -2661,4 +2917,4 @@ interface Unstable_ASSETSBindingsOptions {
2661
2917
  }
2662
2918
  declare const generateASSETSBinding: (opts: Unstable_ASSETSBindingsOptions) => (request: Request) => Promise<Response$1>;
2663
2919
 
2664
- export { type ConfigBindingOptions as Experimental_ConfigBindingOptions, type RemoteProxySession as Experimental_RemoteProxySession, type GetPlatformProxyOptions, type PlatformProxy, type SourcelessWorkerOptions, type Unstable_ASSETSBindingsOptions, type Binding as Unstable_Binding, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, type StartRemoteProxySessionOptions as experimental_StartRemoteProxySessionOptions, maybeStartOrUpdateRemoteProxySession as experimental_maybeStartOrUpdateRemoteProxySession, experimental_patchConfig, pickRemoteBindings as experimental_pickRemoteBindings, experimental_readRawConfig, startRemoteProxySession as experimental_startRemoteProxySession, getPlatformProxy, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, generateASSETSBinding as unstable_generateASSETSBinding, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, unstable_pages, readConfig as unstable_readConfig, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };
2920
+ export { type ConfigBindingOptions as Experimental_ConfigBindingOptions, type RemoteProxySession as Experimental_RemoteProxySession, type GetPlatformProxyOptions, type PlatformProxy, type SourcelessWorkerOptions, type Unstable_ASSETSBindingsOptions, type Binding as Unstable_Binding, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, type StartRemoteProxySessionOptions as experimental_StartRemoteProxySessionOptions, experimental_getWranglerCommands, maybeStartOrUpdateRemoteProxySession as experimental_maybeStartOrUpdateRemoteProxySession, experimental_patchConfig, pickRemoteBindings as experimental_pickRemoteBindings, experimental_readRawConfig, startRemoteProxySession as experimental_startRemoteProxySession, getPlatformProxy, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, generateASSETSBinding as unstable_generateASSETSBinding, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, unstable_pages, readConfig as unstable_readConfig, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };