@cloudflare/workers-utils 0.23.2 → 0.25.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.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  export { assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate, mapWorkerMetadataBindings } from './chunk-J6D57QVQ.mjs';
2
2
  export { MetricsRegistry } from './chunk-O4YGOZSW.mjs';
3
- import { isDirectory, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, removeDirSync, ParseError, parseJSON, APIError, readFileSync as readFileSync$1, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-ULVYGN52.mjs';
4
- 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, isDirectory, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation } from './chunk-ULVYGN52.mjs';
3
+ import { partitionExports, isDirectory, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, removeDirSync, ParseError, parseJSON, APIError, parsePackageJSON, readFileSync as readFileSync$1, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-66IS76LR.mjs';
4
+ 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, isDirectory, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation } from './chunk-66IS76LR.mjs';
5
5
  import { __commonJS, __name, __require, __export, __toESM, __reExport } from './chunk-DCOBXSFB.mjs';
6
6
  import fs2, { accessSync, constants, writeFileSync, renameSync, existsSync, unlinkSync, mkdirSync, chmodSync, readFileSync } from 'node:fs';
7
7
  import assert from 'node:assert';
8
- import path3, { join, dirname } from 'node:path';
8
+ import path3, { join, dirname, basename, resolve } from 'node:path';
9
9
  import os, { arch } from 'node:os';
10
10
  import { execFileSync, spawn } from 'node:child_process';
11
11
  import { createHash } from 'node:crypto';
@@ -827,8 +827,8 @@ var require_command_exists = __commonJS({
827
827
  var isPathName = /[\\]/.test(s);
828
828
  if (isPathName) {
829
829
  var dirname2 = '"' + path5.dirname(s) + '"';
830
- var basename = '"' + path5.basename(s) + '"';
831
- return dirname2 + ":" + basename;
830
+ var basename2 = '"' + path5.basename(s) + '"';
831
+ return dirname2 + ":" + basename2;
832
832
  }
833
833
  return '"' + s + '"';
834
834
  }, "cleanInput");
@@ -836,10 +836,10 @@ var require_command_exists = __commonJS({
836
836
  module.exports = /* @__PURE__ */ __name(function commandExists(commandName, callback) {
837
837
  var cleanedCommandName = cleanInput(commandName);
838
838
  if (!callback && typeof Promise !== "undefined") {
839
- return new Promise(function(resolve, reject) {
839
+ return new Promise(function(resolve2, reject) {
840
840
  commandExists(commandName, function(error, output) {
841
841
  if (output) {
842
- resolve(commandName);
842
+ resolve2(commandName);
843
843
  } else {
844
844
  reject(error);
845
845
  }
@@ -1757,7 +1757,7 @@ var require_update_check = __commonJS({
1757
1757
  });
1758
1758
  await writeFile(file, content, "utf8");
1759
1759
  }, "updateCache");
1760
- var loadPackage = /* @__PURE__ */ __name((url, authInfo) => new Promise((resolve, reject) => {
1760
+ var loadPackage = /* @__PURE__ */ __name((url, authInfo) => new Promise((resolve2, reject) => {
1761
1761
  const options = {
1762
1762
  host: url.hostname,
1763
1763
  path: url.pathname,
@@ -1788,7 +1788,7 @@ var require_update_check = __commonJS({
1788
1788
  response.on("end", () => {
1789
1789
  try {
1790
1790
  const parsedData = JSON.parse(rawData);
1791
- resolve(parsedData);
1791
+ resolve2(parsedData);
1792
1792
  } catch (e2) {
1793
1793
  reject(e2);
1794
1794
  }
@@ -1861,6 +1861,16 @@ var require_update_check = __commonJS({
1861
1861
  }
1862
1862
  });
1863
1863
 
1864
+ // src/config/durable-object-exports.ts
1865
+ function getDurableObjectExports(exports) {
1866
+ return partitionExports(exports)["durable-object"];
1867
+ }
1868
+ __name(getDurableObjectExports, "getDurableObjectExports");
1869
+ function hasDurableObjectExports(exports) {
1870
+ return Object.keys(getDurableObjectExports(exports)).length > 0;
1871
+ }
1872
+ __name(hasDurableObjectExports, "hasDurableObjectExports");
1873
+
1864
1874
  // src/config/config.ts
1865
1875
  var defaultWranglerConfig = {
1866
1876
  /* COMPUTED_FIELDS */
@@ -1953,6 +1963,7 @@ var defaultWranglerConfig = {
1953
1963
  jsx_factory: "React.createElement",
1954
1964
  jsx_fragment: "React.Fragment",
1955
1965
  migrations: [],
1966
+ exports: {},
1956
1967
  triggers: {
1957
1968
  crons: void 0
1958
1969
  },
@@ -6104,7 +6115,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({
6104
6115
  var getRegistryPath = getEnvironmentVariableFactory({
6105
6116
  variableName: "WRANGLER_REGISTRY_PATH",
6106
6117
  defaultValue() {
6107
- return path3.join(getGlobalWranglerConfigPath(), "registry");
6118
+ return path3.join(getGlobalConfigPath(), "registry");
6108
6119
  }
6109
6120
  });
6110
6121
  var getD1ExtraLocationChoices = getEnvironmentVariableFactory({
@@ -7115,11 +7126,12 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
7115
7126
  validateRequiredProperty(diagnostics, "site", "bucket", bucket, "string");
7116
7127
  validateTypedArray(diagnostics, "sites.include", include, "string");
7117
7128
  validateTypedArray(diagnostics, "sites.exclude", exclude, "string");
7129
+ const legacySiteEntryPoint = rawConfig.site["entry-point"];
7118
7130
  validateOptionalProperty(
7119
7131
  diagnostics,
7120
7132
  "site",
7121
7133
  "entry-point",
7122
- rawConfig.site["entry-point"],
7134
+ legacySiteEntryPoint,
7123
7135
  "string"
7124
7136
  );
7125
7137
  deprecated(
@@ -7129,15 +7141,15 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
7129
7141
  `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
7130
7142
  \`\`\`
7131
7143
  main = "${path3.join(
7132
- String(rawConfig.site["entry-point"]) || "workers-site",
7133
- path3.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js"
7144
+ String(legacySiteEntryPoint) || "workers-site",
7145
+ path3.extname(String(legacySiteEntryPoint) || "workers-site") ? "" : "index.js"
7134
7146
  )}"
7135
7147
  \`\`\``,
7136
7148
  false,
7137
7149
  void 0,
7138
7150
  "warning"
7139
7151
  );
7140
- let siteEntryPoint = rawConfig.site["entry-point"];
7152
+ let siteEntryPoint = legacySiteEntryPoint;
7141
7153
  if (!mainEntryPoint && !siteEntryPoint) {
7142
7154
  diagnostics.warnings.push(
7143
7155
  `Because you've defined a [site] configuration, we're defaulting to "workers-site" for the deprecated \`site.entry-point\`field.
@@ -7765,6 +7777,14 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
7765
7777
  validateMigrations,
7766
7778
  []
7767
7779
  ),
7780
+ exports: inheritable(
7781
+ diagnostics,
7782
+ topLevelEnv,
7783
+ rawEnv,
7784
+ "exports",
7785
+ validateExports,
7786
+ {}
7787
+ ),
7768
7788
  kv_namespaces: notInheritable(
7769
7789
  diagnostics,
7770
7790
  topLevelEnv,
@@ -8214,12 +8234,18 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
8214
8234
  void 0
8215
8235
  )
8216
8236
  };
8217
- warnIfDurableObjectsHaveNoMigrations(
8237
+ warnIfDurableObjectsHaveNoLifecycleConfig(
8218
8238
  diagnostics,
8219
8239
  environment.durable_objects,
8220
8240
  environment.migrations,
8241
+ environment.exports,
8221
8242
  configPath
8222
8243
  );
8244
+ errorIfMigrationsAndExportsBothSet(
8245
+ diagnostics,
8246
+ environment.migrations,
8247
+ environment.exports
8248
+ );
8223
8249
  if (envName !== "top level") {
8224
8250
  validateAdditionalProperties(
8225
8251
  diagnostics,
@@ -11127,6 +11153,210 @@ var validateMigrations = /* @__PURE__ */ __name((diagnostics, field, value) => {
11127
11153
  }
11128
11154
  return valid;
11129
11155
  }, "validateMigrations");
11156
+ var VALID_EXPORT_STORAGES = /* @__PURE__ */ new Set(["sqlite", "legacy-kv"]);
11157
+ var JS_IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
11158
+ function validateDurableObjectExportProperties(diagnostics, className, durableObjectExport, allowedProperties) {
11159
+ let valid = true;
11160
+ for (const key of Object.keys(durableObjectExport)) {
11161
+ if (!allowedProperties.includes(key)) {
11162
+ diagnostics.errors.push(
11163
+ `"exports.${className}.${key}" is forbidden on state "${durableObjectExport.state ?? "created"}".`
11164
+ );
11165
+ valid = false;
11166
+ }
11167
+ }
11168
+ if (!valid) {
11169
+ diagnostics.errors.push(
11170
+ `Allowed properties are: ${ENGLISH.format(allowedProperties)}.`
11171
+ );
11172
+ }
11173
+ return valid;
11174
+ }
11175
+ __name(validateDurableObjectExportProperties, "validateDurableObjectExportProperties");
11176
+ function validateDurableObjectExport(diagnostics, className, durableObjectExport) {
11177
+ let valid = true;
11178
+ if (className === "") {
11179
+ diagnostics.errors.push(`"export" keys cannot be the empty string.`);
11180
+ valid = false;
11181
+ }
11182
+ switch (durableObjectExport.state) {
11183
+ case void 0:
11184
+ case "created": {
11185
+ if (typeof durableObjectExport.storage !== "string" || !VALID_EXPORT_STORAGES.has(durableObjectExport.storage)) {
11186
+ diagnostics.errors.push(
11187
+ `"exports.${className}.storage" is required for state "created" and must be one of ${ENGLISH.format(VALID_EXPORT_STORAGES)}, but got ${JSON.stringify(durableObjectExport.storage)}`
11188
+ );
11189
+ valid = false;
11190
+ }
11191
+ valid = validateDurableObjectExportProperties(
11192
+ diagnostics,
11193
+ className,
11194
+ durableObjectExport,
11195
+ ["type", "state", "storage"]
11196
+ ) && valid;
11197
+ break;
11198
+ }
11199
+ case "deleted": {
11200
+ valid = validateDurableObjectExportProperties(
11201
+ diagnostics,
11202
+ className,
11203
+ durableObjectExport,
11204
+ ["type", "state"]
11205
+ ) && valid;
11206
+ break;
11207
+ }
11208
+ case "renamed": {
11209
+ if (typeof durableObjectExport.renamed_to !== "string" || durableObjectExport.renamed_to === "") {
11210
+ diagnostics.errors.push(
11211
+ `"exports.${className}.renamed_to" is required for state "renamed" and must be a non-empty string.`
11212
+ );
11213
+ valid = false;
11214
+ } else {
11215
+ if (!JS_IDENTIFIER_RE.test(durableObjectExport.renamed_to)) {
11216
+ diagnostics.errors.push(
11217
+ `"exports.${className}.renamed_to" must be a valid JavaScript identifier (got "${durableObjectExport.renamed_to}").`
11218
+ );
11219
+ valid = false;
11220
+ }
11221
+ if (durableObjectExport.renamed_to === className) {
11222
+ diagnostics.errors.push(
11223
+ `"exports.${className}.renamed_to" cannot equal the source class name "${className}".`
11224
+ );
11225
+ valid = false;
11226
+ }
11227
+ }
11228
+ valid = validateDurableObjectExportProperties(
11229
+ diagnostics,
11230
+ className,
11231
+ durableObjectExport,
11232
+ ["type", "state", "renamed_to"]
11233
+ ) && valid;
11234
+ break;
11235
+ }
11236
+ case "transferred": {
11237
+ if (typeof durableObjectExport.transferred_to !== "string" || durableObjectExport.transferred_to === "") {
11238
+ diagnostics.errors.push(
11239
+ `"exports.${className}.transferred_to" is required for state "transferred" and must be a non-empty string.`
11240
+ );
11241
+ valid = false;
11242
+ }
11243
+ valid = validateDurableObjectExportProperties(
11244
+ diagnostics,
11245
+ className,
11246
+ durableObjectExport,
11247
+ ["type", "state", "transferred_to"]
11248
+ ) && valid;
11249
+ break;
11250
+ }
11251
+ case "expecting-transfer": {
11252
+ if (typeof durableObjectExport.storage !== "string" || !VALID_EXPORT_STORAGES.has(durableObjectExport.storage)) {
11253
+ diagnostics.errors.push(
11254
+ `"exports.${className}.storage" is required for state "expecting-transfer" and must be one of ${ENGLISH.format(VALID_EXPORT_STORAGES)}, but got ${JSON.stringify(durableObjectExport.storage)}`
11255
+ );
11256
+ valid = false;
11257
+ }
11258
+ if (typeof durableObjectExport.transfer_from !== "string" || durableObjectExport.transfer_from === "") {
11259
+ diagnostics.errors.push(
11260
+ `"exports.${className}.transfer_from" is required for state "expecting-transfer" and must be a non-empty string.`
11261
+ );
11262
+ valid = false;
11263
+ }
11264
+ valid = validateDurableObjectExportProperties(
11265
+ diagnostics,
11266
+ className,
11267
+ durableObjectExport,
11268
+ ["type", "state", "storage", "transfer_from"]
11269
+ ) && valid;
11270
+ break;
11271
+ }
11272
+ default: {
11273
+ const state = durableObjectExport.state;
11274
+ diagnostics.errors.push(
11275
+ `"exports.${className}.state" must be one of "created", "deleted", "renamed", "transferred", or "expecting-transfer" but got ${JSON.stringify(state)}.`
11276
+ );
11277
+ valid = false;
11278
+ }
11279
+ }
11280
+ return valid;
11281
+ }
11282
+ __name(validateDurableObjectExport, "validateDurableObjectExport");
11283
+ function validateWorkerExport(diagnostics, exportName, workerExport) {
11284
+ let valid = true;
11285
+ valid = validateAdditionalProperties(
11286
+ diagnostics,
11287
+ `exports.${exportName}`,
11288
+ Object.keys(workerExport),
11289
+ ["type", "cache"]
11290
+ ) && valid;
11291
+ valid = validateWorkerExportCache(
11292
+ diagnostics,
11293
+ `exports.${exportName}.cache`,
11294
+ workerExport.cache
11295
+ ) && valid;
11296
+ return valid;
11297
+ }
11298
+ __name(validateWorkerExport, "validateWorkerExport");
11299
+ function validateWorkerExportCache(diagnostics, field, value) {
11300
+ if (value === void 0) {
11301
+ return true;
11302
+ }
11303
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
11304
+ diagnostics.errors.push(
11305
+ `"${field}" should be an object but got ${JSON.stringify(value)}.`
11306
+ );
11307
+ return false;
11308
+ }
11309
+ const cache = value;
11310
+ let valid = true;
11311
+ valid = validateRequiredProperty(
11312
+ diagnostics,
11313
+ field,
11314
+ "enabled",
11315
+ cache.enabled,
11316
+ "boolean"
11317
+ ) && valid;
11318
+ valid = validateAdditionalProperties(diagnostics, field, Object.keys(cache), [
11319
+ "enabled"
11320
+ ]) && valid;
11321
+ return valid;
11322
+ }
11323
+ __name(validateWorkerExportCache, "validateWorkerExportCache");
11324
+ var validateExports = /* @__PURE__ */ __name((diagnostics, field, value) => {
11325
+ if (value === void 0 || value === null) {
11326
+ return true;
11327
+ }
11328
+ if (typeof value !== "object" || Array.isArray(value)) {
11329
+ diagnostics.errors.push(
11330
+ `The optional "${field}" field should be an object keyed by class name, but got ${JSON.stringify(
11331
+ value
11332
+ )}`
11333
+ );
11334
+ return false;
11335
+ }
11336
+ let valid = true;
11337
+ for (const [exportName, exportConfig] of Object.entries(value)) {
11338
+ if (typeof exportConfig !== "object" || exportConfig === null) {
11339
+ diagnostics.errors.push(
11340
+ `"exports.${exportName}" should be an object but got ${JSON.stringify(
11341
+ exportConfig
11342
+ )}.`
11343
+ );
11344
+ valid = false;
11345
+ continue;
11346
+ }
11347
+ if (exportConfig.type === "durable-object") {
11348
+ valid = validateDurableObjectExport(diagnostics, exportName, exportConfig) && valid;
11349
+ } else if (exportConfig.type === "worker") {
11350
+ valid = validateWorkerExport(diagnostics, exportName, exportConfig) && valid;
11351
+ } else {
11352
+ valid = false;
11353
+ diagnostics.errors.push(
11354
+ `"exports.${exportName}.type" must be "durable-object" or "worker", but got ${JSON.stringify(exportConfig.type)}.`
11355
+ );
11356
+ }
11357
+ }
11358
+ return valid;
11359
+ }, "validateExports");
11130
11360
  var validateObservability = /* @__PURE__ */ __name((diagnostics, field, value) => {
11131
11361
  if (value === void 0) {
11132
11362
  return true;
@@ -11282,43 +11512,71 @@ var validateCache = /* @__PURE__ */ __name((diagnostics, field, value) => {
11282
11512
  val.enabled,
11283
11513
  "boolean"
11284
11514
  ) && isValid2;
11515
+ isValid2 = validateOptionalProperty(
11516
+ diagnostics,
11517
+ field,
11518
+ "cross_version_cache",
11519
+ val.cross_version_cache,
11520
+ "boolean"
11521
+ ) && isValid2;
11285
11522
  isValid2 = validateAdditionalProperties(diagnostics, field, Object.keys(val), [
11286
- "enabled"
11523
+ "enabled",
11524
+ "cross_version_cache"
11287
11525
  ]) && isValid2;
11288
11526
  return isValid2;
11289
11527
  }, "validateCache");
11290
- function warnIfDurableObjectsHaveNoMigrations(diagnostics, durableObjects, migrations, configPath) {
11291
- if (Array.isArray(durableObjects.bindings) && durableObjects.bindings.length > 0) {
11292
- const exportedDurableObjects = (durableObjects.bindings || []).filter(
11293
- (binding) => !binding.script_name
11294
- );
11295
- if (exportedDurableObjects.length > 0 && migrations.length === 0) {
11296
- if (!exportedDurableObjects.some(
11297
- (exportedDurableObject) => typeof exportedDurableObject.class_name !== "string"
11298
- )) {
11299
- const durableObjectClassnames = exportedDurableObjects.map(
11300
- (durable) => durable.class_name
11301
- );
11302
- diagnostics.warnings.push(dedent`
11303
- In your ${configFileName(configPath)} file, you have configured \`durable_objects\` exported by this Worker (${durableObjectClassnames.join(", ")}), but no \`migrations\` for them. This may not work as expected until you add a \`migrations\` section to your ${configFileName(configPath)} file. Add the following configuration:
11304
-
11305
- \`\`\`
11306
- ${formatConfigSnippet(
11307
- {
11308
- migrations: [
11309
- { tag: "v1", new_sqlite_classes: durableObjectClassnames }
11310
- ]
11311
- },
11312
- configPath
11313
- )}
11314
- \`\`\`
11315
-
11316
- Refer to https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/ for more details.`);
11317
- }
11528
+ function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects, migrations, exports, configPath) {
11529
+ if (!Array.isArray(durableObjects.bindings) || durableObjects.bindings.length === 0) {
11530
+ return;
11531
+ }
11532
+ const exportedDurableObjects = durableObjects.bindings.filter(
11533
+ (binding) => !binding.script_name
11534
+ );
11535
+ const exportsCovers = /* @__PURE__ */ __name((className) => {
11536
+ const entry = exports?.[className];
11537
+ if (entry === void 0 || entry.type !== "durable-object") {
11538
+ return false;
11318
11539
  }
11540
+ const state = entry.state ?? "created";
11541
+ return state === "created" || state === "expecting-transfer";
11542
+ }, "exportsCovers");
11543
+ const uncoveredByExports = exportedDurableObjects.filter(
11544
+ (binding) => typeof binding.class_name !== "string" || !exportsCovers(binding.class_name)
11545
+ );
11546
+ if (uncoveredByExports.length === 0 || migrations.length > 0) {
11547
+ return;
11548
+ }
11549
+ if (uncoveredByExports.some(
11550
+ (exportedDurableObject) => typeof exportedDurableObject.class_name !== "string"
11551
+ )) {
11552
+ return;
11553
+ }
11554
+ const durableObjectClassnames = uncoveredByExports.map(
11555
+ (durable) => durable.class_name
11556
+ );
11557
+ const suggestedExports = {};
11558
+ for (const className of durableObjectClassnames) {
11559
+ suggestedExports[className] = {
11560
+ type: "durable-object",
11561
+ storage: "sqlite"
11562
+ };
11563
+ }
11564
+ diagnostics.warnings.push(dedent`
11565
+ In your ${configFileName(configPath)} file, you have configured \`durable_objects\` exported by this Worker (${durableObjectClassnames.join(", ")}), but no live \`exports\` entry for them. This may not work as expected until you add a live \`durable-object\` entry to \`exports\` for each. Add the following configuration:
11566
+
11567
+ \`\`\`
11568
+ ${formatConfigSnippet({ exports: suggestedExports }, configPath)}
11569
+ \`\`\``);
11570
+ }
11571
+ __name(warnIfDurableObjectsHaveNoLifecycleConfig, "warnIfDurableObjectsHaveNoLifecycleConfig");
11572
+ function errorIfMigrationsAndExportsBothSet(diagnostics, migrations, exports) {
11573
+ if (migrations.length > 0 && exports !== void 0 && Object.values(exports).some((entry) => entry.type === "durable-object")) {
11574
+ diagnostics.errors.push(
11575
+ `\`migrations\` and \`exports\` are mutually exclusive. Choose one or the other to declare your Durable Object lifecycle, but not both.`
11576
+ );
11319
11577
  }
11320
11578
  }
11321
- __name(warnIfDurableObjectsHaveNoMigrations, "warnIfDurableObjectsHaveNoMigrations");
11579
+ __name(errorIfMigrationsAndExportsBothSet, "errorIfMigrationsAndExportsBothSet");
11322
11580
  var validatePythonModules = /* @__PURE__ */ __name((diagnostics, field, value, topLevelEnv) => {
11323
11581
  if (value === void 0) {
11324
11582
  return true;
@@ -11783,7 +12041,7 @@ https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-
11783
12041
  }
11784
12042
  __name(getLatestVersionInfo, "getLatestVersionInfo");
11785
12043
  function getCacheDir(version) {
11786
- return join(getGlobalWranglerConfigPath(), "cloudflared", version);
12044
+ return join(getGlobalConfigPath(), "cloudflared", version);
11787
12045
  }
11788
12046
  __name(getCacheDir, "getCacheDir");
11789
12047
  function getCloudflaredBinPath(version) {
@@ -11828,7 +12086,7 @@ On Linux, make sure you have the required dependencies:
11828
12086
  errorMessage += ` - For Debian/Ubuntu: sudo apt-get install libc6
11829
12087
  `;
11830
12088
  }
11831
- const cacheDir = join(getGlobalWranglerConfigPath(), "cloudflared");
12089
+ const cacheDir = join(getGlobalConfigPath(), "cloudflared");
11832
12090
  errorMessage += `
11833
12091
  You can try:
11834
12092
  `;
@@ -12143,7 +12401,7 @@ async function spawnCloudflared(args, options) {
12143
12401
  }
12144
12402
  __name(spawnCloudflared, "spawnCloudflared");
12145
12403
  function removeCloudflaredCache(version) {
12146
- const cacheDir = version ? getCacheDir(version) : join(getGlobalWranglerConfigPath(), "cloudflared");
12404
+ const cacheDir = version ? getCacheDir(version) : join(getGlobalConfigPath(), "cloudflared");
12147
12405
  if (existsSync(cacheDir)) {
12148
12406
  removeDirSync(cacheDir);
12149
12407
  return cacheDir;
@@ -12320,7 +12578,7 @@ function terminateCloudflared(cloudflared) {
12320
12578
  }
12321
12579
  __name(terminateCloudflared, "terminateCloudflared");
12322
12580
  function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
12323
- return new Promise((resolve, reject) => {
12581
+ return new Promise((resolve2, reject) => {
12324
12582
  let resolved = false;
12325
12583
  let stderrOutput = "";
12326
12584
  const logger = options?.logger;
@@ -12348,7 +12606,7 @@ function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
12348
12606
  if (match && !resolved) {
12349
12607
  resolved = true;
12350
12608
  clearTimeout(timeoutId);
12351
- resolve({ mode: "quick", publicUrl: new URL(match[0]) });
12609
+ resolve2({ mode: "quick", publicUrl: new URL(match[0]) });
12352
12610
  }
12353
12611
  });
12354
12612
  }
@@ -12693,6 +12951,10 @@ function throwFetchError(resource, response, status) {
12693
12951
  if (code) {
12694
12952
  error.code = code;
12695
12953
  }
12954
+ const meta = errors[0]?.meta;
12955
+ if (meta) {
12956
+ error.meta = meta;
12957
+ }
12696
12958
  error.accountTag = extractAccountTag(resource);
12697
12959
  throw error;
12698
12960
  }
@@ -12867,6 +13129,96 @@ function getHostFromUrl(urlLike) {
12867
13129
  }
12868
13130
  }
12869
13131
  __name(getHostFromUrl, "getHostFromUrl");
13132
+
13133
+ // src/package-manager.ts
13134
+ var NpmPackageManager = {
13135
+ type: "npm",
13136
+ npx: "npx",
13137
+ dlx: ["npx"],
13138
+ lockFiles: ["package-lock.json"]
13139
+ };
13140
+ var PnpmPackageManager = {
13141
+ type: "pnpm",
13142
+ npx: "pnpm",
13143
+ lockFiles: ["pnpm-lock.yaml"],
13144
+ dlx: ["pnpm", "dlx"]
13145
+ };
13146
+ var YarnPackageManager = {
13147
+ type: "yarn",
13148
+ npx: "yarn",
13149
+ dlx: ["yarn", "dlx"],
13150
+ lockFiles: ["yarn.lock"]
13151
+ };
13152
+ var BunPackageManager = {
13153
+ type: "bun",
13154
+ npx: "bunx",
13155
+ dlx: ["bunx"],
13156
+ lockFiles: ["bun.lockb", "bun.lock"]
13157
+ };
13158
+ var invalidWorkerNameCharsRegex = /[^a-z0-9- ]/g;
13159
+ var invalidWorkerNameStartEndRegex = /^(-+)|(-+)$/g;
13160
+ var workerNameLengthLimit = 63;
13161
+ function checkWorkerNameValidity(input) {
13162
+ if (!input) {
13163
+ return {
13164
+ valid: false,
13165
+ cause: "Worker names cannot be empty."
13166
+ };
13167
+ }
13168
+ if (input.match(invalidWorkerNameStartEndRegex)) {
13169
+ return {
13170
+ valid: false,
13171
+ cause: "Worker names cannot start or end with a dash."
13172
+ };
13173
+ }
13174
+ if (input.match(invalidWorkerNameCharsRegex)) {
13175
+ return {
13176
+ valid: false,
13177
+ cause: "Project names must only contain lowercase characters, numbers, and dashes."
13178
+ };
13179
+ }
13180
+ if (input.length > workerNameLengthLimit) {
13181
+ return {
13182
+ valid: false,
13183
+ cause: "Project names must be less than 63 characters."
13184
+ };
13185
+ }
13186
+ return { valid: true };
13187
+ }
13188
+ __name(checkWorkerNameValidity, "checkWorkerNameValidity");
13189
+ function toValidWorkerName(input) {
13190
+ if (checkWorkerNameValidity(input).valid) {
13191
+ return input;
13192
+ }
13193
+ input = input.replaceAll("_", "-").replace(invalidWorkerNameCharsRegex, "-").replace(invalidWorkerNameStartEndRegex, "").slice(0, workerNameLengthLimit);
13194
+ if (!input.length) {
13195
+ return "my-worker";
13196
+ }
13197
+ return input;
13198
+ }
13199
+ __name(toValidWorkerName, "toValidWorkerName");
13200
+ function getWorkerName(projectOrWorkerName = "", projectPath) {
13201
+ const rawName = getCIOverrideName() ?? (projectOrWorkerName || basename(projectPath));
13202
+ return toValidWorkerName(rawName);
13203
+ }
13204
+ __name(getWorkerName, "getWorkerName");
13205
+ function getWorkerNameFromProject(projectPath) {
13206
+ const packageJsonPath = resolve(projectPath, "package.json");
13207
+ let packageJsonName;
13208
+ try {
13209
+ const packageJson = parsePackageJSON(
13210
+ readFileSync$1(packageJsonPath),
13211
+ packageJsonPath
13212
+ );
13213
+ packageJsonName = packageJson.name;
13214
+ } catch {
13215
+ }
13216
+ return getWorkerName(packageJsonName, projectPath);
13217
+ }
13218
+ __name(getWorkerNameFromProject, "getWorkerNameFromProject");
13219
+
13220
+ // src/index.ts
13221
+ var friendlyBindingNames2 = friendlyBindingNames;
12870
13222
  /*! Bundled license information:
12871
13223
 
12872
13224
  deep-extend/lib/deep-extend.js:
@@ -12901,4 +13253,4 @@ safe-buffer/index.js:
12901
13253
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
12902
13254
  */
12903
13255
 
12904
- export { COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, PatchConfigError, addAuthorizationHeader, bucketFormatMessage, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, 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, getGlobalConfigPath, getGlobalWranglerConfigPath, getHostFromRoute, getHostFromUrl, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasMorePages, hasProperty, isDockerfile, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, truncate, validatePagesConfig };
13256
+ export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, 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, getGlobalConfigPath, getGlobalWranglerConfigPath, getHostFromRoute, getHostFromUrl, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isDockerfile, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };