@cloudflare/workers-utils 0.33.0 → 0.33.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.mjs CHANGED
@@ -1,9 +1,9 @@
1
- export { NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, mapWorkerMetadataBindings, resolveNodejsCompat, stripRedundantNodejsCompatFlags } from './chunk-NMPHTL5R.mjs';
1
+ export { DEFAULT_COMPAT_DATE, assertNever, constructWranglerConfig, mapWorkerMetadataBindings } from './chunk-IV7UMGT2.mjs';
2
2
  import { getGlobalConfigPath } from './chunk-34VZWBGB.mjs';
3
3
  export { getGlobalConfigPath, getGlobalWranglerCachePath } from './chunk-34VZWBGB.mjs';
4
4
  export { MetricsRegistry } from './chunk-Z62CVNHJ.mjs';
5
- import { partitionExports, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-3K53PSCY.mjs';
6
- export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-3K53PSCY.mjs';
5
+ import { UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, getDurableObjectExports, getContainerNameToClassNameMap, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-QFKPUV4H.mjs';
6
+ export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, getContainerDurableObjectClassNames, getContainerNameToClassNameMap, getDurableObjectExports, hasDurableObjectExports, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveContainerClassName, resolveWranglerConfigPath, searchLocation } from './chunk-QFKPUV4H.mjs';
7
7
  import { isDirectory, removeDirSync } from './chunk-53IMCORZ.mjs';
8
8
  export { isDirectory, removeDir, removeDirSync } from './chunk-53IMCORZ.mjs';
9
9
  import { __commonJS, __name, __require, __export, __toESM } from './chunk-Q72B4Q5Z.mjs';
@@ -1630,16 +1630,6 @@ var ARTIFACTS_EVENT_TYPES = [
1630
1630
  "cf.artifacts.repo.token.revoked"
1631
1631
  ];
1632
1632
 
1633
- // src/config/durable-object-exports.ts
1634
- function getDurableObjectExports(exports) {
1635
- return partitionExports(exports)["durable-object"];
1636
- }
1637
- __name(getDurableObjectExports, "getDurableObjectExports");
1638
- function hasDurableObjectExports(exports) {
1639
- return Object.keys(getDurableObjectExports(exports)).length > 0;
1640
- }
1641
- __name(hasDurableObjectExports, "hasDurableObjectExports");
1642
-
1643
1633
  // src/config/config.ts
1644
1634
  var defaultWranglerConfig = {
1645
1635
  /* COMPUTED_FIELDS */
@@ -1749,6 +1739,7 @@ var defaultWranglerConfig = {
1749
1739
  upload_source_maps: void 0,
1750
1740
  assets: void 0,
1751
1741
  observability: { enabled: true },
1742
+ access: void 0,
1752
1743
  cache: void 0,
1753
1744
  /** The default here is undefined so that we can delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable. */
1754
1745
  compliance_region: void 0,
@@ -16893,6 +16884,9 @@ function getWranglerSendMetricsFromEnv() {
16893
16884
  return getWranglerSendMetricsVariableFromEnv();
16894
16885
  }
16895
16886
  __name(getWranglerSendMetricsFromEnv, "getWranglerSendMetricsFromEnv");
16887
+ var getNoSkillsUpdatePromptsFromEnv = getBooleanEnvironmentVariableFactory({
16888
+ variableName: "WRANGLER_NO_SKILLS_UPDATE_PROMPTS"
16889
+ });
16896
16890
  var getWranglerSendErrorReportsFromEnv = getBooleanEnvironmentVariableFactory({
16897
16891
  variableName: "WRANGLER_SEND_ERROR_REPORTS",
16898
16892
  defaultValue: false
@@ -19073,6 +19067,14 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
19073
19067
  validateObservability,
19074
19068
  void 0
19075
19069
  ),
19070
+ access: inheritable(
19071
+ diagnostics,
19072
+ topLevelEnv,
19073
+ rawEnv,
19074
+ "access",
19075
+ validateAccess,
19076
+ void 0
19077
+ ),
19076
19078
  cache: inheritable(
19077
19079
  diagnostics,
19078
19080
  topLevelEnv,
@@ -19118,6 +19120,15 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
19118
19120
  environment.migrations,
19119
19121
  environment.exports
19120
19122
  );
19123
+ const containersDeclaredElsewhere = rawConfig !== void 0 ? rawConfig.containers !== void 0 : Object.values("env" in rawEnv ? rawEnv.env ?? {} : {}).some(
19124
+ (rawNamedEnv) => rawNamedEnv?.containers !== void 0
19125
+ );
19126
+ validateContainerExportLinks(
19127
+ diagnostics,
19128
+ environment.containers,
19129
+ environment.exports,
19130
+ containersDeclaredElsewhere
19131
+ );
19121
19132
  if (envName !== "top level") {
19122
19133
  validateAdditionalProperties(
19123
19134
  diagnostics,
@@ -20017,6 +20028,31 @@ Please add a binding for "${configBindingName}" to "env.${envName}.${field}.bind
20017
20028
  }
20018
20029
  return isValid;
20019
20030
  }, "validateBindingArray");
20031
+ function validateSshPublicKeys(diagnostics, field, value, nameRequired) {
20032
+ if (!Array.isArray(value)) {
20033
+ diagnostics.errors.push(`${field} must be an array`);
20034
+ return;
20035
+ }
20036
+ for (const [index, key] of value.entries()) {
20037
+ const fieldPath = `${field}[${index}]`;
20038
+ if (typeof key !== "object" || key === null || Array.isArray(key)) {
20039
+ diagnostics.errors.push(`${fieldPath} must be an object`);
20040
+ continue;
20041
+ }
20042
+ const hasValidName = nameRequired ? isRequiredProperty(key, "name", "string") : isOptionalProperty(key, "name", "string");
20043
+ if (!hasValidName) {
20044
+ diagnostics.errors.push(`${fieldPath}.name must be a string`);
20045
+ }
20046
+ if (!isRequiredProperty(key, "public_key", "string")) {
20047
+ diagnostics.errors.push(`${fieldPath}.public_key must be a string`);
20048
+ } else if (!key.public_key.toLowerCase().startsWith("ssh-ed25519")) {
20049
+ diagnostics.errors.push(
20050
+ `${fieldPath}.public_key is an unsupported key type. Please provide an ED25519 public key.`
20051
+ );
20052
+ }
20053
+ }
20054
+ }
20055
+ __name(validateSshPublicKeys, "validateSshPublicKeys");
20020
20056
  function validateContainerApp(envName, topLevelName, configPath) {
20021
20057
  return (diagnostics, field, value, config2) => {
20022
20058
  if (!value) {
@@ -20029,12 +20065,7 @@ function validateContainerApp(envName, topLevelName, configPath) {
20029
20065
  return false;
20030
20066
  }
20031
20067
  for (const containerAppOptional of value) {
20032
- if (!isOptionalProperty(value, "name", "string")) {
20033
- diagnostics.errors.push(
20034
- `Field "name", when present, should be a string, but got ${JSON.stringify(value)}`
20035
- );
20036
- }
20037
- validateRequiredProperty(
20068
+ validateOptionalProperty(
20038
20069
  diagnostics,
20039
20070
  field,
20040
20071
  "class_name",
@@ -20049,14 +20080,19 @@ function validateContainerApp(envName, topLevelName, configPath) {
20049
20080
  "string"
20050
20081
  );
20051
20082
  if (!containerAppOptional.name) {
20052
- if (!topLevelName || !isOptionalProperty(containerAppOptional, "class_name", "string")) {
20083
+ if (containerAppOptional.class_name === void 0) {
20084
+ diagnostics.errors.push(
20085
+ `"containers.name" is required when "containers.class_name" is not defined, because there is no class name to derive a default name from. Either name this container and reference it from a Durable Object's \`exports\` entry, or set "containers.class_name".`
20086
+ );
20087
+ } else if (!topLevelName) {
20053
20088
  diagnostics.errors.push(
20054
20089
  `Must have either a top level "name" and "containers.class_name" field defined, or have field "containers.name" defined.`
20055
20090
  );
20091
+ } else {
20092
+ let name = `${topLevelName}-${containerAppOptional.class_name}`;
20093
+ name += config2 === void 0 ? "" : `-${envName}`;
20094
+ containerAppOptional.name = name.toLowerCase().replace(/ /g, "-");
20056
20095
  }
20057
- let name = `${topLevelName}-${containerAppOptional.class_name}`;
20058
- name += config2 === void 0 ? "" : `-${envName}`;
20059
- containerAppOptional.name = name.toLowerCase().replace(/ /g, "-");
20060
20096
  }
20061
20097
  if (!containerAppOptional.configuration?.image && !containerAppOptional.image) {
20062
20098
  diagnostics.errors.push(
@@ -20067,12 +20103,11 @@ function validateContainerApp(envName, topLevelName, configPath) {
20067
20103
  diagnostics.warnings.push(
20068
20104
  `"containers.configuration" is deprecated. Use top level "containers" fields instead. "configuration.image" should be "image", limits should be set via "instance_type".`
20069
20105
  );
20070
- if (typeof containerAppOptional.configuration !== "object" || Array.isArray(containerAppOptional.configuration)) {
20106
+ if (typeof containerAppOptional.configuration !== "object" || containerAppOptional.configuration === null || Array.isArray(containerAppOptional.configuration)) {
20071
20107
  diagnostics.errors.push(
20072
20108
  `"containers.configuration" should be an object`
20073
20109
  );
20074
- }
20075
- if (containerAppOptional.instance_type && (containerAppOptional.configuration.disk !== void 0 || containerAppOptional.configuration.vcpu !== void 0 || containerAppOptional.configuration.memory_mib !== void 0)) {
20110
+ } else if (containerAppOptional.instance_type && (containerAppOptional.configuration.disk !== void 0 || containerAppOptional.configuration.vcpu !== void 0 || containerAppOptional.configuration.memory_mib !== void 0)) {
20076
20111
  diagnostics.errors.push(
20077
20112
  `Cannot set custom limits via "containers.configuration" and use preset "instance_type" limits at the same time.`
20078
20113
  );
@@ -20257,7 +20292,7 @@ function validateContainerApp(envName, topLevelName, configPath) {
20257
20292
  "unsafe"
20258
20293
  ]
20259
20294
  );
20260
- if ("configuration" in containerAppOptional) {
20295
+ if (typeof containerAppOptional.configuration === "object" && containerAppOptional.configuration !== null && !Array.isArray(containerAppOptional.configuration)) {
20261
20296
  validateAdditionalProperties(
20262
20297
  diagnostics,
20263
20298
  `${field}.configuration`,
@@ -20291,52 +20326,20 @@ function validateContainerApp(envName, topLevelName, configPath) {
20291
20326
  }
20292
20327
  }
20293
20328
  if ("authorized_keys" in containerAppOptional) {
20294
- if (!Array.isArray(containerAppOptional.authorized_keys)) {
20295
- diagnostics.errors.push(`${field}.authorized_keys must be an array`);
20296
- } else {
20297
- for (const index in containerAppOptional.authorized_keys) {
20298
- const fieldPath = `${field}.authorized_keys[${index}]`;
20299
- const key = containerAppOptional.authorized_keys[index];
20300
- if (!isRequiredProperty(key, "name", "string")) {
20301
- diagnostics.errors.push(`${fieldPath}.name must be a string`);
20302
- }
20303
- if (!isRequiredProperty(key, "public_key", "string")) {
20304
- diagnostics.errors.push(
20305
- `${fieldPath}.public_key must be a string`
20306
- );
20307
- }
20308
- if (!key.public_key.toLowerCase().startsWith("ssh-ed25519")) {
20309
- diagnostics.errors.push(
20310
- `${fieldPath}.public_key is a unsupported key type. Please provide a ED25519 public key.`
20311
- );
20312
- }
20313
- }
20314
- }
20329
+ validateSshPublicKeys(
20330
+ diagnostics,
20331
+ `${field}.authorized_keys`,
20332
+ containerAppOptional.authorized_keys,
20333
+ true
20334
+ );
20315
20335
  }
20316
20336
  if ("trusted_user_ca_keys" in containerAppOptional) {
20317
- if (!Array.isArray(containerAppOptional.trusted_user_ca_keys)) {
20318
- diagnostics.errors.push(
20319
- `${field}.trusted_user_ca_keys must be an array`
20320
- );
20321
- } else {
20322
- for (const index in containerAppOptional.trusted_user_ca_keys) {
20323
- const fieldPath = `${field}.trusted_user_ca_keys[${index}]`;
20324
- const key = containerAppOptional.trusted_user_ca_keys[index];
20325
- if (!isOptionalProperty(key, "name", "string")) {
20326
- diagnostics.errors.push(`${fieldPath}.name must be a string`);
20327
- }
20328
- if (!isRequiredProperty(key, "public_key", "string")) {
20329
- diagnostics.errors.push(
20330
- `${fieldPath}.public_key must be a string`
20331
- );
20332
- }
20333
- if (!key.public_key.toLowerCase().startsWith("ssh-ed25519")) {
20334
- diagnostics.errors.push(
20335
- `${fieldPath}.public_key is a unsupported key type. Please provide a ED25519 public key.`
20336
- );
20337
- }
20338
- }
20339
- }
20337
+ validateSshPublicKeys(
20338
+ diagnostics,
20339
+ `${field}.trusted_user_ca_keys`,
20340
+ containerAppOptional.trusted_user_ca_keys,
20341
+ false
20342
+ );
20340
20343
  }
20341
20344
  if (validateOptionalProperty(
20342
20345
  diagnostics,
@@ -21407,12 +21410,13 @@ function validateQueues(envName) {
21407
21410
  )}.`
21408
21411
  );
21409
21412
  isValid = false;
21410
- }
21411
- for (let i = 0; i < consumers.length; i++) {
21412
- const consumer = consumers[i];
21413
- const consumerPath = `${fieldPath}.consumers[${i}]`;
21414
- if (!validateConsumer(diagnostics, consumerPath, consumer, config2)) {
21415
- isValid = false;
21413
+ } else {
21414
+ for (let i = 0; i < consumers.length; i++) {
21415
+ const consumer = consumers[i];
21416
+ const consumerPath = `${fieldPath}.consumers[${i}]`;
21417
+ if (!validateConsumer(diagnostics, consumerPath, consumer, config2)) {
21418
+ isValid = false;
21419
+ }
21416
21420
  }
21417
21421
  }
21418
21422
  }
@@ -22187,6 +22191,25 @@ function validateDurableObjectExportProperties(diagnostics, className, durableOb
22187
22191
  return valid;
22188
22192
  }
22189
22193
  __name(validateDurableObjectExportProperties, "validateDurableObjectExportProperties");
22194
+ function validateDurableObjectExportContainer(diagnostics, className, durableObjectExport) {
22195
+ if (durableObjectExport.container === void 0) {
22196
+ return true;
22197
+ }
22198
+ if (typeof durableObjectExport.container !== "string" || durableObjectExport.container === "") {
22199
+ diagnostics.errors.push(
22200
+ `"exports.${className}.container" must be a non-empty string naming a container in the "containers" array, but got ${JSON.stringify(durableObjectExport.container)}.`
22201
+ );
22202
+ return false;
22203
+ }
22204
+ if (durableObjectExport.storage === "legacy-kv") {
22205
+ diagnostics.errors.push(
22206
+ `"exports.${className}.container" requires "storage" to be "sqlite". Containers are not supported on Durable Objects using the "legacy-kv" storage backend.`
22207
+ );
22208
+ return false;
22209
+ }
22210
+ return true;
22211
+ }
22212
+ __name(validateDurableObjectExportContainer, "validateDurableObjectExportContainer");
22190
22213
  function validateDurableObjectExport(diagnostics, className, durableObjectExport) {
22191
22214
  let valid = true;
22192
22215
  if (className === "") {
@@ -22202,11 +22225,16 @@ function validateDurableObjectExport(diagnostics, className, durableObjectExport
22202
22225
  );
22203
22226
  valid = false;
22204
22227
  }
22228
+ valid = validateDurableObjectExportContainer(
22229
+ diagnostics,
22230
+ className,
22231
+ durableObjectExport
22232
+ ) && valid;
22205
22233
  valid = validateDurableObjectExportProperties(
22206
22234
  diagnostics,
22207
22235
  className,
22208
22236
  durableObjectExport,
22209
- ["type", "state", "storage"]
22237
+ ["type", "state", "storage", "container"]
22210
22238
  ) && valid;
22211
22239
  break;
22212
22240
  }
@@ -22275,11 +22303,16 @@ function validateDurableObjectExport(diagnostics, className, durableObjectExport
22275
22303
  );
22276
22304
  valid = false;
22277
22305
  }
22306
+ valid = validateDurableObjectExportContainer(
22307
+ diagnostics,
22308
+ className,
22309
+ durableObjectExport
22310
+ ) && valid;
22278
22311
  valid = validateDurableObjectExportProperties(
22279
22312
  diagnostics,
22280
22313
  className,
22281
22314
  durableObjectExport,
22282
- ["type", "state", "storage", "transfer_from"]
22315
+ ["type", "state", "storage", "transfer_from", "container"]
22283
22316
  ) && valid;
22284
22317
  break;
22285
22318
  }
@@ -22527,6 +22560,46 @@ function validateHeadSamplingRate(diagnostics, container, key, samplingRate) {
22527
22560
  }
22528
22561
  }
22529
22562
  __name(validateHeadSamplingRate, "validateHeadSamplingRate");
22563
+ var validateAccess = /* @__PURE__ */ __name((diagnostics, field, value) => {
22564
+ if (value === void 0) {
22565
+ return true;
22566
+ }
22567
+ if (typeof value !== "object" || value === null) {
22568
+ diagnostics.errors.push(
22569
+ `"${field}" should be an object but got ${JSON.stringify(value)}.`
22570
+ );
22571
+ return false;
22572
+ }
22573
+ const val = value;
22574
+ let isValid = true;
22575
+ isValid = validateOptionalProperty(diagnostics, field, "dev", val.dev, "object") && isValid;
22576
+ isValid = validateAdditionalProperties(diagnostics, field, Object.keys(val), [
22577
+ "dev"
22578
+ ]) && isValid;
22579
+ if (typeof val.dev === "object" && val.dev !== null) {
22580
+ isValid = validateRequiredProperty(
22581
+ diagnostics,
22582
+ `${field}.dev`,
22583
+ "aud",
22584
+ val.dev.aud,
22585
+ "string"
22586
+ ) && isValid;
22587
+ isValid = validateOptionalProperty(
22588
+ diagnostics,
22589
+ `${field}.dev`,
22590
+ "identity",
22591
+ val.dev.identity,
22592
+ "object"
22593
+ ) && isValid;
22594
+ isValid = validateAdditionalProperties(
22595
+ diagnostics,
22596
+ `${field}.dev`,
22597
+ Object.keys(val.dev),
22598
+ ["aud", "identity"]
22599
+ ) && isValid;
22600
+ }
22601
+ return isValid;
22602
+ }, "validateAccess");
22530
22603
  var validateCache = /* @__PURE__ */ __name((diagnostics, field, value) => {
22531
22604
  if (value === void 0) {
22532
22605
  return true;
@@ -22611,6 +22684,124 @@ function errorIfMigrationsAndExportsBothSet(diagnostics, migrations, exports) {
22611
22684
  }
22612
22685
  }
22613
22686
  __name(errorIfMigrationsAndExportsBothSet, "errorIfMigrationsAndExportsBothSet");
22687
+ function validateContainerExportLinks(diagnostics, containers, exports, containersDeclaredElsewhere) {
22688
+ if (containers !== void 0 && !Array.isArray(containers)) {
22689
+ return;
22690
+ }
22691
+ if (containers === void 0 && containersDeclaredElsewhere) {
22692
+ return;
22693
+ }
22694
+ const containersByName = /* @__PURE__ */ new Map();
22695
+ const duplicateNames = /* @__PURE__ */ new Set();
22696
+ for (const container of containers ?? []) {
22697
+ if (typeof container.name !== "string") {
22698
+ continue;
22699
+ }
22700
+ if (containersByName.has(container.name)) {
22701
+ duplicateNames.add(container.name);
22702
+ } else {
22703
+ containersByName.set(container.name, container);
22704
+ }
22705
+ }
22706
+ for (const name of [...duplicateNames].sort()) {
22707
+ diagnostics.errors.push(
22708
+ `"containers" contains more than one container named "${name}". Container names must be unique.`
22709
+ );
22710
+ }
22711
+ const containerCountByClassName = /* @__PURE__ */ new Map();
22712
+ for (const container of containers ?? []) {
22713
+ if (typeof container.class_name !== "string") {
22714
+ continue;
22715
+ }
22716
+ containerCountByClassName.set(
22717
+ container.class_name,
22718
+ (containerCountByClassName.get(container.class_name) ?? 0) + 1
22719
+ );
22720
+ }
22721
+ const overSubscribedClassNames = new Set(
22722
+ [...containerCountByClassName].filter(([, count]) => count > 1).map(([className]) => className)
22723
+ );
22724
+ for (const className of [...overSubscribedClassNames].sort()) {
22725
+ diagnostics.errors.push(
22726
+ `More than one container is attached to the Durable Object "${className}". A Durable Object can only have one container attached to it.`
22727
+ );
22728
+ }
22729
+ const durableObjectExports = getDurableObjectExports(exports);
22730
+ const liveExportClassNames = /* @__PURE__ */ new Set();
22731
+ const classNamesByContainerName = /* @__PURE__ */ new Map();
22732
+ for (const [className, entry] of Object.entries(durableObjectExports)) {
22733
+ if (entry.state !== void 0 && entry.state !== "created" && entry.state !== "expecting-transfer") {
22734
+ continue;
22735
+ }
22736
+ liveExportClassNames.add(className);
22737
+ if (typeof entry.container !== "string" || entry.container === "") {
22738
+ continue;
22739
+ }
22740
+ if (!containersByName.has(entry.container)) {
22741
+ diagnostics.errors.push(
22742
+ `"exports.${className}.container" references a container named "${entry.container}", but no container with that name is defined in "containers".`
22743
+ );
22744
+ continue;
22745
+ }
22746
+ classNamesByContainerName.set(entry.container, [
22747
+ ...classNamesByContainerName.get(entry.container) ?? [],
22748
+ className
22749
+ ]);
22750
+ }
22751
+ for (const [containerName, classNames] of classNamesByContainerName) {
22752
+ if (classNames.length > 1) {
22753
+ diagnostics.errors.push(
22754
+ `The container "${containerName}" is referenced by more than one Durable Object export (${classNames.join(", ")}). A container can only back a single Durable Object.`
22755
+ );
22756
+ }
22757
+ }
22758
+ const containerNameToClassName = getContainerNameToClassNameMap(exports);
22759
+ const usesDurableObjectExports = Object.keys(durableObjectExports).length > 0;
22760
+ for (const container of containers ?? []) {
22761
+ if (typeof container.name !== "string") {
22762
+ continue;
22763
+ }
22764
+ if (container.class_name === void 0) {
22765
+ if (!containerNameToClassName.has(container.name)) {
22766
+ diagnostics.errors.push(
22767
+ `The container "${container.name}" is not linked to a Durable Object. Either set "containers.class_name", or reference this container from a Durable Object's \`exports\` entry via its "container" field.`
22768
+ );
22769
+ }
22770
+ continue;
22771
+ }
22772
+ if (overSubscribedClassNames.has(container.class_name)) {
22773
+ continue;
22774
+ }
22775
+ const exportEntry = durableObjectExports[container.class_name];
22776
+ const referencedContainerName = exportEntry !== void 0 && "container" in exportEntry ? exportEntry.container : void 0;
22777
+ if (typeof referencedContainerName === "string" && referencedContainerName !== container.name) {
22778
+ diagnostics.errors.push(
22779
+ `The container "${container.name}" sets "class_name" to "${container.class_name}", but "exports.${container.class_name}.container" is "${referencedContainerName}". A Durable Object and its container must reference each other consistently.`
22780
+ );
22781
+ continue;
22782
+ }
22783
+ const claimingClassNames = classNamesByContainerName.get(container.name);
22784
+ const claimingClassName = claimingClassNames?.length === 1 ? claimingClassNames[0] : void 0;
22785
+ if (claimingClassName !== void 0 && claimingClassName !== container.class_name) {
22786
+ diagnostics.errors.push(
22787
+ `The container "${container.name}" sets "class_name" to "${container.class_name}", but "exports.${claimingClassName}.container" references it. A Durable Object and its container must reference each other consistently.`
22788
+ );
22789
+ continue;
22790
+ }
22791
+ if (usesDurableObjectExports && !liveExportClassNames.has(container.class_name)) {
22792
+ diagnostics.errors.push(
22793
+ `The container "${container.name}" sets "class_name" to "${container.class_name}", but "exports" has no live "durable-object" entry for "${container.class_name}".`
22794
+ );
22795
+ continue;
22796
+ }
22797
+ if (referencedContainerName === void 0 && exportEntry !== void 0 && "storage" in exportEntry && exportEntry.storage === "legacy-kv") {
22798
+ diagnostics.errors.push(
22799
+ `The container "${container.name}" sets "class_name" to "${container.class_name}", but "exports.${container.class_name}.storage" is "legacy-kv". Containers are not supported on Durable Objects using the "legacy-kv" storage backend.`
22800
+ );
22801
+ }
22802
+ }
22803
+ }
22804
+ __name(validateContainerExportLinks, "validateContainerExportLinks");
22614
22805
  var validatePythonModules = /* @__PURE__ */ __name((diagnostics, field, value, topLevelEnv) => {
22615
22806
  if (value === void 0) {
22616
22807
  return true;
@@ -22941,6 +23132,43 @@ function findFileUp(name, startDir, lastDir) {
22941
23132
  return void 0;
22942
23133
  }
22943
23134
  __name(findFileUp, "findFileUp");
23135
+ function isCompatDate(str) {
23136
+ return /^\d{4}-\d{2}-\d{2}$/.test(str);
23137
+ }
23138
+ __name(isCompatDate, "isCompatDate");
23139
+ function formatCompatibilityDate(date5) {
23140
+ const compatDate = date5.toISOString().slice(0, 10);
23141
+ assert2(isCompatDate(compatDate));
23142
+ return compatDate;
23143
+ }
23144
+ __name(formatCompatibilityDate, "formatCompatibilityDate");
23145
+ function getTodaysCompatDate() {
23146
+ return formatCompatibilityDate(/* @__PURE__ */ new Date());
23147
+ }
23148
+ __name(getTodaysCompatDate, "getTodaysCompatDate");
23149
+ var NODEJS_COMPAT_DEFAULT_ON_DATE = "2026-08-04";
23150
+ function isNodejsCompatDefaultOn(compatibilityDate) {
23151
+ return compatibilityDate !== void 0 && compatibilityDate >= NODEJS_COMPAT_DEFAULT_ON_DATE;
23152
+ }
23153
+ __name(isNodejsCompatDefaultOn, "isNodejsCompatDefaultOn");
23154
+ var NODEJS_COMPAT_V2_SWITCH_OVER_DATE = "2024-09-23";
23155
+ function resolveNodejsCompat(compatibilityDate, compatibilityFlags) {
23156
+ const isDefaultOn = isNodejsCompatDefaultOn(compatibilityDate);
23157
+ const isNodejsCompatEnabled = compatibilityFlags.includes("nodejs_compat") || isDefaultOn && !compatibilityFlags.includes("no_nodejs_compat");
23158
+ const isNodejsCompatV2Enabled = compatibilityFlags.includes("nodejs_compat_v2") || !compatibilityFlags.includes("no_nodejs_compat_v2") && (isDefaultOn || isNodejsCompatEnabled && compatibilityDate >= NODEJS_COMPAT_V2_SWITCH_OVER_DATE);
23159
+ return { isNodejsCompatEnabled, isNodejsCompatV2Enabled };
23160
+ }
23161
+ __name(resolveNodejsCompat, "resolveNodejsCompat");
23162
+ function stripRedundantNodejsCompatFlags(compatibilityDate, compatibilityFlags) {
23163
+ if (!isNodejsCompatDefaultOn(compatibilityDate)) {
23164
+ return compatibilityFlags;
23165
+ }
23166
+ const redundantFlags = ["nodejs_compat", "nodejs_compat_v2"].filter(
23167
+ (flag) => !compatibilityFlags.includes(`no_${flag}`)
23168
+ );
23169
+ return compatibilityFlags.filter((flag) => !redundantFlags.includes(flag));
23170
+ }
23171
+ __name(stripRedundantNodejsCompatFlags, "stripRedundantNodejsCompatFlags");
22944
23172
 
22945
23173
  // src/is-interactive.ts
22946
23174
  var import_ci_info = __toESM(require_ci_info());
@@ -25096,4 +25324,4 @@ safe-buffer/index.js:
25096
25324
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
25097
25325
  */
25098
25326
 
25099
- export { ARTIFACTS_EVENT_TYPES, BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, _forceColour, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, formatZodError, friendlyBindingNames2 as 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, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDoNotTrackEnabled, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validatePagesConfig };
25327
+ export { ARTIFACTS_EVENT_TYPES, BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, _forceColour, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, formatZodError, friendlyBindingNames2 as 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, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getNoSkillsUpdatePromptsFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTodaysCompatDate, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasMorePages, hasProperty, isCI, isCompatDate, isDoNotTrackEnabled, isDockerfile, isInteractive, isNodejsCompatDefaultOn, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, resolveNodejsCompat, retryOnAPIFailure, spawnCloudflared, startTunnel, stripRedundantNodejsCompatFlags, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validatePagesConfig };