@azure/provisioning-core 1.0.0-beta.1 → 1.0.0-beta.2

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 (571) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +49 -10
  3. package/dist/browser/constructs/built-in-resources/resource-group.d.ts +7 -1
  4. package/dist/browser/constructs/built-in-resources/resource-group.d.ts.map +1 -1
  5. package/dist/browser/constructs/built-in-resources/resource-group.js +26 -6
  6. package/dist/browser/constructs/built-in-resources/resource-group.js.map +1 -1
  7. package/dist/browser/constructs/output.d.ts +1 -1
  8. package/dist/browser/constructs/output.d.ts.map +1 -1
  9. package/dist/browser/constructs/output.js.map +1 -1
  10. package/dist/browser/constructs/parameter.d.ts +1 -1
  11. package/dist/browser/constructs/parameter.d.ts.map +1 -1
  12. package/dist/browser/constructs/parameter.js.map +1 -1
  13. package/dist/browser/constructs/resource/resource-query.d.ts +3 -1
  14. package/dist/browser/constructs/resource/resource-query.d.ts.map +1 -1
  15. package/dist/browser/constructs/resource/resource-query.js +10 -0
  16. package/dist/browser/constructs/resource/resource-query.js.map +1 -1
  17. package/dist/browser/constructs/resource/resource-relationships.d.ts +9 -0
  18. package/dist/browser/constructs/resource/resource-relationships.d.ts.map +1 -0
  19. package/dist/browser/constructs/resource/resource-relationships.js +35 -0
  20. package/dist/browser/constructs/resource/resource-relationships.js.map +1 -0
  21. package/dist/browser/constructs/resource/resource.d.ts +11 -17
  22. package/dist/browser/constructs/resource/resource.d.ts.map +1 -1
  23. package/dist/browser/constructs/resource/resource.js +70 -28
  24. package/dist/browser/constructs/resource/resource.js.map +1 -1
  25. package/dist/browser/constructs/stack.d.ts +2 -16
  26. package/dist/browser/constructs/stack.d.ts.map +1 -1
  27. package/dist/browser/constructs/stack.js +1 -15
  28. package/dist/browser/constructs/stack.js.map +1 -1
  29. package/dist/browser/expression/ast-nodes.d.ts +1 -1
  30. package/dist/browser/expression/ast-nodes.d.ts.map +1 -1
  31. package/dist/browser/expression/ast-nodes.js.map +1 -1
  32. package/dist/browser/expression/expressions.d.ts +2 -9
  33. package/dist/browser/expression/expressions.d.ts.map +1 -1
  34. package/dist/browser/expression/expressions.js +2 -9
  35. package/dist/browser/expression/expressions.js.map +1 -1
  36. package/dist/browser/expression/utils.d.ts +5 -0
  37. package/dist/browser/expression/utils.d.ts.map +1 -0
  38. package/dist/browser/expression/utils.js +25 -0
  39. package/dist/browser/expression/utils.js.map +1 -0
  40. package/dist/browser/index.d.ts +4 -4
  41. package/dist/browser/index.d.ts.map +1 -1
  42. package/dist/browser/index.js.map +1 -1
  43. package/dist/browser/internal.d.ts +2 -5
  44. package/dist/browser/internal.d.ts.map +1 -1
  45. package/dist/browser/internal.js +1 -3
  46. package/dist/browser/internal.js.map +1 -1
  47. package/dist/browser/naming/name-validation.d.ts +15 -0
  48. package/dist/browser/naming/name-validation.d.ts.map +1 -0
  49. package/dist/browser/naming/name-validation.js +82 -0
  50. package/dist/browser/naming/name-validation.js.map +1 -0
  51. package/dist/browser/naming/naming-policy.d.ts +7 -7
  52. package/dist/browser/naming/naming-policy.d.ts.map +1 -1
  53. package/dist/browser/naming/naming-policy.js +166 -33
  54. package/dist/browser/naming/naming-policy.js.map +1 -1
  55. package/dist/browser/naming/naming-rules.d.ts +12 -11
  56. package/dist/browser/naming/naming-rules.d.ts.map +1 -1
  57. package/dist/browser/naming/naming-rules.js +2 -9
  58. package/dist/browser/naming/naming-rules.js.map +1 -1
  59. package/dist/browser/package.json +1 -1
  60. package/dist/{esm/serialization/json/lower.d.ts → browser/serialization/arm-object-conversion.d.ts} +11 -11
  61. package/dist/browser/serialization/arm-object-conversion.d.ts.map +1 -0
  62. package/dist/{esm/serialization/json/lower.js → browser/serialization/arm-object-conversion.js} +20 -20
  63. package/dist/browser/serialization/arm-object-conversion.js.map +1 -0
  64. package/dist/browser/serialization/ast/declaration-builder.d.ts +10 -0
  65. package/dist/browser/serialization/ast/declaration-builder.d.ts.map +1 -0
  66. package/dist/browser/serialization/ast/declaration-builder.js +265 -0
  67. package/dist/browser/serialization/ast/declaration-builder.js.map +1 -0
  68. package/dist/browser/serialization/ast/declaration-dependencies.d.ts +18 -0
  69. package/dist/browser/serialization/ast/declaration-dependencies.d.ts.map +1 -0
  70. package/dist/browser/serialization/ast/declaration-dependencies.js +96 -0
  71. package/dist/browser/serialization/ast/declaration-dependencies.js.map +1 -0
  72. package/dist/browser/serialization/ast/expression-builder.d.ts +14 -0
  73. package/dist/browser/serialization/ast/expression-builder.d.ts.map +1 -0
  74. package/dist/browser/serialization/ast/expression-builder.js +313 -0
  75. package/dist/browser/serialization/ast/expression-builder.js.map +1 -0
  76. package/dist/browser/serialization/ast/expression-restorer.d.ts +8 -0
  77. package/dist/browser/serialization/ast/expression-restorer.d.ts.map +1 -0
  78. package/dist/browser/serialization/ast/expression-restorer.js +162 -0
  79. package/dist/browser/serialization/ast/expression-restorer.js.map +1 -0
  80. package/dist/browser/serialization/ast/expression-rewriter.d.ts +29 -0
  81. package/dist/browser/serialization/ast/expression-rewriter.d.ts.map +1 -0
  82. package/dist/browser/serialization/ast/expression-rewriter.js +257 -0
  83. package/dist/browser/serialization/ast/expression-rewriter.js.map +1 -0
  84. package/dist/browser/serialization/ast/expression-walker.d.ts +16 -0
  85. package/dist/browser/serialization/ast/expression-walker.d.ts.map +1 -0
  86. package/dist/browser/serialization/ast/expression-walker.js +154 -0
  87. package/dist/browser/serialization/ast/expression-walker.js.map +1 -0
  88. package/dist/browser/serialization/ast/generated/ast.d.ts.map +1 -0
  89. package/dist/browser/serialization/ast/generated/ast.js.map +1 -0
  90. package/dist/browser/serialization/ast/index.d.ts +7 -0
  91. package/dist/browser/serialization/ast/index.d.ts.map +1 -0
  92. package/dist/browser/serialization/ast/index.js.map +1 -0
  93. package/dist/browser/serialization/ast/resource-utils.d.ts +10 -0
  94. package/dist/browser/serialization/ast/resource-utils.d.ts.map +1 -0
  95. package/dist/browser/serialization/ast/resource-utils.js +52 -0
  96. package/dist/browser/serialization/ast/resource-utils.js.map +1 -0
  97. package/dist/browser/serialization/bicep/file-layout/authored-context.d.ts +12 -0
  98. package/dist/browser/serialization/bicep/file-layout/authored-context.d.ts.map +1 -0
  99. package/dist/browser/serialization/bicep/file-layout/authored-context.js +57 -0
  100. package/dist/browser/serialization/bicep/file-layout/authored-context.js.map +1 -0
  101. package/dist/browser/serialization/bicep/file-layout/bicep-namer.d.ts +11 -0
  102. package/dist/browser/serialization/bicep/file-layout/bicep-namer.d.ts.map +1 -0
  103. package/dist/browser/serialization/bicep/file-layout/bicep-namer.js +100 -0
  104. package/dist/browser/serialization/bicep/file-layout/bicep-namer.js.map +1 -0
  105. package/dist/browser/serialization/bicep/file-layout/build-bicep-files.d.ts +7 -0
  106. package/dist/browser/serialization/bicep/file-layout/build-bicep-files.d.ts.map +1 -0
  107. package/dist/browser/serialization/bicep/file-layout/build-bicep-files.js +46 -0
  108. package/dist/browser/serialization/bicep/file-layout/build-bicep-files.js.map +1 -0
  109. package/dist/browser/serialization/bicep/file-layout/deployment-planning.d.ts +19 -0
  110. package/dist/browser/serialization/bicep/file-layout/deployment-planning.d.ts.map +1 -0
  111. package/dist/browser/serialization/bicep/file-layout/deployment-planning.js +68 -0
  112. package/dist/browser/serialization/bicep/file-layout/deployment-planning.js.map +1 -0
  113. package/dist/browser/serialization/bicep/file-layout/deployment-resource-utils.d.ts +8 -0
  114. package/dist/browser/serialization/bicep/file-layout/deployment-resource-utils.d.ts.map +1 -0
  115. package/dist/browser/serialization/bicep/file-layout/deployment-resource-utils.js +67 -0
  116. package/dist/browser/serialization/bicep/file-layout/deployment-resource-utils.js.map +1 -0
  117. package/dist/browser/serialization/bicep/file-layout/file-dependencies.d.ts +4 -0
  118. package/dist/browser/serialization/bicep/file-layout/file-dependencies.d.ts.map +1 -0
  119. package/dist/browser/serialization/bicep/file-layout/file-dependencies.js +32 -0
  120. package/dist/browser/serialization/bicep/file-layout/file-dependencies.js.map +1 -0
  121. package/dist/browser/serialization/bicep/file-layout/file-paths.d.ts +3 -0
  122. package/dist/browser/serialization/bicep/file-layout/file-paths.d.ts.map +1 -0
  123. package/dist/browser/serialization/bicep/file-layout/file-paths.js +46 -0
  124. package/dist/browser/serialization/bicep/file-layout/file-paths.js.map +1 -0
  125. package/dist/browser/serialization/bicep/file-layout/file-preparation.d.ts +34 -0
  126. package/dist/browser/serialization/bicep/file-layout/file-preparation.d.ts.map +1 -0
  127. package/dist/browser/serialization/bicep/file-layout/file-preparation.js +140 -0
  128. package/dist/browser/serialization/bicep/file-layout/file-preparation.js.map +1 -0
  129. package/dist/browser/serialization/bicep/file-layout/reference-wiring.d.ts +3 -0
  130. package/dist/browser/serialization/bicep/file-layout/reference-wiring.d.ts.map +1 -0
  131. package/dist/browser/serialization/bicep/file-layout/reference-wiring.js +225 -0
  132. package/dist/browser/serialization/bicep/file-layout/reference-wiring.js.map +1 -0
  133. package/dist/browser/serialization/bicep/index.d.ts +2 -0
  134. package/dist/browser/serialization/bicep/index.d.ts.map +1 -0
  135. package/dist/browser/serialization/bicep/index.js +4 -0
  136. package/dist/browser/serialization/bicep/index.js.map +1 -0
  137. package/dist/browser/serialization/bicep/render.d.ts +11 -0
  138. package/dist/browser/serialization/bicep/render.d.ts.map +1 -0
  139. package/dist/browser/serialization/bicep/render.js +293 -0
  140. package/dist/browser/serialization/bicep/render.js.map +1 -0
  141. package/dist/browser/serialization/{json/encoding.d.ts → encoding.d.ts} +1 -1
  142. package/dist/browser/serialization/encoding.d.ts.map +1 -0
  143. package/dist/browser/serialization/{json/encoding.js → encoding.js} +2 -12
  144. package/dist/browser/serialization/encoding.js.map +1 -0
  145. package/dist/browser/serialization/{json/util.d.ts → identifiers.d.ts} +1 -1
  146. package/dist/browser/serialization/identifiers.d.ts.map +1 -0
  147. package/dist/browser/serialization/{json/util.js → identifiers.js} +1 -1
  148. package/dist/browser/serialization/identifiers.js.map +1 -0
  149. package/dist/browser/serialization/index.d.ts +1 -1
  150. package/dist/browser/serialization/index.d.ts.map +1 -1
  151. package/dist/browser/serialization/index.js.map +1 -1
  152. package/dist/browser/serialization/json/deserialize.d.ts.map +1 -1
  153. package/dist/browser/serialization/json/deserialize.js +131 -39
  154. package/dist/browser/serialization/json/deserialize.js.map +1 -1
  155. package/dist/browser/serialization/json/serialize.d.ts +1 -1
  156. package/dist/browser/serialization/json/serialize.d.ts.map +1 -1
  157. package/dist/browser/serialization/json/serialize.js +5 -360
  158. package/dist/browser/serialization/json/serialize.js.map +1 -1
  159. package/dist/browser/serialization/pluralize-config.d.ts.map +1 -0
  160. package/dist/browser/serialization/pluralize-config.js.map +1 -0
  161. package/dist/browser/serialization/symbol-map.d.ts +10 -0
  162. package/dist/browser/serialization/symbol-map.d.ts.map +1 -0
  163. package/dist/browser/serialization/symbol-map.js +40 -0
  164. package/dist/browser/serialization/symbol-map.js.map +1 -0
  165. package/dist/browser/shape/shape.d.ts +4 -4
  166. package/dist/browser/shape/shape.js +2 -2
  167. package/dist/browser/shape/shape.js.map +1 -1
  168. package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts +7 -1
  169. package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts.map +1 -1
  170. package/dist/commonjs/constructs/built-in-resources/resource-group.js +27 -6
  171. package/dist/commonjs/constructs/built-in-resources/resource-group.js.map +2 -2
  172. package/dist/commonjs/constructs/output.d.ts +1 -1
  173. package/dist/commonjs/constructs/output.d.ts.map +1 -1
  174. package/dist/commonjs/constructs/output.js.map +1 -1
  175. package/dist/commonjs/constructs/parameter.d.ts +1 -1
  176. package/dist/commonjs/constructs/parameter.d.ts.map +1 -1
  177. package/dist/commonjs/constructs/parameter.js.map +1 -1
  178. package/dist/commonjs/constructs/resource/resource-query.d.ts +3 -1
  179. package/dist/commonjs/constructs/resource/resource-query.d.ts.map +1 -1
  180. package/dist/commonjs/constructs/resource/resource-query.js +11 -0
  181. package/dist/commonjs/constructs/resource/resource-query.js.map +2 -2
  182. package/dist/commonjs/constructs/resource/resource-relationships.d.ts +9 -0
  183. package/dist/commonjs/constructs/resource/resource-relationships.d.ts.map +1 -0
  184. package/dist/commonjs/constructs/resource/resource-relationships.js +59 -0
  185. package/dist/commonjs/constructs/resource/resource-relationships.js.map +7 -0
  186. package/dist/commonjs/constructs/resource/resource.d.ts +11 -17
  187. package/dist/commonjs/constructs/resource/resource.d.ts.map +1 -1
  188. package/dist/commonjs/constructs/resource/resource.js +57 -35
  189. package/dist/commonjs/constructs/resource/resource.js.map +2 -2
  190. package/dist/commonjs/constructs/stack.d.ts +2 -16
  191. package/dist/commonjs/constructs/stack.d.ts.map +1 -1
  192. package/dist/commonjs/constructs/stack.js.map +2 -2
  193. package/dist/commonjs/expression/ast-nodes.d.ts +1 -1
  194. package/dist/commonjs/expression/ast-nodes.d.ts.map +1 -1
  195. package/dist/commonjs/expression/ast-nodes.js.map +1 -1
  196. package/dist/commonjs/expression/expressions.d.ts +2 -9
  197. package/dist/commonjs/expression/expressions.d.ts.map +1 -1
  198. package/dist/commonjs/expression/expressions.js.map +2 -2
  199. package/dist/commonjs/expression/utils.d.ts +5 -0
  200. package/dist/commonjs/expression/utils.d.ts.map +1 -0
  201. package/dist/commonjs/expression/utils.js +43 -0
  202. package/dist/commonjs/expression/utils.js.map +7 -0
  203. package/dist/commonjs/index.d.ts +4 -4
  204. package/dist/commonjs/index.d.ts.map +1 -1
  205. package/dist/commonjs/index.js.map +2 -2
  206. package/dist/commonjs/internal.d.ts +2 -5
  207. package/dist/commonjs/internal.d.ts.map +1 -1
  208. package/dist/commonjs/internal.js +3 -9
  209. package/dist/commonjs/internal.js.map +2 -2
  210. package/dist/commonjs/naming/name-validation.d.ts +15 -0
  211. package/dist/commonjs/naming/name-validation.d.ts.map +1 -0
  212. package/dist/commonjs/naming/name-validation.js +74 -0
  213. package/dist/commonjs/naming/name-validation.js.map +7 -0
  214. package/dist/commonjs/naming/naming-policy.d.ts +7 -7
  215. package/dist/commonjs/naming/naming-policy.d.ts.map +1 -1
  216. package/dist/commonjs/naming/naming-policy.js +136 -26
  217. package/dist/commonjs/naming/naming-policy.js.map +2 -2
  218. package/dist/commonjs/naming/naming-rules.d.ts +12 -11
  219. package/dist/commonjs/naming/naming-rules.d.ts.map +1 -1
  220. package/dist/commonjs/naming/naming-rules.js +4 -11
  221. package/dist/commonjs/naming/naming-rules.js.map +2 -2
  222. package/dist/commonjs/package.json +1 -1
  223. package/dist/{browser/serialization/json/lower.d.ts → commonjs/serialization/arm-object-conversion.d.ts} +11 -11
  224. package/dist/commonjs/serialization/arm-object-conversion.d.ts.map +1 -0
  225. package/dist/commonjs/serialization/{json/lower.js → arm-object-conversion.js} +15 -15
  226. package/dist/commonjs/serialization/arm-object-conversion.js.map +7 -0
  227. package/dist/commonjs/serialization/ast/declaration-builder.d.ts +10 -0
  228. package/dist/commonjs/serialization/ast/declaration-builder.d.ts.map +1 -0
  229. package/dist/commonjs/serialization/ast/declaration-builder.js +274 -0
  230. package/dist/commonjs/serialization/ast/declaration-builder.js.map +7 -0
  231. package/dist/commonjs/serialization/ast/declaration-dependencies.d.ts +18 -0
  232. package/dist/commonjs/serialization/ast/declaration-dependencies.d.ts.map +1 -0
  233. package/dist/commonjs/serialization/ast/declaration-dependencies.js +109 -0
  234. package/dist/commonjs/serialization/ast/declaration-dependencies.js.map +7 -0
  235. package/dist/commonjs/serialization/ast/expression-builder.d.ts +14 -0
  236. package/dist/commonjs/serialization/ast/expression-builder.d.ts.map +1 -0
  237. package/dist/commonjs/serialization/ast/expression-builder.js +316 -0
  238. package/dist/commonjs/serialization/ast/expression-builder.js.map +7 -0
  239. package/dist/commonjs/serialization/ast/expression-restorer.d.ts +8 -0
  240. package/dist/commonjs/serialization/ast/expression-restorer.d.ts.map +1 -0
  241. package/dist/commonjs/serialization/ast/expression-restorer.js +193 -0
  242. package/dist/commonjs/serialization/ast/expression-restorer.js.map +7 -0
  243. package/dist/commonjs/serialization/ast/expression-rewriter.d.ts +29 -0
  244. package/dist/commonjs/serialization/ast/expression-rewriter.d.ts.map +1 -0
  245. package/dist/commonjs/serialization/ast/expression-rewriter.js +270 -0
  246. package/dist/commonjs/serialization/ast/expression-rewriter.js.map +7 -0
  247. package/dist/commonjs/serialization/ast/expression-walker.d.ts +16 -0
  248. package/dist/commonjs/serialization/ast/expression-walker.d.ts.map +1 -0
  249. package/dist/commonjs/serialization/ast/expression-walker.js +165 -0
  250. package/dist/commonjs/serialization/ast/expression-walker.js.map +7 -0
  251. package/dist/commonjs/serialization/ast/generated/ast.d.ts.map +1 -0
  252. package/dist/commonjs/serialization/{contract → ast}/generated/ast.js.map +1 -1
  253. package/dist/commonjs/serialization/ast/index.d.ts +7 -0
  254. package/dist/commonjs/serialization/ast/index.d.ts.map +1 -0
  255. package/dist/commonjs/serialization/{contract → ast}/index.js +3 -3
  256. package/dist/commonjs/serialization/ast/index.js.map +7 -0
  257. package/dist/commonjs/serialization/ast/resource-utils.d.ts +10 -0
  258. package/dist/commonjs/serialization/ast/resource-utils.d.ts.map +1 -0
  259. package/dist/commonjs/serialization/ast/resource-utils.js +71 -0
  260. package/dist/commonjs/serialization/ast/resource-utils.js.map +7 -0
  261. package/dist/commonjs/serialization/bicep/file-layout/authored-context.d.ts +12 -0
  262. package/dist/commonjs/serialization/bicep/file-layout/authored-context.d.ts.map +1 -0
  263. package/dist/commonjs/serialization/bicep/file-layout/authored-context.js +74 -0
  264. package/dist/commonjs/serialization/bicep/file-layout/authored-context.js.map +7 -0
  265. package/dist/commonjs/serialization/bicep/file-layout/bicep-namer.d.ts +11 -0
  266. package/dist/commonjs/serialization/bicep/file-layout/bicep-namer.d.ts.map +1 -0
  267. package/dist/commonjs/serialization/bicep/file-layout/bicep-namer.js +130 -0
  268. package/dist/commonjs/serialization/bicep/file-layout/bicep-namer.js.map +7 -0
  269. package/dist/commonjs/serialization/bicep/file-layout/build-bicep-files.d.ts +7 -0
  270. package/dist/commonjs/serialization/bicep/file-layout/build-bicep-files.d.ts.map +1 -0
  271. package/dist/commonjs/serialization/bicep/file-layout/build-bicep-files.js +71 -0
  272. package/dist/commonjs/serialization/bicep/file-layout/build-bicep-files.js.map +7 -0
  273. package/dist/commonjs/serialization/bicep/file-layout/deployment-planning.d.ts +19 -0
  274. package/dist/commonjs/serialization/bicep/file-layout/deployment-planning.d.ts.map +1 -0
  275. package/dist/commonjs/serialization/bicep/file-layout/deployment-planning.js +80 -0
  276. package/dist/commonjs/serialization/bicep/file-layout/deployment-planning.js.map +7 -0
  277. package/dist/commonjs/serialization/bicep/file-layout/deployment-resource-utils.d.ts +8 -0
  278. package/dist/commonjs/serialization/bicep/file-layout/deployment-resource-utils.d.ts.map +1 -0
  279. package/dist/commonjs/serialization/bicep/file-layout/deployment-resource-utils.js +91 -0
  280. package/dist/commonjs/serialization/bicep/file-layout/deployment-resource-utils.js.map +7 -0
  281. package/dist/commonjs/serialization/bicep/file-layout/file-dependencies.d.ts +4 -0
  282. package/dist/commonjs/serialization/bicep/file-layout/file-dependencies.d.ts.map +1 -0
  283. package/dist/commonjs/serialization/bicep/file-layout/file-dependencies.js +57 -0
  284. package/dist/commonjs/serialization/bicep/file-layout/file-dependencies.js.map +7 -0
  285. package/dist/commonjs/serialization/bicep/file-layout/file-paths.d.ts +3 -0
  286. package/dist/commonjs/serialization/bicep/file-layout/file-paths.d.ts.map +1 -0
  287. package/dist/commonjs/serialization/bicep/file-layout/file-paths.js +70 -0
  288. package/dist/commonjs/serialization/bicep/file-layout/file-paths.js.map +7 -0
  289. package/dist/commonjs/serialization/bicep/file-layout/file-preparation.d.ts +34 -0
  290. package/dist/commonjs/serialization/bicep/file-layout/file-preparation.d.ts.map +1 -0
  291. package/dist/commonjs/serialization/bicep/file-layout/file-preparation.js +190 -0
  292. package/dist/commonjs/serialization/bicep/file-layout/file-preparation.js.map +7 -0
  293. package/dist/commonjs/serialization/bicep/file-layout/reference-wiring.d.ts +3 -0
  294. package/dist/commonjs/serialization/bicep/file-layout/reference-wiring.d.ts.map +1 -0
  295. package/dist/commonjs/serialization/bicep/file-layout/reference-wiring.js +241 -0
  296. package/dist/commonjs/serialization/bicep/file-layout/reference-wiring.js.map +7 -0
  297. package/dist/commonjs/serialization/bicep/index.d.ts +2 -0
  298. package/dist/commonjs/serialization/bicep/index.d.ts.map +1 -0
  299. package/dist/commonjs/serialization/bicep/index.js +28 -0
  300. package/dist/commonjs/serialization/bicep/index.js.map +7 -0
  301. package/dist/commonjs/serialization/bicep/render.d.ts +11 -0
  302. package/dist/commonjs/serialization/bicep/render.d.ts.map +1 -0
  303. package/dist/commonjs/serialization/bicep/render.js +312 -0
  304. package/dist/commonjs/serialization/bicep/render.js.map +7 -0
  305. package/dist/commonjs/serialization/{json/encoding.d.ts → encoding.d.ts} +1 -1
  306. package/dist/commonjs/serialization/encoding.d.ts.map +1 -0
  307. package/dist/commonjs/serialization/{json/encoding.js → encoding.js} +2 -12
  308. package/dist/commonjs/serialization/encoding.js.map +7 -0
  309. package/dist/commonjs/serialization/{json/util.d.ts → identifiers.d.ts} +1 -1
  310. package/dist/commonjs/serialization/identifiers.d.ts.map +1 -0
  311. package/dist/commonjs/serialization/{json/util.js → identifiers.js} +4 -4
  312. package/dist/commonjs/serialization/{json/util.js.map → identifiers.js.map} +1 -1
  313. package/dist/commonjs/serialization/index.d.ts +1 -1
  314. package/dist/commonjs/serialization/index.d.ts.map +1 -1
  315. package/dist/commonjs/serialization/index.js.map +1 -1
  316. package/dist/commonjs/serialization/json/deserialize.d.ts.map +1 -1
  317. package/dist/commonjs/serialization/json/deserialize.js +115 -44
  318. package/dist/commonjs/serialization/json/deserialize.js.map +2 -2
  319. package/dist/commonjs/serialization/json/serialize.d.ts +1 -1
  320. package/dist/commonjs/serialization/json/serialize.d.ts.map +1 -1
  321. package/dist/commonjs/serialization/json/serialize.js +6 -308
  322. package/dist/commonjs/serialization/json/serialize.js.map +3 -3
  323. package/dist/commonjs/serialization/pluralize-config.d.ts.map +1 -0
  324. package/dist/commonjs/serialization/{json/pluralize-config.js.map → pluralize-config.js.map} +1 -1
  325. package/dist/commonjs/serialization/symbol-map.d.ts +10 -0
  326. package/dist/commonjs/serialization/symbol-map.d.ts.map +1 -0
  327. package/dist/commonjs/serialization/symbol-map.js +72 -0
  328. package/dist/commonjs/serialization/symbol-map.js.map +7 -0
  329. package/dist/commonjs/shape/shape.d.ts +4 -4
  330. package/dist/commonjs/shape/shape.js.map +1 -1
  331. package/dist/commonjs/tsdoc-metadata.json +1 -1
  332. package/dist/esm/constructs/built-in-resources/resource-group.d.ts +7 -1
  333. package/dist/esm/constructs/built-in-resources/resource-group.d.ts.map +1 -1
  334. package/dist/esm/constructs/built-in-resources/resource-group.js +26 -6
  335. package/dist/esm/constructs/built-in-resources/resource-group.js.map +1 -1
  336. package/dist/esm/constructs/output.d.ts +1 -1
  337. package/dist/esm/constructs/output.d.ts.map +1 -1
  338. package/dist/esm/constructs/output.js.map +1 -1
  339. package/dist/esm/constructs/parameter.d.ts +1 -1
  340. package/dist/esm/constructs/parameter.d.ts.map +1 -1
  341. package/dist/esm/constructs/parameter.js.map +1 -1
  342. package/dist/esm/constructs/resource/resource-query.d.ts +3 -1
  343. package/dist/esm/constructs/resource/resource-query.d.ts.map +1 -1
  344. package/dist/esm/constructs/resource/resource-query.js +10 -0
  345. package/dist/esm/constructs/resource/resource-query.js.map +1 -1
  346. package/dist/esm/constructs/resource/resource-relationships.d.ts +9 -0
  347. package/dist/esm/constructs/resource/resource-relationships.d.ts.map +1 -0
  348. package/dist/esm/constructs/resource/resource-relationships.js +35 -0
  349. package/dist/esm/constructs/resource/resource-relationships.js.map +1 -0
  350. package/dist/esm/constructs/resource/resource.d.ts +11 -17
  351. package/dist/esm/constructs/resource/resource.d.ts.map +1 -1
  352. package/dist/esm/constructs/resource/resource.js +70 -28
  353. package/dist/esm/constructs/resource/resource.js.map +1 -1
  354. package/dist/esm/constructs/stack.d.ts +2 -16
  355. package/dist/esm/constructs/stack.d.ts.map +1 -1
  356. package/dist/esm/constructs/stack.js +1 -15
  357. package/dist/esm/constructs/stack.js.map +1 -1
  358. package/dist/esm/expression/ast-nodes.d.ts +1 -1
  359. package/dist/esm/expression/ast-nodes.d.ts.map +1 -1
  360. package/dist/esm/expression/ast-nodes.js.map +1 -1
  361. package/dist/esm/expression/expressions.d.ts +2 -9
  362. package/dist/esm/expression/expressions.d.ts.map +1 -1
  363. package/dist/esm/expression/expressions.js +2 -9
  364. package/dist/esm/expression/expressions.js.map +1 -1
  365. package/dist/esm/expression/utils.d.ts +5 -0
  366. package/dist/esm/expression/utils.d.ts.map +1 -0
  367. package/dist/esm/expression/utils.js +25 -0
  368. package/dist/esm/expression/utils.js.map +1 -0
  369. package/dist/esm/index.d.ts +4 -4
  370. package/dist/esm/index.d.ts.map +1 -1
  371. package/dist/esm/index.js.map +1 -1
  372. package/dist/esm/internal.d.ts +2 -5
  373. package/dist/esm/internal.d.ts.map +1 -1
  374. package/dist/esm/internal.js +1 -3
  375. package/dist/esm/internal.js.map +1 -1
  376. package/dist/esm/naming/name-validation.d.ts +15 -0
  377. package/dist/esm/naming/name-validation.d.ts.map +1 -0
  378. package/dist/esm/naming/name-validation.js +82 -0
  379. package/dist/esm/naming/name-validation.js.map +1 -0
  380. package/dist/esm/naming/naming-policy.d.ts +7 -7
  381. package/dist/esm/naming/naming-policy.d.ts.map +1 -1
  382. package/dist/esm/naming/naming-policy.js +166 -33
  383. package/dist/esm/naming/naming-policy.js.map +1 -1
  384. package/dist/esm/naming/naming-rules.d.ts +12 -11
  385. package/dist/esm/naming/naming-rules.d.ts.map +1 -1
  386. package/dist/esm/naming/naming-rules.js +2 -9
  387. package/dist/esm/naming/naming-rules.js.map +1 -1
  388. package/dist/esm/package.json +1 -1
  389. package/dist/{commonjs/serialization/json/lower.d.ts → esm/serialization/arm-object-conversion.d.ts} +11 -11
  390. package/dist/esm/serialization/arm-object-conversion.d.ts.map +1 -0
  391. package/dist/{browser/serialization/json/lower.js → esm/serialization/arm-object-conversion.js} +20 -20
  392. package/dist/esm/serialization/arm-object-conversion.js.map +1 -0
  393. package/dist/esm/serialization/ast/declaration-builder.d.ts +10 -0
  394. package/dist/esm/serialization/ast/declaration-builder.d.ts.map +1 -0
  395. package/dist/esm/serialization/ast/declaration-builder.js +265 -0
  396. package/dist/esm/serialization/ast/declaration-builder.js.map +1 -0
  397. package/dist/esm/serialization/ast/declaration-dependencies.d.ts +18 -0
  398. package/dist/esm/serialization/ast/declaration-dependencies.d.ts.map +1 -0
  399. package/dist/esm/serialization/ast/declaration-dependencies.js +96 -0
  400. package/dist/esm/serialization/ast/declaration-dependencies.js.map +1 -0
  401. package/dist/esm/serialization/ast/expression-builder.d.ts +14 -0
  402. package/dist/esm/serialization/ast/expression-builder.d.ts.map +1 -0
  403. package/dist/esm/serialization/ast/expression-builder.js +313 -0
  404. package/dist/esm/serialization/ast/expression-builder.js.map +1 -0
  405. package/dist/esm/serialization/ast/expression-restorer.d.ts +8 -0
  406. package/dist/esm/serialization/ast/expression-restorer.d.ts.map +1 -0
  407. package/dist/esm/serialization/ast/expression-restorer.js +162 -0
  408. package/dist/esm/serialization/ast/expression-restorer.js.map +1 -0
  409. package/dist/esm/serialization/ast/expression-rewriter.d.ts +29 -0
  410. package/dist/esm/serialization/ast/expression-rewriter.d.ts.map +1 -0
  411. package/dist/esm/serialization/ast/expression-rewriter.js +257 -0
  412. package/dist/esm/serialization/ast/expression-rewriter.js.map +1 -0
  413. package/dist/esm/serialization/ast/expression-walker.d.ts +16 -0
  414. package/dist/esm/serialization/ast/expression-walker.d.ts.map +1 -0
  415. package/dist/esm/serialization/ast/expression-walker.js +154 -0
  416. package/dist/esm/serialization/ast/expression-walker.js.map +1 -0
  417. package/dist/esm/serialization/ast/generated/ast.d.ts.map +1 -0
  418. package/dist/esm/serialization/ast/generated/ast.js.map +1 -0
  419. package/dist/esm/serialization/ast/index.d.ts +7 -0
  420. package/dist/esm/serialization/ast/index.d.ts.map +1 -0
  421. package/dist/esm/serialization/ast/index.js.map +1 -0
  422. package/dist/esm/serialization/ast/resource-utils.d.ts +10 -0
  423. package/dist/esm/serialization/ast/resource-utils.d.ts.map +1 -0
  424. package/dist/esm/serialization/ast/resource-utils.js +52 -0
  425. package/dist/esm/serialization/ast/resource-utils.js.map +1 -0
  426. package/dist/esm/serialization/bicep/file-layout/authored-context.d.ts +12 -0
  427. package/dist/esm/serialization/bicep/file-layout/authored-context.d.ts.map +1 -0
  428. package/dist/esm/serialization/bicep/file-layout/authored-context.js +57 -0
  429. package/dist/esm/serialization/bicep/file-layout/authored-context.js.map +1 -0
  430. package/dist/esm/serialization/bicep/file-layout/bicep-namer.d.ts +11 -0
  431. package/dist/esm/serialization/bicep/file-layout/bicep-namer.d.ts.map +1 -0
  432. package/dist/esm/serialization/bicep/file-layout/bicep-namer.js +100 -0
  433. package/dist/esm/serialization/bicep/file-layout/bicep-namer.js.map +1 -0
  434. package/dist/esm/serialization/bicep/file-layout/build-bicep-files.d.ts +7 -0
  435. package/dist/esm/serialization/bicep/file-layout/build-bicep-files.d.ts.map +1 -0
  436. package/dist/esm/serialization/bicep/file-layout/build-bicep-files.js +46 -0
  437. package/dist/esm/serialization/bicep/file-layout/build-bicep-files.js.map +1 -0
  438. package/dist/esm/serialization/bicep/file-layout/deployment-planning.d.ts +19 -0
  439. package/dist/esm/serialization/bicep/file-layout/deployment-planning.d.ts.map +1 -0
  440. package/dist/esm/serialization/bicep/file-layout/deployment-planning.js +68 -0
  441. package/dist/esm/serialization/bicep/file-layout/deployment-planning.js.map +1 -0
  442. package/dist/esm/serialization/bicep/file-layout/deployment-resource-utils.d.ts +8 -0
  443. package/dist/esm/serialization/bicep/file-layout/deployment-resource-utils.d.ts.map +1 -0
  444. package/dist/esm/serialization/bicep/file-layout/deployment-resource-utils.js +67 -0
  445. package/dist/esm/serialization/bicep/file-layout/deployment-resource-utils.js.map +1 -0
  446. package/dist/esm/serialization/bicep/file-layout/file-dependencies.d.ts +4 -0
  447. package/dist/esm/serialization/bicep/file-layout/file-dependencies.d.ts.map +1 -0
  448. package/dist/esm/serialization/bicep/file-layout/file-dependencies.js +32 -0
  449. package/dist/esm/serialization/bicep/file-layout/file-dependencies.js.map +1 -0
  450. package/dist/esm/serialization/bicep/file-layout/file-paths.d.ts +3 -0
  451. package/dist/esm/serialization/bicep/file-layout/file-paths.d.ts.map +1 -0
  452. package/dist/esm/serialization/bicep/file-layout/file-paths.js +46 -0
  453. package/dist/esm/serialization/bicep/file-layout/file-paths.js.map +1 -0
  454. package/dist/esm/serialization/bicep/file-layout/file-preparation.d.ts +34 -0
  455. package/dist/esm/serialization/bicep/file-layout/file-preparation.d.ts.map +1 -0
  456. package/dist/esm/serialization/bicep/file-layout/file-preparation.js +140 -0
  457. package/dist/esm/serialization/bicep/file-layout/file-preparation.js.map +1 -0
  458. package/dist/esm/serialization/bicep/file-layout/reference-wiring.d.ts +3 -0
  459. package/dist/esm/serialization/bicep/file-layout/reference-wiring.d.ts.map +1 -0
  460. package/dist/esm/serialization/bicep/file-layout/reference-wiring.js +225 -0
  461. package/dist/esm/serialization/bicep/file-layout/reference-wiring.js.map +1 -0
  462. package/dist/esm/serialization/bicep/index.d.ts +2 -0
  463. package/dist/esm/serialization/bicep/index.d.ts.map +1 -0
  464. package/dist/esm/serialization/bicep/index.js +4 -0
  465. package/dist/esm/serialization/bicep/index.js.map +1 -0
  466. package/dist/esm/serialization/bicep/render.d.ts +11 -0
  467. package/dist/esm/serialization/bicep/render.d.ts.map +1 -0
  468. package/dist/esm/serialization/bicep/render.js +293 -0
  469. package/dist/esm/serialization/bicep/render.js.map +1 -0
  470. package/dist/esm/serialization/{json/encoding.d.ts → encoding.d.ts} +1 -1
  471. package/dist/esm/serialization/encoding.d.ts.map +1 -0
  472. package/dist/esm/serialization/{json/encoding.js → encoding.js} +2 -12
  473. package/dist/esm/serialization/encoding.js.map +1 -0
  474. package/dist/esm/serialization/{json/util.d.ts → identifiers.d.ts} +1 -1
  475. package/dist/esm/serialization/identifiers.d.ts.map +1 -0
  476. package/dist/esm/serialization/{json/util.js → identifiers.js} +1 -1
  477. package/dist/esm/serialization/identifiers.js.map +1 -0
  478. package/dist/esm/serialization/index.d.ts +1 -1
  479. package/dist/esm/serialization/index.d.ts.map +1 -1
  480. package/dist/esm/serialization/index.js.map +1 -1
  481. package/dist/esm/serialization/json/deserialize.d.ts.map +1 -1
  482. package/dist/esm/serialization/json/deserialize.js +131 -39
  483. package/dist/esm/serialization/json/deserialize.js.map +1 -1
  484. package/dist/esm/serialization/json/serialize.d.ts +1 -1
  485. package/dist/esm/serialization/json/serialize.d.ts.map +1 -1
  486. package/dist/esm/serialization/json/serialize.js +5 -360
  487. package/dist/esm/serialization/json/serialize.js.map +1 -1
  488. package/dist/esm/serialization/pluralize-config.d.ts.map +1 -0
  489. package/dist/esm/serialization/pluralize-config.js.map +1 -0
  490. package/dist/esm/serialization/symbol-map.d.ts +10 -0
  491. package/dist/esm/serialization/symbol-map.d.ts.map +1 -0
  492. package/dist/esm/serialization/symbol-map.js +40 -0
  493. package/dist/esm/serialization/symbol-map.js.map +1 -0
  494. package/dist/esm/shape/shape.d.ts +4 -4
  495. package/dist/esm/shape/shape.js +2 -2
  496. package/dist/esm/shape/shape.js.map +1 -1
  497. package/package.json +3 -2
  498. package/dist/browser/serialization/contract/generated/ast.d.ts.map +0 -1
  499. package/dist/browser/serialization/contract/generated/ast.js.map +0 -1
  500. package/dist/browser/serialization/contract/index.d.ts +0 -2
  501. package/dist/browser/serialization/contract/index.d.ts.map +0 -1
  502. package/dist/browser/serialization/contract/index.js.map +0 -1
  503. package/dist/browser/serialization/json/encoding.d.ts.map +0 -1
  504. package/dist/browser/serialization/json/encoding.js.map +0 -1
  505. package/dist/browser/serialization/json/expression.d.ts +0 -32
  506. package/dist/browser/serialization/json/expression.d.ts.map +0 -1
  507. package/dist/browser/serialization/json/expression.js +0 -494
  508. package/dist/browser/serialization/json/expression.js.map +0 -1
  509. package/dist/browser/serialization/json/lower.d.ts.map +0 -1
  510. package/dist/browser/serialization/json/lower.js.map +0 -1
  511. package/dist/browser/serialization/json/pluralize-config.d.ts.map +0 -1
  512. package/dist/browser/serialization/json/pluralize-config.js.map +0 -1
  513. package/dist/browser/serialization/json/util.d.ts.map +0 -1
  514. package/dist/browser/serialization/json/util.js.map +0 -1
  515. package/dist/browser/serialization/utils.d.ts +0 -3
  516. package/dist/browser/serialization/utils.d.ts.map +0 -1
  517. package/dist/browser/serialization/utils.js +0 -146
  518. package/dist/browser/serialization/utils.js.map +0 -1
  519. package/dist/commonjs/serialization/contract/generated/ast.d.ts.map +0 -1
  520. package/dist/commonjs/serialization/contract/index.d.ts +0 -2
  521. package/dist/commonjs/serialization/contract/index.d.ts.map +0 -1
  522. package/dist/commonjs/serialization/contract/index.js.map +0 -7
  523. package/dist/commonjs/serialization/json/encoding.d.ts.map +0 -1
  524. package/dist/commonjs/serialization/json/encoding.js.map +0 -7
  525. package/dist/commonjs/serialization/json/expression.d.ts +0 -32
  526. package/dist/commonjs/serialization/json/expression.d.ts.map +0 -1
  527. package/dist/commonjs/serialization/json/expression.js +0 -509
  528. package/dist/commonjs/serialization/json/expression.js.map +0 -7
  529. package/dist/commonjs/serialization/json/lower.d.ts.map +0 -1
  530. package/dist/commonjs/serialization/json/lower.js.map +0 -7
  531. package/dist/commonjs/serialization/json/pluralize-config.d.ts.map +0 -1
  532. package/dist/commonjs/serialization/json/util.d.ts.map +0 -1
  533. package/dist/commonjs/serialization/utils.d.ts +0 -3
  534. package/dist/commonjs/serialization/utils.d.ts.map +0 -1
  535. package/dist/commonjs/serialization/utils.js +0 -169
  536. package/dist/commonjs/serialization/utils.js.map +0 -7
  537. package/dist/esm/serialization/contract/generated/ast.d.ts.map +0 -1
  538. package/dist/esm/serialization/contract/generated/ast.js.map +0 -1
  539. package/dist/esm/serialization/contract/index.d.ts +0 -2
  540. package/dist/esm/serialization/contract/index.d.ts.map +0 -1
  541. package/dist/esm/serialization/contract/index.js.map +0 -1
  542. package/dist/esm/serialization/json/encoding.d.ts.map +0 -1
  543. package/dist/esm/serialization/json/encoding.js.map +0 -1
  544. package/dist/esm/serialization/json/expression.d.ts +0 -32
  545. package/dist/esm/serialization/json/expression.d.ts.map +0 -1
  546. package/dist/esm/serialization/json/expression.js +0 -494
  547. package/dist/esm/serialization/json/expression.js.map +0 -1
  548. package/dist/esm/serialization/json/lower.d.ts.map +0 -1
  549. package/dist/esm/serialization/json/lower.js.map +0 -1
  550. package/dist/esm/serialization/json/pluralize-config.d.ts.map +0 -1
  551. package/dist/esm/serialization/json/pluralize-config.js.map +0 -1
  552. package/dist/esm/serialization/json/util.d.ts.map +0 -1
  553. package/dist/esm/serialization/json/util.js.map +0 -1
  554. package/dist/esm/serialization/utils.d.ts +0 -3
  555. package/dist/esm/serialization/utils.d.ts.map +0 -1
  556. package/dist/esm/serialization/utils.js +0 -146
  557. package/dist/esm/serialization/utils.js.map +0 -1
  558. /package/dist/browser/serialization/{contract → ast}/generated/ast.d.ts +0 -0
  559. /package/dist/browser/serialization/{contract → ast}/generated/ast.js +0 -0
  560. /package/dist/browser/serialization/{contract → ast}/index.js +0 -0
  561. /package/dist/browser/serialization/{json/pluralize-config.d.ts → pluralize-config.d.ts} +0 -0
  562. /package/dist/browser/serialization/{json/pluralize-config.js → pluralize-config.js} +0 -0
  563. /package/dist/commonjs/serialization/{contract → ast}/generated/ast.d.ts +0 -0
  564. /package/dist/commonjs/serialization/{contract → ast}/generated/ast.js +0 -0
  565. /package/dist/commonjs/serialization/{json/pluralize-config.d.ts → pluralize-config.d.ts} +0 -0
  566. /package/dist/commonjs/serialization/{json/pluralize-config.js → pluralize-config.js} +0 -0
  567. /package/dist/esm/serialization/{contract → ast}/generated/ast.d.ts +0 -0
  568. /package/dist/esm/serialization/{contract → ast}/generated/ast.js +0 -0
  569. /package/dist/esm/serialization/{contract → ast}/index.js +0 -0
  570. /package/dist/esm/serialization/{json/pluralize-config.d.ts → pluralize-config.d.ts} +0 -0
  571. /package/dist/esm/serialization/{json/pluralize-config.js → pluralize-config.js} +0 -0
@@ -8,18 +8,19 @@ import { createOutput } from "../../constructs/output.js";
8
8
  import { createParameter } from "../../constructs/parameter.js";
9
9
  import { createVariable } from "../../constructs/variable.js";
10
10
  import { createIndexedResourceProxy, unwrapResourceHandle, } from "../../constructs/resource/resource-proxy.js";
11
- import { isLoopedResource } from "../../constructs/resource/resource-utils.js";
11
+ import { isResource, isLoopedResource } from "../../constructs/resource/resource-utils.js";
12
12
  import { createLoopedResource, Loop, Resource, } from "../../constructs/resource/resource.js";
13
13
  import { Stack } from "../../constructs/stack.js";
14
- import { wrapExpression, isExpression } from "../../expression/expressions.js";
14
+ import { wrapExpression, unwrapExpression, isExpression, } from "../../expression/expressions.js";
15
15
  import { namingRequiredPolicy } from "../../naming/naming-policy.js";
16
16
  import { getShape } from "../../shape/shape-registry.js";
17
- import { symbolicValueExpressionNode } from "../../expression/ast-nodes.js";
17
+ import { identifierExpressionNode, symbolicValueExpressionNode, } from "../../expression/ast-nodes.js";
18
18
  import { resolveResource } from "../../constructs/resource/resource-registry.js";
19
- import { isPrimitiveTypeName, } from "../contract/index.js";
20
- import { deserializeDependsOnExpression, deserializeExpression, requireResourceHandle, } from "./expression.js";
21
- import { raiseState } from "./lower.js";
22
- import { collectDependenciesForDeclaration } from "../utils.js";
19
+ import { isPrimitiveTypeName, } from "../ast/index.js";
20
+ import { restoreExpression } from "../ast/expression-restorer.js";
21
+ import { convertFromArmObject } from "../arm-object-conversion.js";
22
+ import { collectDependenciesForDeclaration } from "../ast/declaration-dependencies.js";
23
+ import { getScopeFunctionTarget } from "../../expression/utils.js";
23
24
  /**
24
25
  * Reconstructs stacks from the JSON text of a {@link SerializationDocument},
25
26
  * such as `JSON.stringify(serialize(stack))`. Returns one stack per `infras`
@@ -32,7 +33,38 @@ import { collectDependenciesForDeclaration } from "../utils.js";
32
33
  * though the resulting JSON need not be byte-for-byte identical.
33
34
  */
34
35
  export function deserialize(raw, options) {
35
- const doc = JSON.parse(raw);
36
+ // TODO(#330): .NET ModelReaderWriter still emits `contextual-variable` nodes
37
+ // with `context` naming a zero-argument scope function (e.g. resourceGroup)
38
+ // and `property` naming the accessed member (e.g. location). The generated
39
+ // AST represents this as property-access over function-call instead.
40
+ // Normalize at the JSON boundary, before dependency inspection or expression
41
+ // restoration: AST walkers accept only the generated node kinds. The reviver
42
+ // handles nested expressions too, while the container guards preserve extra
43
+ // `kind` fields on documents, files, and declarations as ordinary metadata.
44
+ // Remove this normalization once .NET emits the composed AST nodes directly.
45
+ const doc = JSON.parse(raw, (_key, value) => {
46
+ if (typeof value !== "object" ||
47
+ value === null ||
48
+ !("kind" in value) ||
49
+ value.kind !== "contextual-variable" ||
50
+ "bicepIdentifier" in value ||
51
+ "fileName" in value ||
52
+ "infras" in value) {
53
+ return value;
54
+ }
55
+ if (!("context" in value) ||
56
+ typeof value.context !== "string" ||
57
+ !("property" in value) ||
58
+ typeof value.property !== "string") {
59
+ throw new Error("Invalid contextual-variable expression: context and property must be strings.");
60
+ }
61
+ return {
62
+ kind: "property-access",
63
+ base: { kind: "function-call", target: value.context, args: [] },
64
+ property: value.property,
65
+ nullish: false,
66
+ };
67
+ });
36
68
  if (doc.infras.length === 0)
37
69
  throw new Error("Empty SerializationDocument");
38
70
  if (doc.infras.some((infra) => Object.keys(infra.modules ?? {}).length > 0)) {
@@ -78,12 +110,12 @@ function processParams(file, stackHandle, symbols) {
78
110
  ...(p.decorators?.secure ? { secure: true } : {}),
79
111
  ...(p.defaultValue !== undefined
80
112
  ? {
81
- defaultValue: deserializeExpression(p.defaultValue, new Map()),
113
+ defaultValue: restoreExpression(p.defaultValue, new Map()),
82
114
  }
83
115
  : {}),
84
116
  ...(p.decorators?.allowed?.length
85
117
  ? {
86
- allowed: p.decorators.allowed.map((a) => deserializeExpression(a, new Map())),
118
+ allowed: p.decorators.allowed.map((a) => restoreExpression(a, new Map())),
87
119
  }
88
120
  : {}),
89
121
  ...(p.decorators?.minValue !== undefined ? { minValue: p.decorators.minValue } : {}),
@@ -94,7 +126,7 @@ function processParams(file, stackHandle, symbols) {
94
126
  ? {
95
127
  metadata: Object.fromEntries(Object.entries(p.decorators.metadata).map(([k, v]) => [
96
128
  k,
97
- deserializeExpression(v, new Map()),
129
+ restoreExpression(v, new Map()),
98
130
  ])),
99
131
  }
100
132
  : {}),
@@ -172,7 +204,7 @@ function processDeclarations(file, stackHandle, symbols, options) {
172
204
  return;
173
205
  }
174
206
  const { node } = declaration;
175
- const sym = createVariable(stackHandle, node.bicepIdentifier, deserializeExpression(node.value, symbols), {
207
+ const sym = createVariable(stackHandle, node.bicepIdentifier, restoreExpression(node.value, symbols), {
176
208
  ...(node.decorators?.description !== undefined
177
209
  ? { description: node.decorators.description }
178
210
  : {}),
@@ -189,7 +221,7 @@ function processOutputs(file, stackHandle, symbols) {
189
221
  if (!isPrimitiveTypeName(o.valueType.name)) {
190
222
  throw new Error(`Cannot deserialize output "${o.bicepIdentifier}" with unknown primitive type "${o.valueType.name}".`);
191
223
  }
192
- const val = deserializeExpression(o.value, symbols);
224
+ const val = restoreExpression(o.value, symbols);
193
225
  createOutput(stackHandle, o.bicepIdentifier, o.valueType.name, val, {
194
226
  ...(o.decorators?.description !== undefined ? { description: o.decorators.description } : {}),
195
227
  ...(o.decorators?.secure ? { secure: true } : {}),
@@ -201,7 +233,7 @@ function processOutputs(file, stackHandle, symbols) {
201
233
  ? {
202
234
  metadata: Object.fromEntries(Object.entries(o.decorators.metadata).map(([k, v]) => [
203
235
  k,
204
- deserializeExpression(v, symbols),
236
+ restoreExpression(v, symbols),
205
237
  ])),
206
238
  }
207
239
  : {}),
@@ -215,6 +247,29 @@ function processOutputs(file, stackHandle, symbols) {
215
247
  // ---------------------------------------------------------------------------
216
248
  // Resource construction
217
249
  // ---------------------------------------------------------------------------
250
+ function resolveResourceReference(targetIdentifier, symbols, resourceIdentifier, field) {
251
+ const handle = symbols.get(targetIdentifier);
252
+ if (handle === undefined) {
253
+ throw new Error(`Resource "${resourceIdentifier}" references unknown resource ` +
254
+ `"${targetIdentifier}" in "${field}".`);
255
+ }
256
+ if (!isResource(handle) && !isLoopedResource(handle)) {
257
+ throw new Error(`Resource "${resourceIdentifier}" references non-resource symbol ` +
258
+ `"${targetIdentifier}" in "${field}".`);
259
+ }
260
+ return handle;
261
+ }
262
+ function restoreResourceDependencies(node, symbols, resourceIdentifier) {
263
+ if (node.kind !== "array") {
264
+ throw new Error(`Resource "${resourceIdentifier}" has an invalid "dependsOn" value; expected an array.`);
265
+ }
266
+ return node.items.map((item) => {
267
+ if (item.kind !== "identifier") {
268
+ throw new Error(`Resource "${resourceIdentifier}" has an invalid "dependsOn" reference; expected a resource identifier.`);
269
+ }
270
+ return resolveResourceReference(item.id, symbols, resourceIdentifier, "dependsOn");
271
+ });
272
+ }
218
273
  function createResource(res, defaultScope, symbols, options) {
219
274
  // `res.value` is the wire body. Valid shapes are:
220
275
  // 1. object
@@ -249,7 +304,7 @@ function createResource(res, defaultScope, symbols, options) {
249
304
  const scopedSymbols = loopWrapper === undefined ? symbols : new Map(symbols);
250
305
  const loopAuthoring = loopWrapper !== undefined
251
306
  ? {
252
- collection: deserializeExpression(loopWrapper.collection, symbols),
307
+ collection: restoreExpression(loopWrapper.collection, symbols),
253
308
  itemVariable: loopWrapper.itemVariable,
254
309
  ...(loopWrapper.indexVariable !== undefined
255
310
  ? { indexVariable: loopWrapper.indexVariable }
@@ -268,7 +323,7 @@ function createResource(res, defaultScope, symbols, options) {
268
323
  const authoring = {
269
324
  ...(conditionNode !== undefined
270
325
  ? {
271
- condition: deserializeExpression(conditionNode, scopedSymbols),
326
+ condition: restoreExpression(conditionNode, scopedSymbols),
272
327
  }
273
328
  : {}),
274
329
  ...(loopAuthoring !== undefined ? { loop: loopAuthoring } : {}),
@@ -284,13 +339,38 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
284
339
  parentNode.kind !== "array-access") {
285
340
  throw new Error(`Resource "${res.bicepIdentifier}" has an invalid "parent" reference.`);
286
341
  }
287
- if (!res.existing && scopeNode !== undefined && scopeNode.kind !== "identifier") {
288
- throw new Error(`Resource "${res.bicepIdentifier}" has an invalid "scope" reference.`);
342
+ let relationship = parentNode;
343
+ let relationshipKind = "parent";
344
+ let resolvedScope = false;
345
+ if (parentNode === undefined && scopeNode !== undefined) {
346
+ const scopeTargetSymbolName = scopeNode.kind === "identifier"
347
+ ? scopeNode.id
348
+ : scopeNode.kind === "array-access" &&
349
+ scopeNode.base.kind === "identifier" &&
350
+ !scopeNode.nullish &&
351
+ !scopeNode.fromEnd
352
+ ? scopeNode.base.id
353
+ : undefined;
354
+ const scopeTarget = scopeTargetSymbolName === undefined ? undefined : symbols.get(scopeTargetSymbolName);
355
+ if (scopeNode.kind === "identifier" && isLoopedResource(scopeTarget)) {
356
+ throw new Error(`Resource "${res.bicepIdentifier}" references resource collection ` +
357
+ `"${scopeNode.id}" in "scope"; expected a single resource.`);
358
+ }
359
+ if ((scopeNode.kind === "identifier" && isResource(scopeTarget)) ||
360
+ (scopeNode.kind === "array-access" &&
361
+ isLoopedResource(scopeTarget) &&
362
+ !scopeNode.nullish &&
363
+ !scopeNode.fromEnd &&
364
+ scopeNode.base.kind === "identifier")) {
365
+ relationship = scopeNode;
366
+ relationshipKind = "scope";
367
+ resolvedScope = true;
368
+ }
289
369
  }
290
- if (parentNode?.kind === "identifier") {
291
- context = requireResourceHandle(parentNode.id, symbols, res.bicepIdentifier, "parent");
370
+ if (relationship?.kind === "identifier") {
371
+ context = resolveResourceReference(relationship.id, symbols, res.bicepIdentifier, relationshipKind);
292
372
  }
293
- else if (parentNode?.kind === "array-access") {
373
+ else if (relationship?.kind === "array-access") {
294
374
  // `parent: parentSym[<index>]` — the serializer emitted this because
295
375
  // the authoring code created the child under `parents.at(i)` /
296
376
  // `parents.current()`. To round-trip the shape, reconstruct the
@@ -298,32 +378,36 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
298
378
  // `state.parentIndex` from the same index expression. Passing the
299
379
  // raw parent here would erase the array-access — the child would
300
380
  // re-serialize as `parent: parentSym` and lose the index.
301
- const baseNode = parentNode.base;
381
+ const baseNode = relationship.base;
302
382
  if (baseNode.kind === "identifier") {
303
- const rawParent = requireResourceHandle(baseNode.id, symbols, res.bicepIdentifier, "parent");
304
- const indexValue = deserializeExpression(parentNode.index, symbols);
383
+ const rawParent = resolveResourceReference(baseNode.id, symbols, res.bicepIdentifier, relationshipKind);
384
+ const indexValue = restoreExpression(relationship.index, symbols);
305
385
  context = createIndexedResourceProxy(rawParent, indexValue);
306
386
  }
307
387
  else {
308
388
  throw new Error(`Resource "${res.bicepIdentifier}" has an invalid "parent" reference.`);
309
389
  }
310
390
  }
311
- else if (scopeNode?.kind === "identifier") {
312
- const scopeResource = requireResourceHandle(scopeNode.id, symbols, res.bicepIdentifier, "scope");
313
- if (isLoopedResource(scopeResource)) {
314
- throw new Error(`Resource "${res.bicepIdentifier}" references resource collection ` +
315
- `"${scopeNode.id}" in "scope"; expected a single resource.`);
316
- }
317
- context = scopeResource;
318
- }
319
391
  let existingScope;
320
- if (res.existing && scopeNode !== undefined && scopeNode.kind !== "identifier") {
321
- const scope = deserializeExpression(scopeNode, symbols);
392
+ let preservedScope;
393
+ if (scopeNode !== undefined && !resolvedScope) {
394
+ const value = restoreExpression(scopeNode, symbols);
395
+ const scope = isResource(value) ? wrapExpression(identifierExpressionNode(value)) : value;
322
396
  if (!isExpression(scope)) {
323
397
  throw new Error(`Resource "${res.bicepIdentifier}" has an invalid "scope" value: ` +
324
398
  `expected an expression, received "${scopeNode.kind}".`);
325
399
  }
326
- existingScope = scope;
400
+ const currentStackScope = parentNode === undefined &&
401
+ defaultScope instanceof Stack &&
402
+ scopeNode.kind === "function-call" &&
403
+ scopeNode.args.length === 0 &&
404
+ getScopeFunctionTarget(scopeNode) === defaultScope.targetScope;
405
+ if (res.existing && getScopeFunctionTarget(scopeNode) !== undefined) {
406
+ existingScope = scope;
407
+ }
408
+ else if (!currentStackScope) {
409
+ preservedScope = scope;
410
+ }
327
411
  }
328
412
  // Collect non-reserved properties
329
413
  const RESERVED = new Set(["name", "parent", "scope", "dependsOn"]);
@@ -331,7 +415,7 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
331
415
  for (const [key, valNode] of Object.entries(body)) {
332
416
  if (!RESERVED.has(key)) {
333
417
  Object.defineProperty(wireProps, key, {
334
- value: deserializeExpression(valNode, symbols),
418
+ value: restoreExpression(valNode, symbols),
335
419
  enumerable: true,
336
420
  configurable: true,
337
421
  writable: true,
@@ -344,13 +428,13 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
344
428
  // because re-serialization also skips lowering when no descriptor
345
429
  // is attached.
346
430
  const nameNode = body["name"];
347
- const resourceName = nameNode === undefined ? "unknown" : deserializeExpression(nameNode, symbols);
431
+ const resourceName = nameNode === undefined ? "unknown" : restoreExpression(nameNode, symbols);
348
432
  const wireState = { name: resourceName, ...wireProps };
349
433
  const descriptor = getShape(res.type, res.apiVersion, wireState, {
350
434
  strict: options?.strict ?? false,
351
435
  valueKeyedBy: "arm",
352
436
  });
353
- const props = descriptor ? raiseState(wireProps, descriptor) : wireProps;
437
+ const props = descriptor ? convertFromArmObject(wireProps, descriptor) : wireProps;
354
438
  const baseProps = {
355
439
  type: res.type,
356
440
  apiVersion: res.apiVersion,
@@ -363,7 +447,7 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
363
447
  ...(authoring?.condition !== undefined ? { condition: authoring.condition } : {}),
364
448
  ...(body.dependsOn !== undefined
365
449
  ? {
366
- dependsOn: deserializeDependsOnExpression(body.dependsOn, symbols, res.bicepIdentifier),
450
+ dependsOn: restoreResourceDependencies(body.dependsOn, symbols, res.bicepIdentifier),
367
451
  }
368
452
  : {}),
369
453
  };
@@ -417,6 +501,14 @@ function buildResource(res, body, defaultScope, symbols, options, authoring) {
417
501
  const state = unwrapResourceHandle(handle);
418
502
  state.condition = authoring.condition;
419
503
  }
504
+ if (preservedScope !== undefined) {
505
+ Object.defineProperty(unwrapResourceHandle(handle), "scope", {
506
+ value: unwrapExpression(preservedScope),
507
+ enumerable: true,
508
+ configurable: true,
509
+ writable: true,
510
+ });
511
+ }
420
512
  return handle;
421
513
  }
422
514
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/serialization/json/deserialize.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAsB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,IAAI,EAEJ,QAAQ,GAGT,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAmB,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAGjF,OAAO,EACL,mBAAmB,GAMpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,qBAAqB,GAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAiBhE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAA4B;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,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// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Deserializes raw JSON (produced by `@azure/provisioning-core/serialization`) back into\n * live CDK `Stack` data structures.\n */\n\nimport { createOutput, type OutputValue } from \"../../constructs/output.js\";\nimport { createParameter } from \"../../constructs/parameter.js\";\nimport { createVariable, type VariableValue } from \"../../constructs/variable.js\";\nimport {\n createIndexedResourceProxy,\n unwrapResourceHandle,\n} from \"../../constructs/resource/resource-proxy.js\";\nimport { isLoopedResource } from \"../../constructs/resource/resource-utils.js\";\nimport {\n createLoopedResource,\n Loop,\n type LoopedResource,\n Resource,\n type ResourceOptions,\n type ScopeExpression,\n} from \"../../constructs/resource/resource.js\";\nimport { Stack } from \"../../constructs/stack.js\";\nimport { wrapExpression, isExpression, type Expression } from \"../../expression/expressions.js\";\nimport { namingRequiredPolicy } from \"../../naming/naming-policy.js\";\nimport { getShape } from \"../../shape/shape-registry.js\";\nimport { symbolicValueExpressionNode } from \"../../expression/ast-nodes.js\";\nimport { resolveResource } from \"../../constructs/resource/resource-registry.js\";\nimport { type ProvisioningComponent } from \"../../constructs/provisioning-component.js\";\n\nimport {\n isPrimitiveTypeName,\n type ExpressionNode,\n type InfraNode,\n type ResourceDeclarationNode,\n type SerializationDocument,\n type VariableDeclarationNode,\n} from \"../contract/index.js\";\n\nimport {\n deserializeDependsOnExpression,\n deserializeExpression,\n requireResourceHandle,\n type DeserializationSymbolMap,\n} from \"./expression.js\";\nimport { raiseState } from \"./lower.js\";\nimport { collectDependenciesForDeclaration } from \"../utils.js\";\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Options for {@link deserialize}.\n *\n * Controls whether unmatched `(type, apiVersion)` pairs fall back\n * to the highest registered version for the type (`strict: false`,\n * the default) or return a base `Resource` (`strict: true`).\n */\nexport interface DeserializeOptions {\n readonly strict?: boolean;\n}\n\n/**\n * Reconstructs stacks from the JSON text of a {@link SerializationDocument},\n * such as `JSON.stringify(serialize(stack))`. Returns one stack per `infras`\n * entry; the input must contain at least one.\n *\n * Import the relevant service packages before restoring to register their\n * resource classes; otherwise unregistered types use base resources.\n * Unsupported module declarations are rejected. A serialize/deserialize/\n * serialize cycle preserves supported deployment semantics and expressions,\n * though the resulting JSON need not be byte-for-byte identical.\n */\nexport function deserialize(raw: string, options?: DeserializeOptions): readonly Stack[] {\n const doc = JSON.parse(raw) as SerializationDocument;\n if (doc.infras.length === 0) throw new Error(\"Empty SerializationDocument\");\n if (doc.infras.some((infra) => Object.keys(infra.modules ?? {}).length > 0)) {\n throw new Error(\"Module deserialization is not supported.\");\n }\n\n return constructStacks(doc.infras, options);\n}\n\n// ---------------------------------------------------------------------------\n// Type aliases\n// ---------------------------------------------------------------------------\n\ninterface LoopAuthoringContext {\n readonly collection: unknown;\n readonly itemVariable: string;\n readonly indexVariable?: string;\n readonly batchSize?: number;\n}\n\ninterface ResourceAuthoringContext {\n readonly condition?: Expression<boolean>;\n readonly loop?: LoopAuthoringContext;\n}\n\n// ---------------------------------------------------------------------------\n// Construction: InfraNode → CDK objects\n// ---------------------------------------------------------------------------\n\nfunction constructStacks(\n files: readonly InfraNode[],\n options: DeserializeOptions | undefined,\n): Stack[] {\n return files.map((file) => constructStack(file, options));\n}\n\nfunction constructStack(file: InfraNode, options: DeserializeOptions | undefined): Stack {\n const rootStack = new Stack(stemName(file.fileName), {\n targetScope: file.targetScope ?? \"resourceGroup\",\n namingPolicy: namingRequiredPolicy,\n });\n\n // Map stack-local identifiers to expression handles and resource declarations.\n const symbols: DeserializationSymbolMap = new Map();\n\n processParams(file, rootStack, symbols);\n processDeclarations(file, rootStack, symbols, options);\n processOutputs(file, rootStack, symbols);\n\n return rootStack;\n}\n\n// ---------------------------------------------------------------------------\n// Declaration processing\n// ---------------------------------------------------------------------------\n\nfunction assertSymbolAvailable(symbols: DeserializationSymbolMap, identifier: string): void {\n if (symbols.has(identifier)) {\n throw new Error(`Duplicate declaration identifier \"${identifier}\".`);\n }\n}\n\nfunction processParams(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeserializationSymbolMap,\n): void {\n for (const [, p] of Object.entries(file.parameters ?? {})) {\n assertSymbolAvailable(symbols, p.bicepIdentifier);\n if (p.valueType.kind !== \"primitive-type\" || !isPrimitiveTypeName(p.valueType.name)) {\n throw new Error(`Parameter \"${p.bicepIdentifier}\" has an unsupported non-primitive type.`);\n }\n const type = p.valueType.name;\n const sym = createParameter(stackHandle, p.bicepIdentifier, type, {\n ...(p.decorators?.description !== undefined ? { description: p.decorators.description } : {}),\n ...(p.decorators?.secure ? { secure: true } : {}),\n ...(p.defaultValue !== undefined\n ? {\n defaultValue: deserializeExpression(p.defaultValue, new Map()) as string,\n }\n : {}),\n ...(p.decorators?.allowed?.length\n ? {\n allowed: p.decorators.allowed.map((a) =>\n deserializeExpression(a, new Map()),\n ) as unknown as readonly string[],\n }\n : {}),\n ...(p.decorators?.minValue !== undefined ? { minValue: p.decorators.minValue } : {}),\n ...(p.decorators?.maxValue !== undefined ? { maxValue: p.decorators.maxValue } : {}),\n ...(p.decorators?.minLength !== undefined ? { minLength: p.decorators.minLength } : {}),\n ...(p.decorators?.maxLength !== undefined ? { maxLength: p.decorators.maxLength } : {}),\n ...(p.decorators?.metadata !== undefined\n ? {\n metadata: Object.fromEntries(\n Object.entries(p.decorators.metadata).map(([k, v]) => [\n k,\n deserializeExpression(v, new Map()),\n ]),\n ) as Record<string, unknown>,\n }\n : {}),\n ...(p.decorators?.discriminator !== undefined\n ? { discriminator: p.decorators.discriminator }\n : {}),\n ...(p.decorators?.sealed ? { sealed: true } : {}),\n });\n symbols.set(p.bicepIdentifier, sym);\n }\n}\n\nfunction processDeclarations(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeserializationSymbolMap,\n options: DeserializeOptions | undefined,\n): void {\n type IndexedDeclaration =\n | { readonly kind: \"resource\"; readonly node: ResourceDeclarationNode }\n | { readonly kind: \"variable\"; readonly node: VariableDeclarationNode };\n const declarations = new Map<string, IndexedDeclaration>();\n\n function registerDeclaration(declaration: IndexedDeclaration): void {\n const { node } = declaration;\n assertSymbolAvailable(symbols, node.bicepIdentifier);\n const previous = declarations.get(node.bicepIdentifier);\n if (previous !== undefined) {\n const category =\n previous.kind === \"resource\" && declaration.kind === \"resource\"\n ? \"resource\"\n : \"declaration\";\n throw new Error(`Duplicate ${category} identifier \"${node.bicepIdentifier}\".`);\n }\n declarations.set(node.bicepIdentifier, declaration);\n }\n\n for (const node of Object.values(file.variables ?? {})) {\n registerDeclaration({ kind: \"variable\", node });\n }\n for (const node of Object.values(file.resources ?? {})) {\n registerDeclaration({ kind: \"resource\", node });\n }\n\n const pending: {\n declaration: IndexedDeclaration;\n dependencies: Iterator<string>;\n }[] = [];\n const active = new Map<string, number>();\n\n function pushDeclaration(declaration: IndexedDeclaration): void {\n const { node } = declaration;\n const identifiers = collectDependenciesForDeclaration(node);\n active.set(node.bicepIdentifier, pending.length);\n pending.push({ declaration, dependencies: identifiers.values() });\n }\n\n for (const declaration of declarations.values()) {\n if (symbols.has(declaration.node.bicepIdentifier)) continue;\n pushDeclaration(declaration);\n\n while (pending.length > 0) {\n const frame = pending[pending.length - 1]!;\n const dependency = frame.dependencies.next();\n if (!dependency.done) {\n if (symbols.has(dependency.value)) continue;\n const target = declarations.get(dependency.value);\n if (target === undefined) continue;\n const cycleStart = active.get(dependency.value);\n if (cycleStart !== undefined) {\n const cycle = pending.slice(cycleStart).map((entry) => entry.declaration);\n const category = cycle.every((entry) => entry.kind === \"resource\")\n ? \"Resource\"\n : \"Declaration\";\n const path = [...cycle.map((entry) => entry.node.bicepIdentifier), dependency.value]\n .map((identifier) => `\"${identifier}\"`)\n .join(\" -> \");\n throw new Error(`${category} dependency cycle detected: ${path}.`);\n }\n pushDeclaration(target);\n continue;\n }\n\n constructDeclaration(frame.declaration);\n active.delete(frame.declaration.node.bicepIdentifier);\n pending.pop();\n }\n }\n\n function constructDeclaration(declaration: IndexedDeclaration): void {\n if (declaration.kind === \"resource\") {\n symbols.set(\n declaration.node.bicepIdentifier,\n createResource(declaration.node, stackHandle, symbols, options),\n );\n return;\n }\n const { node } = declaration;\n const sym = createVariable(\n stackHandle,\n node.bicepIdentifier,\n deserializeExpression(node.value, symbols) as VariableValue,\n {\n ...(node.decorators?.description !== undefined\n ? { description: node.decorators.description }\n : {}),\n ...(node.decorators?.export ? { export: true } : {}),\n },\n );\n symbols.set(node.bicepIdentifier, sym);\n }\n}\n\nfunction processOutputs(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeserializationSymbolMap,\n): void {\n for (const [, o] of Object.entries(file.outputs ?? {})) {\n if (o.valueType.kind !== \"primitive-type\") {\n throw new Error(\n `Cannot deserialize output \"${o.bicepIdentifier}\" with non-primitive type \"${o.valueType.kind}\".`,\n );\n }\n if (!isPrimitiveTypeName(o.valueType.name)) {\n throw new Error(\n `Cannot deserialize output \"${o.bicepIdentifier}\" with unknown primitive type \"${o.valueType.name}\".`,\n );\n }\n const val = deserializeExpression(o.value, symbols) as OutputValue;\n createOutput(stackHandle, o.bicepIdentifier, o.valueType.name, val as OutputValue, {\n ...(o.decorators?.description !== undefined ? { description: o.decorators.description } : {}),\n ...(o.decorators?.secure ? { secure: true } : {}),\n ...(o.decorators?.minValue !== undefined ? { minValue: o.decorators.minValue } : {}),\n ...(o.decorators?.maxValue !== undefined ? { maxValue: o.decorators.maxValue } : {}),\n ...(o.decorators?.minLength !== undefined ? { minLength: o.decorators.minLength } : {}),\n ...(o.decorators?.maxLength !== undefined ? { maxLength: o.decorators.maxLength } : {}),\n ...(o.decorators?.metadata !== undefined\n ? {\n metadata: Object.fromEntries(\n Object.entries(o.decorators.metadata).map(([k, v]) => [\n k,\n deserializeExpression(v, symbols),\n ]),\n ) as Record<string, unknown>,\n }\n : {}),\n ...(o.decorators?.discriminator !== undefined\n ? { discriminator: o.decorators.discriminator }\n : {}),\n ...(o.decorators?.sealed ? { sealed: true } : {}),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Resource construction\n// ---------------------------------------------------------------------------\n\nfunction createResource(\n res: ResourceDeclarationNode,\n defaultScope: Stack | Resource,\n symbols: DeserializationSymbolMap,\n options: DeserializeOptions | undefined,\n): Resource | LoopedResource<Resource> {\n // `res.value` is the wire body. Valid shapes are:\n // 1. object\n // 2. if-condition(object)\n // 3. for-expression(object)\n // 4. for-expression(if-condition(object))\n // Anything else (bare wrappers, if-outer-for-inner, multi-if, multi-for,\n // nested for-for, if-for-if, etc.) is malformed and rejected here.\n let wireBody: ExpressionNode = res.value;\n let loopWrapper:\n | {\n itemVariable: string;\n indexVariable?: string;\n collection: ExpressionNode;\n }\n | undefined;\n let conditionNode: ExpressionNode | undefined;\n\n if (wireBody.kind === \"for-expression\") {\n loopWrapper = {\n itemVariable: wireBody.itemVariable,\n ...(wireBody.indexVariable !== undefined ? { indexVariable: wireBody.indexVariable } : {}),\n collection: wireBody.collection,\n };\n wireBody = wireBody.body;\n }\n if (wireBody.kind === \"if-condition\") {\n conditionNode = wireBody.condition;\n wireBody = wireBody.body;\n }\n if (wireBody.kind !== \"object\") {\n throw new Error(\n `Invalid wire shape for resource \"${res.bicepIdentifier}\": ` +\n `\\`value\\` must be an \\`object\\`, optionally wrapped in ` +\n `\\`if-condition\\` and/or an outer \\`for-expression\\` (Bicep source ` +\n `order: \\`for\\` outer, \\`if\\` inner). Innermost node after peeling ` +\n `at most one \\`for-expression\\` and one \\`if-condition\\` is ` +\n `\\`${wireBody.kind}\\`.`,\n );\n }\n\n const scopedSymbols = loopWrapper === undefined ? symbols : new Map(symbols);\n const loopAuthoring: LoopAuthoringContext | undefined =\n loopWrapper !== undefined\n ? {\n collection: deserializeExpression(loopWrapper.collection, symbols),\n itemVariable: loopWrapper.itemVariable,\n ...(loopWrapper.indexVariable !== undefined\n ? { indexVariable: loopWrapper.indexVariable }\n : {}),\n ...(res.decorators?.batchSize !== undefined\n ? { batchSize: res.decorators.batchSize }\n : {}),\n }\n : undefined;\n\n if (loopWrapper !== undefined) {\n scopedSymbols.set(\n loopWrapper.itemVariable,\n wrapExpression(symbolicValueExpressionNode(loopWrapper.itemVariable)),\n );\n if (loopWrapper.indexVariable !== undefined) {\n scopedSymbols.set(\n loopWrapper.indexVariable,\n wrapExpression(symbolicValueExpressionNode(loopWrapper.indexVariable)),\n );\n }\n }\n\n const authoring: ResourceAuthoringContext = {\n ...(conditionNode !== undefined\n ? {\n condition: deserializeExpression(conditionNode, scopedSymbols) as Expression<boolean>,\n }\n : {}),\n ...(loopAuthoring !== undefined ? { loop: loopAuthoring } : {}),\n };\n\n return buildResource(\n res,\n objBody(res.value) ?? {},\n defaultScope,\n scopedSymbols,\n options,\n authoring,\n );\n}\n\nfunction buildResource(\n res: ResourceDeclarationNode,\n body: Record<string, ExpressionNode>,\n defaultScope: Stack | Resource,\n symbols: DeserializationSymbolMap,\n options: DeserializeOptions | undefined,\n authoring?: ResourceAuthoringContext,\n): Resource | LoopedResource<Resource> {\n let context: ProvisioningComponent = defaultScope;\n const parentNode = body[\"parent\"];\n const scopeNode = body[\"scope\"];\n if (\n parentNode !== undefined &&\n parentNode.kind !== \"identifier\" &&\n parentNode.kind !== \"array-access\"\n ) {\n throw new Error(`Resource \"${res.bicepIdentifier}\" has an invalid \"parent\" reference.`);\n }\n if (!res.existing && scopeNode !== undefined && scopeNode.kind !== \"identifier\") {\n throw new Error(`Resource \"${res.bicepIdentifier}\" has an invalid \"scope\" reference.`);\n }\n if (parentNode?.kind === \"identifier\") {\n context = requireResourceHandle(parentNode.id, symbols, res.bicepIdentifier, \"parent\");\n } else if (parentNode?.kind === \"array-access\") {\n // `parent: parentSym[<index>]` — the serializer emitted this because\n // the authoring code created the child under `parents.at(i)` /\n // `parents.current()`. To round-trip the shape, reconstruct the\n // indexed proxy so the base `Resource` ctor stashes\n // `state.parentIndex` from the same index expression. Passing the\n // raw parent here would erase the array-access — the child would\n // re-serialize as `parent: parentSym` and lose the index.\n const baseNode = parentNode.base;\n if (baseNode.kind === \"identifier\") {\n const rawParent = requireResourceHandle(baseNode.id, symbols, res.bicepIdentifier, \"parent\");\n const indexValue = deserializeExpression(parentNode.index, symbols);\n context = createIndexedResourceProxy(\n rawParent,\n indexValue as number,\n ) as unknown as ProvisioningComponent;\n } else {\n throw new Error(`Resource \"${res.bicepIdentifier}\" has an invalid \"parent\" reference.`);\n }\n } else if (scopeNode?.kind === \"identifier\") {\n const scopeResource = requireResourceHandle(\n scopeNode.id,\n symbols,\n res.bicepIdentifier,\n \"scope\",\n );\n if (isLoopedResource(scopeResource)) {\n throw new Error(\n `Resource \"${res.bicepIdentifier}\" references resource collection ` +\n `\"${scopeNode.id}\" in \"scope\"; expected a single resource.`,\n );\n }\n context = scopeResource;\n }\n\n let existingScope: ScopeExpression | undefined;\n if (res.existing && scopeNode !== undefined && scopeNode.kind !== \"identifier\") {\n const scope = deserializeExpression(scopeNode, symbols);\n if (!isExpression(scope)) {\n throw new Error(\n `Resource \"${res.bicepIdentifier}\" has an invalid \"scope\" value: ` +\n `expected an expression, received \"${scopeNode.kind}\".`,\n );\n }\n existingScope = scope;\n }\n\n // Collect non-reserved properties\n const RESERVED = new Set([\"name\", \"parent\", \"scope\", \"dependsOn\"]);\n const wireProps: Record<string, unknown> = Object.create(null);\n for (const [key, valNode] of Object.entries(body)) {\n if (!RESERVED.has(key)) {\n Object.defineProperty(wireProps, key, {\n value: deserializeExpression(valNode, symbols),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n }\n\n // Raise wire-shape props into JS-shape when a descriptor is\n // registered for this resource type + apiVersion. No-op otherwise —\n // the resource stays in wire shape, which round-trips correctly\n // because re-serialization also skips lowering when no descriptor\n // is attached.\n const nameNode = body[\"name\"];\n const resourceName =\n nameNode === undefined ? \"unknown\" : (deserializeExpression(nameNode, symbols) as string);\n const wireState = { name: resourceName, ...wireProps };\n const descriptor = getShape(res.type, res.apiVersion, wireState, {\n strict: options?.strict ?? false,\n valueKeyedBy: \"arm\",\n });\n const props = descriptor ? raiseState(wireProps, descriptor) : wireProps;\n\n const baseProps: Record<string, unknown> = {\n type: res.type,\n apiVersion: res.apiVersion,\n name: resourceName,\n ...(res.existing ? { existing: true } : {}),\n ...(existingScope !== undefined ? { scope: existingScope } : {}),\n ...props,\n };\n\n const resourceOptions: ResourceOptions = {\n ...(authoring?.condition !== undefined ? { condition: authoring.condition } : {}),\n ...(body.dependsOn !== undefined\n ? {\n dependsOn: deserializeDependsOnExpression(body.dependsOn, symbols, res.bicepIdentifier),\n }\n : {}),\n };\n\n // Look up a registered class for this (type, apiVersion). If one\n // exists, construct it directly so the resulting handle has the right\n // prototype, instance fields, and `instanceof` identity. The class\n // constructor sets `type` and\n // `apiVersion` itself, so strip them before forwarding. Fall back to\n // base `Resource` when no class is registered (unknown type or\n // tree-shaken/missing class module). The `{ name }` lookup state lets\n // the registry pick the right variant for ARM-discriminated types\n // (e.g. `Microsoft.ApiManagement/service/portalsettings` keyed by\n // singleton name). By default the registry does a best-effort match\n // — an unknown apiVersion falls back to the highest registered\n // version for the same `(type, channel)`. Callers can pass\n // `{ strict: true }` on `deserialize` to require an\n // exact `(type, apiVersion)` match instead.\n const Ctor = resolveResource(res.type, res.apiVersion, wireState, options);\n\n let handle: Resource | LoopedResource<Resource>;\n if (authoring?.loop !== undefined) {\n // Looped path: construct a `LoopedResource` directly. Build a fresh\n // `Loop` from the peeled wire metadata; `Resource.fromLoop` reads\n // `.collection`, `.itemVariable`, `.indexRequested`, `.indexVariable`,\n // and `.batchSize` off it. Passing the itemVariable/indexVariable\n // explicitly keeps the wire name (rather than the \"item\"/\"i\" default)\n // and, since supplying `{ indexVariable }` counts as a request,\n // preserves the index binding on re-serialize.\n const loopInstance = new Loop(authoring.loop.collection as unknown as unknown[], {\n itemVariable: authoring.loop.itemVariable,\n ...(authoring.loop.indexVariable !== undefined\n ? { indexVariable: authoring.loop.indexVariable }\n : {}),\n ...(authoring.loop.batchSize !== undefined ? { batchSize: authoring.loop.batchSize } : {}),\n });\n // Base `Resource` is the fallback when no subclass is registered.\n // `LoopedResource`'s ctor accepts type/apiVersion from `userProps`\n // when the ctor's own statics are undefined (as they are on base\n // `Resource`), so this path threads the wire values through\n // `baseProps`.\n const CtorToUse = Ctor ?? Resource;\n handle = createLoopedResource(\n CtorToUse as new (\n context: ProvisioningComponent,\n props: unknown,\n options?: ResourceOptions,\n ) => Resource,\n loopInstance,\n context,\n baseProps,\n resourceOptions,\n );\n } else if (Ctor === undefined) {\n handle = new Resource(context, baseProps as any, resourceOptions);\n } else {\n const { type: _t, apiVersion: _v, ...classProps } = baseProps;\n handle = new Ctor(context, classProps, resourceOptions);\n }\n\n if (authoring?.condition !== undefined) {\n const state = unwrapResourceHandle(handle) as unknown as Record<string, unknown>;\n state.condition = authoring.condition;\n }\n\n return handle;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction objBody(node: ExpressionNode): Record<string, ExpressionNode> | undefined {\n if (node.kind === \"object\") return node.value;\n if (node.kind === \"if-condition\") return objBody(node.body);\n if (node.kind === \"for-expression\") return objBody(node.body);\n return undefined;\n}\n\nfunction stemName(fileName: string): string {\n return fileName.replace(/\\.bicep$/, \"\");\n}\n"]}
1
+ {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/serialization/json/deserialize.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAsB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EACL,oBAAoB,EACpB,IAAI,EAEJ,QAAQ,GAIT,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE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EAA8E;AAE9E,SAAS,OAAO,CAAC,IAAoB;IACnC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Deserializes raw JSON (produced by `@azure/provisioning-core/serialization`) back into\n * live CDK `Stack` data structures.\n */\n\nimport { createOutput, type OutputValue } from \"../../constructs/output.js\";\nimport { createParameter } from \"../../constructs/parameter.js\";\nimport { createVariable, type VariableValue } from \"../../constructs/variable.js\";\nimport {\n createIndexedResourceProxy,\n unwrapResourceHandle,\n} from \"../../constructs/resource/resource-proxy.js\";\nimport { isResource, isLoopedResource } from \"../../constructs/resource/resource-utils.js\";\nimport {\n createLoopedResource,\n Loop,\n type LoopedResource,\n Resource,\n type ResourceDeclaration,\n type ResourceOptions,\n type ScopeExpression,\n} from \"../../constructs/resource/resource.js\";\nimport { Stack } from \"../../constructs/stack.js\";\nimport {\n wrapExpression,\n unwrapExpression,\n isExpression,\n type Expression,\n} from \"../../expression/expressions.js\";\nimport { namingRequiredPolicy } from \"../../naming/naming-policy.js\";\nimport { getShape } from \"../../shape/shape-registry.js\";\nimport {\n identifierExpressionNode,\n symbolicValueExpressionNode,\n} from \"../../expression/ast-nodes.js\";\nimport { resolveResource } from \"../../constructs/resource/resource-registry.js\";\nimport { type ProvisioningComponent } from \"../../constructs/provisioning-component.js\";\n\nimport {\n isPrimitiveTypeName,\n type ExpressionNode,\n type InfraNode,\n type ResourceDeclarationNode,\n type SerializationDocument,\n type VariableDeclarationNode,\n} from \"../ast/index.js\";\n\nimport { restoreExpression, type DeclarationReferenceMap } from \"../ast/expression-restorer.js\";\nimport { convertFromArmObject } from \"../arm-object-conversion.js\";\nimport { collectDependenciesForDeclaration } from \"../ast/declaration-dependencies.js\";\nimport { getScopeFunctionTarget } from \"../../expression/utils.js\";\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Options for {@link deserialize}.\n *\n * Controls whether unmatched `(type, apiVersion)` pairs fall back\n * to the highest registered version for the type (`strict: false`,\n * the default) or return a base `Resource` (`strict: true`).\n */\nexport interface DeserializeOptions {\n readonly strict?: boolean;\n}\n\n/**\n * Reconstructs stacks from the JSON text of a {@link SerializationDocument},\n * such as `JSON.stringify(serialize(stack))`. Returns one stack per `infras`\n * entry; the input must contain at least one.\n *\n * Import the relevant service packages before restoring to register their\n * resource classes; otherwise unregistered types use base resources.\n * Unsupported module declarations are rejected. A serialize/deserialize/\n * serialize cycle preserves supported deployment semantics and expressions,\n * though the resulting JSON need not be byte-for-byte identical.\n */\nexport function deserialize(raw: string, options?: DeserializeOptions): readonly Stack[] {\n // TODO(#330): .NET ModelReaderWriter still emits `contextual-variable` nodes\n // with `context` naming a zero-argument scope function (e.g. resourceGroup)\n // and `property` naming the accessed member (e.g. location). The generated\n // AST represents this as property-access over function-call instead.\n // Normalize at the JSON boundary, before dependency inspection or expression\n // restoration: AST walkers accept only the generated node kinds. The reviver\n // handles nested expressions too, while the container guards preserve extra\n // `kind` fields on documents, files, and declarations as ordinary metadata.\n // Remove this normalization once .NET emits the composed AST nodes directly.\n const doc = JSON.parse(raw, (_key, value: unknown) => {\n if (\n typeof value !== \"object\" ||\n value === null ||\n !(\"kind\" in value) ||\n value.kind !== \"contextual-variable\" ||\n \"bicepIdentifier\" in value ||\n \"fileName\" in value ||\n \"infras\" in value\n ) {\n return value;\n }\n if (\n !(\"context\" in value) ||\n typeof value.context !== \"string\" ||\n !(\"property\" in value) ||\n typeof value.property !== \"string\"\n ) {\n throw new Error(\n \"Invalid contextual-variable expression: context and property must be strings.\",\n );\n }\n return {\n kind: \"property-access\",\n base: { kind: \"function-call\", target: value.context, args: [] },\n property: value.property,\n nullish: false,\n } satisfies ExpressionNode;\n }) as SerializationDocument;\n if (doc.infras.length === 0) throw new Error(\"Empty SerializationDocument\");\n if (doc.infras.some((infra) => Object.keys(infra.modules ?? {}).length > 0)) {\n throw new Error(\"Module deserialization is not supported.\");\n }\n\n return constructStacks(doc.infras, options);\n}\n\n// ---------------------------------------------------------------------------\n// Type aliases\n// ---------------------------------------------------------------------------\n\ninterface LoopAuthoringContext {\n readonly collection: unknown;\n readonly itemVariable: string;\n readonly indexVariable?: string;\n readonly batchSize?: number;\n}\n\ninterface ResourceAuthoringContext {\n readonly condition?: Expression<boolean>;\n readonly loop?: LoopAuthoringContext;\n}\n\n// ---------------------------------------------------------------------------\n// Construction: InfraNode → CDK objects\n// ---------------------------------------------------------------------------\n\nfunction constructStacks(\n files: readonly InfraNode[],\n options: DeserializeOptions | undefined,\n): Stack[] {\n return files.map((file) => constructStack(file, options));\n}\n\nfunction constructStack(file: InfraNode, options: DeserializeOptions | undefined): Stack {\n const rootStack = new Stack(stemName(file.fileName), {\n targetScope: file.targetScope ?? \"resourceGroup\",\n namingPolicy: namingRequiredPolicy,\n });\n\n // Map stack-local identifiers to expression handles and resource declarations.\n const symbols: DeclarationReferenceMap = new Map();\n\n processParams(file, rootStack, symbols);\n processDeclarations(file, rootStack, symbols, options);\n processOutputs(file, rootStack, symbols);\n\n return rootStack;\n}\n\n// ---------------------------------------------------------------------------\n// Declaration processing\n// ---------------------------------------------------------------------------\n\nfunction assertSymbolAvailable(symbols: DeclarationReferenceMap, identifier: string): void {\n if (symbols.has(identifier)) {\n throw new Error(`Duplicate declaration identifier \"${identifier}\".`);\n }\n}\n\nfunction processParams(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeclarationReferenceMap,\n): void {\n for (const [, p] of Object.entries(file.parameters ?? {})) {\n assertSymbolAvailable(symbols, p.bicepIdentifier);\n if (p.valueType.kind !== \"primitive-type\" || !isPrimitiveTypeName(p.valueType.name)) {\n throw new Error(`Parameter \"${p.bicepIdentifier}\" has an unsupported non-primitive type.`);\n }\n const type = p.valueType.name;\n const sym = createParameter(stackHandle, p.bicepIdentifier, type, {\n ...(p.decorators?.description !== undefined ? { description: p.decorators.description } : {}),\n ...(p.decorators?.secure ? { secure: true } : {}),\n ...(p.defaultValue !== undefined\n ? {\n defaultValue: restoreExpression(p.defaultValue, new Map()) as string,\n }\n : {}),\n ...(p.decorators?.allowed?.length\n ? {\n allowed: p.decorators.allowed.map((a) =>\n restoreExpression(a, new Map()),\n ) as unknown as readonly string[],\n }\n : {}),\n ...(p.decorators?.minValue !== undefined ? { minValue: p.decorators.minValue } : {}),\n ...(p.decorators?.maxValue !== undefined ? { maxValue: p.decorators.maxValue } : {}),\n ...(p.decorators?.minLength !== undefined ? { minLength: p.decorators.minLength } : {}),\n ...(p.decorators?.maxLength !== undefined ? { maxLength: p.decorators.maxLength } : {}),\n ...(p.decorators?.metadata !== undefined\n ? {\n metadata: Object.fromEntries(\n Object.entries(p.decorators.metadata).map(([k, v]) => [\n k,\n restoreExpression(v, new Map()),\n ]),\n ) as Record<string, unknown>,\n }\n : {}),\n ...(p.decorators?.discriminator !== undefined\n ? { discriminator: p.decorators.discriminator }\n : {}),\n ...(p.decorators?.sealed ? { sealed: true } : {}),\n });\n symbols.set(p.bicepIdentifier, sym);\n }\n}\n\nfunction processDeclarations(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeclarationReferenceMap,\n options: DeserializeOptions | undefined,\n): void {\n type IndexedDeclaration =\n | { readonly kind: \"resource\"; readonly node: ResourceDeclarationNode }\n | { readonly kind: \"variable\"; readonly node: VariableDeclarationNode };\n const declarations = new Map<string, IndexedDeclaration>();\n\n function registerDeclaration(declaration: IndexedDeclaration): void {\n const { node } = declaration;\n assertSymbolAvailable(symbols, node.bicepIdentifier);\n const previous = declarations.get(node.bicepIdentifier);\n if (previous !== undefined) {\n const category =\n previous.kind === \"resource\" && declaration.kind === \"resource\"\n ? \"resource\"\n : \"declaration\";\n throw new Error(`Duplicate ${category} identifier \"${node.bicepIdentifier}\".`);\n }\n declarations.set(node.bicepIdentifier, declaration);\n }\n\n for (const node of Object.values(file.variables ?? {})) {\n registerDeclaration({ kind: \"variable\", node });\n }\n for (const node of Object.values(file.resources ?? {})) {\n registerDeclaration({ kind: \"resource\", node });\n }\n\n const pending: {\n declaration: IndexedDeclaration;\n dependencies: Iterator<string>;\n }[] = [];\n const active = new Map<string, number>();\n\n function pushDeclaration(declaration: IndexedDeclaration): void {\n const { node } = declaration;\n const identifiers = collectDependenciesForDeclaration(node);\n active.set(node.bicepIdentifier, pending.length);\n pending.push({ declaration, dependencies: identifiers.values() });\n }\n\n for (const declaration of declarations.values()) {\n if (symbols.has(declaration.node.bicepIdentifier)) continue;\n pushDeclaration(declaration);\n\n while (pending.length > 0) {\n const frame = pending[pending.length - 1]!;\n const dependency = frame.dependencies.next();\n if (!dependency.done) {\n if (symbols.has(dependency.value)) continue;\n const target = declarations.get(dependency.value);\n if (target === undefined) continue;\n const cycleStart = active.get(dependency.value);\n if (cycleStart !== undefined) {\n const cycle = pending.slice(cycleStart).map((entry) => entry.declaration);\n const category = cycle.every((entry) => entry.kind === \"resource\")\n ? \"Resource\"\n : \"Declaration\";\n const path = [...cycle.map((entry) => entry.node.bicepIdentifier), dependency.value]\n .map((identifier) => `\"${identifier}\"`)\n .join(\" -> \");\n throw new Error(`${category} dependency cycle detected: ${path}.`);\n }\n pushDeclaration(target);\n continue;\n }\n\n constructDeclaration(frame.declaration);\n active.delete(frame.declaration.node.bicepIdentifier);\n pending.pop();\n }\n }\n\n function constructDeclaration(declaration: IndexedDeclaration): void {\n if (declaration.kind === \"resource\") {\n symbols.set(\n declaration.node.bicepIdentifier,\n createResource(declaration.node, stackHandle, symbols, options),\n );\n return;\n }\n const { node } = declaration;\n const sym = createVariable(\n stackHandle,\n node.bicepIdentifier,\n restoreExpression(node.value, symbols) as VariableValue,\n {\n ...(node.decorators?.description !== undefined\n ? { description: node.decorators.description }\n : {}),\n ...(node.decorators?.export ? { export: true } : {}),\n },\n );\n symbols.set(node.bicepIdentifier, sym);\n }\n}\n\nfunction processOutputs(\n file: InfraNode,\n stackHandle: Stack,\n symbols: DeclarationReferenceMap,\n): void {\n for (const [, o] of Object.entries(file.outputs ?? {})) {\n if (o.valueType.kind !== \"primitive-type\") {\n throw new Error(\n `Cannot deserialize output \"${o.bicepIdentifier}\" with non-primitive type \"${o.valueType.kind}\".`,\n );\n }\n if (!isPrimitiveTypeName(o.valueType.name)) {\n throw new Error(\n `Cannot deserialize output \"${o.bicepIdentifier}\" with unknown primitive type \"${o.valueType.name}\".`,\n );\n }\n const val = restoreExpression(o.value, symbols) as OutputValue;\n createOutput(stackHandle, o.bicepIdentifier, o.valueType.name, val as OutputValue, {\n ...(o.decorators?.description !== undefined ? { description: o.decorators.description } : {}),\n ...(o.decorators?.secure ? { secure: true } : {}),\n ...(o.decorators?.minValue !== undefined ? { minValue: o.decorators.minValue } : {}),\n ...(o.decorators?.maxValue !== undefined ? { maxValue: o.decorators.maxValue } : {}),\n ...(o.decorators?.minLength !== undefined ? { minLength: o.decorators.minLength } : {}),\n ...(o.decorators?.maxLength !== undefined ? { maxLength: o.decorators.maxLength } : {}),\n ...(o.decorators?.metadata !== undefined\n ? {\n metadata: Object.fromEntries(\n Object.entries(o.decorators.metadata).map(([k, v]) => [\n k,\n restoreExpression(v, symbols),\n ]),\n ) as Record<string, unknown>,\n }\n : {}),\n ...(o.decorators?.discriminator !== undefined\n ? { discriminator: o.decorators.discriminator }\n : {}),\n ...(o.decorators?.sealed ? { sealed: true } : {}),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Resource construction\n// ---------------------------------------------------------------------------\n\nfunction resolveResourceReference(\n targetIdentifier: string,\n symbols: DeclarationReferenceMap,\n resourceIdentifier: string,\n field: \"parent\" | \"scope\" | \"dependsOn\",\n): Resource | LoopedResource<Resource> {\n const handle = symbols.get(targetIdentifier);\n if (handle === undefined) {\n throw new Error(\n `Resource \"${resourceIdentifier}\" references unknown resource ` +\n `\"${targetIdentifier}\" in \"${field}\".`,\n );\n }\n if (!isResource(handle) && !isLoopedResource(handle)) {\n throw new Error(\n `Resource \"${resourceIdentifier}\" references non-resource symbol ` +\n `\"${targetIdentifier}\" in \"${field}\".`,\n );\n }\n return handle;\n}\n\nfunction restoreResourceDependencies(\n node: ExpressionNode,\n symbols: DeclarationReferenceMap,\n resourceIdentifier: string,\n): readonly ResourceDeclaration[] {\n if (node.kind !== \"array\") {\n throw new Error(\n `Resource \"${resourceIdentifier}\" has an invalid \"dependsOn\" value; expected an array.`,\n );\n }\n return node.items.map((item) => {\n if (item.kind !== \"identifier\") {\n throw new Error(\n `Resource \"${resourceIdentifier}\" has an invalid \"dependsOn\" reference; expected a resource identifier.`,\n );\n }\n return resolveResourceReference(item.id, symbols, resourceIdentifier, \"dependsOn\");\n });\n}\n\nfunction createResource(\n res: ResourceDeclarationNode,\n defaultScope: Stack | Resource,\n symbols: DeclarationReferenceMap,\n options: DeserializeOptions | undefined,\n): Resource | LoopedResource<Resource> {\n // `res.value` is the wire body. Valid shapes are:\n // 1. object\n // 2. if-condition(object)\n // 3. for-expression(object)\n // 4. for-expression(if-condition(object))\n // Anything else (bare wrappers, if-outer-for-inner, multi-if, multi-for,\n // nested for-for, if-for-if, etc.) is malformed and rejected here.\n let wireBody: ExpressionNode = res.value;\n let loopWrapper:\n | {\n itemVariable: string;\n indexVariable?: string;\n collection: ExpressionNode;\n }\n | undefined;\n let conditionNode: ExpressionNode | undefined;\n\n if (wireBody.kind === \"for-expression\") {\n loopWrapper = {\n itemVariable: wireBody.itemVariable,\n ...(wireBody.indexVariable !== undefined ? { indexVariable: wireBody.indexVariable } : {}),\n collection: wireBody.collection,\n };\n wireBody = wireBody.body;\n }\n if (wireBody.kind === \"if-condition\") {\n conditionNode = wireBody.condition;\n wireBody = wireBody.body;\n }\n if (wireBody.kind !== \"object\") {\n throw new Error(\n `Invalid wire shape for resource \"${res.bicepIdentifier}\": ` +\n `\\`value\\` must be an \\`object\\`, optionally wrapped in ` +\n `\\`if-condition\\` and/or an outer \\`for-expression\\` (Bicep source ` +\n `order: \\`for\\` outer, \\`if\\` inner). Innermost node after peeling ` +\n `at most one \\`for-expression\\` and one \\`if-condition\\` is ` +\n `\\`${wireBody.kind}\\`.`,\n );\n }\n\n const scopedSymbols = loopWrapper === undefined ? symbols : new Map(symbols);\n const loopAuthoring: LoopAuthoringContext | undefined =\n loopWrapper !== undefined\n ? {\n collection: restoreExpression(loopWrapper.collection, symbols),\n itemVariable: loopWrapper.itemVariable,\n ...(loopWrapper.indexVariable !== undefined\n ? { indexVariable: loopWrapper.indexVariable }\n : {}),\n ...(res.decorators?.batchSize !== undefined\n ? { batchSize: res.decorators.batchSize }\n : {}),\n }\n : undefined;\n\n if (loopWrapper !== undefined) {\n scopedSymbols.set(\n loopWrapper.itemVariable,\n wrapExpression(symbolicValueExpressionNode(loopWrapper.itemVariable)),\n );\n if (loopWrapper.indexVariable !== undefined) {\n scopedSymbols.set(\n loopWrapper.indexVariable,\n wrapExpression(symbolicValueExpressionNode(loopWrapper.indexVariable)),\n );\n }\n }\n\n const authoring: ResourceAuthoringContext = {\n ...(conditionNode !== undefined\n ? {\n condition: restoreExpression(conditionNode, scopedSymbols) as Expression<boolean>,\n }\n : {}),\n ...(loopAuthoring !== undefined ? { loop: loopAuthoring } : {}),\n };\n\n return buildResource(\n res,\n objBody(res.value) ?? {},\n defaultScope,\n scopedSymbols,\n options,\n authoring,\n );\n}\n\nfunction buildResource(\n res: ResourceDeclarationNode,\n body: Record<string, ExpressionNode>,\n defaultScope: Stack | Resource,\n symbols: DeclarationReferenceMap,\n options: DeserializeOptions | undefined,\n authoring?: ResourceAuthoringContext,\n): Resource | LoopedResource<Resource> {\n let context: ProvisioningComponent = defaultScope;\n const parentNode = body[\"parent\"];\n const scopeNode = body[\"scope\"];\n if (\n parentNode !== undefined &&\n parentNode.kind !== \"identifier\" &&\n parentNode.kind !== \"array-access\"\n ) {\n throw new Error(`Resource \"${res.bicepIdentifier}\" has an invalid \"parent\" reference.`);\n }\n let relationship = parentNode;\n let relationshipKind: \"parent\" | \"scope\" = \"parent\";\n let resolvedScope = false;\n if (parentNode === undefined && scopeNode !== undefined) {\n const scopeTargetSymbolName =\n scopeNode.kind === \"identifier\"\n ? scopeNode.id\n : scopeNode.kind === \"array-access\" &&\n scopeNode.base.kind === \"identifier\" &&\n !scopeNode.nullish &&\n !scopeNode.fromEnd\n ? scopeNode.base.id\n : undefined;\n const scopeTarget =\n scopeTargetSymbolName === undefined ? undefined : symbols.get(scopeTargetSymbolName);\n if (scopeNode.kind === \"identifier\" && isLoopedResource(scopeTarget)) {\n throw new Error(\n `Resource \"${res.bicepIdentifier}\" references resource collection ` +\n `\"${scopeNode.id}\" in \"scope\"; expected a single resource.`,\n );\n }\n if (\n (scopeNode.kind === \"identifier\" && isResource(scopeTarget)) ||\n (scopeNode.kind === \"array-access\" &&\n isLoopedResource(scopeTarget) &&\n !scopeNode.nullish &&\n !scopeNode.fromEnd &&\n scopeNode.base.kind === \"identifier\")\n ) {\n relationship = scopeNode;\n relationshipKind = \"scope\";\n resolvedScope = true;\n }\n }\n if (relationship?.kind === \"identifier\") {\n context = resolveResourceReference(\n relationship.id,\n symbols,\n res.bicepIdentifier,\n relationshipKind,\n );\n } else if (relationship?.kind === \"array-access\") {\n // `parent: parentSym[<index>]` — the serializer emitted this because\n // the authoring code created the child under `parents.at(i)` /\n // `parents.current()`. To round-trip the shape, reconstruct the\n // indexed proxy so the base `Resource` ctor stashes\n // `state.parentIndex` from the same index expression. Passing the\n // raw parent here would erase the array-access — the child would\n // re-serialize as `parent: parentSym` and lose the index.\n const baseNode = relationship.base;\n if (baseNode.kind === \"identifier\") {\n const rawParent = resolveResourceReference(\n baseNode.id,\n symbols,\n res.bicepIdentifier,\n relationshipKind,\n );\n const indexValue = restoreExpression(relationship.index, symbols);\n context = createIndexedResourceProxy(\n rawParent,\n indexValue as number,\n ) as unknown as ProvisioningComponent;\n } else {\n throw new Error(`Resource \"${res.bicepIdentifier}\" has an invalid \"parent\" reference.`);\n }\n }\n\n let existingScope: ScopeExpression | undefined;\n let preservedScope: ScopeExpression | undefined;\n if (scopeNode !== undefined && !resolvedScope) {\n const value = restoreExpression(scopeNode, symbols);\n const scope = isResource(value) ? wrapExpression(identifierExpressionNode(value)) : value;\n if (!isExpression(scope)) {\n throw new Error(\n `Resource \"${res.bicepIdentifier}\" has an invalid \"scope\" value: ` +\n `expected an expression, received \"${scopeNode.kind}\".`,\n );\n }\n const currentStackScope =\n parentNode === undefined &&\n defaultScope instanceof Stack &&\n scopeNode.kind === \"function-call\" &&\n scopeNode.args.length === 0 &&\n getScopeFunctionTarget(scopeNode) === defaultScope.targetScope;\n if (res.existing && getScopeFunctionTarget(scopeNode) !== undefined) {\n existingScope = scope;\n } else if (!currentStackScope) {\n preservedScope = scope;\n }\n }\n\n // Collect non-reserved properties\n const RESERVED = new Set([\"name\", \"parent\", \"scope\", \"dependsOn\"]);\n const wireProps: Record<string, unknown> = Object.create(null);\n for (const [key, valNode] of Object.entries(body)) {\n if (!RESERVED.has(key)) {\n Object.defineProperty(wireProps, key, {\n value: restoreExpression(valNode, symbols),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n }\n\n // Raise wire-shape props into JS-shape when a descriptor is\n // registered for this resource type + apiVersion. No-op otherwise —\n // the resource stays in wire shape, which round-trips correctly\n // because re-serialization also skips lowering when no descriptor\n // is attached.\n const nameNode = body[\"name\"];\n const resourceName =\n nameNode === undefined ? \"unknown\" : (restoreExpression(nameNode, symbols) as string);\n const wireState = { name: resourceName, ...wireProps };\n const descriptor = getShape(res.type, res.apiVersion, wireState, {\n strict: options?.strict ?? false,\n valueKeyedBy: \"arm\",\n });\n const props = descriptor ? convertFromArmObject(wireProps, descriptor) : wireProps;\n\n const baseProps: Record<string, unknown> = {\n type: res.type,\n apiVersion: res.apiVersion,\n name: resourceName,\n ...(res.existing ? { existing: true } : {}),\n ...(existingScope !== undefined ? { scope: existingScope } : {}),\n ...props,\n };\n\n const resourceOptions: ResourceOptions = {\n ...(authoring?.condition !== undefined ? { condition: authoring.condition } : {}),\n ...(body.dependsOn !== undefined\n ? {\n dependsOn: restoreResourceDependencies(body.dependsOn, symbols, res.bicepIdentifier),\n }\n : {}),\n };\n\n // Look up a registered class for this (type, apiVersion). If one\n // exists, construct it directly so the resulting handle has the right\n // prototype, instance fields, and `instanceof` identity. The class\n // constructor sets `type` and\n // `apiVersion` itself, so strip them before forwarding. Fall back to\n // base `Resource` when no class is registered (unknown type or\n // tree-shaken/missing class module). The `{ name }` lookup state lets\n // the registry pick the right variant for ARM-discriminated types\n // (e.g. `Microsoft.ApiManagement/service/portalsettings` keyed by\n // singleton name). By default the registry does a best-effort match\n // — an unknown apiVersion falls back to the highest registered\n // version for the same `(type, channel)`. Callers can pass\n // `{ strict: true }` on `deserialize` to require an\n // exact `(type, apiVersion)` match instead.\n const Ctor = resolveResource(res.type, res.apiVersion, wireState, options);\n\n let handle: Resource | LoopedResource<Resource>;\n if (authoring?.loop !== undefined) {\n // Looped path: construct a `LoopedResource` directly. Build a fresh\n // `Loop` from the peeled wire metadata; `Resource.fromLoop` reads\n // `.collection`, `.itemVariable`, `.indexRequested`, `.indexVariable`,\n // and `.batchSize` off it. Passing the itemVariable/indexVariable\n // explicitly keeps the wire name (rather than the \"item\"/\"i\" default)\n // and, since supplying `{ indexVariable }` counts as a request,\n // preserves the index binding on re-serialize.\n const loopInstance = new Loop(authoring.loop.collection as unknown as unknown[], {\n itemVariable: authoring.loop.itemVariable,\n ...(authoring.loop.indexVariable !== undefined\n ? { indexVariable: authoring.loop.indexVariable }\n : {}),\n ...(authoring.loop.batchSize !== undefined ? { batchSize: authoring.loop.batchSize } : {}),\n });\n // Base `Resource` is the fallback when no subclass is registered.\n // `LoopedResource`'s ctor accepts type/apiVersion from `userProps`\n // when the ctor's own statics are undefined (as they are on base\n // `Resource`), so this path threads the wire values through\n // `baseProps`.\n const CtorToUse = Ctor ?? Resource;\n handle = createLoopedResource(\n CtorToUse as new (\n context: ProvisioningComponent,\n props: unknown,\n options?: ResourceOptions,\n ) => Resource,\n loopInstance,\n context,\n baseProps,\n resourceOptions,\n );\n } else if (Ctor === undefined) {\n handle = new Resource(context, baseProps as any, resourceOptions);\n } else {\n const { type: _t, apiVersion: _v, ...classProps } = baseProps;\n handle = new Ctor(context, classProps, resourceOptions);\n }\n\n if (authoring?.condition !== undefined) {\n const state = unwrapResourceHandle(handle) as unknown as Record<string, unknown>;\n state.condition = authoring.condition;\n }\n if (preservedScope !== undefined) {\n Object.defineProperty(unwrapResourceHandle(handle), \"scope\", {\n value: unwrapExpression(preservedScope),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n\n return handle;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction objBody(node: ExpressionNode): Record<string, ExpressionNode> | undefined {\n if (node.kind === \"object\") return node.value;\n if (node.kind === \"if-condition\") return objBody(node.body);\n if (node.kind === \"for-expression\") return objBody(node.body);\n return undefined;\n}\n\nfunction stemName(fileName: string): string {\n return fileName.replace(/\\.bicep$/, \"\");\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Stack } from "../../constructs/stack.js";
2
- import type { SerializationDocument } from "../contract/index.js";
2
+ import type { SerializationDocument } from "../ast/index.js";
3
3
  /**
4
4
  * Serializes a stack or a nonempty array of stacks into a JSON-compatible
5
5
  * {@link SerializationDocument} with one `infras` entry per stack.
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../src/serialization/json/serialize.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAgBvD,OAAO,KAAK,EAQV,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AA4b9B;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,GAAG,qBAAqB,CAahF"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../src/serialization/json/serialize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,KAAK,EAAa,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAgBxE;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,GAAG,qBAAqB,CAahF"}