@backifydev/cli 0.4.5 → 0.4.6
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/README.md +1 -0
- package/dist/index.js +335 -222
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1966,6 +1966,7 @@ __export(release_flow_exports, {
|
|
|
1966
1966
|
ENVIRONMENT_FLOW: () => ENVIRONMENT_FLOW,
|
|
1967
1967
|
OPTIONAL_ENVIRONMENTS: () => OPTIONAL_ENVIRONMENTS,
|
|
1968
1968
|
activatedEnvironments: () => activatedEnvironments,
|
|
1969
|
+
entryBlockedText: () => entryBlockedText,
|
|
1969
1970
|
environmentsArguments: () => environmentsArguments,
|
|
1970
1971
|
environmentsHelp: () => environmentsHelp,
|
|
1971
1972
|
environmentsText: () => environmentsText,
|
|
@@ -1984,6 +1985,11 @@ __export(release_flow_exports, {
|
|
|
1984
1985
|
runEnvironments: () => runEnvironments,
|
|
1985
1986
|
splitDetail: () => splitDetail
|
|
1986
1987
|
});
|
|
1988
|
+
function entryBlockedText(flow) {
|
|
1989
|
+
const reasons2 = flow.entryBlockedBy ?? [];
|
|
1990
|
+
if (!reasons2.length) return void 0;
|
|
1991
|
+
return "Production is this application's only environment, and its deployment settings need a release to run in an earlier environment first (" + reasons2.join("; ").toLowerCase() + "). Add one with backify environments add <preview|prototype>, then ship again.";
|
|
1992
|
+
}
|
|
1987
1993
|
async function activatedEnvironments(call2, applicationId) {
|
|
1988
1994
|
try {
|
|
1989
1995
|
const view = await call2("/apps/" + applicationId + "/environments/options");
|
|
@@ -2008,7 +2014,7 @@ function parse(args2, command2, booleans, valued) {
|
|
|
2008
2014
|
return { flags, values, positional };
|
|
2009
2015
|
}
|
|
2010
2016
|
function moveArguments(flags, values, positional) {
|
|
2011
|
-
const
|
|
2017
|
+
const json3 = flags.has("--json"), yes = flags.has("--yes"), usage = "Use backify environments move <environment> --target <id> --window-start <ISO> --window-end <ISO> [--check] [--yes], or move status|start|abort|confirm <environment>.";
|
|
2012
2018
|
if (values["--confirm"]) throw new Error(usage);
|
|
2013
2019
|
const sub = positional[1]?.toLowerCase();
|
|
2014
2020
|
const moveAction = sub === "status" || sub === "start" || sub === "abort" || sub === "confirm" ? sub : "request";
|
|
@@ -2024,10 +2030,10 @@ function moveArguments(flags, values, positional) {
|
|
|
2024
2030
|
if (!target || !uuid3.test(target)) throw new Error("--target takes a deployment target ID.");
|
|
2025
2031
|
if (!start || !end || Number.isNaN(Date.parse(start)) || Number.isNaN(Date.parse(end))) throw new Error("--window-start and --window-end take ISO date-times, for example 2026-11-20T22:00:00Z.");
|
|
2026
2032
|
if (Date.parse(end) <= Date.parse(start)) throw new Error("--window-end must be after --window-start.");
|
|
2027
|
-
return { action: "move", moveAction, kind: kind2, target, windowStart: new Date(start).toISOString(), windowEnd: new Date(end).toISOString(), check: flags.has("--check"), yes, json:
|
|
2033
|
+
return { action: "move", moveAction, kind: kind2, target, windowStart: new Date(start).toISOString(), windowEnd: new Date(end).toISOString(), check: flags.has("--check"), yes, json: json3 };
|
|
2028
2034
|
}
|
|
2029
2035
|
if (moveAction === "confirm" && (!active || !uuid3.test(active))) throw new Error("--active takes the ID of the deployment target that is serving the environment.");
|
|
2030
|
-
return { action: "move", moveAction, kind: kind2, ...active ? { active } : {}, yes, json:
|
|
2036
|
+
return { action: "move", moveAction, kind: kind2, ...active ? { active } : {}, yes, json: json3 };
|
|
2031
2037
|
}
|
|
2032
2038
|
function moveBackArguments(flags, values, positional) {
|
|
2033
2039
|
const usage = "Use backify environments move-back <environment> --window-start <ISO> --window-end <ISO> --confirm <application-slug>.";
|
|
@@ -2056,22 +2062,22 @@ function environmentsArguments(args2) {
|
|
|
2056
2062
|
}
|
|
2057
2063
|
if (values["--window-start"] || values["--window-end"] || values["--active"]) throw new Error("--window-start, --window-end and --active apply to environments move.");
|
|
2058
2064
|
if (action === "placement") {
|
|
2059
|
-
const
|
|
2065
|
+
const json4 = flags.has("--json"), kind3 = positional[1]?.toLowerCase(), target = values["--target"]?.toLowerCase();
|
|
2060
2066
|
if (values["--confirm"] || positional.length > 2) throw new Error("Use backify environments placement [<environment> --target <deployment-target-id|default> [--check] [--yes]].");
|
|
2061
2067
|
if (!kind3) {
|
|
2062
2068
|
if (target || flags.has("--check") || flags.has("--yes")) throw new Error("Name the environment to place: backify environments placement <environment> --target <deployment-target-id|default>.");
|
|
2063
|
-
return { action, yes: false, json:
|
|
2069
|
+
return { action, yes: false, json: json4 };
|
|
2064
2070
|
}
|
|
2065
2071
|
if (!ENVIRONMENT_FLOW.includes(kind3)) throw new Error("Unknown environment: " + positional[1] + ". Use " + ENVIRONMENT_FLOW.join(", ") + ".");
|
|
2066
2072
|
if (!target || target !== "default" && !uuid3.test(target)) throw new Error("--target takes a deployment target ID, or default for the application's own target.");
|
|
2067
|
-
return { action, kind: kind3, target, check: flags.has("--check"), yes: flags.has("--yes"), json:
|
|
2073
|
+
return { action, kind: kind3, target, check: flags.has("--check"), yes: flags.has("--yes"), json: json4 };
|
|
2068
2074
|
}
|
|
2069
2075
|
if (flags.has("--check") || values["--target"]) throw new Error("--target and --check apply to environments placement.");
|
|
2070
2076
|
if (action !== "list" && action !== "add" && action !== "remove") throw new Error("Unknown environments command: " + action + "\n\n" + environmentsHelp);
|
|
2071
|
-
const
|
|
2077
|
+
const json3 = flags.has("--json");
|
|
2072
2078
|
if (action === "list") {
|
|
2073
2079
|
if (positional.length > 1 || flags.has("--yes") || values["--confirm"]) throw new Error("backify environments takes only --app and --json.\n\n" + environmentsHelp);
|
|
2074
|
-
return { action, yes: false, json:
|
|
2080
|
+
return { action, yes: false, json: json3 };
|
|
2075
2081
|
}
|
|
2076
2082
|
const kind2 = positional[1]?.toLowerCase();
|
|
2077
2083
|
if (positional.length !== 2 || !kind2) throw new Error(`Use backify environments ${action} <preview|prototype>.`);
|
|
@@ -2079,7 +2085,7 @@ function environmentsArguments(args2) {
|
|
|
2079
2085
|
if (!OPTIONAL_ENVIRONMENTS.includes(kind2)) throw new Error(`Unknown environment: ${positional[1]}. Use backify environments ${action} <preview|prototype>.`);
|
|
2080
2086
|
if (action === "add" && values["--confirm"]) throw new Error("--confirm applies to environments remove. Use --yes to add without the prompt.");
|
|
2081
2087
|
if (action === "remove" && flags.has("--yes")) throw new Error("Removing an environment is confirmed with --confirm <application-slug>, not --yes.");
|
|
2082
|
-
return { action, kind: kind2, confirm: values["--confirm"], yes: flags.has("--yes"), json:
|
|
2088
|
+
return { action, kind: kind2, confirm: values["--confirm"], yes: flags.has("--yes"), json: json3 };
|
|
2083
2089
|
}
|
|
2084
2090
|
function pad(rows) {
|
|
2085
2091
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -2295,6 +2301,8 @@ function releaseFlowText(flow) {
|
|
|
2295
2301
|
}
|
|
2296
2302
|
if (stage.promotion) lines.push(" " + promotionText(stage, stage.promotion));
|
|
2297
2303
|
}
|
|
2304
|
+
const blocked = entryBlockedText(flow);
|
|
2305
|
+
if (blocked) lines.push("", "Blocked: " + blocked);
|
|
2298
2306
|
return lines.join("\n");
|
|
2299
2307
|
}
|
|
2300
2308
|
function gateRows(flow) {
|
|
@@ -2323,7 +2331,7 @@ async function promote(call2, applicationId, options, context2 = {}) {
|
|
|
2323
2331
|
status: blocked ? "blocked" : waiting.length ? "not-ready" : "nothing-to-promote",
|
|
2324
2332
|
stages: waiting.map((item) => ({ environment: item.kind, target: item.promotion.target, state: item.promotion.state, blockedBy: item.promotion.blockedBy, release: item.deployment ? shortCommit(item.deployment) : null }))
|
|
2325
2333
|
};
|
|
2326
|
-
const text2 = waiting.length ? ["No release is ready to promote. Nothing was sent.", ...waiting.map((item) => `${item.name}: ${promotionText(item, item.promotion)}`), "Run backify release-flow for every check."].join("\n") : flow.stages.length < 2 ? "Production is this application's only environment; there is nothing to promote. Add one with backify environments add <preview|prototype>." : "Every release is already promoted. Nothing was sent.";
|
|
2334
|
+
const text2 = waiting.length ? ["No release is ready to promote. Nothing was sent.", ...waiting.map((item) => `${item.name}: ${promotionText(item, item.promotion)}`), "Run backify release-flow for every check."].join("\n") : flow.stages.length < 2 ? entryBlockedText(flow) ?? "Production is this application's only environment; there is nothing to promote. Add one with backify environments add <preview|prototype>." : "Every release is already promoted. Nothing was sent.";
|
|
2327
2335
|
return { value, text: text2, exitCode: waiting.length ? 2 : 0 };
|
|
2328
2336
|
}
|
|
2329
2337
|
const promotion = stage.promotion, release2 = stage.deployment;
|
|
@@ -2512,7 +2520,7 @@ var init_package = __esm({
|
|
|
2512
2520
|
"package.json"() {
|
|
2513
2521
|
package_default = {
|
|
2514
2522
|
name: "@backifydev/cli",
|
|
2515
|
-
version: "0.4.
|
|
2523
|
+
version: "0.4.6",
|
|
2516
2524
|
description: "Command-line setup and diagnostics for Backify applications",
|
|
2517
2525
|
type: "module",
|
|
2518
2526
|
bin: {
|
|
@@ -3105,6 +3113,8 @@ async function ship(call2, appId, options = {}) {
|
|
|
3105
3113
|
const entry = planned.stages?.[0];
|
|
3106
3114
|
if (!entry) throw new Error("The application has no environment to deploy to. Run backify environments.");
|
|
3107
3115
|
const kinds = planned.stages.map((stage) => stage.kind);
|
|
3116
|
+
const blocked = entryBlockedText(planned);
|
|
3117
|
+
if (blocked) throw new CommandError(blocked + " Nothing was pushed.", "preview_required", { flow: kinds, entryBlockedBy: planned.entryBlockedBy });
|
|
3108
3118
|
if (options.dryRun) {
|
|
3109
3119
|
const current = entry.deployment, checks = localReport(false, root), staging = planned.stages.at(-2);
|
|
3110
3120
|
const production = entry.kind === "production" ? "this release deploys straight to production, the application's only environment" : !options.productionDeploy || options.previewOnly ? `not requested; the healthy ${entry.kind} release is the result` : planned.policy.requirePreviewTesting ? `requested; the release must be marked tested in ${staging.kind} before promotion to production` : planned.policy.requireProductionApproval ? "requested; promotion waits for production approval" : "requested; the healthy release for this commit is promoted " + kinds.join(" -> ");
|
|
@@ -3211,6 +3221,7 @@ var init_development = __esm({
|
|
|
3211
3221
|
init_setup();
|
|
3212
3222
|
init_cli_session();
|
|
3213
3223
|
init_container_build();
|
|
3224
|
+
init_release_flow();
|
|
3214
3225
|
CliAuthenticationRequired = class extends Error {
|
|
3215
3226
|
code = "authentication_required";
|
|
3216
3227
|
constructor() {
|
|
@@ -7929,13 +7940,13 @@ function initializeContext(params) {
|
|
|
7929
7940
|
external: params?.external ?? void 0
|
|
7930
7941
|
};
|
|
7931
7942
|
}
|
|
7932
|
-
function handleUnrepresentable(schema, ctx,
|
|
7943
|
+
function handleUnrepresentable(schema, ctx, json3, params, message) {
|
|
7933
7944
|
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
7934
7945
|
if (result === "any")
|
|
7935
7946
|
return false;
|
|
7936
7947
|
if (result === void 0 || result === "throw")
|
|
7937
7948
|
throw new Error(message);
|
|
7938
|
-
Object.assign(
|
|
7949
|
+
Object.assign(json3, result);
|
|
7939
7950
|
return true;
|
|
7940
7951
|
}
|
|
7941
7952
|
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
@@ -8169,12 +8180,12 @@ function foldObjects(members2) {
|
|
|
8169
8180
|
}
|
|
8170
8181
|
return folded;
|
|
8171
8182
|
}
|
|
8172
|
-
function foldIntersection(
|
|
8173
|
-
const allOf =
|
|
8183
|
+
function foldIntersection(json3) {
|
|
8184
|
+
const allOf = json3.allOf;
|
|
8174
8185
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
8175
8186
|
return;
|
|
8176
8187
|
for (const key of FOLDABLE_KEYS)
|
|
8177
|
-
if (key in
|
|
8188
|
+
if (key in json3)
|
|
8178
8189
|
return;
|
|
8179
8190
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
8180
8191
|
let folded = null;
|
|
@@ -8193,8 +8204,8 @@ function foldIntersection(json2) {
|
|
|
8193
8204
|
}
|
|
8194
8205
|
if (!folded)
|
|
8195
8206
|
return;
|
|
8196
|
-
delete
|
|
8197
|
-
assignProps(
|
|
8207
|
+
delete json3.allOf;
|
|
8208
|
+
assignProps(json3, folded);
|
|
8198
8209
|
}
|
|
8199
8210
|
function finalize(ctx, schema) {
|
|
8200
8211
|
const root = ctx.seen.get(schema);
|
|
@@ -8276,20 +8287,20 @@ function finalize(ctx, schema) {
|
|
|
8276
8287
|
if (ctx.intersections.length) {
|
|
8277
8288
|
const carriers = /* @__PURE__ */ new Map();
|
|
8278
8289
|
for (const seen of ctx.seen.values()) {
|
|
8279
|
-
for (const
|
|
8280
|
-
const allOf =
|
|
8290
|
+
for (const json3 of [seen.schema, seen.def]) {
|
|
8291
|
+
const allOf = json3?.allOf;
|
|
8281
8292
|
if (!Array.isArray(allOf))
|
|
8282
8293
|
continue;
|
|
8283
8294
|
const existing = carriers.get(allOf);
|
|
8284
8295
|
if (existing)
|
|
8285
|
-
existing.push(
|
|
8296
|
+
existing.push(json3);
|
|
8286
8297
|
else
|
|
8287
|
-
carriers.set(allOf, [
|
|
8298
|
+
carriers.set(allOf, [json3]);
|
|
8288
8299
|
}
|
|
8289
8300
|
}
|
|
8290
8301
|
for (const allOf of ctx.intersections) {
|
|
8291
|
-
for (const
|
|
8292
|
-
foldIntersection(
|
|
8302
|
+
for (const json3 of carriers.get(allOf) ?? [])
|
|
8303
|
+
foldIntersection(json3);
|
|
8293
8304
|
}
|
|
8294
8305
|
}
|
|
8295
8306
|
}
|
|
@@ -8469,31 +8480,31 @@ function inputOptin(schema) {
|
|
|
8469
8480
|
}
|
|
8470
8481
|
return schema._zod.optin;
|
|
8471
8482
|
}
|
|
8472
|
-
function stringifyKeyNames(bySchema,
|
|
8473
|
-
if (
|
|
8474
|
-
if (visited.has(
|
|
8475
|
-
return
|
|
8476
|
-
visited.add(
|
|
8477
|
-
const def = bySchema.get(
|
|
8483
|
+
function stringifyKeyNames(bySchema, json3, visited) {
|
|
8484
|
+
if (json3.$ref) {
|
|
8485
|
+
if (visited.has(json3))
|
|
8486
|
+
return json3;
|
|
8487
|
+
visited.add(json3);
|
|
8488
|
+
const def = bySchema.get(json3)?.def;
|
|
8478
8489
|
if (!def)
|
|
8479
|
-
return
|
|
8490
|
+
return json3;
|
|
8480
8491
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
8481
|
-
return inlined === def ?
|
|
8492
|
+
return inlined === def ? json3 : inlined;
|
|
8482
8493
|
}
|
|
8483
8494
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
8484
|
-
const branches =
|
|
8495
|
+
const branches = json3[keyword];
|
|
8485
8496
|
if (!Array.isArray(branches))
|
|
8486
8497
|
continue;
|
|
8487
8498
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
8488
8499
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
8489
|
-
|
|
8500
|
+
json3 = { ...json3, [keyword]: mapped };
|
|
8490
8501
|
}
|
|
8491
|
-
const types2 = Array.isArray(
|
|
8502
|
+
const types2 = Array.isArray(json3.type) ? json3.type : [json3.type];
|
|
8492
8503
|
const numericType = !types2.includes("string") && types2.some((t) => t === "number" || t === "integer");
|
|
8493
|
-
const values =
|
|
8504
|
+
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
8494
8505
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
8495
|
-
return
|
|
8496
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
8506
|
+
return json3;
|
|
8507
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json3;
|
|
8497
8508
|
if (rest.enum)
|
|
8498
8509
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
8499
8510
|
else if (typeof rest.const === "number")
|
|
@@ -8531,7 +8542,7 @@ function rewriteKeyNames(ctx) {
|
|
|
8531
8542
|
}
|
|
8532
8543
|
}
|
|
8533
8544
|
}
|
|
8534
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
8545
|
+
function serializeDefaultValue(value, schema, ctx, json3, params) {
|
|
8535
8546
|
let unrepresentable = false;
|
|
8536
8547
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
8537
8548
|
if (typeof val !== "bigint")
|
|
@@ -8541,7 +8552,7 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
|
|
|
8541
8552
|
});
|
|
8542
8553
|
if (!unrepresentable)
|
|
8543
8554
|
return JSON.parse(serialized);
|
|
8544
|
-
handleUnrepresentable(schema, ctx,
|
|
8555
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
8545
8556
|
return UNREPRESENTABLE_DEFAULT;
|
|
8546
8557
|
}
|
|
8547
8558
|
var narrowMin, narrowMax, narrowBoth, addDivisor, addPattern, intersectMime, setFormat, minContributor, maxContributor, formatContributor, contributors, formatMap, exactPatterns, exactPattern, stringProcessor, numberProcessor, booleanProcessor, bigintProcessor, nullProcessor, neverProcessor, anyProcessor, unknownProcessor, dateProcessor, enumProcessor, literalProcessor, customProcessor, transformProcessor, arrayProcessor, objectProcessor, unionProcessor, intersectionProcessor, pendingRecords, recordProcessor, nullableProcessor, nonoptionalProcessor, UNREPRESENTABLE_DEFAULT, defaultProcessor, prefaultProcessor, catchProcessor, pipeProcessor, readonlyProcessor, optionalProcessor;
|
|
@@ -8625,29 +8636,29 @@ var init_json_schema_processors = __esm({
|
|
|
8625
8636
|
]);
|
|
8626
8637
|
exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
8627
8638
|
stringProcessor = (schema, ctx, _json, _params) => {
|
|
8628
|
-
const
|
|
8629
|
-
|
|
8639
|
+
const json3 = _json;
|
|
8640
|
+
json3.type = "string";
|
|
8630
8641
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
8631
8642
|
if (typeof minimum === "number")
|
|
8632
|
-
|
|
8643
|
+
json3.minLength = minimum;
|
|
8633
8644
|
if (typeof maximum === "number")
|
|
8634
|
-
|
|
8645
|
+
json3.maxLength = maximum;
|
|
8635
8646
|
if (format) {
|
|
8636
|
-
|
|
8637
|
-
if (
|
|
8638
|
-
delete
|
|
8647
|
+
json3.format = formatMap[format] ?? format;
|
|
8648
|
+
if (json3.format === "")
|
|
8649
|
+
delete json3.format;
|
|
8639
8650
|
if (format === "time" || laxFormat) {
|
|
8640
|
-
delete
|
|
8651
|
+
delete json3.format;
|
|
8641
8652
|
}
|
|
8642
8653
|
}
|
|
8643
8654
|
if (contentEncoding)
|
|
8644
|
-
|
|
8655
|
+
json3.contentEncoding = contentEncoding;
|
|
8645
8656
|
if (patterns && patterns.size > 0) {
|
|
8646
8657
|
const patternList = [...patterns].map(exactPattern);
|
|
8647
8658
|
if (patternList.length === 1)
|
|
8648
|
-
|
|
8659
|
+
json3.pattern = patternList[0].source;
|
|
8649
8660
|
else if (patternList.length > 1) {
|
|
8650
|
-
|
|
8661
|
+
json3.allOf = [
|
|
8651
8662
|
...patternList.map((regex) => ({
|
|
8652
8663
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
8653
8664
|
pattern: regex.source
|
|
@@ -8657,31 +8668,31 @@ var init_json_schema_processors = __esm({
|
|
|
8657
8668
|
}
|
|
8658
8669
|
};
|
|
8659
8670
|
numberProcessor = (schema, ctx, _json, params) => {
|
|
8660
|
-
const
|
|
8671
|
+
const json3 = _json;
|
|
8661
8672
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
8662
|
-
|
|
8673
|
+
json3.type = isInt ? "integer" : "number";
|
|
8663
8674
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
8664
8675
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
8665
8676
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
8666
8677
|
if (exMin) {
|
|
8667
8678
|
if (legacy) {
|
|
8668
|
-
|
|
8669
|
-
|
|
8679
|
+
json3.minimum = exclusiveMinimum;
|
|
8680
|
+
json3.exclusiveMinimum = true;
|
|
8670
8681
|
} else {
|
|
8671
|
-
|
|
8682
|
+
json3.exclusiveMinimum = exclusiveMinimum;
|
|
8672
8683
|
}
|
|
8673
8684
|
} else if (typeof minimum === "number") {
|
|
8674
|
-
|
|
8685
|
+
json3.minimum = minimum;
|
|
8675
8686
|
}
|
|
8676
8687
|
if (exMax) {
|
|
8677
8688
|
if (legacy) {
|
|
8678
|
-
|
|
8679
|
-
|
|
8689
|
+
json3.maximum = exclusiveMaximum;
|
|
8690
|
+
json3.exclusiveMaximum = true;
|
|
8680
8691
|
} else {
|
|
8681
|
-
|
|
8692
|
+
json3.exclusiveMaximum = exclusiveMaximum;
|
|
8682
8693
|
}
|
|
8683
8694
|
} else if (typeof maximum === "number") {
|
|
8684
|
-
|
|
8695
|
+
json3.maximum = maximum;
|
|
8685
8696
|
}
|
|
8686
8697
|
if (multipleOf) {
|
|
8687
8698
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -8689,66 +8700,66 @@ var init_json_schema_processors = __esm({
|
|
|
8689
8700
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
8690
8701
|
divisors.add(Math.abs(divisor));
|
|
8691
8702
|
else
|
|
8692
|
-
handleUnrepresentable(schema, ctx,
|
|
8703
|
+
handleUnrepresentable(schema, ctx, json3, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
8693
8704
|
}
|
|
8694
8705
|
const [first, ...rest] = divisors;
|
|
8695
8706
|
if (first !== void 0)
|
|
8696
|
-
|
|
8707
|
+
json3.multipleOf = first;
|
|
8697
8708
|
if (rest.length)
|
|
8698
|
-
|
|
8709
|
+
json3.allOf = [...json3.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
8699
8710
|
}
|
|
8700
8711
|
};
|
|
8701
|
-
booleanProcessor = (_schema, _ctx,
|
|
8702
|
-
|
|
8712
|
+
booleanProcessor = (_schema, _ctx, json3, _params) => {
|
|
8713
|
+
json3.type = "boolean";
|
|
8703
8714
|
};
|
|
8704
|
-
bigintProcessor = (schema, ctx,
|
|
8705
|
-
handleUnrepresentable(schema, ctx,
|
|
8715
|
+
bigintProcessor = (schema, ctx, json3, params) => {
|
|
8716
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt cannot be represented in JSON Schema");
|
|
8706
8717
|
};
|
|
8707
|
-
nullProcessor = (_schema, ctx,
|
|
8718
|
+
nullProcessor = (_schema, ctx, json3, _params) => {
|
|
8708
8719
|
if (ctx.target === "openapi-3.0") {
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8720
|
+
json3.type = "string";
|
|
8721
|
+
json3.nullable = true;
|
|
8722
|
+
json3.enum = [null];
|
|
8712
8723
|
} else {
|
|
8713
|
-
|
|
8724
|
+
json3.type = "null";
|
|
8714
8725
|
}
|
|
8715
8726
|
};
|
|
8716
|
-
neverProcessor = (_schema, _ctx,
|
|
8717
|
-
|
|
8727
|
+
neverProcessor = (_schema, _ctx, json3, _params) => {
|
|
8728
|
+
json3.not = {};
|
|
8718
8729
|
};
|
|
8719
8730
|
anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
8720
8731
|
};
|
|
8721
8732
|
unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
8722
8733
|
};
|
|
8723
|
-
dateProcessor = (schema, ctx,
|
|
8724
|
-
handleUnrepresentable(schema, ctx,
|
|
8734
|
+
dateProcessor = (schema, ctx, json3, params) => {
|
|
8735
|
+
handleUnrepresentable(schema, ctx, json3, params, "Date cannot be represented in JSON Schema");
|
|
8725
8736
|
};
|
|
8726
|
-
enumProcessor = (schema, _ctx,
|
|
8737
|
+
enumProcessor = (schema, _ctx, json3, _params) => {
|
|
8727
8738
|
const def = schema._zod.def;
|
|
8728
8739
|
const values = getEnumValues(def.entries);
|
|
8729
8740
|
if (values.length === 0) {
|
|
8730
|
-
|
|
8741
|
+
json3.not = {};
|
|
8731
8742
|
return;
|
|
8732
8743
|
}
|
|
8733
8744
|
if (values.every((v) => typeof v === "number"))
|
|
8734
|
-
|
|
8745
|
+
json3.type = "number";
|
|
8735
8746
|
if (values.every((v) => typeof v === "string"))
|
|
8736
|
-
|
|
8737
|
-
|
|
8747
|
+
json3.type = "string";
|
|
8748
|
+
json3.enum = values;
|
|
8738
8749
|
};
|
|
8739
|
-
literalProcessor = (schema, ctx,
|
|
8750
|
+
literalProcessor = (schema, ctx, json3, params) => {
|
|
8740
8751
|
const def = schema._zod.def;
|
|
8741
8752
|
if (def.values.length === 0) {
|
|
8742
|
-
|
|
8753
|
+
json3.not = {};
|
|
8743
8754
|
return;
|
|
8744
8755
|
}
|
|
8745
8756
|
const vals = [];
|
|
8746
8757
|
for (const val of def.values) {
|
|
8747
8758
|
if (val === void 0) {
|
|
8748
|
-
if (handleUnrepresentable(schema, ctx,
|
|
8759
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
8749
8760
|
return;
|
|
8750
8761
|
} else if (typeof val === "bigint") {
|
|
8751
|
-
if (handleUnrepresentable(schema, ctx,
|
|
8762
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
8752
8763
|
return;
|
|
8753
8764
|
vals.push(Number(val));
|
|
8754
8765
|
} else {
|
|
@@ -8758,56 +8769,56 @@ var init_json_schema_processors = __esm({
|
|
|
8758
8769
|
if (vals.length === 0) {
|
|
8759
8770
|
} else if (vals.length === 1) {
|
|
8760
8771
|
const val = vals[0];
|
|
8761
|
-
|
|
8772
|
+
json3.type = val === null ? "null" : typeof val;
|
|
8762
8773
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
8763
|
-
|
|
8774
|
+
json3.enum = [val];
|
|
8764
8775
|
} else {
|
|
8765
|
-
|
|
8776
|
+
json3.const = val;
|
|
8766
8777
|
}
|
|
8767
8778
|
} else {
|
|
8768
8779
|
if (vals.every((v) => typeof v === "number"))
|
|
8769
|
-
|
|
8780
|
+
json3.type = "number";
|
|
8770
8781
|
if (vals.every((v) => typeof v === "string"))
|
|
8771
|
-
|
|
8782
|
+
json3.type = "string";
|
|
8772
8783
|
if (vals.every((v) => typeof v === "boolean"))
|
|
8773
|
-
|
|
8784
|
+
json3.type = "boolean";
|
|
8774
8785
|
if (vals.every((v) => v === null))
|
|
8775
|
-
|
|
8776
|
-
|
|
8786
|
+
json3.type = "null";
|
|
8787
|
+
json3.enum = vals;
|
|
8777
8788
|
}
|
|
8778
8789
|
};
|
|
8779
|
-
customProcessor = (schema, ctx,
|
|
8780
|
-
handleUnrepresentable(schema, ctx,
|
|
8790
|
+
customProcessor = (schema, ctx, json3, params) => {
|
|
8791
|
+
handleUnrepresentable(schema, ctx, json3, params, "Custom types cannot be represented in JSON Schema");
|
|
8781
8792
|
};
|
|
8782
|
-
transformProcessor = (schema, ctx,
|
|
8783
|
-
handleUnrepresentable(schema, ctx,
|
|
8793
|
+
transformProcessor = (schema, ctx, json3, params) => {
|
|
8794
|
+
handleUnrepresentable(schema, ctx, json3, params, "Transforms cannot be represented in JSON Schema");
|
|
8784
8795
|
};
|
|
8785
8796
|
arrayProcessor = (schema, ctx, _json, params) => {
|
|
8786
|
-
const
|
|
8797
|
+
const json3 = _json;
|
|
8787
8798
|
const def = schema._zod.def;
|
|
8788
8799
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
8789
8800
|
if (typeof minimum === "number")
|
|
8790
|
-
|
|
8801
|
+
json3.minItems = minimum;
|
|
8791
8802
|
if (typeof maximum === "number")
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8803
|
+
json3.maxItems = maximum;
|
|
8804
|
+
json3.type = "array";
|
|
8805
|
+
json3.items = processSchema(def.element, ctx, {
|
|
8795
8806
|
...params,
|
|
8796
8807
|
path: [...params.path, "items"]
|
|
8797
8808
|
});
|
|
8798
8809
|
};
|
|
8799
8810
|
objectProcessor = (schema, ctx, _json, params) => {
|
|
8800
|
-
const
|
|
8811
|
+
const json3 = _json;
|
|
8801
8812
|
const def = schema._zod.def;
|
|
8802
8813
|
const shape = def.shape;
|
|
8803
8814
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
8804
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
8815
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json3, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
8805
8816
|
return;
|
|
8806
8817
|
}
|
|
8807
|
-
|
|
8808
|
-
|
|
8818
|
+
json3.type = "object";
|
|
8819
|
+
json3.properties = {};
|
|
8809
8820
|
for (const key in shape) {
|
|
8810
|
-
assignProp(
|
|
8821
|
+
assignProp(json3.properties, key, processSchema(shape[key], ctx, {
|
|
8811
8822
|
...params,
|
|
8812
8823
|
path: [...params.path, "properties", key]
|
|
8813
8824
|
}));
|
|
@@ -8820,21 +8831,21 @@ var init_json_schema_processors = __esm({
|
|
|
8820
8831
|
}
|
|
8821
8832
|
}
|
|
8822
8833
|
if (requiredKeys.length > 0) {
|
|
8823
|
-
|
|
8834
|
+
json3.required = requiredKeys;
|
|
8824
8835
|
}
|
|
8825
8836
|
if (def.catchall?._zod.def.type === "never") {
|
|
8826
|
-
|
|
8837
|
+
json3.additionalProperties = false;
|
|
8827
8838
|
} else if (!def.catchall) {
|
|
8828
8839
|
if (ctx.io === "output")
|
|
8829
|
-
|
|
8840
|
+
json3.additionalProperties = false;
|
|
8830
8841
|
} else if (def.catchall) {
|
|
8831
|
-
|
|
8842
|
+
json3.additionalProperties = processSchema(def.catchall, ctx, {
|
|
8832
8843
|
...params,
|
|
8833
8844
|
path: [...params.path, "additionalProperties"]
|
|
8834
8845
|
});
|
|
8835
8846
|
}
|
|
8836
8847
|
};
|
|
8837
|
-
unionProcessor = (schema, ctx,
|
|
8848
|
+
unionProcessor = (schema, ctx, json3, params) => {
|
|
8838
8849
|
const def = schema._zod.def;
|
|
8839
8850
|
const isExclusive = def.inclusive === false;
|
|
8840
8851
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -8842,12 +8853,12 @@ var init_json_schema_processors = __esm({
|
|
|
8842
8853
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
8843
8854
|
}));
|
|
8844
8855
|
if (isExclusive) {
|
|
8845
|
-
|
|
8856
|
+
json3.oneOf = options;
|
|
8846
8857
|
} else {
|
|
8847
|
-
|
|
8858
|
+
json3.anyOf = options;
|
|
8848
8859
|
}
|
|
8849
8860
|
};
|
|
8850
|
-
intersectionProcessor = (schema, ctx,
|
|
8861
|
+
intersectionProcessor = (schema, ctx, json3, params) => {
|
|
8851
8862
|
const def = schema._zod.def;
|
|
8852
8863
|
const a = processSchema(def.left, ctx, {
|
|
8853
8864
|
...params,
|
|
@@ -8862,14 +8873,14 @@ var init_json_schema_processors = __esm({
|
|
|
8862
8873
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
8863
8874
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
8864
8875
|
];
|
|
8865
|
-
|
|
8876
|
+
json3.allOf = allOf;
|
|
8866
8877
|
ctx.intersections.push(allOf);
|
|
8867
8878
|
};
|
|
8868
8879
|
pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
8869
8880
|
recordProcessor = (schema, ctx, _json, params) => {
|
|
8870
|
-
const
|
|
8881
|
+
const json3 = _json;
|
|
8871
8882
|
const def = schema._zod.def;
|
|
8872
|
-
|
|
8883
|
+
json3.type = "object";
|
|
8873
8884
|
const keyType = def.keyType;
|
|
8874
8885
|
const patterns = aggregateChecks(keyType).patterns;
|
|
8875
8886
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -8877,13 +8888,13 @@ var init_json_schema_processors = __esm({
|
|
|
8877
8888
|
...params,
|
|
8878
8889
|
path: [...params.path, "patternProperties", "*"]
|
|
8879
8890
|
});
|
|
8880
|
-
|
|
8891
|
+
json3.patternProperties = {};
|
|
8881
8892
|
for (const pattern of patterns) {
|
|
8882
|
-
assignProp(
|
|
8893
|
+
assignProp(json3.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
8883
8894
|
}
|
|
8884
8895
|
} else {
|
|
8885
8896
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
8886
|
-
|
|
8897
|
+
json3.propertyNames = processSchema(def.keyType, ctx, {
|
|
8887
8898
|
...params,
|
|
8888
8899
|
path: [...params.path, "propertyNames"]
|
|
8889
8900
|
});
|
|
@@ -8895,7 +8906,7 @@ var init_json_schema_processors = __esm({
|
|
|
8895
8906
|
}
|
|
8896
8907
|
pending.push(schema);
|
|
8897
8908
|
}
|
|
8898
|
-
|
|
8909
|
+
json3.additionalProperties = processSchema(def.valueType, ctx, {
|
|
8899
8910
|
...params,
|
|
8900
8911
|
path: [...params.path, "additionalProperties"]
|
|
8901
8912
|
});
|
|
@@ -8905,19 +8916,19 @@ var init_json_schema_processors = __esm({
|
|
|
8905
8916
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
8906
8917
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
8907
8918
|
if (validKeyValues.length > 0) {
|
|
8908
|
-
|
|
8919
|
+
json3.required = validKeyValues.map(String);
|
|
8909
8920
|
}
|
|
8910
8921
|
}
|
|
8911
8922
|
};
|
|
8912
|
-
nullableProcessor = (schema, ctx,
|
|
8923
|
+
nullableProcessor = (schema, ctx, json3, params) => {
|
|
8913
8924
|
const def = schema._zod.def;
|
|
8914
8925
|
const inner = processSchema(def.innerType, ctx, params);
|
|
8915
8926
|
const seen = ctx.seen.get(schema);
|
|
8916
8927
|
if (ctx.target === "openapi-3.0") {
|
|
8917
8928
|
seen.ref = def.innerType;
|
|
8918
|
-
|
|
8929
|
+
json3.nullable = true;
|
|
8919
8930
|
} else {
|
|
8920
|
-
|
|
8931
|
+
json3.anyOf = [inner, { type: "null" }];
|
|
8921
8932
|
}
|
|
8922
8933
|
};
|
|
8923
8934
|
nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -8927,27 +8938,27 @@ var init_json_schema_processors = __esm({
|
|
|
8927
8938
|
seen.ref = def.innerType;
|
|
8928
8939
|
};
|
|
8929
8940
|
UNREPRESENTABLE_DEFAULT = Symbol();
|
|
8930
|
-
defaultProcessor = (schema, ctx,
|
|
8941
|
+
defaultProcessor = (schema, ctx, json3, params) => {
|
|
8931
8942
|
const def = schema._zod.def;
|
|
8932
8943
|
processSchema(def.innerType, ctx, params);
|
|
8933
8944
|
const seen = ctx.seen.get(schema);
|
|
8934
8945
|
seen.ref = def.innerType;
|
|
8935
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
8946
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
8936
8947
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
8937
|
-
|
|
8948
|
+
json3.default = value;
|
|
8938
8949
|
};
|
|
8939
|
-
prefaultProcessor = (schema, ctx,
|
|
8950
|
+
prefaultProcessor = (schema, ctx, json3, params) => {
|
|
8940
8951
|
const def = schema._zod.def;
|
|
8941
8952
|
processSchema(def.innerType, ctx, params);
|
|
8942
8953
|
const seen = ctx.seen.get(schema);
|
|
8943
8954
|
seen.ref = def.innerType;
|
|
8944
8955
|
if (ctx.io !== "input")
|
|
8945
8956
|
return;
|
|
8946
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
8957
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
8947
8958
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
8948
|
-
|
|
8959
|
+
json3._prefault = value;
|
|
8949
8960
|
};
|
|
8950
|
-
catchProcessor = (schema, ctx,
|
|
8961
|
+
catchProcessor = (schema, ctx, json3, params) => {
|
|
8951
8962
|
const def = schema._zod.def;
|
|
8952
8963
|
processSchema(def.innerType, ctx, params);
|
|
8953
8964
|
const seen = ctx.seen.get(schema);
|
|
@@ -8956,10 +8967,10 @@ var init_json_schema_processors = __esm({
|
|
|
8956
8967
|
try {
|
|
8957
8968
|
catchValue = def.catchValue(void 0);
|
|
8958
8969
|
} catch {
|
|
8959
|
-
handleUnrepresentable(schema, ctx,
|
|
8970
|
+
handleUnrepresentable(schema, ctx, json3, params, "Dynamic catch values are not supported in JSON Schema");
|
|
8960
8971
|
return;
|
|
8961
8972
|
}
|
|
8962
|
-
|
|
8973
|
+
json3.default = catchValue;
|
|
8963
8974
|
};
|
|
8964
8975
|
pipeProcessor = (schema, ctx, _json, params) => {
|
|
8965
8976
|
const def = schema._zod.def;
|
|
@@ -8969,12 +8980,12 @@ var init_json_schema_processors = __esm({
|
|
|
8969
8980
|
const seen = ctx.seen.get(schema);
|
|
8970
8981
|
seen.ref = innerType;
|
|
8971
8982
|
};
|
|
8972
|
-
readonlyProcessor = (schema, ctx,
|
|
8983
|
+
readonlyProcessor = (schema, ctx, json3, params) => {
|
|
8973
8984
|
const def = schema._zod.def;
|
|
8974
8985
|
processSchema(def.innerType, ctx, params);
|
|
8975
8986
|
const seen = ctx.seen.get(schema);
|
|
8976
8987
|
seen.ref = def.innerType;
|
|
8977
|
-
|
|
8988
|
+
json3.readOnly = true;
|
|
8978
8989
|
};
|
|
8979
8990
|
optionalProcessor = (schema, ctx, _json, params) => {
|
|
8980
8991
|
const def = schema._zod.def;
|
|
@@ -9598,7 +9609,7 @@ var init_schemas3 = __esm({
|
|
|
9598
9609
|
(inst, def) => {
|
|
9599
9610
|
$ZodString.init(inst, def);
|
|
9600
9611
|
ZodType.init(inst, def);
|
|
9601
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9612
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
|
|
9602
9613
|
},
|
|
9603
9614
|
/* @__PURE__ */ util_exports.derived({
|
|
9604
9615
|
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
@@ -9836,7 +9847,7 @@ var init_schemas3 = __esm({
|
|
|
9836
9847
|
(inst, def) => {
|
|
9837
9848
|
$ZodNumber.init(inst, def);
|
|
9838
9849
|
ZodType.init(inst, def);
|
|
9839
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9850
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
|
|
9840
9851
|
inst.isFinite = true;
|
|
9841
9852
|
},
|
|
9842
9853
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -9908,14 +9919,14 @@ var init_schemas3 = __esm({
|
|
|
9908
9919
|
ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
9909
9920
|
$ZodBoolean.init(inst, def);
|
|
9910
9921
|
ZodType.init(inst, def);
|
|
9911
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9922
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
|
|
9912
9923
|
});
|
|
9913
9924
|
ZodBigInt = /* @__PURE__ */ $constructor(
|
|
9914
9925
|
"ZodBigInt",
|
|
9915
9926
|
(inst, def) => {
|
|
9916
9927
|
$ZodBigInt.init(inst, def);
|
|
9917
9928
|
ZodType.init(inst, def);
|
|
9918
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9929
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
|
|
9919
9930
|
},
|
|
9920
9931
|
/* @__PURE__ */ util_exports.derived({
|
|
9921
9932
|
minValue: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
@@ -9960,29 +9971,29 @@ var init_schemas3 = __esm({
|
|
|
9960
9971
|
ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
9961
9972
|
$ZodNull.init(inst, def);
|
|
9962
9973
|
ZodType.init(inst, def);
|
|
9963
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9974
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
|
|
9964
9975
|
});
|
|
9965
9976
|
ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
9966
9977
|
$ZodAny.init(inst, def);
|
|
9967
9978
|
ZodType.init(inst, def);
|
|
9968
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9979
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
|
|
9969
9980
|
});
|
|
9970
9981
|
ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
9971
9982
|
$ZodUnknown.init(inst, def);
|
|
9972
9983
|
ZodType.init(inst, def);
|
|
9973
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9984
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
|
|
9974
9985
|
});
|
|
9975
9986
|
ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
9976
9987
|
$ZodNever.init(inst, def);
|
|
9977
9988
|
ZodType.init(inst, def);
|
|
9978
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9989
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
|
|
9979
9990
|
});
|
|
9980
9991
|
ZodDate = /* @__PURE__ */ $constructor(
|
|
9981
9992
|
"ZodDate",
|
|
9982
9993
|
(inst, def) => {
|
|
9983
9994
|
$ZodDate.init(inst, def);
|
|
9984
9995
|
ZodType.init(inst, def);
|
|
9985
|
-
inst._zod.processJSONSchema = (ctx,
|
|
9996
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
|
|
9986
9997
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
9987
9998
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
9988
9999
|
},
|
|
@@ -10001,7 +10012,7 @@ var init_schemas3 = __esm({
|
|
|
10001
10012
|
_ensureDefaultMemoizer();
|
|
10002
10013
|
$ZodArray.init(inst, def);
|
|
10003
10014
|
ZodType.init(inst, def);
|
|
10004
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10015
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
|
|
10005
10016
|
inst.element = def.element;
|
|
10006
10017
|
}, {
|
|
10007
10018
|
min(n, params) {
|
|
@@ -10024,7 +10035,7 @@ var init_schemas3 = __esm({
|
|
|
10024
10035
|
_ensureDefaultMemoizer();
|
|
10025
10036
|
$ZodObjectJIT.init(inst, def);
|
|
10026
10037
|
ZodType.init(inst, def);
|
|
10027
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10038
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
|
|
10028
10039
|
util_exports.installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
10029
10040
|
}, {
|
|
10030
10041
|
keyof() {
|
|
@@ -10073,7 +10084,7 @@ var init_schemas3 = __esm({
|
|
|
10073
10084
|
ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
10074
10085
|
$ZodUnion.init(inst, def);
|
|
10075
10086
|
ZodType.init(inst, def);
|
|
10076
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10087
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
10077
10088
|
inst.options = def.options;
|
|
10078
10089
|
});
|
|
10079
10090
|
ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
@@ -10083,20 +10094,20 @@ var init_schemas3 = __esm({
|
|
|
10083
10094
|
ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
10084
10095
|
$ZodIntersection.init(inst, def);
|
|
10085
10096
|
ZodType.init(inst, def);
|
|
10086
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10097
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
|
|
10087
10098
|
});
|
|
10088
10099
|
ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
10089
10100
|
_ensureDefaultMemoizer();
|
|
10090
10101
|
$ZodRecord.init(inst, def);
|
|
10091
10102
|
ZodType.init(inst, def);
|
|
10092
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10103
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
|
|
10093
10104
|
inst.keyType = def.keyType;
|
|
10094
10105
|
inst.valueType = def.valueType;
|
|
10095
10106
|
});
|
|
10096
10107
|
ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
10097
10108
|
$ZodEnum.init(inst, def);
|
|
10098
10109
|
ZodType.init(inst, def);
|
|
10099
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10110
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
|
|
10100
10111
|
inst.enum = def.entries;
|
|
10101
10112
|
inst.options = [...inst._zod.values];
|
|
10102
10113
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -10134,7 +10145,7 @@ var init_schemas3 = __esm({
|
|
|
10134
10145
|
ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
10135
10146
|
$ZodLiteral.init(inst, def);
|
|
10136
10147
|
ZodType.init(inst, def);
|
|
10137
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10148
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
|
|
10138
10149
|
inst.values = new Set(def.values);
|
|
10139
10150
|
Object.defineProperty(inst, "value", {
|
|
10140
10151
|
get() {
|
|
@@ -10149,7 +10160,7 @@ var init_schemas3 = __esm({
|
|
|
10149
10160
|
_ensureDefaultMemoizer();
|
|
10150
10161
|
$ZodTransform.init(inst, def);
|
|
10151
10162
|
ZodType.init(inst, def);
|
|
10152
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10163
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
|
|
10153
10164
|
inst._zod.parse = (payload, _ctx) => {
|
|
10154
10165
|
if (_ctx.direction === "backward") {
|
|
10155
10166
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -10182,51 +10193,51 @@ var init_schemas3 = __esm({
|
|
|
10182
10193
|
ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
10183
10194
|
$ZodOptional.init(inst, def);
|
|
10184
10195
|
ZodType.init(inst, def);
|
|
10185
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10196
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
10186
10197
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10187
10198
|
});
|
|
10188
10199
|
ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
10189
10200
|
$ZodExactOptional.init(inst, def);
|
|
10190
10201
|
ZodType.init(inst, def);
|
|
10191
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10202
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
10192
10203
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10193
10204
|
});
|
|
10194
10205
|
ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
10195
10206
|
$ZodNullable.init(inst, def);
|
|
10196
10207
|
ZodType.init(inst, def);
|
|
10197
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10208
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
|
|
10198
10209
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10199
10210
|
});
|
|
10200
10211
|
ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
10201
10212
|
$ZodDefault.init(inst, def);
|
|
10202
10213
|
ZodType.init(inst, def);
|
|
10203
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10214
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
|
|
10204
10215
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10205
10216
|
inst.removeDefault = inst.unwrap;
|
|
10206
10217
|
});
|
|
10207
10218
|
ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
10208
10219
|
$ZodPrefault.init(inst, def);
|
|
10209
10220
|
ZodType.init(inst, def);
|
|
10210
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10221
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
|
|
10211
10222
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10212
10223
|
});
|
|
10213
10224
|
ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
10214
10225
|
$ZodNonOptional.init(inst, def);
|
|
10215
10226
|
ZodType.init(inst, def);
|
|
10216
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10227
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
|
|
10217
10228
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10218
10229
|
});
|
|
10219
10230
|
ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
10220
10231
|
$ZodCatch.init(inst, def);
|
|
10221
10232
|
ZodType.init(inst, def);
|
|
10222
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10233
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
|
|
10223
10234
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10224
10235
|
inst.removeCatch = inst.unwrap;
|
|
10225
10236
|
});
|
|
10226
10237
|
ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
10227
10238
|
$ZodPipe.init(inst, def);
|
|
10228
10239
|
ZodType.init(inst, def);
|
|
10229
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10240
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
|
|
10230
10241
|
inst.in = def.in;
|
|
10231
10242
|
inst.out = def.out;
|
|
10232
10243
|
});
|
|
@@ -10237,13 +10248,13 @@ var init_schemas3 = __esm({
|
|
|
10237
10248
|
ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
10238
10249
|
$ZodReadonly.init(inst, def);
|
|
10239
10250
|
ZodType.init(inst, def);
|
|
10240
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10251
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
|
|
10241
10252
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
10242
10253
|
});
|
|
10243
10254
|
ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
10244
10255
|
$ZodCustom.init(inst, def);
|
|
10245
10256
|
ZodType.init(inst, def);
|
|
10246
|
-
inst._zod.processJSONSchema = (ctx,
|
|
10257
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
|
|
10247
10258
|
});
|
|
10248
10259
|
}
|
|
10249
10260
|
});
|
|
@@ -23768,8 +23779,8 @@ var init_stdio2 = __esm({
|
|
|
23768
23779
|
}
|
|
23769
23780
|
send(message) {
|
|
23770
23781
|
return new Promise((resolve10) => {
|
|
23771
|
-
const
|
|
23772
|
-
if (this._stdout.write(
|
|
23782
|
+
const json3 = serializeMessage(message);
|
|
23783
|
+
if (this._stdout.write(json3)) {
|
|
23773
23784
|
resolve10();
|
|
23774
23785
|
} else {
|
|
23775
23786
|
this._stdout.once("drain", resolve10);
|
|
@@ -24323,6 +24334,7 @@ var init_ops = __esm({
|
|
|
24323
24334
|
// src/tasks.ts
|
|
24324
24335
|
var tasks_exports = {};
|
|
24325
24336
|
__export(tasks_exports, {
|
|
24337
|
+
locationsText: () => locationsText,
|
|
24326
24338
|
opsHumanTaskHandler: () => opsHumanTaskHandler,
|
|
24327
24339
|
runTaskCommand: () => runTaskCommand,
|
|
24328
24340
|
runtimeUpgradeText: () => runtimeUpgradeText,
|
|
@@ -24440,6 +24452,82 @@ function opsHumanTaskHandler(options, context2) {
|
|
|
24440
24452
|
return result;
|
|
24441
24453
|
};
|
|
24442
24454
|
}
|
|
24455
|
+
async function readLocations(call2, organizationId, workspaceId) {
|
|
24456
|
+
const supported = (await call2(`/organizations/${organizationId}/supported-regions` + (workspaceId ? "?workspaceId=" + workspaceId : ""))).regions;
|
|
24457
|
+
const organization = (await call2("/organizations")).find((value) => value.id === organizationId);
|
|
24458
|
+
if (!organization) throw new Error("The organization was not found.");
|
|
24459
|
+
const organizationAllowed = (organization.allowedRegions ?? supported).filter((region) => supported.includes(region));
|
|
24460
|
+
if (!workspaceId) return {
|
|
24461
|
+
scope: "organization",
|
|
24462
|
+
organization,
|
|
24463
|
+
supportedRegions: supported,
|
|
24464
|
+
allowedRegions: organization.allowedRegions ?? null,
|
|
24465
|
+
defaultRegion: organization.defaultRegion,
|
|
24466
|
+
effectiveAllowedRegions: organizationAllowed,
|
|
24467
|
+
effectiveDefaultRegion: organization.defaultRegion
|
|
24468
|
+
};
|
|
24469
|
+
const workspace = (await call2("/workspaces")).find((value) => value.id === workspaceId);
|
|
24470
|
+
if (!workspace) throw new Error("The workspace was not found.");
|
|
24471
|
+
const effective = await call2(`/workspaces/${workspaceId}/effective-settings`);
|
|
24472
|
+
return {
|
|
24473
|
+
scope: "workspace",
|
|
24474
|
+
workspaceId,
|
|
24475
|
+
organization,
|
|
24476
|
+
workspace,
|
|
24477
|
+
supportedRegions: supported,
|
|
24478
|
+
allowedRegions: workspace.allowedRegions ?? null,
|
|
24479
|
+
defaultRegion: workspace.defaultRegion ?? null,
|
|
24480
|
+
effectiveAllowedRegions: effective.allowedRegions.filter((region) => supported.includes(region)),
|
|
24481
|
+
effectiveDefaultRegion: effective.region
|
|
24482
|
+
};
|
|
24483
|
+
}
|
|
24484
|
+
function locationsText(view) {
|
|
24485
|
+
const all = view.scope === "organization" ? "every supported location" : "the organization's locations";
|
|
24486
|
+
return [
|
|
24487
|
+
`Default location: ${view.effectiveDefaultRegion}${view.scope === "workspace" && view.defaultRegion === null ? " (organization default)" : ""}`,
|
|
24488
|
+
`Allowed locations: ${view.allowedRegions === null ? all + ": " : ""}${view.effectiveAllowedRegions.join(", ") || "none"}`,
|
|
24489
|
+
`Supported locations (Backify Cloud and connected clouds): ${view.supportedRegions.join(", ") || "none yet; connect a cloud or ask your platform operator"}`
|
|
24490
|
+
].join("\n");
|
|
24491
|
+
}
|
|
24492
|
+
async function setLocations(call2, organizationId, values, options, context2) {
|
|
24493
|
+
const workspaceId = workspaceOption(values);
|
|
24494
|
+
const allow = values.allow?.map((region) => region.trim().toLowerCase()), [defaultChoice] = (values.default ?? []).map((region) => region.trim().toLowerCase());
|
|
24495
|
+
if (!allow && !defaultChoice) throw new Error("Pass --default <region> and/or --allow <region> (repeat it, or use all or inherit).");
|
|
24496
|
+
const special = allow?.find((region) => region === "all" || region === "inherit");
|
|
24497
|
+
if (special && allow.length > 1) throw new Error(`--allow ${special} cannot be combined with regions.`);
|
|
24498
|
+
if (special === "inherit" && !workspaceId) throw new Error("--allow inherit is for a workspace; use --allow all for the organization.");
|
|
24499
|
+
if (defaultChoice === "inherit" && !workspaceId) throw new Error("--default inherit is for a workspace.");
|
|
24500
|
+
const current = await readLocations(call2, organizationId, workspaceId);
|
|
24501
|
+
const allowedRegions = !allow ? current.allowedRegions : special === "all" ? workspaceId ? current.supportedRegions.filter((region) => (current.organization.allowedRegions ?? current.supportedRegions).includes(region)) : null : special === "inherit" ? null : [...new Set(allow)];
|
|
24502
|
+
const scope = workspaceId ? `workspace ${current.workspace.name}` : `organization ${current.organization.name}`;
|
|
24503
|
+
const change = [allow ? `allowed locations to ${allowedRegions ? allowedRegions.join(", ") : workspaceId ? "the organization's" : "every supported location"}` : "", defaultChoice ? `default location to ${defaultChoice === "inherit" ? "the organization's" : defaultChoice}` : ""].filter(Boolean).join(" and ");
|
|
24504
|
+
if (!options.yes) {
|
|
24505
|
+
if (!context2.confirm) throw new OpsError(`Refusing to change locations without confirmation. Re-run with --yes to set the ${scope} ${change}.`, "confirmation_required");
|
|
24506
|
+
if (!await context2.confirm(`Set the ${scope} ${change}? Existing applications are not moved.`)) throw new OpsError("Not confirmed. Nothing was changed.", "not_confirmed");
|
|
24507
|
+
}
|
|
24508
|
+
if (workspaceId) {
|
|
24509
|
+
const workspace = current.workspace;
|
|
24510
|
+
const defaultRegion = defaultChoice === "inherit" ? null : defaultChoice ?? workspace.defaultRegion ?? null;
|
|
24511
|
+
await call2(`/workspaces/${workspaceId}`, { method: "PATCH", headers: json, body: JSON.stringify({
|
|
24512
|
+
name: workspace.name,
|
|
24513
|
+
description: workspace.description ?? null,
|
|
24514
|
+
isDefault: workspace.isDefault,
|
|
24515
|
+
defaultRegion,
|
|
24516
|
+
allowedRegions,
|
|
24517
|
+
cloudConnectionId: workspace.cloudConnectionId ?? null,
|
|
24518
|
+
deploymentTargetId: workspace.deploymentTargetId ?? null,
|
|
24519
|
+
githubInstallationId: workspace.githubInstallationId ?? null,
|
|
24520
|
+
allowHostingSelection: workspace.allowHostingSelection !== false,
|
|
24521
|
+
allowRepositorySelection: workspace.allowRepositorySelection !== false,
|
|
24522
|
+
repositoryNamePrefix: workspace.repositoryNamePrefix ?? "",
|
|
24523
|
+
repositoryNamePostfix: workspace.repositoryNamePostfix ?? ""
|
|
24524
|
+
}) });
|
|
24525
|
+
} else {
|
|
24526
|
+
await call2(`/organizations/${organizationId}`, { method: "PATCH", headers: json, body: JSON.stringify({ name: current.organization.name, region: defaultChoice ?? current.organization.defaultRegion, allowedRegions }) });
|
|
24527
|
+
}
|
|
24528
|
+
const { organization: _organization, workspace: _workspace, ...view } = await readLocations(call2, organizationId, workspaceId);
|
|
24529
|
+
return { value: view, text: "Locations saved.\n" + locationsText(view), exitCode: 0 };
|
|
24530
|
+
}
|
|
24443
24531
|
function scopedGrants(entries, scopeType, flag) {
|
|
24444
24532
|
return (entries ?? []).map((entry) => {
|
|
24445
24533
|
const at = entry.indexOf("="), scopeId = entry.slice(0, at), role = entry.slice(at + 1).trim();
|
|
@@ -24493,6 +24581,13 @@ async function runTaskCommand(command2, args2, context2) {
|
|
|
24493
24581
|
const deployment = await call2("/cloud-connections/" + connection(values) + "/runtime");
|
|
24494
24582
|
return { result: { value: deployment, text: runtimeUpgradeText(deployment), exitCode: 0 }, json: options.json };
|
|
24495
24583
|
}
|
|
24584
|
+
case "azure automatic-upgrades": {
|
|
24585
|
+
const id = connection(values);
|
|
24586
|
+
if (target !== void 0 && target !== "on" && target !== "off") throw new Error("Pass on or off, or nothing to show the setting: backify azure automatic-upgrades on|off --connection <id>.");
|
|
24587
|
+
const deployment = target === void 0 ? await call2("/cloud-connections/" + id + "/runtime") : await call2("/cloud-connections/" + id + "/runtime/automatic-upgrades", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ enabled: target === "on" }) });
|
|
24588
|
+
const enabled = deployment.automaticUpgrades !== false;
|
|
24589
|
+
return { result: { value: { automaticUpgrades: enabled }, text: enabled ? "Automatic Runtime upgrades are on: compatible releases start their phased upgrade without approval. Releases that change Azure roles or templates, and major releases, still wait for approval." : "Automatic Runtime upgrades are off: each proposed upgrade waits for approval (backify azure update-runtime --connection <id>).", exitCode: 0 }, json: options.json };
|
|
24590
|
+
}
|
|
24496
24591
|
case "azure grant-scope": {
|
|
24497
24592
|
const scope = await call2("/cloud-connections/" + connection(values) + "/grant-scope");
|
|
24498
24593
|
return { result: { value: scope, text: JSON.stringify(scope, null, 2), exitCode: 0 }, json: options.json };
|
|
@@ -24508,6 +24603,12 @@ async function runTaskCommand(command2, args2, context2) {
|
|
|
24508
24603
|
const summary = await call2("/organizations/" + organizationId + "/summary");
|
|
24509
24604
|
return { result: { value: summary, text: JSON.stringify(summary, null, 2) }, json: options.json };
|
|
24510
24605
|
}
|
|
24606
|
+
case "org locations": {
|
|
24607
|
+
if (target === "set") return { result: await setLocations(call2, organizationId, values, options, context2), json: options.json };
|
|
24608
|
+
if (target) throw new Error("Use backify org locations [--workspace <id>], or backify org locations set.");
|
|
24609
|
+
const { organization: _organization, workspace: _workspace, ...view } = await readLocations(call2, organizationId, workspaceOption(values));
|
|
24610
|
+
return { result: { value: view, text: locationsText(view) }, json: options.json };
|
|
24611
|
+
}
|
|
24511
24612
|
case "billing":
|
|
24512
24613
|
case "billing show": {
|
|
24513
24614
|
const billing = await call2("/organizations/" + organizationId + "/billing");
|
|
@@ -24583,7 +24684,7 @@ async function runTaskCommand(command2, args2, context2) {
|
|
|
24583
24684
|
throw new Error("Unknown command.\n\n" + taskHelp);
|
|
24584
24685
|
}
|
|
24585
24686
|
}
|
|
24586
|
-
var taskHelp, purposes, upgradeEnded, upgradeInProgress, connection;
|
|
24687
|
+
var taskHelp, purposes, upgradeEnded, upgradeInProgress, json, workspaceOption, connection;
|
|
24587
24688
|
var init_tasks = __esm({
|
|
24588
24689
|
"src/tasks.ts"() {
|
|
24589
24690
|
"use strict";
|
|
@@ -24607,7 +24708,13 @@ var init_tasks = __esm({
|
|
|
24607
24708
|
" backify azure grant-scope --connection <id> [--json] Show the grant scope, proposed changes and latest re-scope operation",
|
|
24608
24709
|
" backify azure rescope-grants --connection <id> Request Azure administrator review and approval of scoped grants",
|
|
24609
24710
|
" backify azure runtime-upgrade --connection <id> [--json] Show the Runtime upgrade: phase, versions, verification, canary outcome, end state",
|
|
24711
|
+
" backify azure automatic-upgrades [on|off] --connection <id> Show or change automatic upgrades of compatible Runtime releases (on by default)",
|
|
24610
24712
|
" backify org Organization summary",
|
|
24713
|
+
" backify org locations [--workspace <id>] Default and allowed application locations, and the locations Backify Cloud",
|
|
24714
|
+
" or a connected cloud can host (only those can be allowed)",
|
|
24715
|
+
" backify org locations set [--workspace <id>] [--default <region>|--default inherit]",
|
|
24716
|
+
" [--allow <region> ...|--allow all|--allow inherit] [--yes]",
|
|
24717
|
+
" Change them; all and inherit follow the supported or organization locations",
|
|
24611
24718
|
" backify billing Subscription status",
|
|
24612
24719
|
" backify billing checkout|change-plan [--plan <plan>] [--interval <interval>] [--currency <currency>]",
|
|
24613
24720
|
" Review a subscription or plan change in the browser",
|
|
@@ -24665,6 +24772,12 @@ var init_tasks = __esm({
|
|
|
24665
24772
|
};
|
|
24666
24773
|
upgradeEnded = (upgrade) => ["committed", "rolled-back", "failed"].includes(upgrade.phase);
|
|
24667
24774
|
upgradeInProgress = (upgrade) => !!upgrade && !upgradeEnded(upgrade) && upgrade.state !== "awaiting-approval";
|
|
24775
|
+
json = { "content-type": "application/json" };
|
|
24776
|
+
workspaceOption = (values) => {
|
|
24777
|
+
const id = values.workspace?.[0];
|
|
24778
|
+
if (id !== void 0 && !isUuid(id)) throw new Error("--workspace takes a workspace ID (UUID).");
|
|
24779
|
+
return id;
|
|
24780
|
+
};
|
|
24668
24781
|
connection = (values) => {
|
|
24669
24782
|
const id = values.connection?.[0];
|
|
24670
24783
|
if (!id || !isUuid(id)) throw new Error("Pass --connection <cloud-connection-id>.");
|
|
@@ -24759,12 +24872,12 @@ __export(auth_identity_exports, {
|
|
|
24759
24872
|
function authIdentityArguments(args2) {
|
|
24760
24873
|
if (args2.includes("--help") || args2.includes("-h")) return "help";
|
|
24761
24874
|
const { flags, values, positional } = parse(args2, "auth identity", ["--json"], ["--app", "--environment", "--confirm"]);
|
|
24762
|
-
const action = (positional[0] ?? "status").toLowerCase(),
|
|
24875
|
+
const action = (positional[0] ?? "status").toLowerCase(), json3 = flags.has("--json");
|
|
24763
24876
|
if (!["status", "move", "move-back", "clear"].includes(action) || positional.length > 1) throw new Error("Unknown auth identity command: " + positional.join(" ") + "\n\n" + authIdentityHelp);
|
|
24764
24877
|
if (action === "status" && (values["--environment"] !== void 0 || values["--confirm"] !== void 0)) throw new Error("--environment and --confirm apply to auth identity move.");
|
|
24765
24878
|
if (action === "clear" && values["--confirm"] !== void 0) throw new Error("--confirm applies to auth identity move and move-back.");
|
|
24766
24879
|
if (action !== "status" && values["--environment"] === void 0) throw new Error("Name the environment to " + (action === "clear" ? "clear" : "move") + " with --environment <name|id>.");
|
|
24767
|
-
return { action, ...values["--environment"] !== void 0 ? { environment: values["--environment"] } : {}, ...values["--confirm"] !== void 0 ? { confirm: values["--confirm"] } : {}, json:
|
|
24880
|
+
return { action, ...values["--environment"] !== void 0 ? { environment: values["--environment"] } : {}, ...values["--confirm"] !== void 0 ? { confirm: values["--confirm"] } : {}, json: json3 };
|
|
24768
24881
|
}
|
|
24769
24882
|
function pad3(rows) {
|
|
24770
24883
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -31236,7 +31349,7 @@ function readBody(req, limit = 300 * 1024 * 1024) {
|
|
|
31236
31349
|
req.on("error", reject);
|
|
31237
31350
|
});
|
|
31238
31351
|
}
|
|
31239
|
-
function
|
|
31352
|
+
function json2(res, status, body) {
|
|
31240
31353
|
res.writeHead(status, { "content-type": "application/json" });
|
|
31241
31354
|
res.end(JSON.stringify(body));
|
|
31242
31355
|
}
|
|
@@ -31326,21 +31439,21 @@ function startGateway(options) {
|
|
|
31326
31439
|
if (url2.pathname.startsWith("/signed/")) return await signed(req, res, url2);
|
|
31327
31440
|
if (url2.pathname.startsWith("/files/")) {
|
|
31328
31441
|
const [, , bucket, ...rest] = url2.pathname.split("/");
|
|
31329
|
-
if (!buckets.get(bucket)?.public) return
|
|
31442
|
+
if (!buckets.get(bucket)?.public) return json2(res, 404, { error: { code: "not_found", message: "Not found" } });
|
|
31330
31443
|
return sendFile(res, objectPath(bucket, rest.map(decodeURIComponent).join("/")));
|
|
31331
31444
|
}
|
|
31332
31445
|
const apiPrefix = config2.kind === "api" ? "/" : "/api";
|
|
31333
31446
|
if (config2.kind !== "web" || !options.frontendPort || url2.pathname === apiPrefix || url2.pathname.startsWith(apiPrefix === "/" ? "/" : apiPrefix + "/") || url2.pathname === (config2.server?.health ?? "/healthz")) {
|
|
31334
31447
|
const port = options.webPort();
|
|
31335
|
-
if (!port) return
|
|
31448
|
+
if (!port) return json2(res, 503, { error: { code: "starting", message: "The backend is starting or failed to start; see the terminal" } });
|
|
31336
31449
|
const user = sessionUser(req);
|
|
31337
31450
|
if (user) req.headers["x-backify-user"] = options.identity.signUser(user);
|
|
31338
31451
|
return proxy(req, res, port);
|
|
31339
31452
|
}
|
|
31340
31453
|
return proxy(req, res, options.frontendPort);
|
|
31341
31454
|
} catch (error2) {
|
|
31342
|
-
if (error2 instanceof InvalidKey) return
|
|
31343
|
-
if (!res.headersSent)
|
|
31455
|
+
if (error2 instanceof InvalidKey) return json2(res, 400, { error: { code: "invalid_key", message: error2.message } });
|
|
31456
|
+
if (!res.headersSent) json2(res, 500, { error: { code: "gateway_error", message: error2.message } });
|
|
31344
31457
|
}
|
|
31345
31458
|
});
|
|
31346
31459
|
server.on("upgrade", (req, socket, head) => {
|
|
@@ -31360,12 +31473,12 @@ function startGateway(options) {
|
|
|
31360
31473
|
response.pipe(res);
|
|
31361
31474
|
});
|
|
31362
31475
|
upstream.on("error", () => {
|
|
31363
|
-
if (!res.headersSent)
|
|
31476
|
+
if (!res.headersSent) json2(res, 502, { error: { code: "bad_gateway", message: `Nothing is listening on port ${port} yet` } });
|
|
31364
31477
|
});
|
|
31365
31478
|
req.pipe(upstream);
|
|
31366
31479
|
}
|
|
31367
31480
|
function sendFile(res, path, contentType2) {
|
|
31368
|
-
if (!existsSync14(path) || !statSync2(path).isFile()) return
|
|
31481
|
+
if (!existsSync14(path) || !statSync2(path).isFile()) return json2(res, 404, { error: { code: "not_found", message: "Not found" } });
|
|
31369
31482
|
const meta2 = existsSync14(path + ".meta.json") ? JSON.parse(readFileSync19(path + ".meta.json", "utf8")) : {};
|
|
31370
31483
|
res.writeHead(200, { "content-type": contentType2 ?? meta2.contentType ?? "application/octet-stream" });
|
|
31371
31484
|
createReadStream(path).pipe(res);
|
|
@@ -31375,7 +31488,7 @@ function startGateway(options) {
|
|
|
31375
31488
|
const returnTo = url2.searchParams.get("returnTo")?.startsWith("/") ? url2.searchParams.get("returnTo") : "/";
|
|
31376
31489
|
if (action === "me") {
|
|
31377
31490
|
const user = sessionUser(req);
|
|
31378
|
-
return user ?
|
|
31491
|
+
return user ? json2(res, 200, { id: user.id, email: user.email, name: user.name, roles: user.roles, permissions: user.permissions }) : json2(res, 401, { error: { code: "unauthenticated", message: "Not signed in" } });
|
|
31379
31492
|
}
|
|
31380
31493
|
if (action === "signout") {
|
|
31381
31494
|
res.writeHead(302, { location: "/", "set-cookie": `${SESSION}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0` });
|
|
@@ -31384,7 +31497,7 @@ function startGateway(options) {
|
|
|
31384
31497
|
if (action === "login" && req.method === "POST") {
|
|
31385
31498
|
const form = new URLSearchParams((await readBody(req, 64 * 1024)).toString());
|
|
31386
31499
|
const email2 = (form.get("email") ?? "").trim().toLowerCase();
|
|
31387
|
-
if (!/^[^@\s]+@[^@\s]+$/.test(email2)) return
|
|
31500
|
+
if (!/^[^@\s]+@[^@\s]+$/.test(email2)) return json2(res, 400, { error: { code: "invalid_email", message: "Enter an email address" } });
|
|
31388
31501
|
const list = (name2) => (form.get(name2) ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
31389
31502
|
const user = { id: "dev-" + createHmac("sha256", "backify-dev").update(email2).digest("hex").slice(0, 16), email: email2, name: form.get("name") || void 0, roles: list("roles"), permissions: list("permissions") };
|
|
31390
31503
|
res.writeHead(302, { location: form.get("returnTo")?.startsWith("/") ? form.get("returnTo") : "/", "set-cookie": `${SESSION}=${encodeURIComponent(sealed({ ...user, exp: Date.now() + 864e5 }))}; Path=/; HttpOnly; SameSite=Lax` });
|
|
@@ -31403,7 +31516,7 @@ function startGateway(options) {
|
|
|
31403
31516
|
<p><label>Permissions (comma separated)<br><input name="permissions" style="width:100%"></label></p>
|
|
31404
31517
|
<button>Sign in</button></form></body>`);
|
|
31405
31518
|
}
|
|
31406
|
-
return
|
|
31519
|
+
return json2(res, 404, { error: { code: "not_found", message: "Unknown auth endpoint" } });
|
|
31407
31520
|
}
|
|
31408
31521
|
async function broker(req, res, url2) {
|
|
31409
31522
|
if (req.headers.authorization !== "Bearer " + options.workloadToken) return brokerError(res, 401, "unauthorized", "Invalid workload token");
|
|
@@ -31413,7 +31526,7 @@ function startGateway(options) {
|
|
|
31413
31526
|
if (!config2.protection?.dynamicRules) return brokerError(res, 403, "protection_scope_required", "Declare protection.dynamicRules in backify.config.ts.");
|
|
31414
31527
|
const now = Date.now();
|
|
31415
31528
|
for (const [key2, rule2] of dynamicRules) if (Date.parse(rule2.expiresAt) <= now) dynamicRules.delete(key2);
|
|
31416
|
-
if (path.endsWith("/list")) return
|
|
31529
|
+
if (path.endsWith("/list")) return json2(res, 200, [...dynamicRules.values()]);
|
|
31417
31530
|
const ip = typeof body.ip === "string" ? body.ip : "";
|
|
31418
31531
|
if (!parseCidr(ip)) return brokerError(res, 400, "invalid_ip", "Use an IPv4 or IPv6 IP or CIDR range.");
|
|
31419
31532
|
if (path.endsWith("/remove")) {
|
|
@@ -31422,43 +31535,43 @@ function startGateway(options) {
|
|
|
31422
31535
|
dynamicRules.delete(key2);
|
|
31423
31536
|
removed++;
|
|
31424
31537
|
}
|
|
31425
|
-
return
|
|
31538
|
+
return json2(res, 200, { removed });
|
|
31426
31539
|
}
|
|
31427
31540
|
if (body.action !== "allow" && body.action !== "block" || typeof body.reason !== "string" || !body.reason.trim() || body.reason.length > 400 || body.ttl !== void 0 && (!Number.isInteger(body.ttl) || Number(body.ttl) < 1 || Number(body.ttl) > 2592e3)) return brokerError(res, 400, "invalid_rule", "Use allow/block, a short reason and TTL of 1 second to 30 days.");
|
|
31428
31541
|
const key = body.action + "|" + ip;
|
|
31429
31542
|
if (!dynamicRules.has(key) && dynamicRules.size >= 1e4) return brokerError(res, 409, "protection_rule_limit", "At most 10,000 active rules.");
|
|
31430
31543
|
const rule = { id: dynamicRules.get(key)?.id ?? crypto.randomUUID(), cidr: ip, action: body.action, reason: body.reason, expiresAt: new Date(now + Number(body.ttl ?? 86400) * 1e3).toISOString() };
|
|
31431
31544
|
dynamicRules.set(key, rule);
|
|
31432
|
-
return
|
|
31545
|
+
return json2(res, 200, rule);
|
|
31433
31546
|
}
|
|
31434
|
-
if (path === "/v1/token/renew") return
|
|
31547
|
+
if (path === "/v1/token/renew") return json2(res, 200, { token: options.workloadToken, expiresAt: new Date(Date.now() + 864e5).toISOString() });
|
|
31435
31548
|
if (path === "/v1/storage/credentials" || path === "/v1/storage/sign") {
|
|
31436
31549
|
const bucket = String(body.bucket);
|
|
31437
31550
|
if (!buckets.has(bucket)) return brokerError(res, 403, "bucket_not_declared", `Bucket ${bucket} is not declared in backify.config.ts storage.buckets`);
|
|
31438
|
-
if (path === "/v1/storage/credentials") return
|
|
31551
|
+
if (path === "/v1/storage/credentials") return json2(res, 200, { provider: "local", endpoint: `http://127.0.0.1:${options.port}/storage`, container: "local", prefix: bucket + "/", credential: storageCredential, expiresAt: new Date(Date.now() + 36e5).toISOString() });
|
|
31439
31552
|
const expires = Date.now() + Number(body.expiresInSeconds ?? 300) * 1e3;
|
|
31440
31553
|
objectPath(bucket, String(body.key));
|
|
31441
31554
|
const token2 = sealed({ kind: "signed", bucket, key: String(body.key), operation: body.operation, contentType: body.contentType, exp: expires });
|
|
31442
|
-
return
|
|
31555
|
+
return json2(res, 200, { url: `http://localhost:${options.port}/signed/${encodeURIComponent(token2)}`, method: body.operation === "upload" ? "PUT" : "GET", headers: body.contentType ? { "content-type": String(body.contentType) } : {}, expiresAt: new Date(expires).toISOString() });
|
|
31443
31556
|
}
|
|
31444
31557
|
if (path === "/v1/mail/send") {
|
|
31445
31558
|
const id = "mail_" + randomBytes4(6).toString("hex");
|
|
31446
31559
|
writeFileSync12(join17(mailDir, id + ".json"), JSON.stringify(body, null, 2));
|
|
31447
31560
|
options.log(`mail to ${JSON.stringify(body.to)}: "${String(body.subject)}" (saved in .backify/dev/mail/${id}.json)`);
|
|
31448
|
-
return
|
|
31561
|
+
return json2(res, 200, { id, status: "sent", from: "noreply@localhost" });
|
|
31449
31562
|
}
|
|
31450
31563
|
if (path === "/v1/http/fetch") {
|
|
31451
31564
|
const target = new URL(String(body.url));
|
|
31452
31565
|
if (target.protocol !== "https:") return brokerError(res, 403, "https_required", `Outbound HTTP to ${target.hostname} must use https`);
|
|
31453
31566
|
const response = await fetch(target, { method: String(body.method ?? "GET"), headers: body.headers, body: body.body, signal: AbortSignal.timeout(Number(body.timeoutSeconds ?? 30) * 1e3) });
|
|
31454
31567
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
31455
|
-
return
|
|
31568
|
+
return json2(res, 200, { status: response.status, headers: Object.fromEntries(response.headers), body: bytes.toString("base64"), encoding: "base64" });
|
|
31456
31569
|
}
|
|
31457
31570
|
if (path.startsWith("/v1/ai/") || path.startsWith("/v1/integrations/")) return brokerError(res, 501, "not_available_locally", `${path.split("/")[2]} is not available in local development yet; test it in a preview environment`);
|
|
31458
31571
|
return brokerError(res, 404, "not_found", "Unknown broker endpoint " + path);
|
|
31459
31572
|
}
|
|
31460
31573
|
async function storage(req, res, url2) {
|
|
31461
|
-
if (req.headers.authorization !== "Bearer " + storageCredential) return
|
|
31574
|
+
if (req.headers.authorization !== "Bearer " + storageCredential) return json2(res, 403, {});
|
|
31462
31575
|
const rest = url2.pathname.slice("/storage/local".length);
|
|
31463
31576
|
if (rest === "" || rest === "/") {
|
|
31464
31577
|
const prefix = url2.searchParams.get("prefix") ?? "";
|
|
@@ -31471,7 +31584,7 @@ function startGateway(options) {
|
|
|
31471
31584
|
}
|
|
31472
31585
|
};
|
|
31473
31586
|
walk2(storageDir);
|
|
31474
|
-
return
|
|
31587
|
+
return json2(res, 200, { keys: files.filter((f) => f.startsWith(prefix)).sort() });
|
|
31475
31588
|
}
|
|
31476
31589
|
const [bucket, ...key] = rest.slice(1).split("/").map(decodeURIComponent);
|
|
31477
31590
|
const path = objectPath(bucket, key.join("/"));
|
|
@@ -31492,7 +31605,7 @@ function startGateway(options) {
|
|
|
31492
31605
|
}
|
|
31493
31606
|
async function signed(req, res, url2) {
|
|
31494
31607
|
const grant = unseal(decodeURIComponent(url2.pathname.slice("/signed/".length)));
|
|
31495
|
-
if (!grant || grant.kind !== "signed") return
|
|
31608
|
+
if (!grant || grant.kind !== "signed") return json2(res, 403, { error: { code: "expired", message: "The signed URL is invalid or expired" } });
|
|
31496
31609
|
const path = objectPath(grant.bucket, grant.key);
|
|
31497
31610
|
if (grant.operation === "upload" && req.method === "PUT") {
|
|
31498
31611
|
mkdirSync6(dirname7(path), { recursive: true });
|
|
@@ -31502,7 +31615,7 @@ function startGateway(options) {
|
|
|
31502
31615
|
return res.end();
|
|
31503
31616
|
}
|
|
31504
31617
|
if (grant.operation === "download" && req.method === "GET") return sendFile(res, path);
|
|
31505
|
-
return
|
|
31618
|
+
return json2(res, 405, { error: { code: "method_not_allowed", message: "Wrong method for this signed URL" } });
|
|
31506
31619
|
}
|
|
31507
31620
|
return new Promise((resolveServer, reject) => {
|
|
31508
31621
|
server.once("error", reject);
|
|
@@ -31521,7 +31634,7 @@ var init_local_gateway = __esm({
|
|
|
31521
31634
|
super("Invalid object key");
|
|
31522
31635
|
}
|
|
31523
31636
|
};
|
|
31524
|
-
brokerError = (res, status, code, message) =>
|
|
31637
|
+
brokerError = (res, status, code, message) => json2(res, status, { error: { code, message, requestId: randomBytes4(6).toString("hex") } });
|
|
31525
31638
|
}
|
|
31526
31639
|
});
|
|
31527
31640
|
|
|
@@ -31810,7 +31923,7 @@ function extractSettings(args2) {
|
|
|
31810
31923
|
}
|
|
31811
31924
|
return { rest, settings };
|
|
31812
31925
|
}
|
|
31813
|
-
function replacementsArguments(positional, flags, values, settings,
|
|
31926
|
+
function replacementsArguments(positional, flags, values, settings, json3, yes) {
|
|
31814
31927
|
const sub = (positional[1] ?? "list").toLowerCase();
|
|
31815
31928
|
if (!["list", "add", "verify", "remove"].includes(sub)) throw new Error("Unknown replacements command: " + positional.slice(1).join(" ") + "\n\n" + handoffHelp);
|
|
31816
31929
|
const takesId = sub === "verify" || sub === "remove";
|
|
@@ -31819,7 +31932,7 @@ function replacementsArguments(positional, flags, values, settings, json2, yes)
|
|
|
31819
31932
|
if (values["--confirm"] !== void 0 || values["--out"] !== void 0) throw new Error("--confirm and --out do not apply to handoff replacements.");
|
|
31820
31933
|
if (sub !== "add" && (addOnlyFlags.some((name2) => values[name2] !== void 0) || Object.keys(settings).length > 0 || flags.has("--consent"))) throw new Error(addOnlyMessage);
|
|
31821
31934
|
if (yes && sub !== "remove") throw new Error("--yes applies to handoff replacements remove. Adding a replacement is consented with --consent.");
|
|
31822
|
-
if (sub !== "add") return { action: "replacements", yes, json:
|
|
31935
|
+
if (sub !== "add") return { action: "replacements", yes, json: json3, replacement: { action: sub, ...takesId ? { id: positional[2] } : {}, settings: {}, consent: false } };
|
|
31823
31936
|
const kind2 = values["--kind"]?.toLowerCase(), secretName = values["--secret-name"];
|
|
31824
31937
|
if (!values["--environment"]) throw new Error("Name the environment with --environment <name|id|kind>.");
|
|
31825
31938
|
if (!kind2 || !replacementKinds.includes(kind2)) throw new Error("Choose what you are replacing with --kind " + replacementKinds.join(", ") + ".");
|
|
@@ -31827,22 +31940,22 @@ function replacementsArguments(positional, flags, values, settings, json2, yes)
|
|
|
31827
31940
|
if (!validSecretName(secretName)) throw new Error("--secret-name is the name of a vault secret: letters, digits and hyphens, at most 127, and not starting with backify-rt-. It is not the secret's value.");
|
|
31828
31941
|
const subject = values["--subject"] ?? (kind2 === "mail" || kind2 === "ai" ? kind2 : void 0);
|
|
31829
31942
|
if (!subject) throw new Error("Name what the replacement is for with --subject: the connection ID for an integration, entra or google for a sign-in provider.");
|
|
31830
|
-
return { action: "replacements", yes, json:
|
|
31943
|
+
return { action: "replacements", yes, json: json3, replacement: { action: "add", environment: values["--environment"], kind: kind2, subject, settings, secretName, consent: flags.has("--consent") } };
|
|
31831
31944
|
}
|
|
31832
31945
|
function handoffArguments(args2) {
|
|
31833
31946
|
if (args2.includes("--help") || args2.includes("-h")) return "help";
|
|
31834
31947
|
const { rest, settings } = extractSettings(args2);
|
|
31835
31948
|
const { flags, values, positional } = parse(rest, "handoff", ["--json", "--yes", "--consent"], ["--app", "--confirm", "--out", "--azure-session", ...addOnlyFlags]);
|
|
31836
|
-
const action = (positional[0] ?? "status").toLowerCase(),
|
|
31949
|
+
const action = (positional[0] ?? "status").toLowerCase(), json3 = flags.has("--json"), yes = flags.has("--yes");
|
|
31837
31950
|
const azureSessionId = values["--azure-session"];
|
|
31838
31951
|
if (azureSessionId !== void 0 && (action !== "start" || !uuid12.test(azureSessionId))) throw new Error("--azure-session requires a valid Azure session ID and applies to handoff start.");
|
|
31839
|
-
if (action === "replacements") return replacementsArguments(positional, flags, values, settings,
|
|
31952
|
+
if (action === "replacements") return replacementsArguments(positional, flags, values, settings, json3, yes);
|
|
31840
31953
|
if (Object.keys(settings).length || flags.has("--consent") || addOnlyFlags.some((name2) => values[name2] !== void 0)) throw new Error(addOnlyMessage);
|
|
31841
31954
|
if (!["status", "check", "request", "start", "abort", "foundation", "package"].includes(action) || positional.length > 1) throw new Error("Unknown handoff command: " + positional.join(" ") + "\n\n" + handoffHelp);
|
|
31842
31955
|
if (values["--confirm"] !== void 0 && action !== "request") throw new Error("--confirm applies to handoff request.");
|
|
31843
31956
|
if (values["--out"] !== void 0 && action !== "package" && action !== "foundation") throw new Error("--out applies to handoff foundation and handoff package.");
|
|
31844
31957
|
if (yes && action !== "start" && action !== "abort") throw new Error(action === "request" ? "Requesting a handoff is confirmed with --confirm <application-slug>, not --yes." : "--yes applies to handoff start and abort.");
|
|
31845
|
-
return { action, ...values["--confirm"] !== void 0 ? { confirm: values["--confirm"] } : {}, ...values["--out"] !== void 0 ? { out: values["--out"] } : {}, ...azureSessionId !== void 0 ? { azureSessionId } : {}, yes, json:
|
|
31958
|
+
return { action, ...values["--confirm"] !== void 0 ? { confirm: values["--confirm"] } : {}, ...values["--out"] !== void 0 ? { out: values["--out"] } : {}, ...azureSessionId !== void 0 ? { azureSessionId } : {}, yes, json: json3 };
|
|
31846
31959
|
}
|
|
31847
31960
|
function pad4(rows) {
|
|
31848
31961
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -33210,7 +33323,7 @@ var help = [
|
|
|
33210
33323
|
"Account: signup [--name <organization>] [--plan <plan>] | login | logout | connect | disconnect | status | apps",
|
|
33211
33324
|
"Coding: tools configure --agent <tool> [--transport http|stdio] [--config <path>] [--dry-run] | mcp [--organization <organization-id>]",
|
|
33212
33325
|
"Org admin: ops search [<query>] | ops describe <operation-id> | ops get|run <operation-id> [--param <name>=<value>] [--body <file>] [--yes] [--organization <id>] [--json]",
|
|
33213
|
-
"Org tasks: task start <kind> [--draft <json>] | task get|wait|open <id> | github connect | azure connect|reconnect|update-runtime|runtime-upgrade|grant-scope|rescope-grants|uninstall|remove | org | billing | members add|invite|list|invitations|join-links|domains (backify task --help)",
|
|
33326
|
+
"Org tasks: task start <kind> [--draft <json>] | task get|wait|open <id> | github connect | azure connect|reconnect|update-runtime|runtime-upgrade|automatic-upgrades|grant-scope|rescope-grants|uninstall|remove | org | billing | members add|invite|list|invitations|join-links|domains (backify task --help)",
|
|
33214
33327
|
"Delivery: pull | report [--check] | ship [--production-deploy|--preview-only] [--dry-run] | deploy [<application-id>] [<source-revision>] | request | workflow refresh",
|
|
33215
33328
|
" ship deploys to the earliest activated environment (production when it is the only one); --production-deploy then promotes",
|
|
33216
33329
|
" through every activated environment to production; --preview-only stops after the first environment",
|
|
@@ -33296,7 +33409,7 @@ async function main() {
|
|
|
33296
33409
|
const controller = new AbortController(), stop = () => controller.abort();
|
|
33297
33410
|
process.once("SIGINT", stop);
|
|
33298
33411
|
process.once("SIGTERM", stop);
|
|
33299
|
-
const
|
|
33412
|
+
const json3 = args.includes("--json");
|
|
33300
33413
|
try {
|
|
33301
33414
|
const { result } = await runTaskCommand2(command, args, {
|
|
33302
33415
|
configPath,
|
|
@@ -33308,10 +33421,10 @@ async function main() {
|
|
|
33308
33421
|
progress: (message) => console.error(message),
|
|
33309
33422
|
signal: controller.signal
|
|
33310
33423
|
});
|
|
33311
|
-
console.log(
|
|
33424
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33312
33425
|
if (result.exitCode !== void 0) process.exitCode = result.exitCode;
|
|
33313
33426
|
} catch (error2) {
|
|
33314
|
-
if (!(error2 instanceof OpsError2) || !
|
|
33427
|
+
if (!(error2 instanceof OpsError2) || !json3) throw error2;
|
|
33315
33428
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33316
33429
|
process.exitCode = 1;
|
|
33317
33430
|
} finally {
|
|
@@ -33366,7 +33479,7 @@ async function main() {
|
|
|
33366
33479
|
if (args[0] === "identity") {
|
|
33367
33480
|
const identity = await Promise.resolve().then(() => (init_auth_identity(), auth_identity_exports));
|
|
33368
33481
|
const { CommandError: CommandError2 } = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33369
|
-
const
|
|
33482
|
+
const json3 = args.includes("--json");
|
|
33370
33483
|
try {
|
|
33371
33484
|
const options2 = identity.authIdentityArguments(args.slice(1));
|
|
33372
33485
|
if (options2 === "help") {
|
|
@@ -33374,10 +33487,10 @@ async function main() {
|
|
|
33374
33487
|
break;
|
|
33375
33488
|
}
|
|
33376
33489
|
const result = await identity.runAuthIdentity(call, applicationGuid(option("--app") ?? projectApplication()), options2);
|
|
33377
|
-
console.log(
|
|
33490
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33378
33491
|
if (result.exitCode !== void 0) process.exitCode = result.exitCode;
|
|
33379
33492
|
} catch (error2) {
|
|
33380
|
-
if (!(error2 instanceof CommandError2) || !
|
|
33493
|
+
if (!(error2 instanceof CommandError2) || !json3) throw error2;
|
|
33381
33494
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33382
33495
|
process.exitCode = 1;
|
|
33383
33496
|
}
|
|
@@ -33686,7 +33799,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33686
33799
|
case "promote": {
|
|
33687
33800
|
const flow = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33688
33801
|
const { terminalConfirm: terminalConfirm2 } = await Promise.resolve().then(() => (init_ops(), ops_exports));
|
|
33689
|
-
const
|
|
33802
|
+
const json3 = args.includes("--json");
|
|
33690
33803
|
try {
|
|
33691
33804
|
const options = command === "environments" ? flow.environmentsArguments(args) : command === "promote" ? flow.promoteArguments(args) : args.includes("--help") || args.includes("-h") ? "help" : void 0;
|
|
33692
33805
|
if (options === "help") {
|
|
@@ -33696,10 +33809,10 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33696
33809
|
if (command === "release-flow" && args.some((value, index) => value !== "--json" && value !== "--app" && args[index - 1] !== "--app")) throw new Error(flow.releaseFlowHelp);
|
|
33697
33810
|
const application = applicationGuid(option("--app") ?? projectApplication()), context2 = { confirm: terminalConfirm2() };
|
|
33698
33811
|
const result = command === "environments" ? await flow.runEnvironments(call, application, options, context2) : command === "promote" ? await flow.promote(call, application, options, context2) : await flow.releaseFlow(call, application);
|
|
33699
|
-
console.log(
|
|
33812
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33700
33813
|
if (result.exitCode !== void 0) process.exitCode = result.exitCode;
|
|
33701
33814
|
} catch (error2) {
|
|
33702
|
-
if (!(error2 instanceof flow.CommandError) || !
|
|
33815
|
+
if (!(error2 instanceof flow.CommandError) || !json3) throw error2;
|
|
33703
33816
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33704
33817
|
process.exitCode = 1;
|
|
33705
33818
|
}
|
|
@@ -33710,7 +33823,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33710
33823
|
const hostingModule = await Promise.resolve().then(() => (init_hosting(), hosting_exports));
|
|
33711
33824
|
const { CommandError: CommandError2 } = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33712
33825
|
const { terminalConfirm: terminalConfirm2 } = await Promise.resolve().then(() => (init_ops(), ops_exports));
|
|
33713
|
-
const
|
|
33826
|
+
const json3 = args.includes("--json");
|
|
33714
33827
|
try {
|
|
33715
33828
|
const options = command === "hosting" ? hostingModule.hostingArguments(args) : hostingModule.rollbackArguments(args);
|
|
33716
33829
|
if (options === "help") {
|
|
@@ -33719,9 +33832,9 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33719
33832
|
}
|
|
33720
33833
|
const application = applicationGuid(option("--app") ?? projectApplication());
|
|
33721
33834
|
const result = command === "hosting" ? await hostingModule.runHosting(call, application) : await hostingModule.runRollback(call, application, options, { confirm: terminalConfirm2() });
|
|
33722
|
-
console.log(
|
|
33835
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33723
33836
|
} catch (error2) {
|
|
33724
|
-
if (!(error2 instanceof CommandError2) || !
|
|
33837
|
+
if (!(error2 instanceof CommandError2) || !json3) throw error2;
|
|
33725
33838
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33726
33839
|
process.exitCode = 1;
|
|
33727
33840
|
}
|
|
@@ -33731,7 +33844,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33731
33844
|
const handoff2 = await Promise.resolve().then(() => (init_handoff(), handoff_exports));
|
|
33732
33845
|
const { CommandError: CommandError2 } = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33733
33846
|
const { terminalConfirm: terminalConfirm2 } = await Promise.resolve().then(() => (init_ops(), ops_exports));
|
|
33734
|
-
const
|
|
33847
|
+
const json3 = args.includes("--json");
|
|
33735
33848
|
try {
|
|
33736
33849
|
const options = handoff2.handoffArguments(args);
|
|
33737
33850
|
if (options === "help") {
|
|
@@ -33739,10 +33852,10 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33739
33852
|
break;
|
|
33740
33853
|
}
|
|
33741
33854
|
const result = await handoff2.runHandoff(call, applicationGuid(option("--app") ?? projectApplication()), options, { confirm: terminalConfirm2() });
|
|
33742
|
-
console.log(
|
|
33855
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33743
33856
|
if (result.exitCode !== void 0) process.exitCode = result.exitCode;
|
|
33744
33857
|
} catch (error2) {
|
|
33745
|
-
if (!(error2 instanceof CommandError2) || !
|
|
33858
|
+
if (!(error2 instanceof CommandError2) || !json3) throw error2;
|
|
33746
33859
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33747
33860
|
process.exitCode = 1;
|
|
33748
33861
|
}
|
|
@@ -33750,7 +33863,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33750
33863
|
}
|
|
33751
33864
|
case "logs": {
|
|
33752
33865
|
const history = await Promise.resolve().then(() => (init_logs_history(), logs_history_exports));
|
|
33753
|
-
const
|
|
33866
|
+
const json3 = args.includes("--json");
|
|
33754
33867
|
try {
|
|
33755
33868
|
const options = history.logsArguments(args);
|
|
33756
33869
|
if (options === "help") {
|
|
@@ -33759,10 +33872,10 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33759
33872
|
}
|
|
33760
33873
|
const application = applicationGuid(option("--app") ?? projectApplication());
|
|
33761
33874
|
const result = options.action === "recent" ? await history.runLogsRecent(call, application, options) : await history.runLogsHistory(call, application, options);
|
|
33762
|
-
console.log(
|
|
33875
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33763
33876
|
} catch (error2) {
|
|
33764
33877
|
const flow = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33765
|
-
if (!(error2 instanceof flow.CommandError) || !
|
|
33878
|
+
if (!(error2 instanceof flow.CommandError) || !json3) throw error2;
|
|
33766
33879
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33767
33880
|
process.exitCode = 1;
|
|
33768
33881
|
}
|
|
@@ -33771,7 +33884,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33771
33884
|
case "monitoring":
|
|
33772
33885
|
case "operation": {
|
|
33773
33886
|
const flow = await Promise.resolve().then(() => (init_release_flow(), release_flow_exports));
|
|
33774
|
-
const
|
|
33887
|
+
const json3 = args.includes("--json");
|
|
33775
33888
|
try {
|
|
33776
33889
|
let result;
|
|
33777
33890
|
if (command === "monitoring") {
|
|
@@ -33789,12 +33902,12 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
33789
33902
|
console.log(progress.operationHelp);
|
|
33790
33903
|
break;
|
|
33791
33904
|
}
|
|
33792
|
-
result = await progress.runOperation(call, options, { progress:
|
|
33905
|
+
result = await progress.runOperation(call, options, { progress: json3 ? void 0 : (text2) => console.log(text2) });
|
|
33793
33906
|
}
|
|
33794
|
-
console.log(
|
|
33907
|
+
console.log(json3 ? JSON.stringify(result.value, null, 2) : result.text);
|
|
33795
33908
|
if (result.exitCode !== void 0) process.exitCode = result.exitCode;
|
|
33796
33909
|
} catch (error2) {
|
|
33797
|
-
if (!(error2 instanceof flow.CommandError) || !
|
|
33910
|
+
if (!(error2 instanceof flow.CommandError) || !json3) throw error2;
|
|
33798
33911
|
console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: error2.message, code: error2.code, ...error2.details }, null, 2));
|
|
33799
33912
|
process.exitCode = 1;
|
|
33800
33913
|
}
|