@cloudflare/workers-utils 0.22.1 → 0.23.1

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/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding } from './config-CXobNAeT.mjs';
2
- export { aw as AssetConfigMetadata, A as Assets, ax as AssetsOptions, aD as BinaryFile, r as CacheOptions, I as CfAIBinding, a1 as CfAISearch, a0 as CfAISearchNamespace, a3 as CfAgentMemory, ae as CfAnalyticsEngineDataset, a5 as CfArtifacts, aj as CfAssetsBinding, H as CfBrowserBinding, am as CfCapnp, _ as CfD1Database, N as CfDataBlobBindings, af as CfDispatchNamespace, Q as CfDurableObject, ao as CfDurableObjectMigrations, a7 as CfFlagship, a6 as CfHelloWorld, aa as CfHyperdrive, J as CfImagesBinding, y as CfKvNamespace, ah as CfLogfwdr, ai as CfLogfwdrBinding, ag as CfMTlsCertificate, K as CfMediaBinding, w as CfModule, v as CfModuleType, ak as CfPipeline, ap as CfPlacement, X as CfQueue, Y as CfR2Bucket, a9 as CfRateLimit, u as CfScriptFormat, a4 as CfSecretsStoreSecrets, z as CfSendEmailBindings, ab as CfService, L as CfStreamBinding, aq as CfTailConsumer, G as CfTextBlobBindings, an as CfUnsafe, al as CfUnsafeBinding, ar as CfUserLimits, x as CfVars, $ as CfVectorize, M as CfVersionMetadataBinding, ad as CfVpcNetwork, ac as CfVpcService, F as CfWasmModuleBindings, a2 as CfWebSearch, at as CfWorkerContext, as as CfWorkerInit, a8 as CfWorkerLoader, au as CfWorkerSourceMap, V as CfWorkflow, j as CloudchamberConfig, d as ConfigFields, p as ConfigModuleRuleType, k as ContainerApp, t as ContainerEngine, h as CustomDomainRoute, q as DispatchNamespaceOutbound, s as DockerConfiguration, l as DurableObjectBindings, D as DurableObjectMigration, aI as ENVIRONMENT_TAG_PREFIX, aF as Entry, E as Environment, n as EnvironmentNonInheritable, aC as File, aG as INHERIT_SYMBOL, aK as JSON_CONFIG_FORMATS, av as Json, ay as LegacyAssetPaths, O as Observability, aJ as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, c as RawDevConfig, e as RawEnvironment, a as RedirectedRawConfig, i as Route, o as Rule, aH as SERVICE_TAG_PREFIX, aB as ServiceFetch, aA as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, aE as Trigger, U as UserLimits, az as WorkerMetadata, m as WorkflowBinding, Z as ZoneIdRoute, g as ZoneNameRoute, f as defaultWranglerConfig } from './config-CXobNAeT.mjs';
1
+ import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding, L as Logger, c as Route } from './config-DrgFpZpF.mjs';
2
+ export { bv as ApiCredentials, az as AssetConfigMetadata, A as Assets, aA as AssetsOptions, aM as AsyncHook, aH as BinaryFile, a$ as COMPLIANCE_REGION_CONFIG_PUBLIC, b0 as COMPLIANCE_REGION_CONFIG_UNKNOWN, t as CacheOptions, K as CfAIBinding, a4 as CfAISearch, a3 as CfAISearchNamespace, aJ as CfAccount, a6 as CfAgentMemory, ah as CfAnalyticsEngineDataset, a8 as CfArtifacts, am as CfAssetsBinding, J as CfBrowserBinding, ap as CfCapnp, a1 as CfD1Database, X as CfDataBlobBindings, ai as CfDispatchNamespace, Y as CfDurableObject, ar as CfDurableObjectMigrations, aa as CfFlagship, a9 as CfHelloWorld, ad as CfHyperdrive, M as CfImagesBinding, F as CfKvNamespace, ak as CfLogfwdr, al as CfLogfwdrBinding, aj as CfMTlsCertificate, N as CfMediaBinding, y as CfModule, x as CfModuleType, an as CfPipeline, as as CfPlacement, $ as CfQueue, a0 as CfR2Bucket, ac as CfRateLimit, w as CfScriptFormat, a7 as CfSecretsStoreSecrets, G as CfSendEmailBindings, ae as CfService, Q as CfStreamBinding, at as CfTailConsumer, I as CfTextBlobBindings, aq as CfUnsafe, ao as CfUnsafeBinding, au as CfUserLimits, z as CfVars, a2 as CfVectorize, V as CfVersionMetadataBinding, ag as CfVpcNetwork, af as CfVpcService, H as CfWasmModuleBindings, a5 as CfWebSearch, aw as CfWorkerContext, av as CfWorkerInit, ab as CfWorkerLoader, ax as CfWorkerSourceMap, _ as CfWorkflow, l as CloudchamberConfig, a_ as ComplianceConfig, e as ConfigFields, r as ConfigModuleRuleType, m as ContainerApp, v as ContainerEngine, k as CustomDomainRoute, s as DispatchNamespaceOutbound, u as DockerConfiguration, n as DurableObjectBindings, D as DurableObjectMigration, aT as ENVIRONMENT_TAG_PREFIX, aQ as Entry, E as Environment, p as EnvironmentNonInheritable, bN as FetchKVGetValueFetcher, by as FetchListResultFetcher, bz as FetchPagedListResultFetcher, bw as FetchResult, bx as FetchResultFetcher, aG as File, aL as Hook, aK as HookValues, aR as INHERIT_SYMBOL, aV as JSON_CONFIG_FORMATS, ay as Json, h as LOGGER_LEVELS, aC as LegacyAssetPaths, aN as LogLevel, i as LoggerLevel, aO as NodeJSCompatMode, O as Observability, aU as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, d as RawDevConfig, f as RawEnvironment, a as RedirectedRawConfig, q as Rule, aS as SERVICE_TAG_PREFIX, aF as ServiceFetch, aE as ServiceMetadataRes, aP as StartDevWorkerInput, S as StreamingTailConsumer, T as TailConsumer, aI as Trigger, U as UserLimits, aB as ValidatedAssetsOptions, aD as WorkerMetadata, o as WorkflowBinding, Z as ZoneIdRoute, j as ZoneNameRoute, bK as addAuthorizationHeader, g as defaultWranglerConfig, bH as extractAccountTag, bG as extractWAFBlockRayId, bB as fetchInternalBase, bM as fetchKVGetValueBase, bD as fetchListResultBase, bC as fetchResultBase, bq as getBrowserRenderingHeadfulFromEnv, bc as getBuildConditionsFromEnv, bd as getBuildPlatformFromEnv, aW as getC3CommandFromEnv, ba as getCIGeneratePreviewAlias, b7 as getCIMatchTag, b8 as getCIOverrideName, b9 as getCIOverrideNetworkModeHost, br as getCfFetchEnabledFromEnv, bs as getCfFetchPathFromEnv, b2 as getCloudflareApiBaseUrl, aZ as getCloudflareApiEnvironmentFromEnv, b1 as getCloudflareComplianceRegion, bn as getCloudflareEnv, bj as getCloudflareIncludeProcessEnvFromEnv, bi as getCloudflareLoadDevVarsFromDotEnv, bu as getCloudflaredPathFromEnv, b3 as getComplianceRegionSubdomain, bf as getD1ExtraLocationChoices, bl as getDisableConfigWatching, bg as getDockerPath, bp as getLocalExplorerEnabledFromEnv, bo as getOpenNextDeployFromEnv, b5 as getOutputFileDirectoryFromEnv, b6 as getOutputFilePathFromEnv, be as getRegistryPath, b4 as getSanitizeLogs, bh as getSubdomainMixedStateCheckDisabled, bk as getTraceHeader, bb as getWorkersCIBranchName, bt as getWranglerCacheDirFromEnv, bm as getWranglerHideBanner, aY as getWranglerSendErrorReportsFromEnv, aX as getWranglerSendMetricsFromEnv, bO as hasCursor, bI as hasMorePages, bF as isWAFBlockResponse, bP as maybeAddTraceHeader, bA as performApiFetchBase, bJ as renderError, bL as throwFetchError, bE as truncate } from './config-DrgFpZpF.mjs';
3
3
  import * as jsoncParser from 'jsonc-parser';
4
4
  export { constructWranglerConfig } from './browser.mjs';
5
5
  export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
6
6
  import { ChildProcess } from 'node:child_process';
7
- import { URLSearchParams } from 'node:url';
8
- import { RequestInit, Response, Headers } from 'undici';
7
+ import 'node:url';
8
+ import 'undici';
9
9
  import '@cloudflare/workers-shared';
10
10
  import 'cloudflare';
11
11
 
@@ -92,7 +92,7 @@ declare const bucketFormatMessage = "Bucket names must begin and end with an alp
92
92
  * Config field names for bindings (e.g., "kv_namespaces", "d1_databases").
93
93
  * These are the keys used in Wrangler's config file
94
94
  */
95
- type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "web_search" | "agent_memory" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
95
+ type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "websearch" | "agent_memory" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
96
96
  /**
97
97
  * @deprecated new code should use getBindingTypeFriendlyName() instead
98
98
  */
@@ -557,248 +557,35 @@ declare function getEnvironmentVariableFactory<Choices extends readonly string[]
557
557
  readonly choices?: Choices;
558
558
  }): () => ElementType<Choices>;
559
559
 
560
+ interface GetGlobalConfigPathOptions {
561
+ /**
562
+ * The application namespace. Defaults to `"wrangler"`.
563
+ */
564
+ appName?: string;
565
+ /**
566
+ * Whether to prepend a `.` to `appName` when resolving the XDG path and the
567
+ * legacy `$HOME` directory. Defaults to `true` to match wrangler's
568
+ * historical behaviour (`.wrangler`).
569
+ */
570
+ leadingDot?: boolean;
571
+ /**
572
+ * When `true` (the default, matching wrangler's historical behaviour), a
573
+ * pre-existing `~/.<appName>` directory takes precedence over the XDG path.
574
+ * Pass `false` to always use the XDG-compliant path.
575
+ */
576
+ useLegacyHomeDir?: boolean;
577
+ }
560
578
  /**
561
- * `WRANGLER_C3_COMMAND` can override the command used by `wrangler init` when delegating to C3.
562
- *
563
- * By default this will use `create cloudflare`.
564
- *
565
- * To run against the beta release of C3 use:
566
- *
567
- * ```sh
568
- * # Tell Wrangler to use the beta version of create-cloudflare
569
- * WRANGLER_C3_COMMAND="create cloudflare@beta" npx wrangler init
570
- * ```
571
- *
572
- * To test the integration between wrangler and C3 locally, use:
573
- *
574
- * ```sh
575
- * # Ensure both Wrangler and C3 are built
576
- * npm run build
577
- * # Tell Wrangler to use the local version of create-cloudflare
578
- * WRANGLER_C3_COMMAND="exec ./packages/create-cloudflare" npx wrangler init temp
579
- * ```
580
- *
581
- * Note that you cannot use `WRANGLER_C3_COMMAND="create cloudflare@2"` if you are
582
- * running Wrangler from inside the monorepo as the bin paths get messed up.
583
- */
584
- declare const getC3CommandFromEnv: () => string;
585
- /**
586
- * `WRANGLER_SEND_METRICS` can override whether we attempt to send metrics information to Sparrow.
587
- */
588
- declare const getWranglerSendMetricsFromEnv: () => boolean | undefined;
589
- /**
590
- * `WRANGLER_SEND_ERROR_REPORTS` controls whether we attempt to send error reports to Sentry.
591
- *
592
- * Defaults to `false` to avoid noisy false-positive reports. Users can opt in
593
- * by setting `WRANGLER_SEND_ERROR_REPORTS=true`.
594
- */
595
- declare const getWranglerSendErrorReportsFromEnv: () => boolean;
596
- /**
597
- * Set `WRANGLER_API_ENVIRONMENT` environment variable to "staging" to tell Wrangler to hit the staging APIs rather than production.
598
- */
599
- declare const getCloudflareApiEnvironmentFromEnv: () => "staging" | "production";
600
- /**
601
- * The compliance region to use for the API requests.
602
- */
603
- type ComplianceConfig = Partial<Pick<Config, "compliance_region">>;
604
- /** Used for commands that explicitly do not support compliance regions other than "public" */
605
- declare const COMPLIANCE_REGION_CONFIG_PUBLIC: ComplianceConfig;
606
- /**
607
- * Used for commands where there is no configuration available and
608
- * we rely upon the CLOUDFLARE_COMPLIANCE_REGION environment variable
609
- * to determine the compliance region.
610
- */
611
- declare const COMPLIANCE_REGION_CONFIG_UNKNOWN: ComplianceConfig;
612
- /**
613
- * Set `CLOUDFLARE_COMPLIANCE_REGION` environment variable to "fedramp_high"
614
- * or set the `compliance_region` property in the Wrangler configuration
615
- * to tell Wrangler to run in FedRAMP High compliance region mode, rather than "public" mode.
616
- */
617
- declare const getCloudflareComplianceRegion: (complianceConfig: ComplianceConfig) => "public" | "fedramp_high";
618
- /**
619
- * `CLOUDFLARE_API_BASE_URL` specifies the URL to the Cloudflare API.
620
- *
621
- * If this environment variable is not set, it will default to a URL computed from the
622
- * Cloudflare compliance region and the API environment.
623
- */
624
- declare const getCloudflareApiBaseUrl: (complianceConfig: ComplianceConfig) => string;
625
- /**
626
- * Compute the subdomain for the compliance region.
627
- */
628
- declare function getComplianceRegionSubdomain(complianceConfig: ComplianceConfig): string;
629
- /**
630
- * `WRANGLER_LOG_SANITIZE` specifies whether we sanitize debug logs.
631
- *
632
- * By default we do, since debug logs could be added to GitHub issues and shouldn't include sensitive information.
633
- */
634
- declare const getSanitizeLogs: () => boolean;
635
- /**
636
- * `WRANGLER_OUTPUT_FILE_DIRECTORY` specifies a directory where we should write a file containing output data in ND-JSON format.
637
- *
638
- * If this is set a random file will be created in this directory, and certain Wrangler commands will write entries to this file.
639
- * This is overridden by the `WRANGLER_OUTPUT_FILE_PATH` environment variable.
640
- */
641
- declare const getOutputFileDirectoryFromEnv: () => string | undefined;
642
- /**
643
- * `WRANGLER_OUTPUT_FILE_PATH` specifies a path to a file where we should write output data in ND-JSON format.
644
- *
645
- * If this is set certain Wrangler commands will write entries to this file.
646
- * This overrides the `WRANGLER_OUTPUT_FILE_DIRECTORY` environment variable.
647
- */
648
- declare const getOutputFilePathFromEnv: () => string | undefined;
649
- /**
650
- * `WRANGLER_CI_MATCH_TAG` specifies a Worker tag
651
- *
652
- * If this is set, Wrangler will ensure the Worker being targeted has this tag
653
- */
654
- declare const getCIMatchTag: () => string | undefined;
655
- /**
656
- * `WRANGLER_CI_OVERRIDE_NAME` specifies a Worker name
657
- *
658
- * If this is set, Wrangler will override the Worker name with this one
659
- */
660
- declare const getCIOverrideName: () => string | undefined;
661
- /**
662
- * `WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST` specifies whether --network=host should be set
663
- *
664
- * If this is set to true, Wrangler will use the --network=host flag when calling out to docker to build container images
665
- */
666
- declare const getCIOverrideNetworkModeHost: () => string | undefined;
667
- /**
668
- * `WRANGLER_CI_GENERATE_PREVIEW_ALIAS` specifies whether to generate a preview alias during version upload
669
- *
670
- * If this is set to true, Wrangler will attempt to autogenerate the preview alias by using the branch
671
- * name. If the branch name is too long and an alias cannot be created, a warning will be printed to the console.
672
- */
673
- declare const getCIGeneratePreviewAlias: () => "true" | "false";
674
- /**
675
- * `WORKERS_CI_BRANCH` is the branch name exposed by Workers CI
676
- *
677
- */
678
- declare const getWorkersCIBranchName: () => string | undefined;
679
- /**
680
- * `WRANGLER_BUILD_CONDITIONS` specifies the "build conditions" to use when importing packages at build time.
681
- *
682
- * See https://nodejs.org/api/packages.html#conditional-exports
683
- * and https://esbuild.github.io/api/#how-conditions-work.
684
- *
685
- * If this is set, Wrangler will configure esbuild to use this list of conditions.
686
- * The format is a string of comma separated conditions.
687
- */
688
- declare const getBuildConditionsFromEnv: () => string | undefined;
689
- /**
690
- * `WRANGLER_BUILD_PLATFORM` specifies the "build platform" to use when importing packages at build time.
691
- *
692
- * See https://esbuild.github.io/api/#platform
693
- * and https://esbuild.github.io/api/#how-conditions-work.
694
- *
695
- * If this is set, Wrangler will configure esbuild to use this platform.
696
- */
697
- declare const getBuildPlatformFromEnv: () => string | undefined;
698
- /**
699
- * `WRANGLER_REGISTRY_PATH` specifies the file based dev registry folder
700
- */
701
- declare const getRegistryPath: () => string;
702
- /**
703
- * `WRANGLER_D1_EXTRA_LOCATION_CHOICES` is an internal variable to let D1 team target their testing environments.
704
- *
705
- * External accounts cannot access testing environments, so should not set this variable.
706
- */
707
- declare const getD1ExtraLocationChoices: () => string | undefined;
708
- /**
709
- * `WRANGLER_DOCKER_BIN` specifies the path to a docker binary.
710
- *
711
- * By default it's `docker`.
712
- */
713
- declare const getDockerPath: () => string;
714
- declare const getSubdomainMixedStateCheckDisabled: () => boolean;
715
- /**
716
- /**
717
- * `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV` specifies whether to load vars for local dev from `.env` files.
718
- */
719
- declare const getCloudflareLoadDevVarsFromDotEnv: () => boolean;
720
- /**
721
- * `CLOUDFLARE_INCLUDE_PROCESS_ENV` specifies whether to include the `process.env` in vars loaded from `.env` for local development.
722
- */
723
- declare const getCloudflareIncludeProcessEnvFromEnv: () => boolean;
724
- declare const getTraceHeader: () => string | undefined;
725
- declare const getDisableConfigWatching: () => boolean;
726
- /**
727
- * Hide the Wrangler version banner and command status (deprecated/experimental) warnings
728
- */
729
- declare const getWranglerHideBanner: () => boolean;
730
- /**
731
- * `CLOUDFLARE_ENV` specifies the currently selected Wrangler/Cloudflare environment.
732
- */
733
- declare const getCloudflareEnv: () => string | undefined;
734
- /**
735
- * `OPEN_NEXT_DEPLOY` is an environment variables that indicates that the current process is being
736
- * run by the open-next deploy command
737
- */
738
- declare const getOpenNextDeployFromEnv: () => string | undefined;
739
- /**
740
- * `X_LOCAL_EXPLORER` enables the local explorer UI at /cdn-cgi/explorer.
741
- */
742
- declare const getLocalExplorerEnabledFromEnv: () => boolean;
743
- /**
744
- * `X_BROWSER_HEADFUL` opens the browser in headful (visible) mode when using the
745
- * Browser Run API in local development.
746
- *
747
- * Set to "true" to enable:
748
- *
749
- * ```sh
750
- * X_BROWSER_HEADFUL=true vite dev
751
- * ```
752
- *
753
- * Note: when using `@cloudflare/playwright`, two Chrome windows may appear — the initial blank
754
- * page and the one created by `browser.newPage()`. This is expected due to how Playwright handles
755
- * browser contexts via CDP.
756
- */
757
- declare const getBrowserRenderingHeadfulFromEnv: () => boolean;
758
- /**
759
- * `CLOUDFLARE_CF_FETCH_ENABLED` controls whether Miniflare fetches the `cf.json` file
760
- * containing request.cf properties from workers.cloudflare.com.
761
- *
762
- * - If set to "false", disables fetching and uses fallback data (no files created)
763
- * - If set to "true" or not set, uses the default behavior (fetches and caches cf.json)
764
- *
765
- * This is particularly useful for non-JavaScript projects that don't want
766
- * a node_modules directory created automatically.
767
- *
768
- * Example:
769
- * ```sh
770
- * # Disable cf fetching entirely
771
- * CLOUDFLARE_CF_FETCH_ENABLED=false npx wrangler dev
772
- * ```
773
- */
774
- declare const getCfFetchEnabledFromEnv: () => boolean;
775
- /**
776
- * `CLOUDFLARE_CF_FETCH_PATH` specifies a custom path for caching the cf.json file.
777
- *
778
- * - If set, uses the specified path instead of the default node_modules/.mf/cf.json
779
- * - If not set, uses the default location (node_modules/.mf/cf.json)
579
+ * Resolve the global config directory for a Cloudflare CLI.
780
580
  *
781
- * Example:
782
- * ```sh
783
- * # Use a custom cache location
784
- * CLOUDFLARE_CF_FETCH_PATH=/tmp/cf-cache.json npx wrangler dev
785
- * ```
581
+ * Defaults to wrangler's directory (`.wrangler`) so existing callers are
582
+ * unaffected, but accepts an `appName` so other first-party CLIs (e.g. `cf`)
583
+ * can reuse the same XDG-compliant resolution under their own namespace.
786
584
  */
787
- declare const getCfFetchPathFromEnv: () => string | undefined;
585
+ declare function getGlobalConfigPath({ appName, leadingDot, useLegacyHomeDir, }?: GetGlobalConfigPathOptions): string;
788
586
  /**
789
- * `WRANGLER_CACHE_DIR` specifies a custom directory for Wrangler's cache files.
790
- * This overrides the default `node_modules/.cache/wrangler` location.
791
- * Useful for Yarn PnP or projects without node_modules.
587
+ * @deprecated Use {@link getGlobalConfigPath} instead.
792
588
  */
793
- declare const getWranglerCacheDirFromEnv: () => string | undefined;
794
- /**
795
- * `CLOUDFLARED_PATH` specifies a custom path to a cloudflared binary.
796
- *
797
- * If set, Wrangler will use this cloudflared binary instead of downloading one.
798
- * The path must point to an existing executable file.
799
- */
800
- declare const getCloudflaredPathFromEnv: () => string | undefined;
801
-
802
589
  declare function getGlobalWranglerConfigPath(): string;
803
590
 
804
591
  type YYYY = `${number}${number}${number}${number}`;
@@ -888,30 +675,6 @@ declare function sweepStaleWranglerTmpDirs(tmpRoot: string): void;
888
675
  */
889
676
  declare function getWranglerTmpDir(projectRoot: string | undefined, prefix: string, cleanup?: boolean): EphemeralDirectory;
890
677
 
891
- /**
892
- * cloudflared binary management for Wrangler tunnel commands.
893
- *
894
- * This module handles downloading, caching, and running the cloudflared binary.
895
- * It uses the Cloudflare update worker (update.argotunnel.com) to resolve
896
- * the latest version and download URL, matching cloudflared's own update mechanism.
897
- */
898
-
899
- interface Logger$1 {
900
- log: typeof console.log;
901
- warn: typeof console.warn;
902
- debug: typeof console.debug;
903
- }
904
- /**
905
- * Spawn cloudflared process with automatic binary management
906
- */
907
- declare function spawnCloudflared(args: string[], options?: {
908
- stdio?: "inherit" | "pipe";
909
- env?: Record<string, string>;
910
- skipVersionCheck?: boolean;
911
- confirmDownload?: (message: string) => Promise<boolean>;
912
- logger?: Logger$1;
913
- }): Promise<ChildProcess>;
914
-
915
678
  interface QuickTunnelResult {
916
679
  mode: "quick";
917
680
  publicUrl: URL;
@@ -933,7 +696,7 @@ interface TunnelOptions {
933
696
  expiryMs?: number;
934
697
  reminderIntervalMs?: number;
935
698
  extendHint?: string;
936
- logger?: Logger$1;
699
+ logger?: Pick<Logger, "debug" | "log" | "warn">;
937
700
  }
938
701
  /**
939
702
  * Start a Cloudflare Quick Tunnel for a local dev origin.
@@ -945,73 +708,24 @@ interface TunnelOptions {
945
708
  */
946
709
  declare function startTunnel(options: TunnelOptions): Tunnel;
947
710
 
948
- interface FetchError {
949
- code: number;
950
- documentation_url?: string;
951
- message: string;
952
- error_chain?: FetchError[];
953
- }
954
-
955
- type Logger = {
956
- debug: (...args: unknown[]) => void;
957
- debugWithSanitization: (label: string, ...args: unknown[]) => void;
958
- log: (...args: unknown[]) => void;
959
- info: (...args: unknown[]) => void;
960
- warn: (...args: unknown[]) => void;
961
- error: (...args: unknown[]) => void;
962
- };
963
-
964
- type ApiCredentials = {
965
- apiToken: string;
966
- } | {
967
- authKey: string;
968
- authEmail: string;
969
- };
970
- interface FetchResult<ResponseType = unknown> {
971
- success: boolean;
972
- result: ResponseType;
973
- errors: FetchError[];
974
- messages?: (string | {
975
- code?: number;
976
- message: string;
977
- })[];
978
- result_info?: unknown;
979
- }
980
- type FetchResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal) => Promise<ResponseType>;
981
711
  /**
712
+ * cloudflared binary management for Wrangler tunnel commands.
982
713
  *
983
- * Note this requires its caller to handle credentials
984
- * (need to call requireLoggedIn and requireApiToken)
714
+ * This module handles downloading, caching, and running the cloudflared binary.
715
+ * It uses the Cloudflare update worker (update.argotunnel.com) to resolve
716
+ * the latest version and download URL, matching cloudflared's own update mechanism.
985
717
  */
986
- declare function performApiFetchBase(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<Response>;
987
- declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
988
- response: ResponseType;
989
- status: number;
990
- }>;
991
- declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
992
- declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
993
- declare function truncate(text: string, maxLength: number): string;
994
- declare function isWAFBlockResponse(headers: Headers): boolean;
995
- declare function extractWAFBlockRayId(headers: Headers): string | undefined;
996
- declare function extractAccountTag(resource: string): string | undefined;
997
- interface PageResultInfo {
998
- page: number;
999
- per_page: number;
1000
- count: number;
1001
- total_count: number;
1002
- }
1003
- declare function hasMorePages(result_info: unknown): result_info is PageResultInfo;
1004
- declare function renderError(err: FetchError | {
1005
- code?: number;
1006
- message?: string;
1007
- documentation_url?: string;
1008
- }, level?: number): string;
1009
- declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
1010
- declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
1011
- declare function hasCursor(result_info: unknown): result_info is {
1012
- cursor: string;
1013
- };
1014
- declare function maybeAddTraceHeader(headers: Headers): void;
718
+
719
+ /**
720
+ * Spawn cloudflared process with automatic binary management
721
+ */
722
+ declare function spawnCloudflared(args: string[], options?: {
723
+ stdio?: "inherit" | "pipe";
724
+ env?: Record<string, string>;
725
+ skipVersionCheck?: boolean;
726
+ confirmDownload?: (message: string) => Promise<boolean>;
727
+ logger?: Pick<Logger, "debug" | "log" | "warn">;
728
+ }): Promise<ChildProcess>;
1015
729
 
1016
730
  type NpmVersionCheckResult = {
1017
731
  status: "up-to-date";
@@ -1037,4 +751,41 @@ type NpmVersionCheckResult = {
1037
751
  */
1038
752
  declare function fetchLatestNpmVersion(name: string, version: string): Promise<NpmVersionCheckResult>;
1039
753
 
1040
- export { APIError, type ApiCredentials, Binding, type BindingLocalSupport, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, type EphemeralDirectory, FatalError, type FetchResult, type FetchResultFetcher, JsonFriendlyFatalError, type Location, type Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type NpmVersionCheckResult, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerMetadataBinding, addAuthorizationHeader, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTodaysCompatDate, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, hasCursor, hasMorePages, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, mapWorkerMetadataBindings, maybeAddTraceHeader, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, performApiFetchBase, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, renderError, resolveWranglerConfigPath, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, truncate, validatePagesConfig };
754
+ declare function retryOnAPIFailure<T>(action: () => T | Promise<T>, logger: Logger, backoff?: number, attempts?: number, abortSignal?: AbortSignal): Promise<T>;
755
+
756
+ declare function formatTime(duration: number): string;
757
+
758
+ /**
759
+ * Get the hostname on which to run a Worker.
760
+ *
761
+ * The most accurate place is usually
762
+ * `route.pattern`, as that includes any subdomains. For example:
763
+ * ```js
764
+ * {
765
+ * pattern: foo.example.com
766
+ * zone_name: example.com
767
+ * }
768
+ * ```
769
+ * However, in the case of patterns that _can't_ be parsed as a hostname
770
+ * (primarily the pattern `*/ declare function getHostFromRoute(route: Route): string | undefined;
771
+ /**
772
+ * Best-effort derivation of the Cloudflare zone name that owns a given route,
773
+ * for use as the `CF-Worker` header value on outbound subrequests in local
774
+ * development (see https://developers.cloudflare.com/fundamentals/reference/http-headers/#cf-worker).
775
+ *
776
+ * In production, `CF-Worker` is set to the zone name — for a route
777
+ * `foo.example.com/*` on zone `example.com`, the header is `example.com`.
778
+ * When the user has explicitly told us the zone name in their route config
779
+ * (`zone_name`), use it. Otherwise, fall back to {@link getHostFromRoute},
780
+ * which returns the route pattern's hostname — this is the closest local
781
+ * approximation without performing an API lookup, and matches the behaviour
782
+ * users see when their route's hostname is already the apex (e.g.
783
+ * `example.com/*`).
784
+ */
785
+ declare function getZoneFromRoute(route: Route): string | undefined;
786
+ /**
787
+ * Given something that resembles a URL, try to extract a host from it.
788
+ */
789
+ declare function getHostFromUrl(urlLike: string): string | undefined;
790
+
791
+ export { APIError, Binding, type BindingLocalSupport, CommandLineArgsError, type CompatDate, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, type EphemeralDirectory, FatalError, type GetGlobalConfigPathOptions, JsonFriendlyFatalError, type Location, Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type NpmVersionCheckResult, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, Route, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerMetadataBinding, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, fetchLatestNpmVersion, findWranglerConfig, formatConfigSnippet, formatTime, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getEnvironmentVariableFactory, getGlobalConfigPath, getGlobalWranglerConfigPath, getHostFromRoute, getHostFromUrl, getTodaysCompatDate, getWranglerHiddenDirPath, getWranglerTmpDir, getZoneFromRoute, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, retryOnAPIFailure, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, validatePagesConfig };