@cloudflare/workers-utils 0.30.0 → 0.31.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/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { fetch, Headers, FormData, Response } from 'undici';
|
|
|
18
18
|
import { URLSearchParams } from 'node:url';
|
|
19
19
|
import * as timersPromises from 'node:timers/promises';
|
|
20
20
|
import { setTimeout as setTimeout$1 } from 'node:timers/promises';
|
|
21
|
+
import util from 'node:util';
|
|
21
22
|
import { assert as assert$1 } from 'node:console';
|
|
22
23
|
|
|
23
24
|
// ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json
|
|
@@ -1616,6 +1617,19 @@ var require_update_check = __commonJS({
|
|
|
1616
1617
|
}
|
|
1617
1618
|
});
|
|
1618
1619
|
|
|
1620
|
+
// src/config/environment.ts
|
|
1621
|
+
var ARTIFACTS_EVENT_TYPES = [
|
|
1622
|
+
"cf.artifacts.repo.created",
|
|
1623
|
+
"cf.artifacts.repo.deleted",
|
|
1624
|
+
"cf.artifacts.repo.forked",
|
|
1625
|
+
"cf.artifacts.repo.imported",
|
|
1626
|
+
"cf.artifacts.repo.pushed",
|
|
1627
|
+
"cf.artifacts.repo.cloned",
|
|
1628
|
+
"cf.artifacts.repo.fetched",
|
|
1629
|
+
"cf.artifacts.repo.token.created",
|
|
1630
|
+
"cf.artifacts.repo.token.revoked"
|
|
1631
|
+
];
|
|
1632
|
+
|
|
1619
1633
|
// src/config/durable-object-exports.ts
|
|
1620
1634
|
function getDurableObjectExports(exports) {
|
|
1621
1635
|
return partitionExports(exports)["durable-object"];
|
|
@@ -2337,7 +2351,7 @@ var NEVER = /* @__PURE__ */ Object.freeze({
|
|
|
2337
2351
|
});
|
|
2338
2352
|
// @__NO_SIDE_EFFECTS__
|
|
2339
2353
|
function $constructor(name, initializer3, params) {
|
|
2340
|
-
function
|
|
2354
|
+
function init2(inst, def) {
|
|
2341
2355
|
if (!inst._zod) {
|
|
2342
2356
|
Object.defineProperty(inst, "_zod", {
|
|
2343
2357
|
value: {
|
|
@@ -2362,7 +2376,7 @@ function $constructor(name, initializer3, params) {
|
|
|
2362
2376
|
}
|
|
2363
2377
|
}
|
|
2364
2378
|
}
|
|
2365
|
-
__name(
|
|
2379
|
+
__name(init2, "init");
|
|
2366
2380
|
const Parent = params?.Parent ?? Object;
|
|
2367
2381
|
class Definition extends Parent {
|
|
2368
2382
|
static {
|
|
@@ -2373,7 +2387,7 @@ function $constructor(name, initializer3, params) {
|
|
|
2373
2387
|
function _(def) {
|
|
2374
2388
|
var _a3;
|
|
2375
2389
|
const inst = params?.Parent ? new Definition() : this;
|
|
2376
|
-
|
|
2390
|
+
init2(inst, def);
|
|
2377
2391
|
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
2378
2392
|
for (const fn of inst._zod.deferred) {
|
|
2379
2393
|
fn();
|
|
@@ -2381,7 +2395,7 @@ function $constructor(name, initializer3, params) {
|
|
|
2381
2395
|
return inst;
|
|
2382
2396
|
}
|
|
2383
2397
|
__name(_, "_");
|
|
2384
|
-
Object.defineProperty(_, "init", { value:
|
|
2398
|
+
Object.defineProperty(_, "init", { value: init2 });
|
|
2385
2399
|
Object.defineProperty(_, Symbol.hasInstance, {
|
|
2386
2400
|
value: /* @__PURE__ */ __name((inst) => {
|
|
2387
2401
|
if (params?.Parent && inst instanceof params.Parent)
|
|
@@ -16995,7 +17009,7 @@ var getLocalExplorerEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
|
16995
17009
|
});
|
|
16996
17010
|
var getLocalObservabilityEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
16997
17011
|
variableName: "X_LOCAL_OBSERVABILITY",
|
|
16998
|
-
defaultValue:
|
|
17012
|
+
defaultValue: true
|
|
16999
17013
|
});
|
|
17000
17014
|
var getBrowserRenderingHeadfulFromEnv = getBooleanEnvironmentVariableFactory({
|
|
17001
17015
|
variableName: "X_BROWSER_HEADFUL",
|
|
@@ -18652,7 +18666,10 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
|
18652
18666
|
rawEnv,
|
|
18653
18667
|
envName,
|
|
18654
18668
|
"containers",
|
|
18655
|
-
|
|
18669
|
+
// `name` is inheritable, so a named environment that doesn't redeclare it
|
|
18670
|
+
// still runs under the top level Worker name — fall back to it so the
|
|
18671
|
+
// generated container name isn't built from `undefined`.
|
|
18672
|
+
validateContainerApp(envName, rawEnv.name ?? rawConfig?.name, configPath),
|
|
18656
18673
|
void 0
|
|
18657
18674
|
),
|
|
18658
18675
|
send_email: notInheritable(
|
|
@@ -19122,11 +19139,14 @@ var validateAndNormalizeRules = /* @__PURE__ */ __name((diagnostics, topLevelEnv
|
|
|
19122
19139
|
[]
|
|
19123
19140
|
);
|
|
19124
19141
|
}, "validateAndNormalizeRules");
|
|
19142
|
+
var ARTIFACTS_EVENT_TYPE_SET = new Set(
|
|
19143
|
+
ARTIFACTS_EVENT_TYPES
|
|
19144
|
+
);
|
|
19125
19145
|
var validateTriggers = /* @__PURE__ */ __name((diagnostics, triggersFieldName, triggersValue) => {
|
|
19126
19146
|
if (triggersValue === void 0 || triggersValue === null) {
|
|
19127
19147
|
return true;
|
|
19128
19148
|
}
|
|
19129
|
-
if (typeof triggersValue !== "object") {
|
|
19149
|
+
if (typeof triggersValue !== "object" || Array.isArray(triggersValue)) {
|
|
19130
19150
|
diagnostics.errors.push(
|
|
19131
19151
|
`Expected "${triggersFieldName}" to be of type object but got ${JSON.stringify(
|
|
19132
19152
|
triggersValue
|
|
@@ -19141,11 +19161,83 @@ var validateTriggers = /* @__PURE__ */ __name((diagnostics, triggersFieldName, t
|
|
|
19141
19161
|
);
|
|
19142
19162
|
isValid = false;
|
|
19143
19163
|
}
|
|
19164
|
+
if (hasProperty(triggersValue, "events") && !Array.isArray(triggersValue.events)) {
|
|
19165
|
+
diagnostics.errors.push(
|
|
19166
|
+
`Expected "${triggersFieldName}.events" to be of type array, but got ${JSON.stringify(triggersValue)}.`
|
|
19167
|
+
);
|
|
19168
|
+
isValid = false;
|
|
19169
|
+
} else if (hasProperty(triggersValue, "events") && Array.isArray(triggersValue.events)) {
|
|
19170
|
+
for (const [eventIndex, event] of triggersValue.events.entries()) {
|
|
19171
|
+
const eventFieldName = `${triggersFieldName}.events[${eventIndex}]`;
|
|
19172
|
+
if (typeof event !== "object" || event === null || Array.isArray(event)) {
|
|
19173
|
+
diagnostics.errors.push(
|
|
19174
|
+
`Expected "${eventFieldName}" to be of type object, but got ${JSON.stringify(event)}.`
|
|
19175
|
+
);
|
|
19176
|
+
isValid = false;
|
|
19177
|
+
continue;
|
|
19178
|
+
}
|
|
19179
|
+
if (!isRequiredProperty(event, "type", "string") || !ARTIFACTS_EVENT_TYPE_SET.has(event.type)) {
|
|
19180
|
+
diagnostics.errors.push(
|
|
19181
|
+
`Expected "${eventFieldName}.type" to be a supported Artifacts event type, but got ${JSON.stringify(event.type)}.`
|
|
19182
|
+
);
|
|
19183
|
+
isValid = false;
|
|
19184
|
+
}
|
|
19185
|
+
if (hasProperty(event, "filter") && event.filter !== void 0) {
|
|
19186
|
+
if (typeof event.filter !== "object" || event.filter === null || Array.isArray(event.filter)) {
|
|
19187
|
+
diagnostics.errors.push(
|
|
19188
|
+
`Expected "${eventFieldName}.filter" to be of type object, but got ${JSON.stringify(event.filter)}.`
|
|
19189
|
+
);
|
|
19190
|
+
isValid = false;
|
|
19191
|
+
} else {
|
|
19192
|
+
for (const [filterName, filterValue] of Object.entries(
|
|
19193
|
+
event.filter
|
|
19194
|
+
)) {
|
|
19195
|
+
if (filterName !== "namespace" && filterName !== "repo_name" || typeof filterValue !== "string") {
|
|
19196
|
+
diagnostics.errors.push(
|
|
19197
|
+
`Expected "${eventFieldName}.filter" to contain only string "namespace" and "repo_name" fields, but got ${JSON.stringify(event.filter)}.`
|
|
19198
|
+
);
|
|
19199
|
+
isValid = false;
|
|
19200
|
+
break;
|
|
19201
|
+
}
|
|
19202
|
+
}
|
|
19203
|
+
}
|
|
19204
|
+
}
|
|
19205
|
+
if (!Array.isArray(event.targets) || event.targets.length === 0) {
|
|
19206
|
+
diagnostics.errors.push(
|
|
19207
|
+
`Expected "${eventFieldName}.targets" to be a non-empty array, but got ${JSON.stringify(event.targets)}.`
|
|
19208
|
+
);
|
|
19209
|
+
isValid = false;
|
|
19210
|
+
} else {
|
|
19211
|
+
for (const [targetIndex, target] of event.targets.entries()) {
|
|
19212
|
+
const targetFieldName = `${eventFieldName}.targets[${targetIndex}]`;
|
|
19213
|
+
if (typeof target !== "object" || target === null || Array.isArray(target) || target.type !== "workflow" || typeof target.workflow_name !== "string" || target.workflow_name.length === 0) {
|
|
19214
|
+
diagnostics.errors.push(
|
|
19215
|
+
`Expected "${targetFieldName}" to be a workflow target with a non-empty "workflow_name", but got ${JSON.stringify(target)}.`
|
|
19216
|
+
);
|
|
19217
|
+
isValid = false;
|
|
19218
|
+
continue;
|
|
19219
|
+
}
|
|
19220
|
+
validateAdditionalProperties(
|
|
19221
|
+
diagnostics,
|
|
19222
|
+
targetFieldName,
|
|
19223
|
+
Object.keys(target),
|
|
19224
|
+
["type", "workflow_name"]
|
|
19225
|
+
);
|
|
19226
|
+
}
|
|
19227
|
+
}
|
|
19228
|
+
validateAdditionalProperties(
|
|
19229
|
+
diagnostics,
|
|
19230
|
+
eventFieldName,
|
|
19231
|
+
Object.keys(event),
|
|
19232
|
+
["type", "filter", "targets"]
|
|
19233
|
+
);
|
|
19234
|
+
}
|
|
19235
|
+
}
|
|
19144
19236
|
isValid = validateAdditionalProperties(
|
|
19145
19237
|
diagnostics,
|
|
19146
19238
|
triggersFieldName,
|
|
19147
19239
|
Object.keys(triggersValue),
|
|
19148
|
-
["crons"]
|
|
19240
|
+
["crons", "events"]
|
|
19149
19241
|
) && isValid;
|
|
19150
19242
|
return isValid;
|
|
19151
19243
|
}, "validateTriggers");
|
|
@@ -24035,14 +24127,14 @@ function logHeaders(headers, logger) {
|
|
|
24035
24127
|
);
|
|
24036
24128
|
}
|
|
24037
24129
|
__name(logHeaders, "logHeaders");
|
|
24038
|
-
async function performApiFetchBase(complianceConfig, resource,
|
|
24130
|
+
async function performApiFetchBase(complianceConfig, resource, init2 = {}, userAgent, logger, queryParams, abortSignal, credentials) {
|
|
24039
24131
|
assert2(credentials, "credentials are required for performApiFetch");
|
|
24040
|
-
const method =
|
|
24132
|
+
const method = init2.method ?? "GET";
|
|
24041
24133
|
assert2(
|
|
24042
24134
|
resource.startsWith("/"),
|
|
24043
24135
|
`CF API fetch - resource path must start with a "/" but got "${resource}"`
|
|
24044
24136
|
);
|
|
24045
|
-
const headers = cloneHeaders(new Headers(
|
|
24137
|
+
const headers = cloneHeaders(new Headers(init2.headers));
|
|
24046
24138
|
addAuthorizationHeader(headers, credentials);
|
|
24047
24139
|
headers.set("User-Agent", userAgent);
|
|
24048
24140
|
maybeAddTraceHeader(headers);
|
|
@@ -24052,11 +24144,11 @@ async function performApiFetchBase(complianceConfig, resource, init = {}, userAg
|
|
|
24052
24144
|
);
|
|
24053
24145
|
logger.debugWithSanitization?.("QUERY STRING:", queryString);
|
|
24054
24146
|
logHeaders(headers, logger);
|
|
24055
|
-
logger.debugWithSanitization?.("INIT:", JSON.stringify({ ...
|
|
24056
|
-
if (
|
|
24147
|
+
logger.debugWithSanitization?.("INIT:", JSON.stringify({ ...init2 }, null, 2));
|
|
24148
|
+
if (init2.body instanceof FormData) {
|
|
24057
24149
|
logger.debugWithSanitization?.(
|
|
24058
24150
|
"BODY:",
|
|
24059
|
-
await new Response(
|
|
24151
|
+
await new Response(init2.body).text(),
|
|
24060
24152
|
null,
|
|
24061
24153
|
2
|
|
24062
24154
|
);
|
|
@@ -24066,19 +24158,19 @@ async function performApiFetchBase(complianceConfig, resource, init = {}, userAg
|
|
|
24066
24158
|
`${getCloudflareApiBaseUrl(complianceConfig)}${resource}${queryString}`,
|
|
24067
24159
|
{
|
|
24068
24160
|
method,
|
|
24069
|
-
...
|
|
24161
|
+
...init2,
|
|
24070
24162
|
headers,
|
|
24071
24163
|
signal: abortSignal
|
|
24072
24164
|
}
|
|
24073
24165
|
);
|
|
24074
24166
|
}
|
|
24075
24167
|
__name(performApiFetchBase, "performApiFetchBase");
|
|
24076
|
-
async function fetchInternalBase(complianceConfig, resource,
|
|
24077
|
-
const method =
|
|
24168
|
+
async function fetchInternalBase(complianceConfig, resource, init2 = {}, userAgent, logger, queryParams, abortSignal, credentials) {
|
|
24169
|
+
const method = init2.method ?? "GET";
|
|
24078
24170
|
const response = await performApiFetchBase(
|
|
24079
24171
|
complianceConfig,
|
|
24080
24172
|
resource,
|
|
24081
|
-
|
|
24173
|
+
init2,
|
|
24082
24174
|
userAgent,
|
|
24083
24175
|
logger,
|
|
24084
24176
|
queryParams,
|
|
@@ -24140,7 +24232,7 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
24140
24232
|
}
|
|
24141
24233
|
}
|
|
24142
24234
|
__name(fetchInternalBase, "fetchInternalBase");
|
|
24143
|
-
async function fetchResultBase(complianceConfig, resource,
|
|
24235
|
+
async function fetchResultBase(complianceConfig, resource, init2 = {}, userAgent, logger, queryParams, abortSignal, credentials) {
|
|
24144
24236
|
const {
|
|
24145
24237
|
response: json2,
|
|
24146
24238
|
status,
|
|
@@ -24148,7 +24240,7 @@ async function fetchResultBase(complianceConfig, resource, init = {}, userAgent,
|
|
|
24148
24240
|
} = await fetchInternalBase(
|
|
24149
24241
|
complianceConfig,
|
|
24150
24242
|
resource,
|
|
24151
|
-
|
|
24243
|
+
init2,
|
|
24152
24244
|
userAgent,
|
|
24153
24245
|
logger,
|
|
24154
24246
|
queryParams,
|
|
@@ -24162,7 +24254,7 @@ async function fetchResultBase(complianceConfig, resource, init = {}, userAgent,
|
|
|
24162
24254
|
}
|
|
24163
24255
|
}
|
|
24164
24256
|
__name(fetchResultBase, "fetchResultBase");
|
|
24165
|
-
async function fetchListResultBase(complianceConfig, resource,
|
|
24257
|
+
async function fetchListResultBase(complianceConfig, resource, init2 = {}, userAgent, logger, queryParams, credentials) {
|
|
24166
24258
|
const results = [];
|
|
24167
24259
|
let getMoreResults = true;
|
|
24168
24260
|
let cursor;
|
|
@@ -24178,7 +24270,7 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
|
|
|
24178
24270
|
} = await fetchInternalBase(
|
|
24179
24271
|
complianceConfig,
|
|
24180
24272
|
resource,
|
|
24181
|
-
|
|
24273
|
+
init2,
|
|
24182
24274
|
userAgent,
|
|
24183
24275
|
logger,
|
|
24184
24276
|
queryParams,
|
|
@@ -24664,6 +24756,266 @@ function getWorkerNameFromProject(projectPath) {
|
|
|
24664
24756
|
return getWorkerName(packageJsonName, projectPath);
|
|
24665
24757
|
}
|
|
24666
24758
|
__name(getWorkerNameFromProject, "getWorkerNameFromProject");
|
|
24759
|
+
|
|
24760
|
+
// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs
|
|
24761
|
+
var FORCE_COLOR;
|
|
24762
|
+
var NODE_DISABLE_COLORS;
|
|
24763
|
+
var NO_COLOR;
|
|
24764
|
+
var TERM;
|
|
24765
|
+
var isTTY = true;
|
|
24766
|
+
if (typeof process !== "undefined") {
|
|
24767
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
24768
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
24769
|
+
}
|
|
24770
|
+
var $ = {
|
|
24771
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
|
|
24772
|
+
};
|
|
24773
|
+
function init(x, y) {
|
|
24774
|
+
let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
|
|
24775
|
+
let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
|
|
24776
|
+
return function(txt) {
|
|
24777
|
+
if (!$.enabled || txt == null) return txt;
|
|
24778
|
+
return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
|
|
24779
|
+
};
|
|
24780
|
+
}
|
|
24781
|
+
__name(init, "init");
|
|
24782
|
+
var dim = init(2, 22);
|
|
24783
|
+
var red = init(31, 39);
|
|
24784
|
+
var green = init(32, 39);
|
|
24785
|
+
var yellow = init(33, 39);
|
|
24786
|
+
var blue = init(34, 39);
|
|
24787
|
+
var magenta = init(35, 39);
|
|
24788
|
+
var cyan = init(36, 39);
|
|
24789
|
+
|
|
24790
|
+
// src/zod-format.ts
|
|
24791
|
+
var originalEnabled = $.enabled;
|
|
24792
|
+
function _forceColour(enabled = originalEnabled) {
|
|
24793
|
+
$.enabled = enabled;
|
|
24794
|
+
}
|
|
24795
|
+
__name(_forceColour, "_forceColour");
|
|
24796
|
+
var kMessages = Symbol("kMessages");
|
|
24797
|
+
var kActual = Symbol("kActual");
|
|
24798
|
+
var kGroupId = Symbol("kGroupId");
|
|
24799
|
+
var groupColours = [
|
|
24800
|
+
yellow,
|
|
24801
|
+
/* (green) */
|
|
24802
|
+
cyan,
|
|
24803
|
+
blue,
|
|
24804
|
+
magenta,
|
|
24805
|
+
green
|
|
24806
|
+
];
|
|
24807
|
+
var GroupCountsMap = Map;
|
|
24808
|
+
function isAnnotation(value) {
|
|
24809
|
+
return typeof value === "object" && value !== null && kMessages in value && kActual in value;
|
|
24810
|
+
}
|
|
24811
|
+
__name(isAnnotation, "isAnnotation");
|
|
24812
|
+
function isRecord2(value) {
|
|
24813
|
+
return typeof value === "object" && value !== null;
|
|
24814
|
+
}
|
|
24815
|
+
__name(isRecord2, "isRecord");
|
|
24816
|
+
function arrayShallowEqual(a, b) {
|
|
24817
|
+
if (a.length !== b.length) {
|
|
24818
|
+
return false;
|
|
24819
|
+
}
|
|
24820
|
+
for (let i = 0; i < a.length; i++) {
|
|
24821
|
+
if (a[i] !== b[i]) {
|
|
24822
|
+
return false;
|
|
24823
|
+
}
|
|
24824
|
+
}
|
|
24825
|
+
return true;
|
|
24826
|
+
}
|
|
24827
|
+
__name(arrayShallowEqual, "arrayShallowEqual");
|
|
24828
|
+
function issueEqual(a, b) {
|
|
24829
|
+
return a.message === b.message && arrayShallowEqual(a.path, b.path);
|
|
24830
|
+
}
|
|
24831
|
+
__name(issueEqual, "issueEqual");
|
|
24832
|
+
function hasMultipleDistinctMessages(issues, atDepth) {
|
|
24833
|
+
let firstIssue;
|
|
24834
|
+
for (const issue2 of issues) {
|
|
24835
|
+
if (issue2.path.length < atDepth) {
|
|
24836
|
+
continue;
|
|
24837
|
+
}
|
|
24838
|
+
if (firstIssue === void 0) {
|
|
24839
|
+
firstIssue = issue2;
|
|
24840
|
+
} else if (!issueEqual(firstIssue, issue2)) {
|
|
24841
|
+
return true;
|
|
24842
|
+
}
|
|
24843
|
+
}
|
|
24844
|
+
return false;
|
|
24845
|
+
}
|
|
24846
|
+
__name(hasMultipleDistinctMessages, "hasMultipleDistinctMessages");
|
|
24847
|
+
function annotate(groupCounts, annotated, input, issue2, path6, groupId) {
|
|
24848
|
+
if (path6.length === 0) {
|
|
24849
|
+
if (issue2.code === "invalid_union") {
|
|
24850
|
+
const allBranchIssues = issue2.errors;
|
|
24851
|
+
const unionIssues = allBranchIssues.flat();
|
|
24852
|
+
if (unionIssues.length > 0) {
|
|
24853
|
+
const multipleDistinct = hasMultipleDistinctMessages(unionIssues, 1);
|
|
24854
|
+
let newGroupId;
|
|
24855
|
+
if (isRecord2(input) && multipleDistinct) {
|
|
24856
|
+
newGroupId = groupCounts.size;
|
|
24857
|
+
groupCounts.set(newGroupId, 0);
|
|
24858
|
+
}
|
|
24859
|
+
for (const branchIssues of allBranchIssues) {
|
|
24860
|
+
for (const unionIssue of branchIssues) {
|
|
24861
|
+
const unionPath = unionIssue.path;
|
|
24862
|
+
if (multipleDistinct && unionPath.length === 0) {
|
|
24863
|
+
continue;
|
|
24864
|
+
}
|
|
24865
|
+
annotated = annotate(
|
|
24866
|
+
groupCounts,
|
|
24867
|
+
annotated,
|
|
24868
|
+
input,
|
|
24869
|
+
unionIssue,
|
|
24870
|
+
unionPath,
|
|
24871
|
+
newGroupId
|
|
24872
|
+
);
|
|
24873
|
+
}
|
|
24874
|
+
}
|
|
24875
|
+
return annotated;
|
|
24876
|
+
}
|
|
24877
|
+
}
|
|
24878
|
+
const message = issue2.message;
|
|
24879
|
+
if (annotated !== void 0) {
|
|
24880
|
+
if (isAnnotation(annotated) && !annotated[kMessages].includes(message)) {
|
|
24881
|
+
annotated[kMessages].push(message);
|
|
24882
|
+
}
|
|
24883
|
+
return annotated;
|
|
24884
|
+
}
|
|
24885
|
+
if (groupId !== void 0) {
|
|
24886
|
+
const current = groupCounts.get(groupId);
|
|
24887
|
+
assert2(current !== void 0);
|
|
24888
|
+
groupCounts.set(groupId, current + 1);
|
|
24889
|
+
}
|
|
24890
|
+
return {
|
|
24891
|
+
[kMessages]: [message],
|
|
24892
|
+
[kActual]: input,
|
|
24893
|
+
[kGroupId]: groupId
|
|
24894
|
+
};
|
|
24895
|
+
}
|
|
24896
|
+
const [head, ...tail] = path6;
|
|
24897
|
+
assert2(isRecord2(input), "Expected object/array input for nested issue");
|
|
24898
|
+
if (annotated === void 0) {
|
|
24899
|
+
if (Array.isArray(input)) {
|
|
24900
|
+
annotated = new Array(input.length);
|
|
24901
|
+
} else {
|
|
24902
|
+
const entries = Object.keys(input).map((key) => [key, void 0]);
|
|
24903
|
+
annotated = Object.fromEntries(entries);
|
|
24904
|
+
}
|
|
24905
|
+
}
|
|
24906
|
+
assert2(isRecord2(annotated), "Expected object/array for nested issue");
|
|
24907
|
+
annotated[head] = annotate(
|
|
24908
|
+
groupCounts,
|
|
24909
|
+
annotated[head],
|
|
24910
|
+
input[head],
|
|
24911
|
+
issue2,
|
|
24912
|
+
tail,
|
|
24913
|
+
groupId
|
|
24914
|
+
);
|
|
24915
|
+
return annotated;
|
|
24916
|
+
}
|
|
24917
|
+
__name(annotate, "annotate");
|
|
24918
|
+
function print(inspectOptions, groupCounts, annotated, indent = "", extras) {
|
|
24919
|
+
const prefix = extras?.prefix ?? "";
|
|
24920
|
+
const suffix = extras?.suffix ?? "";
|
|
24921
|
+
if (isAnnotation(annotated)) {
|
|
24922
|
+
const prefixIndent = indent + " ".repeat(prefix.length);
|
|
24923
|
+
const actual = util.inspect(annotated[kActual], inspectOptions);
|
|
24924
|
+
const actualIndented = actual.split("\n").map((line, i) => i > 0 ? prefixIndent + line : line).join("\n");
|
|
24925
|
+
let messageColour = red;
|
|
24926
|
+
let messagePrefix = prefixIndent + "^";
|
|
24927
|
+
let groupOr = "";
|
|
24928
|
+
if (annotated[kGroupId] !== void 0) {
|
|
24929
|
+
messageColour = groupColours[annotated[kGroupId] % groupColours.length];
|
|
24930
|
+
messagePrefix += annotated[kGroupId] + 1;
|
|
24931
|
+
const remaining = groupCounts.get(annotated[kGroupId]);
|
|
24932
|
+
assert2(remaining !== void 0);
|
|
24933
|
+
if (remaining > 1) {
|
|
24934
|
+
groupOr = " *or*";
|
|
24935
|
+
}
|
|
24936
|
+
groupCounts.set(annotated[kGroupId], remaining - 1);
|
|
24937
|
+
}
|
|
24938
|
+
messagePrefix += " ";
|
|
24939
|
+
const messageIndent = " ".repeat(messagePrefix.length);
|
|
24940
|
+
const messageIndented = annotated[kMessages].flatMap((m) => m.split("\n")).map((line, i) => i > 0 ? messageIndent + line : line).join("\n");
|
|
24941
|
+
const error51 = messageColour(`${messagePrefix}${messageIndented}${groupOr}`);
|
|
24942
|
+
return `${indent}${dim(prefix)}${actualIndented}${dim(suffix)}
|
|
24943
|
+
${error51}`;
|
|
24944
|
+
} else if (Array.isArray(annotated)) {
|
|
24945
|
+
let result = `${indent}${dim(`${prefix}[`)}
|
|
24946
|
+
`;
|
|
24947
|
+
const arrayIndent = indent + " ";
|
|
24948
|
+
for (let i = 0; i < annotated.length; i++) {
|
|
24949
|
+
const value = annotated[i];
|
|
24950
|
+
if (value === void 0 && (i === 0 || annotated[i - 1] !== void 0)) {
|
|
24951
|
+
result += `${arrayIndent}${dim("...,")}
|
|
24952
|
+
`;
|
|
24953
|
+
}
|
|
24954
|
+
if (value !== void 0) {
|
|
24955
|
+
result += print(inspectOptions, groupCounts, value, arrayIndent, {
|
|
24956
|
+
prefix: `/* [${i}] */ `,
|
|
24957
|
+
suffix: ","
|
|
24958
|
+
});
|
|
24959
|
+
result += "\n";
|
|
24960
|
+
}
|
|
24961
|
+
}
|
|
24962
|
+
result += `${indent}${dim(`]${suffix}`)}`;
|
|
24963
|
+
return result;
|
|
24964
|
+
} else if (isRecord2(annotated)) {
|
|
24965
|
+
let result = `${indent}${dim(`${prefix}{`)}
|
|
24966
|
+
`;
|
|
24967
|
+
const objectIndent = indent + " ";
|
|
24968
|
+
const entries = Object.entries(annotated);
|
|
24969
|
+
for (let i = 0; i < entries.length; i++) {
|
|
24970
|
+
const [key, value] = entries[i];
|
|
24971
|
+
if (value === void 0 && (i === 0 || entries[i - 1][1] !== void 0)) {
|
|
24972
|
+
result += `${objectIndent}${dim("...,")}
|
|
24973
|
+
`;
|
|
24974
|
+
}
|
|
24975
|
+
if (value !== void 0) {
|
|
24976
|
+
result += print(inspectOptions, groupCounts, value, objectIndent, {
|
|
24977
|
+
prefix: `${key}: `,
|
|
24978
|
+
suffix: ","
|
|
24979
|
+
});
|
|
24980
|
+
result += "\n";
|
|
24981
|
+
}
|
|
24982
|
+
}
|
|
24983
|
+
result += `${indent}${dim(`}${suffix}`)}`;
|
|
24984
|
+
return result;
|
|
24985
|
+
}
|
|
24986
|
+
return "";
|
|
24987
|
+
}
|
|
24988
|
+
__name(print, "print");
|
|
24989
|
+
function formatZodError(error51, input) {
|
|
24990
|
+
const sortedIssues = Array.from(error51.issues).sort((a, b) => {
|
|
24991
|
+
if (a.code !== b.code) {
|
|
24992
|
+
if (a.code === "invalid_union") {
|
|
24993
|
+
return -1;
|
|
24994
|
+
}
|
|
24995
|
+
if (b.code === "invalid_union") {
|
|
24996
|
+
return 1;
|
|
24997
|
+
}
|
|
24998
|
+
}
|
|
24999
|
+
return 0;
|
|
25000
|
+
});
|
|
25001
|
+
let annotated;
|
|
25002
|
+
const groupCounts = new GroupCountsMap();
|
|
25003
|
+
for (const issue2 of sortedIssues) {
|
|
25004
|
+
annotated = annotate(
|
|
25005
|
+
groupCounts,
|
|
25006
|
+
annotated,
|
|
25007
|
+
input,
|
|
25008
|
+
issue2,
|
|
25009
|
+
issue2.path
|
|
25010
|
+
);
|
|
25011
|
+
}
|
|
25012
|
+
const inspectOptions = {
|
|
25013
|
+
depth: 0,
|
|
25014
|
+
colors: $.enabled
|
|
25015
|
+
};
|
|
25016
|
+
return print(inspectOptions, groupCounts, annotated);
|
|
25017
|
+
}
|
|
25018
|
+
__name(formatZodError, "formatZodError");
|
|
24667
25019
|
function toUrlPath(filePath) {
|
|
24668
25020
|
assert$1(
|
|
24669
25021
|
!/^[a-z]:/i.test(filePath),
|
|
@@ -24709,4 +25061,4 @@ safe-buffer/index.js:
|
|
|
24709
25061
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
24710
25062
|
*/
|
|
24711
25063
|
|
|
24712
|
-
export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validatePagesConfig };
|
|
25064
|
+
export { ARTIFACTS_EVENT_TYPES, BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, _forceColour, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, formatZodError, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validatePagesConfig };
|