@intentius/behold 0.29.19 → 0.29.20
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/AGENTS.md +15 -0
- package/dist/cli.js +615 -417
- package/package.json +1 -1
- package/web/kiosk-metrics.js +281 -0
- package/web/kiosk-metrics.test.js +94 -0
- package/web/kiosk.html +3 -0
package/dist/cli.js
CHANGED
|
@@ -25,9 +25,9 @@ var __export = (target, all) => {
|
|
|
25
25
|
};
|
|
26
26
|
var __copyProps = (to, from, except, desc) => {
|
|
27
27
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let
|
|
29
|
-
if (!__hasOwnProp.call(to,
|
|
30
|
-
__defProp(to,
|
|
28
|
+
for (let key2 of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
30
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
31
31
|
}
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
@@ -54,9 +54,9 @@ function recordRead(sample) {
|
|
|
54
54
|
totals.queuedMs += sample.queuedMs;
|
|
55
55
|
totals.runningMs += sample.runningMs;
|
|
56
56
|
byOutcome[sample.outcome]++;
|
|
57
|
-
const
|
|
58
|
-
recent.delete(
|
|
59
|
-
recent.set(
|
|
57
|
+
const key2 = `${sample.dir}\0${sample.what}`;
|
|
58
|
+
recent.delete(key2);
|
|
59
|
+
recent.set(key2, sample);
|
|
60
60
|
if (recent.size > RECENT_LIMIT) recent.delete(recent.keys().next().value);
|
|
61
61
|
}
|
|
62
62
|
function readStats() {
|
|
@@ -132,11 +132,11 @@ var init_read_scheduler = __esm({
|
|
|
132
132
|
active = 0;
|
|
133
133
|
pending = /* @__PURE__ */ new Map();
|
|
134
134
|
queue = [];
|
|
135
|
-
read(
|
|
135
|
+
read(key2, run3, signal, label) {
|
|
136
136
|
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
137
|
-
let job = this.pending.get(
|
|
137
|
+
let job = this.pending.get(key2);
|
|
138
138
|
if (job?.controller.signal.aborted) {
|
|
139
|
-
this.pending.delete(
|
|
139
|
+
this.pending.delete(key2);
|
|
140
140
|
job = void 0;
|
|
141
141
|
}
|
|
142
142
|
if (job) {
|
|
@@ -153,7 +153,7 @@ var init_read_scheduler = __esm({
|
|
|
153
153
|
reject = no;
|
|
154
154
|
});
|
|
155
155
|
job = {
|
|
156
|
-
key,
|
|
156
|
+
key: key2,
|
|
157
157
|
run: run3,
|
|
158
158
|
promise,
|
|
159
159
|
resolve: resolve36,
|
|
@@ -165,7 +165,7 @@ var init_read_scheduler = __esm({
|
|
|
165
165
|
enqueuedAt: Date.now(),
|
|
166
166
|
expired: false
|
|
167
167
|
};
|
|
168
|
-
this.pending.set(
|
|
168
|
+
this.pending.set(key2, job);
|
|
169
169
|
this.queue.push(job);
|
|
170
170
|
}
|
|
171
171
|
const shared2 = job;
|
|
@@ -183,7 +183,7 @@ var init_read_scheduler = __esm({
|
|
|
183
183
|
const abort = () => {
|
|
184
184
|
finish(signal?.reason, void 0, true);
|
|
185
185
|
if (shared2.users === 0) {
|
|
186
|
-
if (this.pending.get(
|
|
186
|
+
if (this.pending.get(key2) === shared2) this.pending.delete(key2);
|
|
187
187
|
shared2.controller.abort(signal?.reason);
|
|
188
188
|
if (!shared2.started) {
|
|
189
189
|
this.queue = this.queue.filter((item) => item !== shared2);
|
|
@@ -911,7 +911,7 @@ async function createK8sClient(options2 = {}) {
|
|
|
911
911
|
async function send(path, method, opts = {}) {
|
|
912
912
|
const ctx = configuration.baseServer.makeRequestContext(path, method);
|
|
913
913
|
ctx.setHeaderParam("Accept", "application/json");
|
|
914
|
-
for (const [
|
|
914
|
+
for (const [key2, value] of Object.entries(opts.query ?? {})) ctx.setQueryParam(key2, value);
|
|
915
915
|
if (opts.body !== void 0) {
|
|
916
916
|
ctx.setHeaderParam("Content-Type", opts.contentType ?? "application/json");
|
|
917
917
|
ctx.setBody(opts.body);
|
|
@@ -1128,7 +1128,7 @@ async function createK8sClient(options2 = {}) {
|
|
|
1128
1128
|
async function openStream(path, query, signal, target) {
|
|
1129
1129
|
const ctx = configuration.baseServer.makeRequestContext(path, "GET");
|
|
1130
1130
|
ctx.setHeaderParam("Accept", "application/json");
|
|
1131
|
-
for (const [
|
|
1131
|
+
for (const [key2, value] of Object.entries(query)) ctx.setQueryParam(key2, value);
|
|
1132
1132
|
ctx.setSignal(signal);
|
|
1133
1133
|
await kc.applySecurityAuthentication(ctx);
|
|
1134
1134
|
let response;
|
|
@@ -1442,12 +1442,12 @@ function fieldPathsOf(fieldsV1, prefix = "") {
|
|
|
1442
1442
|
}
|
|
1443
1443
|
function collect(node, prefix, into) {
|
|
1444
1444
|
if (node === null || typeof node !== "object" || Array.isArray(node)) return into;
|
|
1445
|
-
for (const [
|
|
1446
|
-
if (
|
|
1445
|
+
for (const [key2, child] of Object.entries(node)) {
|
|
1446
|
+
if (key2 === ".") {
|
|
1447
1447
|
if (prefix !== "") into.add(prefix);
|
|
1448
1448
|
continue;
|
|
1449
1449
|
}
|
|
1450
|
-
const segment = renderSegment(
|
|
1450
|
+
const segment = renderSegment(key2);
|
|
1451
1451
|
if (segment === void 0) continue;
|
|
1452
1452
|
const path = `${prefix}${segment}`;
|
|
1453
1453
|
into.add(path);
|
|
@@ -1455,11 +1455,11 @@ function collect(node, prefix, into) {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
return into;
|
|
1457
1457
|
}
|
|
1458
|
-
function renderSegment(
|
|
1459
|
-
if (
|
|
1460
|
-
if (
|
|
1461
|
-
if (
|
|
1462
|
-
if (
|
|
1458
|
+
function renderSegment(key2) {
|
|
1459
|
+
if (key2.startsWith("f:")) return `.${key2.slice(2)}`;
|
|
1460
|
+
if (key2.startsWith("i:")) return `[${key2.slice(2)}]`;
|
|
1461
|
+
if (key2.startsWith("v:")) return `[=${key2.slice(2)}]`;
|
|
1462
|
+
if (key2.startsWith("k:")) return renderKeySegment(key2.slice(2));
|
|
1463
1463
|
return void 0;
|
|
1464
1464
|
}
|
|
1465
1465
|
function renderKeySegment(json2) {
|
|
@@ -1984,9 +1984,9 @@ function carveReportToIr(report) {
|
|
|
1984
1984
|
const from = direction === "inbound" ? e.survivor : e.carved;
|
|
1985
1985
|
const to = direction === "inbound" ? e.carved : e.survivor;
|
|
1986
1986
|
if (!known.has(from) || !known.has(to)) continue;
|
|
1987
|
-
const
|
|
1988
|
-
if (seen.has(
|
|
1989
|
-
seen.add(
|
|
1987
|
+
const key2 = `${from}|${to}`;
|
|
1988
|
+
if (seen.has(key2)) continue;
|
|
1989
|
+
seen.add(key2);
|
|
1990
1990
|
edges.push({
|
|
1991
1991
|
from,
|
|
1992
1992
|
to,
|
|
@@ -2047,9 +2047,9 @@ function typeOfAddress(address, block) {
|
|
|
2047
2047
|
function readsOf(body) {
|
|
2048
2048
|
if (!body || typeof body !== "object" || Array.isArray(body)) return void 0;
|
|
2049
2049
|
const b = body;
|
|
2050
|
-
for (const
|
|
2051
|
-
const v = b[
|
|
2052
|
-
if (typeof v === "string" && v) return `${
|
|
2050
|
+
for (const key2 of ["name", "bucket", "arn", "id", "domain", "repository"]) {
|
|
2051
|
+
const v = b[key2];
|
|
2052
|
+
if (typeof v === "string" && v) return `${key2} ${v}`;
|
|
2053
2053
|
}
|
|
2054
2054
|
return void 0;
|
|
2055
2055
|
}
|
|
@@ -2072,8 +2072,8 @@ function groupTerraformByRoot(ir) {
|
|
|
2072
2072
|
if (!root) continue;
|
|
2073
2073
|
const at2 = n.id.indexOf(`/${root}/`);
|
|
2074
2074
|
const prefix = at2 > 0 ? n.id.slice(0, at2) : "";
|
|
2075
|
-
const
|
|
2076
|
-
(roots.get(
|
|
2075
|
+
const key2 = `${prefix} ${root}`;
|
|
2076
|
+
(roots.get(key2) ?? roots.set(key2, { prefix, root, ids: [] }).get(key2)).ids.push(n.id);
|
|
2077
2077
|
}
|
|
2078
2078
|
if (roots.size === 0) return ir;
|
|
2079
2079
|
const byStack = { ...ir.groups.byStack ?? {} };
|
|
@@ -2305,9 +2305,9 @@ function waveTitles(ir, decl) {
|
|
|
2305
2305
|
const jobs = componentJobs(decl);
|
|
2306
2306
|
const order = decl.pipeline.jobs.map((j) => j.name);
|
|
2307
2307
|
const out = {};
|
|
2308
|
-
for (const [
|
|
2308
|
+
for (const [key2, members] of Object.entries(byWave)) {
|
|
2309
2309
|
const names = new Set(members.map((m) => jobs[m]?.jobName).filter((n) => !!n));
|
|
2310
|
-
if (names.size) out[
|
|
2310
|
+
if (names.size) out[key2] = order.filter((n) => names.has(n)).join(" + ");
|
|
2311
2311
|
}
|
|
2312
2312
|
return out;
|
|
2313
2313
|
}
|
|
@@ -2944,9 +2944,9 @@ function joinLexiconEdges(edges, index, root = LEXICON_ROOT) {
|
|
|
2944
2944
|
const seen = /* @__PURE__ */ new Set();
|
|
2945
2945
|
const add = (from, to, viaAttr) => {
|
|
2946
2946
|
if (from === to) return;
|
|
2947
|
-
const
|
|
2948
|
-
if (seen.has(
|
|
2949
|
-
seen.add(
|
|
2947
|
+
const key2 = `${from}\0${to}`;
|
|
2948
|
+
if (seen.has(key2)) return;
|
|
2949
|
+
seen.add(key2);
|
|
2950
2950
|
out.push({ from, to, kind: "ref", ...viaAttr ? { viaAttr } : {}, inferred: true });
|
|
2951
2951
|
};
|
|
2952
2952
|
for (const e of edges) {
|
|
@@ -3205,7 +3205,7 @@ async function choudoufuLiveIr(dir, opts, run3 = captureChoudoufu) {
|
|
|
3205
3205
|
return paintChoudoufu(liveCheckToIr(check), ls, plan, check.estate);
|
|
3206
3206
|
}
|
|
3207
3207
|
function choudoufuDiffNodes(check, ls, plan, member, drift) {
|
|
3208
|
-
const
|
|
3208
|
+
const key2 = (address) => member ? `${member}/${address}` : address;
|
|
3209
3209
|
const out = {};
|
|
3210
3210
|
const seen = /* @__PURE__ */ new Set();
|
|
3211
3211
|
for (const i of check.instances) {
|
|
@@ -3213,7 +3213,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
|
|
|
3213
3213
|
const v = verdictFor(i.address, ls, plan);
|
|
3214
3214
|
const health = !v ? "unknown" : v._status === "good" ? "healthy" : v._status === "warn" ? "degraded" : "unknown";
|
|
3215
3215
|
const detail = !v ? "not mentioned by live-plan or live-ls" : typeof v.attrs.bound === "string" ? `bound ${v.attrs.bound}` : typeof v.attrs.omission === "string" ? `${v.attrs.omission}: ${String(v.attrs.detail ?? "")}` : v._unobserved ?? (typeof v.attrs.listing === "string" ? v.attrs.listing : void 0);
|
|
3216
|
-
out[
|
|
3216
|
+
out[key2(i.address)] = {
|
|
3217
3217
|
observed: v ? {
|
|
3218
3218
|
type: i.type,
|
|
3219
3219
|
...v.physicalId ? { physicalId: v.physicalId } : {},
|
|
@@ -3234,7 +3234,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
|
|
|
3234
3234
|
}
|
|
3235
3235
|
for (const item of ls.items) {
|
|
3236
3236
|
if (!item.address || seen.has(item.address)) continue;
|
|
3237
|
-
out[
|
|
3237
|
+
out[key2(item.address)] = {
|
|
3238
3238
|
observed: { type: item.type, physicalId: item.id, ownership: "owned", attributes: { tags: item.tags, ...item.slot ? { slot: item.slot } : {} } },
|
|
3239
3239
|
diff: null,
|
|
3240
3240
|
health: "degraded",
|
|
@@ -3420,8 +3420,8 @@ function readInfo(cfg) {
|
|
|
3420
3420
|
...stacks ? { stacks } : {}
|
|
3421
3421
|
};
|
|
3422
3422
|
}
|
|
3423
|
-
function parseStringArray(content,
|
|
3424
|
-
const arr = content.match(new RegExp(`\\b${
|
|
3423
|
+
function parseStringArray(content, key2) {
|
|
3424
|
+
const arr = content.match(new RegExp(`\\b${key2}\\s*:\\s*\\[([^\\]]*)\\]`));
|
|
3425
3425
|
if (!arr) return [];
|
|
3426
3426
|
return [...arr[1].matchAll(/["'`]([^"'`]+)["'`]/g)].map((m) => m[1]);
|
|
3427
3427
|
}
|
|
@@ -3451,8 +3451,8 @@ function parseK8sProfileNames(content) {
|
|
|
3451
3451
|
for (const ch of body) {
|
|
3452
3452
|
if (ch === "{") {
|
|
3453
3453
|
if (d === 0) {
|
|
3454
|
-
const
|
|
3455
|
-
if (
|
|
3454
|
+
const key2 = segment.match(/(["'`]?)([\w.-]+)\1\s*:\s*$/);
|
|
3455
|
+
if (key2) names.push(key2[2]);
|
|
3456
3456
|
segment = "";
|
|
3457
3457
|
}
|
|
3458
3458
|
d++;
|
|
@@ -3464,8 +3464,8 @@ function parseK8sProfileNames(content) {
|
|
|
3464
3464
|
}
|
|
3465
3465
|
return names;
|
|
3466
3466
|
}
|
|
3467
|
-
function parseStringLiteral(content,
|
|
3468
|
-
const m = content.match(new RegExp(`\\b${
|
|
3467
|
+
function parseStringLiteral(content, key2) {
|
|
3468
|
+
const m = content.match(new RegExp(`\\b${key2}\\s*:\\s*["'\`]([^"'\`]+)["'\`]`));
|
|
3469
3469
|
return m?.[1];
|
|
3470
3470
|
}
|
|
3471
3471
|
async function detectProject(projectDir) {
|
|
@@ -3803,16 +3803,16 @@ function charFromCodepoint(c) {
|
|
|
3803
3803
|
(c - 65536 & 1023) + 56320
|
|
3804
3804
|
);
|
|
3805
3805
|
}
|
|
3806
|
-
function setProperty(object,
|
|
3807
|
-
if (
|
|
3808
|
-
Object.defineProperty(object,
|
|
3806
|
+
function setProperty(object, key2, value) {
|
|
3807
|
+
if (key2 === "__proto__") {
|
|
3808
|
+
Object.defineProperty(object, key2, {
|
|
3809
3809
|
configurable: true,
|
|
3810
3810
|
enumerable: true,
|
|
3811
3811
|
writable: true,
|
|
3812
3812
|
value
|
|
3813
3813
|
});
|
|
3814
3814
|
} else {
|
|
3815
|
-
object[
|
|
3815
|
+
object[key2] = value;
|
|
3816
3816
|
}
|
|
3817
3817
|
}
|
|
3818
3818
|
function State(input, types) {
|
|
@@ -3940,11 +3940,11 @@ function mergeMappings(state, destination, source2, overridableKeys) {
|
|
|
3940
3940
|
chargeMergeWork(state);
|
|
3941
3941
|
const sourceKeys = Object.keys(source2);
|
|
3942
3942
|
for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
3943
|
-
const
|
|
3943
|
+
const key2 = sourceKeys[index];
|
|
3944
3944
|
chargeMergeWork(state);
|
|
3945
|
-
if (!_hasOwnProperty.call(destination,
|
|
3946
|
-
setProperty(destination,
|
|
3947
|
-
overridableKeys[
|
|
3945
|
+
if (!_hasOwnProperty.call(destination, key2)) {
|
|
3946
|
+
setProperty(destination, key2, source2[key2]);
|
|
3947
|
+
overridableKeys[key2] = true;
|
|
3948
3948
|
}
|
|
3949
3949
|
}
|
|
3950
3950
|
}
|
|
@@ -5071,7 +5071,7 @@ function unshareAliases(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
5071
5071
|
for (let i = 0; i < value.length; i++) value[i] = unshareAliases(value[i], seen);
|
|
5072
5072
|
} else {
|
|
5073
5073
|
const obj = value;
|
|
5074
|
-
for (const
|
|
5074
|
+
for (const key2 of Object.keys(obj)) obj[key2] = unshareAliases(obj[key2], seen);
|
|
5075
5075
|
}
|
|
5076
5076
|
return value;
|
|
5077
5077
|
}
|
|
@@ -5701,7 +5701,7 @@ function runChantRaw(args, projectDir, envOverride) {
|
|
|
5701
5701
|
const stamp = isIntentRead(args) ? "intent" : memberSourceStamp(dir);
|
|
5702
5702
|
const effectiveEnv = { ...process.env, ...envOverride };
|
|
5703
5703
|
const environment = Object.entries(effectiveEnv).sort(([a], [b]) => a.localeCompare(b));
|
|
5704
|
-
const
|
|
5704
|
+
const key2 = createHash3("sha256").update(JSON.stringify([
|
|
5705
5705
|
dir,
|
|
5706
5706
|
chant.bin,
|
|
5707
5707
|
chant.version,
|
|
@@ -5710,7 +5710,7 @@ function runChantRaw(args, projectDir, envOverride) {
|
|
|
5710
5710
|
readGeneration(),
|
|
5711
5711
|
stamp ?? ++unstampableRead
|
|
5712
5712
|
])).digest("hex");
|
|
5713
|
-
return reads.read(
|
|
5713
|
+
return reads.read(key2, (signal) => spawnChant(chant.bin, args, projectDir, effectiveEnv, signal), currentReadSignal(), labelRead(args, dir)).then((result) => ({ ...result }));
|
|
5714
5714
|
}
|
|
5715
5715
|
function spawnChant(bin, args, projectDir, envOverride, signal) {
|
|
5716
5716
|
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
@@ -9763,19 +9763,19 @@ function publicKey(blob) {
|
|
|
9763
9763
|
const take = reader(blob);
|
|
9764
9764
|
const type = take().toString();
|
|
9765
9765
|
if (type === "ssh-ed25519" || type === "sk-ssh-ed25519@openssh.com") {
|
|
9766
|
-
const
|
|
9767
|
-
return { type, key, ...type.startsWith("sk-") ? { application: take() } : {} };
|
|
9766
|
+
const key2 = createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: b64url(take()) }, format: "jwk" });
|
|
9767
|
+
return { type, key: key2, ...type.startsWith("sk-") ? { application: take() } : {} };
|
|
9768
9768
|
}
|
|
9769
9769
|
if (type.startsWith("ecdsa-sha2-") || type === "sk-ecdsa-sha2-nistp256@openssh.com") {
|
|
9770
9770
|
const curve = CURVES[take().toString()];
|
|
9771
9771
|
if (!curve) throw new Error(`unsupported curve in ${type}`);
|
|
9772
9772
|
const q = take();
|
|
9773
9773
|
if (q[0] !== 4 || q.length !== 1 + 2 * curve.size) throw new Error("the ECDSA key is not an uncompressed point");
|
|
9774
|
-
const
|
|
9774
|
+
const key2 = createPublicKey({
|
|
9775
9775
|
key: { kty: "EC", crv: curve.crv, x: b64url(q.subarray(1, 1 + curve.size)), y: b64url(q.subarray(1 + curve.size)) },
|
|
9776
9776
|
format: "jwk"
|
|
9777
9777
|
});
|
|
9778
|
-
return { type, key, ecdsa: curve, ...type.startsWith("sk-") ? { application: take() } : {} };
|
|
9778
|
+
return { type, key: key2, ecdsa: curve, ...type.startsWith("sk-") ? { application: take() } : {} };
|
|
9779
9779
|
}
|
|
9780
9780
|
if (type === "ssh-rsa") {
|
|
9781
9781
|
const e = unsigned(take());
|
|
@@ -9799,7 +9799,7 @@ function verifySshSignatureWith(armored, message2, namespace, keys) {
|
|
|
9799
9799
|
if (alg !== "sha256" && alg !== "sha512") return { ok: false, reason: `it hashes with ${alg}, and only sha256 and sha512 are accepted` };
|
|
9800
9800
|
if (!keys.some((k) => k.equals(pk))) return { ok: false, reason: "signed by a key the policy at base does not list for the approver" };
|
|
9801
9801
|
let data = Buffer.concat([Buffer.from("SSHSIG"), wire(ns), wire(reserved), wire(alg), wire(hash(alg, message2))]);
|
|
9802
|
-
const { type, key, ecdsa, application } = publicKey(pk);
|
|
9802
|
+
const { type, key: key2, ecdsa, application } = publicKey(pk);
|
|
9803
9803
|
const sig = reader(sigWire);
|
|
9804
9804
|
const sigType = sig().toString();
|
|
9805
9805
|
const raw = sig();
|
|
@@ -9807,7 +9807,7 @@ function verifySshSignatureWith(armored, message2, namespace, keys) {
|
|
|
9807
9807
|
const answer = (ok) => ok ? { ok: true, key: fingerprint } : { ok: false, reason: "the signature does not match the signed fields" };
|
|
9808
9808
|
if (type === "ssh-rsa") {
|
|
9809
9809
|
if (sigType !== "rsa-sha2-256" && sigType !== "rsa-sha2-512") return { ok: false, reason: `an RSA signature of type ${sigType} is not accepted` };
|
|
9810
|
-
return answer(verify(`sha${sigType.slice(9)}`, data,
|
|
9810
|
+
return answer(verify(`sha${sigType.slice(9)}`, data, key2, raw));
|
|
9811
9811
|
}
|
|
9812
9812
|
if (sigType !== type) return { ok: false, reason: `a ${sigType} signature from a ${type} key` };
|
|
9813
9813
|
if (application !== void 0) {
|
|
@@ -9819,9 +9819,9 @@ function verifySshSignatureWith(armored, message2, namespace, keys) {
|
|
|
9819
9819
|
const rs = reader(raw);
|
|
9820
9820
|
const r = unsigned(rs(), ecdsa.size);
|
|
9821
9821
|
const s = unsigned(rs(), ecdsa.size);
|
|
9822
|
-
return answer(verify(application !== void 0 ? "sha256" : ecdsa.hash, data, { key, dsaEncoding: "ieee-p1363" }, Buffer.concat([r, s])));
|
|
9822
|
+
return answer(verify(application !== void 0 ? "sha256" : ecdsa.hash, data, { key: key2, dsaEncoding: "ieee-p1363" }, Buffer.concat([r, s])));
|
|
9823
9823
|
}
|
|
9824
|
-
return answer(verify(null, data,
|
|
9824
|
+
return answer(verify(null, data, key2, raw));
|
|
9825
9825
|
} catch (err) {
|
|
9826
9826
|
return { ok: false, reason: err instanceof Error ? err.message : String(err) };
|
|
9827
9827
|
}
|
|
@@ -9980,8 +9980,8 @@ function classDataShapeProblems(raw, source2) {
|
|
|
9980
9980
|
say("", "must be object");
|
|
9981
9981
|
return p;
|
|
9982
9982
|
}
|
|
9983
|
-
for (const
|
|
9984
|
-
for (const
|
|
9983
|
+
for (const key2 of Object.keys(raw)) if (extra(key2, ["$schema", "$comment", "schema", "classes"])) say("", `must NOT have additional property ${key2}`);
|
|
9984
|
+
for (const key2 of ["$schema", "$comment"]) if (key2 in raw && typeof raw[key2] !== "string") say(`/${key2}`, "must be string");
|
|
9985
9985
|
if (!("schema" in raw)) say("", "must have required property 'schema'");
|
|
9986
9986
|
else if (raw.schema !== 1) say("/schema", "must be equal to constant 1");
|
|
9987
9987
|
if (!("classes" in raw)) say("", "must have required property 'classes'");
|
|
@@ -9991,8 +9991,8 @@ function classDataShapeProblems(raw, source2) {
|
|
|
9991
9991
|
raw.classes.forEach((c, i) => {
|
|
9992
9992
|
const at2 = `/classes/${i}`;
|
|
9993
9993
|
if (!isObject(c)) return say(at2, "must be object");
|
|
9994
|
-
for (const
|
|
9995
|
-
for (const
|
|
9994
|
+
for (const key2 of Object.keys(c)) if (extra(key2, ["name", "description", "role"])) say(at2, `must NOT have additional property ${key2}`);
|
|
9995
|
+
for (const key2 of ["name", "description", "role"]) if (!(key2 in c)) say(at2, `must have required property '${key2}'`);
|
|
9996
9996
|
if ("name" in c && (typeof c.name !== "string" || !NAME.test(c.name))) say(`${at2}/name`, "must be a class name");
|
|
9997
9997
|
if ("description" in c && (typeof c.description !== "string" || [...c.description].length < 1)) say(`${at2}/description`, "must be a non-empty string");
|
|
9998
9998
|
if ("role" in c && (typeof c.role !== "string" || !ROLE.test(c.role))) say(`${at2}/role`, "must be a role name");
|
|
@@ -10093,7 +10093,7 @@ var init_class_data = __esm({
|
|
|
10093
10093
|
NAME = /^(?!x-)[a-z][a-z0-9-]{0,39}$/u;
|
|
10094
10094
|
ROLE = /^[a-z][a-z0-9-]*$/u;
|
|
10095
10095
|
isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
10096
|
-
extra = (
|
|
10096
|
+
extra = (key2, known) => !known.includes(key2) && !key2.startsWith("x-");
|
|
10097
10097
|
CORE_ROLES = new Set(CORE_CLASSES.map((c) => c.role).filter((r) => r !== null));
|
|
10098
10098
|
}
|
|
10099
10099
|
});
|
|
@@ -10301,15 +10301,15 @@ function parseJsonText(text2, options2) {
|
|
|
10301
10301
|
skip();
|
|
10302
10302
|
if (text2[i] !== '"') fail(`expected a quoted key, found ${describe(i)}`);
|
|
10303
10303
|
const keyAt = i;
|
|
10304
|
-
const
|
|
10305
|
-
if (seen.has(
|
|
10306
|
-
seen.add(
|
|
10307
|
-
const child = `${pointer}/${pointerToken(
|
|
10304
|
+
const key2 = parseString();
|
|
10305
|
+
if (seen.has(key2)) fail(`duplicate key ${JSON.stringify(key2)}`, keyAt);
|
|
10306
|
+
seen.add(key2);
|
|
10307
|
+
const child = `${pointer}/${pointerToken(key2)}`;
|
|
10308
10308
|
keys.set(child, keyAt);
|
|
10309
10309
|
skip();
|
|
10310
|
-
if (text2[i] !== ":") fail(`expected ":" after key ${JSON.stringify(
|
|
10310
|
+
if (text2[i] !== ":") fail(`expected ":" after key ${JSON.stringify(key2)}, found ${describe(i)}`);
|
|
10311
10311
|
i++;
|
|
10312
|
-
Object.defineProperty(obj,
|
|
10312
|
+
Object.defineProperty(obj, key2, { value: parseValue(child), enumerable: true, writable: true, configurable: true });
|
|
10313
10313
|
skip();
|
|
10314
10314
|
if (text2[i] === ",") {
|
|
10315
10315
|
i++;
|
|
@@ -10365,8 +10365,8 @@ function parseJsonText(text2, options2) {
|
|
|
10365
10365
|
return {
|
|
10366
10366
|
ok: true,
|
|
10367
10367
|
value,
|
|
10368
|
-
locate(pointer,
|
|
10369
|
-
if (
|
|
10368
|
+
locate(pointer, key2) {
|
|
10369
|
+
if (key2 && keys.has(pointer)) return toLocation(keys.get(pointer));
|
|
10370
10370
|
for (let p = pointer; ; p = p.slice(0, p.lastIndexOf("/"))) {
|
|
10371
10371
|
const at2 = values.get(p);
|
|
10372
10372
|
if (at2 !== void 0) return toLocation(at2);
|
|
@@ -10500,9 +10500,9 @@ function explain(e, value) {
|
|
|
10500
10500
|
function valueAt(root, pointer) {
|
|
10501
10501
|
let v = root;
|
|
10502
10502
|
for (const token of pointer.split("/").slice(1)) {
|
|
10503
|
-
const
|
|
10503
|
+
const key2 = token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
10504
10504
|
if (v === null || typeof v !== "object") return void 0;
|
|
10505
|
-
v = v[
|
|
10505
|
+
v = v[key2];
|
|
10506
10506
|
}
|
|
10507
10507
|
return v;
|
|
10508
10508
|
}
|
|
@@ -10518,7 +10518,7 @@ function parseDeclaration(text2, file, reader2 = readerVersion(), options2 = {})
|
|
|
10518
10518
|
if (!parsed.ok) {
|
|
10519
10519
|
throw new WorkspaceReadError2("declaration-unparseable", parsed.message, { file, ...parsed.location });
|
|
10520
10520
|
}
|
|
10521
|
-
const at2 = (pointer,
|
|
10521
|
+
const at2 = (pointer, key2 = false) => ({ file, ...parsed.locate(pointer, key2) });
|
|
10522
10522
|
const raw = parsed.value;
|
|
10523
10523
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
10524
10524
|
throw new WorkspaceReadError2("declaration-invalid", "the declaration must be a JSON object", at2(""));
|
|
@@ -10931,13 +10931,13 @@ function factoryProblem(members) {
|
|
|
10931
10931
|
const answered = /* @__PURE__ */ new Map();
|
|
10932
10932
|
for (const [i, t2] of factory.tiers.entries()) {
|
|
10933
10933
|
for (const kind of t2.kinds ?? [null]) {
|
|
10934
|
-
const
|
|
10935
|
-
const first = answered.get(
|
|
10934
|
+
const key2 = `${t2.tier}\0${kind ?? ""}`;
|
|
10935
|
+
const first = answered.get(key2);
|
|
10936
10936
|
if (first !== void 0) {
|
|
10937
10937
|
const which = kind === null ? "with no kinds" : `for kind ${kind}`;
|
|
10938
10938
|
return { message: `tiers/${first} and tiers/${i} both name a builder at tier ${t2.tier} ${which}; a tier has one builder per kind, so one entry answers it`, pointer: `${factory.pointer}/tiers/${i}` };
|
|
10939
10939
|
}
|
|
10940
|
-
answered.set(
|
|
10940
|
+
answered.set(key2, i);
|
|
10941
10941
|
}
|
|
10942
10942
|
}
|
|
10943
10943
|
return null;
|
|
@@ -11340,9 +11340,9 @@ function mergeClusterRoot(ir, clusterIr, running) {
|
|
|
11340
11340
|
}
|
|
11341
11341
|
const haveEdges = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
|
|
11342
11342
|
for (const edge of clusterIr.edges) {
|
|
11343
|
-
const
|
|
11344
|
-
if (haveEdges.has(
|
|
11345
|
-
haveEdges.add(
|
|
11343
|
+
const key2 = `${edge.from}\0${edge.to}`;
|
|
11344
|
+
if (haveEdges.has(key2)) continue;
|
|
11345
|
+
haveEdges.add(key2);
|
|
11346
11346
|
ir.edges.push(edge);
|
|
11347
11347
|
}
|
|
11348
11348
|
return ir;
|
|
@@ -11407,15 +11407,15 @@ function synthesizeHelmReleases(ir, observed, owners) {
|
|
|
11407
11407
|
const declared = declaredChartNames(ir);
|
|
11408
11408
|
const have = new Set(ir.nodes.map((n) => n.id));
|
|
11409
11409
|
let added = 0;
|
|
11410
|
-
for (const [
|
|
11411
|
-
const m = RELEASE_KEY.exec(
|
|
11412
|
-
if (!m || have.has(
|
|
11410
|
+
for (const [key2, o] of Object.entries(observed)) {
|
|
11411
|
+
const m = RELEASE_KEY.exec(key2);
|
|
11412
|
+
if (!m || have.has(key2)) continue;
|
|
11413
11413
|
const [, namespace, name] = m;
|
|
11414
11414
|
if (matchesDeclaredChart(o.attributes?.chart, declared)) continue;
|
|
11415
11415
|
const component = owners.get(name);
|
|
11416
11416
|
const deployed = o.status === "deployed";
|
|
11417
11417
|
const node = {
|
|
11418
|
-
id:
|
|
11418
|
+
id: key2,
|
|
11419
11419
|
kind: "Helm::Release",
|
|
11420
11420
|
lexicon: "helm",
|
|
11421
11421
|
attrs: {
|
|
@@ -11435,7 +11435,7 @@ function synthesizeHelmReleases(ir, observed, owners) {
|
|
|
11435
11435
|
}
|
|
11436
11436
|
};
|
|
11437
11437
|
ir.nodes.push(node);
|
|
11438
|
-
have.add(
|
|
11438
|
+
have.add(key2);
|
|
11439
11439
|
added++;
|
|
11440
11440
|
}
|
|
11441
11441
|
return added;
|
|
@@ -12537,9 +12537,9 @@ function typeSegment(kind) {
|
|
|
12537
12537
|
const parts = kind.split(kind.includes("::") ? "::" : "/");
|
|
12538
12538
|
return parts[parts.length - 1] ?? kind;
|
|
12539
12539
|
}
|
|
12540
|
-
function isOwnNameAttr(kind,
|
|
12541
|
-
if (!/name$/i.test(
|
|
12542
|
-
const prefix =
|
|
12540
|
+
function isOwnNameAttr(kind, key2) {
|
|
12541
|
+
if (!/name$/i.test(key2)) return false;
|
|
12542
|
+
const prefix = key2.slice(0, -4).toLowerCase();
|
|
12543
12543
|
if (prefix === "") return true;
|
|
12544
12544
|
return typeSegment(kind).toLowerCase().includes(prefix);
|
|
12545
12545
|
}
|
|
@@ -12566,16 +12566,16 @@ function joinable(v) {
|
|
|
12566
12566
|
function stringLeaves(attrs) {
|
|
12567
12567
|
const out = [];
|
|
12568
12568
|
const onPath = /* @__PURE__ */ new Set();
|
|
12569
|
-
const step = (v,
|
|
12569
|
+
const step = (v, key2, path, depth) => {
|
|
12570
12570
|
if (typeof v === "string") {
|
|
12571
|
-
out.push({ path, key, value: v });
|
|
12571
|
+
out.push({ path, key: key2, value: v });
|
|
12572
12572
|
return;
|
|
12573
12573
|
}
|
|
12574
12574
|
if (depth >= MAX_DEPTH || !v || typeof v !== "object") return;
|
|
12575
12575
|
if (onPath.has(v)) return;
|
|
12576
12576
|
onPath.add(v);
|
|
12577
12577
|
if (Array.isArray(v)) {
|
|
12578
|
-
for (const item of v) step(item,
|
|
12578
|
+
for (const item of v) step(item, key2, path, depth + 1);
|
|
12579
12579
|
} else {
|
|
12580
12580
|
for (const [k, val] of Object.entries(v)) {
|
|
12581
12581
|
if (k.startsWith("_") || SKIP_KEYS.has(k)) continue;
|
|
@@ -12594,9 +12594,9 @@ function addValueMatchEdges(ir) {
|
|
|
12594
12594
|
const nodes = ir.nodes;
|
|
12595
12595
|
const owner = /* @__PURE__ */ new Map();
|
|
12596
12596
|
for (const n of nodes) {
|
|
12597
|
-
for (const { path, key, value } of stringLeaves(n.attrs)) {
|
|
12598
|
-
if (path !==
|
|
12599
|
-
if (!joinable(value) || !isOwnNameAttr(n.kind,
|
|
12597
|
+
for (const { path, key: key2, value } of stringLeaves(n.attrs)) {
|
|
12598
|
+
if (path !== key2 && path !== `metadata.${key2}`) continue;
|
|
12599
|
+
if (!joinable(value) || !isOwnNameAttr(n.kind, key2)) continue;
|
|
12600
12600
|
owner.set(value, owner.has(value) ? null : n.id);
|
|
12601
12601
|
}
|
|
12602
12602
|
}
|
|
@@ -12609,9 +12609,9 @@ function addValueMatchEdges(ir) {
|
|
|
12609
12609
|
if (!joinable(value)) continue;
|
|
12610
12610
|
const b = owner.get(value);
|
|
12611
12611
|
if (!b || b === a.id) continue;
|
|
12612
|
-
const
|
|
12613
|
-
if (declared.has(
|
|
12614
|
-
added.add(
|
|
12612
|
+
const key2 = `${a.id}\0${b}`;
|
|
12613
|
+
if (declared.has(key2) || added.has(key2)) continue;
|
|
12614
|
+
added.add(key2);
|
|
12615
12615
|
ir.edges.push({ from: a.id, to: b, kind: "ref", viaAttr: path, inferred: true });
|
|
12616
12616
|
}
|
|
12617
12617
|
}
|
|
@@ -12825,9 +12825,9 @@ function deriveK8sEdges(nodes) {
|
|
|
12825
12825
|
function addK8sDeclaredEdges(ir) {
|
|
12826
12826
|
const existing = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
|
|
12827
12827
|
for (const e of deriveK8sEdges(ir.nodes)) {
|
|
12828
|
-
const
|
|
12829
|
-
if (existing.has(
|
|
12830
|
-
existing.add(
|
|
12828
|
+
const key2 = `${e.from}\0${e.to}`;
|
|
12829
|
+
if (existing.has(key2)) continue;
|
|
12830
|
+
existing.add(key2);
|
|
12831
12831
|
ir.edges.push(e);
|
|
12832
12832
|
}
|
|
12833
12833
|
return ir;
|
|
@@ -12856,14 +12856,14 @@ function applyHelmArtifacts(ir, observed) {
|
|
|
12856
12856
|
continue;
|
|
12857
12857
|
}
|
|
12858
12858
|
const chartName = chartNameOf(node);
|
|
12859
|
-
const entry = chartName ? Object.entries(observed).find(([
|
|
12859
|
+
const entry = chartName ? Object.entries(observed).find(([key3, o2]) => key3.startsWith("release/") && releaseMatchesChart(o2, chartName)) : void 0;
|
|
12860
12860
|
if (!entry) {
|
|
12861
12861
|
attrs._status = "accent";
|
|
12862
12862
|
continue;
|
|
12863
12863
|
}
|
|
12864
|
-
const [
|
|
12864
|
+
const [key2, o] = entry;
|
|
12865
12865
|
const match = {
|
|
12866
|
-
release:
|
|
12866
|
+
release: key2.replace(/^release\//, ""),
|
|
12867
12867
|
...o.status ? { status: o.status } : {},
|
|
12868
12868
|
...typeof o.attributes?.revision === "string" ? { revision: o.attributes.revision } : {},
|
|
12869
12869
|
...typeof o.attributes?.chart === "string" ? { chart: o.attributes.chart } : {},
|
|
@@ -12923,25 +12923,25 @@ function invalidateMember(dir) {
|
|
|
12923
12923
|
return;
|
|
12924
12924
|
}
|
|
12925
12925
|
const root = resolve8(dir);
|
|
12926
|
-
for (const [
|
|
12926
|
+
for (const [key2, entry] of cache) if (entry.dir === root) cache.delete(key2);
|
|
12927
12927
|
}
|
|
12928
12928
|
async function memberIr(dir, opts = {}, via = chantVia) {
|
|
12929
12929
|
const size = memberIrCacheSize();
|
|
12930
12930
|
if (opts.live || opts.overlay || size === 0) return via.read(dir, opts);
|
|
12931
12931
|
const stamp = memberSourceStamp(dir);
|
|
12932
|
-
const
|
|
12933
|
-
const hit = stamp !== void 0 ? cache.get(
|
|
12932
|
+
const key2 = cacheKey(dir, opts, via);
|
|
12933
|
+
const hit = stamp !== void 0 ? cache.get(key2) : void 0;
|
|
12934
12934
|
if (hit && hit.stamp === stamp) {
|
|
12935
12935
|
hits++;
|
|
12936
|
-
cache.delete(
|
|
12937
|
-
cache.set(
|
|
12936
|
+
cache.delete(key2);
|
|
12937
|
+
cache.set(key2, hit);
|
|
12938
12938
|
return structuredClone(hit.ir);
|
|
12939
12939
|
}
|
|
12940
12940
|
misses++;
|
|
12941
12941
|
const ir = await via.read(dir, opts);
|
|
12942
12942
|
if (stamp === void 0 || memberSourceStamp(dir) !== stamp) return ir;
|
|
12943
|
-
cache.delete(
|
|
12944
|
-
cache.set(
|
|
12943
|
+
cache.delete(key2);
|
|
12944
|
+
cache.set(key2, { dir: resolve8(dir), stamp, ir });
|
|
12945
12945
|
for (const oldest of cache.keys()) {
|
|
12946
12946
|
if (cache.size <= size) break;
|
|
12947
12947
|
cache.delete(oldest);
|
|
@@ -13028,10 +13028,10 @@ function optionsKey(opts, via, dir) {
|
|
|
13028
13028
|
}
|
|
13029
13029
|
async function overlayIr(dir, opts, via, fresh = false) {
|
|
13030
13030
|
const root = resolve9(dir);
|
|
13031
|
-
const
|
|
13031
|
+
const key2 = optionsKey(opts, via, dir);
|
|
13032
13032
|
const stamp = memberSourceStamp(dir);
|
|
13033
13033
|
if (!fresh && stamp !== void 0) {
|
|
13034
|
-
const hit = cache3.get(root)?.get(
|
|
13034
|
+
const hit = cache3.get(root)?.get(key2);
|
|
13035
13035
|
if (hit && hit.stamp === stamp) {
|
|
13036
13036
|
hits2++;
|
|
13037
13037
|
return structuredClone(hit.ir);
|
|
@@ -13041,7 +13041,7 @@ async function overlayIr(dir, opts, via, fresh = false) {
|
|
|
13041
13041
|
const ir = await via.read(dir, opts);
|
|
13042
13042
|
if (stamp === void 0 || memberSourceStamp(dir) !== stamp) return ir;
|
|
13043
13043
|
const per = cache3.get(root) ?? /* @__PURE__ */ new Map();
|
|
13044
|
-
per.set(
|
|
13044
|
+
per.set(key2, { stamp, ir });
|
|
13045
13045
|
cache3.set(root, per);
|
|
13046
13046
|
return structuredClone(ir);
|
|
13047
13047
|
}
|
|
@@ -13396,13 +13396,13 @@ function memberIrFromGraphDocument(doc, member) {
|
|
|
13396
13396
|
const own = new Set(nodes.map((n) => n.id));
|
|
13397
13397
|
const groups = {};
|
|
13398
13398
|
if (isRecord7(doc.groups)) {
|
|
13399
|
-
for (const [
|
|
13400
|
-
if (
|
|
13401
|
-
const scoped =
|
|
13399
|
+
for (const [key2, table] of Object.entries(doc.groups)) {
|
|
13400
|
+
if (key2 === "byMember" || !isRecord7(table)) continue;
|
|
13401
|
+
const scoped = key2 === "byStack" || key2 === "byContainer" || key2 === "byWave" || key2 === "byPipeline";
|
|
13402
13402
|
for (const [k, ids] of Object.entries(table)) {
|
|
13403
13403
|
if (scoped && !k.startsWith(p)) continue;
|
|
13404
13404
|
const members = (Array.isArray(ids) ? ids : []).map(un).filter((id) => own.has(id));
|
|
13405
|
-
if (members.length) (groups[
|
|
13405
|
+
if (members.length) (groups[key2] ??= {})[scoped ? k.slice(p.length) : k] = members;
|
|
13406
13406
|
}
|
|
13407
13407
|
}
|
|
13408
13408
|
}
|
|
@@ -13769,11 +13769,11 @@ function renderIdentity(record, observed) {
|
|
|
13769
13769
|
}
|
|
13770
13770
|
function observedReleaseFor(record, observed, namespace) {
|
|
13771
13771
|
if (!observed) return void 0;
|
|
13772
|
-
const candidates = Object.entries(observed).filter(([
|
|
13772
|
+
const candidates = Object.entries(observed).filter(([key3]) => key3.startsWith("release/") && key3.split("/").pop() === record.name);
|
|
13773
13773
|
if (candidates.length === 0) return void 0;
|
|
13774
|
-
const scoped = namespace ? candidates.find(([
|
|
13775
|
-
const [
|
|
13776
|
-
return { key, observation };
|
|
13774
|
+
const scoped = namespace ? candidates.find(([key3]) => key3 === `release/${namespace}/${record.name}`) : void 0;
|
|
13775
|
+
const [key2, observation] = scoped ?? candidates[0];
|
|
13776
|
+
return { key: key2, observation };
|
|
13777
13777
|
}
|
|
13778
13778
|
function countChanges(docs) {
|
|
13779
13779
|
return docs.reduce((n, d) => n + d.changes.length, 0);
|
|
@@ -13880,8 +13880,8 @@ function metadata(node) {
|
|
|
13880
13880
|
const m = node.attrs?.metadata;
|
|
13881
13881
|
return m && typeof m === "object" && !Array.isArray(m) ? m : void 0;
|
|
13882
13882
|
}
|
|
13883
|
-
function metaString(node,
|
|
13884
|
-
const v = metadata(node)?.[
|
|
13883
|
+
function metaString(node, key2) {
|
|
13884
|
+
const v = metadata(node)?.[key2];
|
|
13885
13885
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
13886
13886
|
}
|
|
13887
13887
|
function isK8s(node) {
|
|
@@ -13893,8 +13893,8 @@ function isNamespace(node) {
|
|
|
13893
13893
|
function managedClusterName(node) {
|
|
13894
13894
|
const metaName = metaString(node, "name");
|
|
13895
13895
|
if (metaName) return metaName;
|
|
13896
|
-
for (const
|
|
13897
|
-
const v = node.attrs?.[
|
|
13896
|
+
for (const key2 of ["name", "clusterName"]) {
|
|
13897
|
+
const v = node.attrs?.[key2];
|
|
13898
13898
|
if (typeof v === "string" && v.length > 0) return v;
|
|
13899
13899
|
}
|
|
13900
13900
|
return node.id;
|
|
@@ -13921,9 +13921,9 @@ function addClusterAnchorEdges(ir, boundContext) {
|
|
|
13921
13921
|
const existing = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
|
|
13922
13922
|
const add = (from, to) => {
|
|
13923
13923
|
if (from === to) return;
|
|
13924
|
-
const
|
|
13925
|
-
if (existing.has(
|
|
13926
|
-
existing.add(
|
|
13924
|
+
const key2 = `${from}\0${to}`;
|
|
13925
|
+
if (existing.has(key2)) return;
|
|
13926
|
+
existing.add(key2);
|
|
13927
13927
|
ir.edges.push({ from, to, kind: "ref", viaAttr: ANCHOR_VIA, inferred: true });
|
|
13928
13928
|
};
|
|
13929
13929
|
for (const n of k8sNodes) {
|
|
@@ -13997,8 +13997,8 @@ function collectAzureRefs(value, out) {
|
|
|
13997
13997
|
if (typeof ref2 === "string") out.add(ref2.split(".")[0]);
|
|
13998
13998
|
for (const v of Object.values(value)) collectAzureRefs(v, out);
|
|
13999
13999
|
}
|
|
14000
|
-
function strAttr(node,
|
|
14001
|
-
const v = node.attrs?.[
|
|
14000
|
+
function strAttr(node, key2) {
|
|
14001
|
+
const v = node.attrs?.[key2];
|
|
14002
14002
|
return typeof v === "string" ? v : void 0;
|
|
14003
14003
|
}
|
|
14004
14004
|
function resourceName(node) {
|
|
@@ -14118,9 +14118,9 @@ function projectAzureLogical(ir, env) {
|
|
|
14118
14118
|
const seenEdge = /* @__PURE__ */ new Set();
|
|
14119
14119
|
const addEdge = (a, b) => {
|
|
14120
14120
|
if (a === b || !kept.has(a) || !kept.has(b)) return;
|
|
14121
|
-
const
|
|
14122
|
-
if (seenEdge.has(
|
|
14123
|
-
seenEdge.add(
|
|
14121
|
+
const key2 = a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
14122
|
+
if (seenEdge.has(key2)) return;
|
|
14123
|
+
seenEdge.add(key2);
|
|
14124
14124
|
edges.push({ from: a, to: b, kind: "ref" });
|
|
14125
14125
|
};
|
|
14126
14126
|
const contractable = (id) => !kept.has(id) && !AZURE_FABRIC_KINDS.has(byId.get(id)?.kind ?? "");
|
|
@@ -14177,8 +14177,8 @@ var GCP_FABRIC_KINDS = /* @__PURE__ */ new Set([
|
|
|
14177
14177
|
"chant:gcp:defaultAnnotations"
|
|
14178
14178
|
]);
|
|
14179
14179
|
var PROJECT_ID_ANNOTATION = "cnrm.cloud.google.com/project-id";
|
|
14180
|
-
function strAttr2(node,
|
|
14181
|
-
const v = node.attrs?.[
|
|
14180
|
+
function strAttr2(node, key2) {
|
|
14181
|
+
const v = node.attrs?.[key2];
|
|
14182
14182
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
14183
14183
|
}
|
|
14184
14184
|
function declaredProject(nodes) {
|
|
@@ -14193,7 +14193,7 @@ function collectRefs(v, out) {
|
|
|
14193
14193
|
if (!v || typeof v !== "object") return;
|
|
14194
14194
|
const ref2 = v.$ref;
|
|
14195
14195
|
if (typeof ref2 === "string") out.add(ref2.split(".")[0]);
|
|
14196
|
-
for (const
|
|
14196
|
+
for (const key2 of Object.keys(v)) collectRefs(v[key2], out);
|
|
14197
14197
|
}
|
|
14198
14198
|
function projectGcpLogical(ir, env) {
|
|
14199
14199
|
const gcp = ir.nodes.filter((n) => n.lexicon === "gcp");
|
|
@@ -14257,9 +14257,9 @@ function projectGcpLogical(ir, env) {
|
|
|
14257
14257
|
const seen = /* @__PURE__ */ new Set();
|
|
14258
14258
|
const addEdge = (a, b) => {
|
|
14259
14259
|
if (a === b || !kept.has(a) || !kept.has(b)) return;
|
|
14260
|
-
const
|
|
14261
|
-
if (seen.has(
|
|
14262
|
-
seen.add(
|
|
14260
|
+
const key2 = a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
14261
|
+
if (seen.has(key2)) return;
|
|
14262
|
+
seen.add(key2);
|
|
14263
14263
|
edges.push({ from: a, to: b, kind: "ref" });
|
|
14264
14264
|
};
|
|
14265
14265
|
const contractable = (id) => !kept.has(id) && !GCP_FABRIC_KINDS.has(byId.get(id)?.kind ?? "");
|
|
@@ -14300,9 +14300,9 @@ var K8S_PLUMBING_KINDS = /* @__PURE__ */ new Set([
|
|
|
14300
14300
|
function namespaceBoxKey(ns) {
|
|
14301
14301
|
return `namespace ${ns}`;
|
|
14302
14302
|
}
|
|
14303
|
-
function metaStr(node,
|
|
14303
|
+
function metaStr(node, key2) {
|
|
14304
14304
|
const meta = node.attrs?.metadata;
|
|
14305
|
-
const v = meta?.[
|
|
14305
|
+
const v = meta?.[key2];
|
|
14306
14306
|
return typeof v === "string" ? v : void 0;
|
|
14307
14307
|
}
|
|
14308
14308
|
function destinationNamespace(n) {
|
|
@@ -14474,7 +14474,7 @@ function collectRefs2(v, out) {
|
|
|
14474
14474
|
if (!v || typeof v !== "object") return;
|
|
14475
14475
|
const ref2 = v.$ref;
|
|
14476
14476
|
if (typeof ref2 === "string") out.add(ref2.split(".")[0]);
|
|
14477
|
-
for (const
|
|
14477
|
+
for (const key2 of Object.keys(v)) collectRefs2(v[key2], out);
|
|
14478
14478
|
}
|
|
14479
14479
|
function projectFlyLogical(ir) {
|
|
14480
14480
|
const fly = ir.nodes.filter((n) => n.lexicon === "fly");
|
|
@@ -14518,9 +14518,9 @@ function projectFlyLogical(ir) {
|
|
|
14518
14518
|
if (!kept.has(from)) continue;
|
|
14519
14519
|
for (const to of tos) {
|
|
14520
14520
|
if (!kept.has(to) || appIds.has(from) || appIds.has(to)) continue;
|
|
14521
|
-
const
|
|
14522
|
-
if (seen.has(
|
|
14523
|
-
seen.add(
|
|
14521
|
+
const key2 = from < to ? `${from}|${to}` : `${to}|${from}`;
|
|
14522
|
+
if (seen.has(key2)) continue;
|
|
14523
|
+
seen.add(key2);
|
|
14524
14524
|
edges.push({ from, to, kind: "ref" });
|
|
14525
14525
|
}
|
|
14526
14526
|
}
|
|
@@ -14545,9 +14545,9 @@ function projectChoudoufuLogical(ir) {
|
|
|
14545
14545
|
const edges = [];
|
|
14546
14546
|
const seen = /* @__PURE__ */ new Set();
|
|
14547
14547
|
for (const e of ir.edges) {
|
|
14548
|
-
const
|
|
14549
|
-
if (!kept.has(e.from) || !kept.has(e.to) || seen.has(
|
|
14550
|
-
seen.add(
|
|
14548
|
+
const key2 = `${e.from}|${e.to}|${e.kind}`;
|
|
14549
|
+
if (!kept.has(e.from) || !kept.has(e.to) || seen.has(key2)) continue;
|
|
14550
|
+
seen.add(key2);
|
|
14551
14551
|
edges.push(e);
|
|
14552
14552
|
}
|
|
14553
14553
|
return { ir: { nodes: cards, edges, groups: {} }, byContainer };
|
|
@@ -14575,9 +14575,9 @@ function projectTerraformLogical(ir) {
|
|
|
14575
14575
|
const edges = [];
|
|
14576
14576
|
const seen = /* @__PURE__ */ new Set();
|
|
14577
14577
|
for (const e of ir.edges) {
|
|
14578
|
-
const
|
|
14579
|
-
if (!kept.has(e.from) || !kept.has(e.to) || seen.has(
|
|
14580
|
-
seen.add(
|
|
14578
|
+
const key2 = `${e.from}|${e.to}|${e.kind}`;
|
|
14579
|
+
if (!kept.has(e.from) || !kept.has(e.to) || seen.has(key2)) continue;
|
|
14580
|
+
seen.add(key2);
|
|
14581
14581
|
edges.push(e);
|
|
14582
14582
|
}
|
|
14583
14583
|
return { ir: { nodes: cards, edges, groups: {} }, byContainer };
|
|
@@ -14683,7 +14683,7 @@ function collectRefs3(v, out) {
|
|
|
14683
14683
|
if (!v || typeof v !== "object") return;
|
|
14684
14684
|
const ref2 = v.$ref;
|
|
14685
14685
|
if (typeof ref2 === "string") out.add(ref2.split(".")[0]);
|
|
14686
|
-
for (const
|
|
14686
|
+
for (const key2 of Object.keys(v)) collectRefs3(v[key2], out);
|
|
14687
14687
|
}
|
|
14688
14688
|
function regionOf(node) {
|
|
14689
14689
|
for (const v of Object.values(node.attrs ?? {})) {
|
|
@@ -14692,8 +14692,8 @@ function regionOf(node) {
|
|
|
14692
14692
|
}
|
|
14693
14693
|
return void 0;
|
|
14694
14694
|
}
|
|
14695
|
-
function strAttr3(node,
|
|
14696
|
-
const v = node.attrs?.[
|
|
14695
|
+
function strAttr3(node, key2) {
|
|
14696
|
+
const v = node.attrs?.[key2];
|
|
14697
14697
|
return typeof v === "string" ? v : void 0;
|
|
14698
14698
|
}
|
|
14699
14699
|
function enrichedRefs(ir, aws, byId) {
|
|
@@ -14811,10 +14811,10 @@ function retainCrossLensEdges(ir, projections, nodes, edges, byContainer) {
|
|
|
14811
14811
|
for (const e of ir.edges) {
|
|
14812
14812
|
if (e.from === e.to || !cards.has(e.from) || !cards.has(e.to)) continue;
|
|
14813
14813
|
if (perLens.some((ids) => ids.has(e.from) && ids.has(e.to))) continue;
|
|
14814
|
-
const
|
|
14815
|
-
if (drawn.has(
|
|
14814
|
+
const key2 = pairKey(e.from, e.to);
|
|
14815
|
+
if (drawn.has(key2)) continue;
|
|
14816
14816
|
if (nests(e.from, e.to) || nests(e.to, e.from)) continue;
|
|
14817
|
-
drawn.add(
|
|
14817
|
+
drawn.add(key2);
|
|
14818
14818
|
edges.push(e);
|
|
14819
14819
|
}
|
|
14820
14820
|
}
|
|
@@ -14946,9 +14946,9 @@ function projectLogical(ir) {
|
|
|
14946
14946
|
const seenEdge = /* @__PURE__ */ new Set();
|
|
14947
14947
|
const addEdge = (a, b, via) => {
|
|
14948
14948
|
if (a === b || !keptSet.has(a) || !keptSet.has(b)) return;
|
|
14949
|
-
const
|
|
14950
|
-
if (seenEdge.has(
|
|
14951
|
-
seenEdge.add(
|
|
14949
|
+
const key2 = a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
14950
|
+
if (seenEdge.has(key2)) return;
|
|
14951
|
+
seenEdge.add(key2);
|
|
14952
14952
|
edges.push({ from: a, to: b, kind: "ref", ...via ? { viaAttr: via } : {} });
|
|
14953
14953
|
};
|
|
14954
14954
|
const isSg = (id) => byId.get(id)?.kind === "AWS::EC2::SecurityGroup";
|
|
@@ -15083,9 +15083,9 @@ function addCompositeDeps(ir, dag) {
|
|
|
15083
15083
|
const from = compToNode.get(e.from);
|
|
15084
15084
|
const to = compToNode.get(e.to);
|
|
15085
15085
|
if (!from || !to || from === to) continue;
|
|
15086
|
-
const
|
|
15087
|
-
if (declared.has(
|
|
15088
|
-
declared.add(
|
|
15086
|
+
const key2 = `${from}\0${to}`;
|
|
15087
|
+
if (declared.has(key2)) continue;
|
|
15088
|
+
declared.add(key2);
|
|
15089
15089
|
ir.edges.push({ from, to, kind: "ref", viaAttr: "dependsOn", inferred: true });
|
|
15090
15090
|
}
|
|
15091
15091
|
return ir;
|
|
@@ -15557,8 +15557,8 @@ function cardFaces(ir, boxes, opts = {}) {
|
|
|
15557
15557
|
const taken = /* @__PURE__ */ new Map();
|
|
15558
15558
|
const scope2 = (id) => `${box.get(id) ?? ""}\0`;
|
|
15559
15559
|
for (const n of ir.nodes) {
|
|
15560
|
-
const
|
|
15561
|
-
taken.set(
|
|
15560
|
+
const key2 = scope2(n.id) + (wanted.get(n.id) ?? n.id);
|
|
15561
|
+
taken.set(key2, (taken.get(key2) ?? 0) + 1);
|
|
15562
15562
|
}
|
|
15563
15563
|
for (const [id, label] of [...wanted]) if ((taken.get(scope2(id) + label) ?? 0) > 1) wanted.delete(id);
|
|
15564
15564
|
const minted = /* @__PURE__ */ new Map();
|
|
@@ -15588,8 +15588,8 @@ function cardFaces(ir, boxes, opts = {}) {
|
|
|
15588
15588
|
nodes,
|
|
15589
15589
|
edges: ir.edges.map((e) => ({ ...e, from: minted.get(e.from) ?? e.from, to: minted.get(e.to) ?? e.to })),
|
|
15590
15590
|
groups: Object.fromEntries(
|
|
15591
|
-
Object.entries(ir.groups ?? {}).map(([
|
|
15592
|
-
|
|
15591
|
+
Object.entries(ir.groups ?? {}).map(([key2, value]) => [
|
|
15592
|
+
key2,
|
|
15593
15593
|
value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).map(([g, ids]) => [g, (ids ?? []).map((id) => minted.get(id) ?? id)])) : value
|
|
15594
15594
|
])
|
|
15595
15595
|
)
|
|
@@ -16077,7 +16077,7 @@ function withRowChains(ir, groups, opts) {
|
|
|
16077
16077
|
const sep13 = { x: opts.nodesep ?? 64, y: opts.ranksep ?? 72 };
|
|
16078
16078
|
const known = new Set(ir.nodes.map((n) => n.id));
|
|
16079
16079
|
const boxOf3 = /* @__PURE__ */ new Map();
|
|
16080
|
-
for (const [
|
|
16080
|
+
for (const [key2, ids] of Object.entries(groups)) for (const id of ids) if (known.has(id)) boxOf3.set(id, key2);
|
|
16081
16081
|
const wired = /* @__PURE__ */ new Set();
|
|
16082
16082
|
for (const e of ir.edges) {
|
|
16083
16083
|
const a = boxOf3.get(e.from);
|
|
@@ -16085,9 +16085,9 @@ function withRowChains(ir, groups, opts) {
|
|
|
16085
16085
|
}
|
|
16086
16086
|
const grids = /* @__PURE__ */ new Map();
|
|
16087
16087
|
const chained = [];
|
|
16088
|
-
for (const [
|
|
16089
|
-
const ids = all.filter((id) => boxOf3.get(id) ===
|
|
16090
|
-
if (wired.has(
|
|
16088
|
+
for (const [key2, all] of Object.entries(groups)) {
|
|
16089
|
+
const ids = all.filter((id) => boxOf3.get(id) === key2);
|
|
16090
|
+
if (wired.has(key2) || ids.length < min) continue;
|
|
16091
16091
|
const cell = ids.reduce(
|
|
16092
16092
|
(m, id) => {
|
|
16093
16093
|
const s = opts.sizes.get(id) ?? FALLBACK;
|
|
@@ -16111,7 +16111,7 @@ function withRowChains(ir, groups, opts) {
|
|
|
16111
16111
|
rows += Math.ceil(band.ids.length / cols);
|
|
16112
16112
|
previous = band;
|
|
16113
16113
|
}
|
|
16114
|
-
grids.set(
|
|
16114
|
+
grids.set(key2, { cols, rows, bands });
|
|
16115
16115
|
}
|
|
16116
16116
|
return { ir: chained.length ? { ...ir, edges: [...ir.edges, ...chained] } : ir, grids };
|
|
16117
16117
|
}
|
|
@@ -16120,11 +16120,11 @@ function bandsOf(ids, bandOf) {
|
|
|
16120
16120
|
const rest = [];
|
|
16121
16121
|
const banded = /* @__PURE__ */ new Map();
|
|
16122
16122
|
for (const id of ids) {
|
|
16123
|
-
const
|
|
16124
|
-
if (
|
|
16125
|
-
else (banded.get(
|
|
16123
|
+
const key2 = bandOf(id);
|
|
16124
|
+
if (key2 === void 0) rest.push(id);
|
|
16125
|
+
else (banded.get(key2) ?? banded.set(key2, []).get(key2)).push(id);
|
|
16126
16126
|
}
|
|
16127
|
-
return [...rest.length ? [{ key: void 0, ids: rest }] : [], ...[...banded].map(([
|
|
16127
|
+
return [...rest.length ? [{ key: void 0, ids: rest }] : [], ...[...banded].map(([key2, band]) => ({ key: key2, ids: band }))];
|
|
16128
16128
|
}
|
|
16129
16129
|
function rowEdge(from, to) {
|
|
16130
16130
|
return { from, to, kind: "ref", viaAttr: LAYOUT_ROW_VIA };
|
|
@@ -16173,9 +16173,9 @@ function boxBadgeText(nodes) {
|
|
|
16173
16173
|
function boxBadges(ir) {
|
|
16174
16174
|
const byId = new Map(ir.nodes.map((n) => [n.id, n]));
|
|
16175
16175
|
const out = {};
|
|
16176
|
-
for (const [
|
|
16176
|
+
for (const [key2, ids] of Object.entries(ir.groups.byStack ?? {})) {
|
|
16177
16177
|
const nodes = ids.flatMap((id) => byId.get(id) ?? []);
|
|
16178
|
-
if (nodes.length) out[
|
|
16178
|
+
if (nodes.length) out[key2] = boxBadgeText(nodes);
|
|
16179
16179
|
}
|
|
16180
16180
|
return out;
|
|
16181
16181
|
}
|
|
@@ -16194,9 +16194,9 @@ function collapseBoxes(ir, opts = {}) {
|
|
|
16194
16194
|
const standsFor = /* @__PURE__ */ new Map();
|
|
16195
16195
|
const summaries = [];
|
|
16196
16196
|
const groups = { ...byStack };
|
|
16197
|
-
for (const [
|
|
16197
|
+
for (const [key2, ids] of shut) {
|
|
16198
16198
|
const nodes2 = ids.flatMap((id2) => byId.get(id2) ?? []);
|
|
16199
|
-
const id = `${SUMMARY_PREFIX}${
|
|
16199
|
+
const id = `${SUMMARY_PREFIX}${key2}`;
|
|
16200
16200
|
for (const n of nodes2) standsFor.set(n.id, id);
|
|
16201
16201
|
const status2 = summaryStatus(nodes2);
|
|
16202
16202
|
summaries.push({
|
|
@@ -16204,14 +16204,14 @@ function collapseBoxes(ir, opts = {}) {
|
|
|
16204
16204
|
kind: "member",
|
|
16205
16205
|
lexicon: SUMMARY_LEXICON,
|
|
16206
16206
|
attrs: {
|
|
16207
|
-
box:
|
|
16207
|
+
box: key2,
|
|
16208
16208
|
summary: boxBadgeText(nodes2),
|
|
16209
16209
|
cards: nodes2.length,
|
|
16210
16210
|
_collapsed: true,
|
|
16211
16211
|
...status2 ? { _status: status2 } : {}
|
|
16212
16212
|
}
|
|
16213
16213
|
});
|
|
16214
|
-
delete groups[
|
|
16214
|
+
delete groups[key2];
|
|
16215
16215
|
}
|
|
16216
16216
|
const nodes = ir.nodes.filter((n) => !standsFor.has(n.id));
|
|
16217
16217
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -16220,14 +16220,14 @@ function collapseBoxes(ir, opts = {}) {
|
|
|
16220
16220
|
const from = standsFor.get(e.from) ?? e.from;
|
|
16221
16221
|
const to = standsFor.get(e.to) ?? e.to;
|
|
16222
16222
|
if (from === to) continue;
|
|
16223
|
-
const
|
|
16224
|
-
if (seen.has(
|
|
16225
|
-
seen.add(
|
|
16223
|
+
const key2 = `${from}|${to}|${e.kind}`;
|
|
16224
|
+
if (seen.has(key2)) continue;
|
|
16225
|
+
seen.add(key2);
|
|
16226
16226
|
edges.push(from === e.from && to === e.to ? e : { ...e, from, to });
|
|
16227
16227
|
}
|
|
16228
16228
|
return {
|
|
16229
16229
|
ir: { ...ir, nodes: [...nodes, ...summaries], edges, groups: { ...ir.groups, byStack: groups } },
|
|
16230
|
-
collapsed: shut.map(([
|
|
16230
|
+
collapsed: shut.map(([key2]) => key2)
|
|
16231
16231
|
};
|
|
16232
16232
|
}
|
|
16233
16233
|
function collapseNote(collapsed, limit = COLLAPSE_LIMIT) {
|
|
@@ -16575,10 +16575,10 @@ function routeEdges(svg) {
|
|
|
16575
16575
|
{ edge: i, card: m[2], side: inSide, toward: centre(a), offset: 0 }
|
|
16576
16576
|
];
|
|
16577
16577
|
for (const e of pair) {
|
|
16578
|
-
const
|
|
16579
|
-
const list3 = sides.get(
|
|
16578
|
+
const key2 = `${e.card}\0${e.side}`;
|
|
16579
|
+
const list3 = sides.get(key2) ?? [];
|
|
16580
16580
|
list3.push(e);
|
|
16581
|
-
sides.set(
|
|
16581
|
+
sides.set(key2, list3);
|
|
16582
16582
|
}
|
|
16583
16583
|
return pair;
|
|
16584
16584
|
});
|
|
@@ -16649,7 +16649,7 @@ function estateFace(irIn, boxesIn, opts = {}) {
|
|
|
16649
16649
|
const face = cardFaces(irIn, boxesIn, opts.prefixes ? { prefixes: opts.prefixes } : {});
|
|
16650
16650
|
const ir = face.ir;
|
|
16651
16651
|
if (Object.keys(face.overrides).length) faceOverrides.set(ir, face.overrides);
|
|
16652
|
-
const toDisplay = (record) => record ? Object.fromEntries(Object.entries(record).map(([
|
|
16652
|
+
const toDisplay = (record) => record ? Object.fromEntries(Object.entries(record).map(([key2, ids]) => [key2, ids.map((id) => face.display.get(id) ?? id)])) : void 0;
|
|
16653
16653
|
const boxes = toDisplay(boxesIn);
|
|
16654
16654
|
const subgroups = boxes ? toDisplay(opts.subgroups) : void 0;
|
|
16655
16655
|
const realBand = moduleBandOf(irIn);
|
|
@@ -16682,7 +16682,7 @@ function renderArchitecture(ir, byContainer, opts = {}) {
|
|
|
16682
16682
|
);
|
|
16683
16683
|
const flat = Object.keys(leafBoxes).length === Object.keys(byContainer).length;
|
|
16684
16684
|
const face = estateFace(ir, leafBoxes, { ...opts.cardPrefixes ? { prefixes: opts.cardPrefixes } : {}, nodesep, ranksep });
|
|
16685
|
-
const display = Object.fromEntries(Object.entries(byContainer).map(([
|
|
16685
|
+
const display = Object.fromEntries(Object.entries(byContainer).map(([key2, members]) => [key2, members.map((m) => face.display.get(m) ?? m)]));
|
|
16686
16686
|
const layout = layoutArchitecture(face.chains.ir, display, { fit: true, nodesep, ranksep, overrides: face.overrides });
|
|
16687
16687
|
if (flat) packEstateBoxes(layout, face, { members: true, badges: opts.groupBadges, marks: opts.groupMarks });
|
|
16688
16688
|
else {
|
|
@@ -16749,9 +16749,9 @@ function pipelineTitles(ir, byPipeline) {
|
|
|
16749
16749
|
return workflows.length === 1 ? workflows[0] : void 0;
|
|
16750
16750
|
};
|
|
16751
16751
|
return Object.fromEntries(
|
|
16752
|
-
Object.entries(byPipeline).map(([
|
|
16753
|
-
const name = (nodes.get(
|
|
16754
|
-
return [
|
|
16752
|
+
Object.entries(byPipeline).map(([key2, ids]) => {
|
|
16753
|
+
const name = (nodes.get(key2) ?? workflowOf(ids))?.attrs?.["name"];
|
|
16754
|
+
return [key2, typeof name === "string" && name.trim() ? name : key2];
|
|
16755
16755
|
})
|
|
16756
16756
|
);
|
|
16757
16757
|
}
|
|
@@ -16812,7 +16812,7 @@ function topLevelSubgroups(boxes, subgroups) {
|
|
|
16812
16812
|
function fitNestedBoxes(layout, ir, boxes, subgroups, only2) {
|
|
16813
16813
|
const at2 = new Map(layout.nodes.map((n) => [n.id, n]));
|
|
16814
16814
|
const ownerOf2 = /* @__PURE__ */ new Map();
|
|
16815
|
-
for (const [
|
|
16815
|
+
for (const [key2, ids] of Object.entries(boxes)) for (const id of ids) if (at2.has(id)) ownerOf2.set(id, key2);
|
|
16816
16816
|
const sizes = footprints(ir);
|
|
16817
16817
|
for (const box of layout.groups ?? []) {
|
|
16818
16818
|
if (box.parent === void 0 || box.id === void 0 || only2 !== void 0 && box.parent !== only2) continue;
|
|
@@ -17159,11 +17159,11 @@ function packMemberBoxes(layout, ir, members) {
|
|
|
17159
17159
|
for (const b of boxes) b.y = layout.height - b.y;
|
|
17160
17160
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17161
17161
|
const ownerOf2 = /* @__PURE__ */ new Map();
|
|
17162
|
-
for (const [
|
|
17162
|
+
for (const [key2, ids] of Object.entries(members)) for (const id of ids) if (byId.has(id)) ownerOf2.set(id, key2);
|
|
17163
17163
|
const claimed = /* @__PURE__ */ new Set();
|
|
17164
17164
|
const blocks = boxes.map((box) => {
|
|
17165
|
-
const
|
|
17166
|
-
const ns = (members[
|
|
17165
|
+
const key2 = box.id ?? box.title;
|
|
17166
|
+
const ns = (members[key2] ?? members[box.title] ?? []).filter((id) => ownerOf2.get(id) === key2 || ownerOf2.get(id) === void 0).flatMap((id) => byId.get(id) ?? []);
|
|
17167
17167
|
for (const n of ns) claimed.add(n.id);
|
|
17168
17168
|
let minX = box.x - box.w / 2;
|
|
17169
17169
|
let maxX2 = box.x + box.w / 2;
|
|
@@ -17273,17 +17273,17 @@ function packBoxComponents(layout, ir, boxes, bandOf, subgroups) {
|
|
|
17273
17273
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
17274
17274
|
const boxByKey = new Map(groupBoxes.flatMap((b) => b.id === void 0 ? [] : [[b.id, b]]));
|
|
17275
17275
|
const ownerOf2 = /* @__PURE__ */ new Map();
|
|
17276
|
-
for (const [
|
|
17276
|
+
for (const [key2, ids] of Object.entries(boxes)) for (const id of ids) if (byId.has(id)) ownerOf2.set(id, key2);
|
|
17277
17277
|
const size = footprints(ir);
|
|
17278
17278
|
const halfW = (n) => (size.get(n.id)?.w ?? NODE_W) / 2;
|
|
17279
17279
|
const halfH = (n) => (size.get(n.id)?.h ?? NODE_H) / 2;
|
|
17280
17280
|
for (const n of nodes) n.y = layout.height - n.y;
|
|
17281
17281
|
for (const b of groupBoxes) b.y = layout.height - b.y;
|
|
17282
17282
|
let packed = false;
|
|
17283
|
-
for (const [
|
|
17284
|
-
const box = boxByKey.get(
|
|
17283
|
+
for (const [key2, ids] of Object.entries(boxes)) {
|
|
17284
|
+
const box = boxByKey.get(key2);
|
|
17285
17285
|
if (!box) continue;
|
|
17286
|
-
const own = ids.filter((id) => ownerOf2.get(id) ===
|
|
17286
|
+
const own = ids.filter((id) => ownerOf2.get(id) === key2).flatMap((id) => byId.get(id) ?? []);
|
|
17287
17287
|
if (own.length < ROW_MIN_CARDS || box.h <= 0 || box.w / box.h <= BOX_ASPECT_MAX) continue;
|
|
17288
17288
|
const idxOf = new Map(own.map((n, i) => [n.id, i]));
|
|
17289
17289
|
const parent = own.map((_, i) => i);
|
|
@@ -17340,7 +17340,7 @@ function packBoxComponents(layout, ir, boxes, bandOf, subgroups) {
|
|
|
17340
17340
|
const all = [...laid.values()];
|
|
17341
17341
|
const area = all.reduce((s, c) => s + (c.w + COMPONENT_GAP) * (c.h + COMPONENT_GAP), 0);
|
|
17342
17342
|
const targetW = Math.max(Math.max(...all.map((c) => c.w)), Math.sqrt(area * ROW_ASPECT));
|
|
17343
|
-
const holdsNested = groupBoxes.some((b) => b.parent ===
|
|
17343
|
+
const holdsNested = groupBoxes.some((b) => b.parent === key2);
|
|
17344
17344
|
const originX = box.x - box.w / 2 + (holdsNested ? NEST_OUTER : BAND_PAD);
|
|
17345
17345
|
const originY = box.y - box.h / 2 + (holdsNested ? NEST_OUTER : TITLE);
|
|
17346
17346
|
let shelfX = 0;
|
|
@@ -17374,8 +17374,8 @@ function packBoxComponents(layout, ir, boxes, bandOf, subgroups) {
|
|
|
17374
17374
|
}
|
|
17375
17375
|
bands.push({ key: band, ids: ids2 });
|
|
17376
17376
|
}
|
|
17377
|
-
if (subgroups) fitNestedBoxes(layout, ir, boxes, subgroups,
|
|
17378
|
-
const inner = groupBoxes.filter((b) => b.parent ===
|
|
17377
|
+
if (subgroups) fitNestedBoxes(layout, ir, boxes, subgroups, key2);
|
|
17378
|
+
const inner = groupBoxes.filter((b) => b.parent === key2);
|
|
17379
17379
|
let x0 = Math.min(...own.map((n) => n.x - halfW(n))) - BAND_PAD;
|
|
17380
17380
|
let x1 = Math.max(...own.map((n) => n.x + halfW(n))) + BAND_PAD;
|
|
17381
17381
|
let y0 = Math.min(...own.map((n) => n.y - halfH(n))) - TITLE;
|
|
@@ -17390,7 +17390,7 @@ function packBoxComponents(layout, ir, boxes, bandOf, subgroups) {
|
|
|
17390
17390
|
box.y = (y0 + y1) / 2;
|
|
17391
17391
|
box.w = x1 - x0;
|
|
17392
17392
|
box.h = y1 - y0;
|
|
17393
|
-
grids.set(
|
|
17393
|
+
grids.set(key2, { cols: 0, rows: bands.length, bands });
|
|
17394
17394
|
packed = true;
|
|
17395
17395
|
}
|
|
17396
17396
|
if (!packed) {
|
|
@@ -17421,11 +17421,11 @@ function groupKeyByNode(ir) {
|
|
|
17421
17421
|
const out = /* @__PURE__ */ new Map();
|
|
17422
17422
|
for (const n of ir.nodes) {
|
|
17423
17423
|
const parts = (n.sourceLoc?.file ?? "").split("/");
|
|
17424
|
-
let
|
|
17425
|
-
if (parts[0] === "src" && parts[1] === "examples")
|
|
17426
|
-
else if (parts[0] === "src" && parts.length >= 3)
|
|
17427
|
-
else
|
|
17428
|
-
out.set(n.id,
|
|
17424
|
+
let key2;
|
|
17425
|
+
if (parts[0] === "src" && parts[1] === "examples") key2 = "examples";
|
|
17426
|
+
else if (parts[0] === "src" && parts.length >= 3) key2 = parts[1];
|
|
17427
|
+
else key2 = n.lexicon || "other";
|
|
17428
|
+
out.set(n.id, key2);
|
|
17429
17429
|
}
|
|
17430
17430
|
return out;
|
|
17431
17431
|
}
|
|
@@ -17451,8 +17451,8 @@ function radializeLayout(layout, groupOf, size = /* @__PURE__ */ new Map()) {
|
|
|
17451
17451
|
const gap = 55;
|
|
17452
17452
|
const rowStep = 190;
|
|
17453
17453
|
let angle = -Math.PI / 2;
|
|
17454
|
-
for (const
|
|
17455
|
-
const gnodes = groups.get(
|
|
17454
|
+
for (const key2 of order) {
|
|
17455
|
+
const gnodes = groups.get(key2).slice().sort((a, b) => (rankOf.get(bucket(a.y)) ?? 0) - (rankOf.get(bucket(b.y)) ?? 0) || a.x - b.x);
|
|
17456
17456
|
const width = minWidth + flexible * (gnodes.length / nodes.length);
|
|
17457
17457
|
const start = angle;
|
|
17458
17458
|
let radius = r0;
|
|
@@ -17549,8 +17549,8 @@ function normalizeLens(raw) {
|
|
|
17549
17549
|
if (typeof raw !== "string" || !raw.trim() || raw.length > MAX_LENS_LENGTH) return null;
|
|
17550
17550
|
const parts = raw.split("+").map((p) => slug2(p)).filter((p) => p && p !== "unknown");
|
|
17551
17551
|
if (!parts.length) return null;
|
|
17552
|
-
const
|
|
17553
|
-
return
|
|
17552
|
+
const key2 = parts.join("+");
|
|
17553
|
+
return key2 === "__proto__" || key2 === "constructor" || key2 === "prototype" ? null : key2;
|
|
17554
17554
|
}
|
|
17555
17555
|
function normalizeDeltas(raw) {
|
|
17556
17556
|
const out = {};
|
|
@@ -17595,10 +17595,10 @@ function readLayoutFile(projectDir) {
|
|
|
17595
17595
|
if (!parsed || typeof parsed !== "object" || !parsed.lenses || typeof parsed.lenses !== "object") return empty;
|
|
17596
17596
|
const lenses = {};
|
|
17597
17597
|
for (const [lens, deltas] of Object.entries(parsed.lenses)) {
|
|
17598
|
-
const
|
|
17599
|
-
if (!
|
|
17598
|
+
const key2 = normalizeLens(lens);
|
|
17599
|
+
if (!key2) continue;
|
|
17600
17600
|
const clean = normalizeDeltas(deltas);
|
|
17601
|
-
if (Object.keys(clean).length) lenses[
|
|
17601
|
+
if (Object.keys(clean).length) lenses[key2] = clean;
|
|
17602
17602
|
if (Object.keys(lenses).length >= MAX_LENSES) break;
|
|
17603
17603
|
}
|
|
17604
17604
|
return { version: 1, lenses };
|
|
@@ -17607,25 +17607,25 @@ function readLayoutFile(projectDir) {
|
|
|
17607
17607
|
}
|
|
17608
17608
|
}
|
|
17609
17609
|
function readLens(projectDir, lens) {
|
|
17610
|
-
const
|
|
17611
|
-
if (!
|
|
17612
|
-
return readLayoutFile(projectDir).lenses[
|
|
17610
|
+
const key2 = normalizeLens(lens);
|
|
17611
|
+
if (!key2) return {};
|
|
17612
|
+
return readLayoutFile(projectDir).lenses[key2] ?? {};
|
|
17613
17613
|
}
|
|
17614
17614
|
var LayoutTooLarge = class extends Error {
|
|
17615
17615
|
};
|
|
17616
17616
|
function writeLens(projectDir, lens, deltas) {
|
|
17617
|
-
const
|
|
17618
|
-
if (!
|
|
17617
|
+
const key2 = normalizeLens(lens);
|
|
17618
|
+
if (!key2) throw new Error(`not a lens key: ${String(lens)}`);
|
|
17619
17619
|
const clean = normalizeDeltas(deltas);
|
|
17620
17620
|
const current = readLayoutFile(projectDir);
|
|
17621
17621
|
const lenses = { ...current.lenses };
|
|
17622
|
-
if (Object.keys(clean).length) lenses[
|
|
17623
|
-
else delete lenses[
|
|
17622
|
+
if (Object.keys(clean).length) lenses[key2] = clean;
|
|
17623
|
+
else delete lenses[key2];
|
|
17624
17624
|
if (Object.keys(lenses).length > MAX_LENSES) throw new LayoutTooLarge(`a layout sidecar holds at most ${MAX_LENSES} lenses`);
|
|
17625
17625
|
const file = layoutPath(projectDir);
|
|
17626
17626
|
if (!Object.keys(lenses).length) {
|
|
17627
17627
|
rmSync2(file, { force: true });
|
|
17628
|
-
return { lens:
|
|
17628
|
+
return { lens: key2, deltas: clean, bytes: 0 };
|
|
17629
17629
|
}
|
|
17630
17630
|
const body = JSON.stringify({ version: 1, lenses }, null, 2) + "\n";
|
|
17631
17631
|
if (body.length > MAX_FILE_BYTES) throw new LayoutTooLarge(`a layout sidecar is capped at ${MAX_FILE_BYTES} bytes`);
|
|
@@ -17633,7 +17633,7 @@ function writeLens(projectDir, lens, deltas) {
|
|
|
17633
17633
|
const tmp = `${file}.tmp`;
|
|
17634
17634
|
writeFileSync4(tmp, body, "utf8");
|
|
17635
17635
|
renameSync(tmp, file);
|
|
17636
|
-
return { lens:
|
|
17636
|
+
return { lens: key2, deltas: clean, bytes: body.length };
|
|
17637
17637
|
}
|
|
17638
17638
|
function nodeTransform(base, d) {
|
|
17639
17639
|
const dx = d.dx || 0;
|
|
@@ -18312,9 +18312,9 @@ function joinRun(op, records, gate) {
|
|
|
18312
18312
|
const slots = slotsFor(placed);
|
|
18313
18313
|
const byKey = /* @__PURE__ */ new Map();
|
|
18314
18314
|
for (const s of slots) {
|
|
18315
|
-
const
|
|
18316
|
-
if (!byKey.has(
|
|
18317
|
-
byKey.get(
|
|
18315
|
+
const key2 = `${s.phase}\0${s.fn}`;
|
|
18316
|
+
if (!byKey.has(key2)) byKey.set(key2, []);
|
|
18317
|
+
byKey.get(key2).push({ id: s.id });
|
|
18318
18318
|
}
|
|
18319
18319
|
const cursor = /* @__PURE__ */ new Map();
|
|
18320
18320
|
const byNode = /* @__PURE__ */ new Map();
|
|
@@ -18322,15 +18322,15 @@ function joinRun(op, records, gate) {
|
|
|
18322
18322
|
let lastSettledIndex = -1;
|
|
18323
18323
|
const indexOf = new Map(placed.map((p, i) => [p.id, i]));
|
|
18324
18324
|
for (const record of records) {
|
|
18325
|
-
const
|
|
18326
|
-
const list3 = byKey.get(
|
|
18327
|
-
const i = cursor.get(
|
|
18325
|
+
const key2 = `${record.phase}\0${record.fn}`;
|
|
18326
|
+
const list3 = byKey.get(key2);
|
|
18327
|
+
const i = cursor.get(key2) ?? 0;
|
|
18328
18328
|
const slot = list3?.[i];
|
|
18329
18329
|
if (!slot) {
|
|
18330
18330
|
unplaced.push(record);
|
|
18331
18331
|
continue;
|
|
18332
18332
|
}
|
|
18333
|
-
cursor.set(
|
|
18333
|
+
cursor.set(key2, i + 1);
|
|
18334
18334
|
byNode.set(slot.id, mergeRun(byNode.get(slot.id), record));
|
|
18335
18335
|
if (record.status !== "skipped") {
|
|
18336
18336
|
lastSettledIndex = Math.max(lastSettledIndex, indexOf.get(slot.id) ?? -1);
|
|
@@ -20029,9 +20029,9 @@ function deriveEstateMemberEdges(ir, members, isDir = realIsDir2) {
|
|
|
20029
20029
|
if (!winner || tied) continue;
|
|
20030
20030
|
for (const to of entryNodes(winner.name, n.lexicon)) {
|
|
20031
20031
|
if (!present2.has(to) || to === delivery.from) continue;
|
|
20032
|
-
const
|
|
20033
|
-
if (seen.has(
|
|
20034
|
-
seen.add(
|
|
20032
|
+
const key2 = `${delivery.from}\0${to}`;
|
|
20033
|
+
if (seen.has(key2)) continue;
|
|
20034
|
+
seen.add(key2);
|
|
20035
20035
|
out.push({ from: delivery.from, to, kind: "ref", viaAttr: delivery.viaAttr, inferred: true });
|
|
20036
20036
|
}
|
|
20037
20037
|
}
|
|
@@ -20041,9 +20041,9 @@ function deriveEstateMemberEdges(ir, members, isDir = realIsDir2) {
|
|
|
20041
20041
|
function addEstateMemberEdges(ir, members, isDir = realIsDir2) {
|
|
20042
20042
|
const existing = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
|
|
20043
20043
|
for (const e of deriveEstateMemberEdges(ir, members, isDir)) {
|
|
20044
|
-
const
|
|
20045
|
-
if (existing.has(
|
|
20046
|
-
existing.add(
|
|
20044
|
+
const key2 = `${e.from}\0${e.to}`;
|
|
20045
|
+
if (existing.has(key2)) continue;
|
|
20046
|
+
existing.add(key2);
|
|
20047
20047
|
ir.edges.push(e);
|
|
20048
20048
|
}
|
|
20049
20049
|
return ir;
|
|
@@ -20085,10 +20085,10 @@ function parsePlanShow(run3, dir) {
|
|
|
20085
20085
|
}
|
|
20086
20086
|
var KNOWN_AFTER_APPLY = "(known after apply)";
|
|
20087
20087
|
var SENSITIVE = "(sensitive)";
|
|
20088
|
-
var flagged = (tree,
|
|
20088
|
+
var flagged = (tree, key2) => {
|
|
20089
20089
|
if (tree === true) return true;
|
|
20090
20090
|
if (!isRecord10(tree)) return false;
|
|
20091
|
-
const v = tree[
|
|
20091
|
+
const v = tree[key2];
|
|
20092
20092
|
return v === true || isRecord10(v) && Object.values(v).some((x) => x === true) || Array.isArray(v) && v.some((x) => x === true);
|
|
20093
20093
|
};
|
|
20094
20094
|
function same(a, b) {
|
|
@@ -20113,13 +20113,13 @@ function planDrift(doc) {
|
|
|
20113
20113
|
if (!Array.isArray(actions) || actions.every((a) => a === "no-op")) continue;
|
|
20114
20114
|
if (!isRecord10(before) || !isRecord10(after2)) continue;
|
|
20115
20115
|
const changes = [];
|
|
20116
|
-
for (const
|
|
20117
|
-
const unknownAfter = flagged(rc.change.after_unknown,
|
|
20118
|
-
if (!unknownAfter && same(before[
|
|
20116
|
+
for (const key2 of [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after2)])].sort()) {
|
|
20117
|
+
const unknownAfter = flagged(rc.change.after_unknown, key2);
|
|
20118
|
+
if (!unknownAfter && same(before[key2], after2[key2])) continue;
|
|
20119
20119
|
changes.push({
|
|
20120
|
-
path:
|
|
20121
|
-
oldValue: flagged(rc.change.before_sensitive,
|
|
20122
|
-
newValue: unknownAfter ? KNOWN_AFTER_APPLY : flagged(rc.change.after_sensitive,
|
|
20120
|
+
path: key2,
|
|
20121
|
+
oldValue: flagged(rc.change.before_sensitive, key2) ? SENSITIVE : before[key2],
|
|
20122
|
+
newValue: unknownAfter ? KNOWN_AFTER_APPLY : flagged(rc.change.after_sensitive, key2) ? SENSITIVE : after2[key2]
|
|
20123
20123
|
});
|
|
20124
20124
|
}
|
|
20125
20125
|
if (changes.length) out.set(rc.address, { address: rc.address, actions, changes });
|
|
@@ -20526,8 +20526,8 @@ function ledgerRecordingOff(env = process.env) {
|
|
|
20526
20526
|
return value !== void 0 && value !== "" && value !== "0" && value !== "false";
|
|
20527
20527
|
}
|
|
20528
20528
|
var overlays = /* @__PURE__ */ new Map();
|
|
20529
|
-
function overlayTip(
|
|
20530
|
-
return overlays.get(
|
|
20529
|
+
function overlayTip(key2) {
|
|
20530
|
+
return overlays.get(key2)?.tip;
|
|
20531
20531
|
}
|
|
20532
20532
|
|
|
20533
20533
|
// node_modules/@intentius/chant/src/lifecycle/git.ts
|
|
@@ -20606,9 +20606,9 @@ async function overlayKey(cwd) {
|
|
|
20606
20606
|
const cached = overlayKeys.get(from);
|
|
20607
20607
|
if (cached !== void 0) return cached;
|
|
20608
20608
|
const result = await getRuntime().spawn(["git", "rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd: from, env: C_LOCALE_ENV });
|
|
20609
|
-
const
|
|
20610
|
-
overlayKeys.set(from,
|
|
20611
|
-
return
|
|
20609
|
+
const key2 = result.exitCode === 0 && result.stdout.trim() !== "" ? result.stdout.trim() : from;
|
|
20610
|
+
overlayKeys.set(from, key2);
|
|
20611
|
+
return key2;
|
|
20612
20612
|
}
|
|
20613
20613
|
|
|
20614
20614
|
// node_modules/@intentius/chant/src/content-digest.ts
|
|
@@ -20663,9 +20663,9 @@ function encodeCanonical(value, path, seen) {
|
|
|
20663
20663
|
}
|
|
20664
20664
|
const keys = Object.keys(obj).sort();
|
|
20665
20665
|
const parts = [];
|
|
20666
|
-
for (const
|
|
20667
|
-
const encoded = encodeCanonical(obj[
|
|
20668
|
-
if (encoded !== void 0) parts.push(`${JSON.stringify(
|
|
20666
|
+
for (const key2 of keys) {
|
|
20667
|
+
const encoded = encodeCanonical(obj[key2], `${path}.${key2}`, seen);
|
|
20668
|
+
if (encoded !== void 0) parts.push(`${JSON.stringify(key2)}:${encoded}`);
|
|
20669
20669
|
}
|
|
20670
20670
|
return `{${parts.join(",")}}`;
|
|
20671
20671
|
} finally {
|
|
@@ -21930,10 +21930,10 @@ var UNKNOWN_LEXICON = "";
|
|
|
21930
21930
|
function driftDigestsByLexicon(ir) {
|
|
21931
21931
|
const byLexicon = /* @__PURE__ */ new Map();
|
|
21932
21932
|
for (const n of ir.nodes) {
|
|
21933
|
-
const
|
|
21934
|
-
const bucket = byLexicon.get(
|
|
21933
|
+
const key2 = n.lexicon ?? UNKNOWN_LEXICON;
|
|
21934
|
+
const bucket = byLexicon.get(key2);
|
|
21935
21935
|
if (bucket) bucket.push(n);
|
|
21936
|
-
else byLexicon.set(
|
|
21936
|
+
else byLexicon.set(key2, [n]);
|
|
21937
21937
|
}
|
|
21938
21938
|
const out = {};
|
|
21939
21939
|
for (const [lexicon, nodes] of byLexicon) out[lexicon] = digestOf(nodes);
|
|
@@ -21941,8 +21941,8 @@ function driftDigestsByLexicon(ir) {
|
|
|
21941
21941
|
}
|
|
21942
21942
|
function changedLexicons(prev, next) {
|
|
21943
21943
|
const moved = /* @__PURE__ */ new Set();
|
|
21944
|
-
for (const
|
|
21945
|
-
if (prev[
|
|
21944
|
+
for (const key2 of /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)])) {
|
|
21945
|
+
if (prev[key2] !== next[key2]) moved.add(key2);
|
|
21946
21946
|
}
|
|
21947
21947
|
return [...moved].sort();
|
|
21948
21948
|
}
|
|
@@ -22485,7 +22485,7 @@ function opWavesLane(op, over = {}) {
|
|
|
22485
22485
|
};
|
|
22486
22486
|
}
|
|
22487
22487
|
async function terragucciApprovalMode(show, identityGates) {
|
|
22488
|
-
let
|
|
22488
|
+
let key2;
|
|
22489
22489
|
let note;
|
|
22490
22490
|
for (const name of TERRAGUCCI_CONFIG_NAMES) {
|
|
22491
22491
|
const text2 = await show(name);
|
|
@@ -22497,13 +22497,13 @@ async function terragucciApprovalMode(show, identityGates) {
|
|
|
22497
22497
|
try {
|
|
22498
22498
|
const doc = name.endsWith(".json") ? JSON.parse(text2) : parseYAML(text2);
|
|
22499
22499
|
const v = doc && !doc.projects ? doc.approval : void 0;
|
|
22500
|
-
if (v === "ledger" || v === "pr-review" || v === "sealed")
|
|
22500
|
+
if (v === "ledger" || v === "pr-review" || v === "sealed") key2 = v;
|
|
22501
22501
|
} catch (e) {
|
|
22502
22502
|
note = `${name} at base could not be parsed (${e instanceof Error ? e.message : String(e)}), so its approval key is not read`;
|
|
22503
22503
|
}
|
|
22504
22504
|
break;
|
|
22505
22505
|
}
|
|
22506
|
-
if (
|
|
22506
|
+
if (key2) return { mode: key2, source: `approval: ${key2} in the config at base`, ...note ? { note } : {} };
|
|
22507
22507
|
if (identityGates > 0) return { mode: "sealed", source: "identity.gates in chant.workspace.json at base, with no approval key", ...note ? { note } : {} };
|
|
22508
22508
|
return { mode: "ledger", source: "the default", ...note ? { note } : {} };
|
|
22509
22509
|
}
|
|
@@ -22943,12 +22943,12 @@ function cacheDir(origin, root = tmpdir3()) {
|
|
|
22943
22943
|
return join35(root, `${CACHE_PREFIX}${createHash8("sha256").update(origin).digest("hex").slice(0, 16)}`);
|
|
22944
22944
|
}
|
|
22945
22945
|
var inflight = /* @__PURE__ */ new Map();
|
|
22946
|
-
function serially(
|
|
22947
|
-
const prev = inflight.get(
|
|
22946
|
+
function serially(key2, fn) {
|
|
22947
|
+
const prev = inflight.get(key2) ?? Promise.resolve();
|
|
22948
22948
|
const next = prev.catch(() => void 0).then(fn);
|
|
22949
|
-
inflight.set(
|
|
22949
|
+
inflight.set(key2, next);
|
|
22950
22950
|
void next.finally(() => {
|
|
22951
|
-
if (inflight.get(
|
|
22951
|
+
if (inflight.get(key2) === next) inflight.delete(key2);
|
|
22952
22952
|
}).catch(() => void 0);
|
|
22953
22953
|
return next;
|
|
22954
22954
|
}
|
|
@@ -23212,24 +23212,24 @@ function terragucciValidator(dirs = []) {
|
|
|
23212
23212
|
}
|
|
23213
23213
|
return { validation: { by: "structural" }, check: structural };
|
|
23214
23214
|
}
|
|
23215
|
-
async function readDoc(source2,
|
|
23215
|
+
async function readDoc(source2, key2, name, v) {
|
|
23216
23216
|
let text2;
|
|
23217
23217
|
try {
|
|
23218
|
-
text2 = await source2.read(
|
|
23218
|
+
text2 = await source2.read(key2);
|
|
23219
23219
|
} catch (e) {
|
|
23220
|
-
refuse10(`Could not read ${
|
|
23220
|
+
refuse10(`Could not read ${key2} from ${source2.location}: ${e instanceof Error ? e.message : String(e)}`, readRemedy(source2));
|
|
23221
23221
|
}
|
|
23222
23222
|
if (text2 === void 0) return void 0;
|
|
23223
23223
|
let doc;
|
|
23224
23224
|
try {
|
|
23225
23225
|
doc = JSON.parse(text2);
|
|
23226
23226
|
} catch {
|
|
23227
|
-
refuse10(`${
|
|
23227
|
+
refuse10(`${key2} in ${source2.location} is not JSON.`, "Point --terragucci at a terragucci reports directory or bucket prefix, the one holding index.json.");
|
|
23228
23228
|
}
|
|
23229
23229
|
const why = v.check(name, doc);
|
|
23230
23230
|
if (why) {
|
|
23231
23231
|
refuse10(
|
|
23232
|
-
`${
|
|
23232
|
+
`${key2} in ${source2.location} is not a terragucci ${SCHEMA_IDS[name]} document: ${why}.`,
|
|
23233
23233
|
v.validation.by === "schema" ? `It was checked against @intentius/terragucci ${v.validation.terragucci}'s ${SCHEMA_FILES[name]}. Check that this terragucci wrote it, or upgrade behold.` : "Install @intentius/terragucci beside behold to check it against terragucci's own JSON Schemas, and check that terragucci wrote it."
|
|
23234
23234
|
);
|
|
23235
23235
|
}
|
|
@@ -23270,26 +23270,26 @@ async function readTerragucci(source2, opts = {}) {
|
|
|
23270
23270
|
const rows = index.reports.filter((r) => r.project === project).sort(newestFirst);
|
|
23271
23271
|
const cache6 = /* @__PURE__ */ new Map();
|
|
23272
23272
|
const report = (row) => {
|
|
23273
|
-
const
|
|
23274
|
-
if (!cache6.has(
|
|
23275
|
-
return cache6.get(
|
|
23273
|
+
const key2 = under(row.path, "report.json");
|
|
23274
|
+
if (!cache6.has(key2)) cache6.set(key2, readDoc(source2, key2, "report", v));
|
|
23275
|
+
return cache6.get(key2);
|
|
23276
23276
|
};
|
|
23277
23277
|
const wanted = opts.roots ? new Set(opts.roots) : void 0;
|
|
23278
23278
|
const roots = {};
|
|
23279
23279
|
const slot = { "tf-plan": "plan", "tf-drift": "drift", "tf-apply": "apply" };
|
|
23280
23280
|
for (const stage of ["tf-plan", "tf-drift", "tf-apply"]) {
|
|
23281
|
-
const
|
|
23281
|
+
const key2 = slot[stage];
|
|
23282
23282
|
let read = 0;
|
|
23283
23283
|
for (const row of rows.filter((r) => r.stage === stage)) {
|
|
23284
|
-
if (wanted && [...wanted].every((p) => roots[p]?.[
|
|
23284
|
+
if (wanted && [...wanted].every((p) => roots[p]?.[key2])) break;
|
|
23285
23285
|
if (read++ >= MAX_RUNS_PER_STAGE) break;
|
|
23286
23286
|
const doc = await report(row);
|
|
23287
23287
|
if (!doc) continue;
|
|
23288
23288
|
for (const r of doc.roots) {
|
|
23289
23289
|
if (wanted && !wanted.has(r.path)) continue;
|
|
23290
23290
|
const entry = roots[r.path] ??= {};
|
|
23291
|
-
if (entry[
|
|
23292
|
-
entry[
|
|
23291
|
+
if (entry[key2]) continue;
|
|
23292
|
+
entry[key2] = {
|
|
23293
23293
|
stage,
|
|
23294
23294
|
finished: doc.run.finished,
|
|
23295
23295
|
commit: doc.run.commit,
|
|
@@ -23484,9 +23484,9 @@ function joinTerragucci(read, nodes, roots) {
|
|
|
23484
23484
|
const at2 = n.id.indexOf(`/${root}/`);
|
|
23485
23485
|
if (at2 < 0) continue;
|
|
23486
23486
|
const member = n.id.slice(0, at2);
|
|
23487
|
-
const
|
|
23488
|
-
if (!byRoot.has(
|
|
23489
|
-
byRoot.get(
|
|
23487
|
+
const key2 = `${member}\0${root}`;
|
|
23488
|
+
if (!byRoot.has(key2)) byRoot.set(key2, /* @__PURE__ */ new Map());
|
|
23489
|
+
byRoot.get(key2).set(n.id.slice(at2 + root.length + 2), n.id);
|
|
23490
23490
|
}
|
|
23491
23491
|
const cards = {};
|
|
23492
23492
|
const applied = {};
|
|
@@ -23567,7 +23567,7 @@ var S3Error = class extends Error {
|
|
|
23567
23567
|
}
|
|
23568
23568
|
};
|
|
23569
23569
|
var encodeStrict = (v) => encodeURIComponent(v).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
23570
|
-
var encodePath = (
|
|
23570
|
+
var encodePath = (key2) => key2.split("/").map(encodeStrict).join("/");
|
|
23571
23571
|
var xmlText = (xml, tag) => {
|
|
23572
23572
|
const m = new RegExp(`<${tag}>([^<]*)</${tag}>`).exec(xml);
|
|
23573
23573
|
return m?.[1].replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").trim();
|
|
@@ -23614,8 +23614,8 @@ async function assumeRole(w, fetchFn) {
|
|
|
23614
23614
|
return { accessKeyId, secretAccessKey, sessionToken };
|
|
23615
23615
|
}
|
|
23616
23616
|
var sha256 = (b) => createHash9("sha256").update(b).digest("hex");
|
|
23617
|
-
var hmac = (
|
|
23618
|
-
var objectUrl = (t2,
|
|
23617
|
+
var hmac = (key2, s) => createHmac("sha256", key2).update(s).digest();
|
|
23618
|
+
var objectUrl = (t2, key2) => `${t2.endpoint ? `${t2.endpoint}/${t2.bucket}` : `https://${t2.bucket}.s3.${t2.region}.amazonaws.com`}/${encodePath(key2)}`;
|
|
23619
23619
|
function sign(t2, method, rawUrl, extra2, payload, now) {
|
|
23620
23620
|
const url = new URL(rawUrl);
|
|
23621
23621
|
const amzDate = now.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
|
|
@@ -23657,14 +23657,14 @@ var S3Object = class {
|
|
|
23657
23657
|
return { bucket: t2.bucket, ...t2.endpoint ? { endpoint: t2.endpoint } : {}, region: t2.region, ...await this.creds };
|
|
23658
23658
|
}
|
|
23659
23659
|
/** The object's text, or undefined when there is none. */
|
|
23660
|
-
async get(
|
|
23660
|
+
async get(key2) {
|
|
23661
23661
|
const t2 = await this.signer();
|
|
23662
|
-
const url = objectUrl(t2,
|
|
23662
|
+
const url = objectUrl(t2, key2);
|
|
23663
23663
|
const res = await this.fetchFn(url, { method: "GET", headers: sign(t2, "GET", url, {}, sha256(""), this.now()) });
|
|
23664
23664
|
if (res.status === 404) return void 0;
|
|
23665
23665
|
if (!res.ok) {
|
|
23666
23666
|
const body = await res.text();
|
|
23667
|
-
throw new S3Error(`GET s3://${t2.bucket}/${
|
|
23667
|
+
throw new S3Error(`GET s3://${t2.bucket}/${key2}: ${res.status} ${body.slice(0, 300)}`, { status: res.status, body });
|
|
23668
23668
|
}
|
|
23669
23669
|
return res.text();
|
|
23670
23670
|
}
|
|
@@ -23673,36 +23673,36 @@ var S3Object = class {
|
|
|
23673
23673
|
* `ifNoneMatch` (S3 answers 304), its ETag otherwise, undefined when there
|
|
23674
23674
|
* is no such object.
|
|
23675
23675
|
*/
|
|
23676
|
-
async head(
|
|
23676
|
+
async head(key2, ifNoneMatch) {
|
|
23677
23677
|
const t2 = await this.signer();
|
|
23678
|
-
const url = objectUrl(t2,
|
|
23678
|
+
const url = objectUrl(t2, key2);
|
|
23679
23679
|
const extra2 = ifNoneMatch ? { "if-none-match": ifNoneMatch } : {};
|
|
23680
23680
|
const res = await this.fetchFn(url, { method: "HEAD", headers: sign(t2, "HEAD", url, extra2, sha256(""), this.now()) });
|
|
23681
23681
|
if (res.status === 304) return { same: true };
|
|
23682
23682
|
if (res.status === 404) return void 0;
|
|
23683
|
-
if (!res.ok) throw new S3Error(`HEAD s3://${t2.bucket}/${
|
|
23683
|
+
if (!res.ok) throw new S3Error(`HEAD s3://${t2.bucket}/${key2}: ${res.status}`, { status: res.status, body: "" });
|
|
23684
23684
|
const etag = res.headers?.get("etag") ?? void 0;
|
|
23685
23685
|
return { same: false, ...etag ? { etag } : {} };
|
|
23686
23686
|
}
|
|
23687
23687
|
/** Write an object, with a Cache-Control header when one is given. */
|
|
23688
|
-
async put(
|
|
23688
|
+
async put(key2, body, contentType2, cacheControl) {
|
|
23689
23689
|
const t2 = await this.signer();
|
|
23690
|
-
const url = objectUrl(t2,
|
|
23690
|
+
const url = objectUrl(t2, key2);
|
|
23691
23691
|
const extra2 = { "content-type": contentType2, ...cacheControl ? { "cache-control": cacheControl } : {} };
|
|
23692
23692
|
const res = await this.fetchFn(url, { method: "PUT", headers: sign(t2, "PUT", url, extra2, sha256(body), this.now()), body });
|
|
23693
23693
|
if (!res.ok) {
|
|
23694
23694
|
const text2 = await res.text();
|
|
23695
|
-
throw new S3Error(`PUT s3://${t2.bucket}/${
|
|
23695
|
+
throw new S3Error(`PUT s3://${t2.bucket}/${key2}: ${res.status} ${text2.slice(0, 300)}`, { status: res.status, body: text2 });
|
|
23696
23696
|
}
|
|
23697
23697
|
}
|
|
23698
23698
|
/** Delete an object. A missing one is not an error. */
|
|
23699
|
-
async delete(
|
|
23699
|
+
async delete(key2) {
|
|
23700
23700
|
const t2 = await this.signer();
|
|
23701
|
-
const url = objectUrl(t2,
|
|
23701
|
+
const url = objectUrl(t2, key2);
|
|
23702
23702
|
const res = await this.fetchFn(url, { method: "DELETE", headers: sign(t2, "DELETE", url, {}, sha256(""), this.now()) });
|
|
23703
23703
|
if (res.ok || res.status === 404) return;
|
|
23704
23704
|
const text2 = await res.text();
|
|
23705
|
-
throw new S3Error(`DELETE s3://${t2.bucket}/${
|
|
23705
|
+
throw new S3Error(`DELETE s3://${t2.bucket}/${key2}: ${res.status} ${text2.slice(0, 300)}`, { status: res.status, body: text2 });
|
|
23706
23706
|
}
|
|
23707
23707
|
};
|
|
23708
23708
|
|
|
@@ -23714,11 +23714,11 @@ var TerragucciDenied = class extends Error {
|
|
|
23714
23714
|
url;
|
|
23715
23715
|
/** Which kind of source refused, for the words. */
|
|
23716
23716
|
via;
|
|
23717
|
-
constructor(
|
|
23717
|
+
constructor(key2, url, detail, via = "s3") {
|
|
23718
23718
|
super(
|
|
23719
23719
|
via === "http" ? `${url} is not readable with these credentials (${detail}): the server refused the GET, and behold sends no credentials to an http(s) source, so whatever serves it has to allow reading that key (a bucket website answers 403 for a missing object too when it may not list the bucket)` : `${url} is not readable with these credentials (${detail}): reading it needs s3:GetObject on that key, and S3 answers 403 for a missing object too when the credentials lack s3:ListBucket on the bucket`
|
|
23720
23720
|
);
|
|
23721
|
-
this.key =
|
|
23721
|
+
this.key = key2;
|
|
23722
23722
|
this.url = url;
|
|
23723
23723
|
this.via = via;
|
|
23724
23724
|
}
|
|
@@ -23746,13 +23746,13 @@ function terragucciSource(spec2, opts = {}) {
|
|
|
23746
23746
|
return {
|
|
23747
23747
|
kind: "s3",
|
|
23748
23748
|
location: `s3://${joinKey(bucket, prefix)}`,
|
|
23749
|
-
async read(
|
|
23750
|
-
const k = joinKey(prefix,
|
|
23749
|
+
async read(key2) {
|
|
23750
|
+
const k = joinKey(prefix, key2);
|
|
23751
23751
|
try {
|
|
23752
23752
|
return await client.get(k);
|
|
23753
23753
|
} catch (e) {
|
|
23754
23754
|
if (e instanceof S3Error && (e.status === 403 || e.code === "AccessDenied")) {
|
|
23755
|
-
throw new TerragucciDenied(trim(
|
|
23755
|
+
throw new TerragucciDenied(trim(key2), `s3://${joinKey(bucket, k)}`, `${e.status ?? 403}${e.code ? ` ${e.code}` : ""}`);
|
|
23756
23756
|
}
|
|
23757
23757
|
throw e;
|
|
23758
23758
|
}
|
|
@@ -23763,12 +23763,12 @@ function terragucciSource(spec2, opts = {}) {
|
|
|
23763
23763
|
return {
|
|
23764
23764
|
kind: "s3",
|
|
23765
23765
|
location: `s3://${joinKey(bucket, prefix)}`,
|
|
23766
|
-
async read(
|
|
23767
|
-
const url = `s3://${joinKey(bucket, prefix,
|
|
23766
|
+
async read(key2) {
|
|
23767
|
+
const url = `s3://${joinKey(bucket, prefix, key2)}`;
|
|
23768
23768
|
const r = await aws(["s3", "cp", url, "-", "--only-show-errors"]);
|
|
23769
23769
|
if (r.code === 0) return r.stdout;
|
|
23770
23770
|
if (/\b(404|NoSuchKey|Not Found|does not exist)\b/i.test(r.stderr)) return void 0;
|
|
23771
|
-
if (/\b(403|AccessDenied|Forbidden)\b|Access Denied/i.test(r.stderr)) throw new TerragucciDenied(trim(
|
|
23771
|
+
if (/\b(403|AccessDenied|Forbidden)\b|Access Denied/i.test(r.stderr)) throw new TerragucciDenied(trim(key2), url, /AccessDenied/i.test(r.stderr) ? "AccessDenied" : "403");
|
|
23772
23772
|
throw new Error(r.code === -1 ? `could not run aws to read ${url}: ${r.stderr.trim()}` : `aws s3 cp ${url} failed: ${r.stderr.trim() || `exit ${r.code}`}`);
|
|
23773
23773
|
}
|
|
23774
23774
|
};
|
|
@@ -23779,11 +23779,11 @@ function terragucciSource(spec2, opts = {}) {
|
|
|
23779
23779
|
return {
|
|
23780
23780
|
kind: "http",
|
|
23781
23781
|
location: base,
|
|
23782
|
-
async read(
|
|
23783
|
-
const url = `${base}/${trim(
|
|
23782
|
+
async read(key2) {
|
|
23783
|
+
const url = `${base}/${trim(key2)}`;
|
|
23784
23784
|
const res = await get(url);
|
|
23785
23785
|
if (res.status === 404) return void 0;
|
|
23786
|
-
if (res.status === 403) throw new TerragucciDenied(trim(
|
|
23786
|
+
if (res.status === 403) throw new TerragucciDenied(trim(key2), url, "403", "http");
|
|
23787
23787
|
if (!res.ok) throw new Error(`GET ${url} answered ${res.status}`);
|
|
23788
23788
|
return await res.text();
|
|
23789
23789
|
}
|
|
@@ -23793,9 +23793,9 @@ function terragucciSource(spec2, opts = {}) {
|
|
|
23793
23793
|
return {
|
|
23794
23794
|
kind: "dir",
|
|
23795
23795
|
location: dir,
|
|
23796
|
-
async read(
|
|
23796
|
+
async read(key2) {
|
|
23797
23797
|
try {
|
|
23798
|
-
return await readFile(join37(dir, ...trim(
|
|
23798
|
+
return await readFile(join37(dir, ...trim(key2).split("/")), "utf8");
|
|
23799
23799
|
} catch (e) {
|
|
23800
23800
|
if (e.code === "ENOENT") return void 0;
|
|
23801
23801
|
throw e;
|
|
@@ -23939,9 +23939,9 @@ function timelineEntries(entries, project) {
|
|
|
23939
23939
|
for (const r of roots) s.add(r);
|
|
23940
23940
|
gateRoots.set(gate(e), s);
|
|
23941
23941
|
}
|
|
23942
|
-
const
|
|
23942
|
+
const key2 = reportKey(e);
|
|
23943
23943
|
const prev = gateReport.get(gate(e));
|
|
23944
|
-
if (
|
|
23944
|
+
if (key2 && (!prev || at(e.at) >= prev.at)) gateReport.set(gate(e), { at: at(e.at), key: key2 });
|
|
23945
23945
|
}
|
|
23946
23946
|
const out = mine.map(({ e, i }) => {
|
|
23947
23947
|
const d = e.detail ?? {};
|
|
@@ -24038,16 +24038,16 @@ function terragucciTimelineRoute(app, source2, opts = {}) {
|
|
|
24038
24038
|
}
|
|
24039
24039
|
const root = q.get("root") || void 0;
|
|
24040
24040
|
const checkout = opts.checkoutProject?.();
|
|
24041
|
-
const
|
|
24041
|
+
const key2 = checkout ?? "";
|
|
24042
24042
|
const now = Date.now();
|
|
24043
|
-
if (q.get("fresh") === "1" || !cached || cached.key !==
|
|
24043
|
+
if (q.get("fresh") === "1" || !cached || cached.key !== key2 || now - cached.at >= TIMELINE_TTL_MS) {
|
|
24044
24044
|
const p = readTimeline(source2, {
|
|
24045
24045
|
...opts.project ? { project: opts.project } : {},
|
|
24046
24046
|
...checkout ? { checkoutProject: checkout } : {},
|
|
24047
24047
|
...opts.validator ? { validator: opts.validator() } : {},
|
|
24048
24048
|
...opts.now ? { now: opts.now() } : {}
|
|
24049
24049
|
});
|
|
24050
|
-
cached = { at: now, key, read: p };
|
|
24050
|
+
cached = { at: now, key: key2, read: p };
|
|
24051
24051
|
p.catch(() => cached = void 0);
|
|
24052
24052
|
}
|
|
24053
24053
|
let r;
|
|
@@ -24076,19 +24076,19 @@ function indexProbe(spec2, opts = {}) {
|
|
|
24076
24076
|
const s3 = /^s3:\/\/([^/]+)\/?(.*)$/.exec(spec2);
|
|
24077
24077
|
if (s3) {
|
|
24078
24078
|
const bucket = s3[1];
|
|
24079
|
-
const
|
|
24079
|
+
const key2 = joinKey2(s3[2] ?? "", name);
|
|
24080
24080
|
const env = opts.env ?? process.env;
|
|
24081
24081
|
if (!opts.aws && hasEnvCredentials(env)) {
|
|
24082
24082
|
const client = new S3Object(s3FromEnv(bucket, env), opts.fetch);
|
|
24083
24083
|
return async (prev) => {
|
|
24084
|
-
const h = await client.head(
|
|
24084
|
+
const h = await client.head(key2, prev);
|
|
24085
24085
|
if (!h) return verdict2(prev, void 0);
|
|
24086
24086
|
return h.same ? { tag: prev, changed: false } : verdict2(prev, h.etag);
|
|
24087
24087
|
};
|
|
24088
24088
|
}
|
|
24089
24089
|
const aws = opts.aws ?? realAws;
|
|
24090
24090
|
return async (prev) => {
|
|
24091
|
-
const r = await aws(["s3api", "head-object", "--bucket", bucket, "--key",
|
|
24091
|
+
const r = await aws(["s3api", "head-object", "--bucket", bucket, "--key", key2, ...prev ? ["--if-none-match", prev] : [], "--output", "json"]);
|
|
24092
24092
|
if (r.code === 0) {
|
|
24093
24093
|
let etag;
|
|
24094
24094
|
try {
|
|
@@ -24100,7 +24100,7 @@ function indexProbe(spec2, opts = {}) {
|
|
|
24100
24100
|
}
|
|
24101
24101
|
if (/\(304\)|Not Modified/i.test(r.stderr)) return { tag: prev, changed: false };
|
|
24102
24102
|
if (/\(404\)|Not Found|NoSuchKey/i.test(r.stderr)) return verdict2(prev, void 0);
|
|
24103
|
-
throw new Error(`aws s3api head-object s3://${bucket}/${
|
|
24103
|
+
throw new Error(`aws s3api head-object s3://${bucket}/${key2} failed: ${r.stderr.trim() || `exit ${r.code}`}`);
|
|
24104
24104
|
};
|
|
24105
24105
|
}
|
|
24106
24106
|
if (/^https?:\/\//.test(spec2)) {
|
|
@@ -24210,9 +24210,9 @@ var TerragucciPoller = class {
|
|
|
24210
24210
|
this.o.onLifecycle?.(a);
|
|
24211
24211
|
if (a.commit) lifecycle.commit = a.commit.sha;
|
|
24212
24212
|
lifecycle.via = a.via;
|
|
24213
|
-
const
|
|
24214
|
-
if (
|
|
24215
|
-
this.lastKey =
|
|
24213
|
+
const key2 = lifecycleKey(a);
|
|
24214
|
+
if (key2 !== this.lastKey) {
|
|
24215
|
+
this.lastKey = key2;
|
|
24216
24216
|
this.send({ type: "lifecycle", data: a });
|
|
24217
24217
|
}
|
|
24218
24218
|
} catch (e) {
|
|
@@ -24375,9 +24375,9 @@ function joinProgress(run3, nodes, roots) {
|
|
|
24375
24375
|
if (typeof root !== "string") continue;
|
|
24376
24376
|
const at2 = n.id.indexOf(`/${root}/`);
|
|
24377
24377
|
if (at2 < 0) continue;
|
|
24378
|
-
const
|
|
24379
|
-
if (!byRoot.has(
|
|
24380
|
-
byRoot.get(
|
|
24378
|
+
const key2 = `${n.id.slice(0, at2)}\0${root}`;
|
|
24379
|
+
if (!byRoot.has(key2)) byRoot.set(key2, /* @__PURE__ */ new Map());
|
|
24380
|
+
byRoot.get(key2).set(n.id.slice(at2 + root.length + 2), n.id);
|
|
24381
24381
|
}
|
|
24382
24382
|
const rootByPath = new Map(roots.map((r) => [r.path, r]));
|
|
24383
24383
|
const waves = [];
|
|
@@ -24453,11 +24453,11 @@ var TerragucciProgress = class {
|
|
|
24453
24453
|
}
|
|
24454
24454
|
/** The answer, from the 30 s cache unless `fresh`. */
|
|
24455
24455
|
answer(fresh = false) {
|
|
24456
|
-
const
|
|
24456
|
+
const key2 = this.o.checkoutProject?.() ?? "";
|
|
24457
24457
|
const at2 = Date.now();
|
|
24458
|
-
if (!fresh && this.cached && this.cached.key ===
|
|
24458
|
+
if (!fresh && this.cached && this.cached.key === key2 && at2 - this.cached.at < PROGRESS_TTL_MS) return this.cached.answer;
|
|
24459
24459
|
const p = this.read();
|
|
24460
|
-
this.cached = { at: at2, key, answer: p };
|
|
24460
|
+
this.cached = { at: at2, key: key2, answer: p };
|
|
24461
24461
|
p.catch(() => this.cached = void 0);
|
|
24462
24462
|
return p;
|
|
24463
24463
|
}
|
|
@@ -24468,14 +24468,14 @@ var TerragucciProgress = class {
|
|
|
24468
24468
|
* poll's watch stays on the newest.
|
|
24469
24469
|
*/
|
|
24470
24470
|
answerFor(commit, fresh = false) {
|
|
24471
|
-
const
|
|
24471
|
+
const key2 = `${this.o.checkoutProject?.() ?? ""}\0${commit}`;
|
|
24472
24472
|
const at2 = Date.now();
|
|
24473
|
-
const hit = this.pinned.get(
|
|
24473
|
+
const hit = this.pinned.get(key2);
|
|
24474
24474
|
if (!fresh && hit && at2 - hit.at < PROGRESS_TTL_MS) return hit.answer;
|
|
24475
24475
|
for (const [k, v] of this.pinned) if (at2 - v.at >= PROGRESS_TTL_MS) this.pinned.delete(k);
|
|
24476
24476
|
const p = this.read(commit);
|
|
24477
|
-
this.pinned.set(
|
|
24478
|
-
p.catch(() => this.pinned.delete(
|
|
24477
|
+
this.pinned.set(key2, { at: at2, answer: p });
|
|
24478
|
+
p.catch(() => this.pinned.delete(key2));
|
|
24479
24479
|
return p;
|
|
24480
24480
|
}
|
|
24481
24481
|
pinned = /* @__PURE__ */ new Map();
|
|
@@ -24520,36 +24520,36 @@ var TerragucciProgress = class {
|
|
|
24520
24520
|
watching: false
|
|
24521
24521
|
};
|
|
24522
24522
|
}
|
|
24523
|
-
const
|
|
24524
|
-
const a = await this.readRun(project, row.commit,
|
|
24525
|
-
if (!commit) this.watch = { key, commit: row.commit, project, last: a };
|
|
24523
|
+
const key2 = runKey(row);
|
|
24524
|
+
const a = await this.readRun(project, row.commit, key2, v?.run);
|
|
24525
|
+
if (!commit) this.watch = { key: key2, commit: row.commit, project, last: a };
|
|
24526
24526
|
return a;
|
|
24527
24527
|
}
|
|
24528
24528
|
base(project, validation) {
|
|
24529
24529
|
return { source: this.o.source.location, kind: this.o.source.kind, project, validation: validation ?? { by: "structural" }, read: this.now().toISOString(), files: FILES };
|
|
24530
24530
|
}
|
|
24531
24531
|
/** One GET of run.json, checked and joined. */
|
|
24532
|
-
async readRun(project, commit,
|
|
24532
|
+
async readRun(project, commit, key2, v) {
|
|
24533
24533
|
const src = this.o.source;
|
|
24534
24534
|
const validator2 = v ?? runValidator();
|
|
24535
24535
|
let text2;
|
|
24536
24536
|
let unreadable;
|
|
24537
24537
|
try {
|
|
24538
|
-
text2 = await src.read(
|
|
24538
|
+
text2 = await src.read(key2);
|
|
24539
24539
|
} catch (e) {
|
|
24540
24540
|
if (e instanceof TerragucciDenied) unreadable = deniedWords(e, "the wave's progress");
|
|
24541
24541
|
else refuse12(
|
|
24542
|
-
`Could not read ${
|
|
24542
|
+
`Could not read ${key2} from ${src.location}: ${e instanceof Error ? e.message : String(e)}`,
|
|
24543
24543
|
src.kind === "s3" ? "behold reads the bucket with your aws CLI or the environment's credentials: check GetObject on <prefix>/*/runs/*/run.json." : "Check the source serves the reports prefix."
|
|
24544
24544
|
);
|
|
24545
24545
|
}
|
|
24546
|
-
const html =
|
|
24546
|
+
const html = key2.replace(/run\.json$/, "run.html");
|
|
24547
24547
|
if (text2 === void 0) {
|
|
24548
24548
|
return {
|
|
24549
24549
|
...this.base(project, validator2.validation),
|
|
24550
|
-
run: { commit, key, present: false },
|
|
24550
|
+
run: { commit, key: key2, present: false },
|
|
24551
24551
|
...unreadable ? { unreadable: true } : {},
|
|
24552
|
-
absent: unreadable ?? `${src.location} has no ${
|
|
24552
|
+
absent: unreadable ?? `${src.location} has no ${key2}: terragucci writes the run view when reports.bucket is set, and a wave's progress per resource only for a choudoufu wave (terragucci 0.4.7 and newer). This says nothing about whether the apply moved.`,
|
|
24553
24553
|
states: [],
|
|
24554
24554
|
reads: [],
|
|
24555
24555
|
waves: [],
|
|
@@ -24562,12 +24562,12 @@ var TerragucciProgress = class {
|
|
|
24562
24562
|
try {
|
|
24563
24563
|
doc = JSON.parse(text2);
|
|
24564
24564
|
} catch {
|
|
24565
|
-
refuse12(`${
|
|
24565
|
+
refuse12(`${key2} in ${src.location} is not JSON.`, "Check that terragucci wrote it.");
|
|
24566
24566
|
}
|
|
24567
24567
|
const why = validator2.check(doc);
|
|
24568
24568
|
if (why) {
|
|
24569
24569
|
refuse12(
|
|
24570
|
-
`${
|
|
24570
|
+
`${key2} in ${src.location} is not a terragucci ${RUN_SCHEMA} document: ${why}.`,
|
|
24571
24571
|
validator2.validation.by === "schema" ? `It was checked against @intentius/terragucci ${validator2.validation.terragucci}'s ${RUN_SCHEMA_FILE}. Check that this terragucci wrote it, or upgrade behold.` : "Install @intentius/terragucci beside behold to check it against terragucci's own JSON Schema, and check that terragucci wrote it."
|
|
24572
24572
|
);
|
|
24573
24573
|
}
|
|
@@ -24580,7 +24580,7 @@ var TerragucciProgress = class {
|
|
|
24580
24580
|
}
|
|
24581
24581
|
return {
|
|
24582
24582
|
...this.base(project, validator2.validation),
|
|
24583
|
-
run: { commit, key, present: true, updated: run3.updated, html },
|
|
24583
|
+
run: { commit, key: key2, present: true, updated: run3.updated, html },
|
|
24584
24584
|
...joinProgress(run3, ctx.nodes, ctx.roots)
|
|
24585
24585
|
};
|
|
24586
24586
|
}
|
|
@@ -24747,23 +24747,23 @@ function cycleProblem(doc, tool) {
|
|
|
24747
24747
|
}
|
|
24748
24748
|
async function readCycle(source2, tool, now = /* @__PURE__ */ new Date()) {
|
|
24749
24749
|
const base = { source: source2.location, read: now.toISOString() };
|
|
24750
|
-
const
|
|
24750
|
+
const key2 = cycleKey(tool);
|
|
24751
24751
|
let body;
|
|
24752
24752
|
try {
|
|
24753
|
-
body = await source2.read(
|
|
24753
|
+
body = await source2.read(key2);
|
|
24754
24754
|
} catch (e) {
|
|
24755
24755
|
if (e instanceof TerragucciDenied) return { ...base, cycle: null, error: deniedWords(e, `${tool}'s latest cycle`), code: "terragucci-cycle" };
|
|
24756
|
-
return { ...base, cycle: null, error: `behold could not read ${
|
|
24756
|
+
return { ...base, cycle: null, error: `behold could not read ${key2} from ${source2.location}: ${e instanceof Error ? e.message : String(e)}`, code: "terragucci-cycle" };
|
|
24757
24757
|
}
|
|
24758
|
-
if (body === void 0) return { ...base, cycle: null, absent: `${source2.location} has no ${
|
|
24758
|
+
if (body === void 0) return { ...base, cycle: null, absent: `${source2.location} has no ${key2}: the loop driver writes it when a cycle of ${tool}'s scenario ends.` };
|
|
24759
24759
|
let doc;
|
|
24760
24760
|
try {
|
|
24761
24761
|
doc = JSON.parse(body);
|
|
24762
24762
|
} catch {
|
|
24763
|
-
return { ...base, cycle: null, error: `${
|
|
24763
|
+
return { ...base, cycle: null, error: `${key2} in ${source2.location} is not JSON.`, code: "terragucci-cycle" };
|
|
24764
24764
|
}
|
|
24765
24765
|
const problem = cycleProblem(doc, tool);
|
|
24766
|
-
if (problem) return { ...base, cycle: null, error: `${
|
|
24766
|
+
if (problem) return { ...base, cycle: null, error: `${key2} in ${source2.location} is not the driver's format: ${problem}.`, code: "terragucci-cycle" };
|
|
24767
24767
|
const c = doc;
|
|
24768
24768
|
return {
|
|
24769
24769
|
...base,
|
|
@@ -24871,24 +24871,24 @@ function runProblemOf(doc, id) {
|
|
|
24871
24871
|
if (doc.id !== id) return `its id is ${JSON.stringify(doc.id)}, not ${id}`;
|
|
24872
24872
|
return runProblem(doc, true, "the run");
|
|
24873
24873
|
}
|
|
24874
|
-
async function readDoc2(source2,
|
|
24875
|
-
const base = { source: source2.location, read: now.toISOString(), key };
|
|
24874
|
+
async function readDoc2(source2, key2, what, problem, now) {
|
|
24875
|
+
const base = { source: source2.location, read: now.toISOString(), key: key2 };
|
|
24876
24876
|
let body;
|
|
24877
24877
|
try {
|
|
24878
|
-
body = await source2.read(
|
|
24878
|
+
body = await source2.read(key2);
|
|
24879
24879
|
} catch (e) {
|
|
24880
24880
|
if (e instanceof TerragucciDenied) return { ...base, doc: null, error: deniedWords(e, what), code: "terragucci-runs" };
|
|
24881
|
-
return { ...base, doc: null, error: `behold could not read ${
|
|
24881
|
+
return { ...base, doc: null, error: `behold could not read ${key2} from ${source2.location}: ${e instanceof Error ? e.message : String(e)}`, code: "terragucci-runs" };
|
|
24882
24882
|
}
|
|
24883
|
-
if (body === void 0) return { ...base, doc: null, absent: `${source2.location} has no ${
|
|
24883
|
+
if (body === void 0) return { ...base, doc: null, absent: `${source2.location} has no ${key2}: the demo's loop driver writes the pipeline runs there (terragucci's stack/demo.sh).` };
|
|
24884
24884
|
let doc;
|
|
24885
24885
|
try {
|
|
24886
24886
|
doc = JSON.parse(body);
|
|
24887
24887
|
} catch {
|
|
24888
|
-
return { ...base, doc: null, error: `${
|
|
24888
|
+
return { ...base, doc: null, error: `${key2} in ${source2.location} is not JSON.`, code: "terragucci-runs" };
|
|
24889
24889
|
}
|
|
24890
24890
|
const p = problem(doc);
|
|
24891
|
-
if (p) return { ...base, doc: null, error: `${
|
|
24891
|
+
if (p) return { ...base, doc: null, error: `${key2} in ${source2.location} is not the driver's format: ${p}.`, code: "terragucci-runs" };
|
|
24892
24892
|
return { ...base, doc };
|
|
24893
24893
|
}
|
|
24894
24894
|
function readRunsIndex(source2, now = /* @__PURE__ */ new Date()) {
|
|
@@ -24902,13 +24902,13 @@ function runIdOf(raw) {
|
|
|
24902
24902
|
}
|
|
24903
24903
|
function terragucciRunsRoutes(app, source2, opts = {}) {
|
|
24904
24904
|
const cache6 = /* @__PURE__ */ new Map();
|
|
24905
|
-
const shared2 = (
|
|
24905
|
+
const shared2 = (key2, read) => {
|
|
24906
24906
|
const at2 = Date.now();
|
|
24907
|
-
const hit = cache6.get(
|
|
24907
|
+
const hit = cache6.get(key2);
|
|
24908
24908
|
if (hit && at2 - hit.at < RUNS_READ_TTL_MS) return hit.read;
|
|
24909
24909
|
for (const [k, v] of cache6) if (at2 - v.at >= RUNS_READ_TTL_MS) cache6.delete(k);
|
|
24910
24910
|
const p = read();
|
|
24911
|
-
cache6.set(
|
|
24911
|
+
cache6.set(key2, { at: at2, read: p });
|
|
24912
24912
|
return p;
|
|
24913
24913
|
};
|
|
24914
24914
|
const answer = (a) => {
|
|
@@ -24978,9 +24978,9 @@ function terragucciRoutes(app, opts, dirs) {
|
|
|
24978
24978
|
const source2 = terragucciSource(opts.source, { ...opts.aws ? { aws: opts.aws } : {}, ...opts.fetch ? { fetch: opts.fetch } : {} });
|
|
24979
24979
|
let cached;
|
|
24980
24980
|
const read = (roots, served2, fresh) => {
|
|
24981
|
-
const
|
|
24981
|
+
const key2 = served2.join("\0");
|
|
24982
24982
|
const now = Date.now();
|
|
24983
|
-
if (!fresh && cached && cached.key ===
|
|
24983
|
+
if (!fresh && cached && cached.key === key2 && now - cached.at < TERRAGUCCI_READ_TTL_MS) return cached.read;
|
|
24984
24984
|
const base = repoBase(served2);
|
|
24985
24985
|
const p = readTerragucci(source2, {
|
|
24986
24986
|
...opts.project ? { project: opts.project } : {},
|
|
@@ -24989,7 +24989,7 @@ function terragucciRoutes(app, opts, dirs) {
|
|
|
24989
24989
|
validator: terragucciValidator(served2),
|
|
24990
24990
|
...opts.now ? { now: opts.now() } : {}
|
|
24991
24991
|
});
|
|
24992
|
-
cached = { at: now, key, read: p };
|
|
24992
|
+
cached = { at: now, key: key2, read: p };
|
|
24993
24993
|
p.catch(() => cached = void 0);
|
|
24994
24994
|
return p;
|
|
24995
24995
|
};
|
|
@@ -25002,7 +25002,7 @@ function terragucciRoutes(app, opts, dirs) {
|
|
|
25002
25002
|
const served2 = dirs();
|
|
25003
25003
|
return { nodes: (await composeEstate(served2, { detail: 3 })).nodes, roots: checkoutRoots(served2) };
|
|
25004
25004
|
},
|
|
25005
|
-
probe: (
|
|
25005
|
+
probe: (key2) => indexProbe(opts.source, { key: key2, ...opts.aws ? { aws: opts.aws } : {}, ...opts.fetch ? { fetch: opts.fetch } : {} }),
|
|
25006
25006
|
...opts.now ? { now: opts.now } : {}
|
|
25007
25007
|
});
|
|
25008
25008
|
terragucciProgressRoute(app, progress);
|
|
@@ -25058,23 +25058,204 @@ function terragucciRoutes(app, opts, dirs) {
|
|
|
25058
25058
|
...opts.now ? { now: opts.now } : {}
|
|
25059
25059
|
});
|
|
25060
25060
|
app.get("/api/terragucci/file", async (c) => {
|
|
25061
|
-
const
|
|
25062
|
-
if (!FILE_KEY.test(
|
|
25061
|
+
const key2 = new URL(c.req.url).searchParams.get("key") ?? "";
|
|
25062
|
+
if (!FILE_KEY.test(key2)) return c.json({ error: `not a report file: ${JSON.stringify(key2)}`, code: "terragucci-file" }, 400);
|
|
25063
25063
|
let body;
|
|
25064
25064
|
try {
|
|
25065
|
-
body = await source2.read(
|
|
25065
|
+
body = await source2.read(key2);
|
|
25066
25066
|
} catch (e) {
|
|
25067
25067
|
return c.json({ error: e instanceof Error ? e.message : String(e), code: "terragucci-file" }, 502);
|
|
25068
25068
|
}
|
|
25069
|
-
if (body === void 0) return c.json({ error: `${source2.location} has no ${
|
|
25069
|
+
if (body === void 0) return c.json({ error: `${source2.location} has no ${key2}`, code: "terragucci-file" }, 404);
|
|
25070
25070
|
return c.body(body, 200, {
|
|
25071
|
-
"content-type": TYPES[
|
|
25071
|
+
"content-type": TYPES[key2.slice(key2.lastIndexOf(".") + 1)],
|
|
25072
25072
|
"content-security-policy": "sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox",
|
|
25073
25073
|
"x-content-type-options": "nosniff"
|
|
25074
25074
|
});
|
|
25075
25075
|
});
|
|
25076
25076
|
}
|
|
25077
25077
|
|
|
25078
|
+
// src/prometheus-metrics.ts
|
|
25079
|
+
var METRICS_TTL_MS = 3e4;
|
|
25080
|
+
var RUN_WINDOW = "3h";
|
|
25081
|
+
var DORA_WINDOW = "7d";
|
|
25082
|
+
var QUERIES = {
|
|
25083
|
+
rootPlan: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_plan_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25084
|
+
rootApply: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_apply_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25085
|
+
held: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_held_seconds[${RUN_WINDOW}]))`,
|
|
25086
|
+
changes: `max by (project, commit, run, wave, action) (last_over_time(terragucci_wave_changes[${RUN_WINDOW}]))`,
|
|
25087
|
+
settled: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_settled_seconds[${RUN_WINDOW}]))`,
|
|
25088
|
+
waiting: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_waiting_since_seconds[${RUN_WINDOW}]))`,
|
|
25089
|
+
deployments: `max by (project) (last_over_time(terragucci_dora_deployments_per_week[${DORA_WINDOW}]))`,
|
|
25090
|
+
leadTime: `max by (project) (last_over_time(terragucci_dora_lead_time_seconds{segment="total"}[${DORA_WINDOW}]))`,
|
|
25091
|
+
failureRate: `max by (project) (last_over_time(terragucci_dora_change_failure_ratio[${DORA_WINDOW}]))`,
|
|
25092
|
+
restore: `max by (project) (last_over_time(terragucci_dora_restore_seconds[${DORA_WINDOW}]))`
|
|
25093
|
+
};
|
|
25094
|
+
var REPO = /^(?:[A-Za-z0-9][A-Za-z0-9._-]{0,99}\/)?[A-Za-z0-9._-]{1,100}$/;
|
|
25095
|
+
var COMMIT = /^[0-9a-f]{7,64}$/;
|
|
25096
|
+
var validRepo = (v) => !!v && REPO.test(v) && !v.split("/").some((p) => p === "." || p === "..");
|
|
25097
|
+
var validCommit = (v) => !!v && COMMIT.test(v);
|
|
25098
|
+
function projectIs(project, repo) {
|
|
25099
|
+
if (!project) return false;
|
|
25100
|
+
return project === repo || project.endsWith(`/${repo}`);
|
|
25101
|
+
}
|
|
25102
|
+
function parseVector(body) {
|
|
25103
|
+
const b = body;
|
|
25104
|
+
if (!b || b.status !== "success" || !b.data || b.data.resultType !== "vector" || !Array.isArray(b.data.result)) {
|
|
25105
|
+
throw new Error("Prometheus did not answer with an instant vector");
|
|
25106
|
+
}
|
|
25107
|
+
const out = [];
|
|
25108
|
+
for (const r of b.data.result) {
|
|
25109
|
+
const v = Array.isArray(r.value) ? Number(r.value[1]) : NaN;
|
|
25110
|
+
if (!Number.isFinite(v)) continue;
|
|
25111
|
+
const labels = {};
|
|
25112
|
+
for (const [k, x] of Object.entries(r.metric ?? {})) if (typeof x === "string") labels[k] = x;
|
|
25113
|
+
out.push({ labels, value: v });
|
|
25114
|
+
}
|
|
25115
|
+
return out;
|
|
25116
|
+
}
|
|
25117
|
+
var key = (s) => `${s.labels.commit ?? ""}\0${s.labels.run ?? ""}\0${s.labels.wave ?? ""}`;
|
|
25118
|
+
function runOf(a, repo, commit) {
|
|
25119
|
+
const mine = (xs) => xs.filter((s) => projectIs(s.labels.project, repo) && /^\d+$/.test(s.labels.wave ?? ""));
|
|
25120
|
+
const rows = { ...a, rootPlan: mine(a.rootPlan), rootApply: mine(a.rootApply), held: mine(a.held), changes: mine(a.changes), settled: mine(a.settled), waiting: mine(a.waiting) };
|
|
25121
|
+
const moved = /* @__PURE__ */ new Map();
|
|
25122
|
+
const note = (s) => {
|
|
25123
|
+
const k = key(s);
|
|
25124
|
+
const had = moved.get(k);
|
|
25125
|
+
if (!had || s.value > had.at) moved.set(k, { commit: s.labels.commit ?? "", run: s.labels.run ?? "", wave: Number(s.labels.wave), at: s.value });
|
|
25126
|
+
};
|
|
25127
|
+
for (const s of [...rows.settled, ...rows.waiting]) note(s);
|
|
25128
|
+
for (const s of [...rows.rootPlan, ...rows.rootApply]) if (!moved.has(key(s))) moved.set(key(s), { commit: s.labels.commit ?? "", run: s.labels.run ?? "", wave: Number(s.labels.wave), at: 0 });
|
|
25129
|
+
if (moved.size === 0) return null;
|
|
25130
|
+
const commits = /* @__PURE__ */ new Map();
|
|
25131
|
+
for (const m of moved.values()) commits.set(m.commit, Math.max(commits.get(m.commit) ?? 0, m.at));
|
|
25132
|
+
const asked = commit ? [...commits.keys()].find((c) => c && (c === commit || c.startsWith(commit) || commit.startsWith(c))) : void 0;
|
|
25133
|
+
const chosen = asked ?? [...commits.entries()].sort((x, y) => y[1] - x[1])[0][0];
|
|
25134
|
+
const waves = /* @__PURE__ */ new Map();
|
|
25135
|
+
for (const m of moved.values()) {
|
|
25136
|
+
if (m.commit !== chosen) continue;
|
|
25137
|
+
const had = waves.get(m.wave);
|
|
25138
|
+
if (!had || m.at > had.at) waves.set(m.wave, { run: m.run, at: m.at });
|
|
25139
|
+
}
|
|
25140
|
+
const of = (xs, wave, run3) => xs.filter((s) => (s.labels.commit ?? "") === chosen && (s.labels.run ?? "") === run3 && Number(s.labels.wave) === wave);
|
|
25141
|
+
const out = [];
|
|
25142
|
+
for (const [wave, { run: run3 }] of [...waves.entries()].sort((x, y) => x[0] - y[0])) {
|
|
25143
|
+
const roots = /* @__PURE__ */ new Map();
|
|
25144
|
+
for (const s of of(rows.rootPlan, wave, run3)) if (s.labels.root) roots.set(s.labels.root, { ...roots.get(s.labels.root) ?? { root: s.labels.root }, plan_seconds: s.value });
|
|
25145
|
+
for (const s of of(rows.rootApply, wave, run3)) if (s.labels.root) roots.set(s.labels.root, { ...roots.get(s.labels.root) ?? { root: s.labels.root }, apply_seconds: s.value });
|
|
25146
|
+
const changes = {};
|
|
25147
|
+
for (const s of of(rows.changes, wave, run3)) if (s.labels.action && s.value > 0) changes[s.labels.action] = s.value;
|
|
25148
|
+
const held = of(rows.held, wave, run3)[0];
|
|
25149
|
+
const settled = of(rows.settled, wave, run3)[0];
|
|
25150
|
+
const waiting = of(rows.waiting, wave, run3)[0];
|
|
25151
|
+
out.push({
|
|
25152
|
+
wave,
|
|
25153
|
+
run: run3 || null,
|
|
25154
|
+
roots: [...roots.values()].sort((x, y) => x.root.localeCompare(y.root)),
|
|
25155
|
+
...held ? { held_seconds: held.value } : {},
|
|
25156
|
+
changes,
|
|
25157
|
+
...waiting && (!settled || waiting.value > settled.value) ? { waiting_since: waiting.value } : {},
|
|
25158
|
+
...settled ? { settled_at: settled.value } : {}
|
|
25159
|
+
});
|
|
25160
|
+
}
|
|
25161
|
+
return { commit: chosen || null, current: !!asked, waves: out };
|
|
25162
|
+
}
|
|
25163
|
+
function doraOf(a, repo) {
|
|
25164
|
+
const pick = (xs) => xs.find((s) => projectIs(s.labels.project, repo))?.value;
|
|
25165
|
+
const d = { deployments_per_week: pick(a.deployments), lead_time_seconds: pick(a.leadTime), change_failure_ratio: pick(a.failureRate), restore_seconds: pick(a.restore) };
|
|
25166
|
+
const set = Object.fromEntries(Object.entries(d).filter(([, v]) => v !== void 0));
|
|
25167
|
+
return Object.keys(set).length ? { from: "prometheus", ...set } : null;
|
|
25168
|
+
}
|
|
25169
|
+
function doraFromFile(text2, repo) {
|
|
25170
|
+
if (!text2) return null;
|
|
25171
|
+
let doc;
|
|
25172
|
+
try {
|
|
25173
|
+
doc = JSON.parse(text2);
|
|
25174
|
+
} catch {
|
|
25175
|
+
return null;
|
|
25176
|
+
}
|
|
25177
|
+
const projects = doc.projects;
|
|
25178
|
+
if (!Array.isArray(projects)) return null;
|
|
25179
|
+
const p = projects.find((x) => x && typeof x === "object" && projectIs(x.project, repo));
|
|
25180
|
+
if (!p) return null;
|
|
25181
|
+
const num3 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
25182
|
+
const d = {
|
|
25183
|
+
deployments_per_week: num3(p.per_week),
|
|
25184
|
+
lead_time_seconds: num3(p.lead_time?.median_seconds),
|
|
25185
|
+
change_failure_ratio: num3(p.change_failure?.rate),
|
|
25186
|
+
restore_seconds: num3(p.restore?.median_seconds)
|
|
25187
|
+
};
|
|
25188
|
+
const set = Object.fromEntries(Object.entries(d).filter(([, v]) => v !== void 0));
|
|
25189
|
+
return Object.keys(set).length ? { dora: { from: "dora.json", ...set }, project: p.project } : null;
|
|
25190
|
+
}
|
|
25191
|
+
function prometheusAddress(v) {
|
|
25192
|
+
if (!v) return void 0;
|
|
25193
|
+
try {
|
|
25194
|
+
const u = new URL(v);
|
|
25195
|
+
if (u.protocol !== "http:" && u.protocol !== "https:" || u.search || u.hash) return void 0;
|
|
25196
|
+
return u.toString().replace(/\/+$/, "");
|
|
25197
|
+
} catch {
|
|
25198
|
+
return void 0;
|
|
25199
|
+
}
|
|
25200
|
+
}
|
|
25201
|
+
async function askAll(base, fetchFn = fetch) {
|
|
25202
|
+
const names = Object.keys(QUERIES);
|
|
25203
|
+
const answers = await Promise.all(
|
|
25204
|
+
names.map(async (n) => {
|
|
25205
|
+
const res = await fetchFn(`${base}/api/v1/query?query=${encodeURIComponent(QUERIES[n])}`, { signal: AbortSignal.timeout(5e3), headers: { accept: "application/json" } });
|
|
25206
|
+
if (!res.ok) throw new Error(`Prometheus answered ${res.status} to ${n}`);
|
|
25207
|
+
return parseVector(await res.json());
|
|
25208
|
+
})
|
|
25209
|
+
);
|
|
25210
|
+
return Object.fromEntries(names.map((n, i) => [n, answers[i]]));
|
|
25211
|
+
}
|
|
25212
|
+
function metricsRoute(app, opts) {
|
|
25213
|
+
let shared2;
|
|
25214
|
+
let dora;
|
|
25215
|
+
const answers = () => {
|
|
25216
|
+
const t2 = Date.now();
|
|
25217
|
+
if (!shared2 || t2 - shared2.at >= METRICS_TTL_MS) {
|
|
25218
|
+
const read = askAll(opts.prometheus, opts.fetch);
|
|
25219
|
+
shared2 = { at: t2, read };
|
|
25220
|
+
read.catch(() => {
|
|
25221
|
+
if (shared2?.read === read) shared2 = void 0;
|
|
25222
|
+
});
|
|
25223
|
+
}
|
|
25224
|
+
return shared2.read;
|
|
25225
|
+
};
|
|
25226
|
+
const doraText = () => {
|
|
25227
|
+
if (!opts.doraFile) return Promise.resolve(void 0);
|
|
25228
|
+
const t2 = Date.now();
|
|
25229
|
+
if (!dora || t2 - dora.at >= METRICS_TTL_MS) dora = { at: t2, read: opts.doraFile().catch(() => void 0) };
|
|
25230
|
+
return dora.read;
|
|
25231
|
+
};
|
|
25232
|
+
app.get("/api/metrics", async (c) => {
|
|
25233
|
+
if (!opts.prometheus) return c.json({ error: "behold reads no Prometheus: start it with --prometheus <url>", code: "metrics-off" }, 404);
|
|
25234
|
+
const repo = c.req.query("project");
|
|
25235
|
+
if (!validRepo(repo)) return c.json({ error: "project must be a forge repo's <owner>/<name>", code: "metrics-project" }, 400);
|
|
25236
|
+
const asked = c.req.query("commit");
|
|
25237
|
+
if (asked !== void 0 && !validCommit(asked)) return c.json({ error: "commit must be a commit's hex id", code: "metrics-commit" }, 400);
|
|
25238
|
+
let a;
|
|
25239
|
+
try {
|
|
25240
|
+
a = await answers();
|
|
25241
|
+
} catch (e) {
|
|
25242
|
+
return c.json({ error: `behold could not read Prometheus: ${e instanceof Error ? e.message : String(e)}`, code: "metrics-read" }, 502, { "cache-control": "no-store" });
|
|
25243
|
+
}
|
|
25244
|
+
const run3 = runOf(a, repo, asked);
|
|
25245
|
+
let d = doraOf(a, repo);
|
|
25246
|
+
let project = [...a.settled, ...a.waiting, ...a.rootPlan, ...a.deployments].find((s) => projectIs(s.labels.project, repo))?.labels.project ?? null;
|
|
25247
|
+
if (!d) {
|
|
25248
|
+
const f = doraFromFile(await doraText(), repo);
|
|
25249
|
+
if (f) {
|
|
25250
|
+
d = f.dora;
|
|
25251
|
+
project ??= f.project;
|
|
25252
|
+
}
|
|
25253
|
+
}
|
|
25254
|
+
const body = { read: (opts.now ? opts.now() : /* @__PURE__ */ new Date()).toISOString(), repo, project, run: run3, dora: d };
|
|
25255
|
+
return c.json(body, 200, { "cache-control": "no-store" });
|
|
25256
|
+
});
|
|
25257
|
+
}
|
|
25258
|
+
|
|
25078
25259
|
// src/view-repos.ts
|
|
25079
25260
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
25080
25261
|
import { existsSync as existsSync24, readdirSync as readdirSync14, readFileSync as readFileSync31 } from "node:fs";
|
|
@@ -25983,11 +26164,11 @@ function migrateOpLane(env, ledgerPrefix = "") {
|
|
|
25983
26164
|
function onceGit(git3) {
|
|
25984
26165
|
const seen = /* @__PURE__ */ new Map();
|
|
25985
26166
|
return (args, o) => {
|
|
25986
|
-
const
|
|
25987
|
-
let p = seen.get(
|
|
26167
|
+
const key2 = JSON.stringify(args);
|
|
26168
|
+
let p = seen.get(key2);
|
|
25988
26169
|
if (!p) {
|
|
25989
26170
|
p = git3(args, o);
|
|
25990
|
-
seen.set(
|
|
26171
|
+
seen.set(key2, p);
|
|
25991
26172
|
}
|
|
25992
26173
|
return p;
|
|
25993
26174
|
};
|
|
@@ -26193,9 +26374,9 @@ async function readControlEstate(source2, config, opts = {}) {
|
|
|
26193
26374
|
const v = opts.validator ?? terragucciValidator();
|
|
26194
26375
|
const rv = opts.runValidator ?? runViewValidator();
|
|
26195
26376
|
let gets = 0;
|
|
26196
|
-
const get = async (
|
|
26377
|
+
const get = async (key2) => {
|
|
26197
26378
|
gets++;
|
|
26198
|
-
return source2.read(
|
|
26379
|
+
return source2.read(key2);
|
|
26199
26380
|
};
|
|
26200
26381
|
let text2;
|
|
26201
26382
|
try {
|
|
@@ -26235,15 +26416,15 @@ async function readControlEstate(source2, config, opts = {}) {
|
|
|
26235
26416
|
if (!commit) {
|
|
26236
26417
|
missing = p.status === "ok" ? "no apply has run, so there is no run view" : p.status === "no-index" ? "no runs in the bucket yet" : `its index could not be read${p.error ? `: ${p.error}` : ""}`;
|
|
26237
26418
|
} else {
|
|
26238
|
-
const
|
|
26419
|
+
const key2 = runKey3(p, commit);
|
|
26239
26420
|
let body;
|
|
26240
26421
|
try {
|
|
26241
|
-
body = await get(
|
|
26422
|
+
body = await get(key2);
|
|
26242
26423
|
} catch (e) {
|
|
26243
26424
|
if (e instanceof TerragucciDenied) missing = deniedWords(e, "this project's run view");
|
|
26244
|
-
else refused2 = refusal(`Could not read ${
|
|
26425
|
+
else refused2 = refusal(`Could not read ${key2} from ${source2.location}: ${e instanceof Error ? e.message : String(e)}`, "Check GetObject on <prefix>/*/runs/*/run.json is allowed.");
|
|
26245
26426
|
}
|
|
26246
|
-
if (!refused2 && !missing && body === void 0) missing = `no run view at ${
|
|
26427
|
+
if (!refused2 && !missing && body === void 0) missing = `no run view at ${key2}`;
|
|
26247
26428
|
if (!refused2 && body !== void 0) {
|
|
26248
26429
|
let parsed;
|
|
26249
26430
|
let problem;
|
|
@@ -26257,7 +26438,7 @@ async function readControlEstate(source2, config, opts = {}) {
|
|
|
26257
26438
|
if (!problem && parsed.commit !== commit) problem = `it is the run view of ${parsed.commit}, not ${commit}`;
|
|
26258
26439
|
if (problem) {
|
|
26259
26440
|
refused2 = refusal(
|
|
26260
|
-
`${
|
|
26441
|
+
`${key2} in ${source2.location} is not a terragucci ${RUN_SCHEMA2} document: ${problem}.`,
|
|
26261
26442
|
rv.validation.by === "schema" ? `It was checked against @intentius/terragucci ${rv.validation.terragucci}'s run.schema.json. Check that this terragucci wrote it, or upgrade behold.` : "Install @intentius/terragucci beside behold to check it against terragucci's own run.schema.json, and check that terragucci wrote it."
|
|
26262
26443
|
);
|
|
26263
26444
|
} else {
|
|
@@ -26267,8 +26448,8 @@ async function readControlEstate(source2, config, opts = {}) {
|
|
|
26267
26448
|
commit,
|
|
26268
26449
|
updated: view.updated,
|
|
26269
26450
|
from: p.run_view?.commit === commit ? "run_view" : "apply",
|
|
26270
|
-
key,
|
|
26271
|
-
page:
|
|
26451
|
+
key: key2,
|
|
26452
|
+
page: key2.replace(/run\.json$/, "run.html"),
|
|
26272
26453
|
roots: view.roots.map((r) => ({
|
|
26273
26454
|
root: r.root,
|
|
26274
26455
|
wave: r.wave,
|
|
@@ -26288,7 +26469,7 @@ async function readControlEstate(source2, config, opts = {}) {
|
|
|
26288
26469
|
...w.command ? { command: w.command } : {},
|
|
26289
26470
|
...w.updated ? { updated: w.updated } : {}
|
|
26290
26471
|
})),
|
|
26291
|
-
dated: { key, at: view.updated }
|
|
26472
|
+
dated: { key: key2, at: view.updated }
|
|
26292
26473
|
};
|
|
26293
26474
|
}
|
|
26294
26475
|
}
|
|
@@ -26363,10 +26544,10 @@ function terragucciEstateRoutes(app, opts, dirs) {
|
|
|
26363
26544
|
404
|
|
26364
26545
|
);
|
|
26365
26546
|
}
|
|
26366
|
-
const
|
|
26547
|
+
const key2 = served2.join("\0");
|
|
26367
26548
|
const now = Date.now();
|
|
26368
26549
|
const fresh = new URL(c.req.url).searchParams.get("fresh") === "1";
|
|
26369
|
-
if (fresh || !cached || cached.key !==
|
|
26550
|
+
if (fresh || !cached || cached.key !== key2 || now - cached.at >= TERRAGUCCI_READ_TTL_MS) {
|
|
26370
26551
|
const base = repoBase(served2);
|
|
26371
26552
|
const p = readControlEstate(source2, control.config, {
|
|
26372
26553
|
validator: terragucciValidator(served2),
|
|
@@ -26375,7 +26556,7 @@ function terragucciEstateRoutes(app, opts, dirs) {
|
|
|
26375
26556
|
base,
|
|
26376
26557
|
...opts.now ? { now: opts.now() } : {}
|
|
26377
26558
|
});
|
|
26378
|
-
cached = { at: now, key, read: p };
|
|
26559
|
+
cached = { at: now, key: key2, read: p };
|
|
26379
26560
|
p.catch(() => cached = void 0);
|
|
26380
26561
|
}
|
|
26381
26562
|
try {
|
|
@@ -26842,12 +27023,12 @@ function yodelValidator(dirs = []) {
|
|
|
26842
27023
|
if (!root) continue;
|
|
26843
27024
|
try {
|
|
26844
27025
|
const version = JSON.parse(readFileSync35(join47(root, "package.json"), "utf8")).version ?? "";
|
|
26845
|
-
const
|
|
26846
|
-
let v = installed.get(
|
|
27026
|
+
const key2 = `${root}\0${version}`;
|
|
27027
|
+
let v = installed.get(key2);
|
|
26847
27028
|
if (!v) {
|
|
26848
27029
|
const load2 = (n) => JSON.parse(readFileSync35(join47(root, "schemas", `${n}.schema.json`), "utf8"));
|
|
26849
27030
|
v = compile({ common: load2("common"), report: load2("report"), drift: load2("drift") }, { by: "schema", from: "package", sqlYodeler: version });
|
|
26850
|
-
installed.set(
|
|
27031
|
+
installed.set(key2, v);
|
|
26851
27032
|
}
|
|
26852
27033
|
return v;
|
|
26853
27034
|
} catch {
|
|
@@ -27612,6 +27793,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
27612
27793
|
const estateSourceRoots = async (opts) => (await Promise.all((cfg.projectDirs ?? []).map(async (dir) => [await graphPath(dir, opts), dir]))).flat();
|
|
27613
27794
|
app.get("/healthz", (c) => c.json({ ok: true, projectDir: cfg.projectDir, env: cfg.env ?? null, frames: frames.size }));
|
|
27614
27795
|
kioskRoute(app, webRoot, !!cfg.terragucci);
|
|
27796
|
+
const doraSource = cfg.terragucci && cfg.prometheus ? terragucciSource(cfg.terragucci.source, { ...cfg.terragucci.aws ? { aws: cfg.terragucci.aws } : {}, ...cfg.terragucci.fetch ? { fetch: cfg.terragucci.fetch } : {} }) : void 0;
|
|
27797
|
+
metricsRoute(app, { ...cfg.prometheus ? { prometheus: cfg.prometheus } : {}, ...doraSource ? { doraFile: () => doraSource.read("dora.json") } : {} });
|
|
27615
27798
|
vendorRoutes(app, webRoot, !!cfg.terragucci);
|
|
27616
27799
|
app.get("/api/frames", (c) => c.json({ frames: frames.summaries() }));
|
|
27617
27800
|
app.get("/lanes", (c) => {
|
|
@@ -27851,15 +28034,15 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
27851
28034
|
const ws = servedWorkspace();
|
|
27852
28035
|
if (!ws) return c.json({ error: "behold isn't serving a declared workspace", code: "no-workspace" }, 404);
|
|
27853
28036
|
const body = await c.req.json().catch(() => ({}));
|
|
27854
|
-
const
|
|
28037
|
+
const key2 = typeof body?.key === "string" ? body.key : "";
|
|
27855
28038
|
const env = typeof body?.env === "string" && body.env ? body.env : cfg.env || "local";
|
|
27856
28039
|
if (!isEnvName(env)) return c.json({ error: `${JSON.stringify(env)} isn't an env name`, code: "env" }, 400);
|
|
27857
28040
|
const read = await readWorkspaceGates(ws, env);
|
|
27858
28041
|
if (!read.ok) return c.json({ error: read.refusal.error, code: read.refusal.code }, 422);
|
|
27859
|
-
const g = read.gates.find((x) => x.key ===
|
|
27860
|
-
if (!g) return c.json({ error: `no gate ${
|
|
27861
|
-
if (isOverrideGate(g)) return c.json({ error: `${
|
|
27862
|
-
if (g.signed) return c.json({ error: `${
|
|
28042
|
+
const g = read.gates.find((x) => x.key === key2);
|
|
28043
|
+
if (!g) return c.json({ error: `no gate ${key2} is waiting in ${env}`, code: "no-gate" }, 404);
|
|
28044
|
+
if (isOverrideGate(g)) return c.json({ error: `${key2} is a policy denial, which behold never overrides. Run, with your reason: ${g.approve}`, code: "override" }, 422);
|
|
28045
|
+
if (g.signed) return c.json({ error: `${key2} wants a signed approval, which behold can't make. Run: ${g.approve}`, code: "signed" }, 422);
|
|
27863
28046
|
const approver = localApprover();
|
|
27864
28047
|
broadcaster.emit("op", `\u270E approve ${g.key} as ${approver}`);
|
|
27865
28048
|
const { code, stderr, stdout } = await runChantRaw(approveArgs(g), g.dir);
|
|
@@ -29500,8 +29683,8 @@ function canonicalKey(path, params) {
|
|
|
29500
29683
|
const q = LENS_PARAMS.filter((k) => params.has(k) && !(flat && (k === "detail" || k === "radial"))).map((k) => `${k}=${params.get(k)}`).join("&");
|
|
29501
29684
|
return q ? `${path}?${q}` : path;
|
|
29502
29685
|
}
|
|
29503
|
-
function slug3(
|
|
29504
|
-
const base =
|
|
29686
|
+
function slug3(key2, body) {
|
|
29687
|
+
const base = key2.replace(/^\//, "").replace(/[^a-zA-Z0-9=_.-]+/g, "_").slice(0, 120);
|
|
29505
29688
|
return `${base}.${createHash11("sha256").update(body).digest("hex").slice(0, 16)}.json`;
|
|
29506
29689
|
}
|
|
29507
29690
|
var CONTENT_ADDRESSED = /^snapshots\/[A-Za-z0-9=_.-]+\.[0-9a-f]{16}\.json$/;
|
|
@@ -29595,20 +29778,20 @@ async function runExport(cfg, outDir, opts = {}) {
|
|
|
29595
29778
|
const keyToFile = {};
|
|
29596
29779
|
let ok = 0;
|
|
29597
29780
|
let failed = 0;
|
|
29598
|
-
for (const
|
|
29599
|
-
const res = await app.request(`${
|
|
29600
|
-
const body = scrub(shapeSnapshot(
|
|
29601
|
-
const file = slug3(
|
|
29781
|
+
for (const key2 of captureKeys(axes)) {
|
|
29782
|
+
const res = await app.request(`${key2}${key2.includes("?") ? "&" : "?"}layout=1`);
|
|
29783
|
+
const body = scrub(shapeSnapshot(key2, await res.text(), opts));
|
|
29784
|
+
const file = slug3(key2, body);
|
|
29602
29785
|
writeFileSync8(join52(snapDir, file), body);
|
|
29603
|
-
keyToFile[
|
|
29786
|
+
keyToFile[key2] = `snapshots/${file}`;
|
|
29604
29787
|
if (res.ok) ok++;
|
|
29605
29788
|
else failed++;
|
|
29606
|
-
if (
|
|
29789
|
+
if (key2 === "/api/terragucci" && !res.ok) {
|
|
29607
29790
|
const refusal2 = JSON.parse(body);
|
|
29608
29791
|
throw new Error(`terragucci reports not read: ${refusal2.error ?? res.status}${refusal2.remedy ? `
|
|
29609
29792
|
${refusal2.remedy}` : ""}`);
|
|
29610
29793
|
}
|
|
29611
|
-
if (
|
|
29794
|
+
if (key2 === "/api/yodel-report" && !res.ok) {
|
|
29612
29795
|
const refusal2 = JSON.parse(body);
|
|
29613
29796
|
throw new Error(`SQL Yodeler report not read: ${refusal2.error ?? res.status}${refusal2.remedy ? `
|
|
29614
29797
|
${refusal2.remedy}` : ""}`);
|
|
@@ -29659,7 +29842,7 @@ function dropSource(v) {
|
|
|
29659
29842
|
if (isRecord22(v.attrs)) delete v.attrs.source;
|
|
29660
29843
|
for (const x of Object.values(v)) dropSource(x);
|
|
29661
29844
|
}
|
|
29662
|
-
function shapeSnapshot(
|
|
29845
|
+
function shapeSnapshot(key2, body, opts = {}) {
|
|
29663
29846
|
let doc;
|
|
29664
29847
|
try {
|
|
29665
29848
|
doc = JSON.parse(body);
|
|
@@ -29667,11 +29850,11 @@ function shapeSnapshot(key, body, opts = {}) {
|
|
|
29667
29850
|
return body;
|
|
29668
29851
|
}
|
|
29669
29852
|
if (!isRecord22(doc)) return body;
|
|
29670
|
-
if (
|
|
29853
|
+
if (key2 === "/api/project") {
|
|
29671
29854
|
delete doc.recents;
|
|
29672
29855
|
delete doc.approver;
|
|
29673
29856
|
}
|
|
29674
|
-
if (
|
|
29857
|
+
if (key2 === "/api/terragucci" || key2 === "/api/terragucci/timeline") doc.files = opts.reportsBase ?? VIEWS_REPORTS_BASE;
|
|
29675
29858
|
if (opts.noSource) dropSource(doc);
|
|
29676
29859
|
return JSON.stringify(doc);
|
|
29677
29860
|
}
|
|
@@ -29812,20 +29995,20 @@ import { readFileSync as readFileSync41 } from "node:fs";
|
|
|
29812
29995
|
import { join as join53 } from "node:path";
|
|
29813
29996
|
var DEFAULT_KEEP = 30;
|
|
29814
29997
|
var SNAPSHOT_REPORTS_BASE = "../../../";
|
|
29815
|
-
var
|
|
29998
|
+
var COMMIT2 = /^[0-9a-f]{7,64}$/;
|
|
29816
29999
|
function resolveCommit2(dir, given) {
|
|
29817
30000
|
const git3 = (...args) => execFileSync4("git", ["-C", dir, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
29818
30001
|
let sha;
|
|
29819
30002
|
if (given !== void 0) {
|
|
29820
30003
|
sha = given.toLowerCase();
|
|
29821
|
-
if (!
|
|
30004
|
+
if (!COMMIT2.test(sha)) return { error: `--commit takes a commit's hex digits (7 to 64 of them), not ${given}` };
|
|
29822
30005
|
} else {
|
|
29823
30006
|
try {
|
|
29824
30007
|
sha = git3("rev-parse", "HEAD").toLowerCase();
|
|
29825
30008
|
} catch {
|
|
29826
30009
|
return { error: `--publish files the view under the served checkout's commit, and ${dir} is not a git checkout with a commit: pass --commit <sha>` };
|
|
29827
30010
|
}
|
|
29828
|
-
if (!
|
|
30011
|
+
if (!COMMIT2.test(sha)) return { error: `git rev-parse HEAD in ${dir} answered ${sha}: pass --commit <sha>` };
|
|
29829
30012
|
}
|
|
29830
30013
|
try {
|
|
29831
30014
|
const at2 = git3("show", "-s", "--format=%cI", `${sha}^{commit}`);
|
|
@@ -29839,7 +30022,7 @@ function parseHistory(text2) {
|
|
|
29839
30022
|
const doc = JSON.parse(text2);
|
|
29840
30023
|
if (!Array.isArray(doc)) throw new Error("history.json is not an array");
|
|
29841
30024
|
const str17 = (v) => typeof v === "string" ? v : "";
|
|
29842
|
-
return doc.filter((e) => isRecord23(e) && typeof e.commit === "string" &&
|
|
30025
|
+
return doc.filter((e) => isRecord23(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str17(e.at), project: str17(e.project), generated: str17(e.generated) }));
|
|
29843
30026
|
}
|
|
29844
30027
|
function nextHistory(old, entry, keep) {
|
|
29845
30028
|
const all = [entry, ...old.filter((e) => e.commit !== entry.commit)];
|
|
@@ -29875,7 +30058,7 @@ function redirectPage() {
|
|
|
29875
30058
|
return r.json();
|
|
29876
30059
|
})
|
|
29877
30060
|
.then(function (l) {
|
|
29878
|
-
if (!l || typeof l.commit !== "string" || !${
|
|
30061
|
+
if (!l || typeof l.commit !== "string" || !${COMMIT2}.test(l.commit)) throw new Error("latest.json names no commit");
|
|
29879
30062
|
location.replace(base + l.commit + "/index.html" + location.search + location.hash);
|
|
29880
30063
|
})
|
|
29881
30064
|
.catch(function (e) { document.getElementById("m").textContent = "No published view to open: " + e.message; });
|
|
@@ -29893,7 +30076,7 @@ var message = (e) => e instanceof Error ? e.message : String(e);
|
|
|
29893
30076
|
var denied = (e) => e instanceof S3Error && (e.status === 403 || e.code === "AccessDenied");
|
|
29894
30077
|
async function publishSnapshot(outDir, target, commit, client, opts = {}) {
|
|
29895
30078
|
const sha = commit.sha.toLowerCase();
|
|
29896
|
-
if (!
|
|
30079
|
+
if (!COMMIT2.test(sha)) throw new Error(`a commit is 7 to 64 hex digits, not ${commit.sha}`);
|
|
29897
30080
|
const keep = opts.keep ?? DEFAULT_KEEP;
|
|
29898
30081
|
if (!Number.isInteger(keep) || keep < 1) throw new Error(`--keep takes a whole number of at least 1, not ${keep}`);
|
|
29899
30082
|
const at2 = (f) => `${target.prefix}/${f}`;
|
|
@@ -30047,6 +30230,12 @@ Options:
|
|
|
30047
30230
|
--hud <url> serve only: where hud reviews this workspace's records
|
|
30048
30231
|
(BEHOLD_HUD_URL too). A proposed decision in a member's
|
|
30049
30232
|
or a card's "why" links to its review there (#471).
|
|
30233
|
+
--prometheus <url> serve only: the Prometheus behold reads a pipeline's
|
|
30234
|
+
numbers from (BEHOLD_PROMETHEUS_URL too), with a fixed
|
|
30235
|
+
set of queries of terragucci's gauges: each wave's plan
|
|
30236
|
+
and apply seconds, its time at the gate and its changes,
|
|
30237
|
+
and the DORA metrics. /api/metrics?project=<owner>/<name>
|
|
30238
|
+
answers them, and the kiosk shows them (behold#571).
|
|
30050
30239
|
--terragucci <src> serve/export: paint a terragucci estate from its reports
|
|
30051
30240
|
(#490). <src> is a report directory (a synced bucket
|
|
30052
30241
|
prefix, or <prefix>/<project>), s3://bucket/prefix (read
|
|
@@ -30191,6 +30380,7 @@ ${USAGE}`);
|
|
|
30191
30380
|
let local = false;
|
|
30192
30381
|
let host;
|
|
30193
30382
|
let hudArg = process.env.BEHOLD_HUD_URL || void 0;
|
|
30383
|
+
let prometheusArg = process.env.BEHOLD_PROMETHEUS_URL || void 0;
|
|
30194
30384
|
let terragucci;
|
|
30195
30385
|
let terragucciProject;
|
|
30196
30386
|
let terragucciPoll;
|
|
@@ -30205,6 +30395,7 @@ ${USAGE}`);
|
|
|
30205
30395
|
else if (a === "--host") host = rest[++i];
|
|
30206
30396
|
else if (a === "--allow-host") allowHosts.push(...(rest[++i] ?? "").split(","));
|
|
30207
30397
|
else if (a === "--hud") hudArg = rest[++i];
|
|
30398
|
+
else if (a === "--prometheus") prometheusArg = rest[++i];
|
|
30208
30399
|
else if (a === "--terragucci") terragucci = rest[++i];
|
|
30209
30400
|
else if (a === "--terragucci-project") terragucciProject = rest[++i];
|
|
30210
30401
|
else if (a === "--terragucci-poll") terragucciPoll = Number(rest[++i]);
|
|
@@ -30253,6 +30444,12 @@ ${USAGE}`);
|
|
|
30253
30444
|
process.exit(2);
|
|
30254
30445
|
}
|
|
30255
30446
|
const hud = hudAddress(hudArg);
|
|
30447
|
+
const prometheus = prometheusAddress(prometheusArg);
|
|
30448
|
+
if (prometheusArg && !prometheus) {
|
|
30449
|
+
process.stderr.write(`behold serve: --prometheus must be an http or https address with no query, not ${JSON.stringify(prometheusArg)}
|
|
30450
|
+
`);
|
|
30451
|
+
process.exit(2);
|
|
30452
|
+
}
|
|
30256
30453
|
if (hudArg && !hud) {
|
|
30257
30454
|
process.stderr.write(`behold serve: --hud must be an http or https address, not ${JSON.stringify(hudArg)}
|
|
30258
30455
|
`);
|
|
@@ -30322,6 +30519,7 @@ ${USAGE}`);
|
|
|
30322
30519
|
...allowHosts.length ? { allowedHosts: allowHosts } : {},
|
|
30323
30520
|
...isPublic ? { public: true, layoutWrites: false } : {},
|
|
30324
30521
|
...target.workspace && hud ? { hud } : {},
|
|
30522
|
+
...prometheus ? { prometheus } : {},
|
|
30325
30523
|
...yodelReport ? { yodelReport: resolve35(yodelReport) } : {},
|
|
30326
30524
|
...terragucci ? { terragucci: { source: terragucci, ...terragucciProject ? { project: terragucciProject } : {}, ...terragucciPoll !== void 0 ? { pollSecs: terragucciPoll } : {}, ...terragucciRuns ? { runsSource: terragucciRuns } : {} } } : {}
|
|
30327
30525
|
});
|