@cloudflare/workers-utils 0.11.2 → 0.18.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/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { B as Binding, R as RawConfig, C as Config, W as WorkerMetadataBinding } from './config-DAxLpjUL.mjs';
2
- export { al as AssetConfigMetadata, A as Assets, aq as BinaryFile, G as CfAIBinding, a3 as CfAnalyticsEngineDataset, a8 as CfAssetsBinding, F as CfBrowserBinding, ab as CfCapnp, Q as CfD1Database, K as CfDataBlobBindings, a4 as CfDispatchNamespace, L as CfDurableObject, ad as CfDurableObjectMigrations, Y as CfHelloWorld, a0 as CfHyperdrive, H as CfImagesBinding, w as CfKvNamespace, a6 as CfLogfwdr, a7 as CfLogfwdrBinding, a5 as CfMTlsCertificate, I as CfMediaBinding, u as CfModule, t as CfModuleType, a9 as CfPipeline, ae as CfPlacement, N as CfQueue, P as CfR2Bucket, $ as CfRateLimit, s as CfScriptFormat, X as CfSecretsStoreSecrets, x as CfSendEmailBindings, a1 as CfService, af as CfTailConsumer, z as CfTextBlobBindings, ac as CfUnsafe, aa as CfUnsafeBinding, ag as CfUserLimits, v as CfVars, V as CfVectorize, J as CfVersionMetadataBinding, a2 as CfVpcService, y as CfWasmModuleBindings, ai as CfWorkerContext, ah as CfWorkerInit, _ as CfWorkerLoader, aj as CfWorkerSourceMap, M as CfWorkflow, i as CloudchamberConfig, c as ConfigFields, o as ConfigModuleRuleType, j as ContainerApp, r as ContainerEngine, g as CustomDomainRoute, p as DispatchNamespaceOutbound, q as DockerConfiguration, k as DurableObjectBindings, D as DurableObjectMigration, au as ENVIRONMENT_TAG_PREFIX, E as Environment, m as EnvironmentNonInheritable, ap as File, as as INHERIT_SYMBOL, aw as JSON_CONFIG_FORMATS, ak as Json, O as Observability, av as PATH_TO_DEPLOY_CONFIG, b as RawDevConfig, d as RawEnvironment, a as RedirectedRawConfig, h as Route, n as Rule, at as SERVICE_TAG_PREFIX, ao as ServiceFetch, an as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, ar as Trigger, U as UserLimits, am as WorkerMetadata, l as WorkflowBinding, Z as ZoneIdRoute, f as ZoneNameRoute, e as defaultWranglerConfig } from './config-DAxLpjUL.mjs';
1
+ import { B as Binding, R as RawConfig, C as Config, W as WorkerMetadataBinding } from './config-_M2XwEUI.mjs';
2
+ export { at as AssetConfigMetadata, A as Assets, ay as BinaryFile, q as CacheOptions, H as CfAIBinding, a0 as CfAISearch, $ as CfAISearchNamespace, ab as CfAnalyticsEngineDataset, a2 as CfArtifacts, ag as CfAssetsBinding, G as CfBrowserBinding, aj as CfCapnp, Y as CfD1Database, M as CfDataBlobBindings, ac as CfDispatchNamespace, N as CfDurableObject, al as CfDurableObjectMigrations, a4 as CfFlagship, a3 as CfHelloWorld, a7 as CfHyperdrive, I as CfImagesBinding, x as CfKvNamespace, ae as CfLogfwdr, af as CfLogfwdrBinding, ad as CfMTlsCertificate, J as CfMediaBinding, v as CfModule, u as CfModuleType, ah as CfPipeline, am as CfPlacement, V as CfQueue, X as CfR2Bucket, a6 as CfRateLimit, t as CfScriptFormat, a1 as CfSecretsStoreSecrets, y as CfSendEmailBindings, a8 as CfService, K as CfStreamBinding, an as CfTailConsumer, F as CfTextBlobBindings, ak as CfUnsafe, ai as CfUnsafeBinding, ao as CfUserLimits, w as CfVars, _ as CfVectorize, L as CfVersionMetadataBinding, aa as CfVpcNetwork, a9 as CfVpcService, z as CfWasmModuleBindings, aq as CfWorkerContext, ap as CfWorkerInit, a5 as CfWorkerLoader, ar as CfWorkerSourceMap, Q as CfWorkflow, i as CloudchamberConfig, c as ConfigFields, o as ConfigModuleRuleType, j as ContainerApp, s as ContainerEngine, g as CustomDomainRoute, p as DispatchNamespaceOutbound, r as DockerConfiguration, k as DurableObjectBindings, D as DurableObjectMigration, aC as ENVIRONMENT_TAG_PREFIX, E as Environment, m as EnvironmentNonInheritable, ax as File, aA as INHERIT_SYMBOL, aE as JSON_CONFIG_FORMATS, as as Json, O as Observability, aD as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, b as RawDevConfig, d as RawEnvironment, a as RedirectedRawConfig, h as Route, n as Rule, aB as SERVICE_TAG_PREFIX, aw as ServiceFetch, av as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, az as Trigger, U as UserLimits, au as WorkerMetadata, l as WorkflowBinding, Z as ZoneIdRoute, f as ZoneNameRoute, e as defaultWranglerConfig } from './config-_M2XwEUI.mjs';
3
3
  import * as jsoncParser from 'jsonc-parser';
4
4
  export { constructWranglerConfig } from './browser.mjs';
5
+ export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
5
6
  import '@cloudflare/workers-shared';
6
7
  import 'cloudflare';
7
8
 
@@ -49,6 +50,8 @@ declare class Diagnostics {
49
50
  errors: string[];
50
51
  warnings: string[];
51
52
  children: Diagnostics[];
53
+ /** Set to true when an unexpected/unknown field is encountered during validation. */
54
+ hasUnexpectedFields: boolean;
52
55
  /**
53
56
  * Create a new Diagnostics object.
54
57
  * @param description A general description of this collection of messages.
@@ -60,6 +63,8 @@ declare class Diagnostics {
60
63
  addChild(diagnostics: Diagnostics): void;
61
64
  /** Does this or any of its children have errors. */
62
65
  hasErrors(): boolean;
66
+ /** Does this or any of its children have unexpected fields. */
67
+ hasUnexpectedFieldsInTree(): boolean;
63
68
  /** Render the errors of this and all its children. */
64
69
  renderErrors(): string;
65
70
  /** Does this or any of its children have warnings. */
@@ -83,7 +88,7 @@ declare const bucketFormatMessage = "Bucket names must begin and end with an alp
83
88
  * Config field names for bindings (e.g., "kv_namespaces", "d1_databases").
84
89
  * These are the keys used in Wrangler's config file
85
90
  */
86
- type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "ratelimits" | "assets" | "unsafe_hello_world" | "worker_loaders" | "vpc_services";
91
+ type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "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";
87
92
  /**
88
93
  * @deprecated new code should use getBindingTypeFriendlyName() instead
89
94
  */
@@ -133,6 +138,8 @@ declare function normalizeAndValidateConfig(rawConfig: RawConfig, configPath: st
133
138
  */
134
139
  declare function isDockerfile(imagePath: string, configPath: string | undefined): boolean;
135
140
 
141
+ type ConfigBindingOptions = Pick<Config, "ai" | "browser" | "d1_databases" | "dispatch_namespaces" | "durable_objects" | "queues" | "r2_buckets" | "services" | "kv_namespaces" | "mtls_certificates" | "vectorize" | "workflows" | "vpc_services">;
142
+
136
143
  declare function configFormat(configPath: string | undefined): "json" | "jsonc" | "toml" | "none";
137
144
  declare function configFileName(configPath: string | undefined): "wrangler.json" | "wrangler.jsonc" | "wrangler.toml" | "Wrangler configuration";
138
145
  declare function formatConfigSnippet(snippet: RawConfig, configPath: Config["configPath"], formatted?: boolean): string;
@@ -252,6 +259,7 @@ declare class APIError extends ParseError {
252
259
  constructor({ status, ...rest }: Message & {
253
260
  status?: number;
254
261
  });
262
+ get status(): number | undefined;
255
263
  isGatewayError(): boolean;
256
264
  isRetryable(): boolean;
257
265
  get reportable(): boolean;
@@ -432,6 +440,8 @@ type VariableNames =
432
440
  | "CLOUDFLARE_ENV"
433
441
  /** Custom directory for Wrangler's cache files (overrides `node_modules/.cache/wrangler`). */
434
442
  | "WRANGLER_CACHE_DIR"
443
+ /** Custom path to cloudflared binary (overrides automatic binary management). */
444
+ | "CLOUDFLARED_PATH"
435
445
  /** Set to "staging" to use staging APIs instead of production. */
436
446
  | "WRANGLER_API_ENVIRONMENT"
437
447
  /** Custom auth domain (usually auto-configured). */
@@ -446,8 +456,14 @@ type VariableNames =
446
456
  | "WRANGLER_REVOKE_URL"
447
457
  /** Direct authorization token for API requests. */
448
458
  | "WRANGLER_CF_AUTHORIZATION_TOKEN"
459
+ /** Cloudflare Access Service Token Client ID. Used to authenticate with Access-protected domains in non-interactive environments (e.g. CI). */
460
+ | "CLOUDFLARE_ACCESS_CLIENT_ID"
461
+ /** Cloudflare Access Service Token Client Secret. Used with CLOUDFLARE_ACCESS_CLIENT_ID. */
462
+ | "CLOUDFLARE_ACCESS_CLIENT_SECRET"
449
463
  /** Enable the local explorer UI at /cdn-cgi/explorer (experimental, default: false). */
450
464
  | "X_LOCAL_EXPLORER"
465
+ /** Open the browser in headful (visible) mode when using the Browser Run API in local dev (default: false). */
466
+ | "X_BROWSER_HEADFUL"
451
467
  /** Override command used by `wrangler init` (default: "create cloudflare"). */
452
468
  | "WRANGLER_C3_COMMAND"
453
469
  /** Enable/disable telemetry data collection. */
@@ -694,9 +710,23 @@ declare const getCloudflareEnv: () => string | undefined;
694
710
  declare const getOpenNextDeployFromEnv: () => string | undefined;
695
711
  /**
696
712
  * `X_LOCAL_EXPLORER` enables the local explorer UI at /cdn-cgi/explorer.
697
- * This is an experimental feature flag. Defaults to false when not set.
698
713
  */
699
714
  declare const getLocalExplorerEnabledFromEnv: () => boolean;
715
+ /**
716
+ * `X_BROWSER_HEADFUL` opens the browser in headful (visible) mode when using the
717
+ * Browser Run API in local development.
718
+ *
719
+ * Set to "true" to enable:
720
+ *
721
+ * ```sh
722
+ * X_BROWSER_HEADFUL=true vite dev
723
+ * ```
724
+ *
725
+ * Note: when using `@cloudflare/playwright`, two Chrome windows may appear — the initial blank
726
+ * page and the one created by `browser.newPage()`. This is expected due to how Playwright handles
727
+ * browser contexts via CDP.
728
+ */
729
+ declare const getBrowserRenderingHeadfulFromEnv: () => boolean;
700
730
  /**
701
731
  * `CLOUDFLARE_CF_FETCH_ENABLED` controls whether Miniflare fetches the `cf.json` file
702
732
  * containing request.cf properties from workers.cloudflare.com.
@@ -733,6 +763,13 @@ declare const getCfFetchPathFromEnv: () => string | undefined;
733
763
  * Useful for Yarn PnP or projects without node_modules.
734
764
  */
735
765
  declare const getWranglerCacheDirFromEnv: () => string | undefined;
766
+ /**
767
+ * `CLOUDFLARED_PATH` specifies a custom path to a cloudflared binary.
768
+ *
769
+ * If set, Wrangler will use this cloudflared binary instead of downloading one.
770
+ * The path must point to an existing executable file.
771
+ */
772
+ declare const getCloudflaredPathFromEnv: () => string | undefined;
736
773
 
737
774
  declare function getGlobalWranglerConfigPath(): string;
738
775
 
@@ -743,24 +780,6 @@ type DD = `${number}${number}`;
743
780
  * Represents a valid compatibility date, a string such as `2025-09-27`
744
781
  */
745
782
  type CompatDate = `${YYYY}-${MM}-${DD}`;
746
- type GetCompatDateOptions = {
747
- projectPath?: string;
748
- };
749
- type GetCompatDateResult = {
750
- date: CompatDate;
751
- source: "workerd" | "fallback";
752
- };
753
- /**
754
- * Gets the compatibility date of the locally installed workerd package.
755
- *
756
- * If the package is not found the fallback date of 2025-09-27 is returned instead.
757
- *
758
- * Additionally, if the workerd date is set to the future then the current date is returned instead.
759
- *
760
- * @param options.projectPath the path to the project
761
- * @returns an object including the compatibility date and its source
762
- */
763
- declare function getLocalWorkerdCompatibilityDate({ projectPath, }?: GetCompatDateOptions): GetCompatDateResult;
764
783
  /**
765
784
  * Discern whether a string represents a compatibility date (`YYYY-MM-DD`)
766
785
  *
@@ -769,12 +788,9 @@ declare function getLocalWorkerdCompatibilityDate({ projectPath, }?: GetCompatDa
769
788
  */
770
789
  declare function isCompatDate(str: string): str is CompatDate;
771
790
  /**
772
- * Returns the date formatted as a compatibility date
773
- *
774
- * @param date The target date to convert
775
- * @returns The date as a CompatDate string (a string following the format `YYYY-MM-DD`)
791
+ * Returns today's date as a compatibility date string (`YYYY-MM-DD`).
776
792
  */
777
- declare function formatCompatibilityDate(date: Date): CompatDate;
793
+ declare function getTodaysCompatDate(): CompatDate;
778
794
 
779
795
  /**
780
796
  * Returns whether the given path is a directory
@@ -815,4 +831,4 @@ declare function removeDir(dirPath: string, options?: {
815
831
  */
816
832
  declare function removeDirSync(dirPath: string): void;
817
833
 
818
- export { APIError, Binding, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, DeprecationError, FatalError, JsonFriendlyFatalError, type Location, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, type TelemetryMessage, UserError, WorkerMetadataBinding, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, findWranglerConfig, formatCompatibilityDate, formatConfigSnippet, friendlyBindingNames, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getLocalExplorerEnabledFromEnv, getLocalWorkerdCompatibilityDate, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation, validatePagesConfig };
834
+ export { APIError, Binding, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, FatalError, JsonFriendlyFatalError, type Location, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, type TelemetryMessage, UserError, WorkerMetadataBinding, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, 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, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation, validatePagesConfig };