@cloudflare/deploy-helpers 0.11.2 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3G6JZQDH.mjs → chunk-QBZBEHZB.mjs} +0 -7
- package/dist/create-worker-upload-form.mjs +1 -1
- package/dist/index.d.mts +49 -11
- package/dist/index.mjs +360 -178
- package/dist/metafile-esm.json +1 -1
- package/dist/startup-profile.d.mts +45 -0
- package/dist/startup-profile.mjs +646 -0
- package/package.json +12 -6
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-
|
|
4
|
-
export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-
|
|
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
|
|
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, 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, 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';
|
|
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((
|
|
261
|
-
if (!isString(
|
|
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 (!
|
|
267
|
+
if (!path9) {
|
|
268
268
|
return doThrow(`path must not be empty`, TypeError);
|
|
269
269
|
}
|
|
270
|
-
if (checkPath.isNotRelative(
|
|
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((
|
|
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(
|
|
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(
|
|
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
|
|
362
|
+
const path9 = originalPath && checkPath.convert(originalPath);
|
|
363
363
|
checkPath(
|
|
364
|
-
|
|
364
|
+
path9,
|
|
365
365
|
originalPath,
|
|
366
366
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
367
367
|
);
|
|
368
|
-
return this._t(
|
|
368
|
+
return this._t(path9, cache, checkUnignored, slices);
|
|
369
369
|
}
|
|
370
|
-
_t(
|
|
371
|
-
if (
|
|
372
|
-
return cache[
|
|
370
|
+
_t(path9, cache, checkUnignored, slices) {
|
|
371
|
+
if (path9 in cache) {
|
|
372
|
+
return cache[path9];
|
|
373
373
|
}
|
|
374
374
|
if (!slices) {
|
|
375
|
-
slices =
|
|
375
|
+
slices = path9.split(SLASH);
|
|
376
376
|
}
|
|
377
377
|
slices.pop();
|
|
378
378
|
if (!slices.length) {
|
|
379
|
-
return cache[
|
|
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[
|
|
387
|
+
return cache[path9] = parent.ignored ? parent : this._testOne(path9, checkUnignored);
|
|
388
388
|
}
|
|
389
|
-
ignores(
|
|
390
|
-
return this._test(
|
|
389
|
+
ignores(path9) {
|
|
390
|
+
return this._test(path9, this._ignoreCache, false).ignored;
|
|
391
391
|
}
|
|
392
392
|
createFilter() {
|
|
393
|
-
return (
|
|
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(
|
|
400
|
-
return this._test(
|
|
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((
|
|
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 = (
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
3002
|
-
return fetchResult(config2,
|
|
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
|
-
|
|
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(
|
|
5781
|
-
if (typeof
|
|
5802
|
+
getType(path9) {
|
|
5803
|
+
if (typeof path9 !== "string")
|
|
5782
5804
|
return null;
|
|
5783
|
-
const last =
|
|
5805
|
+
const last = path9.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
5784
5806
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
5785
|
-
const hasPath = last.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
|
-
|
|
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
|
);
|
|
@@ -6526,7 +6560,10 @@ function addContainerImagesBinding(durableObjectContainerConfig, bindings, prepa
|
|
|
6526
6560
|
bindings[CONTAINER_IMAGES_BINDING] = {
|
|
6527
6561
|
type: "json",
|
|
6528
6562
|
value: Object.fromEntries(
|
|
6529
|
-
|
|
6563
|
+
getResolvedDurableObjectContainerApps(
|
|
6564
|
+
durableObjectContainerConfig,
|
|
6565
|
+
options.exports
|
|
6566
|
+
).map((container) => {
|
|
6530
6567
|
const configuredImages = Object.keys(container.images ?? {});
|
|
6531
6568
|
const preparedImages = preparedContainerImages[container.class_name];
|
|
6532
6569
|
if (configuredImages.length > 0 && preparedImages === void 0) {
|
|
@@ -6541,18 +6578,25 @@ function addContainerImagesBinding(durableObjectContainerConfig, bindings, prepa
|
|
|
6541
6578
|
}
|
|
6542
6579
|
__name(addContainerImagesBinding, "addContainerImagesBinding");
|
|
6543
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
|
+
);
|
|
6544
6586
|
return containers?.map((container) => {
|
|
6545
6587
|
if (isDurableObjectContainerApp(container)) {
|
|
6588
|
+
const className = managedClasses.get(container.name);
|
|
6589
|
+
assert6(className, "managed container class should have been resolved");
|
|
6546
6590
|
const configuredImages = Object.keys(container.images ?? {});
|
|
6547
|
-
const images = preparedContainerImages[
|
|
6591
|
+
const images = preparedContainerImages[className];
|
|
6548
6592
|
if (configuredImages.length > 0 && images === void 0 && !options.allowUnprepared) {
|
|
6549
6593
|
throw new Error(
|
|
6550
|
-
`Container images for Durable Object class "${
|
|
6594
|
+
`Container images for Durable Object class "${className}" were not prepared before upload.`
|
|
6551
6595
|
);
|
|
6552
6596
|
}
|
|
6553
6597
|
return {
|
|
6554
6598
|
name: container.name,
|
|
6555
|
-
class_name:
|
|
6599
|
+
class_name: className,
|
|
6556
6600
|
...images !== void 0 && { images }
|
|
6557
6601
|
};
|
|
6558
6602
|
}
|
|
@@ -6573,16 +6617,16 @@ async function getContainerMetadataForRolloutSkip(config2, containers, {
|
|
|
6573
6617
|
latestDeployment,
|
|
6574
6618
|
dryRun = false
|
|
6575
6619
|
}) {
|
|
6576
|
-
const configuredMetadata = getContainerMetadata(
|
|
6577
|
-
containers,
|
|
6578
|
-
{},
|
|
6579
|
-
{
|
|
6580
|
-
allowUnprepared: true
|
|
6581
|
-
}
|
|
6582
|
-
);
|
|
6583
6620
|
if (dryRun || !workerExists) {
|
|
6584
6621
|
return {
|
|
6585
|
-
containers:
|
|
6622
|
+
containers: getContainerMetadata(
|
|
6623
|
+
containers,
|
|
6624
|
+
{},
|
|
6625
|
+
{
|
|
6626
|
+
allowUnprepared: true,
|
|
6627
|
+
exports: config2.exports
|
|
6628
|
+
}
|
|
6629
|
+
),
|
|
6586
6630
|
hasExistingContainerImagesBinding: false
|
|
6587
6631
|
};
|
|
6588
6632
|
}
|
|
@@ -6663,15 +6707,36 @@ function deployWfpUserWorker(dispatchNamespace, versionId) {
|
|
|
6663
6707
|
__name(deployWfpUserWorker, "deployWfpUserWorker");
|
|
6664
6708
|
var IMAGE_PREPARATION_POLL_INTERVAL_MS = 2e3;
|
|
6665
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");
|
|
6666
6730
|
function isRegistryImage(image) {
|
|
6667
6731
|
return typeof image.image === "string";
|
|
6668
6732
|
}
|
|
6669
6733
|
__name(isRegistryImage, "isRegistryImage");
|
|
6670
|
-
function toCreateApplicationRequest({ name }, namespaceId) {
|
|
6734
|
+
function toCreateApplicationRequest({ name }, namespaceId, settings = {}) {
|
|
6671
6735
|
return {
|
|
6672
6736
|
name,
|
|
6673
6737
|
scheduling_policy: SchedulingPolicy.DURABLE_OBJECT,
|
|
6674
|
-
durable_objects: { namespace_id: namespaceId }
|
|
6738
|
+
durable_objects: { namespace_id: namespaceId },
|
|
6739
|
+
...settings
|
|
6675
6740
|
};
|
|
6676
6741
|
}
|
|
6677
6742
|
__name(toCreateApplicationRequest, "toCreateApplicationRequest");
|
|
@@ -6774,6 +6839,45 @@ function getVersionedDurableObjectContainerApplications(versions, scriptName) {
|
|
|
6774
6839
|
});
|
|
6775
6840
|
}
|
|
6776
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");
|
|
6777
6881
|
async function resolveVersionedDurableObjectContainerApplications(config2, {
|
|
6778
6882
|
applications,
|
|
6779
6883
|
accountId,
|
|
@@ -6815,22 +6919,12 @@ async function deployVersionedDurableObjectContainerApplications(config2, args)
|
|
|
6815
6919
|
);
|
|
6816
6920
|
for (const application of applications) {
|
|
6817
6921
|
if (application.namespaceId !== void 0) {
|
|
6818
|
-
await
|
|
6819
|
-
application,
|
|
6820
|
-
application.namespaceId
|
|
6821
|
-
);
|
|
6922
|
+
await applyApplication(application, application.namespaceId);
|
|
6822
6923
|
}
|
|
6823
6924
|
}
|
|
6824
6925
|
}
|
|
6825
6926
|
__name(deployVersionedDurableObjectContainerApplications, "deployVersionedDurableObjectContainerApplications");
|
|
6826
|
-
|
|
6827
|
-
if (isRegistryImage(imageConfig)) {
|
|
6828
|
-
if (dryRun) {
|
|
6829
|
-
return imageConfig.image;
|
|
6830
|
-
}
|
|
6831
|
-
assert5(accountId, "Expected accountId to resolve container image name");
|
|
6832
|
-
return resolveImageName(accountId, imageConfig.image, config2);
|
|
6833
|
-
}
|
|
6927
|
+
function getBuiltImage(container, imageName, builtImages) {
|
|
6834
6928
|
const builtImage = builtImages.find(
|
|
6835
6929
|
(candidate) => candidate.className === container.class_name && candidate.imageName === imageName
|
|
6836
6930
|
);
|
|
@@ -6839,6 +6933,18 @@ async function buildOrResolveImage(config2, container, imageName, imageConfig, b
|
|
|
6839
6933
|
`Container image "${imageName}" for Durable Object class "${container.class_name}" was not built before upload.`
|
|
6840
6934
|
);
|
|
6841
6935
|
}
|
|
6936
|
+
return builtImage;
|
|
6937
|
+
}
|
|
6938
|
+
__name(getBuiltImage, "getBuiltImage");
|
|
6939
|
+
async function pushOrResolveImage(config2, container, imageName, imageConfig, builtImages, dryRun, accountId) {
|
|
6940
|
+
if (isRegistryImage(imageConfig)) {
|
|
6941
|
+
if (dryRun) {
|
|
6942
|
+
return imageConfig.image;
|
|
6943
|
+
}
|
|
6944
|
+
assert6(accountId, "Expected accountId to resolve container image name");
|
|
6945
|
+
return resolveImageName(accountId, imageConfig.image, config2);
|
|
6946
|
+
}
|
|
6947
|
+
const builtImage = getBuiltImage(container, imageName, builtImages);
|
|
6842
6948
|
if (dryRun) {
|
|
6843
6949
|
return builtImage.localTag;
|
|
6844
6950
|
}
|
|
@@ -6851,7 +6957,11 @@ async function buildOrResolveImage(config2, container, imageName, imageConfig, b
|
|
|
6851
6957
|
complianceConfig: config2,
|
|
6852
6958
|
cleanupSourceTag: true
|
|
6853
6959
|
});
|
|
6854
|
-
|
|
6960
|
+
for (const image of builtImages) {
|
|
6961
|
+
if (image.localTag === builtImage.localTag) {
|
|
6962
|
+
image.localTagCleaned = true;
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6855
6965
|
return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
|
|
6856
6966
|
} catch (error51) {
|
|
6857
6967
|
if (error51 instanceof Error) {
|
|
@@ -6865,7 +6975,7 @@ async function buildOrResolveImage(config2, container, imageName, imageConfig, b
|
|
|
6865
6975
|
});
|
|
6866
6976
|
}
|
|
6867
6977
|
}
|
|
6868
|
-
__name(
|
|
6978
|
+
__name(pushOrResolveImage, "pushOrResolveImage");
|
|
6869
6979
|
async function waitForImagePreparation(image) {
|
|
6870
6980
|
const deadline = Date.now() + IMAGE_PREPARATION_TIMEOUT_MS;
|
|
6871
6981
|
while (Date.now() < deadline) {
|
|
@@ -6910,13 +7020,17 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
|
|
|
6910
7020
|
config2,
|
|
6911
7021
|
durableObjectContainerConfig
|
|
6912
7022
|
);
|
|
7023
|
+
const managedContainers = getResolvedDurableObjectContainerApps(
|
|
7024
|
+
durableObjectContainerConfig,
|
|
7025
|
+
config2.exports
|
|
7026
|
+
);
|
|
6913
7027
|
if (!dryRun) {
|
|
6914
|
-
|
|
7028
|
+
assert6(accountId, "Expected accountId to prepare container applications");
|
|
6915
7029
|
const storageByClass = getDurableObjectClassNameToUseSQLiteMap(
|
|
6916
7030
|
config2.migrations,
|
|
6917
7031
|
config2.exports
|
|
6918
7032
|
);
|
|
6919
|
-
const unknownStorage =
|
|
7033
|
+
const unknownStorage = managedContainers.filter(
|
|
6920
7034
|
(container) => storageByClass.get(container.class_name) === void 0
|
|
6921
7035
|
);
|
|
6922
7036
|
if (unknownStorage.length > 0) {
|
|
@@ -6935,7 +7049,7 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
|
|
|
6935
7049
|
}
|
|
6936
7050
|
}
|
|
6937
7051
|
}
|
|
6938
|
-
const containers =
|
|
7052
|
+
const containers = managedContainers.filter(
|
|
6939
7053
|
(container) => Object.keys(container.images ?? {}).length > 0
|
|
6940
7054
|
);
|
|
6941
7055
|
if (containers.length === 0) {
|
|
@@ -6948,13 +7062,10 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
|
|
|
6948
7062
|
for (const [imageName, imageConfig] of Object.entries(
|
|
6949
7063
|
container.images ?? {}
|
|
6950
7064
|
)) {
|
|
6951
|
-
const source = isRegistryImage(imageConfig) ? `image:${imageConfig.image}` : `
|
|
6952
|
-
config2.configPath ? path__default.dirname(config2.configPath) : process.cwd(),
|
|
6953
|
-
imageConfig.dockerfile
|
|
6954
|
-
)}`;
|
|
7065
|
+
const source = isRegistryImage(imageConfig) ? `image:${imageConfig.image}` : `built:${getBuiltImage(container, imageName, builtImages).localTag}`;
|
|
6955
7066
|
let image = preparedImages.get(source);
|
|
6956
7067
|
if (image === void 0) {
|
|
6957
|
-
image = await
|
|
7068
|
+
image = await pushOrResolveImage(
|
|
6958
7069
|
config2,
|
|
6959
7070
|
container,
|
|
6960
7071
|
imageName,
|
|
@@ -6986,9 +7097,13 @@ async function deployDurableObjectContainerApplications(config2, durableObjectCo
|
|
|
6986
7097
|
versionId,
|
|
6987
7098
|
accountId,
|
|
6988
7099
|
scriptName,
|
|
6989
|
-
dispatchNamespace
|
|
7100
|
+
dispatchNamespace,
|
|
7101
|
+
updateExisting = true
|
|
6990
7102
|
}) {
|
|
6991
|
-
const containers =
|
|
7103
|
+
const containers = getResolvedDurableObjectContainerApps(
|
|
7104
|
+
durableObjectContainerConfig,
|
|
7105
|
+
config2.exports
|
|
7106
|
+
);
|
|
6992
7107
|
if (containers.length === 0) {
|
|
6993
7108
|
return;
|
|
6994
7109
|
}
|
|
@@ -7006,7 +7121,12 @@ async function deployDurableObjectContainerApplications(config2, durableObjectCo
|
|
|
7006
7121
|
});
|
|
7007
7122
|
}
|
|
7008
7123
|
for (const { container, namespaceId } of applications) {
|
|
7009
|
-
await
|
|
7124
|
+
await applyApplication(
|
|
7125
|
+
container,
|
|
7126
|
+
namespaceId,
|
|
7127
|
+
getApplicationSettings(container),
|
|
7128
|
+
updateExisting
|
|
7129
|
+
);
|
|
7010
7130
|
}
|
|
7011
7131
|
}
|
|
7012
7132
|
__name(deployDurableObjectContainerApplications, "deployDurableObjectContainerApplications");
|
|
@@ -7049,7 +7169,7 @@ function tagsAreEqual(a, b) {
|
|
|
7049
7169
|
__name(tagsAreEqual, "tagsAreEqual");
|
|
7050
7170
|
async function getMigrationsToUpload(scriptName, props) {
|
|
7051
7171
|
const { config: config2, accountId } = props;
|
|
7052
|
-
|
|
7172
|
+
assert6(accountId, "Missing accountId");
|
|
7053
7173
|
let migrations;
|
|
7054
7174
|
if (config2.migrations.length > 0) {
|
|
7055
7175
|
let script;
|
|
@@ -7305,7 +7425,7 @@ function diagnoseScriptSizeError(err, dependencies) {
|
|
|
7305
7425
|
return message;
|
|
7306
7426
|
}
|
|
7307
7427
|
__name(diagnoseScriptSizeError, "diagnoseScriptSizeError");
|
|
7308
|
-
async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundle) {
|
|
7428
|
+
async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundle = analyseBundleLazily) {
|
|
7309
7429
|
let errorMessage = esm_default`
|
|
7310
7430
|
Your Worker failed validation because it exceeded startup limits.
|
|
7311
7431
|
|
|
@@ -7316,23 +7436,21 @@ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundl
|
|
|
7316
7436
|
|
|
7317
7437
|
Refer to https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time for more details`;
|
|
7318
7438
|
try {
|
|
7319
|
-
if (!analyseBundle) {
|
|
7320
|
-
return errorMessage;
|
|
7321
|
-
}
|
|
7322
7439
|
const cpuProfile = await analyseBundle(workerBundle);
|
|
7323
7440
|
const tmpDir = await getWranglerTmpDir(
|
|
7324
7441
|
projectRoot,
|
|
7325
7442
|
"startup-profile",
|
|
7326
7443
|
false
|
|
7327
7444
|
);
|
|
7328
|
-
const
|
|
7445
|
+
const profilePath = path__default.join(tmpDir.path, "worker.cpuprofile");
|
|
7446
|
+
const displayProfilePath = path__default.relative(
|
|
7329
7447
|
projectRoot ?? process.cwd(),
|
|
7330
|
-
|
|
7448
|
+
profilePath
|
|
7331
7449
|
);
|
|
7332
|
-
await writeFile(
|
|
7450
|
+
await writeFile(profilePath, JSON.stringify(cpuProfile));
|
|
7333
7451
|
errorMessage += esm_default`
|
|
7334
7452
|
|
|
7335
|
-
A CPU Profile of your Worker's startup phase has been written to ${
|
|
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.`;
|
|
7336
7454
|
} catch (profilingError) {
|
|
7337
7455
|
logger.debug(
|
|
7338
7456
|
`An error occurred while trying to locally profile the Worker: ${profilingError}`
|
|
@@ -7341,6 +7459,11 @@ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundl
|
|
|
7341
7459
|
return errorMessage;
|
|
7342
7460
|
}
|
|
7343
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");
|
|
7344
7467
|
function getOffendingDependenciesMessage(dependencies) {
|
|
7345
7468
|
const dependenciesSorted = Object.entries(dependencies);
|
|
7346
7469
|
if (dependenciesSorted.length === 0) {
|
|
@@ -7530,9 +7653,9 @@ async function parseBulkInputToObject(input, includeNull = false) {
|
|
|
7530
7653
|
__name(parseBulkInputToObject, "parseBulkInputToObject");
|
|
7531
7654
|
|
|
7532
7655
|
// src/deploy/helpers/placement.ts
|
|
7533
|
-
function parseConfigPlacement(
|
|
7534
|
-
if (
|
|
7535
|
-
const configPlacement =
|
|
7656
|
+
function parseConfigPlacement(placement) {
|
|
7657
|
+
if (placement) {
|
|
7658
|
+
const configPlacement = placement;
|
|
7536
7659
|
const hint = "hint" in configPlacement ? configPlacement.hint : void 0;
|
|
7537
7660
|
if (!hint && configPlacement.mode === "off") {
|
|
7538
7661
|
return void 0;
|
|
@@ -7656,7 +7779,7 @@ var R2Handler = class extends ProvisionResourceHandler {
|
|
|
7656
7779
|
);
|
|
7657
7780
|
}
|
|
7658
7781
|
async isConnectedToExistingResource() {
|
|
7659
|
-
|
|
7782
|
+
assert6(typeof this.binding.bucket_name !== "symbol");
|
|
7660
7783
|
if (!this.binding.bucket_name) {
|
|
7661
7784
|
return false;
|
|
7662
7785
|
}
|
|
@@ -7703,7 +7826,7 @@ var AISearchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7703
7826
|
);
|
|
7704
7827
|
}
|
|
7705
7828
|
async isConnectedToExistingResource() {
|
|
7706
|
-
|
|
7829
|
+
assert6(typeof this.binding.namespace !== "symbol");
|
|
7707
7830
|
if (!this.binding.namespace) {
|
|
7708
7831
|
return false;
|
|
7709
7832
|
}
|
|
@@ -7746,7 +7869,7 @@ var AgentMemoryNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7746
7869
|
);
|
|
7747
7870
|
}
|
|
7748
7871
|
async isConnectedToExistingResource() {
|
|
7749
|
-
|
|
7872
|
+
assert6(typeof this.binding.namespace !== "symbol");
|
|
7750
7873
|
if (!this.binding.namespace) {
|
|
7751
7874
|
return false;
|
|
7752
7875
|
}
|
|
@@ -7801,7 +7924,7 @@ var QueueHandler = class extends ProvisionResourceHandler {
|
|
|
7801
7924
|
return true;
|
|
7802
7925
|
}
|
|
7803
7926
|
async isConnectedToExistingResource() {
|
|
7804
|
-
|
|
7927
|
+
assert6(typeof this.binding.queue_name !== "symbol");
|
|
7805
7928
|
if (!this.binding.queue_name) {
|
|
7806
7929
|
return false;
|
|
7807
7930
|
}
|
|
@@ -7857,7 +7980,7 @@ var DispatchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7857
7980
|
return true;
|
|
7858
7981
|
}
|
|
7859
7982
|
async isConnectedToExistingResource() {
|
|
7860
|
-
|
|
7983
|
+
assert6(typeof this.binding.namespace !== "symbol");
|
|
7861
7984
|
if (!this.binding.namespace) {
|
|
7862
7985
|
return false;
|
|
7863
7986
|
}
|
|
@@ -7982,7 +8105,7 @@ var D1Handler = class extends ProvisionResourceHandler {
|
|
|
7982
8105
|
return false;
|
|
7983
8106
|
}
|
|
7984
8107
|
async isConnectedToExistingResource() {
|
|
7985
|
-
|
|
8108
|
+
assert6(typeof this.binding.database_name !== "symbol");
|
|
7986
8109
|
if (!this.binding.database_name) {
|
|
7987
8110
|
return false;
|
|
7988
8111
|
}
|
|
@@ -8367,7 +8490,7 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
|
|
|
8367
8490
|
const configPath = config2.userConfigPath ?? config2.configPath;
|
|
8368
8491
|
const { pendingResources, skippedProvisioning } = await collectPendingResources(config2, accountId, scriptName, bindings);
|
|
8369
8492
|
if (pendingResources.length > 0) {
|
|
8370
|
-
|
|
8493
|
+
assert6(
|
|
8371
8494
|
configPath,
|
|
8372
8495
|
"Provisioning resources is not possible without a config file"
|
|
8373
8496
|
);
|
|
@@ -9463,7 +9586,7 @@ __export(util_exports, {
|
|
|
9463
9586
|
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
9464
9587
|
aborted: () => aborted,
|
|
9465
9588
|
allowsEval: () => allowsEval,
|
|
9466
|
-
assert: () =>
|
|
9589
|
+
assert: () => assert7,
|
|
9467
9590
|
assertEqual: () => assertEqual,
|
|
9468
9591
|
assertIs: () => assertIs,
|
|
9469
9592
|
assertNever: () => assertNever,
|
|
@@ -9537,9 +9660,9 @@ function assertNever(_x) {
|
|
|
9537
9660
|
throw new Error("Unexpected value in exhaustive check");
|
|
9538
9661
|
}
|
|
9539
9662
|
__name(assertNever, "assertNever");
|
|
9540
|
-
function
|
|
9663
|
+
function assert7(_) {
|
|
9541
9664
|
}
|
|
9542
|
-
__name(
|
|
9665
|
+
__name(assert7, "assert");
|
|
9543
9666
|
function getEnumValues(entries) {
|
|
9544
9667
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
9545
9668
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -9637,10 +9760,10 @@ function cloneDef(schema) {
|
|
|
9637
9760
|
return mergeDefs(schema._zod.def);
|
|
9638
9761
|
}
|
|
9639
9762
|
__name(cloneDef, "cloneDef");
|
|
9640
|
-
function getElementAtPath(obj,
|
|
9641
|
-
if (!
|
|
9763
|
+
function getElementAtPath(obj, path9) {
|
|
9764
|
+
if (!path9)
|
|
9642
9765
|
return obj;
|
|
9643
|
-
return
|
|
9766
|
+
return path9.reduce((acc, key) => acc?.[key], obj);
|
|
9644
9767
|
}
|
|
9645
9768
|
__name(getElementAtPath, "getElementAtPath");
|
|
9646
9769
|
function promiseAllObject(promisesObj) {
|
|
@@ -10073,11 +10196,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
10073
10196
|
return false;
|
|
10074
10197
|
}
|
|
10075
10198
|
__name(explicitlyAborted, "explicitlyAborted");
|
|
10076
|
-
function prefixIssues(
|
|
10199
|
+
function prefixIssues(path9, issues) {
|
|
10077
10200
|
return issues.map((iss) => {
|
|
10078
10201
|
var _a3;
|
|
10079
10202
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
10080
|
-
iss.path.unshift(
|
|
10203
|
+
iss.path.unshift(path9);
|
|
10081
10204
|
return iss;
|
|
10082
10205
|
});
|
|
10083
10206
|
}
|
|
@@ -10242,16 +10365,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
10242
10365
|
__name(flattenError, "flattenError");
|
|
10243
10366
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
10244
10367
|
const fieldErrors = { _errors: [] };
|
|
10245
|
-
const processError = /* @__PURE__ */ __name((error52,
|
|
10368
|
+
const processError = /* @__PURE__ */ __name((error52, path9 = []) => {
|
|
10246
10369
|
for (const issue2 of error52.issues) {
|
|
10247
10370
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
10248
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10371
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
10249
10372
|
} else if (issue2.code === "invalid_key") {
|
|
10250
|
-
processError({ issues: issue2.issues }, [...
|
|
10373
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
10251
10374
|
} else if (issue2.code === "invalid_element") {
|
|
10252
|
-
processError({ issues: issue2.issues }, [...
|
|
10375
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
10253
10376
|
} else {
|
|
10254
|
-
const fullpath = [...
|
|
10377
|
+
const fullpath = [...path9, ...issue2.path];
|
|
10255
10378
|
if (fullpath.length === 0) {
|
|
10256
10379
|
fieldErrors._errors.push(mapper(issue2));
|
|
10257
10380
|
} else {
|
|
@@ -10279,17 +10402,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
10279
10402
|
__name(formatError, "formatError");
|
|
10280
10403
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
10281
10404
|
const result = { errors: [] };
|
|
10282
|
-
const processError = /* @__PURE__ */ __name((error52,
|
|
10405
|
+
const processError = /* @__PURE__ */ __name((error52, path9 = []) => {
|
|
10283
10406
|
var _a3, _b;
|
|
10284
10407
|
for (const issue2 of error52.issues) {
|
|
10285
10408
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
10286
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10409
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
10287
10410
|
} else if (issue2.code === "invalid_key") {
|
|
10288
|
-
processError({ issues: issue2.issues }, [...
|
|
10411
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
10289
10412
|
} else if (issue2.code === "invalid_element") {
|
|
10290
|
-
processError({ issues: issue2.issues }, [...
|
|
10413
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
10291
10414
|
} else {
|
|
10292
|
-
const fullpath = [...
|
|
10415
|
+
const fullpath = [...path9, ...issue2.path];
|
|
10293
10416
|
if (fullpath.length === 0) {
|
|
10294
10417
|
result.errors.push(mapper(issue2));
|
|
10295
10418
|
continue;
|
|
@@ -10322,8 +10445,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
10322
10445
|
__name(treeifyError, "treeifyError");
|
|
10323
10446
|
function toDotPath(_path) {
|
|
10324
10447
|
const segs = [];
|
|
10325
|
-
const
|
|
10326
|
-
for (const seg of
|
|
10448
|
+
const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
10449
|
+
for (const seg of path9) {
|
|
10327
10450
|
if (typeof seg === "number")
|
|
10328
10451
|
segs.push(`[${seg}]`);
|
|
10329
10452
|
else if (typeof seg === "symbol")
|
|
@@ -23379,13 +23502,13 @@ function resolveRef(ref, ctx) {
|
|
|
23379
23502
|
if (!ref.startsWith("#")) {
|
|
23380
23503
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
23381
23504
|
}
|
|
23382
|
-
const
|
|
23383
|
-
if (
|
|
23505
|
+
const path9 = ref.slice(1).split("/").filter(Boolean);
|
|
23506
|
+
if (path9.length === 0) {
|
|
23384
23507
|
return ctx.rootSchema;
|
|
23385
23508
|
}
|
|
23386
23509
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
23387
|
-
if (
|
|
23388
|
-
const key =
|
|
23510
|
+
if (path9[0] === defsKey) {
|
|
23511
|
+
const key = path9[1];
|
|
23389
23512
|
if (!key || !ctx.defs[key]) {
|
|
23390
23513
|
throw new Error(`Reference not found: ${ref}`);
|
|
23391
23514
|
}
|
|
@@ -23915,12 +24038,12 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
|
|
|
23915
24038
|
// Make sure we're using fresh copies of files each time we source map
|
|
23916
24039
|
emptyCacheBetweenOperations: true,
|
|
23917
24040
|
// Allow retriever to be overridden at prepare stack trace time
|
|
23918
|
-
retrieveSourceMap(
|
|
23919
|
-
return retrieveSourceMapOverride?.(
|
|
24041
|
+
retrieveSourceMap(path9) {
|
|
24042
|
+
return retrieveSourceMapOverride?.(path9) ?? null;
|
|
23920
24043
|
}
|
|
23921
24044
|
});
|
|
23922
24045
|
sourceMappingPrepareStackTrace = Error.prepareStackTrace;
|
|
23923
|
-
|
|
24046
|
+
assert6(sourceMappingPrepareStackTrace !== void 0);
|
|
23924
24047
|
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
23925
24048
|
return sourceMappingPrepareStackTrace;
|
|
23926
24049
|
}
|
|
@@ -23982,7 +24105,7 @@ function getSourceMappedString(value, retrieveSourceMap) {
|
|
|
23982
24105
|
}
|
|
23983
24106
|
const callSiteLine = callSiteLines[i][0];
|
|
23984
24107
|
const callSiteAtIndex = callSiteLine.indexOf("at");
|
|
23985
|
-
|
|
24108
|
+
assert6(callSiteAtIndex !== -1);
|
|
23986
24109
|
const callSiteLineLeftPad = callSiteLine.substring(0, callSiteAtIndex);
|
|
23987
24110
|
value = value.replace(
|
|
23988
24111
|
callSiteLine,
|
|
@@ -24203,8 +24326,7 @@ function extractBindingNames(config2) {
|
|
|
24203
24326
|
return (value ?? []).map((workflowBinding) => workflowBinding.binding);
|
|
24204
24327
|
}
|
|
24205
24328
|
case "browser":
|
|
24206
|
-
case "ai":
|
|
24207
|
-
case "websearch": {
|
|
24329
|
+
case "ai": {
|
|
24208
24330
|
const value = untypedValue;
|
|
24209
24331
|
return value ? [value.binding] : [];
|
|
24210
24332
|
}
|
|
@@ -24378,7 +24500,6 @@ var reorderableBindings = {
|
|
|
24378
24500
|
images: false,
|
|
24379
24501
|
stream: false,
|
|
24380
24502
|
media: false,
|
|
24381
|
-
websearch: false,
|
|
24382
24503
|
version_metadata: false,
|
|
24383
24504
|
unsafe: false,
|
|
24384
24505
|
assets: false
|
|
@@ -24507,8 +24628,7 @@ function removeRemoteConfigFieldFromBindings(normalizedConfig) {
|
|
|
24507
24628
|
"ai",
|
|
24508
24629
|
"images",
|
|
24509
24630
|
"stream",
|
|
24510
|
-
"media"
|
|
24511
|
-
"websearch"
|
|
24631
|
+
"media"
|
|
24512
24632
|
];
|
|
24513
24633
|
for (const singleBindingField of singleBindingFields) {
|
|
24514
24634
|
if (normalizedConfig[singleBindingField] && "remote" in normalizedConfig[singleBindingField]) {
|
|
@@ -24702,10 +24822,10 @@ function populateConfigPatch(diff, patchObj, targetEnvironment) {
|
|
|
24702
24822
|
return;
|
|
24703
24823
|
}
|
|
24704
24824
|
if (Array.isArray(diff)) {
|
|
24705
|
-
|
|
24825
|
+
assert6(Array.isArray(patchObj));
|
|
24706
24826
|
return populateConfigPatchArray(diff, patchObj);
|
|
24707
24827
|
}
|
|
24708
|
-
|
|
24828
|
+
assert6(!Array.isArray(patchObj));
|
|
24709
24829
|
return populateConfigPatchObject(diff, patchObj, targetEnvironment);
|
|
24710
24830
|
}
|
|
24711
24831
|
__name(populateConfigPatch, "populateConfigPatch");
|
|
@@ -25039,7 +25159,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
25039
25159
|
if (props.command === "deploy") {
|
|
25040
25160
|
validateEventTriggerTargets(config2, name);
|
|
25041
25161
|
validateRoutes(props.routes, props.assetsOptions);
|
|
25042
|
-
|
|
25162
|
+
assert6(
|
|
25043
25163
|
!config2.site || config2.site.bucket,
|
|
25044
25164
|
"A [site] definition requires a `bucket` field with a path to the site's assets directory."
|
|
25045
25165
|
);
|
|
@@ -25318,7 +25438,9 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25318
25438
|
dryRun: isDryRun
|
|
25319
25439
|
}
|
|
25320
25440
|
) : void 0;
|
|
25321
|
-
const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(props.containers.source, preparedContainerImages
|
|
25441
|
+
const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(props.containers.source, preparedContainerImages, {
|
|
25442
|
+
exports: config2.exports
|
|
25443
|
+
});
|
|
25322
25444
|
const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
|
|
25323
25445
|
scriptName,
|
|
25324
25446
|
isDryRun,
|
|
@@ -25386,6 +25508,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25386
25508
|
preparedContainerImages ?? {},
|
|
25387
25509
|
{
|
|
25388
25510
|
preserveExisting: skipContainerChanges,
|
|
25511
|
+
exports: config2.exports,
|
|
25389
25512
|
workerExists,
|
|
25390
25513
|
hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
|
|
25391
25514
|
}
|
|
@@ -25398,7 +25521,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25398
25521
|
type: "text"
|
|
25399
25522
|
});
|
|
25400
25523
|
}
|
|
25401
|
-
const placement = parseConfigPlacement(config2);
|
|
25524
|
+
const placement = parseConfigPlacement(config2.placement);
|
|
25402
25525
|
const entryPointName = path__default.basename(resolvedEntryPointPath);
|
|
25403
25526
|
const main = {
|
|
25404
25527
|
name: entryPointName,
|
|
@@ -25475,7 +25598,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25475
25598
|
unsafeMetadata: config2.unsafe?.metadata
|
|
25476
25599
|
});
|
|
25477
25600
|
} else {
|
|
25478
|
-
|
|
25601
|
+
assert6(accountId, "Missing accountId");
|
|
25479
25602
|
let provisionBindingsResult;
|
|
25480
25603
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
25481
25604
|
logger.debug("skipping provisioning on assets-only project");
|
|
@@ -25649,6 +25772,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25649
25772
|
dependencies,
|
|
25650
25773
|
workerBundle,
|
|
25651
25774
|
projectRoot,
|
|
25775
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- compatibility callback for existing deploy-helpers consumers
|
|
25652
25776
|
callbacks.analyseBundle
|
|
25653
25777
|
);
|
|
25654
25778
|
if (message !== null) {
|
|
@@ -25698,7 +25822,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25698
25822
|
const uploadMs = Date.now() - start;
|
|
25699
25823
|
logger.log("Uploaded", workerName, formatTime(uploadMs));
|
|
25700
25824
|
if (shouldDeployContainers) {
|
|
25701
|
-
|
|
25825
|
+
assert6(versionId && accountId);
|
|
25702
25826
|
initContainersSharedContext({ logger, fetchPagedListResult, fetchResult });
|
|
25703
25827
|
const containerDeployments = [];
|
|
25704
25828
|
for (const container of normalisedContainerConfig) {
|
|
@@ -25706,7 +25830,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25706
25830
|
const builtImage = builtContainerImages.find(
|
|
25707
25831
|
(image) => image.container === container
|
|
25708
25832
|
);
|
|
25709
|
-
|
|
25833
|
+
assert6(
|
|
25710
25834
|
builtImage,
|
|
25711
25835
|
"Expected container image to be built before upload"
|
|
25712
25836
|
);
|
|
@@ -25735,7 +25859,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25735
25859
|
});
|
|
25736
25860
|
}
|
|
25737
25861
|
if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
|
|
25738
|
-
|
|
25862
|
+
assert6(versionId && accountId);
|
|
25739
25863
|
try {
|
|
25740
25864
|
await deployDurableObjectContainerApplications(
|
|
25741
25865
|
config2,
|
|
@@ -25749,7 +25873,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25749
25873
|
);
|
|
25750
25874
|
} catch (error51) {
|
|
25751
25875
|
throw new UserError(
|
|
25752
|
-
"The Worker version was deployed, but Wrangler could not finish
|
|
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.",
|
|
25753
25877
|
{
|
|
25754
25878
|
telemetryMessage: "deploy durable object container application creation failed after deployment",
|
|
25755
25879
|
cause: error51
|
|
@@ -25761,7 +25885,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25761
25885
|
deployWfpUserWorker(props.dispatchNamespace, versionId);
|
|
25762
25886
|
return { versionId, workerTag, assetUploadStats, bundleSize };
|
|
25763
25887
|
}
|
|
25764
|
-
|
|
25888
|
+
assert6(accountId);
|
|
25765
25889
|
const targets = await triggersDeploy({
|
|
25766
25890
|
config: config2,
|
|
25767
25891
|
accountId,
|
|
@@ -25796,7 +25920,7 @@ function renderBindingDependsOnExportError(serverMessage) {
|
|
|
25796
25920
|
__name(renderBindingDependsOnExportError, "renderBindingDependsOnExportError");
|
|
25797
25921
|
|
|
25798
25922
|
// src/deploy/versions-upload.ts
|
|
25799
|
-
async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
25923
|
+
async function versionsUpload(props, config2, buildResult, callbacks = {}) {
|
|
25800
25924
|
const result = await uploadWorkerVersion(
|
|
25801
25925
|
props,
|
|
25802
25926
|
config2,
|
|
@@ -25908,9 +26032,10 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25908
26032
|
addContainerImagesBinding(
|
|
25909
26033
|
durableObjectContainerConfig,
|
|
25910
26034
|
bindings,
|
|
25911
|
-
preparedContainerImages ?? {}
|
|
26035
|
+
preparedContainerImages ?? {},
|
|
26036
|
+
{ exports: config2.exports }
|
|
25912
26037
|
);
|
|
25913
|
-
const placement = parseConfigPlacement(config2);
|
|
26038
|
+
const placement = parseConfigPlacement(config2.placement);
|
|
25914
26039
|
const entryPointName = path__default.basename(resolvedEntryPointPath);
|
|
25915
26040
|
const main = {
|
|
25916
26041
|
name: entryPointName,
|
|
@@ -25926,7 +26051,8 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25926
26051
|
modules,
|
|
25927
26052
|
containers: getContainerMetadata(
|
|
25928
26053
|
props.containers.source,
|
|
25929
|
-
preparedContainerImages
|
|
26054
|
+
preparedContainerImages,
|
|
26055
|
+
{ exports: config2.exports }
|
|
25930
26056
|
),
|
|
25931
26057
|
sourceMaps,
|
|
25932
26058
|
compatibility_date: compatibilityDate,
|
|
@@ -25976,7 +26102,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25976
26102
|
unsafeMetadata: config2.unsafe?.metadata
|
|
25977
26103
|
});
|
|
25978
26104
|
} else {
|
|
25979
|
-
|
|
26105
|
+
assert6(accountId, "Missing accountId");
|
|
25980
26106
|
let provisionBindingsResult;
|
|
25981
26107
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
25982
26108
|
logger.debug("skipping provisioning on assets-only project");
|
|
@@ -26042,6 +26168,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
26042
26168
|
dependencies,
|
|
26043
26169
|
workerBundle,
|
|
26044
26170
|
projectRoot,
|
|
26171
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- compatibility callback for existing deploy-helpers consumers
|
|
26045
26172
|
callbacks.analyseBundle
|
|
26046
26173
|
);
|
|
26047
26174
|
if (message) {
|
|
@@ -26090,16 +26217,17 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
26090
26217
|
logger.log(`--dry-run: exiting now.`);
|
|
26091
26218
|
return { versionId, workerTag, bundleSize };
|
|
26092
26219
|
}
|
|
26093
|
-
|
|
26220
|
+
assert6(accountId);
|
|
26094
26221
|
if (!hasDurableObjectExports(config2.exports) && durableObjectContainerConfig.length > 0) {
|
|
26095
|
-
|
|
26222
|
+
assert6(versionId);
|
|
26096
26223
|
await deployDurableObjectContainerApplications(
|
|
26097
26224
|
config2,
|
|
26098
26225
|
durableObjectContainerConfig,
|
|
26099
26226
|
{
|
|
26100
26227
|
versionId,
|
|
26101
26228
|
accountId,
|
|
26102
|
-
scriptName
|
|
26229
|
+
scriptName,
|
|
26230
|
+
updateExisting: false
|
|
26103
26231
|
}
|
|
26104
26232
|
);
|
|
26105
26233
|
}
|
|
@@ -26608,6 +26736,10 @@ function getBindingValue(binding) {
|
|
|
26608
26736
|
return String(binding.queue_name ?? "");
|
|
26609
26737
|
case "vectorize":
|
|
26610
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 ?? "");
|
|
26611
26743
|
case "hyperdrive":
|
|
26612
26744
|
return String(binding.id ?? "");
|
|
26613
26745
|
case "analytics_engine":
|
|
@@ -26653,13 +26785,18 @@ function extractConfigBindings(config2) {
|
|
|
26653
26785
|
};
|
|
26654
26786
|
}
|
|
26655
26787
|
for (const r2 of previews?.r2_buckets ?? []) {
|
|
26656
|
-
env[r2.binding] = {
|
|
26788
|
+
env[r2.binding] = {
|
|
26789
|
+
type: "r2_bucket",
|
|
26790
|
+
bucket_name: r2.bucket_name,
|
|
26791
|
+
jurisdiction: r2.jurisdiction
|
|
26792
|
+
};
|
|
26657
26793
|
}
|
|
26658
26794
|
for (const service of previews?.services ?? []) {
|
|
26659
|
-
const crossAccountGrant = service
|
|
26795
|
+
const { cross_account_grant: crossAccountGrant, environment } = service;
|
|
26660
26796
|
env[service.binding] = {
|
|
26661
26797
|
type: "service",
|
|
26662
26798
|
service: service.service,
|
|
26799
|
+
environment,
|
|
26663
26800
|
entrypoint: service.entrypoint,
|
|
26664
26801
|
...crossAccountGrant !== void 0 && {
|
|
26665
26802
|
cross_account_grant: crossAccountGrant
|
|
@@ -26702,6 +26839,18 @@ function extractConfigBindings(config2) {
|
|
|
26702
26839
|
index_name: vectorize.index_name
|
|
26703
26840
|
};
|
|
26704
26841
|
}
|
|
26842
|
+
for (const ns of previews?.ai_search_namespaces ?? []) {
|
|
26843
|
+
env[ns.binding] = {
|
|
26844
|
+
type: "ai_search_namespace",
|
|
26845
|
+
namespace: ns.namespace
|
|
26846
|
+
};
|
|
26847
|
+
}
|
|
26848
|
+
for (const search of previews?.ai_search ?? []) {
|
|
26849
|
+
env[search.binding] = {
|
|
26850
|
+
type: "ai_search",
|
|
26851
|
+
instance_name: search.instance_name
|
|
26852
|
+
};
|
|
26853
|
+
}
|
|
26705
26854
|
for (const hyperdrive of previews?.hyperdrive ?? []) {
|
|
26706
26855
|
env[hyperdrive.binding] = { type: "hyperdrive", id: hyperdrive.id };
|
|
26707
26856
|
}
|
|
@@ -26919,6 +27068,16 @@ function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, pre
|
|
|
26919
27068
|
};
|
|
26920
27069
|
}
|
|
26921
27070
|
__name(buildPreviewContainerConfig, "buildPreviewContainerConfig");
|
|
27071
|
+
function getPreviewExports(exports$1) {
|
|
27072
|
+
const previewExports = structuredClone(exports$1);
|
|
27073
|
+
for (const configuredExport of Object.values(previewExports)) {
|
|
27074
|
+
if (configuredExport.type === "durable-object" && "container" in configuredExport) {
|
|
27075
|
+
delete configuredExport.container;
|
|
27076
|
+
}
|
|
27077
|
+
}
|
|
27078
|
+
return previewExports;
|
|
27079
|
+
}
|
|
27080
|
+
__name(getPreviewExports, "getPreviewExports");
|
|
26922
27081
|
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks) {
|
|
26923
27082
|
const previewContainers = config2.previews?.containers ?? [];
|
|
26924
27083
|
if (previewContainers.length === 0 || !callbacks.getNormalizedContainerOptions) {
|
|
@@ -27164,6 +27323,9 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
27164
27323
|
if (config2.compatibility_flags && config2.compatibility_flags.length > 0) {
|
|
27165
27324
|
request.compatibility_flags = config2.compatibility_flags;
|
|
27166
27325
|
}
|
|
27326
|
+
if (Object.keys(config2.exports).length > 0) {
|
|
27327
|
+
request.exports = getPreviewExports(config2.exports);
|
|
27328
|
+
}
|
|
27167
27329
|
const repositoryUrl = options.repositoryUrl;
|
|
27168
27330
|
const pullRequest = options.pullRequest;
|
|
27169
27331
|
const commitSha = options.commitSha;
|
|
@@ -27217,8 +27379,9 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
27217
27379
|
} else if (config2.cache !== void 0) {
|
|
27218
27380
|
request.cache = config2.cache;
|
|
27219
27381
|
}
|
|
27220
|
-
|
|
27221
|
-
|
|
27382
|
+
const placement = previews?.placement ?? config2.placement;
|
|
27383
|
+
if (placement !== void 0) {
|
|
27384
|
+
request.placement = placement.mode === "off" ? null : parseConfigPlacement(placement);
|
|
27222
27385
|
}
|
|
27223
27386
|
const previewContainers = previews?.containers ?? [];
|
|
27224
27387
|
if (previewContainers.length > 0) {
|
|
@@ -27231,6 +27394,14 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
27231
27394
|
}
|
|
27232
27395
|
}
|
|
27233
27396
|
const env = extractConfigBindings(config2);
|
|
27397
|
+
for (const [varName, varValue] of Object.entries(options.cliVars ?? {})) {
|
|
27398
|
+
env[varName] = { type: "plain_text", text: varValue };
|
|
27399
|
+
}
|
|
27400
|
+
for (const [secretName, secretValue] of Object.entries(
|
|
27401
|
+
options.secrets ?? {}
|
|
27402
|
+
)) {
|
|
27403
|
+
env[secretName] = { type: "secret_text", text: secretValue };
|
|
27404
|
+
}
|
|
27234
27405
|
if (Object.keys(env).length > 0) {
|
|
27235
27406
|
request.env = env;
|
|
27236
27407
|
}
|
|
@@ -27259,37 +27430,37 @@ function formatPreviewDeploymentSummary(config2, previewResource, deployment, is
|
|
|
27259
27430
|
return [
|
|
27260
27431
|
`${chalk6.bold("Preview:")} ${previewResource.name} ${statusLabel}`,
|
|
27261
27432
|
...formatUrlLines("Preview", previewResource.urls),
|
|
27262
|
-
"",
|
|
27263
|
-
`${chalk6.bold("Deployment ID:")} ${deployment.id}`,
|
|
27264
|
-
...formatUrlLines("Deployment", deployment.urls),
|
|
27265
27433
|
...pullRequestUrl || pullRequestNumber ? [
|
|
27266
27434
|
`${chalk6.bold("Pull Request:")} ${pullRequestUrl ?? `#${pullRequestNumber}`}`
|
|
27267
27435
|
] : [],
|
|
27436
|
+
...formatUrlLines("Unique Deployment", deployment.urls),
|
|
27268
27437
|
...hasActiveUrls ? [] : [formatNoActivePreviewUrlsMessage(config2)]
|
|
27269
27438
|
].join("\n");
|
|
27270
27439
|
}
|
|
27271
27440
|
__name(formatPreviewDeploymentSummary, "formatPreviewDeploymentSummary");
|
|
27272
|
-
function logMissingPreviewsBindingsWarning(
|
|
27441
|
+
function logMissingPreviewsBindingsWarning(productionBindingsExpectedInPreview, remotePreviewDefaultBindings, localPreviewBindings) {
|
|
27273
27442
|
const availableBindingNames = /* @__PURE__ */ new Set([
|
|
27274
27443
|
...Object.keys(remotePreviewDefaultBindings ?? {}),
|
|
27275
27444
|
...Object.keys(localPreviewBindings)
|
|
27276
27445
|
]);
|
|
27277
|
-
const
|
|
27278
|
-
Object.entries(
|
|
27446
|
+
const missingPreviewBindings = Object.fromEntries(
|
|
27447
|
+
Object.entries(productionBindingsExpectedInPreview).filter(
|
|
27279
27448
|
([name]) => !availableBindingNames.has(name)
|
|
27280
27449
|
)
|
|
27281
27450
|
);
|
|
27282
|
-
if (Object.keys(
|
|
27451
|
+
if (Object.keys(missingPreviewBindings).length === 0) {
|
|
27283
27452
|
return;
|
|
27284
27453
|
}
|
|
27285
|
-
logger.warn(`
|
|
27286
|
-
The following bindings are configured at the top level of your Wrangler config file, but are missing from the Previews settings of your Worker.
|
|
27454
|
+
logger.warn(`These bindings are configured for your production Worker but not for Previews:
|
|
27287
27455
|
|
|
27288
|
-
${Object.entries(
|
|
27456
|
+
${Object.entries(missingPreviewBindings).map(
|
|
27289
27457
|
([name, binding]) => ` ${chalk6.cyan(name)} ${chalk6.dim(getBindingTypeFriendlyName(binding.type))}`
|
|
27290
27458
|
).join("\n")}
|
|
27291
27459
|
|
|
27292
|
-
|
|
27460
|
+
Parts of your Worker that depend on these bindings may not work correctly in the Preview. If this is not intentional, add Preview-safe values to the ${chalk6.cyan("previews")} field.
|
|
27461
|
+
|
|
27462
|
+
Configuration: https://developers.cloudflare.com/workers/previews/configuration/
|
|
27463
|
+
Resources: https://developers.cloudflare.com/workers/previews/resources/`);
|
|
27293
27464
|
}
|
|
27294
27465
|
__name(logMissingPreviewsBindingsWarning, "logMissingPreviewsBindingsWarning");
|
|
27295
27466
|
async function provisionParentWorker(config2, accountId, workerName, json2) {
|
|
@@ -27324,6 +27495,10 @@ async function provisionParentWorker(config2, accountId, workerName, json2) {
|
|
|
27324
27495
|
__name(provisionParentWorker, "provisionParentWorker");
|
|
27325
27496
|
async function preview(accountId, args, config2, buildResult, assetsOptions, callbacks) {
|
|
27326
27497
|
const workerName = resolveWorkerName(args, config2);
|
|
27498
|
+
let secrets;
|
|
27499
|
+
if (args.secretsFile) {
|
|
27500
|
+
secrets = (await parseBulkInputToObject(args.secretsFile))?.content;
|
|
27501
|
+
}
|
|
27327
27502
|
let previewName = args.name;
|
|
27328
27503
|
if (!previewName) {
|
|
27329
27504
|
previewName = getBranchName2();
|
|
@@ -27403,7 +27578,9 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27403
27578
|
repositoryUrl,
|
|
27404
27579
|
pullRequest,
|
|
27405
27580
|
commitSha,
|
|
27406
|
-
assetsOptions
|
|
27581
|
+
assetsOptions,
|
|
27582
|
+
secrets,
|
|
27583
|
+
cliVars: args.cliVars
|
|
27407
27584
|
}
|
|
27408
27585
|
);
|
|
27409
27586
|
const deployment = await createPreviewDeployment(
|
|
@@ -27413,6 +27590,11 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27413
27590
|
previewResource.id,
|
|
27414
27591
|
deploymentRequest
|
|
27415
27592
|
);
|
|
27593
|
+
for (const binding of Object.values(deployment.env ?? {})) {
|
|
27594
|
+
if (binding.type === "secret_text") {
|
|
27595
|
+
delete binding.text;
|
|
27596
|
+
}
|
|
27597
|
+
}
|
|
27416
27598
|
if (normalisedContainerConfig.length > 0 && scopedContainerConfig && callbacks.deployPreviewContainers) {
|
|
27417
27599
|
try {
|
|
27418
27600
|
await callbacks.deployPreviewContainers(
|
|
@@ -27434,28 +27616,28 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27434
27616
|
JSON.stringify({ preview: previewResource, deployment }, null, 2)
|
|
27435
27617
|
);
|
|
27436
27618
|
} else {
|
|
27437
|
-
|
|
27438
|
-
|
|
27439
|
-
config2,
|
|
27440
|
-
previewResource,
|
|
27441
|
-
deployment,
|
|
27442
|
-
isNewPreview,
|
|
27443
|
-
pullRequest
|
|
27444
|
-
)
|
|
27445
|
-
);
|
|
27446
|
-
const topLevelBindings = getBindings(config2);
|
|
27447
|
-
if (Object.keys(topLevelBindings).length > 0) {
|
|
27619
|
+
const productionBindingsExpectedInPreview = callbacks.productionBindingsExpectedInPreview ?? {};
|
|
27620
|
+
if (Object.keys(productionBindingsExpectedInPreview).length > 0) {
|
|
27448
27621
|
const previewBaseConfig = await getPreviewBaseConfig(
|
|
27449
27622
|
config2,
|
|
27450
27623
|
accountId,
|
|
27451
27624
|
workerName
|
|
27452
27625
|
);
|
|
27453
27626
|
logMissingPreviewsBindingsWarning(
|
|
27454
|
-
|
|
27627
|
+
productionBindingsExpectedInPreview,
|
|
27455
27628
|
previewBaseConfig.env,
|
|
27456
|
-
|
|
27629
|
+
deploymentRequest.env ?? {}
|
|
27457
27630
|
);
|
|
27458
27631
|
}
|
|
27632
|
+
logger.log(
|
|
27633
|
+
formatPreviewDeploymentSummary(
|
|
27634
|
+
config2,
|
|
27635
|
+
previewResource,
|
|
27636
|
+
deployment,
|
|
27637
|
+
isNewPreview,
|
|
27638
|
+
pullRequest
|
|
27639
|
+
)
|
|
27640
|
+
);
|
|
27459
27641
|
}
|
|
27460
27642
|
return { preview: previewResource, deployment, isNewPreview };
|
|
27461
27643
|
}
|