@intentius/chant 0.18.34 → 0.18.35
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/package.json +1 -1
- package/src/graph-detail.test.ts +13 -0
- package/src/graph-detail.ts +12 -1
package/package.json
CHANGED
package/src/graph-detail.test.ts
CHANGED
|
@@ -57,6 +57,19 @@ describe("applyDetail", () => {
|
|
|
57
57
|
expect(ir.edges).toContainEqual({ from: "subnet", to: "vpc", kind: "ref", viaAttr: "network" });
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
test("T1 (composites) carries the cross-stack imports forward (survive the collapse as plain nodes)", () => {
|
|
61
|
+
const withImports: GraphIR = {
|
|
62
|
+
...base,
|
|
63
|
+
nodes: [...base.nodes, { id: "pClusterArn", kind: "AWS::CloudFormation::Parameter", lexicon: "aws", attrs: {} }],
|
|
64
|
+
imports: [{ name: "pClusterArn", node: "pClusterArn" }],
|
|
65
|
+
};
|
|
66
|
+
const ir = applyDetail(withImports, DETAIL.COMPOSITES);
|
|
67
|
+
// The import node isn't a composite, so it survives — and `imports` rides
|
|
68
|
+
// along so a viewer can hide/match it at this tier too (not just base + T3).
|
|
69
|
+
expect(ir.nodes.some((n) => n.id === "pClusterArn")).toBe(true);
|
|
70
|
+
expect(ir.imports).toEqual([{ name: "pClusterArn", node: "pClusterArn" }]);
|
|
71
|
+
});
|
|
72
|
+
|
|
60
73
|
test("T1 node count is between T0 and T2", () => {
|
|
61
74
|
const t0 = applyDetail(base, DETAIL.STACKS).nodes.length;
|
|
62
75
|
const t1 = applyDetail(base, DETAIL.COMPOSITES).nodes.length;
|
package/src/graph-detail.ts
CHANGED
|
@@ -111,7 +111,18 @@ function toComposites(ir: GraphIR): GraphIR {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
114
|
-
|
|
114
|
+
// Carry the cross-stack import list forward: parameter/import nodes aren't
|
|
115
|
+
// composites, so they survive the collapse as plain nodes — a viewer that
|
|
116
|
+
// hides imports (or matches them across stacks) needs `imports` at every tier,
|
|
117
|
+
// not just the base + ATTRIBUTES. Filter to handles whose node survived.
|
|
118
|
+
const surviving = new Set(nodes.map((n) => n.id));
|
|
119
|
+
const imports = ir.imports?.filter((i) => surviving.has(i.node));
|
|
120
|
+
return {
|
|
121
|
+
nodes,
|
|
122
|
+
edges: sortEdges([...seen.values()]),
|
|
123
|
+
groups: { byLexicon: byLexiconOf(nodes) },
|
|
124
|
+
...(imports && imports.length ? { imports } : {}),
|
|
125
|
+
};
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
/** T3 — annotate each edge with the producer attribute it references. */
|