@azure/provisioning-core 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +40 -0
  4. package/dist/browser/constructs/built-in-resources/resource-group.d.ts +50 -0
  5. package/dist/browser/constructs/built-in-resources/resource-group.d.ts.map +1 -0
  6. package/dist/browser/constructs/built-in-resources/resource-group.js +100 -0
  7. package/dist/browser/constructs/built-in-resources/resource-group.js.map +1 -0
  8. package/dist/browser/constructs/output.d.ts +80 -0
  9. package/dist/browser/constructs/output.d.ts.map +1 -0
  10. package/dist/browser/constructs/output.js +75 -0
  11. package/dist/browser/constructs/output.js.map +1 -0
  12. package/dist/browser/constructs/parameter.d.ts +77 -0
  13. package/dist/browser/constructs/parameter.d.ts.map +1 -0
  14. package/dist/browser/constructs/parameter.js +93 -0
  15. package/dist/browser/constructs/parameter.js.map +1 -0
  16. package/dist/browser/constructs/provisioning-component.d.ts +91 -0
  17. package/dist/browser/constructs/provisioning-component.d.ts.map +1 -0
  18. package/dist/browser/constructs/provisioning-component.js +150 -0
  19. package/dist/browser/constructs/provisioning-component.js.map +1 -0
  20. package/dist/browser/constructs/resource/resource-proxy.d.ts +134 -0
  21. package/dist/browser/constructs/resource/resource-proxy.d.ts.map +1 -0
  22. package/dist/browser/constructs/resource/resource-proxy.js +517 -0
  23. package/dist/browser/constructs/resource/resource-proxy.js.map +1 -0
  24. package/dist/browser/constructs/resource/resource-query.d.ts +23 -0
  25. package/dist/browser/constructs/resource/resource-query.d.ts.map +1 -0
  26. package/dist/browser/constructs/resource/resource-query.js +69 -0
  27. package/dist/browser/constructs/resource/resource-query.js.map +1 -0
  28. package/dist/browser/constructs/resource/resource-registry.d.ts +99 -0
  29. package/dist/browser/constructs/resource/resource-registry.d.ts.map +1 -0
  30. package/dist/browser/constructs/resource/resource-registry.js +51 -0
  31. package/dist/browser/constructs/resource/resource-registry.js.map +1 -0
  32. package/dist/browser/constructs/resource/resource-type-registry.d.ts +46 -0
  33. package/dist/browser/constructs/resource/resource-type-registry.d.ts.map +1 -0
  34. package/dist/browser/constructs/resource/resource-type-registry.js +156 -0
  35. package/dist/browser/constructs/resource/resource-type-registry.js.map +1 -0
  36. package/dist/browser/constructs/resource/resource-utils.d.ts +60 -0
  37. package/dist/browser/constructs/resource/resource-utils.d.ts.map +1 -0
  38. package/dist/browser/constructs/resource/resource-utils.js +75 -0
  39. package/dist/browser/constructs/resource/resource-utils.js.map +1 -0
  40. package/dist/browser/constructs/resource/resource.d.ts +460 -0
  41. package/dist/browser/constructs/resource/resource.d.ts.map +1 -0
  42. package/dist/browser/constructs/resource/resource.js +582 -0
  43. package/dist/browser/constructs/resource/resource.js.map +1 -0
  44. package/dist/browser/constructs/stack.d.ts +110 -0
  45. package/dist/browser/constructs/stack.d.ts.map +1 -0
  46. package/dist/browser/constructs/stack.js +110 -0
  47. package/dist/browser/constructs/stack.js.map +1 -0
  48. package/dist/browser/constructs/variable.d.ts +63 -0
  49. package/dist/browser/constructs/variable.d.ts.map +1 -0
  50. package/dist/browser/constructs/variable.js +74 -0
  51. package/dist/browser/constructs/variable.js.map +1 -0
  52. package/dist/browser/deployment-context/deployment-context.d.ts +27 -0
  53. package/dist/browser/deployment-context/deployment-context.d.ts.map +1 -0
  54. package/dist/browser/deployment-context/deployment-context.js +4 -0
  55. package/dist/browser/deployment-context/deployment-context.js.map +1 -0
  56. package/dist/browser/expression/ast-nodes.d.ts +100 -0
  57. package/dist/browser/expression/ast-nodes.d.ts.map +1 -0
  58. package/dist/browser/expression/ast-nodes.js +125 -0
  59. package/dist/browser/expression/ast-nodes.js.map +1 -0
  60. package/dist/browser/expression/expressions.d.ts +164 -0
  61. package/dist/browser/expression/expressions.d.ts.map +1 -0
  62. package/dist/browser/expression/expressions.js +211 -0
  63. package/dist/browser/expression/expressions.js.map +1 -0
  64. package/dist/browser/fn.d.ts +194 -0
  65. package/dist/browser/fn.d.ts.map +1 -0
  66. package/dist/browser/fn.js +334 -0
  67. package/dist/browser/fn.js.map +1 -0
  68. package/dist/browser/index.d.ts +25 -0
  69. package/dist/browser/index.d.ts.map +1 -0
  70. package/dist/browser/index.js +17 -0
  71. package/dist/browser/index.js.map +1 -0
  72. package/dist/browser/internal.d.ts +13 -0
  73. package/dist/browser/internal.d.ts.map +1 -0
  74. package/dist/browser/internal.js +10 -0
  75. package/dist/browser/internal.js.map +1 -0
  76. package/dist/browser/naming/naming-policy.d.ts +56 -0
  77. package/dist/browser/naming/naming-policy.d.ts.map +1 -0
  78. package/dist/browser/naming/naming-policy.js +97 -0
  79. package/dist/browser/naming/naming-policy.js.map +1 -0
  80. package/dist/browser/naming/naming-rules.d.ts +15 -0
  81. package/dist/browser/naming/naming-rules.d.ts.map +1 -0
  82. package/dist/browser/naming/naming-rules.js +15 -0
  83. package/dist/browser/naming/naming-rules.js.map +1 -0
  84. package/dist/browser/package.json +8 -0
  85. package/dist/browser/serialization/contract/generated/ast.d.ts +508 -0
  86. package/dist/browser/serialization/contract/generated/ast.d.ts.map +1 -0
  87. package/dist/browser/serialization/contract/generated/ast.js +23 -0
  88. package/dist/browser/serialization/contract/generated/ast.js.map +1 -0
  89. package/dist/browser/serialization/contract/index.d.ts +2 -0
  90. package/dist/browser/serialization/contract/index.d.ts.map +1 -0
  91. package/dist/browser/serialization/contract/index.js +4 -0
  92. package/dist/browser/serialization/contract/index.js.map +1 -0
  93. package/dist/browser/serialization/index.d.ts +4 -0
  94. package/dist/browser/serialization/index.d.ts.map +1 -0
  95. package/dist/browser/serialization/index.js +5 -0
  96. package/dist/browser/serialization/index.js.map +1 -0
  97. package/dist/browser/serialization/json/deserialize.d.ts +24 -0
  98. package/dist/browser/serialization/json/deserialize.d.ts.map +1 -0
  99. package/dist/browser/serialization/json/deserialize.js +437 -0
  100. package/dist/browser/serialization/json/deserialize.js.map +1 -0
  101. package/dist/browser/serialization/json/encoding.d.ts +4 -0
  102. package/dist/browser/serialization/json/encoding.d.ts.map +1 -0
  103. package/dist/browser/serialization/json/encoding.js +319 -0
  104. package/dist/browser/serialization/json/encoding.js.map +1 -0
  105. package/dist/browser/serialization/json/expression.d.ts +32 -0
  106. package/dist/browser/serialization/json/expression.d.ts.map +1 -0
  107. package/dist/browser/serialization/json/expression.js +494 -0
  108. package/dist/browser/serialization/json/expression.js.map +1 -0
  109. package/dist/browser/serialization/json/lower.d.ts +41 -0
  110. package/dist/browser/serialization/json/lower.d.ts.map +1 -0
  111. package/dist/browser/serialization/json/lower.js +334 -0
  112. package/dist/browser/serialization/json/lower.js.map +1 -0
  113. package/dist/browser/serialization/json/pluralize-config.d.ts +3 -0
  114. package/dist/browser/serialization/json/pluralize-config.d.ts.map +1 -0
  115. package/dist/browser/serialization/json/pluralize-config.js +7 -0
  116. package/dist/browser/serialization/json/pluralize-config.js.map +1 -0
  117. package/dist/browser/serialization/json/serialize.d.ts +12 -0
  118. package/dist/browser/serialization/json/serialize.d.ts.map +1 -0
  119. package/dist/browser/serialization/json/serialize.js +389 -0
  120. package/dist/browser/serialization/json/serialize.js.map +1 -0
  121. package/dist/browser/serialization/json/util.d.ts +2 -0
  122. package/dist/browser/serialization/json/util.d.ts.map +1 -0
  123. package/dist/browser/serialization/json/util.js +19 -0
  124. package/dist/browser/serialization/json/util.js.map +1 -0
  125. package/dist/browser/serialization/utils.d.ts +3 -0
  126. package/dist/browser/serialization/utils.d.ts.map +1 -0
  127. package/dist/browser/serialization/utils.js +146 -0
  128. package/dist/browser/serialization/utils.js.map +1 -0
  129. package/dist/browser/shape/shape-registry.d.ts +51 -0
  130. package/dist/browser/shape/shape-registry.d.ts.map +1 -0
  131. package/dist/browser/shape/shape-registry.js +41 -0
  132. package/dist/browser/shape/shape-registry.js.map +1 -0
  133. package/dist/browser/shape/shape.d.ts +407 -0
  134. package/dist/browser/shape/shape.d.ts.map +1 -0
  135. package/dist/browser/shape/shape.js +424 -0
  136. package/dist/browser/shape/shape.js.map +1 -0
  137. package/dist/browser/shape/value-encoding.d.ts +121 -0
  138. package/dist/browser/shape/value-encoding.d.ts.map +1 -0
  139. package/dist/browser/shape/value-encoding.js +32 -0
  140. package/dist/browser/shape/value-encoding.js.map +1 -0
  141. package/dist/browser/types.d.ts +9 -0
  142. package/dist/browser/types.d.ts.map +1 -0
  143. package/dist/browser/types.js +4 -0
  144. package/dist/browser/types.js.map +1 -0
  145. package/dist/browser/util.d.ts +33 -0
  146. package/dist/browser/util.d.ts.map +1 -0
  147. package/dist/browser/util.js +74 -0
  148. package/dist/browser/util.js.map +1 -0
  149. package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts +50 -0
  150. package/dist/commonjs/constructs/built-in-resources/resource-group.d.ts.map +1 -0
  151. package/dist/commonjs/constructs/built-in-resources/resource-group.js +114 -0
  152. package/dist/commonjs/constructs/built-in-resources/resource-group.js.map +7 -0
  153. package/dist/commonjs/constructs/output.d.ts +80 -0
  154. package/dist/commonjs/constructs/output.d.ts.map +1 -0
  155. package/dist/commonjs/constructs/output.js +75 -0
  156. package/dist/commonjs/constructs/output.js.map +7 -0
  157. package/dist/commonjs/constructs/parameter.d.ts +77 -0
  158. package/dist/commonjs/constructs/parameter.d.ts.map +1 -0
  159. package/dist/commonjs/constructs/parameter.js +95 -0
  160. package/dist/commonjs/constructs/parameter.js.map +7 -0
  161. package/dist/commonjs/constructs/provisioning-component.d.ts +91 -0
  162. package/dist/commonjs/constructs/provisioning-component.d.ts.map +1 -0
  163. package/dist/commonjs/constructs/provisioning-component.js +130 -0
  164. package/dist/commonjs/constructs/provisioning-component.js.map +7 -0
  165. package/dist/commonjs/constructs/resource/resource-proxy.d.ts +134 -0
  166. package/dist/commonjs/constructs/resource/resource-proxy.d.ts.map +1 -0
  167. package/dist/commonjs/constructs/resource/resource-proxy.js +456 -0
  168. package/dist/commonjs/constructs/resource/resource-proxy.js.map +7 -0
  169. package/dist/commonjs/constructs/resource/resource-query.d.ts +23 -0
  170. package/dist/commonjs/constructs/resource/resource-query.d.ts.map +1 -0
  171. package/dist/commonjs/constructs/resource/resource-query.js +68 -0
  172. package/dist/commonjs/constructs/resource/resource-query.js.map +7 -0
  173. package/dist/commonjs/constructs/resource/resource-registry.d.ts +99 -0
  174. package/dist/commonjs/constructs/resource/resource-registry.d.ts.map +1 -0
  175. package/dist/commonjs/constructs/resource/resource-registry.js +49 -0
  176. package/dist/commonjs/constructs/resource/resource-registry.js.map +7 -0
  177. package/dist/commonjs/constructs/resource/resource-type-registry.d.ts +46 -0
  178. package/dist/commonjs/constructs/resource/resource-type-registry.d.ts.map +1 -0
  179. package/dist/commonjs/constructs/resource/resource-type-registry.js +178 -0
  180. package/dist/commonjs/constructs/resource/resource-type-registry.js.map +7 -0
  181. package/dist/commonjs/constructs/resource/resource-utils.d.ts +60 -0
  182. package/dist/commonjs/constructs/resource/resource-utils.d.ts.map +1 -0
  183. package/dist/commonjs/constructs/resource/resource-utils.js +51 -0
  184. package/dist/commonjs/constructs/resource/resource-utils.js.map +7 -0
  185. package/dist/commonjs/constructs/resource/resource.d.ts +460 -0
  186. package/dist/commonjs/constructs/resource/resource.d.ts.map +1 -0
  187. package/dist/commonjs/constructs/resource/resource.js +455 -0
  188. package/dist/commonjs/constructs/resource/resource.js.map +7 -0
  189. package/dist/commonjs/constructs/stack.d.ts +110 -0
  190. package/dist/commonjs/constructs/stack.d.ts.map +1 -0
  191. package/dist/commonjs/constructs/stack.js +101 -0
  192. package/dist/commonjs/constructs/stack.js.map +7 -0
  193. package/dist/commonjs/constructs/variable.d.ts +63 -0
  194. package/dist/commonjs/constructs/variable.d.ts.map +1 -0
  195. package/dist/commonjs/constructs/variable.js +85 -0
  196. package/dist/commonjs/constructs/variable.js.map +7 -0
  197. package/dist/commonjs/deployment-context/deployment-context.d.ts +27 -0
  198. package/dist/commonjs/deployment-context/deployment-context.d.ts.map +1 -0
  199. package/dist/commonjs/deployment-context/deployment-context.js +16 -0
  200. package/dist/commonjs/deployment-context/deployment-context.js.map +7 -0
  201. package/dist/commonjs/expression/ast-nodes.d.ts +100 -0
  202. package/dist/commonjs/expression/ast-nodes.d.ts.map +1 -0
  203. package/dist/commonjs/expression/ast-nodes.js +152 -0
  204. package/dist/commonjs/expression/ast-nodes.js.map +7 -0
  205. package/dist/commonjs/expression/expressions.d.ts +164 -0
  206. package/dist/commonjs/expression/expressions.d.ts.map +1 -0
  207. package/dist/commonjs/expression/expressions.js +171 -0
  208. package/dist/commonjs/expression/expressions.js.map +7 -0
  209. package/dist/commonjs/fn.d.ts +194 -0
  210. package/dist/commonjs/fn.d.ts.map +1 -0
  211. package/dist/commonjs/fn.js +382 -0
  212. package/dist/commonjs/fn.js.map +7 -0
  213. package/dist/commonjs/index.d.ts +25 -0
  214. package/dist/commonjs/index.d.ts.map +1 -0
  215. package/dist/commonjs/index.js +93 -0
  216. package/dist/commonjs/index.js.map +7 -0
  217. package/dist/commonjs/internal.d.ts +13 -0
  218. package/dist/commonjs/internal.d.ts.map +1 -0
  219. package/dist/commonjs/internal.js +88 -0
  220. package/dist/commonjs/internal.js.map +7 -0
  221. package/dist/commonjs/naming/naming-policy.d.ts +56 -0
  222. package/dist/commonjs/naming/naming-policy.d.ts.map +1 -0
  223. package/dist/commonjs/naming/naming-policy.js +99 -0
  224. package/dist/commonjs/naming/naming-policy.js.map +7 -0
  225. package/dist/commonjs/naming/naming-rules.d.ts +15 -0
  226. package/dist/commonjs/naming/naming-rules.d.ts.map +1 -0
  227. package/dist/commonjs/naming/naming-rules.js +39 -0
  228. package/dist/commonjs/naming/naming-rules.js.map +7 -0
  229. package/dist/commonjs/package.json +8 -0
  230. package/dist/commonjs/serialization/contract/generated/ast.d.ts +508 -0
  231. package/dist/commonjs/serialization/contract/generated/ast.d.ts.map +1 -0
  232. package/dist/commonjs/serialization/contract/generated/ast.js +40 -0
  233. package/dist/commonjs/serialization/contract/generated/ast.js.map +7 -0
  234. package/dist/commonjs/serialization/contract/index.d.ts +2 -0
  235. package/dist/commonjs/serialization/contract/index.d.ts.map +1 -0
  236. package/dist/commonjs/serialization/contract/index.js +22 -0
  237. package/dist/commonjs/serialization/contract/index.js.map +7 -0
  238. package/dist/commonjs/serialization/index.d.ts +4 -0
  239. package/dist/commonjs/serialization/index.d.ts.map +1 -0
  240. package/dist/commonjs/serialization/index.js +31 -0
  241. package/dist/commonjs/serialization/index.js.map +7 -0
  242. package/dist/commonjs/serialization/json/deserialize.d.ts +24 -0
  243. package/dist/commonjs/serialization/json/deserialize.d.ts.map +1 -0
  244. package/dist/commonjs/serialization/json/deserialize.js +385 -0
  245. package/dist/commonjs/serialization/json/deserialize.js.map +7 -0
  246. package/dist/commonjs/serialization/json/encoding.d.ts +4 -0
  247. package/dist/commonjs/serialization/json/encoding.d.ts.map +1 -0
  248. package/dist/commonjs/serialization/json/encoding.js +306 -0
  249. package/dist/commonjs/serialization/json/encoding.js.map +7 -0
  250. package/dist/commonjs/serialization/json/expression.d.ts +32 -0
  251. package/dist/commonjs/serialization/json/expression.d.ts.map +1 -0
  252. package/dist/commonjs/serialization/json/expression.js +509 -0
  253. package/dist/commonjs/serialization/json/expression.js.map +7 -0
  254. package/dist/commonjs/serialization/json/lower.d.ts +41 -0
  255. package/dist/commonjs/serialization/json/lower.d.ts.map +1 -0
  256. package/dist/commonjs/serialization/json/lower.js +272 -0
  257. package/dist/commonjs/serialization/json/lower.js.map +7 -0
  258. package/dist/commonjs/serialization/json/pluralize-config.d.ts +3 -0
  259. package/dist/commonjs/serialization/json/pluralize-config.d.ts.map +1 -0
  260. package/dist/commonjs/serialization/json/pluralize-config.js +37 -0
  261. package/dist/commonjs/serialization/json/pluralize-config.js.map +7 -0
  262. package/dist/commonjs/serialization/json/serialize.d.ts +12 -0
  263. package/dist/commonjs/serialization/json/serialize.d.ts.map +1 -0
  264. package/dist/commonjs/serialization/json/serialize.js +352 -0
  265. package/dist/commonjs/serialization/json/serialize.js.map +7 -0
  266. package/dist/commonjs/serialization/json/util.d.ts +2 -0
  267. package/dist/commonjs/serialization/json/util.d.ts.map +1 -0
  268. package/dist/commonjs/serialization/json/util.js +37 -0
  269. package/dist/commonjs/serialization/json/util.js.map +7 -0
  270. package/dist/commonjs/serialization/utils.d.ts +3 -0
  271. package/dist/commonjs/serialization/utils.d.ts.map +1 -0
  272. package/dist/commonjs/serialization/utils.js +169 -0
  273. package/dist/commonjs/serialization/utils.js.map +7 -0
  274. package/dist/commonjs/shape/shape-registry.d.ts +51 -0
  275. package/dist/commonjs/shape/shape-registry.d.ts.map +1 -0
  276. package/dist/commonjs/shape/shape-registry.js +40 -0
  277. package/dist/commonjs/shape/shape-registry.js.map +7 -0
  278. package/dist/commonjs/shape/shape.d.ts +407 -0
  279. package/dist/commonjs/shape/shape.d.ts.map +1 -0
  280. package/dist/commonjs/shape/shape.js +290 -0
  281. package/dist/commonjs/shape/shape.js.map +7 -0
  282. package/dist/commonjs/shape/value-encoding.d.ts +121 -0
  283. package/dist/commonjs/shape/value-encoding.d.ts.map +1 -0
  284. package/dist/commonjs/shape/value-encoding.js +62 -0
  285. package/dist/commonjs/shape/value-encoding.js.map +7 -0
  286. package/dist/commonjs/tsdoc-metadata.json +11 -0
  287. package/dist/commonjs/types.d.ts +9 -0
  288. package/dist/commonjs/types.d.ts.map +1 -0
  289. package/dist/commonjs/types.js +16 -0
  290. package/dist/commonjs/types.js.map +7 -0
  291. package/dist/commonjs/util.d.ts +33 -0
  292. package/dist/commonjs/util.d.ts.map +1 -0
  293. package/dist/commonjs/util.js +73 -0
  294. package/dist/commonjs/util.js.map +7 -0
  295. package/dist/esm/constructs/built-in-resources/resource-group.d.ts +50 -0
  296. package/dist/esm/constructs/built-in-resources/resource-group.d.ts.map +1 -0
  297. package/dist/esm/constructs/built-in-resources/resource-group.js +100 -0
  298. package/dist/esm/constructs/built-in-resources/resource-group.js.map +1 -0
  299. package/dist/esm/constructs/output.d.ts +80 -0
  300. package/dist/esm/constructs/output.d.ts.map +1 -0
  301. package/dist/esm/constructs/output.js +75 -0
  302. package/dist/esm/constructs/output.js.map +1 -0
  303. package/dist/esm/constructs/parameter.d.ts +77 -0
  304. package/dist/esm/constructs/parameter.d.ts.map +1 -0
  305. package/dist/esm/constructs/parameter.js +93 -0
  306. package/dist/esm/constructs/parameter.js.map +1 -0
  307. package/dist/esm/constructs/provisioning-component.d.ts +91 -0
  308. package/dist/esm/constructs/provisioning-component.d.ts.map +1 -0
  309. package/dist/esm/constructs/provisioning-component.js +150 -0
  310. package/dist/esm/constructs/provisioning-component.js.map +1 -0
  311. package/dist/esm/constructs/resource/resource-proxy.d.ts +134 -0
  312. package/dist/esm/constructs/resource/resource-proxy.d.ts.map +1 -0
  313. package/dist/esm/constructs/resource/resource-proxy.js +517 -0
  314. package/dist/esm/constructs/resource/resource-proxy.js.map +1 -0
  315. package/dist/esm/constructs/resource/resource-query.d.ts +23 -0
  316. package/dist/esm/constructs/resource/resource-query.d.ts.map +1 -0
  317. package/dist/esm/constructs/resource/resource-query.js +69 -0
  318. package/dist/esm/constructs/resource/resource-query.js.map +1 -0
  319. package/dist/esm/constructs/resource/resource-registry.d.ts +99 -0
  320. package/dist/esm/constructs/resource/resource-registry.d.ts.map +1 -0
  321. package/dist/esm/constructs/resource/resource-registry.js +51 -0
  322. package/dist/esm/constructs/resource/resource-registry.js.map +1 -0
  323. package/dist/esm/constructs/resource/resource-type-registry.d.ts +46 -0
  324. package/dist/esm/constructs/resource/resource-type-registry.d.ts.map +1 -0
  325. package/dist/esm/constructs/resource/resource-type-registry.js +156 -0
  326. package/dist/esm/constructs/resource/resource-type-registry.js.map +1 -0
  327. package/dist/esm/constructs/resource/resource-utils.d.ts +60 -0
  328. package/dist/esm/constructs/resource/resource-utils.d.ts.map +1 -0
  329. package/dist/esm/constructs/resource/resource-utils.js +75 -0
  330. package/dist/esm/constructs/resource/resource-utils.js.map +1 -0
  331. package/dist/esm/constructs/resource/resource.d.ts +460 -0
  332. package/dist/esm/constructs/resource/resource.d.ts.map +1 -0
  333. package/dist/esm/constructs/resource/resource.js +582 -0
  334. package/dist/esm/constructs/resource/resource.js.map +1 -0
  335. package/dist/esm/constructs/stack.d.ts +110 -0
  336. package/dist/esm/constructs/stack.d.ts.map +1 -0
  337. package/dist/esm/constructs/stack.js +110 -0
  338. package/dist/esm/constructs/stack.js.map +1 -0
  339. package/dist/esm/constructs/variable.d.ts +63 -0
  340. package/dist/esm/constructs/variable.d.ts.map +1 -0
  341. package/dist/esm/constructs/variable.js +74 -0
  342. package/dist/esm/constructs/variable.js.map +1 -0
  343. package/dist/esm/deployment-context/deployment-context.d.ts +27 -0
  344. package/dist/esm/deployment-context/deployment-context.d.ts.map +1 -0
  345. package/dist/esm/deployment-context/deployment-context.js +4 -0
  346. package/dist/esm/deployment-context/deployment-context.js.map +1 -0
  347. package/dist/esm/expression/ast-nodes.d.ts +100 -0
  348. package/dist/esm/expression/ast-nodes.d.ts.map +1 -0
  349. package/dist/esm/expression/ast-nodes.js +125 -0
  350. package/dist/esm/expression/ast-nodes.js.map +1 -0
  351. package/dist/esm/expression/expressions.d.ts +164 -0
  352. package/dist/esm/expression/expressions.d.ts.map +1 -0
  353. package/dist/esm/expression/expressions.js +211 -0
  354. package/dist/esm/expression/expressions.js.map +1 -0
  355. package/dist/esm/fn.d.ts +194 -0
  356. package/dist/esm/fn.d.ts.map +1 -0
  357. package/dist/esm/fn.js +334 -0
  358. package/dist/esm/fn.js.map +1 -0
  359. package/dist/esm/index.d.ts +25 -0
  360. package/dist/esm/index.d.ts.map +1 -0
  361. package/dist/esm/index.js +17 -0
  362. package/dist/esm/index.js.map +1 -0
  363. package/dist/esm/internal.d.ts +13 -0
  364. package/dist/esm/internal.d.ts.map +1 -0
  365. package/dist/esm/internal.js +10 -0
  366. package/dist/esm/internal.js.map +1 -0
  367. package/dist/esm/naming/naming-policy.d.ts +56 -0
  368. package/dist/esm/naming/naming-policy.d.ts.map +1 -0
  369. package/dist/esm/naming/naming-policy.js +97 -0
  370. package/dist/esm/naming/naming-policy.js.map +1 -0
  371. package/dist/esm/naming/naming-rules.d.ts +15 -0
  372. package/dist/esm/naming/naming-rules.d.ts.map +1 -0
  373. package/dist/esm/naming/naming-rules.js +15 -0
  374. package/dist/esm/naming/naming-rules.js.map +1 -0
  375. package/dist/esm/package.json +8 -0
  376. package/dist/esm/serialization/contract/generated/ast.d.ts +508 -0
  377. package/dist/esm/serialization/contract/generated/ast.d.ts.map +1 -0
  378. package/dist/esm/serialization/contract/generated/ast.js +23 -0
  379. package/dist/esm/serialization/contract/generated/ast.js.map +1 -0
  380. package/dist/esm/serialization/contract/index.d.ts +2 -0
  381. package/dist/esm/serialization/contract/index.d.ts.map +1 -0
  382. package/dist/esm/serialization/contract/index.js +4 -0
  383. package/dist/esm/serialization/contract/index.js.map +1 -0
  384. package/dist/esm/serialization/index.d.ts +4 -0
  385. package/dist/esm/serialization/index.d.ts.map +1 -0
  386. package/dist/esm/serialization/index.js +5 -0
  387. package/dist/esm/serialization/index.js.map +1 -0
  388. package/dist/esm/serialization/json/deserialize.d.ts +24 -0
  389. package/dist/esm/serialization/json/deserialize.d.ts.map +1 -0
  390. package/dist/esm/serialization/json/deserialize.js +437 -0
  391. package/dist/esm/serialization/json/deserialize.js.map +1 -0
  392. package/dist/esm/serialization/json/encoding.d.ts +4 -0
  393. package/dist/esm/serialization/json/encoding.d.ts.map +1 -0
  394. package/dist/esm/serialization/json/encoding.js +319 -0
  395. package/dist/esm/serialization/json/encoding.js.map +1 -0
  396. package/dist/esm/serialization/json/expression.d.ts +32 -0
  397. package/dist/esm/serialization/json/expression.d.ts.map +1 -0
  398. package/dist/esm/serialization/json/expression.js +494 -0
  399. package/dist/esm/serialization/json/expression.js.map +1 -0
  400. package/dist/esm/serialization/json/lower.d.ts +41 -0
  401. package/dist/esm/serialization/json/lower.d.ts.map +1 -0
  402. package/dist/esm/serialization/json/lower.js +334 -0
  403. package/dist/esm/serialization/json/lower.js.map +1 -0
  404. package/dist/esm/serialization/json/pluralize-config.d.ts +3 -0
  405. package/dist/esm/serialization/json/pluralize-config.d.ts.map +1 -0
  406. package/dist/esm/serialization/json/pluralize-config.js +7 -0
  407. package/dist/esm/serialization/json/pluralize-config.js.map +1 -0
  408. package/dist/esm/serialization/json/serialize.d.ts +12 -0
  409. package/dist/esm/serialization/json/serialize.d.ts.map +1 -0
  410. package/dist/esm/serialization/json/serialize.js +389 -0
  411. package/dist/esm/serialization/json/serialize.js.map +1 -0
  412. package/dist/esm/serialization/json/util.d.ts +2 -0
  413. package/dist/esm/serialization/json/util.d.ts.map +1 -0
  414. package/dist/esm/serialization/json/util.js +19 -0
  415. package/dist/esm/serialization/json/util.js.map +1 -0
  416. package/dist/esm/serialization/utils.d.ts +3 -0
  417. package/dist/esm/serialization/utils.d.ts.map +1 -0
  418. package/dist/esm/serialization/utils.js +146 -0
  419. package/dist/esm/serialization/utils.js.map +1 -0
  420. package/dist/esm/shape/shape-registry.d.ts +51 -0
  421. package/dist/esm/shape/shape-registry.d.ts.map +1 -0
  422. package/dist/esm/shape/shape-registry.js +41 -0
  423. package/dist/esm/shape/shape-registry.js.map +1 -0
  424. package/dist/esm/shape/shape.d.ts +407 -0
  425. package/dist/esm/shape/shape.d.ts.map +1 -0
  426. package/dist/esm/shape/shape.js +424 -0
  427. package/dist/esm/shape/shape.js.map +1 -0
  428. package/dist/esm/shape/value-encoding.d.ts +121 -0
  429. package/dist/esm/shape/value-encoding.d.ts.map +1 -0
  430. package/dist/esm/shape/value-encoding.js +32 -0
  431. package/dist/esm/shape/value-encoding.js.map +1 -0
  432. package/dist/esm/types.d.ts +9 -0
  433. package/dist/esm/types.d.ts.map +1 -0
  434. package/dist/esm/types.js +4 -0
  435. package/dist/esm/types.js.map +1 -0
  436. package/dist/esm/util.d.ts +33 -0
  437. package/dist/esm/util.d.ts.map +1 -0
  438. package/dist/esm/util.js +74 -0
  439. package/dist/esm/util.js.map +1 -0
  440. package/package.json +117 -0
@@ -0,0 +1,424 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ // ---------------------------------------------------------------------------
4
+ // Constructor helpers
5
+ // ---------------------------------------------------------------------------
6
+ /** Build a {@link FlatModelShape} from a property map. */
7
+ export const createFlatModelShape = (byJsName) => ({
8
+ kind: "flatModel",
9
+ byJsName,
10
+ });
11
+ /**
12
+ * Build a {@link DiscriminatedModelShape}.
13
+ *
14
+ * Pass a bare string when the field goes by the same name on both
15
+ * sides, which is the overwhelmingly common case; pass a
16
+ * {@link DiscriminatorNames} pair when a `@clientName` makes them
17
+ * differ.
18
+ */
19
+ export const createDiscriminatedModelShape = (discriminator, byValue) => ({
20
+ kind: "discriminatedModel",
21
+ discriminator: typeof discriminator === "string"
22
+ ? { jsName: discriminator, armName: discriminator }
23
+ : discriminator,
24
+ byValue,
25
+ });
26
+ /**
27
+ * Build a {@link DeferredShape}. The thunk is called on dereference; defer
28
+ * the actual shape lookup so that mutually-referential constants can
29
+ * be emitted in any order.
30
+ */
31
+ export const createDeferredShape = (value) => ({
32
+ kind: "deferred",
33
+ value,
34
+ });
35
+ /** Build an {@link AnyShape}. */
36
+ export const createAnyShape = () => ({ kind: "any" });
37
+ /** Build a {@link StringShape}, optionally with a compatible wire encoding. */
38
+ export const createStringShape = (encoding) => ({
39
+ kind: "string",
40
+ ...(encoding ? { encoding } : {}),
41
+ });
42
+ /** Build a {@link BooleanShape}, optionally with a compatible wire encoding. */
43
+ export const createBooleanShape = (encoding) => ({
44
+ kind: "boolean",
45
+ ...(encoding ? { encoding } : {}),
46
+ });
47
+ /** Build a {@link NumberShape}, optionally with a compatible wire encoding. */
48
+ export const createNumberShape = (encoding) => ({
49
+ kind: "number",
50
+ ...(encoding ? { encoding } : {}),
51
+ });
52
+ /** Build a {@link BytesShape}, optionally with a compatible wire encoding. */
53
+ export const createBytesShape = (encoding) => ({
54
+ kind: "bytes",
55
+ ...(encoding ? { encoding } : {}),
56
+ });
57
+ /** Build a {@link DateShape}, optionally with a compatible wire encoding. */
58
+ export const createDateShape = (encoding) => ({
59
+ kind: "date",
60
+ ...(encoding ? { encoding } : {}),
61
+ });
62
+ /** Build a terminal {@link StringLiteralShape}. */
63
+ export const createStringLiteralShape = () => ({
64
+ kind: "stringLiteral",
65
+ });
66
+ /** Build a terminal {@link NumberLiteralShape}. */
67
+ export const createNumberLiteralShape = (encoding) => ({
68
+ kind: "numberLiteral",
69
+ ...(encoding ? { encoding } : {}),
70
+ });
71
+ /** Build a terminal {@link BooleanLiteralShape}. */
72
+ export const createBooleanLiteralShape = (encoding) => ({
73
+ kind: "booleanLiteral",
74
+ ...(encoding ? { encoding } : {}),
75
+ });
76
+ /** Build a terminal {@link EnumShape}. */
77
+ export const createEnumShape = () => ({ kind: "enum" });
78
+ /** Build a terminal {@link UnionShape}. */
79
+ export const createUnionShape = () => ({ kind: "union" });
80
+ /** Build a terminal {@link NullShape}. */
81
+ export const createNullShape = () => ({ kind: "null" });
82
+ /** Build an {@link ArrayShape}. */
83
+ export const createArrayShape = (element) => ({
84
+ kind: "array",
85
+ element,
86
+ });
87
+ /** Build a {@link RecordShape}. */
88
+ export const createRecordShape = (value) => ({
89
+ kind: "record",
90
+ value,
91
+ });
92
+ /** Build a {@link TupleShape}. */
93
+ export const createTupleShape = (values) => ({
94
+ kind: "tuple",
95
+ values,
96
+ });
97
+ /** Return whether a value shape terminates property navigation. */
98
+ export function isTerminalValueShape(shape) {
99
+ switch (shape.kind) {
100
+ case "any":
101
+ case "string":
102
+ case "boolean":
103
+ case "number":
104
+ case "bytes":
105
+ case "date":
106
+ case "stringLiteral":
107
+ case "numberLiteral":
108
+ case "booleanLiteral":
109
+ case "enum":
110
+ case "union":
111
+ case "null":
112
+ return true;
113
+ case "deferred":
114
+ case "array":
115
+ case "record":
116
+ case "tuple":
117
+ return false;
118
+ default:
119
+ return assertNeverShape(shape);
120
+ }
121
+ }
122
+ function assertNeverShape(shape) {
123
+ throw new Error(`Unhandled value shape: ${String(shape)}`);
124
+ }
125
+ /**
126
+ * Resolve a {@link ModelShape} to the single concrete variant that
127
+ * applies to `value`.
128
+ *
129
+ * Resolution is iterative, not a single step, because a variant may
130
+ * itself be a discriminated group keyed on a *different* field (see
131
+ * {@link DiscriminatedModelShape.byValue}). Each hop reads its own
132
+ * discriminator out of the same `value`, so
133
+ * `{ kind: "cat", breed: "siamese" }` resolves through `Pet` → `Cat`
134
+ * → `Siamese`. {@link DeferredShape} entries are dereferenced in
135
+ * place, and flat model shapes are returned as-is.
136
+ *
137
+ * When a hop's discriminator can't be read — it is absent, is not a
138
+ * string (the *expression-valued* case), or names an unknown variant —
139
+ * the variant is instead **inferred from the value's structure** by
140
+ * {@link selectVariant}. That inference is sound rather than a guess:
141
+ * ARM would reject a payload that doesn't match the variant its
142
+ * discriminator selects, so a concrete payload determines the variant
143
+ * even when the discriminator itself is only known at deploy time.
144
+ *
145
+ * Bicep takes the same position — a discriminator it can't evaluate at
146
+ * compile time downgrades type checking for that object (diagnostic
147
+ * `BCP225`) rather than failing the build.
148
+ *
149
+ * Returns `undefined` when `shape` is `undefined`, when there is no
150
+ * `value` to infer from, or when the `byValue` graph is cyclic
151
+ * (defensive; the emitter does not produce cycles here).
152
+ *
153
+ * @param shape - The shape to resolve. Flat shapes are returned
154
+ * unchanged, so callers can pass either kind without checking.
155
+ * @param value - The object this shape describes, used both to read
156
+ * discriminators and to infer a variant when they can't be read.
157
+ * Omit it when no value exists (an `Expression<T>` proxy, say) and
158
+ * discriminated shapes will resolve to `undefined`.
159
+ * @param valueKeyedBy - Which naming **`value`'s own keys** use — not
160
+ * the shape's. A {@link FlatModelShape} is the mapping *between* the
161
+ * two sides (one property is `secretVersion` in TypeScript and
162
+ * `version` on the wire), so inference has to read both sides in the
163
+ * same naming or nothing matches:
164
+ *
165
+ * - `"js"` — client-facing names, as authored in TypeScript and held
166
+ * in a resource's state. These are
167
+ * {@link FlatModelShape.byJsName}'s own keys. Passed by
168
+ * `lowerState`, on state about to be serialized.
169
+ * - `"arm"` — wire names, as they appear in an ARM template or a
170
+ * service response. These are the first segment of each
171
+ * {@link PropertyShape.armPath}. Passed by `raiseState`, on JSON
172
+ * just parsed off the wire.
173
+ *
174
+ * Has no effect when the discriminator resolves normally, and no
175
+ * effect at all for models whose properties map 1:1.
176
+ */
177
+ export function resolveModelShape(shape, value, valueKeyedBy = "js") {
178
+ let current = shape;
179
+ const seen = new Set();
180
+ while (current !== undefined) {
181
+ if (seen.has(current))
182
+ return undefined;
183
+ seen.add(current);
184
+ if (current.kind === "deferred") {
185
+ current = current.value();
186
+ continue;
187
+ }
188
+ if (current.kind === "flatModel")
189
+ return current;
190
+ const group = current;
191
+ // Read the discriminator under the same naming as `value`'s own
192
+ // keys: JS-side state holds it under the client name, wire JSON
193
+ // under the ARM name. The two coincide for almost every ARM
194
+ // discriminator, but a `@clientName` on the field makes them
195
+ // differ, and reading the wrong one silently downgrades exact
196
+ // dispatch to structural inference below.
197
+ const names = group.discriminator;
198
+ const key = value?.[valueKeyedBy === "js" ? names.jsName : names.armName];
199
+ const next = typeof key === "string" ? group.byValue[key] : undefined;
200
+ if (next === undefined) {
201
+ return value ? selectVariant(group, value, valueKeyedBy) : undefined;
202
+ }
203
+ current = next;
204
+ }
205
+ return undefined;
206
+ }
207
+ /**
208
+ * Infer which variant of `group` a value belongs to by structure.
209
+ *
210
+ * Every variant is scored by how many of the value's keys it declares,
211
+ * descending into nested objects and containers so that variants which
212
+ * are indistinguishable at the top level can still be told apart. CDN's
213
+ * delivery-rule actions are exactly that case: all nine variants
214
+ * declare `{ name, parameters }` and differ only inside `parameters`.
215
+ *
216
+ * The highest score wins; ties keep the earliest variant in `byValue`
217
+ * order, which is stable emitter output. A tie means the tied variants
218
+ * declare the same keys for the data given, and the emitter guarantees
219
+ * that keys shared across variants map identically — so either choice
220
+ * produces the same wire mapping for everything actually present.
221
+ */
222
+ function selectVariant(group, value, valueKeyedBy) {
223
+ let best;
224
+ let bestScore = -1;
225
+ for (const variant of flattenVariants(group, new Set())) {
226
+ const score = scoreShape(variant, value, valueKeyedBy, new WeakSet());
227
+ if (score > bestScore) {
228
+ bestScore = score;
229
+ best = variant;
230
+ }
231
+ }
232
+ return best;
233
+ }
234
+ /** How many of `value`'s keys, recursively, `shape` accounts for. */
235
+ function scoreShape(shape, value, valueKeyedBy, visiting) {
236
+ if (visiting.has(value))
237
+ return 0;
238
+ visiting.add(value);
239
+ const byKey = getShapePropertiesMap(shape, valueKeyedBy);
240
+ let score = 0;
241
+ for (const [key, sub] of Object.entries(value)) {
242
+ const prop = byKey.get(key);
243
+ if (!prop)
244
+ continue;
245
+ score += 1;
246
+ score += scoreNested(sub, prop.value, valueKeyedBy, visiting);
247
+ }
248
+ visiting.delete(value);
249
+ return score;
250
+ }
251
+ /**
252
+ * Score one level deeper, through a property's target. Containers are
253
+ * sampled at their first entry — enough to discriminate, and bounded
254
+ * regardless of how large the value is.
255
+ */
256
+ function scoreNested(value, target, valueKeyedBy, visiting) {
257
+ if (!target || isTerminalValueShape(target) || value === null || typeof value !== "object") {
258
+ return 0;
259
+ }
260
+ if (target.kind === "array") {
261
+ if (!Array.isArray(value) || value.length === 0)
262
+ return 0;
263
+ return scoreNested(value[0], target.element, valueKeyedBy, visiting);
264
+ }
265
+ if (target.kind === "record") {
266
+ if (Array.isArray(value))
267
+ return 0;
268
+ const first = Object.values(value)[0];
269
+ if (first === undefined)
270
+ return 0;
271
+ return scoreNested(first, target.value, valueKeyedBy, visiting);
272
+ }
273
+ if (target.kind === "tuple") {
274
+ if (!Array.isArray(value))
275
+ return 0;
276
+ return target.values.reduce((score, tupleValue, index) => score + scoreNested(value[index], tupleValue, valueKeyedBy, visiting), 0);
277
+ }
278
+ if (Array.isArray(value))
279
+ return 0;
280
+ const nested = resolveModelShape(target.value(), value, valueKeyedBy);
281
+ if (!nested)
282
+ return 0;
283
+ return scoreShape(nested, value, valueKeyedBy, visiting);
284
+ }
285
+ const shapePropertiesCache = new WeakMap();
286
+ /**
287
+ * A shape's properties as a map, keyed by the name they go by in the
288
+ * requested naming. Pass the same naming the value uses and the two
289
+ * line up, which is what lets {@link scoreShape} compare them.
290
+ *
291
+ * Memoized per (shape, naming): scoring calls this once per candidate
292
+ * variant per level, so rebuilding would be wasteful.
293
+ *
294
+ * @param shape - The shape whose properties to map.
295
+ * @param keyedBy - Which name to key by. Note this describes the *map
296
+ * being built*, not an incoming value — unlike the `valueKeyedBy`
297
+ * parameter the callers thread through.
298
+ */
299
+ function getShapePropertiesMap(shape, keyedBy) {
300
+ let byNaming = shapePropertiesCache.get(shape);
301
+ if (!byNaming) {
302
+ byNaming = new Map();
303
+ shapePropertiesCache.set(shape, byNaming);
304
+ }
305
+ let byKey = byNaming.get(keyedBy);
306
+ if (byKey)
307
+ return byKey;
308
+ byKey = new Map();
309
+ for (const [jsName, prop] of Object.entries(shape.byJsName)) {
310
+ // `armPath[0]` rather than the whole path: that is the top-level
311
+ // wire key, even for properties hoisted through `@flattenProperty`.
312
+ const key = keyedBy === "js" ? jsName : prop.armPath[0];
313
+ // First writer wins, so a hoisted property never shadows the
314
+ // wrapper it was hoisted through.
315
+ if (key !== undefined && !byKey.has(key))
316
+ byKey.set(key, prop);
317
+ }
318
+ byNaming.set(keyedBy, byKey);
319
+ return byKey;
320
+ }
321
+ /**
322
+ * Flatten a group to the concrete flat shapes underneath it,
323
+ * dereferencing thunks and descending through nested groups.
324
+ */
325
+ function flattenVariants(group, seen) {
326
+ if (seen.has(group))
327
+ return [];
328
+ seen.add(group);
329
+ const out = [];
330
+ for (const key of Object.keys(group.byValue)) {
331
+ let entry = group.byValue[key];
332
+ if (entry?.kind === "deferred")
333
+ entry = entry.value();
334
+ if (entry === undefined)
335
+ continue;
336
+ if (entry.kind === "flatModel")
337
+ out.push(entry);
338
+ else
339
+ out.push(...flattenVariants(entry, seen));
340
+ }
341
+ return out;
342
+ }
343
+ /**
344
+ * Navigate `nav` one step deeper using `segment`. For string segments
345
+ * (`.foo`) at a model position, returns the property's shape entry as
346
+ * `stamp` and advances `next` into the property's target. For numeric
347
+ * segments (`[i]`) or string keys at a record position, peels one
348
+ * container layer; `stamp` is always `undefined`.
349
+ *
350
+ * Returns `{ stamp: undefined, next: undefined }` when the step can't
351
+ * be resolved (unknown property, out-of-shape access, etc.) — the
352
+ * access is treated as passthrough.
353
+ *
354
+ * @param nav - Where navigation currently sits.
355
+ * @param segment - The member name or array index being accessed.
356
+ * @param value - The value sitting at `nav`, when the caller has one.
357
+ * Consulted only at a {@link DiscriminatedModelShape} position, to
358
+ * select the variant via {@link resolveModelShape}. Always read with
359
+ * `"js"` naming, since navigation follows client-facing property
360
+ * names. Callers with no value — an `Expression<T>` proxy, for
361
+ * instance — omit it and get passthrough for discriminated
362
+ * positions, which is the honest answer when the variant is
363
+ * unknowable.
364
+ */
365
+ export function navigateShape(nav, segment, value) {
366
+ if (typeof segment === "number") {
367
+ return { stamp: undefined, next: peelContainer(nav, segment) };
368
+ }
369
+ if (isModelShape(nav)) {
370
+ const flat = resolveModelShape(nav, asRecord(value));
371
+ const stamp = flat?.byJsName[segment];
372
+ if (!stamp)
373
+ return { stamp: undefined, next: undefined };
374
+ return { stamp, next: derefTarget(stamp.value) };
375
+ }
376
+ // String segment against a container — treat as a record key access.
377
+ if (nav && nav.kind === "record") {
378
+ return { stamp: undefined, next: derefTarget(nav.value) };
379
+ }
380
+ return { stamp: undefined, next: undefined };
381
+ }
382
+ function asRecord(value) {
383
+ return value !== null && typeof value === "object" && !Array.isArray(value)
384
+ ? value
385
+ : undefined;
386
+ }
387
+ function isModelShape(nav) {
388
+ return nav !== undefined && (nav.kind === "flatModel" || nav.kind === "discriminatedModel");
389
+ }
390
+ /**
391
+ * Peel one container layer off `nav`. Returns `undefined` for
392
+ * non-containers (caller treats the step as passthrough).
393
+ */
394
+ function peelContainer(nav, index) {
395
+ if (!nav || isModelShape(nav))
396
+ return undefined;
397
+ if (nav.kind === "array")
398
+ return derefTarget(nav.element);
399
+ if (nav.kind === "record")
400
+ return derefTarget(nav.value);
401
+ return derefTarget(nav.values[index]);
402
+ }
403
+ /**
404
+ * Convert a {@link ValueShape} — where a property *points* — into a
405
+ * {@link NavShape} — where navigation now *is*.
406
+ *
407
+ * The only real work is forcing a {@link DeferredShape} thunk; the
408
+ * resolved model becomes the new position whether or not it is
409
+ * discriminated, since {@link navigateShape} can look up properties on
410
+ * either. Container shapes pass through unchanged, pending an index
411
+ * step.
412
+ *
413
+ * Deliberately *not* named `resolve*` — that prefix belongs to
414
+ * {@link resolveModelShape}, which picks a variant and is a much
415
+ * heavier operation.
416
+ */
417
+ function derefTarget(shape) {
418
+ if (!shape || isTerminalValueShape(shape))
419
+ return undefined;
420
+ if (shape.kind === "deferred")
421
+ return shape.value();
422
+ return shape;
423
+ }
424
+ //# sourceMappingURL=shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../../src/shape/shape.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAqTlC,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAuC,EAAkB,EAAE,CAAC,CAAC;IAChG,IAAI,EAAE,WAAW;IACjB,QAAQ;CACT,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,aAA0C,EAC1C,OAA+D,EACtC,EAAE,CAAC,CAAC;IAC7B,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EACX,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE;QACnD,CAAC,CAAC,aAAa;IACnB,OAAO;CACR,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAI,KAAc,EAAoB,EAAE,CAAC,CAAC;IAC3E,IAAI,EAAE,UAAU;IAChB,KAAK;CACN,CAAC,CAAC;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAa,EAAE,CAAC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AAK,EAAE,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Runtime types for ARM shape information.\n *\n * A `ModelShape` is generated once per emitted Model and describes how\n * to map JS-ergonomic property names + structure to the underlying ARM\n * wire shape. The shapes are consumed by the serialization `lowerState`\n * pass (and its inverse `raiseState`) which rewrites state keys and\n * re-nests `@flattenProperty` paths just before serialization /\n * after deserialization.\n *\n * These types are an internal cross-package runtime contract; generated code\n * imports them from `@azure/provisioning-core/internal`.\n *\n * Nested-shape thunks ({@link DeferredShape}) defer dereferencing the\n * inner shape constant until use, so mutually-referential or\n * self-referential models can be emitted without initialization-order\n * problems.\n *\n * A model shape comes in two flavors:\n * - `FlatModelShape` ({@link FlatModelShape}): the common case —\n * one shape per concrete model.\n * - `DiscriminatedModelShape` ({@link DiscriminatedModelShape}): a\n * name-discriminated variant group. ARM permits multiple resources\n * to share an ARM `type` + `apiVersion` pair and disambiguate via a\n * fixed field — e.g. `Microsoft.ApiManagement/service/portalsettings@2024-05-01`\n * has three variants with `name: 'signin' | 'signup' | 'delegation'`\n * and distinct `properties` shapes. The same machinery applies to\n * nested models that use a `@discriminator` field.\n */\nimport type {\n BooleanValueEncodingDescriptor,\n BytesValueEncodingDescriptor,\n DateValueEncodingDescriptor,\n NumberValueEncodingDescriptor,\n NumericStringEncodingDescriptor,\n StringValueEncodingDescriptor,\n} from \"./value-encoding.js\";\n\n/** The standard single-model shape. */\nexport interface FlatModelShape {\n /**\n * Tag for tag-dispatched discrimination on {@link NavShape} and\n * {@link ModelShape}. Always `\"flatModel\"`.\n */\n readonly kind: \"flatModel\";\n /**\n * Map, keyed by JS-side (client-facing) property name, of how that\n * property maps to the ARM wire shape. Property names not present in\n * this map are assumed to be pass-through (identity mapping).\n */\n readonly byJsName: { readonly [jsName: string]: PropertyShape };\n}\n\n/**\n * The two names a discriminator field goes by.\n *\n * Usually identical — ARM discriminators are `type`, `name`, `kind` and\n * service teams rarely rename them — but a `@clientName` on the field\n * makes them differ, and the two are looked up in different keyspaces:\n * JS-side state is keyed by {@link jsName}, wire JSON by\n * {@link armName}. Carrying both is what lets a discriminated shape\n * resolve in either direction.\n */\nexport interface DiscriminatorNames {\n /** Client-facing name, as authored in TypeScript and held in state. */\n readonly jsName: string;\n /** Wire-level name, as it appears in an ARM template or response. */\n readonly armName: string;\n}\n\n/**\n * A name-discriminated group of variants that share one parent key\n * (an ARM `(type, apiVersion)` at the registry level, or a parent\n * model's `@discriminator` field elsewhere). The `discriminator` names\n * the field whose value selects a variant.\n */\nexport interface DiscriminatedModelShape {\n readonly kind: \"discriminatedModel\";\n /** Names of the field used to select a variant. */\n readonly discriminator: DiscriminatorNames;\n /**\n * Map from discriminator value (e.g. `\"signin\"`) to the shape for\n * that variant. A value with no entry here doesn't end resolution —\n * {@link resolveModelShape} infers the variant from the payload's\n * structure instead.\n *\n * Entries may be:\n * - a {@link FlatModelShape} — the terminal, common case;\n * - a {@link DeferredShape} — breaks emit-order / cyclic-reference\n * hazards, exactly as {@link PropertyShape.value} does;\n * - a nested {@link DiscriminatedModelShape} — a variant that is\n * itself a discriminated base on a *different* field. TypeSpec\n * permits this (`@discriminator(\"kind\") model Pet`, then\n * `@discriminator(\"breed\") model Cat extends Pet`), so selecting\n * a concrete shape may take more than one hop. See\n * {@link resolveModelShape}.\n *\n * Note that a hierarchy re-using the *same* discriminator field at\n * every level (abstract intermediates) is flattened by the emitter\n * into a single level here — only a change of discriminator field\n * produces a nested entry.\n */\n readonly byValue: {\n readonly [value: string]: ModelShape | DeferredShape<ModelShape>;\n };\n}\n\n/** A single model's shape — either flat or discriminated. */\nexport type ModelShape = FlatModelShape | DiscriminatedModelShape;\n\n/**\n * What `registerShape` stores in the global registry, keyed by\n * `(armType, apiVersion)`. Same structural type as {@link ModelShape};\n * the alias documents intent at the registry boundary.\n */\nexport type ResourceShape = ModelShape;\n\n/** A single property's shape entry. */\nexport interface PropertyShape {\n /**\n * ARM wire path from the owning model's root to this property.\n * Single-segment for direct properties; multi-segment for properties\n * hoisted through one or more `@flattenProperty` wrappers.\n */\n readonly armPath: readonly string[];\n\n /**\n * Describes this property's value for navigation and wire conversion.\n * Model and container shapes recurse into nested values; a\n * {@link TerminalValueShape} explicitly terminates recursion. Scalar\n * terminal shapes carry only the encodings valid for their client-side\n * JavaScript representation.\n */\n readonly value: ValueShape;\n\n /**\n * `true` when ARM treats this property as server-set (visible in GET\n * responses but rejected on PUT). Omitted (i.e. `undefined`/`false`)\n * for writable properties.\n *\n * Currently consumed by the `Resource` constructor's deployment-context\n * inheritance to skip readonly properties (notably `location` on many\n * child resources where the field exists in the read model only).\n */\n readonly readOnly?: boolean;\n}\n\n/**\n * Deferred reference to a shape value. The thunk is called on\n * dereference so the actual shape lookup is deferred.\n *\n * **Why this exists instead of embedding the shape directly.**\n *\n * Model shapes frequently reference each other — a model's properties\n * can point to other models, and ARM types include both self-\n * referential (tree-like) and mutually-referential (cyclic) structures.\n * If we embedded a {@link ModelShape} value directly inside another\n * model shape's value field, both shapes would need to be fully\n * initialized when the parent is constructed. That's impossible\n * whenever:\n *\n * - A model references itself, e.g. `TreeNode { children: TreeNode[] }`.\n * - Two models reference each other, e.g. `A { b?: B }` and `B { a?: A }`.\n * - Two modules each define shapes that reference shapes from the other.\n *\n * In all three cases the second constant is in the Temporal Dead Zone\n * when the first one's literal evaluates, and the runtime throws\n * `ReferenceError: Cannot access ... before initialization`.\n *\n * Wrapping the reference in a thunk solves it. The closure captures\n * the *binding name*, not its current value. The lookup happens later\n * when the thunk is called — by which time the module graph has\n * finished evaluating and both shapes are fully constructed.\n *\n * Only the model variant of {@link ValueShape} carries a reference —\n * container shapes (`array`, `record`) are eager because they don't\n * reference any module-level binding directly; the inner reference\n * deeper down handles cycle-breaking.\n */\nexport interface DeferredShape<T> {\n readonly kind: \"deferred\";\n readonly value: () => T;\n}\n\n/** An array-of-T property/container shape. */\nexport interface ArrayShape {\n readonly kind: \"array\";\n readonly element: ValueShape;\n}\n\n/** A `Record<string, T>` property/container shape. */\nexport interface RecordShape {\n readonly kind: \"record\";\n readonly value: ValueShape;\n}\n\n/** A fixed-length heterogeneous tuple property/container shape. */\nexport interface TupleShape {\n readonly kind: \"tuple\";\n readonly values: readonly ValueShape[];\n}\n\n/** A TypeSpec scalar rendered as TypeScript `any`. */\nexport interface AnyShape {\n readonly kind: \"any\";\n}\n\n/** A scalar whose client-side JavaScript representation is `string`. */\nexport interface StringShape {\n readonly kind: \"string\";\n readonly encoding?: StringValueEncodingDescriptor;\n}\n\n/** A scalar whose client-side JavaScript representation is `boolean`. */\nexport interface BooleanShape {\n readonly kind: \"boolean\";\n readonly encoding?: BooleanValueEncodingDescriptor;\n}\n\n/** A scalar whose client-side JavaScript representation is `number`. */\nexport interface NumberShape {\n readonly kind: \"number\";\n readonly encoding?: NumberValueEncodingDescriptor;\n}\n\n/** A scalar whose client-side JavaScript representation is `Uint8Array`. */\nexport interface BytesShape {\n readonly kind: \"bytes\";\n readonly encoding?: BytesValueEncodingDescriptor;\n}\n\n/** A scalar whose client-side JavaScript representation is `Date`. */\nexport interface DateShape {\n readonly kind: \"date\";\n readonly encoding?: DateValueEncodingDescriptor;\n}\n\n/** A terminal TypeSpec string literal. Literals cannot carry `@encode`. */\nexport interface StringLiteralShape {\n readonly kind: \"stringLiteral\";\n}\n\n/** A terminal TypeSpec numeric literal. */\nexport interface NumberLiteralShape {\n readonly kind: \"numberLiteral\";\n /** `@encode(string)` when the numeric literal is exposed as wire text. */\n readonly encoding?: NumericStringEncodingDescriptor;\n}\n\n/** A terminal TypeSpec boolean literal. */\nexport interface BooleanLiteralShape {\n readonly kind: \"booleanLiteral\";\n /** `@encode(string)` while the client value remains a boolean literal. */\n readonly encoding?: BooleanValueEncodingDescriptor;\n}\n\n/** A terminal TypeSpec enum. Enums cannot carry `@encode`. */\nexport interface EnumShape {\n readonly kind: \"enum\";\n}\n\n/**\n * A terminal TypeSpec union for which no single structural shape can be\n * selected. Unions cannot carry `@encode` in the provisioning emitter.\n */\nexport interface UnionShape {\n readonly kind: \"union\";\n}\n\n/** The TypeSpec `null` intrinsic. */\nexport interface NullShape {\n readonly kind: \"null\";\n}\n\n/**\n * Concrete terminal values in the generated client API.\n *\n * Scalar kinds describe the JavaScript value accepted by the generated\n * TypeScript surface, not necessarily the semantic TypeSpec scalar. For\n * example, a numeric `duration` is a {@link NumberShape}, while the default\n * ISO8601 duration is a {@link StringShape}; their narrowed `encoding` fields\n * retain the TypeSpec source semantics needed for wire conversion. Numeric and\n * boolean literal shapes can carry the same narrowly applicable encodings that\n * TypeSpec permits on those values. String literals, enums, unions, and null\n * remain distinct non-encodable terminal categories.\n * Expressions are orthogonal wrappers around any value shape and are handled\n * before shape-directed conversion.\n */\nexport type TerminalValueShape =\n | AnyShape\n | StringShape\n | BooleanShape\n | NumberShape\n | BytesShape\n | DateShape\n | StringLiteralShape\n | NumberLiteralShape\n | BooleanLiteralShape\n | EnumShape\n | UnionShape\n | NullShape;\n\n/** A container through which property navigation can continue. */\nexport type ContainerShape = ArrayShape | RecordShape | TupleShape;\n\nexport type ValueShape = TerminalValueShape | DeferredShape<ModelShape> | ContainerShape;\n\n// ---------------------------------------------------------------------------\n// Constructor helpers\n// ---------------------------------------------------------------------------\n\n/** Build a {@link FlatModelShape} from a property map. */\nexport const createFlatModelShape = (byJsName: Record<string, PropertyShape>): FlatModelShape => ({\n kind: \"flatModel\",\n byJsName,\n});\n\n/**\n * Build a {@link DiscriminatedModelShape}.\n *\n * Pass a bare string when the field goes by the same name on both\n * sides, which is the overwhelmingly common case; pass a\n * {@link DiscriminatorNames} pair when a `@clientName` makes them\n * differ.\n */\nexport const createDiscriminatedModelShape = (\n discriminator: string | DiscriminatorNames,\n byValue: Record<string, ModelShape | DeferredShape<ModelShape>>,\n): DiscriminatedModelShape => ({\n kind: \"discriminatedModel\",\n discriminator:\n typeof discriminator === \"string\"\n ? { jsName: discriminator, armName: discriminator }\n : discriminator,\n byValue,\n});\n\n/**\n * Build a {@link DeferredShape}. The thunk is called on dereference; defer\n * the actual shape lookup so that mutually-referential constants can\n * be emitted in any order.\n */\nexport const createDeferredShape = <T>(value: () => T): DeferredShape<T> => ({\n kind: \"deferred\",\n value,\n});\n\n/** Build an {@link AnyShape}. */\nexport const createAnyShape = (): AnyShape => ({ kind: \"any\" });\n\n/** Build a {@link StringShape}, optionally with a compatible wire encoding. */\nexport const createStringShape = (encoding?: StringValueEncodingDescriptor): StringShape => ({\n kind: \"string\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a {@link BooleanShape}, optionally with a compatible wire encoding. */\nexport const createBooleanShape = (encoding?: BooleanValueEncodingDescriptor): BooleanShape => ({\n kind: \"boolean\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a {@link NumberShape}, optionally with a compatible wire encoding. */\nexport const createNumberShape = (encoding?: NumberValueEncodingDescriptor): NumberShape => ({\n kind: \"number\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a {@link BytesShape}, optionally with a compatible wire encoding. */\nexport const createBytesShape = (encoding?: BytesValueEncodingDescriptor): BytesShape => ({\n kind: \"bytes\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a {@link DateShape}, optionally with a compatible wire encoding. */\nexport const createDateShape = (encoding?: DateValueEncodingDescriptor): DateShape => ({\n kind: \"date\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a terminal {@link StringLiteralShape}. */\nexport const createStringLiteralShape = (): StringLiteralShape => ({\n kind: \"stringLiteral\",\n});\n\n/** Build a terminal {@link NumberLiteralShape}. */\nexport const createNumberLiteralShape = (\n encoding?: NumericStringEncodingDescriptor,\n): NumberLiteralShape => ({\n kind: \"numberLiteral\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a terminal {@link BooleanLiteralShape}. */\nexport const createBooleanLiteralShape = (\n encoding?: BooleanValueEncodingDescriptor,\n): BooleanLiteralShape => ({\n kind: \"booleanLiteral\",\n ...(encoding ? { encoding } : {}),\n});\n\n/** Build a terminal {@link EnumShape}. */\nexport const createEnumShape = (): EnumShape => ({ kind: \"enum\" });\n\n/** Build a terminal {@link UnionShape}. */\nexport const createUnionShape = (): UnionShape => ({ kind: \"union\" });\n\n/** Build a terminal {@link NullShape}. */\nexport const createNullShape = (): NullShape => ({ kind: \"null\" });\n\n/** Build an {@link ArrayShape}. */\nexport const createArrayShape = (element: ValueShape): ArrayShape => ({\n kind: \"array\",\n element,\n});\n\n/** Build a {@link RecordShape}. */\nexport const createRecordShape = (value: ValueShape): RecordShape => ({\n kind: \"record\",\n value,\n});\n\n/** Build a {@link TupleShape}. */\nexport const createTupleShape = (values: readonly ValueShape[]): TupleShape => ({\n kind: \"tuple\",\n values,\n});\n\n/** Return whether a value shape terminates property navigation. */\nexport function isTerminalValueShape(shape: ValueShape): shape is TerminalValueShape {\n switch (shape.kind) {\n case \"any\":\n case \"string\":\n case \"boolean\":\n case \"number\":\n case \"bytes\":\n case \"date\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"enum\":\n case \"union\":\n case \"null\":\n return true;\n case \"deferred\":\n case \"array\":\n case \"record\":\n case \"tuple\":\n return false;\n default:\n return assertNeverShape(shape);\n }\n}\n\nfunction assertNeverShape(shape: never): never {\n throw new Error(`Unhandled value shape: ${String(shape)}`);\n}\n\n// ---------------------------------------------------------------------------\n// Helpers used by the runtime proxy + lowering pass\n// ---------------------------------------------------------------------------\n\n/**\n * Runtime navigation position for a typed proxy. Either:\n * - a {@link ModelShape} — we're at a model's properties, whether or\n * not its variant is known,\n * - a {@link ContainerShape} — we're at a container that hasn't yet been\n * indexed,\n * - `undefined` — the current position is terminal, unknown, or the proxy\n * was created without a shape.\n *\n * Proxies carry a `NavShape` through each access so they can stamp and\n * resolve the correct shape on deeper navigation.\n *\n * Navigation never sits at a {@link DeferredShape} — refs are resolved\n * eagerly as soon as the proxy encounters them.\n */\nexport type NavShape = ModelShape | ContainerShape | undefined;\n\n/**\n * Resolve a {@link ModelShape} to the single concrete variant that\n * applies to `value`.\n *\n * Resolution is iterative, not a single step, because a variant may\n * itself be a discriminated group keyed on a *different* field (see\n * {@link DiscriminatedModelShape.byValue}). Each hop reads its own\n * discriminator out of the same `value`, so\n * `{ kind: \"cat\", breed: \"siamese\" }` resolves through `Pet` → `Cat`\n * → `Siamese`. {@link DeferredShape} entries are dereferenced in\n * place, and flat model shapes are returned as-is.\n *\n * When a hop's discriminator can't be read — it is absent, is not a\n * string (the *expression-valued* case), or names an unknown variant —\n * the variant is instead **inferred from the value's structure** by\n * {@link selectVariant}. That inference is sound rather than a guess:\n * ARM would reject a payload that doesn't match the variant its\n * discriminator selects, so a concrete payload determines the variant\n * even when the discriminator itself is only known at deploy time.\n *\n * Bicep takes the same position — a discriminator it can't evaluate at\n * compile time downgrades type checking for that object (diagnostic\n * `BCP225`) rather than failing the build.\n *\n * Returns `undefined` when `shape` is `undefined`, when there is no\n * `value` to infer from, or when the `byValue` graph is cyclic\n * (defensive; the emitter does not produce cycles here).\n *\n * @param shape - The shape to resolve. Flat shapes are returned\n * unchanged, so callers can pass either kind without checking.\n * @param value - The object this shape describes, used both to read\n * discriminators and to infer a variant when they can't be read.\n * Omit it when no value exists (an `Expression<T>` proxy, say) and\n * discriminated shapes will resolve to `undefined`.\n * @param valueKeyedBy - Which naming **`value`'s own keys** use — not\n * the shape's. A {@link FlatModelShape} is the mapping *between* the\n * two sides (one property is `secretVersion` in TypeScript and\n * `version` on the wire), so inference has to read both sides in the\n * same naming or nothing matches:\n *\n * - `\"js\"` — client-facing names, as authored in TypeScript and held\n * in a resource's state. These are\n * {@link FlatModelShape.byJsName}'s own keys. Passed by\n * `lowerState`, on state about to be serialized.\n * - `\"arm\"` — wire names, as they appear in an ARM template or a\n * service response. These are the first segment of each\n * {@link PropertyShape.armPath}. Passed by `raiseState`, on JSON\n * just parsed off the wire.\n *\n * Has no effect when the discriminator resolves normally, and no\n * effect at all for models whose properties map 1:1.\n */\nexport function resolveModelShape(\n shape: ModelShape | undefined,\n value: Record<string, unknown> | undefined,\n valueKeyedBy: \"js\" | \"arm\" = \"js\",\n): FlatModelShape | undefined {\n let current: ModelShape | DeferredShape<ModelShape> | undefined = shape;\n const seen = new Set<ModelShape | DeferredShape<ModelShape>>();\n\n while (current !== undefined) {\n if (seen.has(current)) return undefined;\n seen.add(current);\n\n if (current.kind === \"deferred\") {\n current = current.value();\n continue;\n }\n if (current.kind === \"flatModel\") return current;\n\n const group: DiscriminatedModelShape = current;\n // Read the discriminator under the same naming as `value`'s own\n // keys: JS-side state holds it under the client name, wire JSON\n // under the ARM name. The two coincide for almost every ARM\n // discriminator, but a `@clientName` on the field makes them\n // differ, and reading the wrong one silently downgrades exact\n // dispatch to structural inference below.\n const names = group.discriminator;\n const key = value?.[valueKeyedBy === \"js\" ? names.jsName : names.armName];\n const next = typeof key === \"string\" ? group.byValue[key] : undefined;\n if (next === undefined) {\n return value ? selectVariant(group, value, valueKeyedBy) : undefined;\n }\n current = next;\n }\n\n return undefined;\n}\n\n/**\n * Infer which variant of `group` a value belongs to by structure.\n *\n * Every variant is scored by how many of the value's keys it declares,\n * descending into nested objects and containers so that variants which\n * are indistinguishable at the top level can still be told apart. CDN's\n * delivery-rule actions are exactly that case: all nine variants\n * declare `{ name, parameters }` and differ only inside `parameters`.\n *\n * The highest score wins; ties keep the earliest variant in `byValue`\n * order, which is stable emitter output. A tie means the tied variants\n * declare the same keys for the data given, and the emitter guarantees\n * that keys shared across variants map identically — so either choice\n * produces the same wire mapping for everything actually present.\n */\nfunction selectVariant(\n group: DiscriminatedModelShape,\n value: Record<string, unknown>,\n valueKeyedBy: \"js\" | \"arm\",\n): FlatModelShape | undefined {\n let best: FlatModelShape | undefined;\n let bestScore = -1;\n\n for (const variant of flattenVariants(group, new Set())) {\n const score = scoreShape(variant, value, valueKeyedBy, new WeakSet());\n if (score > bestScore) {\n bestScore = score;\n best = variant;\n }\n }\n\n return best;\n}\n\n/** How many of `value`'s keys, recursively, `shape` accounts for. */\nfunction scoreShape(\n shape: FlatModelShape,\n value: Record<string, unknown>,\n valueKeyedBy: \"js\" | \"arm\",\n visiting: WeakSet<object>,\n): number {\n if (visiting.has(value)) return 0;\n visiting.add(value);\n\n const byKey = getShapePropertiesMap(shape, valueKeyedBy);\n let score = 0;\n\n for (const [key, sub] of Object.entries(value)) {\n const prop = byKey.get(key);\n if (!prop) continue;\n score += 1;\n score += scoreNested(sub, prop.value, valueKeyedBy, visiting);\n }\n\n visiting.delete(value);\n return score;\n}\n\n/**\n * Score one level deeper, through a property's target. Containers are\n * sampled at their first entry — enough to discriminate, and bounded\n * regardless of how large the value is.\n */\nfunction scoreNested(\n value: unknown,\n target: ValueShape | undefined,\n valueKeyedBy: \"js\" | \"arm\",\n visiting: WeakSet<object>,\n): number {\n if (!target || isTerminalValueShape(target) || value === null || typeof value !== \"object\") {\n return 0;\n }\n\n if (target.kind === \"array\") {\n if (!Array.isArray(value) || value.length === 0) return 0;\n return scoreNested(value[0], target.element, valueKeyedBy, visiting);\n }\n\n if (target.kind === \"record\") {\n if (Array.isArray(value)) return 0;\n const first = Object.values(value)[0];\n if (first === undefined) return 0;\n return scoreNested(first, target.value, valueKeyedBy, visiting);\n }\n\n if (target.kind === \"tuple\") {\n if (!Array.isArray(value)) return 0;\n return target.values.reduce(\n (score, tupleValue, index) =>\n score + scoreNested(value[index], tupleValue, valueKeyedBy, visiting),\n 0,\n );\n }\n\n if (Array.isArray(value)) return 0;\n const nested = resolveModelShape(target.value(), value as Record<string, unknown>, valueKeyedBy);\n if (!nested) return 0;\n return scoreShape(nested, value as Record<string, unknown>, valueKeyedBy, visiting);\n}\n\nconst shapePropertiesCache = new WeakMap<\n FlatModelShape,\n Map<\"js\" | \"arm\", Map<string, PropertyShape>>\n>();\n\n/**\n * A shape's properties as a map, keyed by the name they go by in the\n * requested naming. Pass the same naming the value uses and the two\n * line up, which is what lets {@link scoreShape} compare them.\n *\n * Memoized per (shape, naming): scoring calls this once per candidate\n * variant per level, so rebuilding would be wasteful.\n *\n * @param shape - The shape whose properties to map.\n * @param keyedBy - Which name to key by. Note this describes the *map\n * being built*, not an incoming value — unlike the `valueKeyedBy`\n * parameter the callers thread through.\n */\nfunction getShapePropertiesMap(\n shape: FlatModelShape,\n keyedBy: \"js\" | \"arm\",\n): Map<string, PropertyShape> {\n let byNaming = shapePropertiesCache.get(shape);\n if (!byNaming) {\n byNaming = new Map();\n shapePropertiesCache.set(shape, byNaming);\n }\n let byKey = byNaming.get(keyedBy);\n if (byKey) return byKey;\n\n byKey = new Map<string, PropertyShape>();\n for (const [jsName, prop] of Object.entries(shape.byJsName)) {\n // `armPath[0]` rather than the whole path: that is the top-level\n // wire key, even for properties hoisted through `@flattenProperty`.\n const key = keyedBy === \"js\" ? jsName : prop.armPath[0];\n // First writer wins, so a hoisted property never shadows the\n // wrapper it was hoisted through.\n if (key !== undefined && !byKey.has(key)) byKey.set(key, prop);\n }\n byNaming.set(keyedBy, byKey);\n return byKey;\n}\n\n/**\n * Flatten a group to the concrete flat shapes underneath it,\n * dereferencing thunks and descending through nested groups.\n */\nfunction flattenVariants(\n group: DiscriminatedModelShape,\n seen: Set<DiscriminatedModelShape>,\n): FlatModelShape[] {\n if (seen.has(group)) return [];\n seen.add(group);\n\n const out: FlatModelShape[] = [];\n for (const key of Object.keys(group.byValue)) {\n let entry: ModelShape | DeferredShape<ModelShape> | undefined = group.byValue[key];\n if (entry?.kind === \"deferred\") entry = entry.value();\n if (entry === undefined) continue;\n if (entry.kind === \"flatModel\") out.push(entry);\n else out.push(...flattenVariants(entry, seen));\n }\n return out;\n}\n\n/**\n * Navigate `nav` one step deeper using `segment`. For string segments\n * (`.foo`) at a model position, returns the property's shape entry as\n * `stamp` and advances `next` into the property's target. For numeric\n * segments (`[i]`) or string keys at a record position, peels one\n * container layer; `stamp` is always `undefined`.\n *\n * Returns `{ stamp: undefined, next: undefined }` when the step can't\n * be resolved (unknown property, out-of-shape access, etc.) — the\n * access is treated as passthrough.\n *\n * @param nav - Where navigation currently sits.\n * @param segment - The member name or array index being accessed.\n * @param value - The value sitting at `nav`, when the caller has one.\n * Consulted only at a {@link DiscriminatedModelShape} position, to\n * select the variant via {@link resolveModelShape}. Always read with\n * `\"js\"` naming, since navigation follows client-facing property\n * names. Callers with no value — an `Expression<T>` proxy, for\n * instance — omit it and get passthrough for discriminated\n * positions, which is the honest answer when the variant is\n * unknowable.\n */\nexport function navigateShape(\n nav: NavShape,\n segment: string | number,\n value?: unknown,\n): { readonly stamp: PropertyShape | undefined; readonly next: NavShape } {\n if (typeof segment === \"number\") {\n return { stamp: undefined, next: peelContainer(nav, segment) };\n }\n if (isModelShape(nav)) {\n const flat = resolveModelShape(nav, asRecord(value));\n const stamp = flat?.byJsName[segment];\n if (!stamp) return { stamp: undefined, next: undefined };\n return { stamp, next: derefTarget(stamp.value) };\n }\n // String segment against a container — treat as a record key access.\n if (nav && nav.kind === \"record\") {\n return { stamp: undefined, next: derefTarget(nav.value) };\n }\n return { stamp: undefined, next: undefined };\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction isModelShape(nav: NavShape): nav is ModelShape {\n return nav !== undefined && (nav.kind === \"flatModel\" || nav.kind === \"discriminatedModel\");\n}\n\n/**\n * Peel one container layer off `nav`. Returns `undefined` for\n * non-containers (caller treats the step as passthrough).\n */\nfunction peelContainer(nav: NavShape, index: number): NavShape {\n if (!nav || isModelShape(nav)) return undefined;\n if (nav.kind === \"array\") return derefTarget(nav.element);\n if (nav.kind === \"record\") return derefTarget(nav.value);\n return derefTarget(nav.values[index]);\n}\n\n/**\n * Convert a {@link ValueShape} — where a property *points* — into a\n * {@link NavShape} — where navigation now *is*.\n *\n * The only real work is forcing a {@link DeferredShape} thunk; the\n * resolved model becomes the new position whether or not it is\n * discriminated, since {@link navigateShape} can look up properties on\n * either. Container shapes pass through unchanged, pending an index\n * step.\n *\n * Deliberately *not* named `resolve*` — that prefix belongs to\n * {@link resolveModelShape}, which picks a variant and is a much\n * heavier operation.\n */\nfunction derefTarget(shape: ValueShape | undefined): NavShape {\n if (!shape || isTerminalValueShape(shape)) return undefined;\n if (shape.kind === \"deferred\") return shape.value();\n return shape;\n}\n"]}
@@ -0,0 +1,121 @@
1
+ export declare const INTEGER_SCALAR_NAMES: readonly ["integer", "safeint", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"];
2
+ export type IntegerScalarName = (typeof INTEGER_SCALAR_NAMES)[number];
3
+ export declare const NUMERIC_SCALAR_NAMES: readonly ["integer", "safeint", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "numeric", "decimal", "decimal128", "float", "float32", "float64"];
4
+ export type NumericScalarName = (typeof NUMERIC_SCALAR_NAMES)[number];
5
+ export declare function isIntegerScalarName(name: string): name is IntegerScalarName;
6
+ export declare function isNumericScalarName(name: string): name is NumericScalarName;
7
+ export interface DateTimeTextEncodingDescriptor {
8
+ readonly kind: "date-time-text";
9
+ readonly source: "utcDateTime" | "offsetDateTime";
10
+ readonly format: "rfc3339" | "rfc7231";
11
+ readonly clientMode: "client" | "wire";
12
+ readonly wire: {
13
+ readonly kind: "string";
14
+ };
15
+ }
16
+ export interface UnixTimestampEncodingDescriptor {
17
+ readonly kind: "unix-timestamp";
18
+ readonly source: "utcDateTime";
19
+ readonly unit: "seconds";
20
+ readonly clientMode: "client" | "wire";
21
+ readonly wire: {
22
+ readonly kind: "integer";
23
+ readonly scalar: IntegerScalarName;
24
+ };
25
+ }
26
+ export interface DurationIso8601EncodingDescriptor {
27
+ readonly kind: "duration-iso8601";
28
+ readonly source: "duration";
29
+ readonly clientMode: "wire";
30
+ readonly wire: {
31
+ readonly kind: "string";
32
+ };
33
+ }
34
+ export interface DurationNumericEncodingDescriptor {
35
+ readonly kind: "duration-numeric";
36
+ readonly source: "duration";
37
+ readonly unit: "seconds" | "milliseconds";
38
+ readonly clientMode: "wire";
39
+ readonly wire: {
40
+ readonly kind: "integer";
41
+ readonly scalar: IntegerScalarName;
42
+ };
43
+ }
44
+ export interface BytesEncodingDescriptor {
45
+ readonly kind: "bytes";
46
+ readonly source: "bytes";
47
+ readonly format: "base64" | "base64url";
48
+ readonly clientMode: "client" | "wire";
49
+ readonly wire: {
50
+ readonly kind: "string";
51
+ };
52
+ }
53
+ export interface PlainDateEncodingDescriptor {
54
+ readonly kind: "plain-date";
55
+ readonly source: "plainDate";
56
+ readonly clientMode: "client" | "wire";
57
+ readonly wire: {
58
+ readonly kind: "string";
59
+ };
60
+ }
61
+ export interface NumericStringEncodingDescriptor {
62
+ readonly kind: "numeric-string";
63
+ readonly source: "integer" | "number";
64
+ readonly sourceScalar: NumericScalarName;
65
+ readonly clientMode: "wire";
66
+ readonly wire: {
67
+ readonly kind: "string";
68
+ };
69
+ }
70
+ export interface BooleanStringEncodingDescriptor {
71
+ readonly kind: "boolean-string";
72
+ readonly source: "boolean";
73
+ readonly clientMode: "client" | "wire";
74
+ readonly wire: {
75
+ readonly kind: "string";
76
+ };
77
+ }
78
+ export type ValueEncodingDescriptor = DateTimeTextEncodingDescriptor | UnixTimestampEncodingDescriptor | DurationIso8601EncodingDescriptor | DurationNumericEncodingDescriptor | BytesEncodingDescriptor | PlainDateEncodingDescriptor | NumericStringEncodingDescriptor | BooleanStringEncodingDescriptor;
79
+ /**
80
+ * Encodings whose client-side value is a JavaScript `string`.
81
+ *
82
+ * The source TypeSpec scalar can be a date/time, duration, byte sequence,
83
+ * numeric value, or boolean. `clientMode: "wire"` is the important invariant:
84
+ * it means the generated TypeScript API exposes the encoded string itself.
85
+ */
86
+ export type StringValueEncodingDescriptor = (DateTimeTextEncodingDescriptor & {
87
+ readonly clientMode: "wire";
88
+ }) | DurationIso8601EncodingDescriptor | (BytesEncodingDescriptor & {
89
+ readonly clientMode: "wire";
90
+ }) | (PlainDateEncodingDescriptor & {
91
+ readonly clientMode: "wire";
92
+ }) | NumericStringEncodingDescriptor | (BooleanStringEncodingDescriptor & {
93
+ readonly clientMode: "wire";
94
+ });
95
+ /** Encoding supported by a client-side JavaScript `boolean`. */
96
+ export type BooleanValueEncodingDescriptor = BooleanStringEncodingDescriptor & {
97
+ readonly clientMode: "client";
98
+ };
99
+ /** Encodings whose client-side value is a JavaScript `number`. */
100
+ export type NumberValueEncodingDescriptor = (UnixTimestampEncodingDescriptor & {
101
+ readonly clientMode: "wire";
102
+ }) | DurationNumericEncodingDescriptor;
103
+ /** Encoding supported by a client-side JavaScript `Uint8Array`. */
104
+ export type BytesValueEncodingDescriptor = BytesEncodingDescriptor & {
105
+ readonly clientMode: "client";
106
+ };
107
+ /**
108
+ * Encodings whose client-side value is a JavaScript `Date`.
109
+ *
110
+ * `offsetDateTime` is intentionally absent: the emitter exposes it as a
111
+ * string so the original offset is not erased.
112
+ */
113
+ export type DateValueEncodingDescriptor = (DateTimeTextEncodingDescriptor & {
114
+ readonly source: "utcDateTime";
115
+ readonly clientMode: "client";
116
+ }) | (UnixTimestampEncodingDescriptor & {
117
+ readonly clientMode: "client";
118
+ }) | (PlainDateEncodingDescriptor & {
119
+ readonly clientMode: "client";
120
+ });
121
+ //# sourceMappingURL=value-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-encoding.d.ts","sourceRoot":"","sources":["../../../src/shape/value-encoding.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,2GAWvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB,8KAQvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAKtE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAE3E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,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