@cloudflare/deploy-helpers 0.2.5 → 0.3.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.d.mts +125 -14
- package/dist/index.mjs +466 -103
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { __commonJS, __name, __require, __toESM, fetchResult, fetchListResult, l
|
|
|
2
2
|
export { initDeployHelpersContext } from './chunk-N72KNDFF.mjs';
|
|
3
3
|
import * as path3 from 'node:path';
|
|
4
4
|
import path3__default, { resolve, isAbsolute, dirname, join, extname, sep } from 'node:path';
|
|
5
|
-
import fs2, { readFileSync, statSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import fs2, { readFileSync, statSync, existsSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
|
|
6
6
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
7
7
|
import * as z from 'zod';
|
|
8
8
|
import { z as z$1 } from 'zod';
|
|
@@ -10,7 +10,7 @@ import assert4 from 'node:assert';
|
|
|
10
10
|
import url, { URLSearchParams as URLSearchParams$1 } from 'node:url';
|
|
11
11
|
import * as cli from '@cloudflare/cli-shared-helpers';
|
|
12
12
|
import { cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
|
-
import { INHERIT_SYMBOL, APIError, UserError as UserError$1, getEnvironmentVariableFactory, getHostFromRoute, retryOnAPIFailure, ParseError as ParseError$1, getComplianceRegionSubdomain, configFileName as configFileName$1, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getWranglerTmpDir, FatalError as FatalError$1, readFileSync as readFileSync$2, parseJSON as parseJSON$1, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever as assertNever$1, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet as formatConfigSnippet$1, getTodaysCompatDate, getDockerPath, parseNonHyphenedUuid as parseNonHyphenedUuid$1, getWorkersCIBranchName } from '@cloudflare/workers-utils';
|
|
13
|
+
import { INHERIT_SYMBOL, APIError, UserError as UserError$1, getEnvironmentVariableFactory, getHostFromRoute, retryOnAPIFailure, ParseError as ParseError$1, getComplianceRegionSubdomain, configFileName as configFileName$1, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports as partitionExports$1, getWranglerTmpDir, FatalError as FatalError$1, readFileSync as readFileSync$2, parseJSON as parseJSON$1, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever as assertNever$1, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet as formatConfigSnippet$1, getTodaysCompatDate, hasDurableObjectExports, getDockerPath, parseNonHyphenedUuid as parseNonHyphenedUuid$1, getWorkersCIBranchName } from '@cloudflare/workers-utils';
|
|
14
14
|
import { spawnSync, execSync, spawn } from 'node:child_process';
|
|
15
15
|
import { FormData, Response } from 'undici';
|
|
16
16
|
import chalk5 from 'chalk';
|
|
@@ -20,7 +20,7 @@ import prettyBytes from 'pretty-bytes';
|
|
|
20
20
|
import { hash } from 'blake3-wasm';
|
|
21
21
|
import { Blob } from 'node:buffer';
|
|
22
22
|
import { gzipSync } from 'node:zlib';
|
|
23
|
-
import { brandColor, white, gray, dim, blue } from '@cloudflare/cli-shared-helpers/colors';
|
|
23
|
+
import { brandColor, white, gray, bold, yellow, dim, red, blue } from '@cloudflare/cli-shared-helpers/colors';
|
|
24
24
|
import { inputPrompt, leftT } from '@cloudflare/cli-shared-helpers/interactive';
|
|
25
25
|
import { sync } from 'command-exists';
|
|
26
26
|
import readline from 'node:readline';
|
|
@@ -2753,6 +2753,17 @@ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name"
|
|
|
2753
2753
|
value,
|
|
2754
2754
|
configurable: true
|
|
2755
2755
|
}), "__name");
|
|
2756
|
+
function partitionExports(exports$2) {
|
|
2757
|
+
const partitioned = {
|
|
2758
|
+
"durable-object": {},
|
|
2759
|
+
worker: {}
|
|
2760
|
+
};
|
|
2761
|
+
if (exports$2 === void 0) return partitioned;
|
|
2762
|
+
for (const [name, entry] of Object.entries(exports$2)) partitioned[entry.type][name] = entry;
|
|
2763
|
+
return partitioned;
|
|
2764
|
+
}
|
|
2765
|
+
__name(partitionExports, "partitionExports");
|
|
2766
|
+
__name2(partitionExports, "partitionExports");
|
|
2756
2767
|
var UserError = class extends Error {
|
|
2757
2768
|
static {
|
|
2758
2769
|
__name(this, "UserError");
|
|
@@ -4881,6 +4892,12 @@ var ParseError = class extends UserError {
|
|
|
4881
4892
|
#status;
|
|
4882
4893
|
code;
|
|
4883
4894
|
accountTag;
|
|
4895
|
+
/**
|
|
4896
|
+
* Optional structured metadata hoisted from the first `FetchError.meta`
|
|
4897
|
+
* on the v4 response envelope. Consumers can inspect this to render
|
|
4898
|
+
* endpoint-specific structured error payloads.
|
|
4899
|
+
*/
|
|
4900
|
+
meta;
|
|
4884
4901
|
constructor({ status, ...rest }) {
|
|
4885
4902
|
super(rest);
|
|
4886
4903
|
this.name = this.constructor.name;
|
|
@@ -5582,7 +5599,10 @@ function isParsedUnsafeBinding(binding) {
|
|
|
5582
5599
|
return binding.type.startsWith("unsafe:");
|
|
5583
5600
|
}
|
|
5584
5601
|
__name(isParsedUnsafeBinding, "isParsedUnsafeBinding");
|
|
5585
|
-
var CacheSchema = z.strictObject({
|
|
5602
|
+
var CacheSchema = z.strictObject({
|
|
5603
|
+
enabled: z.boolean(),
|
|
5604
|
+
crossVersionCache: z.boolean().optional()
|
|
5605
|
+
});
|
|
5586
5606
|
var SINGLETON_BINDING_TYPES = /* @__PURE__ */ new Set([
|
|
5587
5607
|
"ai",
|
|
5588
5608
|
"assets",
|
|
@@ -5609,10 +5629,37 @@ var EnvSchema = z.record(z.string(), BindingSchema).superRefine((env, ctx) => {
|
|
|
5609
5629
|
message: `${listFormatter.format([...duplicates].sort())} bindings can only be defined once`
|
|
5610
5630
|
});
|
|
5611
5631
|
}).optional();
|
|
5612
|
-
var ExportSchema = z.
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5632
|
+
var ExportSchema = z.union([
|
|
5633
|
+
z.strictObject({
|
|
5634
|
+
type: z.literal("durable-object"),
|
|
5635
|
+
state: z.literal("created").optional(),
|
|
5636
|
+
storage: z.enum(["sqlite", "legacy-kv"])
|
|
5637
|
+
}),
|
|
5638
|
+
z.strictObject({
|
|
5639
|
+
type: z.literal("durable-object"),
|
|
5640
|
+
state: z.literal("deleted")
|
|
5641
|
+
}),
|
|
5642
|
+
z.strictObject({
|
|
5643
|
+
type: z.literal("durable-object"),
|
|
5644
|
+
state: z.literal("renamed"),
|
|
5645
|
+
renamedTo: z.string()
|
|
5646
|
+
}),
|
|
5647
|
+
z.strictObject({
|
|
5648
|
+
type: z.literal("durable-object"),
|
|
5649
|
+
state: z.literal("transferred"),
|
|
5650
|
+
transferredTo: z.string()
|
|
5651
|
+
}),
|
|
5652
|
+
z.strictObject({
|
|
5653
|
+
type: z.literal("durable-object"),
|
|
5654
|
+
state: z.literal("expecting-transfer"),
|
|
5655
|
+
storage: z.enum(["sqlite", "legacy-kv"]),
|
|
5656
|
+
transferFrom: z.string()
|
|
5657
|
+
}),
|
|
5658
|
+
z.strictObject({
|
|
5659
|
+
type: z.literal("worker"),
|
|
5660
|
+
cache: z.strictObject({ enabled: z.boolean() }).optional()
|
|
5661
|
+
})
|
|
5662
|
+
]);
|
|
5616
5663
|
var LimitsSchema = z.strictObject({
|
|
5617
5664
|
cpuMs: z.number().optional(),
|
|
5618
5665
|
subrequests: z.number().optional()
|
|
@@ -5772,7 +5819,7 @@ function convertToWranglerConfig(config) {
|
|
|
5772
5819
|
const result = {};
|
|
5773
5820
|
convertTopLevel(config, result);
|
|
5774
5821
|
convertBindingsAndAssets(config, result);
|
|
5775
|
-
convertExports(config);
|
|
5822
|
+
convertExports(config, result);
|
|
5776
5823
|
convertDomains(config, result);
|
|
5777
5824
|
convertTriggers(config, result);
|
|
5778
5825
|
convertTailConsumers(config, result);
|
|
@@ -5798,7 +5845,11 @@ function convertTopLevel(config, result) {
|
|
|
5798
5845
|
result.limits = limits;
|
|
5799
5846
|
}
|
|
5800
5847
|
if (config.observability !== void 0) result.observability = convertObservability(config.observability);
|
|
5801
|
-
if (config.cache !== void 0)
|
|
5848
|
+
if (config.cache !== void 0) {
|
|
5849
|
+
const cache = { enabled: config.cache.enabled };
|
|
5850
|
+
if (config.cache.crossVersionCache !== void 0) cache.cross_version_cache = config.cache.crossVersionCache;
|
|
5851
|
+
result.cache = cache;
|
|
5852
|
+
}
|
|
5802
5853
|
if (config.unsafe !== void 0) result.unsafe = convertUnsafeTopLevel(config.unsafe);
|
|
5803
5854
|
}
|
|
5804
5855
|
__name(convertTopLevel, "convertTopLevel");
|
|
@@ -6159,10 +6210,60 @@ function convertBindingsAndAssets(config, result) {
|
|
|
6159
6210
|
}
|
|
6160
6211
|
}
|
|
6161
6212
|
__name(convertBindingsAndAssets, "convertBindingsAndAssets");
|
|
6162
|
-
function convertExports(config,
|
|
6213
|
+
function convertExports(config, result) {
|
|
6163
6214
|
const exports$2 = config.exports;
|
|
6164
6215
|
if (!exports$2) return;
|
|
6165
|
-
|
|
6216
|
+
const converted = {};
|
|
6217
|
+
const unknownExports = {};
|
|
6218
|
+
for (const [exportName, value] of Object.entries(exports$2)) {
|
|
6219
|
+
if (value.type === "worker") {
|
|
6220
|
+
converted[exportName] = value;
|
|
6221
|
+
continue;
|
|
6222
|
+
}
|
|
6223
|
+
if (value.type !== "durable-object") {
|
|
6224
|
+
unknownExports[exportName] = value;
|
|
6225
|
+
continue;
|
|
6226
|
+
}
|
|
6227
|
+
switch (value.state) {
|
|
6228
|
+
case void 0:
|
|
6229
|
+
case "created":
|
|
6230
|
+
converted[exportName] = {
|
|
6231
|
+
type: "durable-object",
|
|
6232
|
+
storage: value.storage
|
|
6233
|
+
};
|
|
6234
|
+
break;
|
|
6235
|
+
case "deleted":
|
|
6236
|
+
converted[exportName] = {
|
|
6237
|
+
type: "durable-object",
|
|
6238
|
+
state: "deleted"
|
|
6239
|
+
};
|
|
6240
|
+
break;
|
|
6241
|
+
case "renamed":
|
|
6242
|
+
converted[exportName] = {
|
|
6243
|
+
type: "durable-object",
|
|
6244
|
+
state: "renamed",
|
|
6245
|
+
renamed_to: value.renamedTo
|
|
6246
|
+
};
|
|
6247
|
+
break;
|
|
6248
|
+
case "transferred":
|
|
6249
|
+
converted[exportName] = {
|
|
6250
|
+
type: "durable-object",
|
|
6251
|
+
state: "transferred",
|
|
6252
|
+
transferred_to: value.transferredTo
|
|
6253
|
+
};
|
|
6254
|
+
break;
|
|
6255
|
+
case "expecting-transfer":
|
|
6256
|
+
converted[exportName] = {
|
|
6257
|
+
type: "durable-object",
|
|
6258
|
+
state: "expecting-transfer",
|
|
6259
|
+
storage: value.storage,
|
|
6260
|
+
transfer_from: value.transferFrom
|
|
6261
|
+
};
|
|
6262
|
+
break;
|
|
6263
|
+
}
|
|
6264
|
+
}
|
|
6265
|
+
if (Object.keys(unknownExports).length > 0) throw new UserError("Unknown export types found: " + Object.entries(unknownExports).map(([exportName, { type }]) => `- ${exportName} : ${type}`).join("\n"), { telemetryMessage: "Unknown export types found" });
|
|
6266
|
+
if (Object.keys(converted).length > 0) result.exports = converted;
|
|
6166
6267
|
}
|
|
6167
6268
|
__name(convertExports, "convertExports");
|
|
6168
6269
|
function convertTriggers(config, result) {
|
|
@@ -8987,14 +9088,15 @@ var hashFile = /* @__PURE__ */ __name((filepath) => {
|
|
|
8987
9088
|
}, "hashFile");
|
|
8988
9089
|
|
|
8989
9090
|
// src/deploy/helpers/jwt.ts
|
|
9091
|
+
var decodeJwtPayload = /* @__PURE__ */ __name((token) => {
|
|
9092
|
+
return JSON.parse(Buffer.from(token.split(".")[1], "base64").toString());
|
|
9093
|
+
}, "decodeJwtPayload");
|
|
8990
9094
|
var isJwtExpired = /* @__PURE__ */ __name((token) => {
|
|
8991
9095
|
if ("vitest" in globalThis && (token === "<<funfetti-auth-jwt>>" || token === "<<funfetti-auth-jwt2>>" || token === "<<aus-completion-token>>")) {
|
|
8992
9096
|
return false;
|
|
8993
9097
|
}
|
|
8994
9098
|
try {
|
|
8995
|
-
const decodedJwt =
|
|
8996
|
-
Buffer.from(token.split(".")[1], "base64").toString()
|
|
8997
|
-
);
|
|
9099
|
+
const decodedJwt = decodeJwtPayload(token);
|
|
8998
9100
|
const dateNow = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
8999
9101
|
return decodedJwt.exp <= dateNow;
|
|
9000
9102
|
} catch (e) {
|
|
@@ -9006,6 +9108,7 @@ var isJwtExpired = /* @__PURE__ */ __name((token) => {
|
|
|
9006
9108
|
|
|
9007
9109
|
// src/deploy/helpers/assets.ts
|
|
9008
9110
|
var BULK_UPLOAD_CONCURRENCY = 3;
|
|
9111
|
+
var EDGE_KV_UPLOAD_CONCURRENCY = 50;
|
|
9009
9112
|
var MAX_UPLOAD_ATTEMPTS = 5;
|
|
9010
9113
|
var MAX_UPLOAD_GATEWAY_ERRORS = 5;
|
|
9011
9114
|
var MAX_DIFF_LINES = 100;
|
|
@@ -9026,7 +9129,11 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
|
|
|
9026
9129
|
{ code: 1, telemetryMessage: "assets upload unexpected api response" }
|
|
9027
9130
|
);
|
|
9028
9131
|
}
|
|
9029
|
-
|
|
9132
|
+
const filesToUpload = initializeAssetsResponse.buckets.flat();
|
|
9133
|
+
const useSingleAssetUpload = isSingleAssetUploadMode(
|
|
9134
|
+
initializeAssetsResponse.jwt
|
|
9135
|
+
);
|
|
9136
|
+
if (filesToUpload.length === 0) {
|
|
9030
9137
|
if (!initializeAssetsResponse.jwt) {
|
|
9031
9138
|
throw new FatalError$1(
|
|
9032
9139
|
"Could not find assets information to attach to deployment. Please try again.",
|
|
@@ -9036,9 +9143,17 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
|
|
|
9036
9143
|
logger.info(
|
|
9037
9144
|
`No updated asset files to upload. Proceeding with deployment...`
|
|
9038
9145
|
);
|
|
9039
|
-
return
|
|
9146
|
+
return {
|
|
9147
|
+
jwt: initializeAssetsResponse.jwt,
|
|
9148
|
+
assetUploadStats: {
|
|
9149
|
+
assetUploadDurationMs: 0,
|
|
9150
|
+
assetUploadIsBulk: !useSingleAssetUpload,
|
|
9151
|
+
assetUploadFileCount: 0,
|
|
9152
|
+
assetUploadTotalBytes: 0
|
|
9153
|
+
}
|
|
9154
|
+
};
|
|
9040
9155
|
}
|
|
9041
|
-
const numberFilesToUpload =
|
|
9156
|
+
const numberFilesToUpload = filesToUpload.length;
|
|
9042
9157
|
logger.info(
|
|
9043
9158
|
`\u{1F300} Found ${numberFilesToUpload} new or modified static asset${numberFilesToUpload > 1 ? "s" : ""} to upload. Proceeding with upload...`
|
|
9044
9159
|
);
|
|
@@ -9062,50 +9177,81 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
|
|
|
9062
9177
|
return manifestEntry;
|
|
9063
9178
|
});
|
|
9064
9179
|
});
|
|
9065
|
-
const
|
|
9180
|
+
const uploadBuckets = useSingleAssetUpload ? assetBuckets.flat().map((entry) => [entry]) : assetBuckets;
|
|
9181
|
+
const concurrency = useSingleAssetUpload ? getEdgeKvUploadConcurrency(initializeAssetsResponse.jwt) : BULK_UPLOAD_CONCURRENCY;
|
|
9182
|
+
if (useSingleAssetUpload) {
|
|
9183
|
+
logger.debug(`Edge KV asset upload concurrency: ${concurrency}`);
|
|
9184
|
+
}
|
|
9185
|
+
const queue = new PQueue({ concurrency });
|
|
9066
9186
|
const queuePromises = [];
|
|
9067
|
-
let attempts = 0;
|
|
9068
9187
|
const start = Date.now();
|
|
9069
9188
|
let completionJwt = "";
|
|
9070
9189
|
let uploadedAssetsCount = 0;
|
|
9071
|
-
|
|
9072
|
-
|
|
9190
|
+
let uploadedBytes = 0;
|
|
9191
|
+
for (const [bucketIndex, bucket] of uploadBuckets.entries()) {
|
|
9192
|
+
let attempts = 0;
|
|
9073
9193
|
let gatewayErrors = 0;
|
|
9074
9194
|
const doUpload = /* @__PURE__ */ __name(async () => {
|
|
9075
|
-
const payload = new FormData();
|
|
9076
9195
|
const uploadedFiles = [];
|
|
9077
9196
|
for (const manifestEntry of bucket) {
|
|
9078
|
-
const absFilePath = path3.join(assetDirectory, manifestEntry[0]);
|
|
9079
9197
|
uploadedFiles.push(manifestEntry[0]);
|
|
9080
|
-
payload.append(
|
|
9081
|
-
manifestEntry[1].hash,
|
|
9082
|
-
new File(
|
|
9083
|
-
[(await readFile(absFilePath)).toString("base64")],
|
|
9084
|
-
manifestEntry[1].hash,
|
|
9085
|
-
{
|
|
9086
|
-
// Most formdata body encoders (incl. undici's) will override with "application/octet-stream" if you use a falsy value here
|
|
9087
|
-
// Additionally, it appears that undici doesn't support non-standard main types (e.g. "null")
|
|
9088
|
-
// So, to make it easier for any other clients, we'll just parse "application/null" on the API
|
|
9089
|
-
// to mean actually null (signal to not send a Content-Type header with the response)
|
|
9090
|
-
type: getContentType(absFilePath) ?? "application/null"
|
|
9091
|
-
}
|
|
9092
|
-
),
|
|
9093
|
-
manifestEntry[1].hash
|
|
9094
|
-
);
|
|
9095
9198
|
}
|
|
9096
9199
|
try {
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
}
|
|
9105
|
-
|
|
9200
|
+
let res;
|
|
9201
|
+
if (useSingleAssetUpload) {
|
|
9202
|
+
const manifestEntry = bucket[0];
|
|
9203
|
+
const absFilePath = path3.join(assetDirectory, manifestEntry[0]);
|
|
9204
|
+
const contentType = getContentType(absFilePath);
|
|
9205
|
+
res = await fetchResult(
|
|
9206
|
+
complianceConfig,
|
|
9207
|
+
`/accounts/${accountId}/workers/assets/upload/${manifestEntry[1].hash}`,
|
|
9208
|
+
{
|
|
9209
|
+
method: "POST",
|
|
9210
|
+
headers: {
|
|
9211
|
+
Authorization: `Bearer ${initializeAssetsResponse.jwt}`,
|
|
9212
|
+
"Content-Type": contentType ?? "application/null"
|
|
9213
|
+
},
|
|
9214
|
+
body: createReadStream(absFilePath),
|
|
9215
|
+
duplex: "half"
|
|
9216
|
+
}
|
|
9217
|
+
);
|
|
9218
|
+
} else {
|
|
9219
|
+
const payload = new FormData();
|
|
9220
|
+
for (const manifestEntry of bucket) {
|
|
9221
|
+
const absFilePath = path3.join(assetDirectory, manifestEntry[0]);
|
|
9222
|
+
payload.append(
|
|
9223
|
+
manifestEntry[1].hash,
|
|
9224
|
+
new File(
|
|
9225
|
+
[(await readFile(absFilePath)).toString("base64")],
|
|
9226
|
+
manifestEntry[1].hash,
|
|
9227
|
+
{
|
|
9228
|
+
// Most formdata body encoders (incl. undici's) will override with "application/octet-stream" if you use a falsy value here
|
|
9229
|
+
// Additionally, it appears that undici doesn't support non-standard main types (e.g. "null")
|
|
9230
|
+
// So, to make it easier for any other clients, we'll just parse "application/null" on the API
|
|
9231
|
+
// to mean actually null (signal to not send a Content-Type header with the response)
|
|
9232
|
+
type: getContentType(absFilePath) ?? "application/null"
|
|
9233
|
+
}
|
|
9234
|
+
),
|
|
9235
|
+
manifestEntry[1].hash
|
|
9236
|
+
);
|
|
9106
9237
|
}
|
|
9107
|
-
|
|
9238
|
+
res = await fetchResult(
|
|
9239
|
+
complianceConfig,
|
|
9240
|
+
`/accounts/${accountId}/workers/assets/upload?base64=true`,
|
|
9241
|
+
{
|
|
9242
|
+
method: "POST",
|
|
9243
|
+
headers: {
|
|
9244
|
+
Authorization: `Bearer ${initializeAssetsResponse.jwt}`
|
|
9245
|
+
},
|
|
9246
|
+
body: payload
|
|
9247
|
+
}
|
|
9248
|
+
);
|
|
9249
|
+
}
|
|
9108
9250
|
uploadedAssetsCount += bucket.length;
|
|
9251
|
+
uploadedBytes += bucket.reduce(
|
|
9252
|
+
(total, manifestEntry) => total + manifestEntry[1].size,
|
|
9253
|
+
0
|
|
9254
|
+
);
|
|
9109
9255
|
logAssetsUploadStatus(
|
|
9110
9256
|
numberFilesToUpload,
|
|
9111
9257
|
uploadedAssetsCount,
|
|
@@ -9140,7 +9286,7 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
|
|
|
9140
9286
|
} else if (isJwtExpired(initializeAssetsResponse.jwt)) {
|
|
9141
9287
|
throw new FatalError$1(
|
|
9142
9288
|
`Upload took too long.
|
|
9143
|
-
Asset upload took too long on bucket ${bucketIndex + 1}/${
|
|
9289
|
+
Asset upload took too long on bucket ${bucketIndex + 1}/${uploadBuckets.length}. Please try again.
|
|
9144
9290
|
Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`,
|
|
9145
9291
|
{ telemetryMessage: "Asset upload took too long" }
|
|
9146
9292
|
);
|
|
@@ -9175,8 +9321,33 @@ Assets already uploaded have been saved, so the next attempt will automatically
|
|
|
9175
9321
|
`\u2728 Success! Uploaded ${numberFilesToUpload} file${numberFilesToUpload > 1 ? "s" : ""} ${skippedMessage}${formatTime(uploadMs)}
|
|
9176
9322
|
`
|
|
9177
9323
|
);
|
|
9178
|
-
return
|
|
9324
|
+
return {
|
|
9325
|
+
jwt: completionJwt,
|
|
9326
|
+
assetUploadStats: {
|
|
9327
|
+
assetUploadDurationMs: uploadMs,
|
|
9328
|
+
assetUploadIsBulk: !useSingleAssetUpload,
|
|
9329
|
+
assetUploadFileCount: uploadedAssetsCount,
|
|
9330
|
+
assetUploadTotalBytes: uploadedBytes
|
|
9331
|
+
}
|
|
9332
|
+
};
|
|
9179
9333
|
}, "syncAssets");
|
|
9334
|
+
function isSingleAssetUploadMode(jwt) {
|
|
9335
|
+
try {
|
|
9336
|
+
return decodeJwtPayload(jwt).wrangler_single_asset_uploads === true;
|
|
9337
|
+
} catch {
|
|
9338
|
+
return false;
|
|
9339
|
+
}
|
|
9340
|
+
}
|
|
9341
|
+
__name(isSingleAssetUploadMode, "isSingleAssetUploadMode");
|
|
9342
|
+
function getEdgeKvUploadConcurrency(jwt) {
|
|
9343
|
+
try {
|
|
9344
|
+
const value = Number(decodeJwtPayload(jwt).edge_kv_upload_concurrency);
|
|
9345
|
+
return value > 0 ? Math.floor(value) : EDGE_KV_UPLOAD_CONCURRENCY;
|
|
9346
|
+
} catch {
|
|
9347
|
+
return EDGE_KV_UPLOAD_CONCURRENCY;
|
|
9348
|
+
}
|
|
9349
|
+
}
|
|
9350
|
+
__name(getEdgeKvUploadConcurrency, "getEdgeKvUploadConcurrency");
|
|
9180
9351
|
var buildAssetManifest = /* @__PURE__ */ __name(async (dir) => {
|
|
9181
9352
|
const files = await readdir(dir, { recursive: true });
|
|
9182
9353
|
logReadFilesFromDirectory(dir, files);
|
|
@@ -9927,6 +10098,7 @@ function createWorkerUploadForm(worker, bindings, options) {
|
|
|
9927
10098
|
main,
|
|
9928
10099
|
sourceMaps,
|
|
9929
10100
|
migrations,
|
|
10101
|
+
exports: configuredExports,
|
|
9930
10102
|
compatibility_date,
|
|
9931
10103
|
compatibility_flags,
|
|
9932
10104
|
keepVars,
|
|
@@ -10554,6 +10726,9 @@ function createWorkerUploadForm(worker, bindings, options) {
|
|
|
10554
10726
|
compatibility_flags
|
|
10555
10727
|
},
|
|
10556
10728
|
...migrations && { migrations },
|
|
10729
|
+
...configuredExports && Object.keys(configuredExports).length > 0 && {
|
|
10730
|
+
exports: configuredExports
|
|
10731
|
+
},
|
|
10557
10732
|
capnp_schema: capnpSchemaOutputFile,
|
|
10558
10733
|
...keep_bindings && { keep_bindings },
|
|
10559
10734
|
...logpush !== void 0 && { logpush },
|
|
@@ -10609,6 +10784,57 @@ function deployWfpUserWorker(dispatchNamespace, versionId) {
|
|
|
10609
10784
|
logger.log("Current Version ID:", versionId);
|
|
10610
10785
|
}
|
|
10611
10786
|
__name(deployWfpUserWorker, "deployWfpUserWorker");
|
|
10787
|
+
|
|
10788
|
+
// src/deploy/helpers/use-service-environments.ts
|
|
10789
|
+
function useServiceEnvironments(config) {
|
|
10790
|
+
return "legacy_env" in config ? !config.legacy_env : Boolean(config.legacy.useServiceEnvironments);
|
|
10791
|
+
}
|
|
10792
|
+
__name(useServiceEnvironments, "useServiceEnvironments");
|
|
10793
|
+
|
|
10794
|
+
// src/deploy/helpers/environments.ts
|
|
10795
|
+
function hasDefinedEnvironments(config) {
|
|
10796
|
+
return !useServiceEnvironments(config) && Boolean(config.definedEnvironments?.length);
|
|
10797
|
+
}
|
|
10798
|
+
__name(hasDefinedEnvironments, "hasDefinedEnvironments");
|
|
10799
|
+
function applyServiceAndEnvironmentTags(config, tags) {
|
|
10800
|
+
const env = config.targetEnvironment;
|
|
10801
|
+
const serviceName = config.topLevelName;
|
|
10802
|
+
const shouldApplyTags = hasDefinedEnvironments(config);
|
|
10803
|
+
if (shouldApplyTags && !serviceName) {
|
|
10804
|
+
logger.warn(
|
|
10805
|
+
"No top-level `name` has been defined in Wrangler configuration. Add a top-level `name` to group this Worker together with its sibling environments in the Cloudflare dashboard."
|
|
10806
|
+
);
|
|
10807
|
+
}
|
|
10808
|
+
const serviceTag = shouldApplyTags && serviceName ? `${SERVICE_TAG_PREFIX}${serviceName}` : null;
|
|
10809
|
+
const environmentTag = serviceTag && env ? `${ENVIRONMENT_TAG_PREFIX}${env}` : null;
|
|
10810
|
+
tags = tags.filter(
|
|
10811
|
+
(tag) => !tag.startsWith(SERVICE_TAG_PREFIX) && !tag.startsWith(ENVIRONMENT_TAG_PREFIX)
|
|
10812
|
+
);
|
|
10813
|
+
if (serviceTag) {
|
|
10814
|
+
tags.push(serviceTag);
|
|
10815
|
+
}
|
|
10816
|
+
if (environmentTag) {
|
|
10817
|
+
tags.push(environmentTag);
|
|
10818
|
+
}
|
|
10819
|
+
return tags;
|
|
10820
|
+
}
|
|
10821
|
+
__name(applyServiceAndEnvironmentTags, "applyServiceAndEnvironmentTags");
|
|
10822
|
+
function warnOnErrorUpdatingServiceAndEnvironmentTags() {
|
|
10823
|
+
logger.warn(
|
|
10824
|
+
"Could not apply service and environment tags. This Worker will not appear grouped together with its sibling environments in the Cloudflare dashboard."
|
|
10825
|
+
);
|
|
10826
|
+
}
|
|
10827
|
+
__name(warnOnErrorUpdatingServiceAndEnvironmentTags, "warnOnErrorUpdatingServiceAndEnvironmentTags");
|
|
10828
|
+
function tagsAreEqual(a, b) {
|
|
10829
|
+
return a.length === b.length && a.every((el, i) => b[i] === el);
|
|
10830
|
+
}
|
|
10831
|
+
__name(tagsAreEqual, "tagsAreEqual");
|
|
10832
|
+
|
|
10833
|
+
// src/deploy/helpers/error-codes.ts
|
|
10834
|
+
var INVALID_INHERIT_BINDING_CODE = 10057;
|
|
10835
|
+
var EXPORTS_RECONCILIATION_ERROR_CODE = 100402;
|
|
10836
|
+
var INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE = 100405;
|
|
10837
|
+
var ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE = 100406;
|
|
10612
10838
|
async function getMigrationsToUpload(scriptName, props) {
|
|
10613
10839
|
const { config, accountId } = props;
|
|
10614
10840
|
assert4(accountId, "Missing accountId");
|
|
@@ -10687,51 +10913,128 @@ var suppressNotFoundError = /* @__PURE__ */ __name((err) => {
|
|
|
10687
10913
|
throw err;
|
|
10688
10914
|
}
|
|
10689
10915
|
}, "suppressNotFoundError");
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10916
|
+
async function resolveDoLifecyclePayload(props) {
|
|
10917
|
+
const durableObjectExports = getDurableObjectExports(props.config.exports);
|
|
10918
|
+
const hasDurableObjectExports2 = Object.keys(durableObjectExports).length > 0;
|
|
10919
|
+
if (hasDurableObjectExports2) {
|
|
10920
|
+
return {
|
|
10921
|
+
migrations: void 0,
|
|
10922
|
+
exports: durableObjectExports
|
|
10923
|
+
};
|
|
10924
|
+
}
|
|
10925
|
+
const migrations = !props.isDryRun ? await getMigrationsToUpload(props.scriptName, {
|
|
10926
|
+
accountId: props.accountId,
|
|
10927
|
+
config: props.config,
|
|
10928
|
+
useServiceEnvironments: props.useServiceEnvironments,
|
|
10929
|
+
env: props.env,
|
|
10930
|
+
dispatchNamespace: props.dispatchNamespace
|
|
10931
|
+
}) : void 0;
|
|
10932
|
+
return {
|
|
10933
|
+
migrations,
|
|
10934
|
+
exports: void 0
|
|
10935
|
+
};
|
|
10694
10936
|
}
|
|
10695
|
-
__name(
|
|
10937
|
+
__name(resolveDoLifecyclePayload, "resolveDoLifecyclePayload");
|
|
10696
10938
|
|
|
10697
|
-
// src/deploy/helpers/
|
|
10698
|
-
function
|
|
10699
|
-
|
|
10939
|
+
// src/deploy/helpers/exports.ts
|
|
10940
|
+
async function resolveExportsUploadPayload(props) {
|
|
10941
|
+
const partitionedExports = partitionExports$1(props.config.exports);
|
|
10942
|
+
const { migrations, exports: durableObjectExports } = await resolveDoLifecyclePayload(props);
|
|
10943
|
+
const exports = {
|
|
10944
|
+
...partitionedExports.worker,
|
|
10945
|
+
...durableObjectExports ?? {}
|
|
10946
|
+
};
|
|
10947
|
+
return {
|
|
10948
|
+
migrations,
|
|
10949
|
+
exports: Object.keys(exports).length > 0 ? exports : void 0
|
|
10950
|
+
};
|
|
10700
10951
|
}
|
|
10701
|
-
__name(
|
|
10702
|
-
function
|
|
10703
|
-
const
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
if (shouldApplyTags && !serviceName) {
|
|
10707
|
-
logger.warn(
|
|
10708
|
-
"No top-level `name` has been defined in Wrangler configuration. Add a top-level `name` to group this Worker together with its sibling environments in the Cloudflare dashboard."
|
|
10709
|
-
);
|
|
10952
|
+
__name(resolveExportsUploadPayload, "resolveExportsUploadPayload");
|
|
10953
|
+
function renderExportsReconciliationSuccess(result) {
|
|
10954
|
+
const hasAnyContent = result.created.length > 0 || result.updated.length > 0 || result.deleted.length > 0 || result.renamed.length > 0 || result.transferred.length > 0 || result.transfer_pending.length > 0 || result.warnings.length > 0 || result.info.length > 0 || result.removable_entries.length > 0;
|
|
10955
|
+
if (!hasAnyContent) {
|
|
10956
|
+
return;
|
|
10710
10957
|
}
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
(
|
|
10715
|
-
);
|
|
10716
|
-
if (serviceTag) {
|
|
10717
|
-
tags.push(serviceTag);
|
|
10958
|
+
logger.log("");
|
|
10959
|
+
logger.log(bold("Durable Object exports reconciliation:"));
|
|
10960
|
+
if (result.created.length > 0) {
|
|
10961
|
+
logger.log(` Created: ${result.created.join(", ")}`);
|
|
10718
10962
|
}
|
|
10719
|
-
if (
|
|
10720
|
-
|
|
10963
|
+
if (result.updated.length > 0) {
|
|
10964
|
+
logger.log(` Updated: ${result.updated.join(", ")}`);
|
|
10721
10965
|
}
|
|
10722
|
-
|
|
10966
|
+
if (result.deleted.length > 0) {
|
|
10967
|
+
logger.log(` Deleted: ${result.deleted.join(", ")}`);
|
|
10968
|
+
}
|
|
10969
|
+
if (result.renamed.length > 0) {
|
|
10970
|
+
const renames = result.renamed.map((r) => `${r.from} \u2192 ${r.to}`).join(", ");
|
|
10971
|
+
logger.log(` Renamed: ${renames}`);
|
|
10972
|
+
}
|
|
10973
|
+
for (const t of result.transferred) {
|
|
10974
|
+
logger.log(` Transferred (${t.phase}): ${t.class} \u2192 ${t.to}`);
|
|
10975
|
+
}
|
|
10976
|
+
for (const t of result.transfer_pending) {
|
|
10977
|
+
logger.log(` Transfer pending: ${t.class} \u2190 ${t.from}`);
|
|
10978
|
+
}
|
|
10979
|
+
if (result.warnings.length > 0) {
|
|
10980
|
+
logger.log("");
|
|
10981
|
+
logger.warn(bold(" Warnings:"));
|
|
10982
|
+
for (const w of result.warnings) {
|
|
10983
|
+
logger.warn(yellow(` [${w.scenario}] ${w.class}: ${w.message}`));
|
|
10984
|
+
}
|
|
10985
|
+
}
|
|
10986
|
+
if (result.info.length > 0) {
|
|
10987
|
+
logger.log("");
|
|
10988
|
+
logger.log(dim(" Info:"));
|
|
10989
|
+
for (const info of result.info) {
|
|
10990
|
+
let line = dim(` [${info.scenario}] ${info.class}: ${info.message}`);
|
|
10991
|
+
if (info.referencing_scripts && info.referencing_scripts.length > 0) {
|
|
10992
|
+
line += dim(` (referenced by: ${info.referencing_scripts.join(", ")})`);
|
|
10993
|
+
}
|
|
10994
|
+
logger.log(line);
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
if (result.removable_entries.length > 0) {
|
|
10998
|
+
logger.log("");
|
|
10999
|
+
logger.log(
|
|
11000
|
+
dim(
|
|
11001
|
+
` Safe to remove from \`exports\`: ${result.removable_entries.join(", ")}`
|
|
11002
|
+
)
|
|
11003
|
+
);
|
|
11004
|
+
}
|
|
11005
|
+
logger.log("");
|
|
10723
11006
|
}
|
|
10724
|
-
__name(
|
|
10725
|
-
function
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
11007
|
+
__name(renderExportsReconciliationSuccess, "renderExportsReconciliationSuccess");
|
|
11008
|
+
function renderExportsReconciliationError(details) {
|
|
11009
|
+
const lines = ["Durable Object exports reconciliation failed:"];
|
|
11010
|
+
for (const detail of details) {
|
|
11011
|
+
lines.push(
|
|
11012
|
+
red(` \u2718 [${detail.scenario}] class '${detail.class}': ${detail.message}`)
|
|
11013
|
+
);
|
|
11014
|
+
if (detail.suggestion) {
|
|
11015
|
+
lines.push(` Suggestion: ${detail.suggestion}`);
|
|
11016
|
+
}
|
|
11017
|
+
if (detail.referencing_scripts && detail.referencing_scripts.length > 0) {
|
|
11018
|
+
lines.push(
|
|
11019
|
+
` Referencing scripts: ${detail.referencing_scripts.join(", ")}`
|
|
11020
|
+
);
|
|
11021
|
+
}
|
|
11022
|
+
}
|
|
11023
|
+
return lines.join("\n");
|
|
10729
11024
|
}
|
|
10730
|
-
__name(
|
|
10731
|
-
function
|
|
10732
|
-
|
|
11025
|
+
__name(renderExportsReconciliationError, "renderExportsReconciliationError");
|
|
11026
|
+
function isExportsReconciliationErrorDetails(value) {
|
|
11027
|
+
if (!Array.isArray(value)) {
|
|
11028
|
+
return false;
|
|
11029
|
+
}
|
|
11030
|
+
for (const entry of value) {
|
|
11031
|
+
if (typeof entry !== "object" || entry === null || typeof entry.class !== "string" || typeof entry.scenario !== "string" || typeof entry.message !== "string") {
|
|
11032
|
+
return false;
|
|
11033
|
+
}
|
|
11034
|
+
}
|
|
11035
|
+
return true;
|
|
10733
11036
|
}
|
|
10734
|
-
__name(
|
|
11037
|
+
__name(isExportsReconciliationErrorDetails, "isExportsReconciliationErrorDetails");
|
|
10735
11038
|
|
|
10736
11039
|
// ../../node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/esm/index.js
|
|
10737
11040
|
function dedent(templ) {
|
|
@@ -12694,11 +12997,6 @@ async function createAgentMemoryNamespace(complianceConfig, accountId, namespace
|
|
|
12694
12997
|
);
|
|
12695
12998
|
}
|
|
12696
12999
|
__name(createAgentMemoryNamespace, "createAgentMemoryNamespace");
|
|
12697
|
-
|
|
12698
|
-
// src/deploy/helpers/error-codes.ts
|
|
12699
|
-
var INVALID_INHERIT_BINDING_CODE = 10057;
|
|
12700
|
-
|
|
12701
|
-
// src/deploy/helpers/secrets-validation.ts
|
|
12702
13000
|
function addRequiredSecretsInheritBindings(config, bindings, options) {
|
|
12703
13001
|
if (!config.secrets?.required?.length) {
|
|
12704
13002
|
return;
|
|
@@ -14182,20 +14480,24 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14182
14480
|
content,
|
|
14183
14481
|
sourceMaps
|
|
14184
14482
|
} = buildResult;
|
|
14185
|
-
const migrations
|
|
14483
|
+
const { migrations, exports } = await resolveExportsUploadPayload({
|
|
14484
|
+
scriptName,
|
|
14485
|
+
isDryRun,
|
|
14186
14486
|
accountId,
|
|
14187
14487
|
config,
|
|
14188
14488
|
useServiceEnvironments: useServiceEnvironments(config),
|
|
14189
14489
|
env: props.env,
|
|
14190
14490
|
dispatchNamespace: props.dispatchNamespace
|
|
14191
|
-
})
|
|
14192
|
-
const
|
|
14491
|
+
});
|
|
14492
|
+
const assetsUploadResult = assetsOptions && !isDryRun ? await syncAssets(
|
|
14193
14493
|
config,
|
|
14194
14494
|
accountId,
|
|
14195
14495
|
assetsOptions.directory,
|
|
14196
14496
|
scriptName,
|
|
14197
14497
|
props.dispatchNamespace
|
|
14198
14498
|
) : void 0;
|
|
14499
|
+
const assetsJwt = assetsUploadResult?.jwt;
|
|
14500
|
+
const assetUploadStats = assetsUploadResult?.assetUploadStats;
|
|
14199
14501
|
if (assetsOptions && isDryRun) {
|
|
14200
14502
|
await buildAssetManifest(assetsOptions.directory);
|
|
14201
14503
|
}
|
|
@@ -14257,6 +14559,7 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14257
14559
|
name: scriptName,
|
|
14258
14560
|
main,
|
|
14259
14561
|
migrations,
|
|
14562
|
+
exports,
|
|
14260
14563
|
modules,
|
|
14261
14564
|
containers: config.containers,
|
|
14262
14565
|
sourceMaps,
|
|
@@ -14292,7 +14595,7 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14292
14595
|
{ name: path3__default.basename(resolvedEntryPointPath), content },
|
|
14293
14596
|
modules
|
|
14294
14597
|
);
|
|
14295
|
-
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && !useServiceEnvironments2 && format3 === "modules" && migrations === void 0 && !config.first_party_worker && config.containers === void 0;
|
|
14598
|
+
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && !useServiceEnvironments2 && format3 === "modules" && migrations === void 0 && !hasDurableObjectExports(config.exports) && !config.first_party_worker && config.containers === void 0;
|
|
14296
14599
|
let workerBundle;
|
|
14297
14600
|
const dockerPath = getDockerPath();
|
|
14298
14601
|
if (normalisedContainerConfig.length && props.containersRollout !== "none") {
|
|
@@ -14424,7 +14727,7 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14424
14727
|
startup_time_ms: versionResult.startup_time_ms
|
|
14425
14728
|
};
|
|
14426
14729
|
} else {
|
|
14427
|
-
|
|
14730
|
+
const uploadResult = await retryOnAPIFailure(
|
|
14428
14731
|
async () => fetchResult(
|
|
14429
14732
|
config,
|
|
14430
14733
|
workerUrl,
|
|
@@ -14442,6 +14745,12 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14442
14745
|
),
|
|
14443
14746
|
logger
|
|
14444
14747
|
);
|
|
14748
|
+
result = uploadResult;
|
|
14749
|
+
if (uploadResult.exports_reconciliation) {
|
|
14750
|
+
renderExportsReconciliationSuccess(
|
|
14751
|
+
uploadResult.exports_reconciliation
|
|
14752
|
+
);
|
|
14753
|
+
}
|
|
14445
14754
|
const nextTags = applyServiceAndEnvironmentTags(config, tags);
|
|
14446
14755
|
if (!tagsAreEqual(tags, nextTags)) {
|
|
14447
14756
|
try {
|
|
@@ -14497,6 +14806,13 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14497
14806
|
{ unsafeMetadata: config.unsafe?.metadata }
|
|
14498
14807
|
);
|
|
14499
14808
|
}
|
|
14809
|
+
if (err instanceof APIError && err.code === EXPORTS_RECONCILIATION_ERROR_CODE && isExportsReconciliationErrorDetails(err.meta?.details)) {
|
|
14810
|
+
err.preventReport();
|
|
14811
|
+
throw new UserError$1(
|
|
14812
|
+
renderExportsReconciliationError(err.meta.details),
|
|
14813
|
+
{ telemetryMessage: "deploy do exports reconciliation failed" }
|
|
14814
|
+
);
|
|
14815
|
+
}
|
|
14500
14816
|
const message = await helpIfErrorIsSizeOrScriptStartup(
|
|
14501
14817
|
err,
|
|
14502
14818
|
dependencies,
|
|
@@ -14560,7 +14876,7 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14560
14876
|
}
|
|
14561
14877
|
if (props.dispatchNamespace !== void 0) {
|
|
14562
14878
|
deployWfpUserWorker(props.dispatchNamespace, versionId);
|
|
14563
|
-
return { versionId, workerTag };
|
|
14879
|
+
return { versionId, workerTag, assetUploadStats };
|
|
14564
14880
|
}
|
|
14565
14881
|
assert4(accountId);
|
|
14566
14882
|
const targets = await triggersDeploy({
|
|
@@ -14578,10 +14894,23 @@ async function deploy(props, config, buildResult, callbacks) {
|
|
|
14578
14894
|
sourceMapSize,
|
|
14579
14895
|
versionId,
|
|
14580
14896
|
workerTag,
|
|
14897
|
+
assetUploadStats,
|
|
14581
14898
|
targets: targets ?? []
|
|
14582
14899
|
};
|
|
14583
14900
|
}
|
|
14584
14901
|
__name(deploy, "deploy");
|
|
14902
|
+
|
|
14903
|
+
// src/deploy/helpers/binding-depends-on-export.ts
|
|
14904
|
+
function renderBindingDependsOnExportError(serverMessage) {
|
|
14905
|
+
const trimmed = serverMessage.trim();
|
|
14906
|
+
if (trimmed.length > 0) {
|
|
14907
|
+
return trimmed;
|
|
14908
|
+
}
|
|
14909
|
+
return "A Durable Object binding references a class declared in `exports` but not yet provisioned. Declarative `exports` are reconciled when the version is deployed. Deploy this version to provision the class, or remove the binding and access the Durable Object via `ctx.exports.<ClassName>` until then.";
|
|
14910
|
+
}
|
|
14911
|
+
__name(renderBindingDependsOnExportError, "renderBindingDependsOnExportError");
|
|
14912
|
+
|
|
14913
|
+
// src/deploy/versions-upload.ts
|
|
14585
14914
|
async function versionsUpload(props, config, buildResult, callbacks) {
|
|
14586
14915
|
const { entry, compatibilityDate, compatibilityFlags, keepVars, accountId } = props;
|
|
14587
14916
|
const assetsOptions = resolveAssetOptions(props, config);
|
|
@@ -14613,14 +14942,17 @@ async function versionsUpload(props, config, buildResult, callbacks) {
|
|
|
14613
14942
|
hidden: true
|
|
14614
14943
|
};
|
|
14615
14944
|
}
|
|
14616
|
-
const migrations
|
|
14945
|
+
const { migrations, exports } = await resolveExportsUploadPayload({
|
|
14946
|
+
scriptName,
|
|
14947
|
+
isDryRun: props.dryRun,
|
|
14617
14948
|
accountId,
|
|
14618
14949
|
config,
|
|
14619
14950
|
useServiceEnvironments: useServiceEnvironments(config),
|
|
14620
14951
|
env: props.env,
|
|
14621
14952
|
dispatchNamespace: void 0
|
|
14622
|
-
})
|
|
14623
|
-
const
|
|
14953
|
+
});
|
|
14954
|
+
const assetsUploadResult = assetsOptions && !props.dryRun ? await syncAssets(config, accountId, assetsOptions.directory, scriptName) : void 0;
|
|
14955
|
+
const assetsJwt = assetsUploadResult?.jwt;
|
|
14624
14956
|
if (props.secretsFile) {
|
|
14625
14957
|
const secretsResult = await parseBulkInputToObject(props.secretsFile);
|
|
14626
14958
|
if (secretsResult) {
|
|
@@ -14646,6 +14978,7 @@ async function versionsUpload(props, config, buildResult, callbacks) {
|
|
|
14646
14978
|
const worker = {
|
|
14647
14979
|
main,
|
|
14648
14980
|
migrations,
|
|
14981
|
+
exports,
|
|
14649
14982
|
modules,
|
|
14650
14983
|
containers: config.containers,
|
|
14651
14984
|
sourceMaps,
|
|
@@ -14749,6 +15082,13 @@ async function versionsUpload(props, config, buildResult, callbacks) {
|
|
|
14749
15082
|
{ unsafeMetadata: config.unsafe?.metadata }
|
|
14750
15083
|
);
|
|
14751
15084
|
}
|
|
15085
|
+
if (err instanceof APIError && err.code === ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE) {
|
|
15086
|
+
err.preventReport();
|
|
15087
|
+
const serverMessage = err.notes[0]?.text.replace(` [code: ${ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE}]`, "").trim() ?? "";
|
|
15088
|
+
throw new UserError$1(renderBindingDependsOnExportError(serverMessage), {
|
|
15089
|
+
telemetryMessage: "versions upload binding depends on unprovisioned export"
|
|
15090
|
+
});
|
|
15091
|
+
}
|
|
14752
15092
|
const message = await helpIfErrorIsSizeOrScriptStartup(
|
|
14753
15093
|
err,
|
|
14754
15094
|
dependencies,
|
|
@@ -14834,7 +15174,13 @@ Changes to non-versioned settings (config properties 'logpush' or 'tail_consumer
|
|
|
14834
15174
|
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command ${cmdTriggersDeploy}
|
|
14835
15175
|
`)
|
|
14836
15176
|
);
|
|
14837
|
-
return {
|
|
15177
|
+
return {
|
|
15178
|
+
versionId,
|
|
15179
|
+
workerTag,
|
|
15180
|
+
assetUploadStats: assetsUploadResult?.assetUploadStats,
|
|
15181
|
+
versionPreviewUrl,
|
|
15182
|
+
versionPreviewAliasUrl
|
|
15183
|
+
};
|
|
14838
15184
|
}
|
|
14839
15185
|
__name(versionsUpload, "versionsUpload");
|
|
14840
15186
|
var MAX_DNS_LABEL_LENGTH = 63;
|
|
@@ -14924,6 +15270,23 @@ function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibili
|
|
|
14924
15270
|
return mode;
|
|
14925
15271
|
}
|
|
14926
15272
|
__name(validateNodeCompatMode, "validateNodeCompatMode");
|
|
15273
|
+
|
|
15274
|
+
// src/deploy/helpers/inconsistent-exports.ts
|
|
15275
|
+
function renderInconsistentExportsAcrossVersionsError(serverMessage) {
|
|
15276
|
+
return [
|
|
15277
|
+
serverMessage,
|
|
15278
|
+
"",
|
|
15279
|
+
"All versions in a percentage-split deployment must declare identical Durable Object `exports`. Cloudflare requires this so traffic on one branch can't route to code referencing unprovisioned or just-deleted DO namespaces.",
|
|
15280
|
+
"",
|
|
15281
|
+
"What to do:",
|
|
15282
|
+
" 1. Deploy the version that changes `exports` at 100% first:",
|
|
15283
|
+
" wrangler versions deploy <new-version-id>@100%",
|
|
15284
|
+
" 2. Once that deploy is stable, run your percentage-split deploy.",
|
|
15285
|
+
"",
|
|
15286
|
+
"Learn more: https://developers.cloudflare.com/workers/configuration/versions-and-deployments/gradual-deployments/#gradual-deployments-for-durable-objects"
|
|
15287
|
+
].join("\n");
|
|
15288
|
+
}
|
|
15289
|
+
__name(renderInconsistentExportsAcrossVersionsError, "renderInconsistentExportsAcrossVersionsError");
|
|
14927
15290
|
/*!
|
|
14928
15291
|
* Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.com)
|
|
14929
15292
|
*
|
|
@@ -14946,4 +15309,4 @@ __name(validateNodeCompatMode, "validateNodeCompatMode");
|
|
|
14946
15309
|
* THE SOFTWARE.
|
|
14947
15310
|
*/
|
|
14948
15311
|
|
|
14949
|
-
export { INVALID_INHERIT_BINDING_CODE, InputWorkerSchema, NoInputError, OutputWorkerSchema, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, convertToWranglerConfig, createDeployment, createTruncatedAlias, createWorkerUploadForm, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderRoute, resolveAssetOptions, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|
|
15312
|
+
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, InputWorkerSchema, NoInputError, OutputWorkerSchema, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, convertToWranglerConfig, createDeployment, createTruncatedAlias, createWorkerUploadForm, decodeJwtPayload, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|