@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.18.34",
3
+ "version": "0.18.35",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -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;
@@ -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
- return { nodes, edges: sortEdges([...seen.values()]), groups: { byLexicon: byLexiconOf(nodes) } };
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. */