@azure/provisioning-core 0.1.0-alpha.20261014.1

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.
Files changed (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/constructs/built-in-resources/resource-group.d.ts +50 -0
  4. package/dist/constructs/built-in-resources/resource-group.d.ts.map +1 -0
  5. package/dist/constructs/built-in-resources/resource-group.js +97 -0
  6. package/dist/constructs/built-in-resources/resource-group.js.map +1 -0
  7. package/dist/constructs/output.d.ts +80 -0
  8. package/dist/constructs/output.d.ts.map +1 -0
  9. package/dist/constructs/output.js +76 -0
  10. package/dist/constructs/output.js.map +1 -0
  11. package/dist/constructs/parameter.d.ts +77 -0
  12. package/dist/constructs/parameter.d.ts.map +1 -0
  13. package/dist/constructs/parameter.js +93 -0
  14. package/dist/constructs/parameter.js.map +1 -0
  15. package/dist/constructs/provisioning-component.d.ts +91 -0
  16. package/dist/constructs/provisioning-component.d.ts.map +1 -0
  17. package/dist/constructs/provisioning-component.js +150 -0
  18. package/dist/constructs/provisioning-component.js.map +1 -0
  19. package/dist/constructs/resource/resource-proxy.d.ts +134 -0
  20. package/dist/constructs/resource/resource-proxy.d.ts.map +1 -0
  21. package/dist/constructs/resource/resource-proxy.js +523 -0
  22. package/dist/constructs/resource/resource-proxy.js.map +1 -0
  23. package/dist/constructs/resource/resource-query.d.ts +23 -0
  24. package/dist/constructs/resource/resource-query.d.ts.map +1 -0
  25. package/dist/constructs/resource/resource-query.js +71 -0
  26. package/dist/constructs/resource/resource-query.js.map +1 -0
  27. package/dist/constructs/resource/resource-registry.d.ts +99 -0
  28. package/dist/constructs/resource/resource-registry.d.ts.map +1 -0
  29. package/dist/constructs/resource/resource-registry.js +51 -0
  30. package/dist/constructs/resource/resource-registry.js.map +1 -0
  31. package/dist/constructs/resource/resource-type-registry.d.ts +46 -0
  32. package/dist/constructs/resource/resource-type-registry.d.ts.map +1 -0
  33. package/dist/constructs/resource/resource-type-registry.js +156 -0
  34. package/dist/constructs/resource/resource-type-registry.js.map +1 -0
  35. package/dist/constructs/resource/resource-utils.d.ts +60 -0
  36. package/dist/constructs/resource/resource-utils.d.ts.map +1 -0
  37. package/dist/constructs/resource/resource-utils.js +77 -0
  38. package/dist/constructs/resource/resource-utils.js.map +1 -0
  39. package/dist/constructs/resource/resource.d.ts +460 -0
  40. package/dist/constructs/resource/resource.d.ts.map +1 -0
  41. package/dist/constructs/resource/resource.js +584 -0
  42. package/dist/constructs/resource/resource.js.map +1 -0
  43. package/dist/constructs/stack.d.ts +110 -0
  44. package/dist/constructs/stack.d.ts.map +1 -0
  45. package/dist/constructs/stack.js +110 -0
  46. package/dist/constructs/stack.js.map +1 -0
  47. package/dist/constructs/variable.d.ts +63 -0
  48. package/dist/constructs/variable.d.ts.map +1 -0
  49. package/dist/constructs/variable.js +74 -0
  50. package/dist/constructs/variable.js.map +1 -0
  51. package/dist/deployment-context/deployment-context.d.ts +27 -0
  52. package/dist/deployment-context/deployment-context.d.ts.map +1 -0
  53. package/dist/deployment-context/deployment-context.js +4 -0
  54. package/dist/deployment-context/deployment-context.js.map +1 -0
  55. package/dist/expression/ast-nodes.d.ts +100 -0
  56. package/dist/expression/ast-nodes.d.ts.map +1 -0
  57. package/dist/expression/ast-nodes.js +127 -0
  58. package/dist/expression/ast-nodes.js.map +1 -0
  59. package/dist/expression/expressions.d.ts +164 -0
  60. package/dist/expression/expressions.d.ts.map +1 -0
  61. package/dist/expression/expressions.js +211 -0
  62. package/dist/expression/expressions.js.map +1 -0
  63. package/dist/fn.d.ts +194 -0
  64. package/dist/fn.d.ts.map +1 -0
  65. package/dist/fn.js +353 -0
  66. package/dist/fn.js.map +1 -0
  67. package/dist/index.d.ts +25 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +19 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/internal-loop.d.ts +14 -0
  72. package/dist/internal-loop.d.ts.map +1 -0
  73. package/dist/internal-loop.js +16 -0
  74. package/dist/internal-loop.js.map +1 -0
  75. package/dist/internal.d.ts +13 -0
  76. package/dist/internal.d.ts.map +1 -0
  77. package/dist/internal.js +10 -0
  78. package/dist/internal.js.map +1 -0
  79. package/dist/naming/naming-policy.d.ts +56 -0
  80. package/dist/naming/naming-policy.d.ts.map +1 -0
  81. package/dist/naming/naming-policy.js +99 -0
  82. package/dist/naming/naming-policy.js.map +1 -0
  83. package/dist/naming/naming-rules.d.ts +15 -0
  84. package/dist/naming/naming-rules.d.ts.map +1 -0
  85. package/dist/naming/naming-rules.js +15 -0
  86. package/dist/naming/naming-rules.js.map +1 -0
  87. package/dist/serialization/contract/generated/ast.d.ts +508 -0
  88. package/dist/serialization/contract/generated/ast.d.ts.map +1 -0
  89. package/dist/serialization/contract/generated/ast.js +23 -0
  90. package/dist/serialization/contract/generated/ast.js.map +1 -0
  91. package/dist/serialization/contract/index.d.ts +2 -0
  92. package/dist/serialization/contract/index.d.ts.map +1 -0
  93. package/dist/serialization/contract/index.js +4 -0
  94. package/dist/serialization/contract/index.js.map +1 -0
  95. package/dist/serialization/index.d.ts +4 -0
  96. package/dist/serialization/index.d.ts.map +1 -0
  97. package/dist/serialization/index.js +5 -0
  98. package/dist/serialization/index.js.map +1 -0
  99. package/dist/serialization/json/deserialize.d.ts +24 -0
  100. package/dist/serialization/json/deserialize.d.ts.map +1 -0
  101. package/dist/serialization/json/deserialize.js +476 -0
  102. package/dist/serialization/json/deserialize.js.map +1 -0
  103. package/dist/serialization/json/encoding.d.ts +4 -0
  104. package/dist/serialization/json/encoding.d.ts.map +1 -0
  105. package/dist/serialization/json/encoding.js +323 -0
  106. package/dist/serialization/json/encoding.js.map +1 -0
  107. package/dist/serialization/json/expression.d.ts +32 -0
  108. package/dist/serialization/json/expression.d.ts.map +1 -0
  109. package/dist/serialization/json/expression.js +490 -0
  110. package/dist/serialization/json/expression.js.map +1 -0
  111. package/dist/serialization/json/lower.d.ts +41 -0
  112. package/dist/serialization/json/lower.d.ts.map +1 -0
  113. package/dist/serialization/json/lower.js +343 -0
  114. package/dist/serialization/json/lower.js.map +1 -0
  115. package/dist/serialization/json/pluralize-config.d.ts +3 -0
  116. package/dist/serialization/json/pluralize-config.d.ts.map +1 -0
  117. package/dist/serialization/json/pluralize-config.js +7 -0
  118. package/dist/serialization/json/pluralize-config.js.map +1 -0
  119. package/dist/serialization/json/serialize.d.ts +12 -0
  120. package/dist/serialization/json/serialize.d.ts.map +1 -0
  121. package/dist/serialization/json/serialize.js +399 -0
  122. package/dist/serialization/json/serialize.js.map +1 -0
  123. package/dist/serialization/json/util.d.ts +2 -0
  124. package/dist/serialization/json/util.d.ts.map +1 -0
  125. package/dist/serialization/json/util.js +19 -0
  126. package/dist/serialization/json/util.js.map +1 -0
  127. package/dist/serialization/utils.d.ts +3 -0
  128. package/dist/serialization/utils.d.ts.map +1 -0
  129. package/dist/serialization/utils.js +146 -0
  130. package/dist/serialization/utils.js.map +1 -0
  131. package/dist/shape/shape-registry.d.ts +51 -0
  132. package/dist/shape/shape-registry.d.ts.map +1 -0
  133. package/dist/shape/shape-registry.js +41 -0
  134. package/dist/shape/shape-registry.js.map +1 -0
  135. package/dist/shape/shape.d.ts +407 -0
  136. package/dist/shape/shape.d.ts.map +1 -0
  137. package/dist/shape/shape.js +425 -0
  138. package/dist/shape/shape.js.map +1 -0
  139. package/dist/shape/value-encoding.d.ts +121 -0
  140. package/dist/shape/value-encoding.d.ts.map +1 -0
  141. package/dist/shape/value-encoding.js +32 -0
  142. package/dist/shape/value-encoding.js.map +1 -0
  143. package/dist/tsconfig.tsbuildinfo +1 -0
  144. package/dist/types.d.ts +9 -0
  145. package/dist/types.d.ts.map +1 -0
  146. package/dist/types.js +4 -0
  147. package/dist/types.js.map +1 -0
  148. package/dist/util.d.ts +33 -0
  149. package/dist/util.d.ts.map +1 -0
  150. package/dist/util.js +78 -0
  151. package/dist/util.js.map +1 -0
  152. package/package.json +49 -0
@@ -0,0 +1,110 @@
1
+ import { ProvisioningComponent } from "./provisioning-component.js";
2
+ import type { ExpressionOrValue } from "../expression/expressions.js";
3
+ import type { NamingPolicy } from "../naming/naming-policy.js";
4
+ import { OutputCollection } from "./output.js";
5
+ import { ParameterCollection } from "./parameter.js";
6
+ import { VariableCollection } from "./variable.js";
7
+ import { type QueryOptions } from "./resource/resource-query.js";
8
+ import { type Loop, type LoopedResource, type Resource, type ResourceOptions } from "./resource/resource.js";
9
+ import type { ResourceCtor } from "./resource/resource-registry.js";
10
+ import type { TargetScope } from "../serialization/contract/index.js";
11
+ export interface StackOptions {
12
+ readonly targetScope?: TargetScope | undefined;
13
+ readonly location?: ExpressionOrValue<string> | undefined;
14
+ readonly tags?: Record<string, ExpressionOrValue<string>> | undefined;
15
+ readonly namingPolicy?: NamingPolicy | undefined;
16
+ }
17
+ /**
18
+ * A Stack defines a deployment unit.
19
+ *
20
+ * @remarks
21
+ * Each stack produces one or more Bicep files — resources at different
22
+ * scopes (subscription vs. resource group) are split into separate files
23
+ * linked by module references.
24
+ *
25
+ * Resources register themselves by passing the stack (or a child component)
26
+ * as their first constructor argument. `Stack.add()` is available as a
27
+ * convenience for creating child components with the stack as parent.
28
+ *
29
+ * The `targetScope` option controls the Bicep target scope. Default is
30
+ * `"subscription"`, which requires explicit `ResourceGroup` instances.
31
+ * Set `"resourceGroup"` to deploy resources directly into an existing
32
+ * resource group.
33
+ *
34
+ * Every stack registers itself in `Stack.roots` for collection by tools
35
+ * like the playground and CLI.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { Stack, ResourceGroup } from "@azure/provisioning-core";
40
+ * import { KeyVault } from "@azure/provisioning-keyvault";
41
+ *
42
+ * const stack = new Stack("my-app");
43
+ * const rg = new ResourceGroup(stack, { name: "rg-my-app", location: "eastus" });
44
+ * const vault = new KeyVault(rg, {
45
+ * name: "kv-my-app",
46
+ * properties: {
47
+ * tenantId: "11111111-1111-1111-1111-111111111111",
48
+ * sku: { family: "A", name: "standard" },
49
+ * },
50
+ * });
51
+ * ```
52
+ */
53
+ export declare class Stack extends ProvisioningComponent {
54
+ #private;
55
+ readonly name: string;
56
+ readonly targetScope: TargetScope;
57
+ readonly parameters: ParameterCollection;
58
+ readonly variables: VariableCollection;
59
+ readonly outputs: OutputCollection;
60
+ /** All root stacks created since the last call to `Stack.clearRoots()`. */
61
+ static get roots(): readonly Stack[];
62
+ /**
63
+ * Returns all root stacks and clears the registry. Useful for collecting
64
+ * all stacks after executing user code (e.g. in the playground or CLI).
65
+ */
66
+ static clearRoots(): Stack[];
67
+ /** Create a root stack. */
68
+ constructor(name: string, options?: StackOptions);
69
+ /**
70
+ * The scalar resources in this stack. With no `type`, returns
71
+ * every scalar resource; pass a resource class to filter and narrow to
72
+ * that subclass. Returns a plain array — use native `.filter` / `.find` /
73
+ * `.map` for anything further.
74
+ *
75
+ * By default walks the whole tree; pass `{ recursive: false }` to consider
76
+ * only the stack's direct children.
77
+ */
78
+ getResources(options?: QueryOptions): Resource[];
79
+ getResources<T extends Resource>(type: ResourceCtor<T>, options?: QueryOptions): T[];
80
+ /**
81
+ * Find the **first** scalar resource of `type` whose literal name equals
82
+ * `name`, or `undefined` if none matches.
83
+ *
84
+ * @remarks
85
+ * Returns the first match in tree order. ARM names are unique only *per
86
+ * resource type within a scope*, so a stack MAY legitimately contain more
87
+ * than one resource of the same `type` and `name` (e.g. across different
88
+ * resource groups) — this returns whichever is found first. Use
89
+ * `getResources(type)` and filter yourself if you need all matches.
90
+ *
91
+ * Only scalar resources are searched, and names that do not resolve to a
92
+ * string literal are never matched. Pass `{ recursive: false }` to search
93
+ * only the stack's direct children.
94
+ */
95
+ getResource<T extends Resource>(type: ResourceCtor<T>, name: string, options?: QueryOptions): T | undefined;
96
+ /**
97
+ * Create a child under this stack (with the stack as its parent context),
98
+ * as a convenience for `new Ctor(stack, ...args)`.
99
+ *
100
+ * Constructs a single child instance and returns it.
101
+ */
102
+ add<T extends new (context: ProvisioningComponent, ...args: any[]) => ProvisioningComponent>(ctor: T, ...args: ConstructorParameters<T> extends [any, ...infer Rest] ? Rest : never): InstanceType<T>;
103
+ }
104
+ /** @internal */
105
+ export declare function getLoopedResources(stack: Stack, options?: QueryOptions): LoopedResource<Resource>[];
106
+ /** @internal */
107
+ export declare function getLoopedResources<T extends Resource>(stack: Stack, type: ResourceCtor<T>, options?: QueryOptions): LoopedResource<T>[];
108
+ /** @internal */
109
+ export declare function addLoopedResource<T extends Resource, P>(stack: Stack, ctor: new (context: Stack, props: P, options?: ResourceOptions) => T, loop: Loop<unknown>, ...rest: undefined extends P ? [props?: P, options?: ResourceOptions] : [props: P, options?: ResourceOptions]): LoopedResource<T>;
110
+ //# sourceMappingURL=stack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/constructs/stack.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAMtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,QAAQ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,IAAI,EAAE,GAAG,EAAE,KACX,qBAAqB,EAE1B,IAAI,EAAE,CAAC,EACP,GAAG,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,GAC1D,IAAI,GACJ,KAAK,GACR,YAAY,CAAC,CAAC,CAAC;CAUnB;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC9B,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EACnD,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;AASvB,gBAAgB;AAChB,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,EACrD,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,CAAC,EACpE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,GAAG,IAAI,EAAE,SAAS,SAAS,CAAC,GACxB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,GACtC,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,GACxC,cAAc,CAAC,CAAC,CAAC,CAEnB"}
@@ -0,0 +1,110 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { ProvisioningComponent } from "./provisioning-component.js";
4
+ import { DefaultNamingPolicy } from "../naming/naming-policy.js";
5
+ import { OutputCollection } from "./output.js";
6
+ import { ParameterCollection } from "./parameter.js";
7
+ import { VariableCollection } from "./variable.js";
8
+ import { getLoopedResources as runGetLoopedResources, getResources as runGetResources, getResource as runGetResource, } from "./resource/resource-query.js";
9
+ import { createLoopedResource, } from "./resource/resource.js";
10
+ /**
11
+ * A Stack defines a deployment unit.
12
+ *
13
+ * @remarks
14
+ * Each stack produces one or more Bicep files — resources at different
15
+ * scopes (subscription vs. resource group) are split into separate files
16
+ * linked by module references.
17
+ *
18
+ * Resources register themselves by passing the stack (or a child component)
19
+ * as their first constructor argument. `Stack.add()` is available as a
20
+ * convenience for creating child components with the stack as parent.
21
+ *
22
+ * The `targetScope` option controls the Bicep target scope. Default is
23
+ * `"subscription"`, which requires explicit `ResourceGroup` instances.
24
+ * Set `"resourceGroup"` to deploy resources directly into an existing
25
+ * resource group.
26
+ *
27
+ * Every stack registers itself in `Stack.roots` for collection by tools
28
+ * like the playground and CLI.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { Stack, ResourceGroup } from "@azure/provisioning-core";
33
+ * import { KeyVault } from "@azure/provisioning-keyvault";
34
+ *
35
+ * const stack = new Stack("my-app");
36
+ * const rg = new ResourceGroup(stack, { name: "rg-my-app", location: "eastus" });
37
+ * const vault = new KeyVault(rg, {
38
+ * name: "kv-my-app",
39
+ * properties: {
40
+ * tenantId: "11111111-1111-1111-1111-111111111111",
41
+ * sku: { family: "A", name: "standard" },
42
+ * },
43
+ * });
44
+ * ```
45
+ */
46
+ export class Stack extends ProvisioningComponent {
47
+ name;
48
+ targetScope;
49
+ parameters = new ParameterCollection();
50
+ variables = new VariableCollection();
51
+ outputs = new OutputCollection();
52
+ // --- Static root stack registry ---
53
+ static #roots = [];
54
+ /** All root stacks created since the last call to `Stack.clearRoots()`. */
55
+ static get roots() {
56
+ return Stack.#roots;
57
+ }
58
+ /**
59
+ * Returns all root stacks and clears the registry. Useful for collecting
60
+ * all stacks after executing user code (e.g. in the playground or CLI).
61
+ */
62
+ static clearRoots() {
63
+ return Stack.#roots.splice(0, Stack.#roots.length);
64
+ }
65
+ /** Create a root stack. */
66
+ constructor(name, options) {
67
+ super();
68
+ const opts = options ?? {};
69
+ this.name = name;
70
+ this.targetScope = opts.targetScope ?? "subscription";
71
+ Stack.#roots.push(this);
72
+ this._localDeploymentContext = {
73
+ location: opts.location,
74
+ tags: opts.tags,
75
+ namingPolicy: opts.namingPolicy ?? new DefaultNamingPolicy({ workload: name }),
76
+ };
77
+ }
78
+ getResources(typeOrOptions, maybeOptions) {
79
+ return runGetResources(this, typeOrOptions, maybeOptions);
80
+ }
81
+ /**
82
+ * Find the **first** scalar resource of `type` whose literal name equals
83
+ * `name`, or `undefined` if none matches.
84
+ *
85
+ * @remarks
86
+ * Returns the first match in tree order. ARM names are unique only *per
87
+ * resource type within a scope*, so a stack MAY legitimately contain more
88
+ * than one resource of the same `type` and `name` (e.g. across different
89
+ * resource groups) — this returns whichever is found first. Use
90
+ * `getResources(type)` and filter yourself if you need all matches.
91
+ *
92
+ * Only scalar resources are searched, and names that do not resolve to a
93
+ * string literal are never matched. Pass `{ recursive: false }` to search
94
+ * only the stack's direct children.
95
+ */
96
+ getResource(type, name, options) {
97
+ return runGetResource(this, type, name, options);
98
+ }
99
+ add(ctor, ...rest) {
100
+ return new ctor(this.self, ...rest);
101
+ }
102
+ }
103
+ export function getLoopedResources(stack, typeOrOptions, maybeOptions) {
104
+ return runGetLoopedResources(stack, typeOrOptions, maybeOptions);
105
+ }
106
+ /** @internal */
107
+ export function addLoopedResource(stack, ctor, loop, ...rest) {
108
+ return createLoopedResource(ctor, loop, stack.self, ...rest);
109
+ }
110
+ //# sourceMappingURL=stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/constructs/stack.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gBAAg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I,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EACV,IAAI,CAAC,YAAY,IAAI,IAAI,mBAAmB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC;IAuBD,YAAY,CACV,aAAqD,EACrD,YAA2B;QAE3B,OAAO,eAAe,CAAC,IAAI,EAAE,aAAsB,EAAE,YAAY,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,WAAW,CACT,IAAqB,EACrB,IAAY,EACZ,OAAsB;QAEtB,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAmBD,GAAG,CACD,IAG0B,EAC1B,GAAG,IAAW;QAEd,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;;AAcH,MAAM,UAAU,kBAAkB,CAChC,KAAY,EACZ,aAAqD,EACrD,YAA2B;IAE3B,OAAO,qBAAqB,CAAC,KAAK,EAAE,aAAsB,EAAE,YAAY,CAAC,CAAC;AAC5E,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAC/B,KAAY,EACZ,IAAoE,EACpE,IAAmB,EACnB,GAAG,IAEsC;IAEzC,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { Expression, InputOf } from "../expression/expressions.js";
2
+ import type { Stack } from "./stack.js";
3
+ export type ExpressionValue<T> = T extends Expression<infer U> ? U : T;
4
+ /**
5
+ * A value accepted as a deployment variable's value: any JSON literal
6
+ * (scalar, `null`, array, object — recursively), an `Expression`, or a
7
+ * resource view (`InputOf<unknown>`). The literal members are required so
8
+ * plain object/array literals are accepted (a bare `InputOf<unknown>` is a
9
+ * weak type and would reject them).
10
+ */
11
+ export type VariableValue = string | number | boolean | null | readonly VariableValue[] | {
12
+ readonly [key: string]: VariableValue;
13
+ } | InputOf<unknown>;
14
+ export type VariableOptions = {
15
+ readonly description?: string | undefined;
16
+ readonly export?: boolean | undefined;
17
+ };
18
+ /**
19
+ * Pure declaration data for a deployment variable. Stored on the stack
20
+ * (paired with the returned expression handle in {@link VariableEntry});
21
+ * read by the serializer at emit time. Not part of the value-level handle.
22
+ */
23
+ export interface VariableMetadata extends VariableOptions {
24
+ readonly name: string;
25
+ readonly value: VariableValue;
26
+ }
27
+ export type Variable<TValue extends VariableValue = VariableValue> = Expression<ExpressionValue<TValue>>;
28
+ /**
29
+ * Authoring-time collection of a stack's deployment variables. Backed by an
30
+ * ordered private array; supports add/get/delete/iteration. Look variables up
31
+ * by name via {@link VariableCollection.get}.
32
+ */
33
+ export declare class VariableCollection {
34
+ #private;
35
+ /** Add a variable; returns its expression handle. Throws on duplicate name. */
36
+ add<TValue extends VariableValue = VariableValue>(name: string, value: TValue, options?: VariableOptions): Variable<TValue>;
37
+ /** The expression handle for a variable, or `undefined`. */
38
+ get(name: string): Variable | undefined;
39
+ /** The declaration metadata for a variable, or `undefined`. */
40
+ getMetadata(name: string): VariableMetadata | undefined;
41
+ /** All variable handles, in insertion order. */
42
+ list(): readonly Variable[];
43
+ /** All declaration metadata, in insertion order. */
44
+ listMetadata(): readonly VariableMetadata[];
45
+ has(name: string): boolean;
46
+ /** Remove a variable by name. Returns whether one was removed. */
47
+ delete(name: string): boolean;
48
+ get size(): number;
49
+ [Symbol.iterator](): IterableIterator<Variable>;
50
+ }
51
+ /**
52
+ * A computed value evaluated at deploy time, compiled to a Bicep `var` declaration.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { Stack, createVariable } from "@azure/provisioning-core";
57
+ *
58
+ * const stack = new Stack("my-app");
59
+ * const suffix = createVariable(stack, "suffix", "prod");
60
+ * ```
61
+ */
62
+ export declare function createVariable<TValue extends VariableValue = VariableValue>(stack: Stack, name: string, value: TValue, options?: VariableOptions): Variable<TValue>;
63
+ //# sourceMappingURL=variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/constructs/variable.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,aAAa,EAAE,GACxB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,GACzC,OAAO,CAAC,OAAO,CAAC,CAAC;AAErB,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AAOD,MAAM,MAAM,QAAQ,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa,IAAI,UAAU,CAC7E,eAAe,CAAC,MAAM,CAAC,CACxB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,kBAAkB;;IAG7B,+EAA+E;IAC/E,GAAG,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa,EAC9C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,CAAC,MAAM,CAAC;IAYnB,4DAA4D;IAC5D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIvC,+DAA+D;IAC/D,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAIvD,gDAAgD;IAChD,IAAI,IAAI,SAAS,QAAQ,EAAE;IAI3B,oDAAoD;IACpD,YAAY,IAAI,SAAS,gBAAgB,EAAE;IAI3C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,kEAAkE;IAClE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC;CAOhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa,EACzE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,CAAC,MAAM,CAAC,CAElB"}
@@ -0,0 +1,74 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { wrapExpression } from "../expression/expressions.js";
4
+ import { symbolicValueExpressionNode } from "../expression/ast-nodes.js";
5
+ import { assertBicepIdentifier } from "../util.js";
6
+ /**
7
+ * Authoring-time collection of a stack's deployment variables. Backed by an
8
+ * ordered private array; supports add/get/delete/iteration. Look variables up
9
+ * by name via {@link VariableCollection.get}.
10
+ */
11
+ export class VariableCollection {
12
+ #entries = [];
13
+ /** Add a variable; returns its expression handle. Throws on duplicate name. */
14
+ add(name, value, options) {
15
+ assertBicepIdentifier(name, "Deployment variable");
16
+ if (this.has(name)) {
17
+ throw new Error(`Duplicate deployment variable name: ${name}`);
18
+ }
19
+ const variable = wrapExpression(symbolicValueExpressionNode(name));
20
+ this.#entries.push({ metadata: { name, value, ...options }, variable });
21
+ return variable;
22
+ }
23
+ /** The expression handle for a variable, or `undefined`. */
24
+ get(name) {
25
+ return this.#find(name)?.variable;
26
+ }
27
+ /** The declaration metadata for a variable, or `undefined`. */
28
+ getMetadata(name) {
29
+ return this.#find(name)?.metadata;
30
+ }
31
+ /** All variable handles, in insertion order. */
32
+ list() {
33
+ return this.#entries.map((e) => e.variable);
34
+ }
35
+ /** All declaration metadata, in insertion order. */
36
+ listMetadata() {
37
+ return this.#entries.map((e) => e.metadata);
38
+ }
39
+ has(name) {
40
+ return this.#find(name) !== undefined;
41
+ }
42
+ /** Remove a variable by name. Returns whether one was removed. */
43
+ delete(name) {
44
+ const i = this.#entries.findIndex((e) => e.metadata.name === name);
45
+ if (i === -1)
46
+ return false;
47
+ this.#entries.splice(i, 1);
48
+ return true;
49
+ }
50
+ get size() {
51
+ return this.#entries.length;
52
+ }
53
+ [Symbol.iterator]() {
54
+ return this.#entries.map((e) => e.variable)[Symbol.iterator]();
55
+ }
56
+ #find(name) {
57
+ return this.#entries.find((e) => e.metadata.name === name);
58
+ }
59
+ }
60
+ /**
61
+ * A computed value evaluated at deploy time, compiled to a Bicep `var` declaration.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * import { Stack, createVariable } from "@azure/provisioning-core";
66
+ *
67
+ * const stack = new Stack("my-app");
68
+ * const suffix = createVariable(stack, "suffix", "prod");
69
+ * ```
70
+ */
71
+ export function createVariable(stack, name, value, options) {
72
+ return stack.variables.add(name, value, options);
73
+ }
74
+ //# sourceMappingURL=variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable.js","sourceRoot":"","sources":["../../src/constructs/variable.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,qBAAqB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C,CAAC;IAED,kEAAkE;IAClE,MAAM,CAAC,IAAY;QACjB,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,KAAK,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7D,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAY,EACZ,IAAY,EACZ,KAAa,EACb,OAAyB;IAEzB,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ExpressionOrValue } from "../expression/expressions.js";
2
+ import type { NamingPolicy } from "../naming/naming-policy.js";
3
+ /**
4
+ * Inherited environment that flows down the component tree.
5
+ *
6
+ * @remarks
7
+ * Each node may attach a local contribution via `ProvisioningComponent._localDeploymentContext`
8
+ * (today, only `Stack` and `ResourceGroup` do). When a `Resource` reads the
9
+ * effective context, the framework walks ancestors and resolves each field:
10
+ *
11
+ * - `location`: nearest ancestor with a value wins.
12
+ * - `namingPolicy`: nearest ancestor with a value wins.
13
+ * - `tags`: flat-merged across **all** ancestors; innermost wins on key conflict.
14
+ *
15
+ * Per-resource Bicep `scope:` is not part of this — a resource's deployment
16
+ * scope is determined by which file or module it lands in, which in turn is
17
+ * determined by the ProvisioningComponent tree (the nearest `ResourceGroup`/`Stack` ancestor).
18
+ *
19
+ * The same interface describes both a node's local contribution and the
20
+ * fully-resolved view returned by `ProvisioningComponent.deploymentContext`.
21
+ */
22
+ export interface DeploymentContext {
23
+ readonly location?: ExpressionOrValue<string> | undefined;
24
+ readonly tags?: Record<string, ExpressionOrValue<string>> | undefined;
25
+ readonly namingPolicy?: NamingPolicy | undefined;
26
+ }
27
+ //# sourceMappingURL=deployment-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-context.d.ts","sourceRoot":"","sources":["../../src/deployment-context/deployment-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CAClD"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=deployment-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-context.js","sourceRoot":"","sources":["../../src/deployment-context/deployment-context.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,100 @@
1
+ import type { Resource } from "../constructs/resource/resource.js";
2
+ import type { BinaryOperator, UnaryOperator } from "../serialization/contract/index.js";
3
+ import type { PropertySegment } from "../types.js";
4
+ export type { BinaryOperator, UnaryOperator };
5
+ export interface FunctionCallExpressionNode<_TValue = unknown, TOperator extends string = string> {
6
+ readonly kind: "fn-call";
7
+ readonly operator: TOperator;
8
+ readonly args: readonly unknown[];
9
+ }
10
+ export interface SymbolicValueExpressionNode<_TValue = unknown, TPath extends string = string> {
11
+ readonly kind: "symbolic-value";
12
+ readonly path: TPath;
13
+ }
14
+ export interface IdentifierExpressionNode<_TValue = unknown> {
15
+ readonly kind: "identifier";
16
+ readonly id: string | Resource;
17
+ }
18
+ export interface PropertyAccessExpressionNode<_TValue = unknown> {
19
+ readonly kind: "property-access";
20
+ readonly base: ExpressionNode;
21
+ readonly property: string;
22
+ readonly nullish: boolean;
23
+ /**
24
+ * Optional ARM wire-path segments. When present, the serialization
25
+ * lowering pass rewrites this single access into a chain that walks
26
+ * these segments (handling renames + `@flattenProperty` hoisting).
27
+ * Untyped / hand-built expressions leave this `undefined` and pass
28
+ * through unchanged.
29
+ */
30
+ readonly armPath?: readonly string[] | undefined;
31
+ }
32
+ export interface ArrayAccessExpressionNode<_TValue = unknown> {
33
+ readonly kind: "array-access";
34
+ readonly base: ExpressionNode;
35
+ /**
36
+ * The index into the array. A literal `number`/`string` lowers to an
37
+ * integer/string array-access (or a property-access for identifier-like
38
+ * strings) at serialize time. Any {@link ExpressionNode} is serialized
39
+ * recursively into the wire array-access's `index` slot — e.g. a looped
40
+ * `.at(loop.index)` stores the unwrapped `symbolic-value` node (emitting
41
+ * `sym[i]`), and a computed offset stores a `binary` / `fn-call` node
42
+ * (`sym[i + 1]`). `Expression<T>` proxies are always unwrapped to their
43
+ * raw node before landing here, per the "state holds normalized raw
44
+ * nodes" invariant — so a proxy is never stored directly.
45
+ */
46
+ readonly index: ArrayAccessIndex;
47
+ readonly nullish: boolean;
48
+ readonly fromEnd: boolean;
49
+ }
50
+ export interface BinaryExpressionNode<_TValue = unknown> {
51
+ readonly kind: "binary";
52
+ readonly operator: BinaryOperator;
53
+ readonly left: unknown;
54
+ readonly right: unknown;
55
+ }
56
+ export interface UnaryExpressionNode<_TValue = unknown> {
57
+ readonly kind: "unary";
58
+ readonly operator: UnaryOperator;
59
+ readonly argument: unknown;
60
+ }
61
+ export interface TernaryExpressionNode<_TValue = unknown> {
62
+ readonly kind: "ternary";
63
+ readonly condition: unknown;
64
+ readonly trueValue: unknown;
65
+ readonly falseValue: unknown;
66
+ }
67
+ export interface InstanceFunctionCallExpressionNode<_TValue = unknown> {
68
+ readonly kind: "instance-function-call";
69
+ readonly base: ExpressionNode;
70
+ readonly name: string;
71
+ readonly args: readonly unknown[];
72
+ }
73
+ export interface InterpolatedStringExpressionNode<_TValue = unknown> {
74
+ readonly kind: "interpolated-string";
75
+ readonly segments: readonly unknown[];
76
+ }
77
+ export type ExpressionNode<T = unknown> = FunctionCallExpressionNode<T> | SymbolicValueExpressionNode<T> | IdentifierExpressionNode<T> | PropertyAccessExpressionNode<T> | ArrayAccessExpressionNode<T> | BinaryExpressionNode<T> | UnaryExpressionNode<T> | TernaryExpressionNode<T> | InstanceFunctionCallExpressionNode<T> | InterpolatedStringExpressionNode<T>;
78
+ /**
79
+ * The index stored on an {@link ArrayAccessExpressionNode}: a literal
80
+ * `number` or `string`, or a raw {@link ExpressionNode} evaluated at
81
+ * serialize time (e.g. a loop's `symbolic-value` index, or a `binary` /
82
+ * `fn-call` node for a computed offset). `Expression<T>` proxies are
83
+ * unwrapped to their raw node before being stored, so the proxy type is
84
+ * intentionally absent here.
85
+ */
86
+ export type ArrayAccessIndex = number | string | ExpressionNode;
87
+ /** Tests whether a value structurally matches a raw expression AST node. */
88
+ export declare function isExpressionNode(value: unknown): value is ExpressionNode;
89
+ export declare function functionCallExpressionNode<TValue = unknown, TOperator extends string = string>(operator: TOperator, args: readonly unknown[]): FunctionCallExpressionNode<TValue, TOperator>;
90
+ export declare function symbolicValueExpressionNode<TValue = unknown, TPath extends string = string>(path: TPath): SymbolicValueExpressionNode<TValue, TPath>;
91
+ export declare function identifierExpressionNode<TValue = unknown>(identifier: string | Resource): IdentifierExpressionNode<TValue>;
92
+ export declare function propertyAccessExpressionNode<TValue = unknown>(base: ExpressionNode, property: string, options?: Partial<Pick<PropertyAccessExpressionNode, "armPath" | "nullish">>): PropertyAccessExpressionNode<TValue>;
93
+ export declare function arrayAccessExpressionNode<TValue = unknown>(base: ExpressionNode, index: ArrayAccessIndex, options?: Partial<Pick<ArrayAccessExpressionNode, "nullish" | "fromEnd">>): ArrayAccessExpressionNode<TValue>;
94
+ export declare function binaryExpressionNode<TValue = unknown>(operator: BinaryOperator, left: unknown, right: unknown): BinaryExpressionNode<TValue>;
95
+ export declare function unaryExpressionNode<TValue = unknown>(operator: UnaryOperator, argument: unknown): UnaryExpressionNode<TValue>;
96
+ export declare function ternaryExpressionNode<TValue = unknown>(condition: unknown, trueValue: unknown, falseValue: unknown): TernaryExpressionNode<TValue>;
97
+ export declare function instanceFunctionCallExpressionNode<TValue = unknown>(base: ExpressionNode, name: string, args: readonly unknown[]): InstanceFunctionCallExpressionNode<TValue>;
98
+ export declare function interpolatedStringExpressionNode<TValue = unknown>(segments: readonly unknown[]): InterpolatedStringExpressionNode<TValue>;
99
+ export declare function accessExpressionNode(base: ExpressionNode, member: PropertySegment, options?: Partial<Pick<PropertyAccessExpressionNode, "armPath" | "nullish">>): PropertyAccessExpressionNode | ArrayAccessExpressionNode;
100
+ //# sourceMappingURL=ast-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-nodes.d.ts","sourceRoot":"","sources":["../../src/expression/ast-nodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAA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