@azure/provisioning-core 1.0.0-beta.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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/browser/constructs/built-in-resources/resource-group.d.ts +50 -0
- package/dist/browser/constructs/built-in-resources/resource-group.d.ts.map +1 -0
- package/dist/browser/constructs/built-in-resources/resource-group.js +100 -0
- package/dist/browser/constructs/built-in-resources/resource-group.js.map +1 -0
- package/dist/browser/constructs/output.d.ts +80 -0
- package/dist/browser/constructs/output.d.ts.map +1 -0
- package/dist/browser/constructs/output.js +75 -0
- package/dist/browser/constructs/output.js.map +1 -0
- package/dist/browser/constructs/parameter.d.ts +77 -0
- package/dist/browser/constructs/parameter.d.ts.map +1 -0
- package/dist/browser/constructs/parameter.js +93 -0
- package/dist/browser/constructs/parameter.js.map +1 -0
- package/dist/browser/constructs/provisioning-component.d.ts +91 -0
- package/dist/browser/constructs/provisioning-component.d.ts.map +1 -0
- package/dist/browser/constructs/provisioning-component.js +150 -0
- package/dist/browser/constructs/provisioning-component.js.map +1 -0
- package/dist/browser/constructs/resource/resource-proxy.d.ts +134 -0
- package/dist/browser/constructs/resource/resource-proxy.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource-proxy.js +517 -0
- package/dist/browser/constructs/resource/resource-proxy.js.map +1 -0
- package/dist/browser/constructs/resource/resource-query.d.ts +23 -0
- package/dist/browser/constructs/resource/resource-query.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource-query.js +69 -0
- package/dist/browser/constructs/resource/resource-query.js.map +1 -0
- package/dist/browser/constructs/resource/resource-registry.d.ts +99 -0
- package/dist/browser/constructs/resource/resource-registry.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource-registry.js +51 -0
- package/dist/browser/constructs/resource/resource-registry.js.map +1 -0
- package/dist/browser/constructs/resource/resource-type-registry.d.ts +46 -0
- package/dist/browser/constructs/resource/resource-type-registry.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource-type-registry.js +156 -0
- package/dist/browser/constructs/resource/resource-type-registry.js.map +1 -0
- package/dist/browser/constructs/resource/resource-utils.d.ts +60 -0
- package/dist/browser/constructs/resource/resource-utils.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource-utils.js +75 -0
- package/dist/browser/constructs/resource/resource-utils.js.map +1 -0
- package/dist/browser/constructs/resource/resource.d.ts +460 -0
- package/dist/browser/constructs/resource/resource.d.ts.map +1 -0
- package/dist/browser/constructs/resource/resource.js +582 -0
- package/dist/browser/constructs/resource/resource.js.map +1 -0
- package/dist/browser/constructs/stack.d.ts +110 -0
- package/dist/browser/constructs/stack.d.ts.map +1 -0
- package/dist/browser/constructs/stack.js +110 -0
- package/dist/browser/constructs/stack.js.map +1 -0
- package/dist/browser/constructs/variable.d.ts +63 -0
- package/dist/browser/constructs/variable.d.ts.map +1 -0
- package/dist/browser/constructs/variable.js +74 -0
- package/dist/browser/constructs/variable.js.map +1 -0
- package/dist/browser/deployment-context/deployment-context.d.ts +27 -0
- package/dist/browser/deployment-context/deployment-context.d.ts.map +1 -0
- package/dist/browser/deployment-context/deployment-context.js +4 -0
- package/dist/browser/deployment-context/deployment-context.js.map +1 -0
- package/dist/browser/expression/ast-nodes.d.ts +100 -0
- package/dist/browser/expression/ast-nodes.d.ts.map +1 -0
- package/dist/browser/expression/ast-nodes.js +125 -0
- package/dist/browser/expression/ast-nodes.js.map +1 -0
- package/dist/browser/expression/expressions.d.ts +164 -0
- package/dist/browser/expression/expressions.d.ts.map +1 -0
- package/dist/browser/expression/expressions.js +211 -0
- package/dist/browser/expression/expressions.js.map +1 -0
- package/dist/browser/fn.d.ts +194 -0
- package/dist/browser/fn.d.ts.map +1 -0
- package/dist/browser/fn.js +334 -0
- package/dist/browser/fn.js.map +1 -0
- package/dist/browser/index.d.ts +25 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +17 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/internal.d.ts +13 -0
- package/dist/browser/internal.d.ts.map +1 -0
- package/dist/browser/internal.js +10 -0
- package/dist/browser/internal.js.map +1 -0
- package/dist/browser/naming/naming-policy.d.ts +56 -0
- package/dist/browser/naming/naming-policy.d.ts.map +1 -0
- package/dist/browser/naming/naming-policy.js +97 -0
- package/dist/browser/naming/naming-policy.js.map +1 -0
- package/dist/browser/naming/naming-rules.d.ts +15 -0
- package/dist/browser/naming/naming-rules.d.ts.map +1 -0
- package/dist/browser/naming/naming-rules.js +15 -0
- package/dist/browser/naming/naming-rules.js.map +1 -0
- package/dist/browser/package.json +8 -0
- package/dist/browser/serialization/contract/generated/ast.d.ts +508 -0
- package/dist/browser/serialization/contract/generated/ast.d.ts.map +1 -0
- package/dist/browser/serialization/contract/generated/ast.js +23 -0
- package/dist/browser/serialization/contract/generated/ast.js.map +1 -0
- package/dist/browser/serialization/contract/index.d.ts +2 -0
- package/dist/browser/serialization/contract/index.d.ts.map +1 -0
- package/dist/browser/serialization/contract/index.js +4 -0
- package/dist/browser/serialization/contract/index.js.map +1 -0
- package/dist/browser/serialization/index.d.ts +4 -0
- package/dist/browser/serialization/index.d.ts.map +1 -0
- package/dist/browser/serialization/index.js +5 -0
- package/dist/browser/serialization/index.js.map +1 -0
- package/dist/browser/serialization/json/deserialize.d.ts +24 -0
- package/dist/browser/serialization/json/deserialize.d.ts.map +1 -0
- package/dist/browser/serialization/json/deserialize.js +437 -0
- package/dist/browser/serialization/json/deserialize.js.map +1 -0
- package/dist/browser/serialization/json/encoding.d.ts +4 -0
- package/dist/browser/serialization/json/encoding.d.ts.map +1 -0
- package/dist/browser/serialization/json/encoding.js +319 -0
- package/dist/browser/serialization/json/encoding.js.map +1 -0
- package/dist/browser/serialization/json/expression.d.ts +32 -0
- package/dist/browser/serialization/json/expression.d.ts.map +1 -0
- package/dist/browser/serialization/json/expression.js +494 -0
- package/dist/browser/serialization/json/expression.js.map +1 -0
- package/dist/browser/serialization/json/lower.d.ts +41 -0
- package/dist/browser/serialization/json/lower.d.ts.map +1 -0
- package/dist/browser/serialization/json/lower.js +334 -0
- package/dist/browser/serialization/json/lower.js.map +1 -0
- package/dist/browser/serialization/json/pluralize-config.d.ts +3 -0
- package/dist/browser/serialization/json/pluralize-config.d.ts.map +1 -0
- package/dist/browser/serialization/json/pluralize-config.js +7 -0
- package/dist/browser/serialization/json/pluralize-config.js.map +1 -0
- package/dist/browser/serialization/json/serialize.d.ts +12 -0
- package/dist/browser/serialization/json/serialize.d.ts.map +1 -0
- package/dist/browser/serialization/json/serialize.js +389 -0
- package/dist/browser/serialization/json/serialize.js.map +1 -0
- package/dist/browser/serialization/json/util.d.ts +2 -0
- package/dist/browser/serialization/json/util.d.ts.map +1 -0
- package/dist/browser/serialization/json/util.js +19 -0
- package/dist/browser/serialization/json/util.js.map +1 -0
- package/dist/browser/serialization/utils.d.ts +3 -0
- package/dist/browser/serialization/utils.d.ts.map +1 -0
- package/dist/browser/serialization/utils.js +146 -0
- package/dist/browser/serialization/utils.js.map +1 -0
- package/dist/browser/shape/shape-registry.d.ts +51 -0
- package/dist/browser/shape/shape-registry.d.ts.map +1 -0
- package/dist/browser/shape/shape-registry.js +41 -0
- package/dist/browser/shape/shape-registry.js.map +1 -0
- package/dist/browser/shape/shape.d.ts +407 -0
- package/dist/browser/shape/shape.d.ts.map +1 -0
- package/dist/browser/shape/shape.js +424 -0
- package/dist/browser/shape/shape.js.map +1 -0
- package/dist/browser/shape/value-encoding.d.ts +121 -0
- package/dist/browser/shape/value-encoding.d.ts.map +1 -0
- package/dist/browser/shape/value-encoding.js +32 -0
- package/dist/browser/shape/value-encoding.js.map +1 -0
- package/dist/browser/types.d.ts +9 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +4 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/browser/util.d.ts +33 -0
- package/dist/browser/util.d.ts.map +1 -0
- package/dist/browser/util.js +74 -0
- package/dist/browser/util.js.map +1 -0
- package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts +50 -0
- package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts.map +1 -0
- package/dist/commonjs/constructs/built-in-resources/resource-group.js +114 -0
- package/dist/commonjs/constructs/built-in-resources/resource-group.js.map +7 -0
- package/dist/commonjs/constructs/output.d.ts +80 -0
- package/dist/commonjs/constructs/output.d.ts.map +1 -0
- package/dist/commonjs/constructs/output.js +75 -0
- package/dist/commonjs/constructs/output.js.map +7 -0
- package/dist/commonjs/constructs/parameter.d.ts +77 -0
- package/dist/commonjs/constructs/parameter.d.ts.map +1 -0
- package/dist/commonjs/constructs/parameter.js +95 -0
- package/dist/commonjs/constructs/parameter.js.map +7 -0
- package/dist/commonjs/constructs/provisioning-component.d.ts +91 -0
- package/dist/commonjs/constructs/provisioning-component.d.ts.map +1 -0
- package/dist/commonjs/constructs/provisioning-component.js +130 -0
- package/dist/commonjs/constructs/provisioning-component.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource-proxy.d.ts +134 -0
- package/dist/commonjs/constructs/resource/resource-proxy.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource-proxy.js +456 -0
- package/dist/commonjs/constructs/resource/resource-proxy.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource-query.d.ts +23 -0
- package/dist/commonjs/constructs/resource/resource-query.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource-query.js +68 -0
- package/dist/commonjs/constructs/resource/resource-query.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource-registry.d.ts +99 -0
- package/dist/commonjs/constructs/resource/resource-registry.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource-registry.js +49 -0
- package/dist/commonjs/constructs/resource/resource-registry.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource-type-registry.d.ts +46 -0
- package/dist/commonjs/constructs/resource/resource-type-registry.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource-type-registry.js +178 -0
- package/dist/commonjs/constructs/resource/resource-type-registry.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource-utils.d.ts +60 -0
- package/dist/commonjs/constructs/resource/resource-utils.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource-utils.js +51 -0
- package/dist/commonjs/constructs/resource/resource-utils.js.map +7 -0
- package/dist/commonjs/constructs/resource/resource.d.ts +460 -0
- package/dist/commonjs/constructs/resource/resource.d.ts.map +1 -0
- package/dist/commonjs/constructs/resource/resource.js +455 -0
- package/dist/commonjs/constructs/resource/resource.js.map +7 -0
- package/dist/commonjs/constructs/stack.d.ts +110 -0
- package/dist/commonjs/constructs/stack.d.ts.map +1 -0
- package/dist/commonjs/constructs/stack.js +101 -0
- package/dist/commonjs/constructs/stack.js.map +7 -0
- package/dist/commonjs/constructs/variable.d.ts +63 -0
- package/dist/commonjs/constructs/variable.d.ts.map +1 -0
- package/dist/commonjs/constructs/variable.js +85 -0
- package/dist/commonjs/constructs/variable.js.map +7 -0
- package/dist/commonjs/deployment-context/deployment-context.d.ts +27 -0
- package/dist/commonjs/deployment-context/deployment-context.d.ts.map +1 -0
- package/dist/commonjs/deployment-context/deployment-context.js +16 -0
- package/dist/commonjs/deployment-context/deployment-context.js.map +7 -0
- package/dist/commonjs/expression/ast-nodes.d.ts +100 -0
- package/dist/commonjs/expression/ast-nodes.d.ts.map +1 -0
- package/dist/commonjs/expression/ast-nodes.js +152 -0
- package/dist/commonjs/expression/ast-nodes.js.map +7 -0
- package/dist/commonjs/expression/expressions.d.ts +164 -0
- package/dist/commonjs/expression/expressions.d.ts.map +1 -0
- package/dist/commonjs/expression/expressions.js +171 -0
- package/dist/commonjs/expression/expressions.js.map +7 -0
- package/dist/commonjs/fn.d.ts +194 -0
- package/dist/commonjs/fn.d.ts.map +1 -0
- package/dist/commonjs/fn.js +382 -0
- package/dist/commonjs/fn.js.map +7 -0
- package/dist/commonjs/index.d.ts +25 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +93 -0
- package/dist/commonjs/index.js.map +7 -0
- package/dist/commonjs/internal.d.ts +13 -0
- package/dist/commonjs/internal.d.ts.map +1 -0
- package/dist/commonjs/internal.js +88 -0
- package/dist/commonjs/internal.js.map +7 -0
- package/dist/commonjs/naming/naming-policy.d.ts +56 -0
- package/dist/commonjs/naming/naming-policy.d.ts.map +1 -0
- package/dist/commonjs/naming/naming-policy.js +99 -0
- package/dist/commonjs/naming/naming-policy.js.map +7 -0
- package/dist/commonjs/naming/naming-rules.d.ts +15 -0
- package/dist/commonjs/naming/naming-rules.d.ts.map +1 -0
- package/dist/commonjs/naming/naming-rules.js +39 -0
- package/dist/commonjs/naming/naming-rules.js.map +7 -0
- package/dist/commonjs/package.json +8 -0
- package/dist/commonjs/serialization/contract/generated/ast.d.ts +508 -0
- package/dist/commonjs/serialization/contract/generated/ast.d.ts.map +1 -0
- package/dist/commonjs/serialization/contract/generated/ast.js +40 -0
- package/dist/commonjs/serialization/contract/generated/ast.js.map +7 -0
- package/dist/commonjs/serialization/contract/index.d.ts +2 -0
- package/dist/commonjs/serialization/contract/index.d.ts.map +1 -0
- package/dist/commonjs/serialization/contract/index.js +22 -0
- package/dist/commonjs/serialization/contract/index.js.map +7 -0
- package/dist/commonjs/serialization/index.d.ts +4 -0
- package/dist/commonjs/serialization/index.d.ts.map +1 -0
- package/dist/commonjs/serialization/index.js +31 -0
- package/dist/commonjs/serialization/index.js.map +7 -0
- package/dist/commonjs/serialization/json/deserialize.d.ts +24 -0
- package/dist/commonjs/serialization/json/deserialize.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/deserialize.js +385 -0
- package/dist/commonjs/serialization/json/deserialize.js.map +7 -0
- package/dist/commonjs/serialization/json/encoding.d.ts +4 -0
- package/dist/commonjs/serialization/json/encoding.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/encoding.js +306 -0
- package/dist/commonjs/serialization/json/encoding.js.map +7 -0
- package/dist/commonjs/serialization/json/expression.d.ts +32 -0
- package/dist/commonjs/serialization/json/expression.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/expression.js +509 -0
- package/dist/commonjs/serialization/json/expression.js.map +7 -0
- package/dist/commonjs/serialization/json/lower.d.ts +41 -0
- package/dist/commonjs/serialization/json/lower.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/lower.js +272 -0
- package/dist/commonjs/serialization/json/lower.js.map +7 -0
- package/dist/commonjs/serialization/json/pluralize-config.d.ts +3 -0
- package/dist/commonjs/serialization/json/pluralize-config.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/pluralize-config.js +37 -0
- package/dist/commonjs/serialization/json/pluralize-config.js.map +7 -0
- package/dist/commonjs/serialization/json/serialize.d.ts +12 -0
- package/dist/commonjs/serialization/json/serialize.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/serialize.js +352 -0
- package/dist/commonjs/serialization/json/serialize.js.map +7 -0
- package/dist/commonjs/serialization/json/util.d.ts +2 -0
- package/dist/commonjs/serialization/json/util.d.ts.map +1 -0
- package/dist/commonjs/serialization/json/util.js +37 -0
- package/dist/commonjs/serialization/json/util.js.map +7 -0
- package/dist/commonjs/serialization/utils.d.ts +3 -0
- package/dist/commonjs/serialization/utils.d.ts.map +1 -0
- package/dist/commonjs/serialization/utils.js +169 -0
- package/dist/commonjs/serialization/utils.js.map +7 -0
- package/dist/commonjs/shape/shape-registry.d.ts +51 -0
- package/dist/commonjs/shape/shape-registry.d.ts.map +1 -0
- package/dist/commonjs/shape/shape-registry.js +40 -0
- package/dist/commonjs/shape/shape-registry.js.map +7 -0
- package/dist/commonjs/shape/shape.d.ts +407 -0
- package/dist/commonjs/shape/shape.d.ts.map +1 -0
- package/dist/commonjs/shape/shape.js +290 -0
- package/dist/commonjs/shape/shape.js.map +7 -0
- package/dist/commonjs/shape/value-encoding.d.ts +121 -0
- package/dist/commonjs/shape/value-encoding.d.ts.map +1 -0
- package/dist/commonjs/shape/value-encoding.js +62 -0
- package/dist/commonjs/shape/value-encoding.js.map +7 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/types.d.ts +9 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +16 -0
- package/dist/commonjs/types.js.map +7 -0
- package/dist/commonjs/util.d.ts +33 -0
- package/dist/commonjs/util.d.ts.map +1 -0
- package/dist/commonjs/util.js +73 -0
- package/dist/commonjs/util.js.map +7 -0
- package/dist/esm/constructs/built-in-resources/resource-group.d.ts +50 -0
- package/dist/esm/constructs/built-in-resources/resource-group.d.ts.map +1 -0
- package/dist/esm/constructs/built-in-resources/resource-group.js +100 -0
- package/dist/esm/constructs/built-in-resources/resource-group.js.map +1 -0
- package/dist/esm/constructs/output.d.ts +80 -0
- package/dist/esm/constructs/output.d.ts.map +1 -0
- package/dist/esm/constructs/output.js +75 -0
- package/dist/esm/constructs/output.js.map +1 -0
- package/dist/esm/constructs/parameter.d.ts +77 -0
- package/dist/esm/constructs/parameter.d.ts.map +1 -0
- package/dist/esm/constructs/parameter.js +93 -0
- package/dist/esm/constructs/parameter.js.map +1 -0
- package/dist/esm/constructs/provisioning-component.d.ts +91 -0
- package/dist/esm/constructs/provisioning-component.d.ts.map +1 -0
- package/dist/esm/constructs/provisioning-component.js +150 -0
- package/dist/esm/constructs/provisioning-component.js.map +1 -0
- package/dist/esm/constructs/resource/resource-proxy.d.ts +134 -0
- package/dist/esm/constructs/resource/resource-proxy.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource-proxy.js +517 -0
- package/dist/esm/constructs/resource/resource-proxy.js.map +1 -0
- package/dist/esm/constructs/resource/resource-query.d.ts +23 -0
- package/dist/esm/constructs/resource/resource-query.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource-query.js +69 -0
- package/dist/esm/constructs/resource/resource-query.js.map +1 -0
- package/dist/esm/constructs/resource/resource-registry.d.ts +99 -0
- package/dist/esm/constructs/resource/resource-registry.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource-registry.js +51 -0
- package/dist/esm/constructs/resource/resource-registry.js.map +1 -0
- package/dist/esm/constructs/resource/resource-type-registry.d.ts +46 -0
- package/dist/esm/constructs/resource/resource-type-registry.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource-type-registry.js +156 -0
- package/dist/esm/constructs/resource/resource-type-registry.js.map +1 -0
- package/dist/esm/constructs/resource/resource-utils.d.ts +60 -0
- package/dist/esm/constructs/resource/resource-utils.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource-utils.js +75 -0
- package/dist/esm/constructs/resource/resource-utils.js.map +1 -0
- package/dist/esm/constructs/resource/resource.d.ts +460 -0
- package/dist/esm/constructs/resource/resource.d.ts.map +1 -0
- package/dist/esm/constructs/resource/resource.js +582 -0
- package/dist/esm/constructs/resource/resource.js.map +1 -0
- package/dist/esm/constructs/stack.d.ts +110 -0
- package/dist/esm/constructs/stack.d.ts.map +1 -0
- package/dist/esm/constructs/stack.js +110 -0
- package/dist/esm/constructs/stack.js.map +1 -0
- package/dist/esm/constructs/variable.d.ts +63 -0
- package/dist/esm/constructs/variable.d.ts.map +1 -0
- package/dist/esm/constructs/variable.js +74 -0
- package/dist/esm/constructs/variable.js.map +1 -0
- package/dist/esm/deployment-context/deployment-context.d.ts +27 -0
- package/dist/esm/deployment-context/deployment-context.d.ts.map +1 -0
- package/dist/esm/deployment-context/deployment-context.js +4 -0
- package/dist/esm/deployment-context/deployment-context.js.map +1 -0
- package/dist/esm/expression/ast-nodes.d.ts +100 -0
- package/dist/esm/expression/ast-nodes.d.ts.map +1 -0
- package/dist/esm/expression/ast-nodes.js +125 -0
- package/dist/esm/expression/ast-nodes.js.map +1 -0
- package/dist/esm/expression/expressions.d.ts +164 -0
- package/dist/esm/expression/expressions.d.ts.map +1 -0
- package/dist/esm/expression/expressions.js +211 -0
- package/dist/esm/expression/expressions.js.map +1 -0
- package/dist/esm/fn.d.ts +194 -0
- package/dist/esm/fn.d.ts.map +1 -0
- package/dist/esm/fn.js +334 -0
- package/dist/esm/fn.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal.d.ts +13 -0
- package/dist/esm/internal.d.ts.map +1 -0
- package/dist/esm/internal.js +10 -0
- package/dist/esm/internal.js.map +1 -0
- package/dist/esm/naming/naming-policy.d.ts +56 -0
- package/dist/esm/naming/naming-policy.d.ts.map +1 -0
- package/dist/esm/naming/naming-policy.js +97 -0
- package/dist/esm/naming/naming-policy.js.map +1 -0
- package/dist/esm/naming/naming-rules.d.ts +15 -0
- package/dist/esm/naming/naming-rules.d.ts.map +1 -0
- package/dist/esm/naming/naming-rules.js +15 -0
- package/dist/esm/naming/naming-rules.js.map +1 -0
- package/dist/esm/package.json +8 -0
- package/dist/esm/serialization/contract/generated/ast.d.ts +508 -0
- package/dist/esm/serialization/contract/generated/ast.d.ts.map +1 -0
- package/dist/esm/serialization/contract/generated/ast.js +23 -0
- package/dist/esm/serialization/contract/generated/ast.js.map +1 -0
- package/dist/esm/serialization/contract/index.d.ts +2 -0
- package/dist/esm/serialization/contract/index.d.ts.map +1 -0
- package/dist/esm/serialization/contract/index.js +4 -0
- package/dist/esm/serialization/contract/index.js.map +1 -0
- package/dist/esm/serialization/index.d.ts +4 -0
- package/dist/esm/serialization/index.d.ts.map +1 -0
- package/dist/esm/serialization/index.js +5 -0
- package/dist/esm/serialization/index.js.map +1 -0
- package/dist/esm/serialization/json/deserialize.d.ts +24 -0
- package/dist/esm/serialization/json/deserialize.d.ts.map +1 -0
- package/dist/esm/serialization/json/deserialize.js +437 -0
- package/dist/esm/serialization/json/deserialize.js.map +1 -0
- package/dist/esm/serialization/json/encoding.d.ts +4 -0
- package/dist/esm/serialization/json/encoding.d.ts.map +1 -0
- package/dist/esm/serialization/json/encoding.js +319 -0
- package/dist/esm/serialization/json/encoding.js.map +1 -0
- package/dist/esm/serialization/json/expression.d.ts +32 -0
- package/dist/esm/serialization/json/expression.d.ts.map +1 -0
- package/dist/esm/serialization/json/expression.js +494 -0
- package/dist/esm/serialization/json/expression.js.map +1 -0
- package/dist/esm/serialization/json/lower.d.ts +41 -0
- package/dist/esm/serialization/json/lower.d.ts.map +1 -0
- package/dist/esm/serialization/json/lower.js +334 -0
- package/dist/esm/serialization/json/lower.js.map +1 -0
- package/dist/esm/serialization/json/pluralize-config.d.ts +3 -0
- package/dist/esm/serialization/json/pluralize-config.d.ts.map +1 -0
- package/dist/esm/serialization/json/pluralize-config.js +7 -0
- package/dist/esm/serialization/json/pluralize-config.js.map +1 -0
- package/dist/esm/serialization/json/serialize.d.ts +12 -0
- package/dist/esm/serialization/json/serialize.d.ts.map +1 -0
- package/dist/esm/serialization/json/serialize.js +389 -0
- package/dist/esm/serialization/json/serialize.js.map +1 -0
- package/dist/esm/serialization/json/util.d.ts +2 -0
- package/dist/esm/serialization/json/util.d.ts.map +1 -0
- package/dist/esm/serialization/json/util.js +19 -0
- package/dist/esm/serialization/json/util.js.map +1 -0
- package/dist/esm/serialization/utils.d.ts +3 -0
- package/dist/esm/serialization/utils.d.ts.map +1 -0
- package/dist/esm/serialization/utils.js +146 -0
- package/dist/esm/serialization/utils.js.map +1 -0
- package/dist/esm/shape/shape-registry.d.ts +51 -0
- package/dist/esm/shape/shape-registry.d.ts.map +1 -0
- package/dist/esm/shape/shape-registry.js +41 -0
- package/dist/esm/shape/shape-registry.js.map +1 -0
- package/dist/esm/shape/shape.d.ts +407 -0
- package/dist/esm/shape/shape.d.ts.map +1 -0
- package/dist/esm/shape/shape.js +424 -0
- package/dist/esm/shape/shape.js.map +1 -0
- package/dist/esm/shape/value-encoding.d.ts +121 -0
- package/dist/esm/shape/value-encoding.d.ts.map +1 -0
- package/dist/esm/shape/value-encoding.js +32 -0
- package/dist/esm/shape/value-encoding.js.map +1 -0
- package/dist/esm/types.d.ts +9 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +4 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/util.d.ts +33 -0
- package/dist/esm/util.d.ts.map +1 -0
- package/dist/esm/util.js +74 -0
- package/dist/esm/util.js.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var resource_proxy_exports = {};
|
|
19
|
+
__export(resource_proxy_exports, {
|
|
20
|
+
INDEXED_PROXY_TARGET: () => INDEXED_PROXY_TARGET,
|
|
21
|
+
LOOPED_RESOURCE_BRAND: () => LOOPED_RESOURCE_BRAND,
|
|
22
|
+
PROXY_INDEX_REF: () => PROXY_INDEX_REF,
|
|
23
|
+
RAW_RESOURCE_HANDLE: () => RAW_RESOURCE_HANDLE,
|
|
24
|
+
RESOURCE_BRAND: () => RESOURCE_BRAND,
|
|
25
|
+
RESOURCE_DECLARATION_BRAND: () => RESOURCE_DECLARATION_BRAND,
|
|
26
|
+
STATE_PARENT_INDEX: () => STATE_PARENT_INDEX,
|
|
27
|
+
createIndexedResourceProxy: () => createIndexedResourceProxy,
|
|
28
|
+
createResourceMemberProxy: () => createResourceMemberProxy,
|
|
29
|
+
createResourceProxy: () => createResourceProxy,
|
|
30
|
+
deref: () => deref,
|
|
31
|
+
normalizeAssignedValue: () => normalizeAssignedValue,
|
|
32
|
+
unwrapResourceHandle: () => unwrapResourceHandle
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(resource_proxy_exports);
|
|
35
|
+
var import_expressions = require("../../expression/expressions.js");
|
|
36
|
+
var import_ast_nodes = require("../../expression/ast-nodes.js");
|
|
37
|
+
var import_shape = require("../../shape/shape.js");
|
|
38
|
+
var import_shape_registry = require("../../shape/shape-registry.js");
|
|
39
|
+
const RAW_RESOURCE_HANDLE = /* @__PURE__ */ Symbol("raw-resource-handle");
|
|
40
|
+
const RESOURCE_BRAND = /* @__PURE__ */ Symbol.for("@azure/provisioning-core.Resource");
|
|
41
|
+
const LOOPED_RESOURCE_BRAND = /* @__PURE__ */ Symbol.for("@azure/provisioning-core.LoopedResource");
|
|
42
|
+
const RESOURCE_DECLARATION_BRAND = /* @__PURE__ */ Symbol.for(
|
|
43
|
+
"@azure/provisioning-core.ResourceDeclaration"
|
|
44
|
+
);
|
|
45
|
+
const PROXY_INDEX_REF = /* @__PURE__ */ Symbol.for("@azure/provisioning-core.PROXY_INDEX_REF");
|
|
46
|
+
const INDEXED_PROXY_TARGET = /* @__PURE__ */ Symbol.for("@azure/provisioning-core.INDEXED_PROXY_TARGET");
|
|
47
|
+
const STATE_PARENT_INDEX = "parentIndex";
|
|
48
|
+
function stepsToPath(steps) {
|
|
49
|
+
return steps.map((s) => s.segment);
|
|
50
|
+
}
|
|
51
|
+
const PROPERTY_PROXY_STATE = /* @__PURE__ */ Symbol("property-proxy-state");
|
|
52
|
+
function isPropertyProxy(value) {
|
|
53
|
+
return typeof value === "object" && value !== null && Reflect.get(value, PROPERTY_PROXY_STATE) !== void 0;
|
|
54
|
+
}
|
|
55
|
+
function getPropertyProxyState(value) {
|
|
56
|
+
return value[PROPERTY_PROXY_STATE];
|
|
57
|
+
}
|
|
58
|
+
function deref(value) {
|
|
59
|
+
if (isPropertyProxy(value)) {
|
|
60
|
+
const state = getPropertyProxyState(value);
|
|
61
|
+
return getValueAtPath(state.root, stepsToPath(state.steps));
|
|
62
|
+
}
|
|
63
|
+
if (isResourceHandle(value)) {
|
|
64
|
+
return unwrapResourceHandle(value);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
function isPlainObject(value) {
|
|
69
|
+
if (typeof value !== "object" || value === null) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const prototype = Object.getPrototypeOf(value);
|
|
73
|
+
return prototype === Object.prototype || prototype === null;
|
|
74
|
+
}
|
|
75
|
+
function getValueAtPath(root, path) {
|
|
76
|
+
let current = root;
|
|
77
|
+
for (const segment of path) {
|
|
78
|
+
if (typeof current !== "object" || current === null) {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
if (!Object.prototype.hasOwnProperty.call(current, String(segment))) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
current = current[String(segment)];
|
|
85
|
+
}
|
|
86
|
+
return current;
|
|
87
|
+
}
|
|
88
|
+
function setValueAtPath(root, path, value) {
|
|
89
|
+
let current = root;
|
|
90
|
+
for (let index = 0; index < path.length - 1; index += 1) {
|
|
91
|
+
const segment = String(path[index]);
|
|
92
|
+
const nextSegment = path[index + 1];
|
|
93
|
+
const existing = Object.prototype.hasOwnProperty.call(current, segment) ? current[segment] : void 0;
|
|
94
|
+
if (typeof existing === "object" && existing !== null) {
|
|
95
|
+
current = existing;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const container = typeof nextSegment === "number" ? [] : /* @__PURE__ */ Object.create(null);
|
|
99
|
+
Object.defineProperty(current, segment, {
|
|
100
|
+
value: container,
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true
|
|
104
|
+
});
|
|
105
|
+
current = container;
|
|
106
|
+
}
|
|
107
|
+
Object.defineProperty(current, String(path[path.length - 1]), {
|
|
108
|
+
value,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function createMemberAccessPathExpression(resource, steps, index) {
|
|
115
|
+
let current = (0, import_ast_nodes.identifierExpressionNode)(resource);
|
|
116
|
+
if (index !== void 0) {
|
|
117
|
+
current = (0, import_ast_nodes.arrayAccessExpressionNode)(current, index);
|
|
118
|
+
}
|
|
119
|
+
for (const { segment, armPath } of steps) {
|
|
120
|
+
current = (0, import_ast_nodes.accessExpressionNode)(current, segment, { armPath });
|
|
121
|
+
}
|
|
122
|
+
return current;
|
|
123
|
+
}
|
|
124
|
+
function normalizeAssignedValue(value, currentResource) {
|
|
125
|
+
if (isPropertyProxy(value)) {
|
|
126
|
+
const state = getPropertyProxyState(value);
|
|
127
|
+
if (currentResource && state.resource === currentResource) {
|
|
128
|
+
return getValueAtPath(state.root, stepsToPath(state.steps));
|
|
129
|
+
}
|
|
130
|
+
return createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
131
|
+
}
|
|
132
|
+
if (isResourceHandle(value)) {
|
|
133
|
+
return (0, import_ast_nodes.identifierExpressionNode)(value);
|
|
134
|
+
}
|
|
135
|
+
if ((0, import_expressions.isExpression)(value)) {
|
|
136
|
+
return (0, import_expressions.unwrapExpression)(value);
|
|
137
|
+
}
|
|
138
|
+
if ((0, import_ast_nodes.isExpressionNode)(value)) {
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
if (Array.isArray(value)) {
|
|
142
|
+
return value.map((item) => normalizeAssignedValue(item, currentResource));
|
|
143
|
+
}
|
|
144
|
+
if (isPlainObject(value)) {
|
|
145
|
+
return normalizeObjectValue(value, currentResource);
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
function normalizeObjectValue(obj, currentResource) {
|
|
150
|
+
const entries = Object.entries(obj);
|
|
151
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
152
|
+
for (const [key, value] of entries) {
|
|
153
|
+
if (isPropertyProxy(value)) {
|
|
154
|
+
const state = getPropertyProxyState(value);
|
|
155
|
+
if (currentResource && state.resource === currentResource) {
|
|
156
|
+
result[key] = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
result[key] = normalizeAssignedValue(value, currentResource);
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
function toPropertySegment(property, nav, currentValue) {
|
|
165
|
+
const isIndexedContainer = nav?.kind === "array" || nav?.kind === "tuple" || Array.isArray(currentValue);
|
|
166
|
+
return isIndexedContainer && /^\d+$/u.test(property) ? Number(property) : property;
|
|
167
|
+
}
|
|
168
|
+
function getPropertyProxyTarget(state) {
|
|
169
|
+
const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
170
|
+
if (typeof currentValue === "object" && currentValue !== null) {
|
|
171
|
+
return currentValue;
|
|
172
|
+
}
|
|
173
|
+
return {};
|
|
174
|
+
}
|
|
175
|
+
function createPropertyProxy(state) {
|
|
176
|
+
const target = {};
|
|
177
|
+
return new Proxy(target, {
|
|
178
|
+
has(proxyTarget, property) {
|
|
179
|
+
if (property === PROPERTY_PROXY_STATE || property === import_expressions.EXPRESSION_BRAND) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
const backing = getPropertyProxyTarget(state);
|
|
183
|
+
if (Reflect.has(backing, property)) return true;
|
|
184
|
+
return Reflect.has(proxyTarget, property);
|
|
185
|
+
},
|
|
186
|
+
ownKeys() {
|
|
187
|
+
const backing = getPropertyProxyTarget(state);
|
|
188
|
+
return Reflect.ownKeys(backing).filter((k) => typeof k === "string");
|
|
189
|
+
},
|
|
190
|
+
getOwnPropertyDescriptor(_proxyTarget, property) {
|
|
191
|
+
const backing = getPropertyProxyTarget(state);
|
|
192
|
+
if (typeof property === "string" && Object.prototype.hasOwnProperty.call(backing, property)) {
|
|
193
|
+
return { enumerable: true, configurable: true, writable: true };
|
|
194
|
+
}
|
|
195
|
+
return void 0;
|
|
196
|
+
},
|
|
197
|
+
get(proxyTarget, property, receiver) {
|
|
198
|
+
if (property === PROPERTY_PROXY_STATE) {
|
|
199
|
+
return state;
|
|
200
|
+
}
|
|
201
|
+
if (property === import_expressions.EXPRESSION_BRAND) {
|
|
202
|
+
return createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
203
|
+
}
|
|
204
|
+
if (property === Symbol.toPrimitive) {
|
|
205
|
+
return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(".")}]`;
|
|
206
|
+
}
|
|
207
|
+
if (typeof property !== "string") {
|
|
208
|
+
return Reflect.get(proxyTarget, property, receiver);
|
|
209
|
+
}
|
|
210
|
+
if (property === "toString") {
|
|
211
|
+
return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(".")}]`;
|
|
212
|
+
}
|
|
213
|
+
if (property === "valueOf") {
|
|
214
|
+
return () => createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
215
|
+
}
|
|
216
|
+
if (property === "then") {
|
|
217
|
+
return void 0;
|
|
218
|
+
}
|
|
219
|
+
const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
220
|
+
const segment = toPropertySegment(property, state.nav, currentValue);
|
|
221
|
+
const step = (0, import_shape.navigateShape)(state.nav, segment, currentValue);
|
|
222
|
+
const nextArmPath = step.stamp?.armPath;
|
|
223
|
+
const nextNav = step.next;
|
|
224
|
+
return createPropertyProxy({
|
|
225
|
+
...state,
|
|
226
|
+
steps: [...state.steps, { segment, armPath: nextArmPath }],
|
|
227
|
+
nav: nextNav
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
set(_proxyTarget, property, value) {
|
|
231
|
+
if (typeof property !== "string") {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (state.index !== void 0) {
|
|
235
|
+
throwLoopedElementWriteError();
|
|
236
|
+
}
|
|
237
|
+
setValueAtPath(
|
|
238
|
+
state.root,
|
|
239
|
+
[
|
|
240
|
+
...stepsToPath(state.steps),
|
|
241
|
+
toPropertySegment(
|
|
242
|
+
property,
|
|
243
|
+
state.nav,
|
|
244
|
+
getValueAtPath(state.root, stepsToPath(state.steps))
|
|
245
|
+
)
|
|
246
|
+
],
|
|
247
|
+
normalizeAssignedValue(value, state.resource)
|
|
248
|
+
);
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function isNonEnumerableOwnProperty(target, property) {
|
|
254
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
255
|
+
return descriptor?.enumerable === false;
|
|
256
|
+
}
|
|
257
|
+
function hasOwnOrPrototypeProperty(target, property) {
|
|
258
|
+
let current = target;
|
|
259
|
+
while (current !== null) {
|
|
260
|
+
if (Object.prototype.hasOwnProperty.call(current, property)) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
current = Object.getPrototypeOf(current);
|
|
264
|
+
}
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
function createResourceMemberProxy(source, path) {
|
|
268
|
+
const rootShape = getResourceShape(source.resource);
|
|
269
|
+
let nav = rootShape;
|
|
270
|
+
const steps = [];
|
|
271
|
+
for (const segment of path) {
|
|
272
|
+
const step = (0, import_shape.navigateShape)(nav, segment, getValueAtPath(source.root, stepsToPath(steps)));
|
|
273
|
+
steps.push({ segment, armPath: step.stamp?.armPath });
|
|
274
|
+
nav = step.next;
|
|
275
|
+
}
|
|
276
|
+
return createPropertyProxy({
|
|
277
|
+
...source,
|
|
278
|
+
steps,
|
|
279
|
+
nav
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function getResourceShape(resource) {
|
|
283
|
+
const state = resource[RAW_RESOURCE_HANDLE];
|
|
284
|
+
return (0, import_shape_registry.getShape)(resource.type, resource.apiVersion, state);
|
|
285
|
+
}
|
|
286
|
+
function createResourceProxy(resource) {
|
|
287
|
+
function getBackingResourceData(target) {
|
|
288
|
+
return Reflect.get(target, RAW_RESOURCE_HANDLE);
|
|
289
|
+
}
|
|
290
|
+
const proxy = new Proxy(resource, {
|
|
291
|
+
ownKeys(target) {
|
|
292
|
+
return Array.from(
|
|
293
|
+
/* @__PURE__ */ new Set([
|
|
294
|
+
...Reflect.ownKeys(target),
|
|
295
|
+
...Reflect.ownKeys(getBackingResourceData(target)).filter(
|
|
296
|
+
(key) => key !== RAW_RESOURCE_HANDLE
|
|
297
|
+
)
|
|
298
|
+
])
|
|
299
|
+
);
|
|
300
|
+
},
|
|
301
|
+
getOwnPropertyDescriptor(target, property) {
|
|
302
|
+
const targetDescriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
303
|
+
if (targetDescriptor !== void 0) {
|
|
304
|
+
return targetDescriptor;
|
|
305
|
+
}
|
|
306
|
+
const backing = getBackingResourceData(target);
|
|
307
|
+
if (Object.prototype.hasOwnProperty.call(backing, property)) {
|
|
308
|
+
return { enumerable: true, configurable: true, writable: true };
|
|
309
|
+
}
|
|
310
|
+
return void 0;
|
|
311
|
+
},
|
|
312
|
+
get(target, property, receiver) {
|
|
313
|
+
if (typeof property !== "string") {
|
|
314
|
+
return Reflect.get(target, property, receiver);
|
|
315
|
+
}
|
|
316
|
+
if (property === "then") {
|
|
317
|
+
return Reflect.get(target, property, receiver);
|
|
318
|
+
}
|
|
319
|
+
if (hasOwnOrPrototypeProperty(target, property) || isNonEnumerableOwnProperty(target, property)) {
|
|
320
|
+
return Reflect.get(target, property, receiver);
|
|
321
|
+
}
|
|
322
|
+
const rootState = unwrapResourceHandle(proxy);
|
|
323
|
+
const rootShape = getResourceShape(target);
|
|
324
|
+
const segment = toPropertySegment(property, rootShape, rootState);
|
|
325
|
+
const step = (0, import_shape.navigateShape)(rootShape, segment, rootState);
|
|
326
|
+
const armPath = step.stamp?.armPath;
|
|
327
|
+
const nav = step.next;
|
|
328
|
+
return createPropertyProxy({
|
|
329
|
+
resource: proxy,
|
|
330
|
+
root: rootState,
|
|
331
|
+
steps: [{ segment, armPath }],
|
|
332
|
+
nav
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
set(target, property, value, receiver) {
|
|
336
|
+
if (typeof property !== "string") {
|
|
337
|
+
return Reflect.set(target, property, value, receiver);
|
|
338
|
+
}
|
|
339
|
+
if (hasOwnOrPrototypeProperty(target, property) || isNonEnumerableOwnProperty(target, property)) {
|
|
340
|
+
return Reflect.set(target, property, value, receiver);
|
|
341
|
+
}
|
|
342
|
+
setValueAtPath(
|
|
343
|
+
unwrapResourceHandle(proxy),
|
|
344
|
+
[toPropertySegment(property, getResourceShape(target), unwrapResourceHandle(proxy))],
|
|
345
|
+
normalizeAssignedValue(value, proxy)
|
|
346
|
+
);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return proxy;
|
|
351
|
+
}
|
|
352
|
+
function isResourceHandle(value) {
|
|
353
|
+
return typeof value === "object" && value !== null && value[RESOURCE_BRAND] === true;
|
|
354
|
+
}
|
|
355
|
+
function unwrapResourceHandle(resource) {
|
|
356
|
+
const maybeRaw = Reflect.get(resource, RAW_RESOURCE_HANDLE);
|
|
357
|
+
if (maybeRaw === void 0) {
|
|
358
|
+
return resource;
|
|
359
|
+
}
|
|
360
|
+
return maybeRaw;
|
|
361
|
+
}
|
|
362
|
+
function throwLoopedElementWriteError() {
|
|
363
|
+
throw new Error(
|
|
364
|
+
"Cannot assign to a property of a looped resource declaration. Individual loop iterations cannot be mutated. Set the property in the declaration passed to `fromLoop(loop, ...)`"
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
function createIndexedResourceProxy(resource, index) {
|
|
368
|
+
const resourceIndexExpression = (0, import_expressions.isExpression)(index) ? (0, import_expressions.unwrapExpression)(index) : index;
|
|
369
|
+
const root = unwrapResourceHandle(resource);
|
|
370
|
+
const subclassProto = resource.wrappedCtor?.prototype;
|
|
371
|
+
return new Proxy(resource, {
|
|
372
|
+
// Deliberately NO `getPrototypeOf` trap. Exposing the subclass
|
|
373
|
+
// prototype here would make `proxy instanceof Subclass` report `true`,
|
|
374
|
+
// invoking subclass getters/methods against the bare `LoopedResource`
|
|
375
|
+
// target (which lacks the subclass's own instance slots). Property
|
|
376
|
+
// reads and writes don't need it: the `get`/`set` traps below have
|
|
377
|
+
// their own `subclassProto` fallbacks that run accessors with
|
|
378
|
+
// `this = receiver` (the proxy) so `this.expr(...)` resolves against the
|
|
379
|
+
// indexed element.
|
|
380
|
+
get(target, property, receiver) {
|
|
381
|
+
if (property === PROXY_INDEX_REF) return resourceIndexExpression;
|
|
382
|
+
if (property === INDEXED_PROXY_TARGET) return target;
|
|
383
|
+
if (property === "expr") {
|
|
384
|
+
return function boundIndexedExpr(...path) {
|
|
385
|
+
return createResourceMemberProxy(
|
|
386
|
+
{
|
|
387
|
+
resource: target,
|
|
388
|
+
root,
|
|
389
|
+
index: resourceIndexExpression
|
|
390
|
+
},
|
|
391
|
+
path
|
|
392
|
+
);
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
if (property === "setProperty") {
|
|
396
|
+
return throwLoopedElementWriteError;
|
|
397
|
+
}
|
|
398
|
+
if (property in target) {
|
|
399
|
+
const value = Reflect.get(target, property, target);
|
|
400
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
401
|
+
}
|
|
402
|
+
if (subclassProto !== void 0) {
|
|
403
|
+
let proto = subclassProto;
|
|
404
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
405
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
406
|
+
if (descriptor !== void 0) {
|
|
407
|
+
if (descriptor.get !== void 0) {
|
|
408
|
+
return descriptor.get.call(receiver);
|
|
409
|
+
}
|
|
410
|
+
const value = descriptor.value;
|
|
411
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
412
|
+
}
|
|
413
|
+
proto = Object.getPrototypeOf(proto);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return void 0;
|
|
417
|
+
},
|
|
418
|
+
// Route writes to an ARM property setter with `this = receiver` (the
|
|
419
|
+
// proxy), allowing its `setProperty` call to hit the rejection above.
|
|
420
|
+
// Falls back to a plain write on the raw target.
|
|
421
|
+
set(target, property, value, receiver) {
|
|
422
|
+
if (subclassProto !== void 0) {
|
|
423
|
+
let proto = subclassProto;
|
|
424
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
425
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
426
|
+
if (descriptor !== void 0) {
|
|
427
|
+
if (descriptor.set !== void 0) {
|
|
428
|
+
descriptor.set.call(receiver, value);
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
proto = Object.getPrototypeOf(proto);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return Reflect.set(target, property, value, target);
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
441
|
+
0 && (module.exports = {
|
|
442
|
+
INDEXED_PROXY_TARGET,
|
|
443
|
+
LOOPED_RESOURCE_BRAND,
|
|
444
|
+
PROXY_INDEX_REF,
|
|
445
|
+
RAW_RESOURCE_HANDLE,
|
|
446
|
+
RESOURCE_BRAND,
|
|
447
|
+
RESOURCE_DECLARATION_BRAND,
|
|
448
|
+
STATE_PARENT_INDEX,
|
|
449
|
+
createIndexedResourceProxy,
|
|
450
|
+
createResourceMemberProxy,
|
|
451
|
+
createResourceProxy,
|
|
452
|
+
deref,
|
|
453
|
+
normalizeAssignedValue,
|
|
454
|
+
unwrapResourceHandle
|
|
455
|
+
});
|
|
456
|
+
//# sourceMappingURL=resource-proxy.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/constructs/resource/resource-proxy.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n EXPRESSION_BRAND,\n isExpression,\n unwrapExpression,\n type Expression,\n type ExpressionOrValue,\n} from \"../../expression/expressions.js\";\nimport {\n accessExpressionNode,\n arrayAccessExpressionNode,\n identifierExpressionNode,\n isExpressionNode,\n type ArrayAccessIndex,\n type ExpressionNode,\n} from \"../../expression/ast-nodes.js\";\nimport type { PropertySegment } from \"../../types.js\";\nimport type { LoopedResource, Resource, ResourceDeclaration } from \"./resource.js\";\nimport { navigateShape, type FlatModelShape, type NavShape } from \"../../shape/shape.js\";\nimport { getShape } from \"../../shape/shape-registry.js\";\n\nexport const RAW_RESOURCE_HANDLE = Symbol(\"raw-resource-handle\");\nexport const RESOURCE_BRAND = Symbol.for(\"@azure/provisioning-core.Resource\");\n\n/**\n * Brand present on every `LoopedResource` instance. Lives here (rather than\n * on the `LoopedResource` class) so tree-walking utilities can brand-check\n * for looped declarations without a runtime import of `resource.ts` \u2014 which\n * would create an eval-time import cycle (`resource.ts` extends `ProvisioningComponent`).\n * Use {@link isLoopedResource} in normal code.\n */\nexport const LOOPED_RESOURCE_BRAND = Symbol.for(\"@azure/provisioning-core.LoopedResource\");\n\n/**\n * Brand present on every `ResourceDeclaration` instance (both scalar\n * `Resource` and looped `LoopedResource`). Use\n * {@link isResourceDeclaration} instead of a direct\n * brand check.\n */\nexport const RESOURCE_DECLARATION_BRAND = Symbol.for(\n \"@azure/provisioning-core.ResourceDeclaration\",\n);\n\n/**\n * Present on indexed resource proxies (see {@link createIndexedResourceProxy}).\n * Reading it off any resource-like value returns the stored index expression\n * for indexed proxies, and `undefined` for plain outer proxies. The base\n * `Resource` constructor probes for it on the `context` argument to detect\n * `parents.at(i)` / `parents.current()` being passed as a child parent\n * context; other consumers may probe it for their own purposes (the proxy\n * itself doesn't imply any parent-child relationship \u2014 the index is simply\n * what identifies which element of a looped declaration this proxy refers\n * to).\n */\nexport const PROXY_INDEX_REF = Symbol.for(\"@azure/provisioning-core.PROXY_INDEX_REF\");\n\n/**\n * Present on indexed resource proxies. Reading it returns the underlying\n * outer-proxy resource that the indexed proxy wraps. Used by the base\n * `Resource` constructor to normalize `this.parent` back to the raw parent\n * (so tree walks and symbol-map lookups continue to work) while\n * `PROXY_INDEX_REF` carries the \"which index\" information onto `state`.\n */\nexport const INDEXED_PROXY_TARGET = Symbol.for(\"@azure/provisioning-core.INDEXED_PROXY_TARGET\");\n\n/**\n * State-object key under which the base `Resource` constructor records the\n * index expression when the `context` argument is an indexed proxy (i.e.,\n * `parent.at(i)` / `parent.current()`). The serializer reads this key\n * from the child's raw state to emit `parent: parentSym[<index>]` instead\n * of the bare `parent: parentSym` form. Kept as a shared const so writer\n * (`resource.ts`) and reader (`serialize.ts`) never drift.\n *\n * Lives on the **child**, not the parent: siblings under the same parent\n * can be created via different indexed proxies (e.g. `new Child(p.at(0), \u2026)`\n * and `new Child(p.at(1), \u2026)` both resolve `.parent` to the same raw parent,\n * so the index that distinguishes them must be recorded per-child).\n */\nexport const STATE_PARENT_INDEX = \"parentIndex\" as const;\n\n// ---------------------------------------------------------------------------\n// Property proxy internal types\n// ---------------------------------------------------------------------------\n\n/**\n * A single step in a property proxy's walk from the root resource. Each step\n * carries the path segment (member name or array index) and the ARM\n * `PropertyShape` stamp's `armPath` for that step (if known). The parallel `path`/`stamps`\n * arrays this replaces could drift in length; a single array of steps makes\n * the invariant structural.\n */\ninterface PropertyStep {\n readonly segment: PropertySegment;\n readonly armPath?: readonly string[] | undefined;\n}\n\n/**\n * The identity a member-proxy needs to lower into a Bicep expression and to\n * back reads/writes. Bundles the three roles that were previously passed\n * positionally to {@link createResourceMemberProxy}:\n *\n * - `resource` \u2014 the tree-registered declaration that supplies BOTH the\n * symbol root (`identifierExpressionNode(resource)`) and the ARM shape\n * source (`getResourceShape`). For a scalar resource this is the outer\n * resource proxy; for an indexed looped element it is the raw\n * `LoopedResource` declaration (the tree citizen), NOT the ephemeral\n * `.at(i)` handle \u2014 that handle isn't in the component tree, so it can't\n * resolve to a Bicep symbol.\n * - `root` \u2014 the raw backing object that stores assigned values, used by\n * `deref(...)` and nested writes.\n * - `index` \u2014 optional array index. When set, the emitted expression roots\n * at `resource[index]` instead of `resource`, so `many.at(i).prop.blob`\n * serializes as `sym[i].prop.blob`. Populated for `.at(i)` / `.current()`\n * handles by {@link createIndexedResourceProxy}.\n */\nexport interface ResourceProxySource {\n readonly resource: Resource;\n readonly root: Record<string, unknown>;\n readonly index?: ArrayAccessIndex;\n}\n\ninterface PropertyProxyState extends ResourceProxySource {\n // The member/index path from the root resource to the current proxied value,\n // each entry paired with its wire `armPath` stamp (if known).\n readonly steps: readonly PropertyStep[];\n // Current ARM shape navigation state. `undefined` at any level means\n // \"untyped from here down\"; subsequent accesses are passthrough.\n readonly nav?: NavShape;\n}\n\nfunction stepsToPath(steps: readonly PropertyStep[]): readonly PropertySegment[] {\n return steps.map((s) => s.segment);\n}\n\nconst PROPERTY_PROXY_STATE = Symbol(\"property-proxy-state\");\n\nfunction isPropertyProxy(\n value: unknown,\n): value is { readonly [PROPERTY_PROXY_STATE]: PropertyProxyState } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Reflect.get(value as object, PROPERTY_PROXY_STATE) !== undefined\n );\n}\n\nfunction getPropertyProxyState(value: {\n readonly [PROPERTY_PROXY_STATE]: PropertyProxyState;\n}): PropertyProxyState {\n return value[PROPERTY_PROXY_STATE];\n}\n\n// ---------------------------------------------------------------------------\n// Deref\n// ---------------------------------------------------------------------------\n\nexport type Deref<T> = T extends Expression<infer U> ? U : T;\n\nexport function deref<T>(value: T): Deref<T> {\n if (isPropertyProxy(value)) {\n const state = getPropertyProxyState(value);\n return getValueAtPath(state.root, stepsToPath(state.steps)) as Deref<T>;\n }\n\n if (isResourceHandle(value)) {\n return unwrapResourceHandle(value) as Deref<T>;\n }\n\n return value as Deref<T>;\n}\n\n// ---------------------------------------------------------------------------\n// Path helpers\n// ---------------------------------------------------------------------------\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction getValueAtPath(root: Record<string, unknown>, path: readonly PropertySegment[]): unknown {\n let current: unknown = root;\n\n for (const segment of path) {\n if (typeof current !== \"object\" || current === null) {\n return undefined;\n }\n\n if (!Object.prototype.hasOwnProperty.call(current, String(segment))) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[String(segment)];\n }\n\n return current;\n}\n\nfunction setValueAtPath(\n root: Record<string, unknown>,\n path: readonly PropertySegment[],\n value: unknown,\n): void {\n let current: Record<string, unknown> = root;\n\n for (let index = 0; index < path.length - 1; index += 1) {\n const segment = String(path[index]);\n const nextSegment = path[index + 1];\n const existing = Object.prototype.hasOwnProperty.call(current, segment)\n ? current[segment]\n : undefined;\n\n if (typeof existing === \"object\" && existing !== null) {\n current = existing as Record<string, unknown>;\n continue;\n }\n\n const container = (typeof nextSegment === \"number\" ? [] : Object.create(null)) as Record<\n string,\n unknown\n >;\n Object.defineProperty(current, segment, {\n value: container,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n current = container;\n }\n\n Object.defineProperty(current, String(path[path.length - 1]), {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n}\n\n// ---------------------------------------------------------------------------\n// Expression construction\n// ---------------------------------------------------------------------------\n\nfunction createMemberAccessPathExpression(\n resource: Resource,\n steps: readonly PropertyStep[],\n index?: ArrayAccessIndex,\n): ExpressionNode {\n let current: ExpressionNode = identifierExpressionNode(resource);\n if (index !== undefined) {\n current = arrayAccessExpressionNode(current, index);\n }\n for (const { segment, armPath } of steps) {\n current = accessExpressionNode(current, segment, { armPath });\n }\n return current;\n}\n\n// ---------------------------------------------------------------------------\n// Value normalization\n// ---------------------------------------------------------------------------\n\nexport function normalizeAssignedValue(value: unknown, currentResource?: Resource): unknown {\n if (isPropertyProxy(value)) {\n const state = getPropertyProxyState(value);\n if (currentResource && state.resource === currentResource) {\n // Same-resource proxy \u2192 inline raw value (avoids self-references)\n return getValueAtPath(state.root, stepsToPath(state.steps));\n }\n return createMemberAccessPathExpression(state.resource, state.steps, state.index);\n }\n\n if (isResourceHandle(value)) {\n return identifierExpressionNode(value);\n }\n\n if (isExpression(value)) {\n return unwrapExpression(value);\n }\n\n if (isExpressionNode(value)) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => normalizeAssignedValue(item, currentResource));\n }\n\n if (isPlainObject(value)) {\n return normalizeObjectValue(value as Record<string, unknown>, currentResource);\n }\n\n return value;\n}\n\nfunction normalizeObjectValue(\n obj: Record<string, unknown>,\n currentResource?: Resource,\n): Record<string, unknown> {\n const entries = Object.entries(obj);\n const result: Record<string, unknown> = Object.create(null);\n\n for (const [key, value] of entries) {\n if (isPropertyProxy(value)) {\n const state = getPropertyProxyState(value);\n if (currentResource && state.resource === currentResource) {\n // Same-resource \u2192 inline raw value (avoids self-references)\n result[key] = getValueAtPath(state.root, stepsToPath(state.steps));\n continue;\n }\n }\n\n result[key] = normalizeAssignedValue(value, currentResource);\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Property proxy\n// ---------------------------------------------------------------------------\n\nfunction toPropertySegment(\n property: string,\n nav: NavShape,\n currentValue: unknown,\n): PropertySegment {\n const isIndexedContainer =\n nav?.kind === \"array\" || nav?.kind === \"tuple\" || Array.isArray(currentValue);\n return isIndexedContainer && /^\\d+$/u.test(property) ? Number(property) : property;\n}\n\nfunction getPropertyProxyTarget(state: PropertyProxyState): object {\n const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));\n\n if (typeof currentValue === \"object\" && currentValue !== null) {\n return currentValue;\n }\n\n return {};\n}\n\nfunction createPropertyProxy(state: PropertyProxyState): unknown {\n // Always use a fresh empty target \u2014 avoids Proxy invariant violations\n // when the stored value has non-configurable properties (e.g. EXPRESSION_BRAND).\n const target = {};\n\n return new Proxy(target, {\n has(proxyTarget, property) {\n if (property === PROPERTY_PROXY_STATE || property === EXPRESSION_BRAND) {\n return true;\n }\n\n const backing = getPropertyProxyTarget(state);\n if (Reflect.has(backing, property)) return true;\n return Reflect.has(proxyTarget, property);\n },\n\n ownKeys() {\n const backing = getPropertyProxyTarget(state);\n return Reflect.ownKeys(backing).filter((k): k is string => typeof k === \"string\");\n },\n\n getOwnPropertyDescriptor(_proxyTarget, property) {\n const backing = getPropertyProxyTarget(state);\n if (typeof property === \"string\" && Object.prototype.hasOwnProperty.call(backing, property)) {\n return { enumerable: true, configurable: true, writable: true };\n }\n return undefined;\n },\n\n get(proxyTarget, property, receiver) {\n if (property === PROPERTY_PROXY_STATE) {\n return state;\n }\n\n if (property === EXPRESSION_BRAND) {\n return createMemberAccessPathExpression(state.resource, state.steps, state.index);\n }\n\n if (property === Symbol.toPrimitive) {\n return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(\".\")}]`;\n }\n\n if (typeof property !== \"string\") {\n return Reflect.get(proxyTarget, property, receiver);\n }\n\n if (property === \"toString\") {\n return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(\".\")}]`;\n }\n\n if (property === \"valueOf\") {\n return () => createMemberAccessPathExpression(state.resource, state.steps, state.index);\n }\n\n if (property === \"then\") {\n return undefined;\n }\n\n const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));\n const segment = toPropertySegment(property, state.nav, currentValue);\n // Pass the value at the current position so a discriminated nav\n // can select its variant (see `resolveModelShape`).\n const step = navigateShape(state.nav, segment, currentValue);\n const nextArmPath = step.stamp?.armPath;\n const nextNav = step.next;\n\n return createPropertyProxy({\n ...state,\n steps: [...state.steps, { segment, armPath: nextArmPath }],\n nav: nextNav,\n });\n },\n\n set(_proxyTarget, property, value) {\n if (typeof property !== \"string\") {\n return false;\n }\n\n // A looped element (`parent.at(i)`) yields member proxies stamped with\n // an index. Writing through one would mutate the shared for-loop body,\n // which is not valid Bicep \u2014 `sym[i].prop = ...` cannot be expressed.\n if (state.index !== undefined) {\n throwLoopedElementWriteError();\n }\n\n setValueAtPath(\n state.root,\n [\n ...stepsToPath(state.steps),\n toPropertySegment(\n property,\n state.nav,\n getValueAtPath(state.root, stepsToPath(state.steps)),\n ),\n ],\n normalizeAssignedValue(value, state.resource),\n );\n\n return true;\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Resource member proxy\n// ---------------------------------------------------------------------------\n\nfunction isNonEnumerableOwnProperty(target: object, property: string): boolean {\n const descriptor = Reflect.getOwnPropertyDescriptor(target, property);\n return descriptor?.enumerable === false;\n}\n\nfunction hasOwnOrPrototypeProperty(target: object, property: string): boolean {\n let current: object | null = target;\n\n while (current !== null) {\n if (Object.prototype.hasOwnProperty.call(current, property)) {\n return true;\n }\n current = Object.getPrototypeOf(current);\n }\n\n return false;\n}\n\nexport function createResourceMemberProxy<TValue>(\n source: ResourceProxySource,\n path: readonly PropertySegment[],\n): Expression<TValue> & TValue {\n // Seed nav from the resource's shape (if any). Walk the existing\n // path, transitioning nav at each step so every segment is stamped\n // correctly. Pre-existing callers pass paths they built manually, so\n // we treat unknown navigations as passthrough.\n const rootShape = getResourceShape(source.resource);\n let nav: NavShape = rootShape;\n const steps: PropertyStep[] = [];\n for (const segment of path) {\n const step = navigateShape(nav, segment, getValueAtPath(source.root, stepsToPath(steps)));\n steps.push({ segment, armPath: step.stamp?.armPath });\n nav = step.next;\n }\n\n return createPropertyProxy({\n ...source,\n steps,\n nav,\n }) as Expression<TValue> & TValue;\n}\n\nfunction getResourceShape(resource: Resource): FlatModelShape | undefined {\n // Look up by (armType, apiVersion), letting the registry resolve\n // any discriminated variant from the instance's own state (typically\n // the hardcoded `name` literal each variant class sets).\n const state = (resource as unknown as { [RAW_RESOURCE_HANDLE]: Record<string, unknown> })[\n RAW_RESOURCE_HANDLE\n ];\n return getShape(resource.type, resource.apiVersion, state);\n}\n\n// ---------------------------------------------------------------------------\n// Resource-level proxy\n// ---------------------------------------------------------------------------\n\nexport function createResourceProxy<\n TType extends string,\n TResource extends Resource<TType> & object,\n>(resource: TResource): TResource {\n function getBackingResourceData(target: TResource): Record<string, unknown> {\n return Reflect.get(target, RAW_RESOURCE_HANDLE) as Record<string, unknown>;\n }\n\n const proxy = new Proxy(resource, {\n ownKeys(target) {\n return Array.from(\n new Set([\n ...Reflect.ownKeys(target),\n ...Reflect.ownKeys(getBackingResourceData(target)).filter(\n (key) => key !== RAW_RESOURCE_HANDLE,\n ),\n ]),\n );\n },\n\n getOwnPropertyDescriptor(target, property) {\n const targetDescriptor = Reflect.getOwnPropertyDescriptor(target, property);\n if (targetDescriptor !== undefined) {\n return targetDescriptor;\n }\n\n const backing = getBackingResourceData(target);\n if (Object.prototype.hasOwnProperty.call(backing, property)) {\n return { enumerable: true, configurable: true, writable: true };\n }\n\n return undefined;\n },\n\n get(target, property, receiver) {\n if (typeof property !== \"string\") {\n return Reflect.get(target, property, receiver);\n }\n\n if (property === \"then\") {\n return Reflect.get(target, property, receiver);\n }\n\n if (\n hasOwnOrPrototypeProperty(target, property) ||\n isNonEnumerableOwnProperty(target, property)\n ) {\n return Reflect.get(target, property, receiver);\n }\n\n const rootState = unwrapResourceHandle(proxy) as Record<string, unknown>;\n const rootShape = getResourceShape(target);\n const segment = toPropertySegment(property, rootShape, rootState);\n const step = navigateShape(rootShape, segment, rootState);\n const armPath = step.stamp?.armPath;\n const nav = step.next;\n\n return createPropertyProxy({\n resource: proxy,\n root: rootState,\n steps: [{ segment, armPath }],\n nav,\n });\n },\n\n set(target, property, value, receiver) {\n if (typeof property !== \"string\") {\n return Reflect.set(target, property, value, receiver);\n }\n\n if (\n hasOwnOrPrototypeProperty(target, property) ||\n isNonEnumerableOwnProperty(target, property)\n ) {\n return Reflect.set(target, property, value, receiver);\n }\n\n setValueAtPath(\n unwrapResourceHandle(proxy) as Record<string, unknown>,\n [toPropertySegment(property, getResourceShape(target), unwrapResourceHandle(proxy))],\n normalizeAssignedValue(value, proxy),\n );\n return true;\n },\n });\n\n return proxy;\n}\n\n// ---------------------------------------------------------------------------\n// Resource handle detection\n// ---------------------------------------------------------------------------\n\nfunction isResourceHandle(value: unknown): value is Resource {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<symbol, unknown>)[RESOURCE_BRAND] === true\n );\n}\n\nexport function unwrapResourceHandle<T extends ResourceDeclaration>(resource: T): T {\n const maybeRaw = Reflect.get(resource as object, RAW_RESOURCE_HANDLE);\n\n if (maybeRaw === undefined) {\n return resource;\n }\n\n return maybeRaw as T;\n}\n\n// ---------------------------------------------------------------------------\n// Indexed resource proxy \u2014 for `LoopedResource.at(i)` / `.current()`\n// ---------------------------------------------------------------------------\n\n/**\n * Returns a passthrough proxy over `resource` that carries an \"index\"\n * expression alongside the wrapped resource. Two purposes:\n *\n * 1. **Property reads** \u2014 ARM getters on the underlying `Resource` funnel\n * through `this.expr(...)`. The indexed proxy intercepts `expr` and\n * threads `resourceIndexExpression` into the member proxy so that reads\n * render as `sym[index].<path>` on the wire. Direct data-property reads\n * like `.type` / `.apiVersion` / `.condition` / `.existing` fall through\n * unchanged (they are authoring/type metadata, not ARM reads).\n *\n * 2. **Child parent context** \u2014 passing `parents.at(0)` as the first\n * argument to a child constructor must (a) let the child register into\n * the raw parent's tree, and (b) record the index so the serializer can\n * emit `parent: parentSym[i]`.\n * This proxy passes framework members (`children`, `deploymentContext`,\n * `_localDeploymentContext`, `hasDeploymentContext`, `.parent`, `.self`,\n * ...) through unchanged so the base `Resource` constructor's\n * interaction with `context` works exactly as it would with the raw\n * parent. `PROXY_INDEX_REF` and `INDEXED_PROXY_TARGET` expose the\n * index and the raw target to the base `Resource` constructor.\n *\n * The `index` can be a literal number, a literal string, or any expression\n * (typically a loop's `.index` symbolic value). It is unwrapped from any\n * `Expression<T>` proxy at construction time so downstream code stores a\n * primitive or an `ExpressionNode`, never an `Expression` proxy.\n *\n * **The indexed proxy is an ephemeral wrapper, not a tree node.** A fresh\n * proxy is minted per `.at(i)` call and is not stored in\n * any `parent.children` array; only the raw outer resource proxy\n * participates in the ProvisioningComponent tree. When a child is created with an\n * indexed proxy as `context`, `ProvisioningComponent`'s ctor writes\n * `this.parent = indexedProxy` briefly, but the base `Resource` ctor then overwrites\n * `this.parent` back to the raw parent (via `INDEXED_PROXY_TARGET`) so the\n * tree only ever references raw resource proxies. The indexed wrapper is\n * garbage-collectable once the child ctor returns; its sole job is to\n * carry the index through construction into `state.parentIndex`.\n */\n/**\n * Static type an indexed proxy exposes, derived from the declaration it\n * wraps. A `LoopedResource<T>` narrows to `T` \u2014 the concrete resource\n * type \u2014 so `parent.at(i)` exposes the full ARM and child-accessor\n * surface, resolved element-scoped at runtime. Any scalar {@link Resource}\n * yields itself.\n */\ntype IndexedProxyOf<D extends ResourceDeclaration> = D extends LoopedResource<infer T> ? T : D;\n\nfunction throwLoopedElementWriteError(): never {\n throw new Error(\n \"Cannot assign to a property of a looped resource declaration. Individual loop iterations cannot be mutated. Set the property in the declaration passed to `fromLoop(loop, ...)`\",\n );\n}\n\nexport function createIndexedResourceProxy<D extends ResourceDeclaration>(\n resource: D,\n index: ExpressionOrValue<number>,\n): IndexedProxyOf<D> {\n const resourceIndexExpression: ArrayAccessIndex = isExpression(index)\n ? unwrapExpression(index as Expression<number>)\n : index;\n const root = unwrapResourceHandle(resource) as unknown as Record<string, unknown>;\n\n // A looped declaration (`LoopedResource`) exposes the concrete subclass\n // ctor it wraps via `wrappedCtor`; its prototype carries the subclass's\n // ARM accessors (`.sku`, `.properties.*`, `.id`, `.name`). The `get` trap\n // below walks this prototype to resolve those reads rooted at\n // `sym[index]`. A scalar `Resource` has no `wrappedCtor` \u2014 it already\n // carries those accessors on its own prototype, so `subclassProto` stays\n // `undefined` and lookups resolve via the target's own chain.\n const subclassProto = (resource as { readonly wrappedCtor?: { readonly prototype: object } })\n .wrappedCtor?.prototype;\n\n return new Proxy(resource as object, {\n // Deliberately NO `getPrototypeOf` trap. Exposing the subclass\n // prototype here would make `proxy instanceof Subclass` report `true`,\n // invoking subclass getters/methods against the bare `LoopedResource`\n // target (which lacks the subclass's own instance slots). Property\n // reads and writes don't need it: the `get`/`set` traps below have\n // their own `subclassProto` fallbacks that run accessors with\n // `this = receiver` (the proxy) so `this.expr(...)` resolves against the\n // indexed element.\n get(target, property, receiver) {\n // Reveal-only symbols consulted by the base `Resource` constructor\n // and by serialization; both are marker keys with no runtime prototype\n // representation on plain resources.\n if (property === PROXY_INDEX_REF) return resourceIndexExpression;\n if (property === INDEXED_PROXY_TARGET) return target;\n\n // Intercept the single funnel for ARM reads. `this.expr(...path)` is\n // the getter body used by every generated ARM property (`.name`,\n // `.id`, `.properties.*`, etc.). Route it through\n // `createResourceMemberProxy` with our `resourceIndexExpression` so\n // the whole emitted expression roots at `sym[index]` instead of `sym`.\n if (property === \"expr\") {\n return function boundIndexedExpr(...path: readonly PropertySegment[]): unknown {\n return createResourceMemberProxy(\n {\n resource: target as Resource,\n root,\n index: resourceIndexExpression,\n },\n path,\n );\n };\n }\n\n // Block ARM property writes on a looped element. Every generated ARM\n // setter (`set sku`, `set properties`, `set name`, \u2026) funnels through\n // `this.setProperty(...)`, so intercepting that single method turns\n // `parent.at(i).sku = ...` into a clear error.\n if (property === \"setProperty\") {\n return throwLoopedElementWriteError;\n }\n\n // First try the target's own chain. Two subtleties:\n //\n // 1. Getters (`.type`, `.apiVersion`, `.children`, `.parent`, \u2026) must\n // run with `this = target` so they see the raw resource's own\n // properties \u2014 including class private fields (`#\u2026`). Passing the\n // proxy as `receiver` would cause private-field access inside a\n // getter to fail because the proxy has no such slot.\n // 2. Subclass methods need `this = target` for the same reason \u2014 private\n // fields again \u2014 so\n // we return a bound wrapper. This means `ctx.method === ctx.method`\n // yields `false` between reads; acceptable trade-off given no\n // caller relies on function identity on an indexed proxy.\n if (property in target) {\n const value = Reflect.get(target, property, target);\n return typeof value === \"function\" ? value.bind(target) : value;\n }\n\n // Fall through to `subclassProto` for subclass-specific getters\n // (e.g. `.id`, `.name`, `.sku`) when wrapping a `LoopedResource`.\n // Getters must run with `this = receiver` (the proxy) so their\n // `this.expr(...)` calls hit our intercept above, yielding an\n // expression rooted at `sym[index]`. Methods bind to `target` to\n // stay consistent with the passthrough branch above.\n if (subclassProto !== undefined) {\n let proto: object | null = subclassProto;\n while (proto !== null && proto !== Object.prototype) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, property);\n if (descriptor !== undefined) {\n if (descriptor.get !== undefined) {\n return descriptor.get.call(receiver);\n }\n const value = descriptor.value;\n return typeof value === \"function\" ? value.bind(target) : value;\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n\n return undefined;\n },\n\n // Route writes to an ARM property setter with `this = receiver` (the\n // proxy), allowing its `setProperty` call to hit the rejection above.\n // Falls back to a plain write on the raw target.\n set(target, property, value, receiver) {\n if (subclassProto !== undefined) {\n let proto: object | null = subclassProto;\n while (proto !== null && proto !== Object.prototype) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, property);\n if (descriptor !== undefined) {\n if (descriptor.set !== undefined) {\n descriptor.set.call(receiver, value);\n return true;\n }\n break;\n }\n proto = Object.getPrototypeOf(proto);\n }\n }\n return Reflect.set(target, property, value, target);\n },\n }) as IndexedProxyOf<D>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAMO;AACP,uBAOO;AAGP,mBAAkE;AAClE,4BAAyB;AAElB,MAAM,sBAAsB,uBAAO,qBAAqB;AACxD,MAAM,iBAAiB,uBAAO,IAAI,mCAAmC;AASrE,MAAM,wBAAwB,uBAAO,IAAI,yCAAyC;AAQlF,MAAM,6BAA6B,uBAAO;AAAA,EAC/C;AACF;AAaO,MAAM,kBAAkB,uBAAO,IAAI,0CAA0C;AAS7E,MAAM,uBAAuB,uBAAO,IAAI,+CAA+C;AAevF,MAAM,qBAAqB;AAoDlC,SAAS,YAAY,OAA4D;AAC/E,SAAO,MAAM,IAAI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,UAAU,OAAO,WAAW;AACnD,gBAAM,aAAa,OAAO,yBAAyB,OAAO,QAAQ;AAClE,cAAI,eAAe,QAAW;AAC5B,gBAAI,WAAW,QAAQ,QAAW;AAChC,yBAAW,IAAI,KAAK,UAAU,KAAK;AACnC,qBAAO;AAAA,YACT;AACA;AAAA,UACF;AACA,kBAAQ,OAAO,eAAe,KAAK;AAAA,QACrC;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,UAAU,OAAO,MAAM;AAAA,IACpD;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ProvisioningComponent } from "../provisioning-component.js";
|
|
2
|
+
import type { LoopedResource, Resource } from "./resource.js";
|
|
3
|
+
import type { ResourceCtor } from "./resource-registry.js";
|
|
4
|
+
/** Options accepted by the `Stack` resource queries. */
|
|
5
|
+
export interface QueryOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to walk the stack's entire subtree (default `true`) or only its
|
|
8
|
+
* **direct children** (`false`).
|
|
9
|
+
*/
|
|
10
|
+
readonly recursive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Scalar (un-looped) resource declarations. */
|
|
13
|
+
export declare function getResources(root: ProvisioningComponent, typeOrOptions?: ResourceCtor<Resource> | QueryOptions, maybeOptions?: QueryOptions): Resource[];
|
|
14
|
+
/** Loop-expanded resource declarations (`Ctor.fromLoop(...)`). */
|
|
15
|
+
export declare function getLoopedResources(root: ProvisioningComponent, typeOrOptions?: ResourceCtor<Resource> | QueryOptions, maybeOptions?: QueryOptions): LoopedResource<Resource>[];
|
|
16
|
+
/**
|
|
17
|
+
* First scalar resource of `type` whose literal name equals `name`, or
|
|
18
|
+
* `undefined`. `deref` resolves the name's expression proxy to its literal
|
|
19
|
+
* (a `Resource`'s `name` is an `Expression`, so `r.name === name` is always
|
|
20
|
+
* false without it).
|
|
21
|
+
*/
|
|
22
|
+
export declare function getResource<T extends Resource>(root: ProvisioningComponent, type: ResourceCtor<T>, name: string, options?: QueryOptions): T | undefined;
|
|
23
|
+
//# sourceMappingURL=resource-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-query.d.ts","sourceRoot":"","sources":["../../../../src/constructs/resource/resource-query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAsCD,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,EACrD,YAAY,CAAC,EAAE,YAAY,GAC1B,QAAQ,EAAE,CAOZ;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,EACrD,YAAY,CAAC,EAAE,YAAY,GAC1B,cAAc,CAAC,QAAQ,CAAC,EAAE,CAO5B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAC5C,IAAI,EAAE,qBAAqB,EAC3B,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,GACrB,CAAC,GAAG,SAAS,CAKf"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var resource_query_exports = {};
|
|
19
|
+
__export(resource_query_exports, {
|
|
20
|
+
getLoopedResources: () => getLoopedResources,
|
|
21
|
+
getResource: () => getResource,
|
|
22
|
+
getResources: () => getResources
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(resource_query_exports);
|
|
25
|
+
var import_resource_utils = require("./resource-utils.js");
|
|
26
|
+
var import_resource_proxy = require("./resource-proxy.js");
|
|
27
|
+
function collectResourcesUnder(root, wantLooped, recursive) {
|
|
28
|
+
const result = [];
|
|
29
|
+
const consider = (node) => {
|
|
30
|
+
if (!(0, import_resource_utils.isResourceDeclaration)(node)) return;
|
|
31
|
+
const r = node.self;
|
|
32
|
+
if ((0, import_resource_utils.isLoopedResource)(r) === wantLooped) result.push(r);
|
|
33
|
+
};
|
|
34
|
+
for (const child of root.children) {
|
|
35
|
+
if (recursive) child.visit(consider);
|
|
36
|
+
else consider(child);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function getResources(root, typeOrOptions, maybeOptions) {
|
|
41
|
+
const isCtor = typeof typeOrOptions === "function";
|
|
42
|
+
const type = isCtor ? typeOrOptions : void 0;
|
|
43
|
+
const options = isCtor ? maybeOptions : typeOrOptions;
|
|
44
|
+
const recursive = options?.recursive ?? true;
|
|
45
|
+
const found = collectResourcesUnder(root, false, recursive);
|
|
46
|
+
return type === void 0 ? found : found.filter((r) => r instanceof type);
|
|
47
|
+
}
|
|
48
|
+
function getLoopedResources(root, typeOrOptions, maybeOptions) {
|
|
49
|
+
const isCtor = typeof typeOrOptions === "function";
|
|
50
|
+
const type = isCtor ? typeOrOptions : void 0;
|
|
51
|
+
const options = isCtor ? maybeOptions : typeOrOptions;
|
|
52
|
+
const recursive = options?.recursive ?? true;
|
|
53
|
+
const found = collectResourcesUnder(root, true, recursive);
|
|
54
|
+
return type === void 0 ? found : found.filter((r) => (0, import_resource_utils.isLoopedResourceOf)(r, type));
|
|
55
|
+
}
|
|
56
|
+
function getResource(root, type, name, options) {
|
|
57
|
+
for (const r of getResources(root, type, options)) {
|
|
58
|
+
if ((0, import_resource_proxy.deref)(r.name) === name) return r;
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
getLoopedResources,
|
|
65
|
+
getResource,
|
|
66
|
+
getResources
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=resource-query.js.map
|