@intentius/chant 0.68.1 → 0.69.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.
@@ -126,9 +126,15 @@ export type FoldedValue = string | number | boolean | null | undefined | FoldedV
126
126
  * `undefined` for a value that has an honest string form.
127
127
  *
128
128
  * These are the shapes `fold()` produces for things the build resolves later:
129
- * a resource attribute, a lexicon intrinsic in either of its two forms, and a
130
- * registered authoring helper. None of them can be concatenated into a string
131
- * here, because what they stand for is not known until the build runs.
129
+ * a resource attribute, a lexicon intrinsic in either of its two forms, a
130
+ * registered authoring helper, a nested construction used as a value, and a
131
+ * composite `.step`. None of them can be concatenated into a string here,
132
+ * because what they stand for is not known until the build runs.
133
+ *
134
+ * Five of the six envelope kinds. `__symbol` is the sixth and is deliberately
135
+ * absent: it is produced only inside an intrinsic's interior and cannot reach
136
+ * a plain template span, so a case for it would be unreachable code claiming
137
+ * to guard something (#2397).
132
138
  */
133
139
  export declare function symbolicEnvelopeKind(value: unknown): string | undefined;
134
140
  export interface AttrRefValue {
@@ -1 +1 @@
1
- {"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/fold/fold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAoE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAaL,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AAEH;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,WAAW,EAAE,GACb;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,GAC9B,YAAY,GACZ,eAAe,G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AAW,CAqdb;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAClC,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,cAAc,CA6BhB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,SAAc,EACtB,UAAU,GAAE,SAAS,YAAY,EAAO,GACvC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CA6BjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"evl011-symbolic-in-template.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/evl011-symbolic-in-template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,SAAS,CAAC;AAwFrE,eAAO,MAAM,4BAA4B,EAAE,QAU1C,CAAC"}
1
+ {"version":3,"file":"evl011-symbolic-in-template.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/evl011-symbolic-in-template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,SAAS,CAAC;AA+GrE,eAAO,MAAM,4BAA4B,EAAE,QAU1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.68.1",
3
+ "version": "0.69.0",
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",
@@ -100,6 +100,29 @@ describe("fold — a symbolic value in a plain template (#2349)", () => {
100
100
  expect(() => "prefix" + (bucket.arn as unknown as string)).toThrow(/no string form/);
101
101
  });
102
102
 
103
+
104
+ test("a nested construction used as a value is refused too (#2397)", () => {
105
+ const src = `
106
+ const x = \`\${new S3Bucket({ BucketName: "b" })}-tag\`;
107
+ `;
108
+ expect(() => foldConst(src, "x")).toThrow(FoldError);
109
+ try {
110
+ foldConst(src, "x");
111
+ } catch (e) {
112
+ expect((e as FoldError).message).toContain("new S3Bucket");
113
+ expect((e as FoldError).message).toContain("[object Object]");
114
+ }
115
+ });
116
+
117
+ test("a composite `.step` is refused too (#2397)", () => {
118
+ // The run path builds a real instance whose default toString is the same
119
+ // "[object Object]", so this agreed across paths exactly as #2349 did.
120
+ const src = `
121
+ const x = \`\${Checkout({}).step}\`;
122
+ `;
123
+ expect(() => foldConst(src, "x")).toThrow(FoldError);
124
+ });
125
+
103
126
  test("an ordinary value in a template still interpolates", () => {
104
127
  const src = `
105
128
  const region = "us-east-1";
package/src/fold/fold.ts CHANGED
@@ -156,9 +156,15 @@ export type FoldedValue =
156
156
  * `undefined` for a value that has an honest string form.
157
157
  *
158
158
  * These are the shapes `fold()` produces for things the build resolves later:
159
- * a resource attribute, a lexicon intrinsic in either of its two forms, and a
160
- * registered authoring helper. None of them can be concatenated into a string
161
- * here, because what they stand for is not known until the build runs.
159
+ * a resource attribute, a lexicon intrinsic in either of its two forms, a
160
+ * registered authoring helper, a nested construction used as a value, and a
161
+ * composite `.step`. None of them can be concatenated into a string here,
162
+ * because what they stand for is not known until the build runs.
163
+ *
164
+ * Five of the six envelope kinds. `__symbol` is the sixth and is deliberately
165
+ * absent: it is produced only inside an intrinsic's interior and cannot reach
166
+ * a plain template span, so a case for it would be unreachable code claiming
167
+ * to guard something (#2397).
162
168
  */
163
169
  export function symbolicEnvelopeKind(value: unknown): string | undefined {
164
170
  if (typeof value !== "object" || value === null) return undefined;
@@ -173,6 +179,15 @@ export function symbolicEnvelopeKind(value: unknown): string | undefined {
173
179
  }
174
180
  if ("__intrinsic" in v && typeof v.__intrinsic === "string") return `the intrinsic \`${v.__intrinsic}\``;
175
181
  if ("__helper" in v && typeof v.__helper === "string") return `the helper \`${v.__helper}\``;
182
+ // A nested construction used as a value (#1169). The run path builds a real
183
+ // instance here, whose default `toString` is `"[object Object]"` too, so
184
+ // fold and run agreed and the differential stayed silent — the same shape
185
+ // as #2349 itself (#2397).
186
+ if ("__resource" in v && typeof v.__resource === "string") return `a nested \`new ${v.__resource}\``;
187
+ // The `.step` idiom (#1174).
188
+ if ("__compositeStep" in v && typeof v.__compositeStep === "string") {
189
+ return `the composite step \`${v.__compositeStep}(…).step\``;
190
+ }
176
191
  return undefined;
177
192
  }
178
193
 
@@ -65,6 +65,34 @@ describe("EVL011: a symbolic reference in a plain template", () => {
65
65
  expect(evl011SymbolicInTemplateRule.check(ctx)).toHaveLength(0);
66
66
  });
67
67
 
68
+
69
+ test("flags a nested construction used as a value (#2397)", () => {
70
+ const ctx = createContext(`
71
+ const x = \`\${new Image({ name: "n" })}-tag\`;
72
+ `);
73
+ const found = evl011SymbolicInTemplateRule.check(ctx);
74
+ expect(found).toHaveLength(1);
75
+ expect(found[0].message).toContain("new Image");
76
+ });
77
+
78
+ test("flags a composite `.step` (#2397)", () => {
79
+ const ctx = createContext(`
80
+ const x = \`\${Checkout({}).step}\`;
81
+ `);
82
+ const found = evl011SymbolicInTemplateRule.check(ctx);
83
+ expect(found).toHaveLength(1);
84
+ expect(found[0].message).toContain("Checkout(…).step");
85
+ });
86
+
87
+ test("an ordinary `.step`-less property on a call is not flagged", () => {
88
+ // The false positive worth avoiding: `.step` is the idiom, and a rule
89
+ // cannot know which callees are composites, so only that name qualifies.
90
+ const ctx = createContext(`
91
+ const x = \`\${getConfig().region}\`;
92
+ `);
93
+ expect(evl011SymbolicInTemplateRule.check(ctx)).toHaveLength(0);
94
+ });
95
+
68
96
  test("says nothing about a reference outside a template", () => {
69
97
  const ctx = createContext(`
70
98
  const bucket = new S3Bucket({ name: "b" });
@@ -49,6 +49,33 @@ function resourceBindings(sourceFile: ts.SourceFile): Set<string> {
49
49
  return names;
50
50
  }
51
51
 
52
+ /**
53
+ * What this span is, if it is one of the shapes that has no string form — or
54
+ * `undefined` for an ordinary expression.
55
+ *
56
+ * The three kinds a syntactic rule can see, matching what `fold()` refuses
57
+ * (#2397): a resource attribute on an identifier bound by `new` in this file,
58
+ * a nested construction used as a value, and a composite `.step`.
59
+ */
60
+ function symbolicSpan(expr: ts.Expression, bound: Set<string>): string | undefined {
61
+ if (ts.isNewExpression(expr)) {
62
+ const name = ts.isIdentifier(expr.expression) ? expr.expression.text : "…";
63
+ return `a nested \`new ${name}\``;
64
+ }
65
+ if (ts.isPropertyAccessExpression(expr)) {
66
+ // `Checkout({}).step` — a call's `.step`, whatever the callee is: the
67
+ // idiom is the shape, and a rule cannot know which callees are composites.
68
+ if (expr.name.text === "step" && ts.isCallExpression(expr.expression)) {
69
+ const callee = ts.isIdentifier(expr.expression.expression) ? expr.expression.expression.text : "…";
70
+ return `the composite step \`${callee}(…).step\``;
71
+ }
72
+ if (ts.isIdentifier(expr.expression) && bound.has(expr.expression.text)) {
73
+ return `\`${expr.expression.text}.${expr.name.text}\` is a resource attribute and`;
74
+ }
75
+ }
76
+ return undefined;
77
+ }
78
+
52
79
  function checkNode(
53
80
  node: ts.Node,
54
81
  context: LintContext,
@@ -60,11 +87,8 @@ function checkNode(
60
87
  if (ts.isTemplateExpression(node) && !ts.isTaggedTemplateExpression(node.parent)) {
61
88
  for (const span of node.templateSpans) {
62
89
  const expr = span.expression;
63
- if (
64
- ts.isPropertyAccessExpression(expr) &&
65
- ts.isIdentifier(expr.expression) &&
66
- bound.has(expr.expression.text)
67
- ) {
90
+ const what = symbolicSpan(expr, bound);
91
+ if (what) {
68
92
  const { line, character } = context.sourceFile.getLineAndCharacterOfPosition(
69
93
  expr.getStart(context.sourceFile),
70
94
  );
@@ -75,10 +99,9 @@ function checkNode(
75
99
  ruleId: "EVL011",
76
100
  severity: "error",
77
101
  message:
78
- `\`${expr.expression.text}.${expr.name.text}\` is a resource attribute and has no string ` +
79
- "form until the build resolves it — a plain template would stringify it as " +
80
- "\"[object Object]\". Use the lexicon's own intrinsic, whose interior handles references " +
81
- "(`Sub`${…}`` for CloudFormation), or move the reference out of the template.",
102
+ `${what} has no string form until the build resolves it — a plain template would ` +
103
+ "stringify it as \"[object Object]\". Use the lexicon's own intrinsic, whose interior " +
104
+ "handles these (`Sub`${…}`` for CloudFormation), or move it out of the template.",
82
105
  });
83
106
  }
84
107
  }