@intentius/behold 0.30.2 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +791 -16
- package/README.md +78 -23
- package/THIRD_PARTY.md +6 -5
- package/demos.json +14 -9
- package/dist/cli.js +51926 -20221
- package/example-carve/README.md +19 -23
- package/example-carve/app/package.json +1 -1
- package/example-carve/app/src/carved.ts +3 -3
- package/example-carve/carve-report.json +1 -1
- package/example-carve/{legacy-tf → tf-root}/terraform.tfstate +1 -1
- package/example-choudoufu-estate/README.md +7 -0
- package/example-choudoufu-estate/chant.workspace.json +1 -1
- package/example-choudoufu-estate/scripts/choudoufu-down.sh +2 -1
- package/example-choudoufu-estate/scripts/choudoufu-up.sh +10 -3
- package/example-terraform-estate/README.md +32 -5
- package/example-terraform-estate/chant.workspace.json +1 -1
- package/example-terraform-estate/recorded/adoption/platform.json +72 -0
- package/example-terraform-estate/recorded/adoption/prod.json +224 -0
- package/example-three-cloud/README.md +111 -18
- package/example-three-cloud/aws/Pulumi.yaml +15 -0
- package/example-three-cloud/aws/index.ts +174 -0
- package/example-three-cloud/aws/package-lock.json +2725 -0
- package/example-three-cloud/aws/package.json +14 -0
- package/example-three-cloud/aws/tsconfig.json +17 -0
- package/example-three-cloud/azure/main.tf +48 -0
- package/example-three-cloud/azure/site.tf +104 -0
- package/example-three-cloud/chant.config.json +9 -0
- package/example-three-cloud/chant.workspace.json +30 -4
- package/example-three-cloud/dns/chant.config.ts +26 -1
- package/example-three-cloud/dns/src/records.component.ts +32 -6
- package/example-three-cloud/package-lock.json +48 -27
- package/example-three-cloud/package.json +8 -6
- package/example-three-cloud/scripts/emulators-up.sh +28 -1
- package/example-three-cloud/scripts/front-door.ts +679 -86
- package/package.json +26 -8
- package/schemas/graph/v1/graph.schema.json +140 -0
- package/web/adopt-pulumi.js +114 -0
- package/web/adopt-pulumi.test.js +28 -0
- package/web/adopt.js +203 -0
- package/web/adopt.test.js +27 -0
- package/web/app.js +367 -14
- package/web/boot-motion.js +6 -0
- package/web/carve-steps.js +1 -1
- package/web/carve-steps.test.js +2 -2
- package/web/change-set-overlay.js +12 -5
- package/web/change-set-overlay.test.js +22 -0
- package/web/cut-around.d.ts +30 -0
- package/web/cut-around.js +138 -0
- package/web/drift-stream.js +241 -0
- package/web/drift-stream.test.js +146 -0
- package/web/edge-weight.d.ts +8 -2
- package/web/edge-weight.js +38 -4
- package/web/edge-weight.test.js +55 -1
- package/web/graph-query.js +180 -0
- package/web/graph-query.test.js +49 -0
- package/web/graph.html +107 -0
- package/web/index-diff.js +109 -0
- package/web/index-diff.test.js +39 -0
- package/web/index.html +45 -20
- package/web/kiosk-ask-tips.js +15 -5
- package/web/kiosk-ask-tips.test.js +14 -1
- package/web/kiosk-estate-scene.js +72 -8
- package/web/kiosk-light-frame.js +1 -0
- package/web/kiosk-light.js +41 -3
- package/web/kiosk-member-kind.test.js +140 -0
- package/web/kiosk-popover.js +4 -1
- package/web/kiosk-side.js +296 -0
- package/web/kiosk-side.test.js +249 -0
- package/web/kiosk-watch.js +12 -0
- package/web/kiosk-watch.test.js +15 -1
- package/web/kiosk.html +47 -1
- package/web/kiosk.js +106 -7
- package/web/member-kind.js +31 -0
- package/web/neighbourhood.js +105 -0
- package/web/neighbourhood.test.js +131 -0
- package/web/outside-refs.js +515 -0
- package/web/outside-refs.test.js +249 -0
- package/web/template-apps.js +245 -0
- package/web/template-apps.test.js +252 -0
- package/web/templates.js +285 -0
- package/web/templates.test.js +155 -0
- package/web/terragucci-lifecycle.js +112 -62
- package/web/terragucci-lifecycle.test.js +29 -1
- package/web/terragucci-timeline.js +39 -2
- package/web/terragucci-timeline.test.js +42 -1
- package/web/theme-paint.js +14 -0
- package/example-three-cloud/aws/chant.config.ts +0 -8
- package/example-three-cloud/aws/site.component.ts +0 -13
- package/example-three-cloud/aws/src/site.ts +0 -27
- package/example-three-cloud/azure/chant.config.ts +0 -1
- package/example-three-cloud/azure/src/site.component.ts +0 -13
- package/example-three-cloud/azure/src/site.ts +0 -18
- /package/example-carve/{legacy-tf → tf-root}/cdn.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/compute.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/floci-override.tf.disabled +0 -0
- /package/example-carve/{legacy-tf → tf-root}/modules/cdn/main.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/naming.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/network.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/observability.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/outputs.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/storage.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/versions.tf +0 -0
package/web/kiosk.html
CHANGED
|
@@ -341,6 +341,8 @@
|
|
|
341
341
|
.k-read-box { width: 1.9em; height: 1.05em; border-radius: 4px; border: 1.5px solid var(--muted); }
|
|
342
342
|
.k-read-solid, .k-read-dashed { width: 2em; height: 0; border-top: 2px solid var(--fg); }
|
|
343
343
|
.k-read-dashed { border-top-style: dashed; }
|
|
344
|
+
.k-read-hole { width: 1.9em; height: 1.05em; border-radius: 4px; border: 2px dashed var(--degraded); }
|
|
345
|
+
.k-read-previewed { width: 1.9em; height: 0.8em; border-radius: 0.4em; border: 1.5px solid var(--pending); }
|
|
344
346
|
.k-read-order { width: 1.9em; height: 1em; background: linear-gradient(var(--muted), var(--muted)) 0 0 / 0.5em 100% no-repeat, linear-gradient(var(--muted), var(--muted)) 0.7em 25% / 0.5em 75% no-repeat, linear-gradient(var(--muted), var(--muted)) 1.4em 50% / 0.5em 50% no-repeat; opacity: 0.8; }
|
|
345
347
|
.k-read-marks { width: 1.5em; height: 0.75em; background: radial-gradient(circle at 25% 50%, var(--foreign) 0 0.3em, transparent 0.32em), radial-gradient(circle at 75% 50%, var(--runtime) 0 0.3em, transparent 0.32em); }
|
|
346
348
|
/* behold#571: a tool's page. Its name (and logo where allowed) before the scenario, the replay's banner, the credit. */
|
|
@@ -548,6 +550,47 @@
|
|
|
548
550
|
border-radius: 0; box-shadow: none; padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom, 0px)); padding-left: 16px; padding-right: 16px; }
|
|
549
551
|
}
|
|
550
552
|
/* ==== end layout: ask mode ==== */
|
|
553
|
+
/* ==== the side pane (web/kiosk-side.js): the act's run and the current line's details, right of the graph, above the prompt ==== */
|
|
554
|
+
#k-side, #k-side-tab { display: none; }
|
|
555
|
+
body { --k-side-w: clamp(280px, 25vw, 520px); --k-side-tab-w: 30px; }
|
|
556
|
+
body.k-ask.k-watch.k-side-open #view-pane { right: calc(var(--k-side-w) + 10px); }
|
|
557
|
+
body.k-ask.k-watch.k-side-folded #view-pane { right: calc(var(--k-side-tab-w) + 10px); }
|
|
558
|
+
body.k-ask.k-watch.k-side-open #k-side { display: flex; flex-direction: column; gap: var(--s4); position: absolute; top: 0; right: 5px; width: var(--k-side-w); max-height: calc(100% - var(--k-ask-h, 30vh) - 15px); box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain;
|
|
559
|
+
padding: var(--s3) var(--s4) var(--s4); border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-pane-a, var(--bg)); color: var(--fg); font: clamp(0.9rem, 0.85vw, 1.1rem)/1.4 var(--font-ui); }
|
|
560
|
+
body.k-ask.k-watch.k-side-folded #k-side-tab { display: block; position: absolute; top: 0; right: 5px; width: var(--k-side-tab-w); bottom: calc(var(--k-ask-h, 30vh) + 10px); box-sizing: border-box; padding: var(--s3) 0; border: 1px solid var(--rule); border-radius: 8px;
|
|
561
|
+
background: var(--surface-pane-a, var(--bg)); color: var(--muted); font: 600 0.82rem var(--font-ui); writing-mode: vertical-rl; cursor: pointer; }
|
|
562
|
+
body.k-ask.k-watch.k-side-folded #k-side-tab:hover, body.k-ask.k-watch.k-side-folded #k-side-tab:focus-visible { color: var(--fg); border-color: var(--pending); }
|
|
563
|
+
#k-side .k-side-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
|
|
564
|
+
#k-side .k-side-title { margin: 0; font: 600 0.9em var(--font-ui); color: var(--muted); }
|
|
565
|
+
#k-side .k-side-fold { font: 600 0.8em var(--font-ui); color: var(--muted); background: transparent; border: 1px solid var(--rule); border-radius: 999px; padding: 0.1em var(--s3); cursor: pointer; }
|
|
566
|
+
#k-side .k-side-fold:hover, #k-side .k-side-fold:focus-visible { color: var(--fg); border-color: var(--pending); }
|
|
567
|
+
#k-side .k-side-fold::after { content: " \203A"; }
|
|
568
|
+
#k-side .k-wf { margin-top: var(--s1); }
|
|
569
|
+
#k-side .k-wf-row.k-wf-plain { grid-template-columns: 5.6em minmax(0, 1fr) 3.6em; }
|
|
570
|
+
#k-side .k-wf-words { text-align: right; }
|
|
571
|
+
#k-side .k-side-part .k-wf-wave { padding-left: 0.9em; font-weight: 500; }
|
|
572
|
+
#k-side .k-side-part .k-wf-track { background: transparent; height: auto; }
|
|
573
|
+
#k-side .k-side-words { font-size: 0.86em; color: var(--ink2, var(--fg)); }
|
|
574
|
+
#k-side .k-side-seg.k-tone-done { background: color-mix(in srgb, var(--managed) 75%, transparent); }
|
|
575
|
+
#k-side .k-side-seg.k-tone-running { background: var(--runtime); }
|
|
576
|
+
#k-side .k-side-seg.k-tone-waiting { background: repeating-linear-gradient(135deg, var(--foreign) 0 4px, color-mix(in srgb, var(--foreign) 45%, transparent) 4px 8px); }
|
|
577
|
+
#k-side .k-side-seg.k-tone-failed { background: var(--degraded); }
|
|
578
|
+
#k-side .k-side-part.k-tone-done .k-side-words { color: var(--managed); }
|
|
579
|
+
#k-side .k-side-part.k-tone-failed .k-side-words { color: var(--degraded); }
|
|
580
|
+
#k-side .k-side-quiet { margin: 0; color: var(--muted); font-size: 0.86em; }
|
|
581
|
+
#k-side .k-side-traces .k-wf { margin-top: var(--s1); }
|
|
582
|
+
#k-side .k-side-card { padding-top: var(--s3); border-top: 1px solid var(--rule); display: grid; gap: var(--s2); }
|
|
583
|
+
#k-side .k-side-item p, #k-side .k-side-estate { margin: 0; overflow-wrap: anywhere; }
|
|
584
|
+
#k-side .k-side-name b, #k-side .k-side-estate b { font-weight: 700; margin-right: var(--s2); }
|
|
585
|
+
#k-side .k-side-type { color: var(--muted); font-size: 0.9em; }
|
|
586
|
+
#k-side .k-side-line { font: 0.92em var(--font-mono); padding-left: var(--s3); border-left: 2px solid var(--rule); }
|
|
587
|
+
#k-side .k-line-unknown { color: var(--foreign); border-left-style: dashed; border-left-color: var(--foreign); }
|
|
588
|
+
#k-side .k-line-applied { color: var(--managed); border-left-color: var(--managed); }
|
|
589
|
+
#k-side .k-side-written b { color: var(--managed); }
|
|
590
|
+
@media (max-width: 700px) {
|
|
591
|
+
body.k-ask.k-watch #k-side, body.k-ask.k-watch #k-side-tab { display: none !important; }
|
|
592
|
+
}
|
|
593
|
+
/* ==== end side pane ==== */
|
|
551
594
|
/* ==== the demo banner (web/kiosk-banner.js): the example's name, its products, the code link ==== */
|
|
552
595
|
#k-banner { display: flex; align-items: center; gap: var(--s2) var(--s5); min-width: 0; height: 34px; box-sizing: border-box; padding: 0 var(--s4); border-bottom: 1px solid var(--rule); background: var(--surface-pane-a, var(--bg)); overflow: hidden; white-space: nowrap; }
|
|
553
596
|
#k-banner[hidden] { display: none; }
|
|
@@ -845,6 +888,9 @@
|
|
|
845
888
|
<aside id="k-result" class="k-over" aria-label="The result" hidden></aside>
|
|
846
889
|
<!-- behold#936: the prompt pane, in the header's and the caption's place while a step has a prompt (web/kiosk-ask.js). -->
|
|
847
890
|
<section id="k-ask" aria-live="polite" aria-label="The prompt" hidden></section>
|
|
891
|
+
<!-- The prompt demo's side pane (web/kiosk-side.js): the act's run and what the current line names, right of the graph. -->
|
|
892
|
+
<aside id="k-side" aria-label="This act's run"></aside>
|
|
893
|
+
<button type="button" id="k-side-tab" aria-label="Show the run details">Run details</button>
|
|
848
894
|
<footer id="k-caption" aria-live="polite"></footer>
|
|
849
895
|
<!-- behold#781, behold#776: a phone's Watch only: the change's facts by the story, and the graph's marks as a list. -->
|
|
850
896
|
<section id="k-change" aria-label="The change" hidden></section>
|
|
@@ -883,7 +929,7 @@
|
|
|
883
929
|
bar: document.getElementById("bar"), frame: document.getElementById("view"), read: document.getElementById("k-read"), side: document.getElementById("runs-side"), main: document.getElementById("runs-main"), views: document.getElementById("views"),
|
|
884
930
|
tools: { what: document.querySelector(".k-what"), pop: document.getElementById("k-what-pop"), theme: document.getElementById("k-theme"), runsToggle: document.getElementById("k-runs-toggle"), mode: document.getElementById("k-mode") },
|
|
885
931
|
eh: { switchHost: document.getElementById("k-tools"), trailHost: document.getElementById("eh-trail"), tipsHost: document.getElementById("eh-tips"), modalHost: document.getElementById("eh-modals") },
|
|
886
|
-
watch: { layer: document.getElementById("k-watch"), caption: document.getElementById("k-caption"), change: document.getElementById("k-change"), waves: document.getElementById("k-waves"), callout: document.getElementById("k-callout"), ask: document.getElementById("k-ask"), drawer: document.getElementById("k-drawer"), badges: document.getElementById("k-badges"), result: document.getElementById("k-result") },
|
|
932
|
+
watch: { layer: document.getElementById("k-watch"), caption: document.getElementById("k-caption"), change: document.getElementById("k-change"), waves: document.getElementById("k-waves"), callout: document.getElementById("k-callout"), ask: document.getElementById("k-ask"), side: document.getElementById("k-side"), sideTab: document.getElementById("k-side-tab"), drawer: document.getElementById("k-drawer"), badges: document.getElementById("k-badges"), result: document.getElementById("k-result") },
|
|
887
933
|
},
|
|
888
934
|
{ tool: pageTool(document), source: pageSource(document), runs: pageRuns(document) },
|
|
889
935
|
);
|
package/web/kiosk.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// Nothing here is all-or-nothing, and nothing says so.
|
|
15
15
|
|
|
16
16
|
import { linkState, linkWords, noteBack, noteRead, readFailed, shareLink } from "./kiosk-link.js";
|
|
17
|
+
import { KIND_ROWS } from "./member-kind.js";
|
|
17
18
|
import { CHANT_PANEL_STEPS, chantApprovalModel, chantResultModel } from "./chant-pr-marks.js";
|
|
18
19
|
import { createLivePacer } from "./chant-live-pace.js";
|
|
19
20
|
import { applyJobs, cycleTrack, drawTrack, failureAt, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
@@ -22,7 +23,7 @@ import { TOOLS } from "./tool-mark.js";
|
|
|
22
23
|
import { graphWaves } from "./chant-pr-marks.js";
|
|
23
24
|
import { createProgressPacer, trackWaves } from "./terragucci-live-pace.js";
|
|
24
25
|
import { PICK_HOLD_MS, annMark, mergeRun, startRuns, statusIcon } from "./kiosk-runs.js";
|
|
25
|
-
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, behindStep, steadyRun, captionModel, captionRoom, coneCaption, stepLine, watchOverlays, doraLine, modeStored, placeBeside, quietWords, recordKey, resultModel, runningStep, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
26
|
+
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, behindStep, steadyRun, holdEnds, captionModel, captionRoom, coneCaption, stepLine, watchOverlays, doraLine, modeStored, placeBeside, quietWords, recordKey, resultModel, runningStep, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
26
27
|
import { REFIT_WAIT_MS, debounced, shotMessage } from "./kiosk-shot.js";
|
|
27
28
|
import { mountTrace } from "./kiosk-trace.js";
|
|
28
29
|
import { startEventHelp } from "./kiosk-event-help-ui.js";
|
|
@@ -40,7 +41,8 @@ import { mountResetModal, resetShown } from "./kiosk-reset.js";
|
|
|
40
41
|
import { graphFolds, graphPending } from "./kiosk-graph-pane.js";
|
|
41
42
|
import { askEventHelp, askMode, askShot, createAskPane, hasAsk, replyValues } from "./kiosk-ask.js";
|
|
42
43
|
import { STATE_WORDS, outcomesOf, changingRoots, costLine, pinsCommit, planFitsPin, pullPin, readEdges, rootsCount, totalsLine, waveRows, blastRows } from "./terragucci-change.js";
|
|
43
|
-
import { startKioskLight } from "./kiosk-light.js"; // behold#937
|
|
44
|
+
import { reportedRunView, startKioskLight } from "./kiosk-light.js"; // behold#937
|
|
45
|
+
import { SIDE_PHONE, detailsModel, keepSide, renderSide, actRunView, runTrace, sideApplied, sideState, sideStep, sideStored } from "./kiosk-side.js";
|
|
44
46
|
|
|
45
47
|
/** The scenarios terragucci#1014 numbers. An id not here is shown by the title demo.json carries. */
|
|
46
48
|
export const SCENARIOS = {
|
|
@@ -703,6 +705,8 @@ export function readingRows(view, tool = null) {
|
|
|
703
705
|
{ mark: "card", words: "Card: one of its resources." },
|
|
704
706
|
...arrows,
|
|
705
707
|
{ mark: "marks", words: "Marks: the tools each job runs, in the jobs pane." },
|
|
708
|
+
// behold#1008: chant's composed run tells a stack no preview was made of from a previewed one (web/member-kind.js).
|
|
709
|
+
...(tool === "chant-compose" ? KIND_ROWS.map((r) => ({ ...r })) : []),
|
|
706
710
|
];
|
|
707
711
|
}
|
|
708
712
|
|
|
@@ -1853,7 +1857,76 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1853
1857
|
};
|
|
1854
1858
|
const applyAsk = () => {
|
|
1855
1859
|
if (typeof document !== "undefined" && document.body && document.body.classList) document.body.classList.toggle("k-ask", !!s.askOn && !!s.watchMode);
|
|
1860
|
+
applySide();
|
|
1856
1861
|
};
|
|
1862
|
+
// The side pane (web/kiosk-side.js): the act's run and what the terminal's current line names, right of the graph
|
|
1863
|
+
// in Watch while the prompt pane is up, on a screen wider than a phone. Open until the viewer folds it.
|
|
1864
|
+
s.sideOpen = sideStored(shelf);
|
|
1865
|
+
s.sideAsk = null;
|
|
1866
|
+
s.sideTurn = null;
|
|
1867
|
+
// The cycle each scenario was last seen on in demo.json, for a turn the terminal plays after demo.json moved on.
|
|
1868
|
+
const sideCycles = new Map();
|
|
1869
|
+
const sideMerges = new Map();
|
|
1870
|
+
let sideWas = null;
|
|
1871
|
+
const sideNow = () => sideState({ ask: askMode(s), phone: typeof matchMedia === "function" && matchMedia(SIDE_PHONE).matches, open: s.sideOpen });
|
|
1872
|
+
function applySide() {
|
|
1873
|
+
if (typeof document === "undefined" || !document.body || !document.body.classList) return;
|
|
1874
|
+
const st = sideNow();
|
|
1875
|
+
document.body.classList.toggle("k-side-open", st === "open");
|
|
1876
|
+
document.body.classList.toggle("k-side-folded", st === "folded");
|
|
1877
|
+
if (st === sideWas) return;
|
|
1878
|
+
sideWas = st;
|
|
1879
|
+
// The graph's pane got narrower or wider: the frame refits on its own resize (web/app.js watchPaneForFit); the shot
|
|
1880
|
+
// is told again once the layout has settled, and the tips dock in the new room.
|
|
1881
|
+
if (typeof requestAnimationFrame === "function")
|
|
1882
|
+
requestAnimationFrame(() => {
|
|
1883
|
+
drawSide();
|
|
1884
|
+
tellShot(true);
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
const setSide = (open) => {
|
|
1888
|
+
s.sideOpen = open;
|
|
1889
|
+
keepSide(shelf, open);
|
|
1890
|
+
applySide();
|
|
1891
|
+
if (open && watch && watch.side && watch.side.focus) watch.side.focus();
|
|
1892
|
+
};
|
|
1893
|
+
function drawSide() {
|
|
1894
|
+
if (!watch || !watch.side || sideNow() !== "open") return;
|
|
1895
|
+
// The terminal plays its steps in turn, and may be a step or an act behind demo.json: the trace is of the act
|
|
1896
|
+
// the terminal's current turn is in, at that turn's step.
|
|
1897
|
+
const at = sideStep(s.demo && s.demo.demo, s.sideTurn, sideCycles);
|
|
1898
|
+
const d = at && sideMerges.has(at.cycle) ? { ...at, commit: sideMerges.get(at.cycle) } : at;
|
|
1899
|
+
const runs = runsApi && runsApi.index && runsApi.index.doc ? runsApi.index.doc.runs : [];
|
|
1900
|
+
// The run view is the apply's: only this act's own, from its merge on (the kiosk's read can be the last merge's).
|
|
1901
|
+
// A pipeline that writes no run view (Terragrunt's and Atmos's on choudoufu) has the act's apply reports instead.
|
|
1902
|
+
const progress = actRunView(d, reportedRunView(s.progress, s.answer));
|
|
1903
|
+
const trace = runTrace(runs, d, { answer: s.answer, progress, now: now().getTime() });
|
|
1904
|
+
const details = detailsModel(s.answer, progress, s.sideAsk);
|
|
1905
|
+
renderSide(watch.side, { trace, details }, { traces: (host) => drawWaveTraces(host, s), onFold: () => setSide(false) });
|
|
1906
|
+
}
|
|
1907
|
+
if (watch && watch.sideTab && watch.sideTab.addEventListener) watch.sideTab.addEventListener("click", () => setSide(true));
|
|
1908
|
+
if (watch && watch.side && watch.side.setAttribute) watch.side.setAttribute("tabindex", "-1");
|
|
1909
|
+
// The prompt pane's height, which the side pane stands on: kept as --k-ask-h so the two never overlap.
|
|
1910
|
+
if (watch && watch.ask && typeof ResizeObserver !== "undefined" && typeof document !== "undefined") {
|
|
1911
|
+
new ResizeObserver(() => {
|
|
1912
|
+
const h = watch.ask.hidden ? 0 : Math.ceil(watch.ask.getBoundingClientRect().height);
|
|
1913
|
+
document.body.style.setProperty("--k-ask-h", `${h}px`);
|
|
1914
|
+
}).observe(watch.ask);
|
|
1915
|
+
}
|
|
1916
|
+
// The card follows the prompt pane's current turn: what its ask lights, from the plan (web/kiosk-light.js).
|
|
1917
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
1918
|
+
const turn = (e) => {
|
|
1919
|
+
const det = e && e.detail && typeof e.detail === "object" ? e.detail : {};
|
|
1920
|
+
s.sideAsk = det.ask && typeof det.ask === "object" ? det.ask : null;
|
|
1921
|
+
if (typeof det.scenario === "string" && typeof det.step === "string") s.sideTurn = { scenario: det.scenario, step: det.step };
|
|
1922
|
+
drawSide();
|
|
1923
|
+
};
|
|
1924
|
+
for (const t of ["behold:ask-hold", "behold:ask-start", "behold:ask-light", "behold:ask-status", "behold:ask-done", "behold:ask-clear"]) window.addEventListener(t, turn);
|
|
1925
|
+
if (typeof matchMedia === "function") {
|
|
1926
|
+
const mq = matchMedia(SIDE_PHONE);
|
|
1927
|
+
if (mq.addEventListener) mq.addEventListener("change", applySide);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1857
1930
|
const askPane =
|
|
1858
1931
|
watch && watch.ask
|
|
1859
1932
|
? createAskPane({
|
|
@@ -1874,8 +1947,15 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1874
1947
|
const resetModal = askPane && typeof document !== "undefined" && document.body ? mountResetModal(document) : null;
|
|
1875
1948
|
/** Take one narration (demo.json, or a replayed step), and ask for the run it is about when the step moved. */
|
|
1876
1949
|
const setDemo = (answer) => {
|
|
1950
|
+
const was = s.demo && s.demo.demo;
|
|
1877
1951
|
s.demo = answer;
|
|
1878
1952
|
const d = answer && answer.demo;
|
|
1953
|
+
// A viewer's hold on the shot ends at the reset and at a new act: the graph in the pane is another one then, and
|
|
1954
|
+
// the shot frames it to the pane as it is (a held view of the last graph left the reset's scene at the left edge).
|
|
1955
|
+
if (holdEnds(was || null, d || null) && s.endHold) s.endHold();
|
|
1956
|
+
if (d && typeof d.scenario === "string" && Number.isInteger(d.cycle)) sideCycles.set(d.scenario, d.cycle);
|
|
1957
|
+
// Each act's merge commit, as demo.json named it from the merge on (the reset names the base instead).
|
|
1958
|
+
if (d && Number.isInteger(d.cycle) && d.step !== "reset" && sideApplied(d) && typeof d.commit === "string") sideMerges.set(d.cycle, d.commit);
|
|
1879
1959
|
if (askPane) {
|
|
1880
1960
|
// behold#942: ask mode holds for the scenario, so the steps between prompts keep the graph and the pane.
|
|
1881
1961
|
s.askHeld = askHeld(s.askHeld, d || null);
|
|
@@ -2072,6 +2152,12 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2072
2152
|
// The layout moved under the frame: the shot goes again once it has settled.
|
|
2073
2153
|
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => tellShot(true));
|
|
2074
2154
|
};
|
|
2155
|
+
s.endHold = () => {
|
|
2156
|
+
if (watchHoldAt === null && !s.watchHeld) return;
|
|
2157
|
+
watchHoldAt = null;
|
|
2158
|
+
s.watchHeld = null;
|
|
2159
|
+
lastShot = null;
|
|
2160
|
+
};
|
|
2075
2161
|
const holdShot = () => {
|
|
2076
2162
|
if (!s.watchMode) return;
|
|
2077
2163
|
watchHoldAt = now().getTime();
|
|
@@ -2155,7 +2241,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2155
2241
|
const trailLineH = chip ? chip.getBoundingClientRect().height + 4 : 26;
|
|
2156
2242
|
return captionRoom({ capHeight: c.height, extras, rowH, trailH, trailLineH, below: Math.max(0, f.bottom - c.bottom) });
|
|
2157
2243
|
}
|
|
2158
|
-
function tellShot(force, still) {
|
|
2244
|
+
function tellShot(force, still, fresh = null) {
|
|
2159
2245
|
if (!frame || !frame.contentWindow || !watch) return;
|
|
2160
2246
|
// behold#940: ask mode holds in the frame between prompts and between shots, so it is told on its own, when it changes.
|
|
2161
2247
|
if (askMode(s) !== askTold) {
|
|
@@ -2169,14 +2255,26 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2169
2255
|
}
|
|
2170
2256
|
return;
|
|
2171
2257
|
}
|
|
2172
|
-
if (
|
|
2258
|
+
if (!s.shot) return;
|
|
2259
|
+
// A viewer's hold keeps the frame they moved where it is. A frame that has just loaded (`fresh`, its window) has
|
|
2260
|
+
// nothing of theirs: it takes the shot, or it would fit itself to the graph it first drew and not to the pane.
|
|
2261
|
+
if (s.watchHeld && !fresh) return;
|
|
2173
2262
|
const insets = shotInsets(s.shot);
|
|
2174
2263
|
// The caption's tallest, for a held small stage's one framing; a stage that isn't held never reads it.
|
|
2175
2264
|
const room = captionRoomPx();
|
|
2176
2265
|
const key = `${s.shot.id}|${s.shot.ask ? "ask" : ""}|${insets.right || 0}|${Math.round((insets.top || 0) / 12)}|${Math.round((insets.left || 0) / 12)}|${Math.round((insets.bottom || 0) / 12)}|${s.shot.roots.join(",")}|${Math.round(room / 12)}`;
|
|
2266
|
+
const msg = shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id, room, ask: s.shot.ask === true, ...(still ? { ms: 0 } : {}) });
|
|
2267
|
+
if (s.watchHeld) {
|
|
2268
|
+
try {
|
|
2269
|
+
fresh.postMessage(msg, origin);
|
|
2270
|
+
} catch {
|
|
2271
|
+
/* the frame went away */
|
|
2272
|
+
}
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2177
2275
|
if (!force && key === lastShot) return;
|
|
2178
2276
|
lastShot = key;
|
|
2179
|
-
post(
|
|
2277
|
+
post(msg);
|
|
2180
2278
|
}
|
|
2181
2279
|
// behold#631: the projected cycle track, a chant kiosk's bottom band in place of the chip strip and the rail.
|
|
2182
2280
|
const trackState = { cycle: null, pulls: [], key: null, since: null };
|
|
@@ -2268,6 +2366,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2268
2366
|
// behold#781, behold#776: a phone's Watch says the change in words by the story, and lists the graph's marks.
|
|
2269
2367
|
if (watch.change) drawChange(watch.change, s);
|
|
2270
2368
|
drawWaves();
|
|
2369
|
+
drawSide();
|
|
2271
2370
|
// behold#775: on a phone, each finished wave's trace under the step (hidden on a wider screen, where the badges open them).
|
|
2272
2371
|
let traces = watch.layer.querySelector(":scope > .k-w-traces");
|
|
2273
2372
|
if (!traces) {
|
|
@@ -2980,10 +3079,10 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2980
3079
|
watchBox(watch && watch.ask);
|
|
2981
3080
|
el.addEventListener("load", () => {
|
|
2982
3081
|
// A new frame takes Watch's shot before it draws, so it opens on it and never on the fit.
|
|
2983
|
-
tellShot(true);
|
|
3082
|
+
tellShot(true, false, el.contentWindow);
|
|
2984
3083
|
tellFrame(true);
|
|
2985
3084
|
// The frame reads its graph after load; tell it again once it has had the time.
|
|
2986
|
-
for (const ms of [1500, 4000, 8000]) setTimeout(() => (tellFrame(true), tellShot(true)), ms);
|
|
3085
|
+
for (const ms of [1500, 4000, 8000]) setTimeout(() => (tellFrame(true), tellShot(true, false, el.contentWindow)), ms);
|
|
2987
3086
|
});
|
|
2988
3087
|
};
|
|
2989
3088
|
const swapFrame = () => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// behold#1008: how a composed run's member box says whether a preview was made of it.
|
|
2
|
+
//
|
|
3
|
+
// chant's composed run (src/chant-compose.ts composedView) gives each member a kind in `answer.chant.members`:
|
|
4
|
+
// hole nothing could be previewed (its change set lists holes); the box is dashed and tagged "no preview";
|
|
5
|
+
// previewed a preview that reads values known after apply; the box is tagged "previewed";
|
|
6
|
+
// plain a preview with every value known; no tag.
|
|
7
|
+
// The estate scene (web/kiosk-estate-scene.js) draws the marks and the kiosk's "How to read this" (web/kiosk.js
|
|
8
|
+
// readingRows) says what they mean, from the words here, so the two never drift apart.
|
|
9
|
+
|
|
10
|
+
/** The tag on a box of each marked kind. A plain member has none. */
|
|
11
|
+
export const KIND_TAGS = { hole: "no preview", previewed: "previewed" };
|
|
12
|
+
|
|
13
|
+
/** The legend's line for each marked kind, in the order the legend lists them. */
|
|
14
|
+
export const KIND_ROWS = [
|
|
15
|
+
{ mark: "hole", words: "Dashed box: a stack no preview could be made of." },
|
|
16
|
+
{ mark: "previewed", words: "Tag previewed: some values known after apply." },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The words in a hole's empty box. */
|
|
20
|
+
export const HOLE_WORDS = "nothing could be previewed";
|
|
21
|
+
|
|
22
|
+
/** Each member's kind by path, from a composed answer: `Map<path, { kind, reasons }>`. Empty when the answer has none. */
|
|
23
|
+
export function memberKinds(answer) {
|
|
24
|
+
const out = new Map();
|
|
25
|
+
const rows = answer && answer.chant && Array.isArray(answer.chant.members) ? answer.chant.members : [];
|
|
26
|
+
for (const m of rows) {
|
|
27
|
+
if (!m || typeof m.member !== "string" || (m.kind !== "hole" && m.kind !== "previewed" && m.kind !== "plain")) continue;
|
|
28
|
+
out.set(m.member, { kind: m.kind, reasons: Array.isArray(m.reasons) ? m.reasons.filter((r) => typeof r === "string") : [] });
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The neighbourhood of one Kubernetes object, cut from a graph the page
|
|
2
|
+
// already holds (#1081). A cluster UI (Headlamp, the Argo CD UI) shows one
|
|
3
|
+
// object; this answers "it, its neighbours in the cluster, and what it reaches
|
|
4
|
+
// outside" with no server to ask.
|
|
5
|
+
//
|
|
6
|
+
// Imports only ./cut-around.js, which imports nothing: no `node:*`, nothing
|
|
7
|
+
// from src/. `esbuild web/neighbourhood.js --bundle --platform=browser` takes
|
|
8
|
+
// it whole, and web/neighbourhood.test.js checks the module graph.
|
|
9
|
+
import { cutAround } from "./cut-around.js";
|
|
10
|
+
|
|
11
|
+
export { cutAround };
|
|
12
|
+
|
|
13
|
+
/** API group of a `K8s::<Segment>::` IR kind, for the segments that name one group. A node carrying `attrs.apiVersion` never reaches this table. */
|
|
14
|
+
const GROUP_OF_SEGMENT = {
|
|
15
|
+
Core: "",
|
|
16
|
+
Apps: "apps",
|
|
17
|
+
Batch: "batch",
|
|
18
|
+
Rbac: "rbac.authorization.k8s.io",
|
|
19
|
+
Networking: "networking.k8s.io",
|
|
20
|
+
Storage: "storage.k8s.io",
|
|
21
|
+
Policy: "policy",
|
|
22
|
+
Autoscaling: "autoscaling",
|
|
23
|
+
Apiextensions: "apiextensions.k8s.io",
|
|
24
|
+
Argo: "argoproj.io",
|
|
25
|
+
Monitoring: "monitoring.coreos.com",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Kinds with no namespace, so an identity without one still matches. */
|
|
29
|
+
const CLUSTER_SCOPED = new Set([
|
|
30
|
+
"Namespace",
|
|
31
|
+
"Node",
|
|
32
|
+
"PersistentVolume",
|
|
33
|
+
"StorageClass",
|
|
34
|
+
"ClusterRole",
|
|
35
|
+
"ClusterRoleBinding",
|
|
36
|
+
"CustomResourceDefinition",
|
|
37
|
+
"PriorityClass",
|
|
38
|
+
"IngressClass",
|
|
39
|
+
"RuntimeClass",
|
|
40
|
+
"ValidatingWebhookConfiguration",
|
|
41
|
+
"MutatingWebhookConfiguration",
|
|
42
|
+
"APIService",
|
|
43
|
+
"AppProject",
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
/** Whether a node is a Kubernetes object (the lexicon chant tags it with, else its kind). */
|
|
47
|
+
export function isK8sNode(node) {
|
|
48
|
+
return !!node && (node.lexicon === "k8s" || (typeof node.kind === "string" && node.kind.startsWith("K8s::")));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const str = (v) => (typeof v === "string" && v.length > 0 ? v : undefined);
|
|
52
|
+
|
|
53
|
+
/** `{ group, kind, namespace, name }` of a Kubernetes node, as far as it declares them. */
|
|
54
|
+
export function identityOf(node) {
|
|
55
|
+
const attrs = (node && node.attrs) || {};
|
|
56
|
+
const meta = attrs.metadata && typeof attrs.metadata === "object" ? attrs.metadata : {};
|
|
57
|
+
const parts = typeof node.kind === "string" ? node.kind.split("::") : [];
|
|
58
|
+
const kind = str(attrs.kind) || (parts[0] === "K8s" ? parts[parts.length - 1] : undefined);
|
|
59
|
+
let group;
|
|
60
|
+
const apiVersion = str(attrs.apiVersion);
|
|
61
|
+
if (apiVersion) group = apiVersion.includes("/") ? apiVersion.slice(0, apiVersion.indexOf("/")) : "";
|
|
62
|
+
else if (parts[0] === "K8s" && parts.length === 3 && parts[1] in GROUP_OF_SEGMENT) group = GROUP_OF_SEGMENT[parts[1]];
|
|
63
|
+
return { group, kind, namespace: str(meta.namespace), name: str(meta.name) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The node for `{ group, kind, namespace, name }`, or null. `group` is the API
|
|
68
|
+
* group ("" or omitted for core, "apps" for Deployment). An object with no
|
|
69
|
+
* namespace joins `default`, as the apiserver defaults it (src/k8s-edges.ts),
|
|
70
|
+
* and a cluster-scoped kind matches without one. A group left out matches any
|
|
71
|
+
* group; one given never matches a node whose group is known and different.
|
|
72
|
+
*/
|
|
73
|
+
export function findK8sNode(graph, { group, kind, namespace, name } = {}) {
|
|
74
|
+
if (!kind || !name) return null;
|
|
75
|
+
const wantNamespace = CLUSTER_SCOPED.has(kind) ? undefined : namespace || "default";
|
|
76
|
+
for (const node of (graph && graph.nodes) || []) {
|
|
77
|
+
if (!isK8sNode(node)) continue;
|
|
78
|
+
const id = identityOf(node);
|
|
79
|
+
if (id.kind !== kind || id.name !== name) continue;
|
|
80
|
+
if (group !== undefined && id.group !== undefined && id.group !== group) continue;
|
|
81
|
+
if (wantNamespace !== undefined && (id.namespace || "default") !== wantNamespace) continue;
|
|
82
|
+
return node;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** "apps/Deployment default/web", the way a person names an object. */
|
|
88
|
+
export function describeIdentity({ group, kind, namespace, name } = {}) {
|
|
89
|
+
const k = group ? `${group}/${kind}` : `${kind}`;
|
|
90
|
+
return namespace ? `${k} ${namespace}/${name}` : `${k} ${name}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The cut around the object named by `identity`. Walks `depth` hops (default
|
|
95
|
+
* 1) between Kubernetes objects and `outside` hops (default 2) past the last
|
|
96
|
+
* one. An identity the graph does not hold returns no nodes and a `reason`
|
|
97
|
+
* naming it.
|
|
98
|
+
*/
|
|
99
|
+
export function neighbourhoodOf(graph, identity, opts = {}) {
|
|
100
|
+
const start = findK8sNode(graph, identity);
|
|
101
|
+
if (!start) {
|
|
102
|
+
return { nodes: [], edges: [], groups: {}, seeds: [], reason: `the graph holds no Kubernetes object ${describeIdentity(identity)}` };
|
|
103
|
+
}
|
|
104
|
+
return cutAround(graph, [start.id], { depth: 1, outside: 2, ...opts, inside: isK8sNode });
|
|
105
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { cutAround, findK8sNode, identityOf, neighbourhoodOf } from "./neighbourhood.js";
|
|
5
|
+
|
|
6
|
+
const k8s = (id, kind, apiVersion, name, namespace) => ({
|
|
7
|
+
id,
|
|
8
|
+
kind,
|
|
9
|
+
lexicon: "k8s",
|
|
10
|
+
attrs: { apiVersion, kind: kind.split("::").pop(), metadata: { name, ...(namespace ? { namespace } : {}) } },
|
|
11
|
+
});
|
|
12
|
+
const tf = (id, kind) => ({ id, kind, lexicon: "terraform", attrs: {} });
|
|
13
|
+
const edge = (from, to) => ({ from, to });
|
|
14
|
+
|
|
15
|
+
/** Deployment web -> ServiceAccount runner -> google_service_account -> project, plus a second Deployment on the same account. */
|
|
16
|
+
function fixture() {
|
|
17
|
+
return {
|
|
18
|
+
nodes: [
|
|
19
|
+
k8s("web", "K8s::Apps::Deployment", "apps/v1", "web"),
|
|
20
|
+
k8s("runner", "K8s::Core::ServiceAccount", "v1", "runner"),
|
|
21
|
+
k8s("other", "K8s::Apps::Deployment", "apps/v1", "other"),
|
|
22
|
+
tf("gsa", "google_service_account"),
|
|
23
|
+
tf("project", "google_project"),
|
|
24
|
+
tf("bucket", "google_storage_bucket"),
|
|
25
|
+
],
|
|
26
|
+
edges: [edge("web", "runner"), edge("other", "runner"), edge("runner", "gsa"), edge("gsa", "project"), edge("bucket", "project")],
|
|
27
|
+
groups: { byStack: { cluster: ["web", "runner", "other"], cloud: ["gsa", "project", "bucket"] } },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const ids = (cut) => cut.nodes.map((n) => n.id).sort();
|
|
31
|
+
|
|
32
|
+
describe("neighbourhoodOf", () => {
|
|
33
|
+
it("keeps the Deployment, the account, the cloud identity and the project at outside 2", () => {
|
|
34
|
+
const cut = neighbourhoodOf(fixture(), { group: "apps", kind: "Deployment", name: "web" }, { depth: 1, outside: 2 });
|
|
35
|
+
expect(ids(cut)).toEqual(["gsa", "project", "runner", "web"]);
|
|
36
|
+
expect(cut.edges).toHaveLength(3);
|
|
37
|
+
expect(cut.seeds).toEqual(["web"]);
|
|
38
|
+
expect(cut.groups).toEqual({ byStack: { cluster: ["web", "runner"], cloud: ["gsa", "project"] } });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("keeps the Deployment and the account only at outside 0", () => {
|
|
42
|
+
const cut = neighbourhoodOf(fixture(), { group: "apps", kind: "Deployment", name: "web" }, { depth: 1, outside: 0 });
|
|
43
|
+
expect(ids(cut)).toEqual(["runner", "web"]);
|
|
44
|
+
expect(cut.edges).toEqual([edge("web", "runner")]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("counts outside hops from the last Kubernetes node", () => {
|
|
48
|
+
const cut = neighbourhoodOf(fixture(), { group: "apps", kind: "Deployment", name: "web" }, { depth: 1, outside: 1 });
|
|
49
|
+
expect(ids(cut)).toEqual(["gsa", "runner", "web"]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("does not take a sibling that shares a dependency", () => {
|
|
53
|
+
const cut = neighbourhoodOf(fixture(), { group: "apps", kind: "Deployment", name: "web" }, { depth: 3 });
|
|
54
|
+
expect(ids(cut)).not.toContain("other");
|
|
55
|
+
expect(ids(cut)).not.toContain("bucket");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("walks down from the account to what uses it", () => {
|
|
59
|
+
const cut = neighbourhoodOf(fixture(), { kind: "ServiceAccount", name: "runner" }, { depth: 1, up: false });
|
|
60
|
+
expect(ids(cut)).toEqual(["other", "runner", "web"]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("returns no nodes and a reason naming an identity that is not there", () => {
|
|
64
|
+
const cut = neighbourhoodOf(fixture(), { group: "apps", kind: "Deployment", namespace: "prod", name: "absent" });
|
|
65
|
+
expect(cut.nodes).toEqual([]);
|
|
66
|
+
expect(cut.edges).toEqual([]);
|
|
67
|
+
expect(cut.reason).toContain("apps/Deployment prod/absent");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("findK8sNode", () => {
|
|
72
|
+
it("joins an object with no namespace to default, and matches a cluster-scoped kind without one", () => {
|
|
73
|
+
const g = {
|
|
74
|
+
nodes: [
|
|
75
|
+
k8s("a", "K8s::Apps::Deployment", "apps/v1", "web", "default"),
|
|
76
|
+
k8s("b", "K8s::Apps::Deployment", "apps/v1", "web", "prod"),
|
|
77
|
+
k8s("ns", "K8s::Core::Namespace", "v1", "prod"),
|
|
78
|
+
],
|
|
79
|
+
edges: [],
|
|
80
|
+
groups: {},
|
|
81
|
+
};
|
|
82
|
+
expect(findK8sNode(g, { group: "apps", kind: "Deployment", name: "web" }).id).toBe("a");
|
|
83
|
+
expect(findK8sNode(g, { group: "apps", kind: "Deployment", namespace: "prod", name: "web" }).id).toBe("b");
|
|
84
|
+
expect(findK8sNode(g, { group: "", kind: "Namespace", name: "prod" }).id).toBe("ns");
|
|
85
|
+
expect(findK8sNode(g, { group: "batch", kind: "Deployment", name: "web" })).toBeNull();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("reads the group from the IR kind when the node carries no apiVersion", () => {
|
|
89
|
+
const g = { nodes: [{ id: "d", kind: "K8s::Apps::Deployment", lexicon: "k8s", attrs: { metadata: { name: "web" } } }], edges: [], groups: {} };
|
|
90
|
+
expect(identityOf(g.nodes[0])).toMatchObject({ group: "apps", kind: "Deployment", name: "web" });
|
|
91
|
+
expect(findK8sNode(g, { group: "apps", kind: "Deployment", name: "web" }).id).toBe("d");
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("cutAround", () => {
|
|
96
|
+
const chain = () => ({ nodes: ["a", "b", "c"].map((id) => tf(id, "t")), edges: [edge("a", "b"), edge("b", "c")], groups: {} });
|
|
97
|
+
|
|
98
|
+
it("up keeps what the seed needs and down keeps what needs it", () => {
|
|
99
|
+
expect(ids(cutAround(chain(), ["b"], { depth: 5, down: false }))).toEqual(["b", "c"]);
|
|
100
|
+
expect(ids(cutAround(chain(), ["b"], { depth: 5, up: false }))).toEqual(["a", "b"]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("bounds the walk by depth over a graph with no inside predicate", () => {
|
|
104
|
+
expect(ids(cutAround(chain(), ["a"], { depth: 1 }))).toEqual(["a", "b"]);
|
|
105
|
+
expect(ids(cutAround(chain(), ["a"], { depth: 2 }))).toEqual(["a", "b", "c"]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("names the ids it could not find", () => {
|
|
109
|
+
const cut = cutAround(chain(), ["a", "zz"], { depth: 1 });
|
|
110
|
+
expect(cut.missing).toEqual(["zz"]);
|
|
111
|
+
expect(cutAround(chain(), ["zz"]).reason).toContain("zz");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("module graph", () => {
|
|
116
|
+
it("imports nothing from node: and nothing outside web/", () => {
|
|
117
|
+
const seen = new Set();
|
|
118
|
+
const walk = (file) => {
|
|
119
|
+
if (seen.has(file)) return;
|
|
120
|
+
seen.add(file);
|
|
121
|
+
const text = readFileSync(file, "utf8");
|
|
122
|
+
for (const m of text.matchAll(/(?:^|\n)\s*(?:import|export)\b[^;\n]*?from\s+["']([^"']+)["']|\bimport\s*\(\s*["']([^"']+)["']\s*\)|(?:^|\n)\s*import\s+["']([^"']+)["']/g)) {
|
|
123
|
+
const spec = m[1] || m[2] || m[3];
|
|
124
|
+
expect(spec.startsWith("./"), `${file} imports ${spec}`).toBe(true);
|
|
125
|
+
walk(resolve(dirname(file), spec));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
walk(join(import.meta.dirname, "neighbourhood.js"));
|
|
129
|
+
expect([...seen].map((f) => f.split("/").pop()).sort()).toEqual(["cut-around.js", "neighbourhood.js"]);
|
|
130
|
+
});
|
|
131
|
+
});
|