@cloudflare/workers-utils 0.33.1 → 0.34.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,4 +1,4 @@
1
- export { DEFAULT_COMPAT_DATE, assertNever, constructWranglerConfig, mapWorkerMetadataBindings } from './chunk-IV7UMGT2.mjs';
1
+ export { DEFAULT_COMPAT_DATE, assertNever, constructWranglerConfig, mapWorkerMetadataBindings } from './chunk-QKX75RGI.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';
@@ -7,12 +7,12 @@ export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFI
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';
10
- import fs2, { statSync, accessSync, constants, writeFileSync, renameSync, existsSync, unlinkSync, mkdirSync, chmodSync, readFileSync as readFileSync$1 } from 'node:fs';
10
+ import fs2, { statSync, accessSync, constants, writeFileSync, renameSync, existsSync, unlinkSync, mkdirSync, chmodSync, readFileSync as readFileSync$1, appendFileSync } from 'node:fs';
11
11
  import assert2 from 'node:assert';
12
12
  import * as path2 from 'node:path';
13
- import path2__default, { join, dirname, basename, resolve } from 'node:path';
13
+ import path2__default, { join, dirname, resolve, basename } from 'node:path';
14
14
  import { execFileSync, spawn } from 'node:child_process';
15
- import { createHash } from 'node:crypto';
15
+ import { createHash, randomBytes } from 'node:crypto';
16
16
  import { arch } from 'node:os';
17
17
  import { fetch, Headers, FormData, Response } from 'undici';
18
18
  import { URLSearchParams } from 'node:url';
@@ -23,7 +23,7 @@ import { assert as assert$1 } from 'node:console';
23
23
 
24
24
  // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json
25
25
  var require_vendors = __commonJS({
26
- "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json"(exports, module) {
26
+ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json"(exports$1, module) {
27
27
  module.exports = [
28
28
  {
29
29
  name: "Agola CI",
@@ -392,33 +392,33 @@ var require_vendors = __commonJS({
392
392
 
393
393
  // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js
394
394
  var require_ci_info = __commonJS({
395
- "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js"(exports) {
395
+ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js"(exports$1) {
396
396
  var vendors = require_vendors();
397
397
  var env = process.env;
398
- Object.defineProperty(exports, "_vendors", {
398
+ Object.defineProperty(exports$1, "_vendors", {
399
399
  value: vendors.map(function(v) {
400
400
  return v.constant;
401
401
  })
402
402
  });
403
- exports.name = null;
404
- exports.isPR = null;
405
- exports.id = null;
403
+ exports$1.name = null;
404
+ exports$1.isPR = null;
405
+ exports$1.id = null;
406
406
  if (env.CI !== "false") {
407
407
  vendors.forEach(function(vendor) {
408
408
  const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
409
409
  const isCI2 = envs.every(function(obj) {
410
410
  return checkEnv(obj);
411
411
  });
412
- exports[vendor.constant] = isCI2;
412
+ exports$1[vendor.constant] = isCI2;
413
413
  if (!isCI2) {
414
414
  return;
415
415
  }
416
- exports.name = vendor.name;
417
- exports.isPR = checkPR(vendor);
418
- exports.id = vendor.constant;
416
+ exports$1.name = vendor.name;
417
+ exports$1.isPR = checkPR(vendor);
418
+ exports$1.id = vendor.constant;
419
419
  });
420
420
  }
421
- exports.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
421
+ exports$1.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
422
422
  (env.BUILD_ID || // Jenkins, Cloudbees
423
423
  env.BUILD_NUMBER || // Jenkins, TeamCity
424
424
  env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
@@ -428,7 +428,7 @@ var require_ci_info = __commonJS({
428
428
  env.CI_NAME || // Codeship and others
429
429
  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
430
430
  env.RUN_ID || // TaskCluster, dsari
431
- exports.name || false));
431
+ exports$1.name || false));
432
432
  function checkEnv(obj) {
433
433
  if (typeof obj === "string") return !!env[obj];
434
434
  if ("env" in obj) {
@@ -474,7 +474,7 @@ var require_ci_info = __commonJS({
474
474
 
475
475
  // ../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js
476
476
  var require_command_exists = __commonJS({
477
- "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js"(exports, module) {
477
+ "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js"(exports$1, module) {
478
478
  var exec = __require("child_process").exec;
479
479
  var execSync = __require("child_process").execSync;
480
480
  var fs3 = __require("fs");
@@ -582,9 +582,9 @@ var require_command_exists = __commonJS({
582
582
  cleanInput = /* @__PURE__ */ __name(function(s) {
583
583
  var isPathName = /[\\]/.test(s);
584
584
  if (isPathName) {
585
- var dirname3 = '"' + path6.dirname(s) + '"';
585
+ var dirname4 = '"' + path6.dirname(s) + '"';
586
586
  var basename2 = '"' + path6.basename(s) + '"';
587
- return dirname3 + ":" + basename2;
587
+ return dirname4 + ":" + basename2;
588
588
  }
589
589
  return '"' + s + '"';
590
590
  }, "cleanInput");
@@ -592,10 +592,10 @@ var require_command_exists = __commonJS({
592
592
  module.exports = /* @__PURE__ */ __name(function commandExists(commandName, callback) {
593
593
  var cleanedCommandName = cleanInput(commandName);
594
594
  if (!callback && typeof Promise !== "undefined") {
595
- return new Promise(function(resolve2, reject) {
595
+ return new Promise(function(resolve3, reject) {
596
596
  commandExists(commandName, function(error51, output) {
597
597
  if (output) {
598
- resolve2(commandName);
598
+ resolve3(commandName);
599
599
  } else {
600
600
  reject(error51);
601
601
  }
@@ -621,18 +621,18 @@ var require_command_exists = __commonJS({
621
621
 
622
622
  // ../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/index.js
623
623
  var require_command_exists2 = __commonJS({
624
- "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/index.js"(exports, module) {
624
+ "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/index.js"(exports$1, module) {
625
625
  module.exports = require_command_exists();
626
626
  }
627
627
  });
628
628
 
629
629
  // ../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js
630
630
  var require_ini = __commonJS({
631
- "../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js"(exports) {
632
- exports.parse = exports.decode = decode3;
633
- exports.stringify = exports.encode = encode3;
634
- exports.safe = safe;
635
- exports.unsafe = unsafe;
631
+ "../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js"(exports$1) {
632
+ exports$1.parse = exports$1.decode = decode3;
633
+ exports$1.stringify = exports$1.encode = encode3;
634
+ exports$1.safe = safe;
635
+ exports$1.unsafe = unsafe;
636
636
  var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
637
637
  function encode3(obj, opt) {
638
638
  var children = [];
@@ -796,7 +796,7 @@ var require_ini = __commonJS({
796
796
 
797
797
  // ../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js
798
798
  var require_strip_json_comments = __commonJS({
799
- "../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js"(exports, module) {
799
+ "../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js"(exports$1, module) {
800
800
  var singleComment = 1;
801
801
  var multiComment = 2;
802
802
  function stripWithoutWhitespace() {
@@ -864,17 +864,17 @@ var require_strip_json_comments = __commonJS({
864
864
 
865
865
  // ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js
866
866
  var require_utils = __commonJS({
867
- "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js"(exports) {
867
+ "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js"(exports$1) {
868
868
  var fs3 = __require("fs");
869
869
  var ini = require_ini();
870
870
  var path6 = __require("path");
871
871
  var stripJsonComments = require_strip_json_comments();
872
- var parse3 = exports.parse = function(content) {
872
+ var parse3 = exports$1.parse = function(content) {
873
873
  if (/^\s*{/.test(content))
874
874
  return JSON.parse(stripJsonComments(content));
875
875
  return ini.parse(content);
876
876
  };
877
- var file2 = exports.file = function() {
877
+ var file2 = exports$1.file = function() {
878
878
  var args = [].slice.call(arguments).filter(function(arg) {
879
879
  return arg != null;
880
880
  });
@@ -888,11 +888,11 @@ var require_utils = __commonJS({
888
888
  return;
889
889
  }
890
890
  };
891
- exports.json = function() {
891
+ exports$1.json = function() {
892
892
  var content = file2.apply(null, arguments);
893
893
  return content ? parse3(content) : null;
894
894
  };
895
- exports.env = function(prefix, env2) {
895
+ exports$1.env = function(prefix, env2) {
896
896
  env2 = env2 || process.env;
897
897
  var obj = {};
898
898
  var l = prefix.length;
@@ -917,7 +917,7 @@ var require_utils = __commonJS({
917
917
  }
918
918
  return obj;
919
919
  };
920
- exports.find = function() {
920
+ exports$1.find = function() {
921
921
  var rel = path6.join.apply(null, [].slice.call(arguments));
922
922
  function find2(start, rel2) {
923
923
  var file3 = path6.join(start, rel2);
@@ -937,7 +937,7 @@ var require_utils = __commonJS({
937
937
 
938
938
  // ../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js
939
939
  var require_deep_extend = __commonJS({
940
- "../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js"(exports, module) {
940
+ "../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js"(exports$1, module) {
941
941
  function isSpecificValue(val) {
942
942
  return val instanceof Buffer || val instanceof Date || val instanceof RegExp ? true : false;
943
943
  }
@@ -1022,7 +1022,7 @@ var require_deep_extend = __commonJS({
1022
1022
 
1023
1023
  // ../../node_modules/.pnpm/minimist@1.2.6/node_modules/minimist/index.js
1024
1024
  var require_minimist = __commonJS({
1025
- "../../node_modules/.pnpm/minimist@1.2.6/node_modules/minimist/index.js"(exports, module) {
1025
+ "../../node_modules/.pnpm/minimist@1.2.6/node_modules/minimist/index.js"(exports$1, module) {
1026
1026
  module.exports = function(args, opts) {
1027
1027
  if (!opts) opts = {};
1028
1028
  var flags = { bools: {}, strings: {}, unknownFn: null };
@@ -1225,7 +1225,7 @@ var require_minimist = __commonJS({
1225
1225
 
1226
1226
  // ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js
1227
1227
  var require_rc = __commonJS({
1228
- "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports, module) {
1228
+ "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports$1, module) {
1229
1229
  var cc = require_utils();
1230
1230
  var join3 = __require("path").join;
1231
1231
  var deepExtend = require_deep_extend();
@@ -1277,7 +1277,7 @@ var require_rc = __commonJS({
1277
1277
 
1278
1278
  // ../../node_modules/.pnpm/registry-url@3.1.0/node_modules/registry-url/index.js
1279
1279
  var require_registry_url = __commonJS({
1280
- "../../node_modules/.pnpm/registry-url@3.1.0/node_modules/registry-url/index.js"(exports, module) {
1280
+ "../../node_modules/.pnpm/registry-url@3.1.0/node_modules/registry-url/index.js"(exports$1, module) {
1281
1281
  module.exports = function(scope) {
1282
1282
  var rc = require_rc()("npm", { registry: "https://registry.npmjs.org/" });
1283
1283
  var url2 = rc[scope + ":registry"] || rc.registry;
@@ -1288,7 +1288,7 @@ var require_registry_url = __commonJS({
1288
1288
 
1289
1289
  // ../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js
1290
1290
  var require_safe_buffer = __commonJS({
1291
- "../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports, module) {
1291
+ "../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports$1, module) {
1292
1292
  var buffer = __require("buffer");
1293
1293
  var Buffer2 = buffer.Buffer;
1294
1294
  function copyProps(src, dst) {
@@ -1300,8 +1300,8 @@ var require_safe_buffer = __commonJS({
1300
1300
  if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
1301
1301
  module.exports = buffer;
1302
1302
  } else {
1303
- copyProps(buffer, exports);
1304
- exports.Buffer = SafeBuffer;
1303
+ copyProps(buffer, exports$1);
1304
+ exports$1.Buffer = SafeBuffer;
1305
1305
  }
1306
1306
  function SafeBuffer(arg, encodingOrOffset, length) {
1307
1307
  return Buffer2(arg, encodingOrOffset, length);
@@ -1348,7 +1348,7 @@ var require_safe_buffer = __commonJS({
1348
1348
 
1349
1349
  // ../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/base64.js
1350
1350
  var require_base64 = __commonJS({
1351
- "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/base64.js"(exports, module) {
1351
+ "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/base64.js"(exports$1, module) {
1352
1352
  var safeBuffer = require_safe_buffer().Buffer;
1353
1353
  function decodeBase64(base643) {
1354
1354
  return safeBuffer.from(base643, "base64").toString("utf8");
@@ -1367,7 +1367,7 @@ var require_base64 = __commonJS({
1367
1367
 
1368
1368
  // ../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/index.js
1369
1369
  var require_registry_auth_token = __commonJS({
1370
- "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/index.js"(exports, module) {
1370
+ "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/index.js"(exports$1, module) {
1371
1371
  var url2 = __require("url");
1372
1372
  var base643 = require_base64();
1373
1373
  var decodeBase64 = base643.decodeBase64;
@@ -1465,7 +1465,7 @@ var require_registry_auth_token = __commonJS({
1465
1465
 
1466
1466
  // ../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js
1467
1467
  var require_update_check = __commonJS({
1468
- "../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js"(exports, module) {
1468
+ "../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js"(exports$1, module) {
1469
1469
  var { URL: URL2 } = __require("url");
1470
1470
  var { join: join3 } = __require("path");
1471
1471
  var fs3 = __require("fs");
@@ -1513,7 +1513,7 @@ var require_update_check = __commonJS({
1513
1513
  });
1514
1514
  await writeFile(file2, content, "utf8");
1515
1515
  }, "updateCache");
1516
- var loadPackage = /* @__PURE__ */ __name((url2, authInfo) => new Promise((resolve2, reject) => {
1516
+ var loadPackage = /* @__PURE__ */ __name((url2, authInfo) => new Promise((resolve3, reject) => {
1517
1517
  const options = {
1518
1518
  host: url2.hostname,
1519
1519
  path: url2.pathname,
@@ -1544,7 +1544,7 @@ var require_update_check = __commonJS({
1544
1544
  response.on("end", () => {
1545
1545
  try {
1546
1546
  const parsedData = JSON.parse(rawData);
1547
- resolve2(parsedData);
1547
+ resolve3(parsedData);
1548
1548
  } catch (e2) {
1549
1549
  reject(e2);
1550
1550
  }
@@ -1676,6 +1676,7 @@ var defaultWranglerConfig = {
1676
1676
  consumers: []
1677
1677
  // WORKERS SUPPORT ONLY!!
1678
1678
  },
1679
+ connect: [],
1679
1680
  r2_buckets: [],
1680
1681
  d1_databases: [],
1681
1682
  vectorize: [],
@@ -18701,6 +18702,16 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
18701
18702
  validateQueues(envName),
18702
18703
  { producers: [], consumers: [] }
18703
18704
  ),
18705
+ connect: notInheritable(
18706
+ diagnostics,
18707
+ topLevelEnv,
18708
+ rawConfig,
18709
+ rawEnv,
18710
+ envName,
18711
+ "connect",
18712
+ validateConnectHandlers(envName),
18713
+ []
18714
+ ),
18704
18715
  r2_buckets: notInheritable(
18705
18716
  diagnostics,
18706
18717
  topLevelEnv,
@@ -19104,7 +19115,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
19104
19115
  topLevelEnv,
19105
19116
  rawEnv,
19106
19117
  "previews",
19107
- validatePreviewsConfig(envName),
19118
+ validatePreviewsConfig(envName, configPath),
19108
19119
  void 0
19109
19120
  )
19110
19121
  };
@@ -19657,14 +19668,6 @@ var validateWorkflowBinding = /* @__PURE__ */ __name((diagnostics, field, value)
19657
19668
  );
19658
19669
  isValid = false;
19659
19670
  }
19660
- if (!isOptionalProperty(value, "remote", "boolean")) {
19661
- diagnostics.errors.push(
19662
- `"${field}" bindings should, optionally, have a boolean "remote" field but got ${JSON.stringify(
19663
- value
19664
- )}.`
19665
- );
19666
- isValid = false;
19667
- }
19668
19671
  if (hasProperty(value, "schedules") && value.schedules !== void 0) {
19669
19672
  if (typeof value.schedules === "string") {
19670
19673
  if (value.schedules.length === 0) {
@@ -19738,7 +19741,6 @@ var validateWorkflowBinding = /* @__PURE__ */ __name((diagnostics, field, value)
19738
19741
  "name",
19739
19742
  "class_name",
19740
19743
  "script_name",
19741
- "remote",
19742
19744
  "limits",
19743
19745
  "schedules"
19744
19746
  ]);
@@ -20053,7 +20055,48 @@ function validateSshPublicKeys(diagnostics, field, value, nameRequired) {
20053
20055
  }
20054
20056
  }
20055
20057
  __name(validateSshPublicKeys, "validateSshPublicKeys");
20056
- function validateContainerApp(envName, topLevelName, configPath) {
20058
+ function validatePreviewsContainers(envName, configPath) {
20059
+ const innerValidator = validateContainerApp(envName, void 0, configPath, {
20060
+ generateDefaultName: false
20061
+ });
20062
+ return (diagnostics, field, value, config2) => {
20063
+ if (Array.isArray(value)) {
20064
+ const nameFields = [...value.entries()].filter(
20065
+ ([, entry]) => entry && typeof entry === "object" && "name" in entry
20066
+ ).map(([index]) => `"${field}[${index}].name"`);
20067
+ if (nameFields.length > 0) {
20068
+ diagnostics.errors.push(
20069
+ `${nameFields.join(", ")} cannot be set. A preview container's application name is generated from the worker name, preview slug, and Durable Object class name, so that separate previews of the same Worker do not collide. Remove it and identify the container with "class_name".`
20070
+ );
20071
+ return false;
20072
+ }
20073
+ const seenClasses = /* @__PURE__ */ new Set();
20074
+ const duplicateClasses = /* @__PURE__ */ new Set();
20075
+ for (const entry of value) {
20076
+ if (!entry || typeof entry !== "object") {
20077
+ continue;
20078
+ }
20079
+ if (typeof entry.class_name === "string") {
20080
+ if (seenClasses.has(entry.class_name)) {
20081
+ duplicateClasses.add(entry.class_name);
20082
+ }
20083
+ seenClasses.add(entry.class_name);
20084
+ }
20085
+ }
20086
+ if (duplicateClasses.size > 0) {
20087
+ const classList = [...duplicateClasses].map((className) => `"${className}"`).join(", ");
20088
+ diagnostics.errors.push(
20089
+ `"${field}" declares more than one container for the Durable Object class ${classList}; each Durable Object class may appear at most once.`
20090
+ );
20091
+ return false;
20092
+ }
20093
+ }
20094
+ return innerValidator(diagnostics, field, value, config2);
20095
+ };
20096
+ }
20097
+ __name(validatePreviewsContainers, "validatePreviewsContainers");
20098
+ function validateContainerApp(envName, topLevelName, configPath, options = {}) {
20099
+ const { generateDefaultName = true } = options;
20057
20100
  return (diagnostics, field, value, config2) => {
20058
20101
  if (!value) {
20059
20102
  return true;
@@ -20079,7 +20122,7 @@ function validateContainerApp(envName, topLevelName, configPath) {
20079
20122
  containerAppOptional.name,
20080
20123
  "string"
20081
20124
  );
20082
- if (!containerAppOptional.name) {
20125
+ if (generateDefaultName && !containerAppOptional.name) {
20083
20126
  if (containerAppOptional.class_name === void 0) {
20084
20127
  diagnostics.errors.push(
20085
20128
  `"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".`
@@ -21488,6 +21531,108 @@ var validateConsumer = /* @__PURE__ */ __name((diagnostics, field, value, _confi
21488
21531
  }
21489
21532
  return isValid;
21490
21533
  }, "validateConsumer");
21534
+ function validateConnectHandlers(envName) {
21535
+ return (diagnostics, field, value, config2) => {
21536
+ if (value === void 0) {
21537
+ return true;
21538
+ }
21539
+ const fieldPath = config2 === void 0 ? `${field}` : `env.${envName}.${field}`;
21540
+ if (!Array.isArray(value)) {
21541
+ diagnostics.errors.push(
21542
+ `The field "${fieldPath}" should be an array but got ${JSON.stringify(
21543
+ value
21544
+ )}.`
21545
+ );
21546
+ return false;
21547
+ }
21548
+ let isValid = true;
21549
+ for (let i = 0; i < value.length; i++) {
21550
+ if (!validateConnectHandler(
21551
+ diagnostics,
21552
+ `${fieldPath}[${i}]`,
21553
+ value[i],
21554
+ config2
21555
+ )) {
21556
+ isValid = false;
21557
+ }
21558
+ }
21559
+ const firstIndexByKey = /* @__PURE__ */ new Map();
21560
+ for (let i = 0; i < value.length; i++) {
21561
+ const handler = value[i];
21562
+ if (typeof handler !== "object" || handler === null || typeof handler.port !== "number" || typeof handler.protocol !== "string") {
21563
+ continue;
21564
+ }
21565
+ const { protocol, port } = handler;
21566
+ const key = `${protocol}:${port}`;
21567
+ const firstIndex = firstIndexByKey.get(key);
21568
+ if (firstIndex !== void 0) {
21569
+ diagnostics.errors.push(
21570
+ `"${fieldPath}[${i}]" has the same "protocol" (${protocol}) and "port" (${port}) as "${fieldPath}[${firstIndex}]". Each entry in "connect" must use a unique protocol/port combination.`
21571
+ );
21572
+ isValid = false;
21573
+ } else {
21574
+ firstIndexByKey.set(key, i);
21575
+ }
21576
+ }
21577
+ return isValid;
21578
+ };
21579
+ }
21580
+ __name(validateConnectHandlers, "validateConnectHandlers");
21581
+ var validateConnectHandler = /* @__PURE__ */ __name((diagnostics, field, value) => {
21582
+ if (typeof value !== "object" || value === null) {
21583
+ diagnostics.errors.push(
21584
+ `"${field}" should be an object, but got ${JSON.stringify(value)}`
21585
+ );
21586
+ return false;
21587
+ }
21588
+ let isValid = true;
21589
+ if (!validateAdditionalProperties(diagnostics, field, Object.keys(value), [
21590
+ "protocol",
21591
+ "port",
21592
+ "address"
21593
+ ])) {
21594
+ isValid = false;
21595
+ }
21596
+ if ("protocol" in value && value.protocol !== "tcp") {
21597
+ diagnostics.errors.push(
21598
+ `"${field}" should have a "protocol" field of "tcp" but got ${JSON.stringify(
21599
+ value.protocol
21600
+ )}.`
21601
+ );
21602
+ isValid = false;
21603
+ } else if (!("protocol" in value)) {
21604
+ diagnostics.errors.push(
21605
+ `"${field}" should have a "protocol" field of "tcp" but got ${JSON.stringify(
21606
+ value
21607
+ )}.`
21608
+ );
21609
+ isValid = false;
21610
+ }
21611
+ if (!isRequiredProperty(value, "port", "number")) {
21612
+ diagnostics.errors.push(
21613
+ `"${field}" should have a number "port" field but got ${JSON.stringify(
21614
+ value
21615
+ )}.`
21616
+ );
21617
+ isValid = false;
21618
+ } else if (!Number.isInteger(value.port) || value.port < 1 || value.port > 65535) {
21619
+ diagnostics.errors.push(
21620
+ `"${field}" should have an integer "port" field between 1 and 65535 but got ${JSON.stringify(
21621
+ value
21622
+ )}.`
21623
+ );
21624
+ isValid = false;
21625
+ }
21626
+ if (!isOptionalProperty(value, "address", "string")) {
21627
+ diagnostics.errors.push(
21628
+ `"${field}" should, optionally, have a string "address" field but got ${JSON.stringify(
21629
+ value
21630
+ )}.`
21631
+ );
21632
+ isValid = false;
21633
+ }
21634
+ return isValid;
21635
+ }, "validateConnectHandler");
21491
21636
  var validateCompatibilityDate = /* @__PURE__ */ __name((diagnostics, field, value) => {
21492
21637
  if (value === void 0) {
21493
21638
  return true;
@@ -21796,7 +21941,7 @@ function normalizeAndValidateLimits(diagnostics, topLevelEnv, rawEnv) {
21796
21941
  );
21797
21942
  }
21798
21943
  __name(normalizeAndValidateLimits, "normalizeAndValidateLimits");
21799
- var validatePreviewsConfig = /* @__PURE__ */ __name((envName) => (diagnostics, field, value) => {
21944
+ var validatePreviewsConfig = /* @__PURE__ */ __name((envName, configPath) => (diagnostics, field, value) => {
21800
21945
  if (value === void 0) {
21801
21946
  return true;
21802
21947
  }
@@ -21843,6 +21988,7 @@ var validatePreviewsConfig = /* @__PURE__ */ __name((envName) => (diagnostics, f
21843
21988
  "ratelimits",
21844
21989
  "vpc_services",
21845
21990
  "version_metadata",
21991
+ "containers",
21846
21992
  "logpush",
21847
21993
  "observability",
21848
21994
  "limits",
@@ -22052,6 +22198,14 @@ var validatePreviewsConfig = /* @__PURE__ */ __name((envName) => (diagnostics, f
22052
22198
  void 0
22053
22199
  ) && isValid;
22054
22200
  }
22201
+ if (previews.containers !== void 0) {
22202
+ isValid = validatePreviewsContainers(envName, configPath)(
22203
+ diagnostics,
22204
+ `${field}.containers`,
22205
+ previews.containers,
22206
+ void 0
22207
+ ) && isValid;
22208
+ }
22055
22209
  isValid = isBoolean(diagnostics, `${field}.logpush`, previews.logpush, void 0) && isValid;
22056
22210
  isValid = validateObservability(
22057
22211
  diagnostics,
@@ -22632,7 +22786,7 @@ var validateCache = /* @__PURE__ */ __name((diagnostics, field, value) => {
22632
22786
  ]) && isValid;
22633
22787
  return isValid;
22634
22788
  }, "validateCache");
22635
- function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects, migrations, exports, configPath) {
22789
+ function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects, migrations, exports$1, configPath) {
22636
22790
  if (!Array.isArray(durableObjects.bindings) || durableObjects.bindings.length === 0) {
22637
22791
  return;
22638
22792
  }
@@ -22640,7 +22794,7 @@ function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects,
22640
22794
  (binding) => !binding.script_name
22641
22795
  );
22642
22796
  const exportsCovers = /* @__PURE__ */ __name((className) => {
22643
- const entry = exports?.[className];
22797
+ const entry = exports$1?.[className];
22644
22798
  if (entry === void 0 || entry.type !== "durable-object") {
22645
22799
  return false;
22646
22800
  }
@@ -22676,15 +22830,15 @@ function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects,
22676
22830
  \`\`\``);
22677
22831
  }
22678
22832
  __name(warnIfDurableObjectsHaveNoLifecycleConfig, "warnIfDurableObjectsHaveNoLifecycleConfig");
22679
- function errorIfMigrationsAndExportsBothSet(diagnostics, migrations, exports) {
22680
- if (migrations.length > 0 && exports !== void 0 && Object.values(exports).some((entry) => entry.type === "durable-object")) {
22833
+ function errorIfMigrationsAndExportsBothSet(diagnostics, migrations, exports$1) {
22834
+ if (migrations.length > 0 && exports$1 !== void 0 && Object.values(exports$1).some((entry) => entry.type === "durable-object")) {
22681
22835
  diagnostics.errors.push(
22682
22836
  `\`migrations\` and \`exports\` are mutually exclusive. Choose one or the other to declare your Durable Object lifecycle, but not both.`
22683
22837
  );
22684
22838
  }
22685
22839
  }
22686
22840
  __name(errorIfMigrationsAndExportsBothSet, "errorIfMigrationsAndExportsBothSet");
22687
- function validateContainerExportLinks(diagnostics, containers, exports, containersDeclaredElsewhere) {
22841
+ function validateContainerExportLinks(diagnostics, containers, exports$1, containersDeclaredElsewhere) {
22688
22842
  if (containers !== void 0 && !Array.isArray(containers)) {
22689
22843
  return;
22690
22844
  }
@@ -22726,7 +22880,7 @@ function validateContainerExportLinks(diagnostics, containers, exports, containe
22726
22880
  `More than one container is attached to the Durable Object "${className}". A Durable Object can only have one container attached to it.`
22727
22881
  );
22728
22882
  }
22729
- const durableObjectExports = getDurableObjectExports(exports);
22883
+ const durableObjectExports = getDurableObjectExports(exports$1);
22730
22884
  const liveExportClassNames = /* @__PURE__ */ new Set();
22731
22885
  const classNamesByContainerName = /* @__PURE__ */ new Map();
22732
22886
  for (const [className, entry] of Object.entries(durableObjectExports)) {
@@ -22755,7 +22909,7 @@ function validateContainerExportLinks(diagnostics, containers, exports, containe
22755
22909
  );
22756
22910
  }
22757
22911
  }
22758
- const containerNameToClassName = getContainerNameToClassNameMap(exports);
22912
+ const containerNameToClassName = getContainerNameToClassNameMap(exports$1);
22759
22913
  const usesDurableObjectExports = Object.keys(durableObjectExports).length > 0;
22760
22914
  for (const container of containers ?? []) {
22761
22915
  if (typeof container.name !== "string") {
@@ -22897,7 +23051,7 @@ var BINDING_LOCAL_SUPPORT = {
22897
23051
  kv_namespace: "local-and-remote",
22898
23052
  r2_bucket: "local-and-remote",
22899
23053
  d1: "local-and-remote",
22900
- workflow: "local-and-remote",
23054
+ workflow: "local-only",
22901
23055
  browser: "local-and-remote",
22902
23056
  images: "local-and-remote",
22903
23057
  stream: "local-and-remote",
@@ -23076,6 +23230,18 @@ function getPackagePath(packageName, projectPath) {
23076
23230
  );
23077
23231
  } catch {
23078
23232
  }
23233
+ try {
23234
+ const candidate = path2__default.join(
23235
+ projectPath,
23236
+ "node_modules",
23237
+ packageName,
23238
+ "package.json"
23239
+ );
23240
+ if (statSync(candidate).isFile()) {
23241
+ return path2__default.dirname(candidate);
23242
+ }
23243
+ } catch {
23244
+ }
23079
23245
  return void 0;
23080
23246
  }
23081
23247
  __name(getPackagePath, "getPackagePath");
@@ -24288,7 +24454,7 @@ function terminateCloudflared(cloudflared) {
24288
24454
  }
24289
24455
  __name(terminateCloudflared, "terminateCloudflared");
24290
24456
  function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
24291
- return new Promise((resolve2, reject) => {
24457
+ return new Promise((resolve3, reject) => {
24292
24458
  let resolved = false;
24293
24459
  let stderrOutput = "";
24294
24460
  const logger = options?.logger;
@@ -24316,7 +24482,7 @@ function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
24316
24482
  if (match && !resolved) {
24317
24483
  resolved = true;
24318
24484
  clearTimeout(timeoutId);
24319
- resolve2({ mode: "quick", publicUrl: new URL(match[0]) });
24485
+ resolve3({ mode: "quick", publicUrl: new URL(match[0]) });
24320
24486
  }
24321
24487
  });
24322
24488
  }
@@ -24837,6 +25003,41 @@ ${url2}`
24837
25003
  logger.debug(err instanceof Error ? err.stack ?? String(err) : String(err));
24838
25004
  }
24839
25005
  __name(handleBrowserOpenError, "handleBrowserOpenError");
25006
+ function writeOutput(entry) {
25007
+ if (outputFilePath === void 0) {
25008
+ outputFilePath = getOutputFilePath();
25009
+ }
25010
+ if (outputFilePath !== null) {
25011
+ mkdirSync(dirname(outputFilePath), { recursive: true });
25012
+ const entryJSON = JSON.stringify({
25013
+ ...entry,
25014
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
25015
+ });
25016
+ appendFileSync(outputFilePath, entryJSON + "\n");
25017
+ }
25018
+ }
25019
+ __name(writeOutput, "writeOutput");
25020
+ function clearOutputFilePath() {
25021
+ outputFilePath = void 0;
25022
+ }
25023
+ __name(clearOutputFilePath, "clearOutputFilePath");
25024
+ var outputFilePath = void 0;
25025
+ function getOutputFilePath() {
25026
+ const outputFilePathFromEnv = getOutputFilePathFromEnv();
25027
+ if (outputFilePathFromEnv) {
25028
+ return outputFilePathFromEnv;
25029
+ }
25030
+ const outputFileDirectoryFromEnv = getOutputFileDirectoryFromEnv();
25031
+ if (outputFileDirectoryFromEnv) {
25032
+ const date5 = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-").replace(".", "_").replace("T", "_").replace("Z", "");
25033
+ return resolve(
25034
+ outputFileDirectoryFromEnv,
25035
+ `wrangler-output-${date5}-${randomBytes(3).toString("hex")}.json`
25036
+ );
25037
+ }
25038
+ return null;
25039
+ }
25040
+ __name(getOutputFilePath, "getOutputFilePath");
24840
25041
  var MAX_ATTEMPTS = 3;
24841
25042
  var MAX_RETRY_AFTER_MS = 6e4;
24842
25043
  async function retryOnAPIFailure(action, logger, backoff = 0, attempts = MAX_ATTEMPTS, abortSignal) {
@@ -25324,4 +25525,4 @@ safe-buffer/index.js:
25324
25525
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
25325
25526
  */
25326
25527
 
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 };
25528
+ 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, clearOutputFilePath, 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, writeOutput };