@cloudflare/deploy-helpers 0.11.1 → 0.12.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,17 +1,17 @@
1
1
  import { fetchResult, fetchPagedListResult, logger, confirm, fetchListResult, prompt, select } from './chunk-Z4LB73IF.mjs';
2
2
  export { initDeployHelpersContext } from './chunk-Z4LB73IF.mjs';
3
- import { createWorkerUploadForm, moduleTypeMimeType } from './chunk-3G6JZQDH.mjs';
4
- export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-3G6JZQDH.mjs';
3
+ import { createWorkerUploadForm, moduleTypeMimeType } from './chunk-QBZBEHZB.mjs';
4
+ export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-QBZBEHZB.mjs';
5
5
  import { __commonJS, __name, __require, __toESM, __export } from './chunk-Q72B4Q5Z.mjs';
6
- import assert5 from 'node:assert';
6
+ import assert6 from 'node:assert';
7
7
  import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
8
8
  import * as path from 'node:path';
9
9
  import path__default, { resolve, isAbsolute, sep, extname } from 'node:path';
10
10
  import url2, { URLSearchParams as URLSearchParams$1 } from 'node:url';
11
11
  import * as cli from '@cloudflare/cli-shared-helpers';
12
12
  import { updateStatus, cancel } from '@cloudflare/cli-shared-helpers';
13
- import { SchedulingPolicy, ApplicationsService, listDurableObjects, resolveImageName, buildAndMaybePush, ContainerImagePreparationsService, ContainerImagePreparationStatus, createDurableObjectNamespaceResolver, initContainersSharedContext, pushBuiltContainerImage, deployContainers, verifyDockerInstalled } from '@cloudflare/containers-shared';
14
- import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, getDurableObjectContainerApps, CONTAINER_IMAGES_BINDING, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, printBindings, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
13
+ import { SchedulingPolicy, ApplicationsService, ApiError, listDurableObjects, resolveImageName, pushImageIfChanged, ContainerImagePreparationsService, ContainerImagePreparationStatus, createDurableObjectNamespaceResolver, initContainersSharedContext, pushBuiltContainerImage, deployContainers, verifyDockerInstalled } from '@cloudflare/containers-shared';
14
+ import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, CONTAINER_IMAGES_BINDING, getResolvedDurableObjectContainerApps, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, printBindings, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, getDurableObjectContainerApps, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
15
15
  import { Response, FormData } from 'undici';
16
16
  import chalk6 from 'chalk';
17
17
  import PQueue from 'p-queue';
@@ -257,17 +257,17 @@ var require_ignore = __commonJS({
257
257
  var throwError = /* @__PURE__ */ __name((message, Ctor) => {
258
258
  throw new Ctor(message);
259
259
  }, "throwError");
260
- var checkPath = /* @__PURE__ */ __name((path10, originalPath, doThrow) => {
261
- if (!isString(path10)) {
260
+ var checkPath = /* @__PURE__ */ __name((path9, originalPath, doThrow) => {
261
+ if (!isString(path9)) {
262
262
  return doThrow(
263
263
  `path must be a string, but got \`${originalPath}\``,
264
264
  TypeError
265
265
  );
266
266
  }
267
- if (!path10) {
267
+ if (!path9) {
268
268
  return doThrow(`path must not be empty`, TypeError);
269
269
  }
270
- if (checkPath.isNotRelative(path10)) {
270
+ if (checkPath.isNotRelative(path9)) {
271
271
  const r = "`path.relative()`d";
272
272
  return doThrow(
273
273
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -276,7 +276,7 @@ var require_ignore = __commonJS({
276
276
  }
277
277
  return true;
278
278
  }, "checkPath");
279
- var isNotRelative = /* @__PURE__ */ __name((path10) => REGEX_TEST_INVALID_PATH.test(path10), "isNotRelative");
279
+ var isNotRelative = /* @__PURE__ */ __name((path9) => REGEX_TEST_INVALID_PATH.test(path9), "isNotRelative");
280
280
  checkPath.isNotRelative = isNotRelative;
281
281
  checkPath.convert = (p) => p;
282
282
  var Ignore = class {
@@ -338,7 +338,7 @@ var require_ignore = __commonJS({
338
338
  // setting `checkUnignored` to `false` could reduce additional
339
339
  // path matching.
340
340
  // @returns {TestResult} true if a file is ignored
341
- _testOne(path10, checkUnignored) {
341
+ _testOne(path9, checkUnignored) {
342
342
  let ignored = false;
343
343
  let unignored = false;
344
344
  this._rules.forEach((rule) => {
@@ -346,7 +346,7 @@ var require_ignore = __commonJS({
346
346
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
347
347
  return;
348
348
  }
349
- const matched = rule.regex.test(path10);
349
+ const matched = rule.regex.test(path9);
350
350
  if (matched) {
351
351
  ignored = !negative;
352
352
  unignored = negative;
@@ -359,24 +359,24 @@ var require_ignore = __commonJS({
359
359
  }
360
360
  // @returns {TestResult}
361
361
  _test(originalPath, cache, checkUnignored, slices) {
362
- const path10 = originalPath && checkPath.convert(originalPath);
362
+ const path9 = originalPath && checkPath.convert(originalPath);
363
363
  checkPath(
364
- path10,
364
+ path9,
365
365
  originalPath,
366
366
  this._allowRelativePaths ? RETURN_FALSE : throwError
367
367
  );
368
- return this._t(path10, cache, checkUnignored, slices);
368
+ return this._t(path9, cache, checkUnignored, slices);
369
369
  }
370
- _t(path10, cache, checkUnignored, slices) {
371
- if (path10 in cache) {
372
- return cache[path10];
370
+ _t(path9, cache, checkUnignored, slices) {
371
+ if (path9 in cache) {
372
+ return cache[path9];
373
373
  }
374
374
  if (!slices) {
375
- slices = path10.split(SLASH);
375
+ slices = path9.split(SLASH);
376
376
  }
377
377
  slices.pop();
378
378
  if (!slices.length) {
379
- return cache[path10] = this._testOne(path10, checkUnignored);
379
+ return cache[path9] = this._testOne(path9, checkUnignored);
380
380
  }
381
381
  const parent = this._t(
382
382
  slices.join(SLASH) + SLASH,
@@ -384,24 +384,24 @@ var require_ignore = __commonJS({
384
384
  checkUnignored,
385
385
  slices
386
386
  );
387
- return cache[path10] = parent.ignored ? parent : this._testOne(path10, checkUnignored);
387
+ return cache[path9] = parent.ignored ? parent : this._testOne(path9, checkUnignored);
388
388
  }
389
- ignores(path10) {
390
- return this._test(path10, this._ignoreCache, false).ignored;
389
+ ignores(path9) {
390
+ return this._test(path9, this._ignoreCache, false).ignored;
391
391
  }
392
392
  createFilter() {
393
- return (path10) => !this.ignores(path10);
393
+ return (path9) => !this.ignores(path9);
394
394
  }
395
395
  filter(paths) {
396
396
  return makeArray(paths).filter(this.createFilter());
397
397
  }
398
398
  // @returns {TestResult}
399
- test(path10) {
400
- return this._test(path10, this._testCache, true);
399
+ test(path9) {
400
+ return this._test(path9, this._testCache, true);
401
401
  }
402
402
  };
403
403
  var factory = /* @__PURE__ */ __name((options) => new Ignore(options), "factory");
404
- var isPathValid = /* @__PURE__ */ __name((path10) => checkPath(path10 && checkPath.convert(path10), path10, RETURN_FALSE), "isPathValid");
404
+ var isPathValid = /* @__PURE__ */ __name((path9) => checkPath(path9 && checkPath.convert(path9), path9, RETURN_FALSE), "isPathValid");
405
405
  factory.isPathValid = isPathValid;
406
406
  factory.default = factory;
407
407
  module.exports = factory;
@@ -412,7 +412,7 @@ var require_ignore = __commonJS({
412
412
  const makePosix = /* @__PURE__ */ __name((str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"), "makePosix");
413
413
  checkPath.convert = makePosix;
414
414
  const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
415
- checkPath.isNotRelative = (path10) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path10) || isNotRelative(path10);
415
+ checkPath.isNotRelative = (path9) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path9) || isNotRelative(path9);
416
416
  }
417
417
  }
418
418
  });
@@ -704,10 +704,10 @@ var require_heap2 = __commonJS({
704
704
  var require_difflib = __commonJS({
705
705
  "../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/lib/difflib.js"(exports$1) {
706
706
  (function() {
707
- var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has, assert12, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, indexOf = [].indexOf;
707
+ var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has, assert13, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, indexOf = [].indexOf;
708
708
  ({ floor, max, min } = Math);
709
709
  Heap = require_heap2();
710
- assert12 = __require("assert");
710
+ assert13 = __require("assert");
711
711
  _calculateRatio = /* @__PURE__ */ __name(function(matches, length) {
712
712
  if (length) {
713
713
  return 2 * matches / length;
@@ -1278,7 +1278,7 @@ var require_difflib = __commonJS({
1278
1278
  }
1279
1279
  _plainReplace(a, alo, ahi, b, blo, bhi) {
1280
1280
  var first, g, l, len, len1, line, lines, m, ref, second;
1281
- assert12(alo < ahi && blo < bhi);
1281
+ assert13(alo < ahi && blo < bhi);
1282
1282
  if (bhi - blo < ahi - alo) {
1283
1283
  first = this._dump("+", b, blo, bhi);
1284
1284
  second = this._dump("-", a, alo, ahi);
@@ -2998,8 +2998,8 @@ async function fetchEmailRoutingPlan(config2, accountId, request) {
2998
2998
  }
2999
2999
  }
3000
3000
  __name(fetchEmailRoutingPlan, "fetchEmailRoutingPlan");
3001
- function putJson(config2, path10, body) {
3002
- return fetchResult(config2, path10, {
3001
+ function putJson(config2, path9, body) {
3002
+ return fetchResult(config2, path9, {
3003
3003
  method: "PUT",
3004
3004
  headers: { "Content-Type": "application/json" },
3005
3005
  body: JSON.stringify(body)
@@ -3967,7 +3967,7 @@ async function triggersDeploy(props) {
3967
3967
  return;
3968
3968
  }
3969
3969
  const { accountId } = props;
3970
- assert5(accountId);
3970
+ assert6(accountId);
3971
3971
  if (props.validated !== true) {
3972
3972
  await ensureQueuesExistByConfig(config2, accountId, true, scriptName);
3973
3973
  }
@@ -4557,6 +4557,7 @@ var MAX_ROUTES_RULES = 100;
4557
4557
  var MAX_ROUTES_RULE_LENGTH = 100;
4558
4558
 
4559
4559
  // ../workers-shared/utils/configuration/parseStaticRouting.ts
4560
+ var MAX_REPORTED_DUPLICATED_RULES = 5;
4560
4561
  function parseStaticRouting(input) {
4561
4562
  if (input.length === 0) {
4562
4563
  throw new Error(
@@ -4564,6 +4565,27 @@ function parseStaticRouting(input) {
4564
4565
  );
4565
4566
  }
4566
4567
  if (input.length > MAX_ROUTES_RULES) {
4568
+ const seenRules = /* @__PURE__ */ new Set();
4569
+ const duplicatedRules = /* @__PURE__ */ new Set();
4570
+ for (const rule of input) {
4571
+ if (seenRules.has(rule)) {
4572
+ duplicatedRules.add(rule);
4573
+ }
4574
+ seenRules.add(rule);
4575
+ }
4576
+ if (duplicatedRules.size > 0) {
4577
+ const duplicateEntryCount = input.length - seenRules.size;
4578
+ const reportedDuplicatedRules = [...seenRules].filter((rule) => duplicatedRules.has(rule)).slice(0, MAX_REPORTED_DUPLICATED_RULES);
4579
+ const unreportedDuplicatedRuleCount = duplicatedRules.size - reportedDuplicatedRules.length;
4580
+ const unreportedDuplicatedRulesMessage = unreportedDuplicatedRuleCount > 0 ? `
4581
+ ...and ${unreportedDuplicatedRuleCount} more duplicated ${unreportedDuplicatedRuleCount === 1 ? "rule" : "rules"}.` : "";
4582
+ throw new Error(
4583
+ `Too many \`run_worker_first\` rules were provided; ${input.length} rules provided (${seenRules.size} distinct, ${duplicateEntryCount} duplicate ${duplicateEntryCount === 1 ? "entry" : "entries"}) exceeds max of ${MAX_ROUTES_RULES}. Note: duplicate entries count towards the route limit. Ensure that no duplicate rules are present in your \`run_worker_first\` configuration.
4584
+
4585
+ The duplicated rules found are:
4586
+ ${reportedDuplicatedRules.map((rule) => `- ${JSON.stringify(rule)}`).join("\n")}${unreportedDuplicatedRulesMessage}`
4587
+ );
4588
+ }
4567
4589
  throw new Error(
4568
4590
  `Too many \`run_worker_first\` rules were provided; ${input.length} rules provided exceeds max of ${MAX_ROUTES_RULES}.`
4569
4591
  );
@@ -5777,12 +5799,12 @@ var Mime = class {
5777
5799
  }
5778
5800
  return this;
5779
5801
  }
5780
- getType(path10) {
5781
- if (typeof path10 !== "string")
5802
+ getType(path9) {
5803
+ if (typeof path9 !== "string")
5782
5804
  return null;
5783
- const last = path10.replace(/^.*[/\\]/s, "").toLowerCase();
5805
+ const last = path9.replace(/^.*[/\\]/s, "").toLowerCase();
5784
5806
  const ext = last.replace(/^.*\./s, "").toLowerCase();
5785
- const hasPath = last.length < path10.length;
5807
+ const hasPath = last.length < path9.length;
5786
5808
  const hasDot = ext.length < last.length - 1;
5787
5809
  if (!hasDot && hasPath)
5788
5810
  return null;
@@ -5913,7 +5935,7 @@ var MAX_UPLOAD_ATTEMPTS = 5;
5913
5935
  var MAX_UPLOAD_GATEWAY_ERRORS = 5;
5914
5936
  var MAX_DIFF_LINES = 100;
5915
5937
  var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, assetDirectory, scriptName, dispatchNamespace) => {
5916
- assert5(accountId, "Missing accountId");
5938
+ assert6(accountId, "Missing accountId");
5917
5939
  logger.info("\u{1F300} Building list of assets...");
5918
5940
  const manifest = await buildAssetManifest(assetDirectory);
5919
5941
  const url3 = dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/assets-upload-session` : `/accounts/${accountId}/workers/scripts/${scriptName}/assets-upload-session`;
@@ -5988,10 +6010,12 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
5988
6010
  let completionJwt = "";
5989
6011
  let uploadedAssetsCount = 0;
5990
6012
  let uploadedBytes = 0;
6013
+ let concurrencyThrottleGeneration = 0;
5991
6014
  for (const [bucketIndex, bucket] of uploadBuckets.entries()) {
5992
6015
  let attempts = 0;
5993
6016
  let gatewayErrors = 0;
5994
6017
  const doUpload = /* @__PURE__ */ __name(async () => {
6018
+ const uploadGeneration = concurrencyThrottleGeneration;
5995
6019
  const uploadedFiles = [];
5996
6020
  for (const manifestEntry of bucket) {
5997
6021
  uploadedFiles.push(manifestEntry[0]);
@@ -6047,6 +6071,12 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6047
6071
  }
6048
6072
  );
6049
6073
  }
6074
+ if (queue.concurrency < concurrency && uploadGeneration === concurrencyThrottleGeneration) {
6075
+ queue.concurrency++;
6076
+ logger.debug(
6077
+ `Asset upload concurrency recovered to ${queue.concurrency}.`
6078
+ );
6079
+ }
6050
6080
  uploadedAssetsCount += bucket.length;
6051
6081
  uploadedBytes += bucket.reduce(
6052
6082
  (total, manifestEntry) => total + manifestEntry[1].size,
@@ -6071,7 +6101,11 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6071
6101
  (resolvePromise) => setTimeout(resolvePromise, Math.pow(2, attempts) * 1e3)
6072
6102
  );
6073
6103
  if (e instanceof APIError && e.isGatewayError()) {
6104
+ concurrencyThrottleGeneration++;
6074
6105
  queue.concurrency = 1;
6106
+ logger.debug(
6107
+ "Asset upload concurrency throttled to 1 after a gateway error."
6108
+ );
6075
6109
  await new Promise(
6076
6110
  (resolvePromise) => setTimeout(resolvePromise, Math.pow(2, gatewayErrors) * 5e3)
6077
6111
  );
@@ -6490,8 +6524,8 @@ function formatVersions(versions, traffic) {
6490
6524
  }).join("\n\n");
6491
6525
  }
6492
6526
  __name(formatVersions, "formatVersions");
6493
- async function clearRemovedContainerImagesBindings(config2, bindings, workerUrl) {
6494
- if (getDurableObjectContainerApps(config2.containers).length > 0) {
6527
+ async function clearRemovedContainerImagesBindings(config2, durableObjectContainerConfig, bindings, workerUrl) {
6528
+ if (durableObjectContainerConfig.length > 0) {
6495
6529
  return;
6496
6530
  }
6497
6531
  const settings = await fetchResult(
@@ -6503,13 +6537,12 @@ async function clearRemovedContainerImagesBindings(config2, bindings, workerUrl)
6503
6537
  }
6504
6538
  }
6505
6539
  __name(clearRemovedContainerImagesBindings, "clearRemovedContainerImagesBindings");
6506
- function addContainerImagesBinding(config2, bindings, preparedContainerImages, options = {}) {
6507
- const containers = getDurableObjectContainerApps(config2.containers);
6540
+ function addContainerImagesBinding(durableObjectContainerConfig, bindings, preparedContainerImages, options = {}) {
6508
6541
  const shouldInheritExisting = options.preserveExisting && options.workerExists && options.hasExistingBinding;
6509
6542
  if (options.preserveExisting && !shouldInheritExisting) {
6510
6543
  return;
6511
6544
  }
6512
- if (containers.length === 0 && !shouldInheritExisting) {
6545
+ if (durableObjectContainerConfig.length === 0 && !shouldInheritExisting) {
6513
6546
  return;
6514
6547
  }
6515
6548
  if (bindings[CONTAINER_IMAGES_BINDING] !== void 0) {
@@ -6527,7 +6560,10 @@ function addContainerImagesBinding(config2, bindings, preparedContainerImages, o
6527
6560
  bindings[CONTAINER_IMAGES_BINDING] = {
6528
6561
  type: "json",
6529
6562
  value: Object.fromEntries(
6530
- containers.map((container) => {
6563
+ getResolvedDurableObjectContainerApps(
6564
+ durableObjectContainerConfig,
6565
+ options.exports
6566
+ ).map((container) => {
6531
6567
  const configuredImages = Object.keys(container.images ?? {});
6532
6568
  const preparedImages = preparedContainerImages[container.class_name];
6533
6569
  if (configuredImages.length > 0 && preparedImages === void 0) {
@@ -6541,19 +6577,26 @@ function addContainerImagesBinding(config2, bindings, preparedContainerImages, o
6541
6577
  };
6542
6578
  }
6543
6579
  __name(addContainerImagesBinding, "addContainerImagesBinding");
6544
- function getContainerMetadata(config2, preparedContainerImages = {}, options = {}) {
6545
- const metadata = config2.containers?.map((container) => {
6580
+ function getContainerMetadata(containers, preparedContainerImages = {}, options = {}) {
6581
+ const managedClasses = new Map(
6582
+ getResolvedDurableObjectContainerApps(containers, options.exports).map(
6583
+ ({ name, class_name }) => [name, class_name]
6584
+ )
6585
+ );
6586
+ return containers?.map((container) => {
6546
6587
  if (isDurableObjectContainerApp(container)) {
6588
+ const className = managedClasses.get(container.name);
6589
+ assert6(className, "managed container class should have been resolved");
6547
6590
  const configuredImages = Object.keys(container.images ?? {});
6548
- const images = preparedContainerImages[container.class_name];
6591
+ const images = preparedContainerImages[className];
6549
6592
  if (configuredImages.length > 0 && images === void 0 && !options.allowUnprepared) {
6550
6593
  throw new Error(
6551
- `Container images for Durable Object class "${container.class_name}" were not prepared before upload.`
6594
+ `Container images for Durable Object class "${className}" were not prepared before upload.`
6552
6595
  );
6553
6596
  }
6554
6597
  return {
6555
6598
  name: container.name,
6556
- class_name: container.class_name,
6599
+ class_name: className,
6557
6600
  ...images !== void 0 && { images }
6558
6601
  };
6559
6602
  }
@@ -6563,11 +6606,10 @@ function getContainerMetadata(config2, preparedContainerImages = {}, options = {
6563
6606
  class_name: container.class_name
6564
6607
  }
6565
6608
  };
6566
- }) ?? [];
6567
- return config2.containers === void 0 ? void 0 : metadata;
6609
+ });
6568
6610
  }
6569
6611
  __name(getContainerMetadata, "getContainerMetadata");
6570
- async function getContainerMetadataForRolloutSkip(config2, {
6612
+ async function getContainerMetadataForRolloutSkip(config2, containers, {
6571
6613
  accountId,
6572
6614
  scriptName,
6573
6615
  dispatchNamespace,
@@ -6575,16 +6617,16 @@ async function getContainerMetadataForRolloutSkip(config2, {
6575
6617
  latestDeployment,
6576
6618
  dryRun = false
6577
6619
  }) {
6578
- const configuredMetadata = getContainerMetadata(
6579
- config2,
6580
- {},
6581
- {
6582
- allowUnprepared: true
6583
- }
6584
- );
6585
6620
  if (dryRun || !workerExists) {
6586
6621
  return {
6587
- containers: configuredMetadata,
6622
+ containers: getContainerMetadata(
6623
+ containers,
6624
+ {},
6625
+ {
6626
+ allowUnprepared: true,
6627
+ exports: config2.exports
6628
+ }
6629
+ ),
6588
6630
  hasExistingContainerImagesBinding: false
6589
6631
  };
6590
6632
  }
@@ -6665,15 +6707,36 @@ function deployWfpUserWorker(dispatchNamespace, versionId) {
6665
6707
  __name(deployWfpUserWorker, "deployWfpUserWorker");
6666
6708
  var IMAGE_PREPARATION_POLL_INTERVAL_MS = 2e3;
6667
6709
  var IMAGE_PREPARATION_TIMEOUT_MS = 15 * 6e4;
6710
+ function getApplicationSettings(container) {
6711
+ const flags = container.unsafe?.configuration?.experimental_flags;
6712
+ return {
6713
+ ...flags !== void 0 && {
6714
+ configuration: { experimental_flags: flags }
6715
+ },
6716
+ ...container.observability !== void 0 && {
6717
+ observability: {
6718
+ logs: {
6719
+ enabled: container.observability.enabled === true || container.observability.logs?.enabled === true
6720
+ }
6721
+ }
6722
+ }
6723
+ };
6724
+ }
6725
+ __name(getApplicationSettings, "getApplicationSettings");
6726
+ function normalizeFlags(flags = []) {
6727
+ return [...new Set(flags)].sort();
6728
+ }
6729
+ __name(normalizeFlags, "normalizeFlags");
6668
6730
  function isRegistryImage(image) {
6669
6731
  return typeof image.image === "string";
6670
6732
  }
6671
6733
  __name(isRegistryImage, "isRegistryImage");
6672
- function toCreateApplicationRequest({ name }, namespaceId) {
6734
+ function toCreateApplicationRequest({ name }, namespaceId, settings = {}) {
6673
6735
  return {
6674
6736
  name,
6675
6737
  scheduling_policy: SchedulingPolicy.DURABLE_OBJECT,
6676
- durable_objects: { namespace_id: namespaceId }
6738
+ durable_objects: { namespace_id: namespaceId },
6739
+ ...settings
6677
6740
  };
6678
6741
  }
6679
6742
  __name(toCreateApplicationRequest, "toCreateApplicationRequest");
@@ -6776,6 +6839,45 @@ function getVersionedDurableObjectContainerApplications(versions, scriptName) {
6776
6839
  });
6777
6840
  }
6778
6841
  __name(getVersionedDurableObjectContainerApplications, "getVersionedDurableObjectContainerApplications");
6842
+ async function applyApplication(application, namespaceId, settings = {}, updateExisting = false) {
6843
+ let existing;
6844
+ try {
6845
+ existing = await ApplicationsService.getApplication(namespaceId);
6846
+ } catch (error51) {
6847
+ if (!(error51 instanceof ApiError) || error51.status !== 404) {
6848
+ throw error51;
6849
+ }
6850
+ await ApplicationsService.createApplication(
6851
+ toCreateApplicationRequest(application, namespaceId, settings)
6852
+ );
6853
+ return;
6854
+ }
6855
+ if (existing.id !== namespaceId || existing.durable_objects?.namespace_id !== namespaceId || existing.scheduling_policy !== SchedulingPolicy.DURABLE_OBJECT || existing.name !== application.name) {
6856
+ throw new UserError(
6857
+ `The application for Durable Object namespace "${namespaceId}" does not match Container "${application.name}". The existing name, namespace, and scheduling policy must match before its settings can be applied.`,
6858
+ {
6859
+ telemetryMessage: "durable object container application identity mismatch"
6860
+ }
6861
+ );
6862
+ }
6863
+ if (!updateExisting) {
6864
+ return;
6865
+ }
6866
+ const patch = {};
6867
+ if (settings.configuration !== void 0 && !isDeepStrictEqual(
6868
+ normalizeFlags(settings.configuration.experimental_flags),
6869
+ normalizeFlags(existing.configuration?.experimental_flags)
6870
+ )) {
6871
+ patch.configuration = settings.configuration;
6872
+ }
6873
+ if (settings.observability !== void 0 && !isDeepStrictEqual(settings.observability, existing.observability)) {
6874
+ patch.observability = settings.observability;
6875
+ }
6876
+ if (Object.keys(patch).length > 0) {
6877
+ await ApplicationsService.modifyApplication(namespaceId, patch);
6878
+ }
6879
+ }
6880
+ __name(applyApplication, "applyApplication");
6779
6881
  async function resolveVersionedDurableObjectContainerApplications(config2, {
6780
6882
  applications,
6781
6883
  accountId,
@@ -6817,47 +6919,63 @@ async function deployVersionedDurableObjectContainerApplications(config2, args)
6817
6919
  );
6818
6920
  for (const application of applications) {
6819
6921
  if (application.namespaceId !== void 0) {
6820
- await createDurableObjectContainerApplication(
6821
- application,
6822
- application.namespaceId
6823
- );
6922
+ await applyApplication(application, application.namespaceId);
6824
6923
  }
6825
6924
  }
6826
6925
  }
6827
6926
  __name(deployVersionedDurableObjectContainerApplications, "deployVersionedDurableObjectContainerApplications");
6828
- function buildTag(scriptName, className, imageName) {
6829
- const repository = `${scriptName}-${className}-${imageName}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
6830
- return `${repository}:wrangler-${Date.now().toString(36)}`;
6927
+ function getBuiltImage(container, imageName, builtImages) {
6928
+ const builtImage = builtImages.find(
6929
+ (candidate) => candidate.className === container.class_name && candidate.imageName === imageName
6930
+ );
6931
+ if (builtImage === void 0) {
6932
+ throw new Error(
6933
+ `Container image "${imageName}" for Durable Object class "${container.class_name}" was not built before upload.`
6934
+ );
6935
+ }
6936
+ return builtImage;
6831
6937
  }
6832
- __name(buildTag, "buildTag");
6833
- async function buildOrResolveImage(config2, container, imageName, imageConfig, scriptName, dryRun, accountId) {
6938
+ __name(getBuiltImage, "getBuiltImage");
6939
+ async function pushOrResolveImage(config2, container, imageName, imageConfig, builtImages, dryRun, accountId) {
6834
6940
  if (isRegistryImage(imageConfig)) {
6835
6941
  if (dryRun) {
6836
6942
  return imageConfig.image;
6837
6943
  }
6838
- assert5(accountId, "Expected accountId to resolve container image name");
6944
+ assert6(accountId, "Expected accountId to resolve container image name");
6839
6945
  return resolveImageName(accountId, imageConfig.image, config2);
6840
6946
  }
6841
- const baseDir = config2.configPath ? path__default.dirname(config2.configPath) : process.cwd();
6842
- const dockerfile = path__default.resolve(baseDir, imageConfig.dockerfile);
6843
- const tag = buildTag(scriptName, container.class_name, imageName);
6844
- logger.log("Building image", tag);
6845
- const imageRef = await buildAndMaybePush(
6846
- {
6847
- tag,
6848
- pathToDockerfile: dockerfile,
6849
- buildContext: path__default.dirname(dockerfile),
6850
- platform: "linux/amd64"
6851
- },
6852
- getDockerPath(),
6853
- !dryRun,
6854
- void 0,
6855
- true,
6856
- config2
6857
- );
6858
- return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
6947
+ const builtImage = getBuiltImage(container, imageName, builtImages);
6948
+ if (dryRun) {
6949
+ return builtImage.localTag;
6950
+ }
6951
+ try {
6952
+ const imageRef = await pushImageIfChanged({
6953
+ pathToDocker: getDockerPath(),
6954
+ sourceTag: builtImage.localTag,
6955
+ targetTag: builtImage.localTag,
6956
+ accountId,
6957
+ complianceConfig: config2,
6958
+ cleanupSourceTag: true
6959
+ });
6960
+ for (const image of builtImages) {
6961
+ if (image.localTag === builtImage.localTag) {
6962
+ image.localTagCleaned = true;
6963
+ }
6964
+ }
6965
+ return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
6966
+ } catch (error51) {
6967
+ if (error51 instanceof Error) {
6968
+ throw new UserError(error51.message, {
6969
+ cause: error51,
6970
+ telemetryMessage: "durable object container image push failed"
6971
+ });
6972
+ }
6973
+ throw new UserError("An unknown error occurred", {
6974
+ telemetryMessage: "durable object container image push failed"
6975
+ });
6976
+ }
6859
6977
  }
6860
- __name(buildOrResolveImage, "buildOrResolveImage");
6978
+ __name(pushOrResolveImage, "pushOrResolveImage");
6861
6979
  async function waitForImagePreparation(image) {
6862
6980
  const deadline = Date.now() + IMAGE_PREPARATION_TIMEOUT_MS;
6863
6981
  while (Date.now() < deadline) {
@@ -6892,22 +7010,27 @@ async function waitForImagePreparation(image) {
6892
7010
  );
6893
7011
  }
6894
7012
  __name(waitForImagePreparation, "waitForImagePreparation");
6895
- async function prepareDurableObjectContainerApplications(config2, {
7013
+ async function prepareDurableObjectContainerApplications(config2, durableObjectContainerConfig, builtImages, {
6896
7014
  accountId,
6897
7015
  dryRun,
6898
7016
  scriptName,
6899
7017
  dispatchNamespace
6900
7018
  }) {
6901
- validateDurableObjectContainerApplications(config2);
7019
+ validateDurableObjectContainerApplications(
7020
+ config2,
7021
+ durableObjectContainerConfig
7022
+ );
7023
+ const managedContainers = getResolvedDurableObjectContainerApps(
7024
+ durableObjectContainerConfig,
7025
+ config2.exports
7026
+ );
6902
7027
  if (!dryRun) {
6903
- assert5(accountId, "Expected accountId to prepare container applications");
7028
+ assert6(accountId, "Expected accountId to prepare container applications");
6904
7029
  const storageByClass = getDurableObjectClassNameToUseSQLiteMap(
6905
7030
  config2.migrations,
6906
7031
  config2.exports
6907
7032
  );
6908
- const unknownStorage = getDurableObjectContainerApps(
6909
- config2.containers
6910
- ).filter(
7033
+ const unknownStorage = managedContainers.filter(
6911
7034
  (container) => storageByClass.get(container.class_name) === void 0
6912
7035
  );
6913
7036
  if (unknownStorage.length > 0) {
@@ -6926,7 +7049,7 @@ async function prepareDurableObjectContainerApplications(config2, {
6926
7049
  }
6927
7050
  }
6928
7051
  }
6929
- const containers = getDurableObjectContainerApps(config2.containers).filter(
7052
+ const containers = managedContainers.filter(
6930
7053
  (container) => Object.keys(container.images ?? {}).length > 0
6931
7054
  );
6932
7055
  if (containers.length === 0) {
@@ -6939,18 +7062,15 @@ async function prepareDurableObjectContainerApplications(config2, {
6939
7062
  for (const [imageName, imageConfig] of Object.entries(
6940
7063
  container.images ?? {}
6941
7064
  )) {
6942
- const source = isRegistryImage(imageConfig) ? `image:${imageConfig.image}` : `dockerfile:${path__default.resolve(
6943
- config2.configPath ? path__default.dirname(config2.configPath) : process.cwd(),
6944
- imageConfig.dockerfile
6945
- )}`;
7065
+ const source = isRegistryImage(imageConfig) ? `image:${imageConfig.image}` : `built:${getBuiltImage(container, imageName, builtImages).localTag}`;
6946
7066
  let image = preparedImages.get(source);
6947
7067
  if (image === void 0) {
6948
- image = await buildOrResolveImage(
7068
+ image = await pushOrResolveImage(
6949
7069
  config2,
6950
7070
  container,
6951
7071
  imageName,
6952
7072
  imageConfig,
6953
- scriptName,
7073
+ builtImages,
6954
7074
  dryRun,
6955
7075
  accountId
6956
7076
  );
@@ -6973,13 +7093,17 @@ ${imageLine}`);
6973
7093
  return Object.fromEntries(imagesByClass);
6974
7094
  }
6975
7095
  __name(prepareDurableObjectContainerApplications, "prepareDurableObjectContainerApplications");
6976
- async function deployDurableObjectContainerApplications(config2, {
7096
+ async function deployDurableObjectContainerApplications(config2, durableObjectContainerConfig, {
6977
7097
  versionId,
6978
7098
  accountId,
6979
7099
  scriptName,
6980
- dispatchNamespace
7100
+ dispatchNamespace,
7101
+ updateExisting = true
6981
7102
  }) {
6982
- const containers = getDurableObjectContainerApps(config2.containers);
7103
+ const containers = getResolvedDurableObjectContainerApps(
7104
+ durableObjectContainerConfig,
7105
+ config2.exports
7106
+ );
6983
7107
  if (containers.length === 0) {
6984
7108
  return;
6985
7109
  }
@@ -6997,7 +7121,12 @@ async function deployDurableObjectContainerApplications(config2, {
6997
7121
  });
6998
7122
  }
6999
7123
  for (const { container, namespaceId } of applications) {
7000
- await createDurableObjectContainerApplication(container, namespaceId);
7124
+ await applyApplication(
7125
+ container,
7126
+ namespaceId,
7127
+ getApplicationSettings(container),
7128
+ updateExisting
7129
+ );
7001
7130
  }
7002
7131
  }
7003
7132
  __name(deployDurableObjectContainerApplications, "deployDurableObjectContainerApplications");
@@ -7040,7 +7169,7 @@ function tagsAreEqual(a, b) {
7040
7169
  __name(tagsAreEqual, "tagsAreEqual");
7041
7170
  async function getMigrationsToUpload(scriptName, props) {
7042
7171
  const { config: config2, accountId } = props;
7043
- assert5(accountId, "Missing accountId");
7172
+ assert6(accountId, "Missing accountId");
7044
7173
  let migrations;
7045
7174
  if (config2.migrations.length > 0) {
7046
7175
  let script;
@@ -7296,7 +7425,7 @@ function diagnoseScriptSizeError(err, dependencies) {
7296
7425
  return message;
7297
7426
  }
7298
7427
  __name(diagnoseScriptSizeError, "diagnoseScriptSizeError");
7299
- async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundle) {
7428
+ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundle = analyseBundleLazily) {
7300
7429
  let errorMessage = esm_default`
7301
7430
  Your Worker failed validation because it exceeded startup limits.
7302
7431
 
@@ -7307,23 +7436,21 @@ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundl
7307
7436
 
7308
7437
  Refer to https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time for more details`;
7309
7438
  try {
7310
- if (!analyseBundle) {
7311
- return errorMessage;
7312
- }
7313
7439
  const cpuProfile = await analyseBundle(workerBundle);
7314
7440
  const tmpDir = await getWranglerTmpDir(
7315
7441
  projectRoot,
7316
7442
  "startup-profile",
7317
7443
  false
7318
7444
  );
7319
- const profile = path__default.relative(
7445
+ const profilePath = path__default.join(tmpDir.path, "worker.cpuprofile");
7446
+ const displayProfilePath = path__default.relative(
7320
7447
  projectRoot ?? process.cwd(),
7321
- path__default.join(tmpDir.path, `worker.cpuprofile`)
7448
+ profilePath
7322
7449
  );
7323
- await writeFile(profile, JSON.stringify(cpuProfile));
7450
+ await writeFile(profilePath, JSON.stringify(cpuProfile));
7324
7451
  errorMessage += esm_default`
7325
7452
 
7326
- A CPU Profile of your Worker's startup phase has been written to ${profile} - load it into the Chrome DevTools profiler (or directly in VSCode) to view a flamegraph.`;
7453
+ A CPU Profile of your Worker's startup phase has been written to ${displayProfilePath} - load it into the Chrome DevTools profiler (or directly in VSCode) to view a flamegraph.`;
7327
7454
  } catch (profilingError) {
7328
7455
  logger.debug(
7329
7456
  `An error occurred while trying to locally profile the Worker: ${profilingError}`
@@ -7332,6 +7459,11 @@ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundl
7332
7459
  return errorMessage;
7333
7460
  }
7334
7461
  __name(diagnoseStartupError, "diagnoseStartupError");
7462
+ async function analyseBundleLazily(workerBundle) {
7463
+ const { analyseBundle } = await import('./startup-profile.mjs');
7464
+ return analyseBundle(workerBundle);
7465
+ }
7466
+ __name(analyseBundleLazily, "analyseBundleLazily");
7335
7467
  function getOffendingDependenciesMessage(dependencies) {
7336
7468
  const dependenciesSorted = Object.entries(dependencies);
7337
7469
  if (dependenciesSorted.length === 0) {
@@ -7647,7 +7779,7 @@ var R2Handler = class extends ProvisionResourceHandler {
7647
7779
  );
7648
7780
  }
7649
7781
  async isConnectedToExistingResource() {
7650
- assert5(typeof this.binding.bucket_name !== "symbol");
7782
+ assert6(typeof this.binding.bucket_name !== "symbol");
7651
7783
  if (!this.binding.bucket_name) {
7652
7784
  return false;
7653
7785
  }
@@ -7694,7 +7826,7 @@ var AISearchNamespaceHandler = class extends ProvisionResourceHandler {
7694
7826
  );
7695
7827
  }
7696
7828
  async isConnectedToExistingResource() {
7697
- assert5(typeof this.binding.namespace !== "symbol");
7829
+ assert6(typeof this.binding.namespace !== "symbol");
7698
7830
  if (!this.binding.namespace) {
7699
7831
  return false;
7700
7832
  }
@@ -7737,7 +7869,7 @@ var AgentMemoryNamespaceHandler = class extends ProvisionResourceHandler {
7737
7869
  );
7738
7870
  }
7739
7871
  async isConnectedToExistingResource() {
7740
- assert5(typeof this.binding.namespace !== "symbol");
7872
+ assert6(typeof this.binding.namespace !== "symbol");
7741
7873
  if (!this.binding.namespace) {
7742
7874
  return false;
7743
7875
  }
@@ -7792,7 +7924,7 @@ var QueueHandler = class extends ProvisionResourceHandler {
7792
7924
  return true;
7793
7925
  }
7794
7926
  async isConnectedToExistingResource() {
7795
- assert5(typeof this.binding.queue_name !== "symbol");
7927
+ assert6(typeof this.binding.queue_name !== "symbol");
7796
7928
  if (!this.binding.queue_name) {
7797
7929
  return false;
7798
7930
  }
@@ -7848,7 +7980,7 @@ var DispatchNamespaceHandler = class extends ProvisionResourceHandler {
7848
7980
  return true;
7849
7981
  }
7850
7982
  async isConnectedToExistingResource() {
7851
- assert5(typeof this.binding.namespace !== "symbol");
7983
+ assert6(typeof this.binding.namespace !== "symbol");
7852
7984
  if (!this.binding.namespace) {
7853
7985
  return false;
7854
7986
  }
@@ -7973,7 +8105,7 @@ var D1Handler = class extends ProvisionResourceHandler {
7973
8105
  return false;
7974
8106
  }
7975
8107
  async isConnectedToExistingResource() {
7976
- assert5(typeof this.binding.database_name !== "symbol");
8108
+ assert6(typeof this.binding.database_name !== "symbol");
7977
8109
  if (!this.binding.database_name) {
7978
8110
  return false;
7979
8111
  }
@@ -8358,7 +8490,7 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
8358
8490
  const configPath = config2.userConfigPath ?? config2.configPath;
8359
8491
  const { pendingResources, skippedProvisioning } = await collectPendingResources(config2, accountId, scriptName, bindings);
8360
8492
  if (pendingResources.length > 0) {
8361
- assert5(
8493
+ assert6(
8362
8494
  configPath,
8363
8495
  "Provisioning resources is not possible without a config file"
8364
8496
  );
@@ -8374,7 +8506,6 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
8374
8506
  log: logger.log,
8375
8507
  tailConsumers: config2.tail_consumers,
8376
8508
  streamingTailConsumers: config2.streaming_tail_consumers,
8377
- containers: config2.containers,
8378
8509
  provisioning: true
8379
8510
  }
8380
8511
  );
@@ -9455,7 +9586,7 @@ __export(util_exports, {
9455
9586
  NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
9456
9587
  aborted: () => aborted,
9457
9588
  allowsEval: () => allowsEval,
9458
- assert: () => assert6,
9589
+ assert: () => assert7,
9459
9590
  assertEqual: () => assertEqual,
9460
9591
  assertIs: () => assertIs,
9461
9592
  assertNever: () => assertNever,
@@ -9529,9 +9660,9 @@ function assertNever(_x) {
9529
9660
  throw new Error("Unexpected value in exhaustive check");
9530
9661
  }
9531
9662
  __name(assertNever, "assertNever");
9532
- function assert6(_) {
9663
+ function assert7(_) {
9533
9664
  }
9534
- __name(assert6, "assert");
9665
+ __name(assert7, "assert");
9535
9666
  function getEnumValues(entries) {
9536
9667
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
9537
9668
  const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -9629,10 +9760,10 @@ function cloneDef(schema) {
9629
9760
  return mergeDefs(schema._zod.def);
9630
9761
  }
9631
9762
  __name(cloneDef, "cloneDef");
9632
- function getElementAtPath(obj, path10) {
9633
- if (!path10)
9763
+ function getElementAtPath(obj, path9) {
9764
+ if (!path9)
9634
9765
  return obj;
9635
- return path10.reduce((acc, key) => acc?.[key], obj);
9766
+ return path9.reduce((acc, key) => acc?.[key], obj);
9636
9767
  }
9637
9768
  __name(getElementAtPath, "getElementAtPath");
9638
9769
  function promiseAllObject(promisesObj) {
@@ -10065,11 +10196,11 @@ function explicitlyAborted(x, startIndex = 0) {
10065
10196
  return false;
10066
10197
  }
10067
10198
  __name(explicitlyAborted, "explicitlyAborted");
10068
- function prefixIssues(path10, issues) {
10199
+ function prefixIssues(path9, issues) {
10069
10200
  return issues.map((iss) => {
10070
10201
  var _a3;
10071
10202
  (_a3 = iss).path ?? (_a3.path = []);
10072
- iss.path.unshift(path10);
10203
+ iss.path.unshift(path9);
10073
10204
  return iss;
10074
10205
  });
10075
10206
  }
@@ -10234,16 +10365,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
10234
10365
  __name(flattenError, "flattenError");
10235
10366
  function formatError(error51, mapper = (issue2) => issue2.message) {
10236
10367
  const fieldErrors = { _errors: [] };
10237
- const processError = /* @__PURE__ */ __name((error52, path10 = []) => {
10368
+ const processError = /* @__PURE__ */ __name((error52, path9 = []) => {
10238
10369
  for (const issue2 of error52.issues) {
10239
10370
  if (issue2.code === "invalid_union" && issue2.errors.length) {
10240
- issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
10371
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
10241
10372
  } else if (issue2.code === "invalid_key") {
10242
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
10373
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
10243
10374
  } else if (issue2.code === "invalid_element") {
10244
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
10375
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
10245
10376
  } else {
10246
- const fullpath = [...path10, ...issue2.path];
10377
+ const fullpath = [...path9, ...issue2.path];
10247
10378
  if (fullpath.length === 0) {
10248
10379
  fieldErrors._errors.push(mapper(issue2));
10249
10380
  } else {
@@ -10271,17 +10402,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
10271
10402
  __name(formatError, "formatError");
10272
10403
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
10273
10404
  const result = { errors: [] };
10274
- const processError = /* @__PURE__ */ __name((error52, path10 = []) => {
10405
+ const processError = /* @__PURE__ */ __name((error52, path9 = []) => {
10275
10406
  var _a3, _b;
10276
10407
  for (const issue2 of error52.issues) {
10277
10408
  if (issue2.code === "invalid_union" && issue2.errors.length) {
10278
- issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
10409
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
10279
10410
  } else if (issue2.code === "invalid_key") {
10280
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
10411
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
10281
10412
  } else if (issue2.code === "invalid_element") {
10282
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
10413
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
10283
10414
  } else {
10284
- const fullpath = [...path10, ...issue2.path];
10415
+ const fullpath = [...path9, ...issue2.path];
10285
10416
  if (fullpath.length === 0) {
10286
10417
  result.errors.push(mapper(issue2));
10287
10418
  continue;
@@ -10314,8 +10445,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
10314
10445
  __name(treeifyError, "treeifyError");
10315
10446
  function toDotPath(_path) {
10316
10447
  const segs = [];
10317
- const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
10318
- for (const seg of path10) {
10448
+ const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
10449
+ for (const seg of path9) {
10319
10450
  if (typeof seg === "number")
10320
10451
  segs.push(`[${seg}]`);
10321
10452
  else if (typeof seg === "symbol")
@@ -23371,13 +23502,13 @@ function resolveRef(ref, ctx) {
23371
23502
  if (!ref.startsWith("#")) {
23372
23503
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
23373
23504
  }
23374
- const path10 = ref.slice(1).split("/").filter(Boolean);
23375
- if (path10.length === 0) {
23505
+ const path9 = ref.slice(1).split("/").filter(Boolean);
23506
+ if (path9.length === 0) {
23376
23507
  return ctx.rootSchema;
23377
23508
  }
23378
23509
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
23379
- if (path10[0] === defsKey) {
23380
- const key = path10[1];
23510
+ if (path9[0] === defsKey) {
23511
+ const key = path9[1];
23381
23512
  if (!key || !ctx.defs[key]) {
23382
23513
  throw new Error(`Reference not found: ${ref}`);
23383
23514
  }
@@ -23907,12 +24038,12 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
23907
24038
  // Make sure we're using fresh copies of files each time we source map
23908
24039
  emptyCacheBetweenOperations: true,
23909
24040
  // Allow retriever to be overridden at prepare stack trace time
23910
- retrieveSourceMap(path10) {
23911
- return retrieveSourceMapOverride?.(path10) ?? null;
24041
+ retrieveSourceMap(path9) {
24042
+ return retrieveSourceMapOverride?.(path9) ?? null;
23912
24043
  }
23913
24044
  });
23914
24045
  sourceMappingPrepareStackTrace = Error.prepareStackTrace;
23915
- assert5(sourceMappingPrepareStackTrace !== void 0);
24046
+ assert6(sourceMappingPrepareStackTrace !== void 0);
23916
24047
  Error.prepareStackTrace = originalPrepareStackTrace;
23917
24048
  return sourceMappingPrepareStackTrace;
23918
24049
  }
@@ -23974,7 +24105,7 @@ function getSourceMappedString(value, retrieveSourceMap) {
23974
24105
  }
23975
24106
  const callSiteLine = callSiteLines[i][0];
23976
24107
  const callSiteAtIndex = callSiteLine.indexOf("at");
23977
- assert5(callSiteAtIndex !== -1);
24108
+ assert6(callSiteAtIndex !== -1);
23978
24109
  const callSiteLineLeftPad = callSiteLine.substring(0, callSiteAtIndex);
23979
24110
  value = value.replace(
23980
24111
  callSiteLine,
@@ -24195,8 +24326,7 @@ function extractBindingNames(config2) {
24195
24326
  return (value ?? []).map((workflowBinding) => workflowBinding.binding);
24196
24327
  }
24197
24328
  case "browser":
24198
- case "ai":
24199
- case "websearch": {
24329
+ case "ai": {
24200
24330
  const value = untypedValue;
24201
24331
  return value ? [value.binding] : [];
24202
24332
  }
@@ -24370,7 +24500,6 @@ var reorderableBindings = {
24370
24500
  images: false,
24371
24501
  stream: false,
24372
24502
  media: false,
24373
- websearch: false,
24374
24503
  version_metadata: false,
24375
24504
  unsafe: false,
24376
24505
  assets: false
@@ -24499,8 +24628,7 @@ function removeRemoteConfigFieldFromBindings(normalizedConfig) {
24499
24628
  "ai",
24500
24629
  "images",
24501
24630
  "stream",
24502
- "media",
24503
- "websearch"
24631
+ "media"
24504
24632
  ];
24505
24633
  for (const singleBindingField of singleBindingFields) {
24506
24634
  if (normalizedConfig[singleBindingField] && "remote" in normalizedConfig[singleBindingField]) {
@@ -24694,10 +24822,10 @@ function populateConfigPatch(diff, patchObj, targetEnvironment) {
24694
24822
  return;
24695
24823
  }
24696
24824
  if (Array.isArray(diff)) {
24697
- assert5(Array.isArray(patchObj));
24825
+ assert6(Array.isArray(patchObj));
24698
24826
  return populateConfigPatchArray(diff, patchObj);
24699
24827
  }
24700
- assert5(!Array.isArray(patchObj));
24828
+ assert6(!Array.isArray(patchObj));
24701
24829
  return populateConfigPatchObject(diff, patchObj, targetEnvironment);
24702
24830
  }
24703
24831
  __name(populateConfigPatch, "populateConfigPatch");
@@ -25031,7 +25159,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
25031
25159
  if (props.command === "deploy") {
25032
25160
  validateEventTriggerTargets(config2, name);
25033
25161
  validateRoutes(props.routes, props.assetsOptions);
25034
- assert5(
25162
+ assert6(
25035
25163
  !config2.site || config2.site.bucket,
25036
25164
  "A [site] definition requires a `bucket` field with a path to the site's assets directory."
25037
25165
  );
@@ -25042,7 +25170,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
25042
25170
  );
25043
25171
  }
25044
25172
  } else {
25045
- if (config2.containers?.some(
25173
+ if (props.containers.source?.some(
25046
25174
  (container) => !isDurableObjectContainerApp(container)
25047
25175
  )) {
25048
25176
  logger.warn(
@@ -25272,8 +25400,11 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25272
25400
  }
25273
25401
  }
25274
25402
  const isDryRun = props.dryRun;
25275
- const normalisedContainerConfig = props.normalisedContainerConfig;
25276
- const builtContainerDeployments = props.builtContainerDeployments;
25403
+ const normalisedContainerConfig = props.containers.standard.normalized;
25404
+ const builtContainerImages = props.containers.standard.builtImages;
25405
+ const durableObjectContainerConfig = getDurableObjectContainerApps(
25406
+ props.containers.source
25407
+ );
25277
25408
  const shouldDeployContainers = normalisedContainerConfig.length > 0 && props.containersRollout !== "none";
25278
25409
  const {
25279
25410
  modules,
@@ -25284,21 +25415,32 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25284
25415
  sourceMaps
25285
25416
  } = buildResult;
25286
25417
  const skipContainerChanges = props.containersRollout === "none";
25287
- const preparedContainerImages = skipContainerChanges ? void 0 : await prepareDurableObjectContainerApplications(config2, {
25288
- accountId,
25289
- dryRun: Boolean(isDryRun),
25290
- scriptName,
25291
- dispatchNamespace: props.dispatchNamespace
25418
+ const preparedContainerImages = skipContainerChanges ? void 0 : await prepareDurableObjectContainerApplications(
25419
+ config2,
25420
+ durableObjectContainerConfig,
25421
+ props.containers.durableObjects.builtImages,
25422
+ {
25423
+ accountId,
25424
+ dryRun: Boolean(isDryRun),
25425
+ scriptName,
25426
+ dispatchNamespace: props.dispatchNamespace
25427
+ }
25428
+ );
25429
+ const rolloutSkipContainerState = skipContainerChanges ? await getContainerMetadataForRolloutSkip(
25430
+ config2,
25431
+ props.containers.source,
25432
+ {
25433
+ accountId,
25434
+ scriptName,
25435
+ dispatchNamespace: props.dispatchNamespace,
25436
+ workerExists,
25437
+ latestDeployment,
25438
+ dryRun: isDryRun
25439
+ }
25440
+ ) : void 0;
25441
+ const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(props.containers.source, preparedContainerImages, {
25442
+ exports: config2.exports
25292
25443
  });
25293
- const rolloutSkipContainerState = skipContainerChanges ? await getContainerMetadataForRolloutSkip(config2, {
25294
- accountId,
25295
- scriptName,
25296
- dispatchNamespace: props.dispatchNamespace,
25297
- workerExists,
25298
- latestDeployment,
25299
- dryRun: isDryRun
25300
- }) : void 0;
25301
- const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(config2, preparedContainerImages);
25302
25444
  const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
25303
25445
  scriptName,
25304
25446
  isDryRun,
@@ -25353,13 +25495,24 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25353
25495
  workerExists
25354
25496
  });
25355
25497
  if (!skipContainerChanges && keepVars && !isDryRun && workerExists) {
25356
- await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
25498
+ await clearRemovedContainerImagesBindings(
25499
+ config2,
25500
+ durableObjectContainerConfig,
25501
+ bindings,
25502
+ workerUrl
25503
+ );
25357
25504
  }
25358
- addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {}, {
25359
- preserveExisting: skipContainerChanges,
25360
- workerExists,
25361
- hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
25362
- });
25505
+ addContainerImagesBinding(
25506
+ durableObjectContainerConfig,
25507
+ bindings,
25508
+ preparedContainerImages ?? {},
25509
+ {
25510
+ preserveExisting: skipContainerChanges,
25511
+ exports: config2.exports,
25512
+ workerExists,
25513
+ hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
25514
+ }
25515
+ );
25363
25516
  if (workersSitesAssets.manifest) {
25364
25517
  modules.push({
25365
25518
  name: "__STATIC_CONTENT_MANIFEST",
@@ -25418,7 +25571,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25418
25571
  );
25419
25572
  const bundleSize = await getSize([...modules, { content }]);
25420
25573
  printBundleSize(bundleSize);
25421
- const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && config2.containers === void 0 && // Rollout skip can recover Container metadata absent from local config.
25574
+ const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && props.containers.source === void 0 && // Rollout skip can recover Container metadata absent from local config.
25422
25575
  containerMetadata === void 0;
25423
25576
  let workerBundle;
25424
25577
  const dockerPath = getDockerPath();
@@ -25440,12 +25593,12 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25440
25593
  log: logger.log,
25441
25594
  tailConsumers: config2.tail_consumers,
25442
25595
  streamingTailConsumers: config2.streaming_tail_consumers,
25443
- containers: config2.containers,
25596
+ containers: props.containers.source,
25444
25597
  warnIfNoBindings: true,
25445
25598
  unsafeMetadata: config2.unsafe?.metadata
25446
25599
  });
25447
25600
  } else {
25448
- assert5(accountId, "Missing accountId");
25601
+ assert6(accountId, "Missing accountId");
25449
25602
  let provisionBindingsResult;
25450
25603
  if (assetsOptions?.routerConfig.has_user_worker === false) {
25451
25604
  logger.debug("skipping provisioning on assets-only project");
@@ -25575,7 +25728,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25575
25728
  log: logger.log,
25576
25729
  tailConsumers: config2.tail_consumers,
25577
25730
  streamingTailConsumers: config2.streaming_tail_consumers,
25578
- containers: config2.containers,
25731
+ containers: props.containers.source,
25579
25732
  unsafeMetadata: config2.unsafe?.metadata
25580
25733
  });
25581
25734
  provisionBindingsResult?.warnOnSkippedProvisioning();
@@ -25603,7 +25756,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25603
25756
  log: logger.log,
25604
25757
  tailConsumers: config2.tail_consumers,
25605
25758
  streamingTailConsumers: config2.streaming_tail_consumers,
25606
- containers: config2.containers,
25759
+ containers: props.containers.source,
25607
25760
  unsafeMetadata: config2.unsafe?.metadata
25608
25761
  });
25609
25762
  }
@@ -25619,6 +25772,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25619
25772
  dependencies,
25620
25773
  workerBundle,
25621
25774
  projectRoot,
25775
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- compatibility callback for existing deploy-helpers consumers
25622
25776
  callbacks.analyseBundle
25623
25777
  );
25624
25778
  if (message !== null) {
@@ -25668,22 +25822,22 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25668
25822
  const uploadMs = Date.now() - start;
25669
25823
  logger.log("Uploaded", workerName, formatTime(uploadMs));
25670
25824
  if (shouldDeployContainers) {
25671
- assert5(versionId && accountId);
25825
+ assert6(versionId && accountId);
25672
25826
  initContainersSharedContext({ logger, fetchPagedListResult, fetchResult });
25673
25827
  const containerDeployments = [];
25674
25828
  for (const container of normalisedContainerConfig) {
25675
25829
  if ("dockerfile" in container) {
25676
- const builtContainerDeployment = builtContainerDeployments.find(
25677
- (deployment) => deployment.container === container
25830
+ const builtImage = builtContainerImages.find(
25831
+ (image) => image.container === container
25678
25832
  );
25679
- assert5(
25680
- builtContainerDeployment,
25833
+ assert6(
25834
+ builtImage,
25681
25835
  "Expected container image to be built before upload"
25682
25836
  );
25683
25837
  containerDeployments.push({
25684
25838
  container,
25685
25839
  imageRef: await pushBuiltContainerImage(
25686
- builtContainerDeployment.builtImage,
25840
+ builtImage,
25687
25841
  versionId,
25688
25842
  dockerPath,
25689
25843
  accountId,
@@ -25704,18 +25858,22 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25704
25858
  dispatchNamespace: props.dispatchNamespace
25705
25859
  });
25706
25860
  }
25707
- if (!skipContainerChanges && getDurableObjectContainerApps(config2.containers).length > 0) {
25708
- assert5(versionId && accountId);
25861
+ if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
25862
+ assert6(versionId && accountId);
25709
25863
  try {
25710
- await deployDurableObjectContainerApplications(config2, {
25711
- versionId,
25712
- accountId,
25713
- scriptName,
25714
- dispatchNamespace: props.dispatchNamespace
25715
- });
25864
+ await deployDurableObjectContainerApplications(
25865
+ config2,
25866
+ durableObjectContainerConfig,
25867
+ {
25868
+ versionId,
25869
+ accountId,
25870
+ scriptName,
25871
+ dispatchNamespace: props.dispatchNamespace
25872
+ }
25873
+ );
25716
25874
  } catch (error51) {
25717
25875
  throw new UserError(
25718
- "The Worker version was deployed, but Wrangler could not finish creating its Durable Object-managed Container applications. Re-run the same `wrangler deploy` command to retry the idempotent application creation and finish deployment.",
25876
+ "The Worker version was deployed, but Wrangler could not finish applying its Durable Object-managed Container application settings. Re-run the same `wrangler deploy` command to retry and finish deployment.",
25719
25877
  {
25720
25878
  telemetryMessage: "deploy durable object container application creation failed after deployment",
25721
25879
  cause: error51
@@ -25727,7 +25885,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
25727
25885
  deployWfpUserWorker(props.dispatchNamespace, versionId);
25728
25886
  return { versionId, workerTag, assetUploadStats, bundleSize };
25729
25887
  }
25730
- assert5(accountId);
25888
+ assert6(accountId);
25731
25889
  const targets = await triggersDeploy({
25732
25890
  config: config2,
25733
25891
  accountId,
@@ -25762,7 +25920,7 @@ function renderBindingDependsOnExportError(serverMessage) {
25762
25920
  __name(renderBindingDependsOnExportError, "renderBindingDependsOnExportError");
25763
25921
 
25764
25922
  // src/deploy/versions-upload.ts
25765
- async function versionsUpload(props, config2, buildResult, callbacks) {
25923
+ async function versionsUpload(props, config2, buildResult, callbacks = {}) {
25766
25924
  const result = await uploadWorkerVersion(
25767
25925
  props,
25768
25926
  config2,
@@ -25834,11 +25992,19 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25834
25992
  { telemetryMessage: "versions upload pending durable object migration" }
25835
25993
  );
25836
25994
  }
25837
- const preparedContainerImages = await prepareDurableObjectContainerApplications(config2, {
25838
- accountId,
25839
- dryRun: Boolean(props.dryRun),
25840
- scriptName
25841
- });
25995
+ const durableObjectContainerConfig = getDurableObjectContainerApps(
25996
+ props.containers.source
25997
+ );
25998
+ const preparedContainerImages = await prepareDurableObjectContainerApplications(
25999
+ config2,
26000
+ durableObjectContainerConfig,
26001
+ props.containers.durableObjects.builtImages,
26002
+ {
26003
+ accountId,
26004
+ dryRun: Boolean(props.dryRun),
26005
+ scriptName
26006
+ }
26007
+ );
25842
26008
  const assetsUploadResult = assetsOptions && !props.dryRun ? await syncAssets(config2, accountId, assetsOptions.directory, scriptName) : void 0;
25843
26009
  const assetsJwt = assetsUploadResult?.jwt;
25844
26010
  if (props.secretsFile) {
@@ -25856,9 +26022,19 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25856
26022
  }
25857
26023
  addRequiredSecretsInheritBindings(config2, bindings, { type: "upload" });
25858
26024
  if (keepVars && !props.dryRun && workerExists) {
25859
- await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
26025
+ await clearRemovedContainerImagesBindings(
26026
+ config2,
26027
+ durableObjectContainerConfig,
26028
+ bindings,
26029
+ workerUrl
26030
+ );
25860
26031
  }
25861
- addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {});
26032
+ addContainerImagesBinding(
26033
+ durableObjectContainerConfig,
26034
+ bindings,
26035
+ preparedContainerImages ?? {},
26036
+ { exports: config2.exports }
26037
+ );
25862
26038
  const placement = parseConfigPlacement(config2);
25863
26039
  const entryPointName = path__default.basename(resolvedEntryPointPath);
25864
26040
  const main = {
@@ -25873,7 +26049,11 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25873
26049
  migrations,
25874
26050
  exports: exports$1,
25875
26051
  modules,
25876
- containers: getContainerMetadata(config2, preparedContainerImages),
26052
+ containers: getContainerMetadata(
26053
+ props.containers.source,
26054
+ preparedContainerImages,
26055
+ { exports: config2.exports }
26056
+ ),
25877
26057
  sourceMaps,
25878
26058
  compatibility_date: compatibilityDate,
25879
26059
  compatibility_flags: compatibilityFlags,
@@ -25922,7 +26102,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25922
26102
  unsafeMetadata: config2.unsafe?.metadata
25923
26103
  });
25924
26104
  } else {
25925
- assert5(accountId, "Missing accountId");
26105
+ assert6(accountId, "Missing accountId");
25926
26106
  let provisionBindingsResult;
25927
26107
  if (assetsOptions?.routerConfig.has_user_worker === false) {
25928
26108
  logger.debug("skipping provisioning on assets-only project");
@@ -25988,6 +26168,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
25988
26168
  dependencies,
25989
26169
  workerBundle,
25990
26170
  projectRoot,
26171
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- compatibility callback for existing deploy-helpers consumers
25991
26172
  callbacks.analyseBundle
25992
26173
  );
25993
26174
  if (message) {
@@ -26036,14 +26217,19 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
26036
26217
  logger.log(`--dry-run: exiting now.`);
26037
26218
  return { versionId, workerTag, bundleSize };
26038
26219
  }
26039
- assert5(accountId);
26040
- if (!hasDurableObjectExports(config2.exports) && getDurableObjectContainerApps(config2.containers).length > 0) {
26041
- assert5(versionId);
26042
- await deployDurableObjectContainerApplications(config2, {
26043
- versionId,
26044
- accountId,
26045
- scriptName
26046
- });
26220
+ assert6(accountId);
26221
+ if (!hasDurableObjectExports(config2.exports) && durableObjectContainerConfig.length > 0) {
26222
+ assert6(versionId);
26223
+ await deployDurableObjectContainerApplications(
26224
+ config2,
26225
+ durableObjectContainerConfig,
26226
+ {
26227
+ versionId,
26228
+ accountId,
26229
+ scriptName,
26230
+ updateExisting: false
26231
+ }
26232
+ );
26047
26233
  }
26048
26234
  const uploadMs = Date.now() - start;
26049
26235
  logger.log("Uploaded", workerName, formatTime(uploadMs));
@@ -26550,6 +26736,10 @@ function getBindingValue(binding) {
26550
26736
  return String(binding.queue_name ?? "");
26551
26737
  case "vectorize":
26552
26738
  return String(binding.index_name ?? "");
26739
+ case "ai_search_namespace":
26740
+ return String(binding.namespace ?? "");
26741
+ case "ai_search":
26742
+ return String(binding.instance_name ?? "");
26553
26743
  case "hyperdrive":
26554
26744
  return String(binding.id ?? "");
26555
26745
  case "analytics_engine":
@@ -26644,6 +26834,18 @@ function extractConfigBindings(config2) {
26644
26834
  index_name: vectorize.index_name
26645
26835
  };
26646
26836
  }
26837
+ for (const ns of previews?.ai_search_namespaces ?? []) {
26838
+ env[ns.binding] = {
26839
+ type: "ai_search_namespace",
26840
+ namespace: ns.namespace
26841
+ };
26842
+ }
26843
+ for (const search of previews?.ai_search ?? []) {
26844
+ env[search.binding] = {
26845
+ type: "ai_search",
26846
+ instance_name: search.instance_name
26847
+ };
26848
+ }
26647
26849
  for (const hyperdrive of previews?.hyperdrive ?? []) {
26648
26850
  env[hyperdrive.binding] = { type: "hyperdrive", id: hyperdrive.id };
26649
26851
  }
@@ -27173,6 +27375,14 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
27173
27375
  }
27174
27376
  }
27175
27377
  const env = extractConfigBindings(config2);
27378
+ for (const [varName, varValue] of Object.entries(options.cliVars ?? {})) {
27379
+ env[varName] = { type: "plain_text", text: varValue };
27380
+ }
27381
+ for (const [secretName, secretValue] of Object.entries(
27382
+ options.secrets ?? {}
27383
+ )) {
27384
+ env[secretName] = { type: "secret_text", text: secretValue };
27385
+ }
27176
27386
  if (Object.keys(env).length > 0) {
27177
27387
  request.env = env;
27178
27388
  }
@@ -27266,6 +27476,10 @@ async function provisionParentWorker(config2, accountId, workerName, json2) {
27266
27476
  __name(provisionParentWorker, "provisionParentWorker");
27267
27477
  async function preview(accountId, args, config2, buildResult, assetsOptions, callbacks) {
27268
27478
  const workerName = resolveWorkerName(args, config2);
27479
+ let secrets;
27480
+ if (args.secretsFile) {
27481
+ secrets = (await parseBulkInputToObject(args.secretsFile))?.content;
27482
+ }
27269
27483
  let previewName = args.name;
27270
27484
  if (!previewName) {
27271
27485
  previewName = getBranchName2();
@@ -27345,7 +27559,9 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
27345
27559
  repositoryUrl,
27346
27560
  pullRequest,
27347
27561
  commitSha,
27348
- assetsOptions
27562
+ assetsOptions,
27563
+ secrets,
27564
+ cliVars: args.cliVars
27349
27565
  }
27350
27566
  );
27351
27567
  const deployment = await createPreviewDeployment(
@@ -27355,6 +27571,11 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
27355
27571
  previewResource.id,
27356
27572
  deploymentRequest
27357
27573
  );
27574
+ for (const binding of Object.values(deployment.env ?? {})) {
27575
+ if (binding.type === "secret_text") {
27576
+ delete binding.text;
27577
+ }
27578
+ }
27358
27579
  if (normalisedContainerConfig.length > 0 && scopedContainerConfig && callbacks.deployPreviewContainers) {
27359
27580
  try {
27360
27581
  await callbacks.deployPreviewContainers(
@@ -27395,7 +27616,7 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
27395
27616
  logMissingPreviewsBindingsWarning(
27396
27617
  topLevelBindings,
27397
27618
  previewBaseConfig.env,
27398
- extractConfigBindings(config2)
27619
+ deploymentRequest.env ?? {}
27399
27620
  );
27400
27621
  }
27401
27622
  }