@intentius/chant 0.18.33 → 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/dist/graph-ir.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/graph-detail.test.ts +13 -0
- package/src/graph-detail.ts +12 -1
- package/src/graph-ir.test.ts +27 -0
- package/src/graph-ir.ts +10 -0
package/dist/graph-ir.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-ir.d.ts","sourceRoot":"","sources":["../src/graph-ir.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,cAAc,CAAC;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;GAQG;AAEH,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,iCAAiC;AACjC,MAAM,WAAW,MAAM;IACrB,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,mCAAmC;IACnC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;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E;AAC5E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,OAAO,CA+BzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAUvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAgC7E"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant",
|
|
3
|
-
"version": "0.18.
|
|
4
|
-
"description": "Declarative infrastructure-as-code toolkit
|
|
3
|
+
"version": "0.18.35",
|
|
4
|
+
"description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
7
7
|
"repository": {
|
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. */
|
package/src/graph-ir.test.ts
CHANGED
|
@@ -78,6 +78,33 @@ describe("buildGraphIr", () => {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
test("follows a ref nested inside a property-kind declarable (a listener's forward action)", () => {
|
|
82
|
+
// Regression: an inlined property-kind declarable (e.g. a Listener Action)
|
|
83
|
+
// keeps its config in the NON-enumerable `props` bag. collectEdges used to
|
|
84
|
+
// recurse with Object.values(), which skips `props`, so a ref buried in
|
|
85
|
+
// `DefaultActions: [Action{ TargetGroupArn: tg.TargetGroupArn }]` produced
|
|
86
|
+
// NO edge — the target group floated even though it deploys wired.
|
|
87
|
+
const tg = decl({ lexicon: "aws", entityType: "AWS::ElasticLoadBalancingV2::TargetGroup" });
|
|
88
|
+
const action = decl({
|
|
89
|
+
lexicon: "aws",
|
|
90
|
+
entityType: "AWS::ElasticLoadBalancingV2::Listener.Action",
|
|
91
|
+
props: { Type: "forward", TargetGroupArn: new AttrRef(tg, "TargetGroupArn") },
|
|
92
|
+
});
|
|
93
|
+
const listener = decl({
|
|
94
|
+
lexicon: "aws",
|
|
95
|
+
entityType: "AWS::ElasticLoadBalancingV2::Listener",
|
|
96
|
+
props: { DefaultActions: [action] },
|
|
97
|
+
});
|
|
98
|
+
const entities = new Map<string, Declarable>([
|
|
99
|
+
["tg", tg],
|
|
100
|
+
["listener", listener],
|
|
101
|
+
]);
|
|
102
|
+
resolveAttrRefs(entities);
|
|
103
|
+
|
|
104
|
+
const ir = buildGraphIr(entities);
|
|
105
|
+
expect(ir.edges).toContainEqual({ from: "listener", to: "tg", kind: "ref", viaAttr: "DefaultActions" });
|
|
106
|
+
});
|
|
107
|
+
|
|
81
108
|
test("treats a foreign AttrRef (different @intentius/chant copy) as a ref, not an opaque intrinsic (#511)", () => {
|
|
82
109
|
// A lexicon built against a *separate* copy of chant produces AttrRefs that
|
|
83
110
|
// fail `instanceof AttrRef` here but carry the global-symbol brand + shape.
|
package/src/graph-ir.ts
CHANGED
|
@@ -287,6 +287,16 @@ function collectEdges(
|
|
|
287
287
|
}
|
|
288
288
|
if (seen.has(value)) return;
|
|
289
289
|
seen.add(value);
|
|
290
|
+
// A nested declarable (an inlined property-kind resource, e.g. a listener's
|
|
291
|
+
// `DefaultActions: [Listener_Action{ TargetGroupArn: tg.TargetGroupArn }]`)
|
|
292
|
+
// keeps its config in a NON-enumerable `props` bag, so `Object.values`
|
|
293
|
+
// below would walk right past the ref inside it and drop the edge. Descend
|
|
294
|
+
// via `configRoots` (which reads `props`), mirroring `project`'s handling —
|
|
295
|
+
// the ref then resolves to a real from→to edge on the containing node.
|
|
296
|
+
if (isDeclarable(value)) {
|
|
297
|
+
for (const [, v] of configRoots(value)) visit(v, viaAttr);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
290
300
|
if (Array.isArray(value)) {
|
|
291
301
|
for (const item of value) visit(item, viaAttr);
|
|
292
302
|
return;
|