@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # `@azure/provisioning-core`
2
+
3
+ The runtime for authoring Azure infrastructure in TypeScript: resource trees, symbolic expressions, shared configuration, and JSON serialization. Creating or editing these objects changes a deployment definition, not live Azure resources.
4
+
5
+ Start with [Getting started](../../docs/getting-started.md) for a walkthrough using core and service classes such as `StorageAccount` and `KeyVault`.
6
+
7
+ ## Major features
8
+
9
+ ### Resource authoring
10
+
11
+ A deployment definition is a tree of `ProvisioningComponent` objects. `Stack`, `Resource`, and concrete resource classes such as `StorageAccount` are direct or indirect subclasses of it. Each building block links to its source implementation:
12
+
13
+ - [ProvisioningComponent](src/constructs/provisioning-component.ts) - the base class for tree nodes, providing parent-child tracking, inherited deployment context, traversal, and transformations. You can create your own subclass to group related resources, apply shared configuration, and expose resource handles as a reusable component. The component itself does not declare an Azure resource.
14
+ - [Stack](src/constructs/stack.ts) - the root component of a definition, holding resources and deployment inputs and outputs.
15
+ - [Resource](src/constructs/resource/resource.ts) - the base for service classes and generic ARM declarations, including existing references, conditions, and dependencies. Writable properties can be edited after construction and before serialization; read-only properties remain available as references.
16
+ - [ResourceGroup](src/constructs/built-in-resources/resource-group.ts) - a built-in Azure resource that also provides a parent context for its resources.
17
+ - [Deployment context](src/deployment-context/deployment-context.ts) - carries inherited location, tags, and naming policy through the component tree. The nearest ancestor supplies location and policy; ancestor tags are merged with nearer values taking precedence.
18
+ - [Naming](src/naming/naming-policy.ts) - generates omitted resource names through a configurable policy, using [resource naming rules](src/naming/naming-rules.ts) that describe Azure length, character, and uniqueness requirements. These rules guide name generation; explicit names are used unchanged.
19
+ - [Parameters](src/constructs/parameter.ts) - inputs supplied at deployment, with optional defaults and constraints.
20
+ - [Variables](src/constructs/variable.ts) - named values or expressions shared within the definition.
21
+ - [Outputs](src/constructs/output.ts) - values returned by the deployment, such as a resource ID.
22
+ - [Resource queries](src/constructs/resource/resource-query.ts) - find authored objects by type or literal name so they can be inspected and edited without querying Azure.
23
+
24
+ **Read more**
25
+
26
+ - [Getting started](../../docs/getting-started.md#define-a-stack-and-resources) - construct and configure resources through the public APIs.
27
+ - [Configure resource properties](../../docs/getting-started.md#configure-resource-properties) - edit writable properties or replace nested objects before serialization.
28
+ - [Infrastructure authoring model](../../docs/authoring-model.md) - resource relationships and reusable components.
29
+ - [Names and shared defaults](../../docs/authoring-model.md#names-and-shared-defaults) - naming policies, inherited settings, and resource-level overrides.
30
+ - [Parameters, variables, and outputs](../../docs/getting-started.md#parameters-variables-and-outputs) - declare deployment values through stack collections.
31
+
32
+ ### Functions and expressions
33
+
34
+ Connect resource settings to parameters, calculations, and other resources even when their values are not yet known. Core preserves these relationships as deployment-time expressions rather than evaluating them in JavaScript.
35
+
36
+ - [Function helpers](src/fn.ts) - `fn` builds symbolic operations such as concatenation, comparisons, and resource-ID calculations.
37
+ - [Expression types](src/expression/expressions.ts) - `Expression<T>` and `ExpressionOrValue<T>` describe symbolic and literal values; generated input/view types use core's typing contracts to support nested authoring.
38
+ - [Resource property expressions](src/constructs/resource/resource-proxy.ts) - use resource properties as deployment-time expressions to connect resources, such as passing one resource's ID to another resource's input.
39
+
40
+ **Read more**
41
+
42
+ - [Working with expressions](../../docs/getting-started.md#work-with-expressions) - authoring calculations and resource references.
43
+ - [Provisioning type system](../../contributing/internals/provisioning-type-system.md) - input/view types and expression assignability.
44
+ - [Proxy system](../../contributing/internals/proxy-system.md) - how core supports expressions on resource properties through ordinary TypeScript property access.
45
+
46
+ ### Serialization and restoration
47
+
48
+ [serialize](src/serialization/json/serialize.ts) converts the tree, values, and references into a JSON-compatible document. [deserialize](src/serialization/json/deserialize.ts) reconstructs supported resource objects so they can be queried, edited, and serialized again. Three pieces support this round trip:
49
+
50
+ - [Serialization contract](src/serialization/contract/index.ts) - defines the cross-language JSON format for exchanging provisioning definitions between TypeScript and .NET, so both sides interpret resource declarations, values, and references consistently.
51
+ - [Runtime shapes](src/shape/shape.ts) - retain client-to-ARM property mappings, nested types, and encoding metadata after TypeScript erasure, guiding value conversion in both directions.
52
+ - [Resource registration](src/constructs/resource/resource-type-registry.ts) - resolves registered classes and shapes by resource type, API version, and variant. Load the relevant service packages before restoration so their registrations are available.
53
+
54
+ **Read more**
55
+
56
+ - [Changing the serialization contract](../../contributing/workflows/change-schema-files.md) - contract source, generation, and affected consumers.
57
+ - [Runtime shapes and registration](../../contributing/internals/service-packages.md#runtime-shapes-and-registration) - property mappings and concrete resource classes.
58
+ - [Serialization and restoration](../../contributing/internals/serialization-roundtrip.md) - the round-trip workflow and its limitations.
59
+
60
+ ## Related packages
61
+
62
+ For how service classes, their types, and runtime metadata are produced, see [Service package anatomy](../../contributing/internals/service-packages.md) and the [TypeSpec emitter overview](../../contributing/internals/emitter-overview.md).
@@ -0,0 +1,50 @@
1
+ import type { ProvisioningComponent } from "../provisioning-component.js";
2
+ import { type Expression, type ExpressionOrValue, type InputRecord } from "../../expression/expressions.js";
3
+ import type { ResourceNamingRules } from "../../naming/naming-rules.js";
4
+ import type { ExistingResourceProps } from "../resource/resource.js";
5
+ import { Resource } from "../resource/resource.js";
6
+ export interface ResourceGroupProps {
7
+ name?: ExpressionOrValue<string> | undefined;
8
+ location: ExpressionOrValue<string>;
9
+ tags?: Record<string, ExpressionOrValue<string>>;
10
+ managedBy?: ExpressionOrValue<string>;
11
+ }
12
+ /**
13
+ * An Azure resource group that establishes a deployment boundary.
14
+ *
15
+ * @remarks
16
+ * Resources created with a `ResourceGroup` as their parent inherit its
17
+ * location, tags, and naming policy, and deploy at resource-group scope
18
+ * in the generated Bicep.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { Stack, ResourceGroup } from "@azure/provisioning-core";
23
+ * import { KeyVault } from "@azure/provisioning-keyvault";
24
+ *
25
+ * const stack = new Stack("my-app");
26
+ * const rg = new ResourceGroup(stack, { location: "eastus" });
27
+ * const vault = new KeyVault(rg, {
28
+ * properties: { tenantId: "...", sku: { family: "A", name: "standard" } },
29
+ * });
30
+ * ```
31
+ */
32
+ export declare class ResourceGroup extends Resource<"Microsoft.Resources/resourceGroups"> {
33
+ static readonly resourceType: "Microsoft.Resources/resourceGroups";
34
+ static readonly apiVersion = "2024-03-01";
35
+ protected static namingRules: ResourceNamingRules;
36
+ constructor(context: ProvisioningComponent, props: (ResourceGroupProps & {
37
+ existing?: false;
38
+ }) | (ExistingResourceProps & {
39
+ existing: true;
40
+ }));
41
+ /** The resource group's location as an expression. */
42
+ get location(): Expression<string>;
43
+ set location(value: ExpressionOrValue<string>);
44
+ get managedBy(): Expression<string>;
45
+ set managedBy(value: ExpressionOrValue<string> | undefined);
46
+ get tags(): InputRecord<ExpressionOrValue<string>, Record<string, string>> | undefined;
47
+ set tags(value: InputRecord<ExpressionOrValue<string>, Record<string, string>> | undefined);
48
+ add<T extends new (context: ProvisioningComponent, ...args: any[]) => ProvisioningComponent>(ctor: T, ...args: ConstructorParameters<T> extends [any, ...infer Rest] ? Rest : never): InstanceType<T>;
49
+ }
50
+ //# sourceMappingURL=resource-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-group.d.ts","sourceRoot":"","sources":["../../../src/constructs/built-in-resources/resource-group.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAoBnD,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAc,SAAQ,QAAQ,CAAC,oCAAoC,CAAC;IAC/E,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAG,oCAAoC,CAAU;IAC7E,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAgB;IAE1C,SAAS,CAAC,MAAM,CAAC,WAAW,sBAA4B;gBAkBtD,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EACD,CAAC,kBAAkB,GAAG;QAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;KAAE,CAAC,GAC3C,CAAC,qBAAqB,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC;IAmBlD,sDAAsD;IACtD,IAAI,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC,CAEjC;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAE5C;IAED,IAAI,SAAS,IAAI,UAAU,CAAC,MAAM,CAAC,CAElC;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,SAAS,EAEzD;IAED,IAAI,IAAI,IACJ,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC9D,SAAS,CAOZ;IACD,IAAI,IAAI,CACN,KAAK,EACD,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC9D,SAAS,EAGd;IAED,GAAG,CACD,CAAC,SAAS,KACR,OAAO,EAAE,qBAAqB,EAC9B,GAAG,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;CAGnB"}
@@ -0,0 +1,97 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import * as fn from "../../fn.js";
4
+ import {} from "../../expression/expressions.js";
5
+ import { deref } from "../resource/resource-proxy.js";
6
+ import { Resource } from "../resource/resource.js";
7
+ import { createFlatModelShape, createRecordShape, createStringShape, } from "../../shape/shape.js";
8
+ const resourceGroupNamingRules = {
9
+ abbreviation: "rg",
10
+ minLength: 1,
11
+ maxLength: 90,
12
+ validCharacters: {
13
+ uppercase: true,
14
+ hyphens: true,
15
+ underscores: true,
16
+ periods: true,
17
+ },
18
+ scope: "subscription",
19
+ };
20
+ /**
21
+ * An Azure resource group that establishes a deployment boundary.
22
+ *
23
+ * @remarks
24
+ * Resources created with a `ResourceGroup` as their parent inherit its
25
+ * location, tags, and naming policy, and deploy at resource-group scope
26
+ * in the generated Bicep.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { Stack, ResourceGroup } from "@azure/provisioning-core";
31
+ * import { KeyVault } from "@azure/provisioning-keyvault";
32
+ *
33
+ * const stack = new Stack("my-app");
34
+ * const rg = new ResourceGroup(stack, { location: "eastus" });
35
+ * const vault = new KeyVault(rg, {
36
+ * properties: { tenantId: "...", sku: { family: "A", name: "standard" } },
37
+ * });
38
+ * ```
39
+ */
40
+ export class ResourceGroup extends Resource {
41
+ static resourceType = "Microsoft.Resources/resourceGroups";
42
+ static apiVersion = "2024-03-01";
43
+ static namingRules = resourceGroupNamingRules;
44
+ static {
45
+ this.registerShape(createFlatModelShape({
46
+ name: { armPath: ["name"], value: createStringShape() },
47
+ location: { armPath: ["location"], value: createStringShape() },
48
+ tags: {
49
+ armPath: ["tags"],
50
+ value: createRecordShape(createStringShape()),
51
+ },
52
+ managedBy: { armPath: ["managedBy"], value: createStringShape() },
53
+ }));
54
+ this.register();
55
+ }
56
+ constructor(context, props) {
57
+ super(context, {
58
+ ...props,
59
+ type: ResourceGroup.resourceType,
60
+ apiVersion: ResourceGroup.apiVersion,
61
+ });
62
+ this._localDeploymentContext = {
63
+ // Resources inside this RG deploy at RG scope, so the canonical
64
+ // default is the Bicep runtime expression `resourceGroup().location`
65
+ // (i.e. the actual location of whichever RG hosts the deployment).
66
+ // This is correct whether the RG is authored locally or referenced
67
+ // as `existing`.
68
+ location: fn.resourceGroup().location,
69
+ tags: deref(this.tags),
70
+ };
71
+ }
72
+ /** The resource group's location as an expression. */
73
+ get location() {
74
+ return this.expr("location");
75
+ }
76
+ set location(value) {
77
+ this.setProperty("location", value);
78
+ }
79
+ get managedBy() {
80
+ return this.expr("managedBy");
81
+ }
82
+ set managedBy(value) {
83
+ this.setProperty("managedBy", value);
84
+ }
85
+ get tags() {
86
+ return this.state.tags === undefined
87
+ ? undefined
88
+ : this.expr("tags");
89
+ }
90
+ set tags(value) {
91
+ this.setProperty("tags", value);
92
+ }
93
+ add(ctor, ...args) {
94
+ return new ctor(this.self, ...args);
95
+ }
96
+ }
97
+ //# sourceMappingURL=resource-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-group.js","sourceRoot":"","sources":["../../../src/constructs/built-in-resources/resource-group.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAIN,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,wBAAwB,GAAwB;IACpD,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,eAAe,EAAE;QACf,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;KACd;IACD,KAAK,EAAE,cAAc;CACtB,CAAC;AASF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,aAAc,SAAQ,QAA8C;IAC/E,MAAM,CAAU,YAAY,GAAG,oCAA6C,CAAC;IAC7E,MAAM,CAAU,UAAU,GAAG,YAAY,CAAC;IAEhC,MAAM,CAAC,WAAW,GAAG,wBAAwB,CAAC;IAExD;QACE,IAAI,CAAC,aAAa,CAChB,oBAAoB,CAAC;YACnB,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE;YACvD,QAAQ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ClC,CAAC,CAAC,SAAS;YACX,CAAC,CAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAGf,CAAC;IACT,CAAC;IACD,IAAI,IAAI,CACN,KAEa;QAEb,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAMD,IAAO,EACP,GAAG,IAEM;QAET,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAoB,CAAC;IACzD,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { PrimitiveTypeMap, PrimitiveTypeName } from "../serialization/contract/index.js";
2
+ import type { ExpressionOrValue, InputOf } from "../expression/expressions.js";
3
+ import type { Resource } from "./resource/resource.js";
4
+ import type { Stack } from "./stack.js";
5
+ /**
6
+ * A value accepted as a deployment output's value: any JSON literal (scalar,
7
+ * `null`, array, object — recursively), an `Expression`, a resource view
8
+ * (`InputOf<unknown>`), or a {@link Resource} handle. The literal members are
9
+ * required so plain object/array literals are accepted (a bare
10
+ * `InputOf<unknown>` is a weak type and would reject them).
11
+ */
12
+ export type OutputValue = string | number | boolean | null | readonly OutputValue[] | {
13
+ readonly [key: string]: OutputValue;
14
+ } | InputOf<unknown> | Resource;
15
+ /** Primitive Bicep type names supported by deployment outputs. */
16
+ export type OutputType = PrimitiveTypeName;
17
+ export type ScalarOutputType = "string" | "int" | "bool";
18
+ export type OutputValueFor<T extends OutputType> = T extends ScalarOutputType ? ExpressionOrValue<PrimitiveTypeMap[T]> : OutputValue;
19
+ export type OutputOptions = {
20
+ readonly description?: string | undefined;
21
+ readonly secure?: boolean | undefined;
22
+ readonly minValue?: number | undefined;
23
+ readonly maxValue?: number | undefined;
24
+ readonly minLength?: number | undefined;
25
+ readonly maxLength?: number | undefined;
26
+ readonly metadata?: Record<string, unknown> | undefined;
27
+ readonly discriminator?: string | undefined;
28
+ readonly sealed?: boolean | undefined;
29
+ };
30
+ /**
31
+ * Pure declaration data for a deployment output. Stored on the stack and read
32
+ * by the serializer at emit time. An output is a terminal sink — it has no
33
+ * expression handle.
34
+ */
35
+ export interface OutputMetadata extends OutputOptions {
36
+ readonly name: string;
37
+ readonly type: OutputType;
38
+ readonly value: OutputValue;
39
+ }
40
+ /**
41
+ * Authoring-time collection of a stack's deployment outputs. Backed by an
42
+ * ordered private array; supports add/get/delete/iteration. Outputs are
43
+ * terminal sinks (no expression handle), so iteration yields metadata.
44
+ */
45
+ export declare class OutputCollection {
46
+ #private;
47
+ /** Add an output. Throws on duplicate name. Returns the stored metadata. */
48
+ add<T extends OutputType>(name: string, type: T, value: OutputValueFor<NoInfer<T>>, options?: OutputOptions): OutputMetadata;
49
+ /** The declaration metadata for an output, or `undefined`. */
50
+ get(name: string): OutputMetadata | undefined;
51
+ /** All output metadata, in insertion order. */
52
+ list(): readonly OutputMetadata[];
53
+ has(name: string): boolean;
54
+ /** Remove an output by name. Returns whether one was removed. */
55
+ delete(name: string): boolean;
56
+ get size(): number;
57
+ [Symbol.iterator](): IterableIterator<OutputMetadata>;
58
+ }
59
+ /**
60
+ * A deployment output, compiled to a Bicep `output` declaration.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * import { Stack } from "@azure/provisioning-core";
65
+ * import { KeyVault } from "@azure/provisioning-keyvault";
66
+ *
67
+ * const stack = new Stack("my-app", { targetScope: "resourceGroup" });
68
+ * const vault = new KeyVault(stack, {
69
+ * name: "kv-my-app",
70
+ * location: "eastus",
71
+ * properties: {
72
+ * tenantId: "11111111-1111-1111-1111-111111111111",
73
+ * sku: { family: "A", name: "standard" },
74
+ * },
75
+ * });
76
+ * stack.outputs.add("vaultUri", "string", vault.properties.vaultUri);
77
+ * ```
78
+ */
79
+ export declare function createOutput<T extends OutputType>(stack: Stack, name: string, type: T, value: OutputValueFor<NoInfer<T>>, options?: OutputOptions): OutputMetadata;
80
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../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EhB"}
@@ -0,0 +1,76 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { isResource } from "./resource/resource-utils.js";
4
+ import { assertBicepIdentifier, assertValueAssignableToType } from "../util.js";
5
+ /**
6
+ * Authoring-time collection of a stack's deployment outputs. Backed by an
7
+ * ordered private array; supports add/get/delete/iteration. Outputs are
8
+ * terminal sinks (no expression handle), so iteration yields metadata.
9
+ */
10
+ export class OutputCollection {
11
+ #entries = [];
12
+ /** Add an output. Throws on duplicate name. Returns the stored metadata. */
13
+ add(name, type, value, options) {
14
+ assertBicepIdentifier(name, "Deployment output");
15
+ if (this.has(name)) {
16
+ throw new Error(`Duplicate deployment output name: ${name}`);
17
+ }
18
+ if ((type === "string" || type === "int" || type === "bool") &&
19
+ isResource(value)) {
20
+ throw new Error(`Deployment output "${name}" expected type "${type}" but got resource.`);
21
+ }
22
+ assertValueAssignableToType(value, type, `Deployment output "${name}"`);
23
+ const metadata = { name, type, value, ...options };
24
+ this.#entries.push(metadata);
25
+ return metadata;
26
+ }
27
+ /** The declaration metadata for an output, or `undefined`. */
28
+ get(name) {
29
+ return this.#entries.find((e) => e.name === name);
30
+ }
31
+ /** All output metadata, in insertion order. */
32
+ list() {
33
+ return this.#entries;
34
+ }
35
+ has(name) {
36
+ return this.get(name) !== undefined;
37
+ }
38
+ /** Remove an output by name. Returns whether one was removed. */
39
+ delete(name) {
40
+ const i = this.#entries.findIndex((e) => e.name === name);
41
+ if (i === -1)
42
+ return false;
43
+ this.#entries.splice(i, 1);
44
+ return true;
45
+ }
46
+ get size() {
47
+ return this.#entries.length;
48
+ }
49
+ [Symbol.iterator]() {
50
+ return this.#entries[Symbol.iterator]();
51
+ }
52
+ }
53
+ /**
54
+ * A deployment output, compiled to a Bicep `output` declaration.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { Stack } from "@azure/provisioning-core";
59
+ * import { KeyVault } from "@azure/provisioning-keyvault";
60
+ *
61
+ * const stack = new Stack("my-app", { targetScope: "resourceGroup" });
62
+ * const vault = new KeyVault(stack, {
63
+ * name: "kv-my-app",
64
+ * location: "eastus",
65
+ * properties: {
66
+ * tenantId: "11111111-1111-1111-1111-111111111111",
67
+ * sku: { family: "A", name: "standard" },
68
+ * },
69
+ * });
70
+ * stack.outputs.add("vaultUri", "string", vault.properties.vaultUri);
71
+ * ```
72
+ */
73
+ export function createOutput(stack, name, type, value, options) {
74
+ return stack.outputs.add(name, type, value, options);
75
+ }
76
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/constructs/output.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAkDhF;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC3B,QAAQ,GAAqB,EAAE,CAAC;IAEhC,4EAA4E;IAC5E,GAAG,CACD,IAAY,EACZ,IAAO,EACP,KAAiC,EACjC,OAAuB;QAEvB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,IACE,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;YACxD,UAAU,CAAC,KAAK,CAAC,EACjB,CAAC;YACD,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,oBAAoB,IAAI,qBAAqB,CACxE,CAAC;QACJ,CAAC;QACD,2BAA2B,CAAC,KAAK,EAAE,IAAI,EAAE,sBAAsB,IAAI,GAAG,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAmB,EAAE,IAA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IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { PrimitiveTypeMap } from "../serialization/contract/index.js";
2
+ import type { Expression, ExpressionOrValue } from "../expression/expressions.js";
3
+ import type { Stack } from "./stack.js";
4
+ export type InferParamType<T extends keyof PrimitiveTypeMap, A> = A extends readonly (infer E)[] ? E : PrimitiveTypeMap[T];
5
+ /**
6
+ * A value accepted as a parameter's `defaultValue`: a literal of the declared
7
+ * type or an `Expression` of it. Resource views are intentionally excluded —
8
+ * a Bicep `param` default cannot reference resources.
9
+ */
10
+ export type ParameterValue<T extends keyof PrimitiveTypeMap = keyof PrimitiveTypeMap> = ExpressionOrValue<PrimitiveTypeMap[T]>;
11
+ export type ParameterOptions<T extends keyof PrimitiveTypeMap = keyof PrimitiveTypeMap, A extends readonly PrimitiveTypeMap[T][] | undefined = undefined> = {
12
+ readonly defaultValue?: ExpressionOrValue<InferParamType<T, A>> | undefined;
13
+ readonly description?: string | undefined;
14
+ readonly secure?: boolean | undefined;
15
+ readonly minValue?: number | undefined;
16
+ readonly maxValue?: number | undefined;
17
+ readonly minLength?: number | undefined;
18
+ readonly maxLength?: number | undefined;
19
+ readonly metadata?: Record<string, unknown> | undefined;
20
+ readonly allowed?: A;
21
+ readonly discriminator?: string | undefined;
22
+ readonly sealed?: boolean | undefined;
23
+ };
24
+ /**
25
+ * Pure declaration data for a deployment parameter. Stored on the stack
26
+ * (paired with the returned expression handle in {@link ParameterEntry});
27
+ * read by the serializer at emit time. Not part of the value-level handle.
28
+ */
29
+ export interface ParameterMetadata extends ParameterOptions<keyof PrimitiveTypeMap, readonly PrimitiveTypeMap[keyof PrimitiveTypeMap][] | undefined> {
30
+ readonly name: string;
31
+ readonly type: keyof PrimitiveTypeMap;
32
+ }
33
+ export type Parameter<T extends keyof PrimitiveTypeMap = keyof PrimitiveTypeMap, A extends readonly PrimitiveTypeMap[T][] | undefined = undefined> = Expression<InferParamType<T, A>>;
34
+ /**
35
+ * Authoring-time collection of a stack's deployment parameters. Backed by an
36
+ * ordered private array; supports add/get/delete/iteration. Look parameters up
37
+ * by name via {@link ParameterCollection.get}.
38
+ */
39
+ export declare class ParameterCollection {
40
+ #private;
41
+ /** Add a parameter; returns its expression handle. Throws on duplicate name. */
42
+ add<T extends keyof PrimitiveTypeMap = keyof PrimitiveTypeMap, const A extends readonly PrimitiveTypeMap[T][] | undefined = undefined>(name: string, type: T, options?: ParameterOptions<T, A>): Parameter<T, A>;
43
+ /** The expression handle for a parameter, or `undefined`. */
44
+ get(name: string): Parameter | undefined;
45
+ /** The declaration metadata for a parameter, or `undefined`. */
46
+ getMetadata(name: string): ParameterMetadata | undefined;
47
+ /** All parameter handles, in insertion order. */
48
+ list(): readonly Parameter[];
49
+ /** All declaration metadata, in insertion order. */
50
+ listMetadata(): readonly ParameterMetadata[];
51
+ has(name: string): boolean;
52
+ /** Remove a parameter by name. Returns whether one was removed. */
53
+ delete(name: string): boolean;
54
+ get size(): number;
55
+ [Symbol.iterator](): IterableIterator<Parameter>;
56
+ }
57
+ /**
58
+ * A deploy-time input to a stack, compiled to a Bicep `param` declaration.
59
+ *
60
+ * @remarks
61
+ * The returned value is an `Expression` that can be passed to resource
62
+ * properties. At deploy time, the user supplies the actual value. The
63
+ * declaration metadata is stored separately on the stack, keyed by name.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { Stack, createParameter } from "@azure/provisioning-core";
68
+ *
69
+ * const stack = new Stack("my-app", { targetScope: "resourceGroup" });
70
+ * const env = createParameter(stack, "env", "string", {
71
+ * allowed: ["dev", "staging", "prod"] as const,
72
+ * defaultValue: "dev",
73
+ * });
74
+ * ```
75
+ */
76
+ export declare function createParameter<T extends keyof PrimitiveTypeMap = keyof PrimitiveTypeMap, const A extends readonly PrimitiveTypeMap[T][] | undefined = undefined>(stack: Stack, name: string, type: T, options?: ParameterOptions<T, A>): Parameter<T, A>;
77
+ //# sourceMappingURL=parameter.d.ts.map
@@ -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AW,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIxD,iDAAiD;IACjD,IAAI,IAAI,SAAS,SAAS,EAAE;IAI5B,oDAAoD;IACpD,YAAY,IAAI,SAAS,iBAAiB,EAAE;IAI5C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,mEAAmE;IACnE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,SAAS,CAAC;CAOjD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS,MAAM,gBAAgB,GAAG,MAAM,gBAAgB,EACzD,KAAK,CAAC,CAAC,SAAS,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,SAAS,EAEtE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC/B,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAEjB"}
@@ -0,0 +1,93 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { wrapExpression } from "../expression/expressions.js";
4
+ import { isExpression } from "../expression/expressions.js";
5
+ import { symbolicValueExpressionNode } from "../expression/ast-nodes.js";
6
+ import { assertBicepIdentifier, assertValueAssignableToType } from "../util.js";
7
+ /**
8
+ * Authoring-time collection of a stack's deployment parameters. Backed by an
9
+ * ordered private array; supports add/get/delete/iteration. Look parameters up
10
+ * by name via {@link ParameterCollection.get}.
11
+ */
12
+ export class ParameterCollection {
13
+ #entries = [];
14
+ /** Add a parameter; returns its expression handle. Throws on duplicate name. */
15
+ add(name, type, options) {
16
+ assertBicepIdentifier(name, "Deployment parameter");
17
+ if (this.has(name)) {
18
+ throw new Error(`Duplicate deployment parameter name: ${name}`);
19
+ }
20
+ assertValueAssignableToType(options?.defaultValue, type, `Deployment parameter "${name}"`);
21
+ if (options?.defaultValue !== undefined &&
22
+ !isExpression(options.defaultValue) &&
23
+ options.allowed !== undefined &&
24
+ !options.allowed.includes(options.defaultValue)) {
25
+ throw new Error(`Deployment parameter "${name}" default value must be one of its allowed values.`);
26
+ }
27
+ const param = wrapExpression(symbolicValueExpressionNode(name));
28
+ this.#entries.push({
29
+ metadata: { name, type, ...options },
30
+ parameter: param,
31
+ });
32
+ return param;
33
+ }
34
+ /** The expression handle for a parameter, or `undefined`. */
35
+ get(name) {
36
+ return this.#find(name)?.parameter;
37
+ }
38
+ /** The declaration metadata for a parameter, or `undefined`. */
39
+ getMetadata(name) {
40
+ return this.#find(name)?.metadata;
41
+ }
42
+ /** All parameter handles, in insertion order. */
43
+ list() {
44
+ return this.#entries.map((e) => e.parameter);
45
+ }
46
+ /** All declaration metadata, in insertion order. */
47
+ listMetadata() {
48
+ return this.#entries.map((e) => e.metadata);
49
+ }
50
+ has(name) {
51
+ return this.#find(name) !== undefined;
52
+ }
53
+ /** Remove a parameter by name. Returns whether one was removed. */
54
+ delete(name) {
55
+ const i = this.#entries.findIndex((e) => e.metadata.name === name);
56
+ if (i === -1)
57
+ return false;
58
+ this.#entries.splice(i, 1);
59
+ return true;
60
+ }
61
+ get size() {
62
+ return this.#entries.length;
63
+ }
64
+ [Symbol.iterator]() {
65
+ return this.#entries.map((e) => e.parameter)[Symbol.iterator]();
66
+ }
67
+ #find(name) {
68
+ return this.#entries.find((e) => e.metadata.name === name);
69
+ }
70
+ }
71
+ /**
72
+ * A deploy-time input to a stack, compiled to a Bicep `param` declaration.
73
+ *
74
+ * @remarks
75
+ * The returned value is an `Expression` that can be passed to resource
76
+ * properties. At deploy time, the user supplies the actual value. The
77
+ * declaration metadata is stored separately on the stack, keyed by name.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * import { Stack, createParameter } from "@azure/provisioning-core";
82
+ *
83
+ * const stack = new Stack("my-app", { targetScope: "resourceGroup" });
84
+ * const env = createParameter(stack, "env", "string", {
85
+ * allowed: ["dev", "staging", "prod"] as const,
86
+ * defaultValue: "dev",
87
+ * });
88
+ * ```
89
+ */
90
+ export function createParameter(stack, name, type, options) {
91
+ return stack.parameters.add(name, type, options);
92
+ }
93
+ //# sourceMappingURL=parameter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/constructs/parameter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AA6DhF;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAC9B,QAAQ,GAAqB,EAAE,CAAC;IAEhC,gFAAgF;IAChF,GAAG,CAGD,IAAY,EAAE,IAAO,EAAE,OAAgC;QACvD,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;QACpD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,2BAA2B,CACzB,OAAO,EAAE,YAAY,EACrB,IAAI,EACJ,yBAAyB,IAAI,GAAG,CACjC,CAAC;QACF,IACE,OAAO,EAAE,YAAY,KAAK,SAAS;YACnC,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC;YACnC,OAAO,CAAC,OAAO,KAAK,SAAS;YAC7B,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAmC,CAAC,EACtE,CA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