@intentius/chant-lexicon-azure 0.20.0 → 0.22.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "9c20268ecaed3d0f86a93507f2dc85fcec6d8dad8eda21d224250a55ae80d168",
4
+ "manifest.json": "ca47b41a282234d99a7fa8a7d54b36ffdef3637f7ea5c258974abf952be72262",
5
5
  "meta.json": "4b9c0be734f8b4a5fbba3136e14aaa1ea73ff0ee93f2aa480db83e476ce727b5",
6
6
  "types/index.d.ts": "d62c0fd7947ddf04a9126cc8bf44a9f4437f21cf8647fc812c022398f2c00d57",
7
7
  "rules/hardcoded-location.ts": "a9b1d1cec93f2ca9c5206641f53fc9621cefcfd2c00b3ab89c194b30a75fa949",
@@ -33,5 +33,5 @@
33
33
  "skills/chant-azure-patterns.md": "1a3bacfac612826b77332d2692a59195638db9f1b5e8ea2eda7579621d25f603",
34
34
  "skills/chant-azure-aks.md": "2d4e0098c1a22b54ffadd410564d9df0f3a04cb4eb7c6261f20ae33106e7aca8"
35
35
  },
36
- "composite": "ced906f09ebf963a407744e5dba3174ca0796595cdfac27bc521c66de66cedf4"
36
+ "composite": "7e7b14bdaf521291e3d9f7ee1825cd0127dc6ddc832819a4f3afd1f1e78e7fb3"
37
37
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "Azure",
6
6
  "intrinsics": [
@@ -8,55 +8,64 @@
8
8
  "name": "ResourceId",
9
9
  "description": "Generate a resource ID for an Azure resource",
10
10
  "outputKey": "ResourceId",
11
- "isTag": false
11
+ "isTag": false,
12
+ "foldsAsCall": true
12
13
  },
13
14
  {
14
15
  "name": "Reference",
15
16
  "description": "Get the runtime state of a deployed resource",
16
17
  "outputKey": "Reference",
17
- "isTag": false
18
+ "isTag": false,
19
+ "foldsAsCall": true
18
20
  },
19
21
  {
20
22
  "name": "Concat",
21
23
  "description": "Concatenate multiple string values",
22
24
  "outputKey": "Concat",
23
- "isTag": false
25
+ "isTag": false,
26
+ "foldsAsCall": true
24
27
  },
25
28
  {
26
29
  "name": "ResourceGroup",
27
30
  "description": "Get the current resource group object",
28
31
  "outputKey": "ResourceGroup",
29
- "isTag": false
32
+ "isTag": false,
33
+ "foldsAsCall": true
30
34
  },
31
35
  {
32
36
  "name": "Subscription",
33
37
  "description": "Get the current subscription object",
34
38
  "outputKey": "Subscription",
35
- "isTag": false
39
+ "isTag": false,
40
+ "foldsAsCall": true
36
41
  },
37
42
  {
38
43
  "name": "UniqueString",
39
44
  "description": "Generate a deterministic hash string",
40
45
  "outputKey": "UniqueString",
41
- "isTag": false
46
+ "isTag": false,
47
+ "foldsAsCall": true
42
48
  },
43
49
  {
44
50
  "name": "Format",
45
51
  "description": "Format a string with arguments",
46
52
  "outputKey": "Format",
47
- "isTag": false
53
+ "isTag": false,
54
+ "foldsAsCall": true
48
55
  },
49
56
  {
50
57
  "name": "If",
51
58
  "description": "Conditional expression",
52
59
  "outputKey": "If",
53
- "isTag": false
60
+ "isTag": false,
61
+ "foldsAsCall": true
54
62
  },
55
63
  {
56
64
  "name": "ListKeys",
57
65
  "description": "List access keys for a resource",
58
66
  "outputKey": "ListKeys",
59
- "isTag": false
67
+ "isTag": false,
68
+ "foldsAsCall": true
60
69
  }
61
70
  ],
62
71
  "pseudoParameters": {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAsB5E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,aAuazB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAsB5E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,aAqbzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-azure",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "Azure lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -74,7 +74,7 @@
74
74
  "typescript": "^5.9.3"
75
75
  },
76
76
  "peerDependencies": {
77
- "@intentius/chant": "^0.20.0",
77
+ "@intentius/chant": "^0.22.0",
78
78
  "typescript": "^5.9.3"
79
79
  }
80
80
  }
@@ -49,6 +49,11 @@ export async function packageLexicon(opts: PackageOptions = {}): Promise<Package
49
49
  description: i.description,
50
50
  outputKey: intrinsicOutputKey(i.name),
51
51
  isTag: i.isTag,
52
+ // chant #1044 — carried through verbatim for the same reason as
53
+ // `isTag`: the packaged manifest is what a consumer reads to
54
+ // learn which intrinsics fold, so recomputing it here would be a
55
+ // second source of truth able to drift from ../plugin.ts.
56
+ foldsAsCall: i.foldsAsCall,
52
57
  }),
53
58
  );
54
59
 
package/src/plugin.ts CHANGED
@@ -35,17 +35,31 @@ export const azurePlugin: LexiconPlugin = {
35
35
  return [hardcodedLocationRule, storageHttpsRule, nsgWildcardRule];
36
36
  },
37
37
 
38
+ /**
39
+ * chant #1044 — azure has no tagged templates at all, so before this every
40
+ * intrinsic use fell the whole file back to the run path. All nine opt
41
+ * their call form in.
42
+ *
43
+ * Audited against `IntrinsicDef.foldsAsCall` (core's lexicon.ts): each one
44
+ * stores its arguments and renders an ARM bracket expression at
45
+ * serialization time (../intrinsics.ts). Nothing is evaluated locally —
46
+ * `UniqueString(x)` emits `[uniqueString(x)]` for ARM to hash at deployment
47
+ * (it does not hash anything at build time), and `Reference`/`ListKeys`
48
+ * name a deployment-time read rather than performing one. Every call is a
49
+ * pure function of its arguments, so calling it while folding is
50
+ * indistinguishable from calling it during a real run of the file.
51
+ */
38
52
  intrinsics(): IntrinsicDef[] {
39
53
  return [
40
- { name: "ResourceId", description: "Generate a resource ID for an Azure resource", isTag: false },
41
- { name: "Reference", description: "Get the runtime state of a deployed resource", isTag: false },
42
- { name: "Concat", description: "Concatenate multiple string values", isTag: false },
43
- { name: "ResourceGroup", description: "Get the current resource group object", isTag: false },
44
- { name: "Subscription", description: "Get the current subscription object", isTag: false },
45
- { name: "UniqueString", description: "Generate a deterministic hash string", isTag: false },
46
- { name: "Format", description: "Format a string with arguments", isTag: false },
47
- { name: "If", description: "Conditional expression", isTag: false },
48
- { name: "ListKeys", description: "List access keys for a resource", isTag: false },
54
+ { name: "ResourceId", description: "Generate a resource ID for an Azure resource", isTag: false, foldsAsCall: true },
55
+ { name: "Reference", description: "Get the runtime state of a deployed resource", isTag: false, foldsAsCall: true },
56
+ { name: "Concat", description: "Concatenate multiple string values", isTag: false, foldsAsCall: true },
57
+ { name: "ResourceGroup", description: "Get the current resource group object", isTag: false, foldsAsCall: true },
58
+ { name: "Subscription", description: "Get the current subscription object", isTag: false, foldsAsCall: true },
59
+ { name: "UniqueString", description: "Generate a deterministic hash string", isTag: false, foldsAsCall: true },
60
+ { name: "Format", description: "Format a string with arguments", isTag: false, foldsAsCall: true },
61
+ { name: "If", description: "Conditional expression", isTag: false, foldsAsCall: true },
62
+ { name: "ListKeys", description: "List access keys for a resource", isTag: false, foldsAsCall: true },
49
63
  ];
50
64
  },
51
65
 
package/src/serializer.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import type { Declarable, CoreParameter } from "@intentius/chant/declarable";
14
- import { isPropertyDeclarable } from "@intentius/chant/declarable";
14
+ import { isPropertyDeclarable, isResourceDeclarable } from "@intentius/chant/declarable";
15
15
  import type { Serializer, SerializerResult, SerializeContext } from "@intentius/chant/serializer";
16
16
  import { ownershipEntries, type OwnershipMarker } from "@intentius/chant/ownership";
17
17
  import { AZURE_TAG_OWNERSHIP_KEYS } from "./ownership";
@@ -147,7 +147,7 @@ function armVisitor(entityNames: Map<Declarable, string>): SerializerVisitor {
147
147
  return `[resourceId('${name}')]`;
148
148
  },
149
149
  propertyDeclarable: (entity, walk) => {
150
- if (!("props" in entity) || typeof entity.props !== "object" || entity.props === null) {
150
+ if (!isResourceDeclarable(entity) || typeof entity.props !== "object" || entity.props === null) {
151
151
  return undefined;
152
152
  }
153
153
  const props = entity.props as Record<string, unknown>;
@@ -244,7 +244,7 @@ function serializeToTemplate(
244
244
  } else if (!isPropertyDeclarable(entity)) {
245
245
  const resourceType = entity.entityType;
246
246
  // Prefer apiVersion from entity attributes (set by composites) over registry lookup
247
- const attrs0 = ("attributes" in entity && typeof entity.attributes === "object" && entity.attributes !== null)
247
+ const attrs0 = (isResourceDeclarable(entity) && typeof entity.attributes === "object" && entity.attributes !== null)
248
248
  ? entity.attributes as Record<string, unknown>
249
249
  : undefined;
250
250
  const apiVersion = (typeof attrs0?.apiVersion === "string") ? attrs0.apiVersion : getApiVersion(resourceType);
@@ -256,7 +256,7 @@ function serializeToTemplate(
256
256
  };
257
257
 
258
258
  // Extract all props
259
- if ("props" in entity && typeof entity.props === "object" && entity.props !== null) {
259
+ if (isResourceDeclarable(entity) && typeof entity.props === "object" && entity.props !== null) {
260
260
  const props = entity.props as Record<string, unknown>;
261
261
  const armProperties: Record<string, unknown> = {};
262
262
 
@@ -284,7 +284,7 @@ function serializeToTemplate(
284
284
  }
285
285
 
286
286
  // Handle DependsOn
287
- const attrs = ("attributes" in entity && typeof entity.attributes === "object" && entity.attributes !== null)
287
+ const attrs = (isResourceDeclarable(entity) && typeof entity.attributes === "object" && entity.attributes !== null)
288
288
  ? entity.attributes as Record<string, unknown>
289
289
  : undefined;
290
290