@prisma/orm-framework 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.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 (354) hide show
  1. package/README.md +1 -5
  2. package/dist/{apply-specifier-default-control-policy-CAxiXxKg.d.mts → apply-specifier-default-control-policy-Dlz0iwnK.d.mts} +2 -2
  3. package/dist/apply-specifier-default-control-policy-Dlz0iwnK.d.mts.map +1 -0
  4. package/dist/{assertions-Cz-GWH8P.mjs → assertions-Dw1lZz_Q.mjs} +2 -2
  5. package/dist/{assertions-Cz-GWH8P.mjs.map → assertions-Dw1lZz_Q.mjs.map} +1 -1
  6. package/dist/authoring-CNUti739.mjs +764 -0
  7. package/dist/authoring-CNUti739.mjs.map +1 -0
  8. package/dist/authoring-CjwinhU5.d.mts +206 -0
  9. package/dist/authoring-CjwinhU5.d.mts.map +1 -0
  10. package/dist/binder-D_4RBHbt-BJ6VKwEZ.d.mts +515 -0
  11. package/dist/binder-D_4RBHbt-BJ6VKwEZ.d.mts.map +1 -0
  12. package/dist/{canonicalization-DFpB09nP-4OdB2nsy.d.mts → canonicalization-CyrrXGmj-CeKUkht1.d.mts} +3 -3
  13. package/dist/{canonicalization-DFpB09nP-4OdB2nsy.d.mts.map → canonicalization-CyrrXGmj-CeKUkht1.d.mts.map} +1 -1
  14. package/dist/{hashing-utils-DQgS3nOe.mjs → canonicalization-path-match-D88xLEq6-BFQC39ZG.mjs} +23 -3
  15. package/dist/canonicalization-path-match-D88xLEq6-BFQC39ZG.mjs.map +1 -0
  16. package/dist/{utils-DMAM0unR.mjs → canonicalize-json-ZPawceQR-Dua1VNEB.mjs} +2 -2
  17. package/dist/canonicalize-json-ZPawceQR-Dua1VNEB.mjs.map +1 -0
  18. package/dist/codec-B4ypaota.d.mts +289 -0
  19. package/dist/codec-B4ypaota.d.mts.map +1 -0
  20. package/dist/codec-Do8tfXqk.mjs +457 -0
  21. package/dist/codec-Do8tfXqk.mjs.map +1 -0
  22. package/dist/codec-descriptor-D0oY-hgs-C5e11ola.mjs +93 -0
  23. package/dist/codec-descriptor-D0oY-hgs-C5e11ola.mjs.map +1 -0
  24. package/dist/codec-types-BXLUbk-Y-DpGfKGK0.mjs +22 -0
  25. package/dist/codec-types-BXLUbk-Y-DpGfKGK0.mjs.map +1 -0
  26. package/dist/codec-types-CPgEZoIq-BL9hisr8.d.mts +384 -0
  27. package/dist/codec-types-CPgEZoIq-BL9hisr8.d.mts.map +1 -0
  28. package/dist/{components-dZRz3T5y.mjs → components-BaV9iCkq.mjs} +34 -3
  29. package/dist/components-BaV9iCkq.mjs.map +1 -0
  30. package/dist/components-CRBcIta_.d.mts +86 -0
  31. package/dist/components-CRBcIta_.d.mts.map +1 -0
  32. package/dist/components.d.mts +19 -17
  33. package/dist/components.mjs +16 -12
  34. package/dist/components__authoring.d.mts +4 -3
  35. package/dist/components__authoring.mjs +3 -2
  36. package/dist/components__codec.d.mts +3 -3
  37. package/dist/components__codec.mjs +6 -4
  38. package/dist/components__components.d.mts +6 -4
  39. package/dist/components__components.mjs +4 -3
  40. package/dist/components__control.d.mts +5 -4
  41. package/dist/components__control.mjs +3 -2
  42. package/dist/components__emission.d.mts +4 -4
  43. package/dist/components__execution.d.mts +1 -1
  44. package/dist/components__ir.d.mts +1 -1
  45. package/dist/components__ir.mjs +2 -1
  46. package/dist/components__psl-ast.d.mts +4 -4
  47. package/dist/components__psl-ast.mjs +2 -2
  48. package/dist/components__runtime.d.mts +3 -2
  49. package/dist/components__runtime.mjs +2 -2
  50. package/dist/components__utils.mjs +1 -1
  51. package/dist/{config-types-CW4PDwMC.d.mts → config-types-BTFT7QfJ.d.mts} +73 -41
  52. package/dist/config-types-BTFT7QfJ.d.mts.map +1 -0
  53. package/dist/config-types-D0mYyP62.mjs +61 -0
  54. package/dist/config-types-D0mYyP62.mjs.map +1 -0
  55. package/dist/config.d.mts +2 -3
  56. package/dist/config.mjs +2 -3
  57. package/dist/config__config-types.d.mts +2 -2
  58. package/dist/config__config-types.mjs +2 -2
  59. package/dist/contract-authoring.d.mts +152 -17
  60. package/dist/contract-authoring.d.mts.map +1 -1
  61. package/dist/contract-authoring.mjs +190 -9
  62. package/dist/contract-authoring.mjs.map +1 -1
  63. package/dist/{contract-types-CkdMH7F7-9EHXSwbH.d.mts → contract-types-DEIEpzU_-DvAVuBr5.d.mts} +14 -8
  64. package/dist/contract-types-DEIEpzU_-DvAVuBr5.d.mts.map +1 -0
  65. package/dist/{contract-validation-error-DEiWp_EI-CRwtUgRw.mjs → contract-validation-error-CAnTGhkt-DSnujRaK.mjs} +6 -3
  66. package/dist/contract-validation-error-CAnTGhkt-DSnujRaK.mjs.map +1 -0
  67. package/dist/{contract-validation-error-R7cMoK04.d.mts → contract-validation-error-D1QAeOh5.d.mts} +4 -2
  68. package/dist/contract-validation-error-D1QAeOh5.d.mts.map +1 -0
  69. package/dist/contract.d.mts +13 -12
  70. package/dist/contract.mjs +9 -9
  71. package/dist/contract__apply-specifier-default-control-policy.d.mts +1 -1
  72. package/dist/contract__contract-validation-error.d.mts +1 -1
  73. package/dist/contract__contract-validation-error.mjs +1 -1
  74. package/dist/contract__default-namespace.mjs +1 -1
  75. package/dist/contract__enum-accessor.d.mts +2 -2
  76. package/dist/contract__enum-accessor.mjs +1 -1
  77. package/dist/contract__hashing-utils.d.mts +2 -2
  78. package/dist/contract__hashing-utils.mjs +2 -3
  79. package/dist/contract__hashing.d.mts +3 -3
  80. package/dist/contract__hashing.mjs +2 -2
  81. package/dist/contract__resolve-domain-model.d.mts +1 -1
  82. package/dist/contract__types.d.mts +5 -5
  83. package/dist/contract__types.mjs +3 -3
  84. package/dist/contract__validate-domain.d.mts +1 -1
  85. package/dist/contract__validate-domain.mjs +1 -1
  86. package/dist/contract__validate-once.d.mts +2 -0
  87. package/dist/contract__validate-once.mjs +2 -0
  88. package/dist/{control-ql9N9u4f-r3Vv41kZ.d.mts → control-B5ezUWD2-BIAYxeSk.d.mts} +34 -6
  89. package/dist/control-B5ezUWD2-BIAYxeSk.d.mts.map +1 -0
  90. package/dist/{control-DLEm6u5m.mjs → control-DMJqhnwU.mjs} +309 -36
  91. package/dist/control-DMJqhnwU.mjs.map +1 -0
  92. package/dist/control-DrDTlxCS.d.mts +1 -0
  93. package/dist/{control-BD96JZi8-NUhO5Kkw.mjs → control-KsXr4fYD-D2Ows0NI.mjs} +70 -24
  94. package/dist/control-KsXr4fYD-D2Ows0NI.mjs.map +1 -0
  95. package/dist/{control-BF8qzdnM.d.mts → control-s5ECUABR.d.mts} +635 -156
  96. package/dist/control-s5ECUABR.d.mts.map +1 -0
  97. package/dist/data-type-V6mcDhcG-DVQAPOQT.mjs +275 -0
  98. package/dist/data-type-V6mcDhcG-DVQAPOQT.mjs.map +1 -0
  99. package/dist/declarations-BgUAq1RG-Dz_-EI1Q.mjs +459 -0
  100. package/dist/declarations-BgUAq1RG-Dz_-EI1Q.mjs.map +1 -0
  101. package/dist/{default-namespace-D4vCwkXg-lzVN7gSc.mjs → default-namespace-D4vCwkXg-BEZbN38y.mjs} +2 -2
  102. package/dist/{default-namespace-D4vCwkXg-lzVN7gSc.mjs.map → default-namespace-D4vCwkXg-BEZbN38y.mjs.map} +1 -1
  103. package/dist/{dist-Dqbo77p7.mjs → dist-D1f6xr7F.mjs} +51 -24
  104. package/dist/dist-D1f6xr7F.mjs.map +1 -0
  105. package/dist/{domain-envelope-D6Wn9AmZ-BqZKTT9U.d.mts → domain-envelope-CN721GnP-4huRt7Wc.d.mts} +27 -13
  106. package/dist/domain-envelope-CN721GnP-4huRt7Wc.d.mts.map +1 -0
  107. package/dist/emission-BtJvV97M.d.mts +2 -0
  108. package/dist/{emission-types-DLXP34Ki-CFms3VrX.d.mts → emission-types-B-jKEbjI-D7BW8Gk1.d.mts} +17 -16
  109. package/dist/emission-types-B-jKEbjI-D7BW8Gk1.d.mts.map +1 -0
  110. package/dist/enum-accessor-2OZgavDX.d.mts +104 -0
  111. package/dist/enum-accessor-2OZgavDX.d.mts.map +1 -0
  112. package/dist/enum-accessor-B-A2wNok.mjs +122 -0
  113. package/dist/enum-accessor-B-A2wNok.mjs.map +1 -0
  114. package/dist/errors.d.mts +5 -4
  115. package/dist/errors.mjs +4 -4
  116. package/dist/errors__control.d.mts +3 -2
  117. package/dist/errors__control.mjs +2 -2
  118. package/dist/errors__execution.d.mts +2 -2
  119. package/dist/errors__execution.mjs +2 -2
  120. package/dist/errors__migration.d.mts +2 -2
  121. package/dist/errors__migration.mjs +2 -2
  122. package/dist/execution-CjX5CCTb.d.mts +76 -0
  123. package/dist/execution-CjX5CCTb.d.mts.map +1 -0
  124. package/dist/{execution-CSnQT8EX.d.mts → execution-lMPVFj5o.d.mts} +2 -2
  125. package/dist/{execution-CSnQT8EX.d.mts.map → execution-lMPVFj5o.d.mts.map} +1 -1
  126. package/dist/execution-vfY4d-SZ.mjs +138 -0
  127. package/dist/execution-vfY4d-SZ.mjs.map +1 -0
  128. package/dist/{declarations-DR6To8_k-BFwkCGeP.mjs → expressions-CMQzbnHk-BL2zN0Iv.mjs} +199 -350
  129. package/dist/expressions-CMQzbnHk-BL2zN0Iv.mjs.map +1 -0
  130. package/dist/framework-authoring-DDxddXZm-uZYdhoE0.d.mts +1096 -0
  131. package/dist/framework-authoring-DDxddXZm-uZYdhoE0.d.mts.map +1 -0
  132. package/dist/{framework-components-hZ2tO-KH-CdRXBOYd.d.mts → framework-components-DKoQnPdB-lax1COaf.d.mts} +28 -91
  133. package/dist/framework-components-DKoQnPdB-lax1COaf.d.mts.map +1 -0
  134. package/dist/generator-functions-CXbQfvYu-BIFU1Ryx.mjs +271 -0
  135. package/dist/generator-functions-CXbQfvYu-BIFU1Ryx.mjs.map +1 -0
  136. package/dist/{hash-content-DwEUh-Rx.d.mts → hash-content-Bde14N2-.d.mts} +2 -2
  137. package/dist/{hash-content-DwEUh-Rx.d.mts.map → hash-content-Bde14N2-.d.mts.map} +1 -1
  138. package/dist/{hash-content-Bugg_nZn.mjs → hash-content-Bdl-HSfq.mjs} +2 -2
  139. package/dist/hash-content-Bdl-HSfq.mjs.map +1 -0
  140. package/dist/{hashing-BtIZVNYX.mjs → hashing-CLRfNAxh.mjs} +28 -9
  141. package/dist/hashing-CLRfNAxh.mjs.map +1 -0
  142. package/dist/hashing-D-DHz0zl.d.mts +36 -0
  143. package/dist/hashing-D-DHz0zl.d.mts.map +1 -0
  144. package/dist/{hashing-utils-qKu59RSC.d.mts → hashing-utils-DiGHKd3b.d.mts} +4 -3
  145. package/dist/{hashing-utils-qKu59RSC.d.mts.map → hashing-utils-DiGHKd3b.d.mts.map} +1 -1
  146. package/dist/ids.d.mts +90 -13
  147. package/dist/ids.d.mts.map +1 -1
  148. package/dist/ids.mjs +45 -59
  149. package/dist/ids.mjs.map +1 -1
  150. package/dist/ids__runtime.d.mts +1 -1
  151. package/dist/ids__runtime.mjs +1 -1
  152. package/dist/{index-CDk9yEbw.d.mts → index-MU-ksXsh.d.mts} +23 -6
  153. package/dist/index-MU-ksXsh.d.mts.map +1 -0
  154. package/dist/{internal-error-kK8QvlDE.d.mts → internal-error-2fJ9fcZX.d.mts} +2 -2
  155. package/dist/{internal-error-kK8QvlDE.d.mts.map → internal-error-2fJ9fcZX.d.mts.map} +1 -1
  156. package/dist/{internal-error-BIc-ehme-ouBQPoEL.mjs → internal-error-ChGYPVpq-DhUD05u0.mjs} +3 -3
  157. package/dist/internal-error-ChGYPVpq-DhUD05u0.mjs.map +1 -0
  158. package/dist/{ir-BvE7L9FK.d.mts → ir-LV4tXsw3.d.mts} +6 -5
  159. package/dist/{ir-BvE7L9FK.d.mts.map → ir-LV4tXsw3.d.mts.map} +1 -1
  160. package/dist/{ir-ChmSSAhX.mjs → ir-uDGU9vaj.mjs} +7 -53
  161. package/dist/ir-uDGU9vaj.mjs.map +1 -0
  162. package/dist/{migration-BvrgDZXw.d.mts → migration-Dluwnqe9.d.mts} +20 -3
  163. package/dist/migration-Dluwnqe9.d.mts.map +1 -0
  164. package/dist/{migration-C57VKLUY.mjs → migration-uC-bSKA4.mjs} +30 -4
  165. package/dist/migration-uC-bSKA4.mjs.map +1 -0
  166. package/dist/namespace-VUH2dgnS-By5y75h9.mjs +53 -0
  167. package/dist/namespace-VUH2dgnS-By5y75h9.mjs.map +1 -0
  168. package/dist/operations.mjs +1 -1
  169. package/dist/{parse-GbZGfMUj-BFSrD2AN.mjs → parse-bZgfjovA-BNgYhylT.mjs} +311 -55
  170. package/dist/parse-bZgfjovA-BNgYhylT.mjs.map +1 -0
  171. package/dist/{parse-0ZJjj_2N-DhQpSVmQ.d.mts → parse-djL5wker-B610mXG4.d.mts} +181 -52
  172. package/dist/parse-djL5wker-B610mXG4.d.mts.map +1 -0
  173. package/dist/psl-ast-COcYtLlz.d.mts +2 -0
  174. package/dist/psl-ast-CyvE6CR-.mjs +116 -0
  175. package/dist/psl-ast-CyvE6CR-.mjs.map +1 -0
  176. package/dist/{psl-ast-CWJQF8LA-Vr5JNPdn.d.mts → psl-ast-rY25o3Ze-ClLY3CYt.d.mts} +10 -40
  177. package/dist/psl-ast-rY25o3Ze-ClLY3CYt.d.mts.map +1 -0
  178. package/dist/psl-parser.d.mts +415 -101
  179. package/dist/psl-parser.d.mts.map +1 -1
  180. package/dist/psl-parser.mjs +2451 -537
  181. package/dist/psl-parser.mjs.map +1 -1
  182. package/dist/psl-parser__format.d.mts +8 -2
  183. package/dist/psl-parser__format.d.mts.map +1 -1
  184. package/dist/psl-parser__format.mjs +65 -34
  185. package/dist/psl-parser__format.mjs.map +1 -1
  186. package/dist/psl-parser__interpret.d.mts +98 -10
  187. package/dist/psl-parser__interpret.d.mts.map +1 -1
  188. package/dist/psl-parser__interpret.mjs +393 -2
  189. package/dist/psl-parser__interpret.mjs.map +1 -1
  190. package/dist/psl-parser__syntax.d.mts +3 -3
  191. package/dist/psl-parser__syntax.mjs +4 -43
  192. package/dist/psl-parser__tokenizer.d.mts +1 -1
  193. package/dist/psl-parser__tokenizer.mjs +1 -1
  194. package/dist/psl-printer.d.mts +7 -17
  195. package/dist/psl-printer.d.mts.map +1 -1
  196. package/dist/psl-printer.mjs +35 -104
  197. package/dist/psl-printer.mjs.map +1 -1
  198. package/dist/resolve-codec-qqMjZrmn-Cok8elAo.mjs +74 -0
  199. package/dist/resolve-codec-qqMjZrmn-Cok8elAo.mjs.map +1 -0
  200. package/dist/{resolve-domain-model-BVSb5wS5-C6Yq0dsD.d.mts → resolve-domain-model-BNr1glea-BLuR-phK.d.mts} +3 -3
  201. package/dist/resolve-domain-model-BNr1glea-BLuR-phK.d.mts.map +1 -0
  202. package/dist/{result-CBZ8X9mU.mjs → result-8OXF26MN.mjs} +14 -3
  203. package/dist/{result-CBZ8X9mU.mjs.map → result-8OXF26MN.mjs.map} +1 -1
  204. package/dist/{result-Bpupv5vO.d.mts → result-BYCOANWy.d.mts} +4 -2
  205. package/dist/result-BYCOANWy.d.mts.map +1 -0
  206. package/dist/runtime-B-YYuWy2.d.mts +899 -0
  207. package/dist/runtime-B-YYuWy2.d.mts.map +1 -0
  208. package/dist/runtime-DSYSc98Y.mjs +1059 -0
  209. package/dist/runtime-DSYSc98Y.mjs.map +1 -0
  210. package/dist/runtime-error-CO4MA3Px-YW5SCUcH.d.mts +19 -0
  211. package/dist/runtime-error-CO4MA3Px-YW5SCUcH.d.mts.map +1 -0
  212. package/dist/{structured-error-CgiSMpdU.mjs → structured-error-BXbihKQ-.mjs} +3 -3
  213. package/dist/{structured-error-CgiSMpdU.mjs.map → structured-error-BXbihKQ-.mjs.map} +1 -1
  214. package/dist/{structured-error-BsNT4Hun.d.mts → structured-error-Cc7AIRsp.d.mts} +19 -5
  215. package/dist/structured-error-Cc7AIRsp.d.mts.map +1 -0
  216. package/dist/suppress-idle-connection-errors-CKrTbp5P.d.mts +18 -0
  217. package/dist/suppress-idle-connection-errors-CKrTbp5P.d.mts.map +1 -0
  218. package/dist/suppress-idle-connection-errors-DzApeUb3.mjs +22 -0
  219. package/dist/suppress-idle-connection-errors-DzApeUb3.mjs.map +1 -0
  220. package/dist/temporal-presets-5TK1pTYJ-DmhrnMP1.mjs +1276 -0
  221. package/dist/temporal-presets-5TK1pTYJ-DmhrnMP1.mjs.map +1 -0
  222. package/dist/temporal-presets-BuMqk7h8-DZSuu4Z_.d.mts +258 -0
  223. package/dist/temporal-presets-BuMqk7h8-DZSuu4Z_.d.mts.map +1 -0
  224. package/dist/text-C3TTEtgd.mjs +35 -0
  225. package/dist/text-C3TTEtgd.mjs.map +1 -0
  226. package/dist/text-C8_-rheN.d.mts +15 -0
  227. package/dist/text-C8_-rheN.d.mts.map +1 -0
  228. package/dist/{tokenizer-1hAHZzmp-QGPORvmA.mjs → tokenizer-C-GTKKjR-B1vOzJy0.mjs} +54 -10
  229. package/dist/tokenizer-C-GTKKjR-B1vOzJy0.mjs.map +1 -0
  230. package/dist/{tokenizer-DcYI0Xrq-C-nNE9mE.d.mts → tokenizer-i8RaVWVa-7fRwlCPP.d.mts} +9 -4
  231. package/dist/tokenizer-i8RaVWVa-7fRwlCPP.d.mts.map +1 -0
  232. package/dist/ts-render.d.mts +2 -2
  233. package/dist/ts-render.mjs +2 -2
  234. package/dist/type-constructor-calls-BLf-HsFy-D_jbIqj8.mjs +261 -0
  235. package/dist/type-constructor-calls-BLf-HsFy-D_jbIqj8.mjs.map +1 -0
  236. package/dist/{types-BnH4zYvN.mjs → types-B8ULzMAX.mjs} +36 -3
  237. package/dist/types-B8ULzMAX.mjs.map +1 -0
  238. package/dist/types-GNXJ7xW2.d.mts +131 -0
  239. package/dist/types-GNXJ7xW2.d.mts.map +1 -0
  240. package/dist/{types-import-spec-3mjbVBhI-DQI6BvKU.d.mts → types-import-spec-DQjfX-gM-zVncuzs0.d.mts} +6 -6
  241. package/dist/types-import-spec-DQjfX-gM-zVncuzs0.d.mts.map +1 -0
  242. package/dist/utils.d.mts +7 -5
  243. package/dist/utils.mjs +9 -7
  244. package/dist/utils__assertions.mjs +1 -1
  245. package/dist/utils__hash-content.d.mts +1 -1
  246. package/dist/utils__hash-content.mjs +1 -1
  247. package/dist/utils__internal-error.d.mts +1 -1
  248. package/dist/utils__internal-error.mjs +1 -1
  249. package/dist/utils__result.d.mts +2 -2
  250. package/dist/utils__result.mjs +2 -2
  251. package/dist/utils__structured-error.d.mts +2 -2
  252. package/dist/utils__structured-error.mjs +1 -1
  253. package/dist/utils__suppress-idle-connection-errors.d.mts +2 -0
  254. package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
  255. package/dist/utils__text.d.mts +2 -0
  256. package/dist/utils__text.mjs +2 -0
  257. package/dist/{validate-domain-BNBs-TVv.d.mts → validate-domain-B5kmlBFB.d.mts} +10 -6
  258. package/dist/validate-domain-B5kmlBFB.d.mts.map +1 -0
  259. package/dist/{validate-domain-BkvFlY3B.mjs → validate-domain-CbXHDYpF.mjs} +43 -22
  260. package/dist/validate-domain-CbXHDYpF.mjs.map +1 -0
  261. package/dist/validate-once-D-IwXHYP.mjs +42 -0
  262. package/dist/validate-once-D-IwXHYP.mjs.map +1 -0
  263. package/dist/validate-once-gfCOHsDh.d.mts +16 -0
  264. package/dist/validate-once-gfCOHsDh.d.mts.map +1 -0
  265. package/package.json +24 -20
  266. package/dist/apply-specifier-default-control-policy-CAxiXxKg.d.mts.map +0 -1
  267. package/dist/authoring-B2H-9qCv.d.mts +0 -1
  268. package/dist/canonicalization-path-match-CNgHuwM_-CCPBeUuk.mjs +0 -25
  269. package/dist/canonicalization-path-match-CNgHuwM_-CCPBeUuk.mjs.map +0 -1
  270. package/dist/capabilities-BCEONw9w-C-lo3rF8.mjs +0 -120
  271. package/dist/capabilities-BCEONw9w-C-lo3rF8.mjs.map +0 -1
  272. package/dist/codec-Cd0QcxAx.mjs +0 -63
  273. package/dist/codec-Cd0QcxAx.mjs.map +0 -1
  274. package/dist/codec-Ce07W3Mz.d.mts +0 -112
  275. package/dist/codec-Ce07W3Mz.d.mts.map +0 -1
  276. package/dist/codec-types-D6VRj2RE-BLElXc-O.d.mts +0 -223
  277. package/dist/codec-types-D6VRj2RE-BLElXc-O.d.mts.map +0 -1
  278. package/dist/codec-types-DcNvNeY1-BO6kUiH0.mjs +0 -30
  279. package/dist/codec-types-DcNvNeY1-BO6kUiH0.mjs.map +0 -1
  280. package/dist/components-CGA_WwEG.d.mts +0 -50
  281. package/dist/components-CGA_WwEG.d.mts.map +0 -1
  282. package/dist/components-dZRz3T5y.mjs.map +0 -1
  283. package/dist/config-types-BqhNxw0z.mjs +0 -67
  284. package/dist/config-types-BqhNxw0z.mjs.map +0 -1
  285. package/dist/config-types-CW4PDwMC.d.mts.map +0 -1
  286. package/dist/config-validation-DPt5hwQx.mjs +0 -168
  287. package/dist/config-validation-DPt5hwQx.mjs.map +0 -1
  288. package/dist/config-validation-Wiqew2J9.d.mts +0 -21
  289. package/dist/config-validation-Wiqew2J9.d.mts.map +0 -1
  290. package/dist/config__config-validation.d.mts +0 -2
  291. package/dist/config__config-validation.mjs +0 -2
  292. package/dist/contract-types-CkdMH7F7-9EHXSwbH.d.mts.map +0 -1
  293. package/dist/contract-validation-error-DEiWp_EI-CRwtUgRw.mjs.map +0 -1
  294. package/dist/contract-validation-error-R7cMoK04.d.mts.map +0 -1
  295. package/dist/control-BD96JZi8-NUhO5Kkw.mjs.map +0 -1
  296. package/dist/control-BF8qzdnM.d.mts.map +0 -1
  297. package/dist/control-DLEm6u5m.mjs.map +0 -1
  298. package/dist/control-ql9N9u4f-r3Vv41kZ.d.mts.map +0 -1
  299. package/dist/declarations-DR6To8_k-BFwkCGeP.mjs.map +0 -1
  300. package/dist/dist-Dqbo77p7.mjs.map +0 -1
  301. package/dist/domain-envelope-D6Wn9AmZ-BqZKTT9U.d.mts.map +0 -1
  302. package/dist/emission-CmUO03gQ.d.mts +0 -2
  303. package/dist/emission-types-DLXP34Ki-CFms3VrX.d.mts.map +0 -1
  304. package/dist/enum-accessor-Db5DaTNX.mjs +0 -35
  305. package/dist/enum-accessor-Db5DaTNX.mjs.map +0 -1
  306. package/dist/enum-accessor-PH5vjghI.d.mts +0 -85
  307. package/dist/enum-accessor-PH5vjghI.d.mts.map +0 -1
  308. package/dist/execution-Crk6IfTs.mjs +0 -218
  309. package/dist/execution-Crk6IfTs.mjs.map +0 -1
  310. package/dist/execution-Cyl2dXxX.d.mts +0 -115
  311. package/dist/execution-Cyl2dXxX.d.mts.map +0 -1
  312. package/dist/framework-authoring-BhctBwih-DQ_6noDM.d.mts +0 -777
  313. package/dist/framework-authoring-BhctBwih-DQ_6noDM.d.mts.map +0 -1
  314. package/dist/framework-authoring-CDEvlouU-DKklu-fL.mjs +0 -698
  315. package/dist/framework-authoring-CDEvlouU-DKklu-fL.mjs.map +0 -1
  316. package/dist/framework-components-hZ2tO-KH-CdRXBOYd.d.mts.map +0 -1
  317. package/dist/hash-content-Bugg_nZn.mjs.map +0 -1
  318. package/dist/hashing-BtIZVNYX.mjs.map +0 -1
  319. package/dist/hashing-CccSPELN.d.mts +0 -25
  320. package/dist/hashing-CccSPELN.d.mts.map +0 -1
  321. package/dist/hashing-utils-DQgS3nOe.mjs.map +0 -1
  322. package/dist/index-CDk9yEbw.d.mts.map +0 -1
  323. package/dist/internal-error-BIc-ehme-ouBQPoEL.mjs.map +0 -1
  324. package/dist/ir-ChmSSAhX.mjs.map +0 -1
  325. package/dist/migration-BvrgDZXw.d.mts.map +0 -1
  326. package/dist/migration-C57VKLUY.mjs.map +0 -1
  327. package/dist/parse-0ZJjj_2N-DhQpSVmQ.d.mts.map +0 -1
  328. package/dist/parse-GbZGfMUj-BFSrD2AN.mjs.map +0 -1
  329. package/dist/psl-ast-BXZoFQBk.d.mts +0 -37
  330. package/dist/psl-ast-BXZoFQBk.d.mts.map +0 -1
  331. package/dist/psl-ast-CWJQF8LA-Vr5JNPdn.d.mts.map +0 -1
  332. package/dist/psl-ast-DUCvVXbB.mjs +0 -239
  333. package/dist/psl-ast-DUCvVXbB.mjs.map +0 -1
  334. package/dist/psl-parser__syntax.mjs.map +0 -1
  335. package/dist/resolve-codec-BZF8TZh_-D-xORT9Q.mjs +0 -59
  336. package/dist/resolve-codec-BZF8TZh_-D-xORT9Q.mjs.map +0 -1
  337. package/dist/resolve-domain-model-BVSb5wS5-C6Yq0dsD.d.mts.map +0 -1
  338. package/dist/result-Bpupv5vO.d.mts.map +0 -1
  339. package/dist/runtime-BqzioOmU.mjs +0 -670
  340. package/dist/runtime-BqzioOmU.mjs.map +0 -1
  341. package/dist/runtime-Cuxw8obj.d.mts +0 -1038
  342. package/dist/runtime-Cuxw8obj.d.mts.map +0 -1
  343. package/dist/structured-error-BsNT4Hun.d.mts.map +0 -1
  344. package/dist/symbol-table-CZ7EVCTL-CR-ncCpD.d.mts +0 -125
  345. package/dist/symbol-table-CZ7EVCTL-CR-ncCpD.d.mts.map +0 -1
  346. package/dist/tokenizer-1hAHZzmp-QGPORvmA.mjs.map +0 -1
  347. package/dist/tokenizer-DcYI0Xrq-C-nNE9mE.d.mts.map +0 -1
  348. package/dist/types-BnH4zYvN.mjs.map +0 -1
  349. package/dist/types-ByeQhU9p.d.mts +0 -17
  350. package/dist/types-ByeQhU9p.d.mts.map +0 -1
  351. package/dist/types-import-spec-3mjbVBhI-DQI6BvKU.d.mts.map +0 -1
  352. package/dist/utils-DMAM0unR.mjs.map +0 -1
  353. package/dist/validate-domain-BNBs-TVv.d.mts.map +0 -1
  354. package/dist/validate-domain-BkvFlY3B.mjs.map +0 -1
@@ -0,0 +1,1276 @@
1
+ import { t as blindCast } from "./casts-DpaahrlC-Bd5n2coI.mjs";
2
+ import { t as ifDefined } from "./defined-BQWA85QH-BRSBMULx.mjs";
3
+ import { t as InternalError } from "./internal-error-ChGYPVpq-DhUD05u0.mjs";
4
+ import { d as isColumnDefaultLiteralInputValue, f as isExecutionMutationDefaultValue } from "./types-B8ULzMAX.mjs";
5
+ import { n as invariant } from "./assertions-Dw1lZz_Q.mjs";
6
+ import { n as notOk, r as ok } from "./result-8OXF26MN.mjs";
7
+ import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
8
+ import { o as assembleDataTypes } from "./data-type-V6mcDhcG-DVQAPOQT.mjs";
9
+ import { c as tsTemplateText, o as tsQuotedTextSource } from "./dist-D1f6xr7F.mjs";
10
+ //#region ../../../1-framework/1-core/framework-components/dist/temporal-presets-5TK1pTYJ.mjs
11
+ /** The descriptor kinds a `type` namespace holds as leaves. */
12
+ const AUTHORING_TYPE_DESCRIPTOR_KINDS = ["typeConstructor", "typeAlias"];
13
+ const AUTHORING_WARNING_BATCH_THRESHOLD = 5;
14
+ /**
15
+ * Emits collected authoring warnings once per build, grouped by `code`:
16
+ * a group at or below the threshold itemizes every `message`; above it,
17
+ * one summary — `"<count> <summary>"` followed by the `item` lines — so
18
+ * a build with many hits of one kind does not wall-of-text, and warnings
19
+ * of different codes never batch into each other's summary.
20
+ */
21
+ function flushAuthoringWarnings(warnings) {
22
+ const groups = /* @__PURE__ */ new Map();
23
+ for (const warning of warnings) {
24
+ const key = JSON.stringify([warning.code, warning.summary]);
25
+ const group = groups.get(key) ?? [];
26
+ group.push(warning);
27
+ groups.set(key, group);
28
+ }
29
+ for (const group of groups.values()) {
30
+ const first = group[0];
31
+ if (first === void 0) continue;
32
+ if (group.length <= AUTHORING_WARNING_BATCH_THRESHOLD) {
33
+ for (const warning of group) process.emitWarning(warning.message, { code: warning.code });
34
+ continue;
35
+ }
36
+ process.emitWarning(`${group.length} ${first.summary}\n${group.map((w) => ` - ${w.item}`).join("\n")}`, { code: first.code });
37
+ }
38
+ }
39
+ function classifyEnumMemberType(values) {
40
+ let sawText = false;
41
+ let sawInt = false;
42
+ for (const key of Object.keys(values)) {
43
+ const value = values[key];
44
+ if (value === void 0 || typeof value === "string") sawText = true;
45
+ else if (typeof value === "number" && Number.isInteger(value)) sawInt = true;
46
+ else return null;
47
+ }
48
+ if (sawText && sawInt) return null;
49
+ if (sawText) return "text";
50
+ if (sawInt) return "int";
51
+ return null;
52
+ }
53
+ /**
54
+ * Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
55
+ * is inferred from the members via {@link classifyEnumMemberType}; otherwise the
56
+ * explicit `@@type("codec")` argument is parsed. Pushes the appropriate
57
+ * diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
58
+ * the span downstream codec-validation diagnostics should anchor to. Shared by
59
+ * every family's enum factory so inference and the explicit path stay identical.
60
+ */
61
+ function resolveEnumCodecId(block, ctx) {
62
+ const sourceId = ctx.sourceId ?? "unknown";
63
+ const typeAttr = block.attributes["type"];
64
+ if (typeAttr === void 0) {
65
+ const inferredKind = classifyEnumMemberType(block.values);
66
+ if (inferredKind === null || ctx.enumInferenceCodecs === void 0) {
67
+ ctx.diagnostics?.push({
68
+ code: "PSL_ENUM_CANNOT_INFER_TYPE",
69
+ message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`,
70
+ sourceId,
71
+ span: block.span
72
+ });
73
+ return;
74
+ }
75
+ return {
76
+ codecId: ctx.enumInferenceCodecs[inferredKind],
77
+ codecSpan: block.span
78
+ };
79
+ }
80
+ const codecId = typeAttr.args["codecId"];
81
+ invariant(typeof codecId === "string", "@@type on an enum block parses one string argument");
82
+ return {
83
+ codecId,
84
+ codecSpan: typeAttr.argSpans?.["codecId"] ?? typeAttr.span
85
+ };
86
+ }
87
+ function isAuthoringArgRef(value) {
88
+ if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
89
+ const { index, path } = value;
90
+ if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
91
+ if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
92
+ return true;
93
+ }
94
+ function isAuthoringSelectRef(value) {
95
+ if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false;
96
+ const index = value["index"];
97
+ const path = value["path"];
98
+ const cases = value["cases"];
99
+ if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
100
+ if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
101
+ return typeof cases === "object" && cases !== null && !Array.isArray(cases);
102
+ }
103
+ function isAuthoringTemplateRecord(value) {
104
+ return typeof value === "object" && value !== null && !Array.isArray(value);
105
+ }
106
+ function readTemplateArgumentValue(args, index, path) {
107
+ let value = args[index];
108
+ for (const segment of path ?? []) {
109
+ if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return;
110
+ value = value[segment];
111
+ }
112
+ return value;
113
+ }
114
+ function isAuthoringTypeConstructorDescriptor(value) {
115
+ return "kind" in value && value.kind === "typeConstructor";
116
+ }
117
+ function isAuthoringTypeAliasDescriptor(value) {
118
+ return "kind" in value && value.kind === "typeAlias";
119
+ }
120
+ /** Whether `value` is a leaf of a `type` namespace: a type constructor or a type alias. */
121
+ function isAuthoringTypeDescriptor(value) {
122
+ return isAuthoringTypeConstructorDescriptor(value) || isAuthoringTypeAliasDescriptor(value);
123
+ }
124
+ /** The type constructor at `path` in the contributions' type namespace, or `undefined` when none is there. */
125
+ function getAuthoringTypeConstructor(contributions, path) {
126
+ let current = contributions?.type;
127
+ for (const segment of path) {
128
+ if (typeof current !== "object" || current === null || "kind" in current) return;
129
+ current = current[segment];
130
+ }
131
+ return current !== void 0 && isAuthoringTypeConstructorDescriptor(current) ? current : void 0;
132
+ }
133
+ function isAuthoringFieldPresetDescriptor(value) {
134
+ return "kind" in value && value.kind === "fieldPreset";
135
+ }
136
+ function isAuthoringEntityTypeDescriptor(value) {
137
+ return "kind" in value && value.kind === "entity";
138
+ }
139
+ function isAuthoringPslBlockDescriptor(value) {
140
+ return "kind" in value && value.kind === "pslBlock";
141
+ }
142
+ function isAuthoringModelAttributeDescriptor(value) {
143
+ return "kind" in value && value.kind === "modelAttribute";
144
+ }
145
+ function isCopyableNamespaceObject(value) {
146
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
147
+ const proto = Object.getPrototypeOf(value);
148
+ return proto === Object.prototype || proto === null;
149
+ }
150
+ function isWellFormedDescriptor(value, descriptorKinds) {
151
+ if (typeof value !== "object" || value === null || !("kind" in value)) return false;
152
+ const kind = value.kind;
153
+ if (typeof kind !== "string" || !(typeof descriptorKinds === "string" ? [descriptorKinds] : descriptorKinds).includes(kind)) return false;
154
+ switch (kind) {
155
+ case "typeConstructor":
156
+ case "fieldPreset": {
157
+ if (!("output" in value)) return false;
158
+ const output = value.output;
159
+ return typeof output === "object" && output !== null;
160
+ }
161
+ case "typeAlias": {
162
+ if (!("output" in value)) return false;
163
+ const output = value.output;
164
+ if (typeof output !== "object" || output === null || !("type" in output)) return false;
165
+ return typeof output.type === "object" && output.type !== null;
166
+ }
167
+ case "entity": {
168
+ if (!("discriminator" in value) || typeof value.discriminator !== "string") return false;
169
+ if (value.discriminator.length === 0) return false;
170
+ if (!("output" in value)) return false;
171
+ const output = value.output;
172
+ if (typeof output !== "object" || output === null) return false;
173
+ const factory = "factory" in output ? output.factory : void 0;
174
+ const template = "template" in output ? output.template : void 0;
175
+ return typeof factory === "function" || template !== void 0;
176
+ }
177
+ case "pslBlock": {
178
+ if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false;
179
+ if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false;
180
+ if (!("name" in value)) return false;
181
+ const name = value.name;
182
+ if (typeof name !== "object" || name === null) return false;
183
+ if (!("required" in name) || typeof name.required !== "boolean") return false;
184
+ if (!("spec" in value) || typeof value.spec !== "function") return false;
185
+ if (!("attributes" in value) || value.attributes === void 0) return true;
186
+ const attributes = value.attributes;
187
+ if (typeof attributes !== "object" || attributes === null || Array.isArray(attributes)) return false;
188
+ return Object.values(attributes).every((factory) => typeof factory === "function");
189
+ }
190
+ case "modelAttribute":
191
+ if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false;
192
+ if (!("spec" in value)) return false;
193
+ return "lower" in value && typeof value.lower === "function";
194
+ default: return false;
195
+ }
196
+ }
197
+ function deepCopyNamespace(source, descriptorKind) {
198
+ const copy = {};
199
+ for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value;
200
+ return copy;
201
+ }
202
+ /**
203
+ * Merges `source` into `target` recursively at the descriptor-namespace
204
+ * level. `descriptorKind` is the `kind` value, or values, ('typeConstructor'
205
+ * and 'typeAlias', 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
206
+ * (terminal merge point; same-path registrations across components are
207
+ * reported as duplicates) as opposed to a sub-namespace (recursion target).
208
+ *
209
+ * Path segments are validated against prototype-pollution names
210
+ * (`__proto__`, `constructor`, `prototype`). A value that is neither a
211
+ * recognized leaf nor a plain object — e.g. a malformed descriptor
212
+ * where the canonical leaf guard rejected it for missing `output` —
213
+ * is reported as an invalid contribution rather than recursed into,
214
+ * which would either silently mangle state or infinite-loop on
215
+ * primitive properties.
216
+ *
217
+ * Within-registry duplicate detection is this walker's job;
218
+ * cross-registry detection runs separately via
219
+ * `assertNoCrossRegistryCollisions` after merging completes.
220
+ */
221
+ function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) {
222
+ const assertSafePath = (currentPath) => {
223
+ const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype");
224
+ if (blockedSegment) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`);
225
+ };
226
+ for (const [key, sourceValue] of Object.entries(source)) {
227
+ const currentPath = [...path, key];
228
+ assertSafePath(currentPath);
229
+ const hasExistingValue = Object.hasOwn(target, key);
230
+ const existingValue = hasExistingValue ? target[key] : void 0;
231
+ if (!hasExistingValue) {
232
+ target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue;
233
+ continue;
234
+ }
235
+ const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind);
236
+ const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind);
237
+ if (existingIsLeaf || sourceIsLeaf) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`);
238
+ if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`);
239
+ mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label);
240
+ }
241
+ }
242
+ const ATTRIBUTE_SPEC_LEVELS = ["model", "field"];
243
+ function mergeAuthoringAttributeSpecs(target, source, contributedBy, owners) {
244
+ const invalidContribution = (detail) => runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring attributeSpecs contribution from descriptor "${contributedBy}". ${detail}`);
245
+ if (!isCopyableNamespaceObject(source)) throw invalidContribution("Expected a record carrying a \"model\" and a \"field\" level.");
246
+ for (const level of ATTRIBUTE_SPEC_LEVELS) {
247
+ const contributed = source[level];
248
+ if (!isCopyableNamespaceObject(contributed)) throw invalidContribution(`The "${level}" level must be a record of spec factories keyed by attribute name.`);
249
+ for (const [attribute, factory] of Object.entries(contributed)) {
250
+ const entryPath = `${level}.${attribute}`;
251
+ const invalidEntry = (detail) => runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring attributeSpecs entry "${entryPath}" contributed by descriptor "${contributedBy}". ${detail}`);
252
+ if (attribute === "__proto__" || attribute === "constructor" || attribute === "prototype") throw invalidEntry(`Attribute names must not use "${attribute}".`);
253
+ if (typeof factory !== "function") throw invalidEntry("Each entry must be a spec factory function.");
254
+ const existingOwner = owners.get(entryPath);
255
+ if (existingOwner !== void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate authoring attributeSpecs entry "${entryPath}". Descriptor "${contributedBy}" conflicts with "${existingOwner}". Each attribute name may be claimed once per level.`);
256
+ owners.set(entryPath, contributedBy);
257
+ target[level][attribute] = factory;
258
+ }
259
+ }
260
+ }
261
+ /**
262
+ * Collects the full dotted paths of every well-formed descriptor of
263
+ * `descriptorKind` in a raw contribution tree, using the same boundary
264
+ * classification as {@link mergeAuthoringNamespaces}. Lets assembly-level
265
+ * callers attribute each contributed path to its contributing component
266
+ * before merging, so a same-path collision can be reported naming both
267
+ * contributors.
268
+ */
269
+ function collectContributedDescriptorPaths(namespace, descriptorKind, path = []) {
270
+ const paths = [];
271
+ for (const [key, value] of Object.entries(namespace)) {
272
+ const currentPath = [...path, key];
273
+ if (isWellFormedDescriptor(value, descriptorKind)) {
274
+ paths.push(currentPath.join("."));
275
+ continue;
276
+ }
277
+ if (isCopyableNamespaceObject(value)) paths.push(...collectContributedDescriptorPaths(value, descriptorKind, currentPath));
278
+ }
279
+ return paths;
280
+ }
281
+ /**
282
+ * Derives the scalar view of an assembled authoring type namespace: every
283
+ * **top-level** type constructor that is instantiable with an empty argument
284
+ * list — all declared args optional and no entity-ref argument. A bare type
285
+ * name `T` in a schema is semantically the zero-arg instantiation `T()`, so
286
+ * each entry is exactly what that call produces (defaulted template values
287
+ * applied, absent optional-arg typeParams keys omitted). Constructors
288
+ * registered under a namespace segment, constructors with required args, and
289
+ * entity-ref constructors are not scalars and are excluded.
290
+ *
291
+ * Eligibility needs no template inspection: templates that cannot resolve
292
+ * for their legal call shapes are rejected at the composition boundary by
293
+ * {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
294
+ * instantiation below cannot fail for an eligible constructor.
295
+ */
296
+ function collectScalarTypeConstructors(namespace) {
297
+ const result = /* @__PURE__ */ new Map();
298
+ for (const [name, value] of Object.entries(namespace)) {
299
+ if (!isAuthoringTypeConstructorDescriptor(value)) continue;
300
+ if (value.entityRefArg !== void 0) continue;
301
+ if (value.args?.some((arg) => arg.optional !== true)) continue;
302
+ result.set(name, instantiateAuthoringTypeConstructor(value, []));
303
+ }
304
+ return result;
305
+ }
306
+ function visitTemplateArgRefs(template, visit) {
307
+ if (template === void 0) return;
308
+ if (isAuthoringArgRef(template)) {
309
+ visit(template);
310
+ visitTemplateArgRefs(template.default, visit);
311
+ return;
312
+ }
313
+ if (Array.isArray(template)) {
314
+ for (const value of template) visitTemplateArgRefs(value, visit);
315
+ return;
316
+ }
317
+ if (typeof template === "object" && template !== null) for (const value of Object.values(template)) visitTemplateArgRefs(value, visit);
318
+ }
319
+ /**
320
+ * Boundary validation for a contributed authoring type namespace, called
321
+ * per contributing component at assembly (which supplies `contributedBy`
322
+ * for attribution). Rejects what the types cannot express — entity-ref
323
+ * constructors are skipped (their output derives from the referenced
324
+ * entity): every `typeParams` arg-ref (including refs inside arg-ref
325
+ * defaults) must point at a declared argument index.
326
+ */
327
+ function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path = []) {
328
+ for (const [name, value] of Object.entries(namespace)) {
329
+ const currentPath = [...path, name];
330
+ if (isAuthoringTypeAliasDescriptor(value)) {
331
+ for (const [key, template] of Object.entries(value.output.type.typeParams ?? {})) visitTemplateArgRefs(template, () => {
332
+ throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring type alias "${currentPath.join(".")}" contributed by descriptor "${contributedBy}". output.type.typeParams.${key} references an argument, but a type alias takes none. Write the value itself.`);
333
+ });
334
+ continue;
335
+ }
336
+ if (!isAuthoringTypeConstructorDescriptor(value)) {
337
+ assertResolvableTypeConstructorTemplates(value, contributedBy, currentPath);
338
+ continue;
339
+ }
340
+ if (value.entityRefArg !== void 0) continue;
341
+ const args = value.args ?? [];
342
+ const invalid = (detail) => /* @__PURE__ */ new Error(`Invalid authoring type constructor "${currentPath.join(".")}" contributed by descriptor "${contributedBy}". ${detail}`);
343
+ for (const [key, template] of Object.entries(value.output.typeParams ?? {})) visitTemplateArgRefs(template, (ref) => {
344
+ if (args[ref.index] === void 0) throw invalid(`output.typeParams.${key} references argument ${ref.index}, but the constructor declares ${args.length} argument(s). Declare the argument or correct the reference index.`);
345
+ });
346
+ }
347
+ }
348
+ function collectDescriptorPaths(namespace, isLeaf, path = []) {
349
+ const paths = [];
350
+ for (const [key, value] of Object.entries(namespace)) {
351
+ const currentPath = [...path, key];
352
+ if (isLeaf(value)) {
353
+ paths.push(currentPath.join("."));
354
+ continue;
355
+ }
356
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath));
357
+ }
358
+ return paths;
359
+ }
360
+ function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) {
361
+ const entries = [];
362
+ for (const [key, value] of Object.entries(namespace)) {
363
+ const currentPath = [...path, key];
364
+ if (isLeaf(value)) {
365
+ if (!isWellFormedDescriptor(value, descriptorKind)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
366
+ if (value.discriminator.length > 0) entries.push({
367
+ path: currentPath.join("."),
368
+ discriminator: value.discriminator
369
+ });
370
+ continue;
371
+ }
372
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
373
+ const record = blindCast(value);
374
+ if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) {
375
+ const hasKind = record["kind"] === "pslBlock";
376
+ const hasKeyword = typeof record["keyword"] === "string";
377
+ const hasDiscriminator = typeof record["discriminator"] === "string";
378
+ if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
379
+ }
380
+ entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath));
381
+ }
382
+ }
383
+ return entries;
384
+ }
385
+ /**
386
+ * Throws when two or more entries in the same namespace share a key. A
387
+ * duplicate key makes dispatch ambiguous — the caller's lookup dispatches by
388
+ * this key, so one entry would silently shadow the other. Catch duplicates
389
+ * before building any dispatch map.
390
+ *
391
+ * `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the
392
+ * duplicate was found in and is carried in the structured error metadata;
393
+ * the key itself is always called `key` in both the message and the
394
+ * metadata, since what it semantically represents (a discriminator for
395
+ * `entityType`, the parser's dispatch keyword for `pslBlock`) is the
396
+ * caller's concern, not this function's.
397
+ */
398
+ function assertUniqueDiscriminators(entries, label) {
399
+ const seen = /* @__PURE__ */ new Map();
400
+ for (const { path, discriminator: key } of entries) {
401
+ const existing = seen.get(key);
402
+ if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, {
403
+ label,
404
+ key,
405
+ existingPath: existing,
406
+ path
407
+ });
408
+ seen.set(key, path);
409
+ }
410
+ }
411
+ function collectPslBlockDescriptorEntries(namespace, path = []) {
412
+ const entries = [];
413
+ for (const [key, value] of Object.entries(namespace)) {
414
+ const currentPath = [...path, key];
415
+ if (isAuthoringPslBlockDescriptor(value)) {
416
+ if (!isWellFormedDescriptor(value, "pslBlock")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
417
+ entries.push({
418
+ path: currentPath.join("."),
419
+ discriminator: value.discriminator,
420
+ keyword: value.keyword
421
+ });
422
+ continue;
423
+ }
424
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
425
+ const record = blindCast(value);
426
+ const hasKind = record["kind"] === "pslBlock";
427
+ const hasKeyword = typeof record["keyword"] === "string";
428
+ const hasDiscriminator = typeof record["discriminator"] === "string";
429
+ if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
430
+ entries.push(...collectPslBlockDescriptorEntries(value, currentPath));
431
+ }
432
+ }
433
+ return entries;
434
+ }
435
+ /**
436
+ * Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory
437
+ * with the same discriminator. An `entityTypes` factory may stand alone (e.g.
438
+ * `enum`, reachable from the TypeScript builder without any PSL block).
439
+ *
440
+ * Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator:
441
+ * several keywords (e.g. `policy_select`/`policy_insert`) may legitimately
442
+ * share one discriminator, routing to the same `entityTypes` factory and the
443
+ * same `entries[discriminator]` slot — that N:1 shape is exactly what lets
444
+ * one entity kind be authored through several PSL keywords. What must stay
445
+ * unique is the keyword itself, since that's what the parser dispatches on.
446
+ */
447
+ function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) {
448
+ const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);
449
+ const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType");
450
+ assertUniqueDiscriminators(blockEntries.map((entry) => ({
451
+ path: entry.path,
452
+ discriminator: entry.keyword
453
+ })), "pslBlock");
454
+ assertUniqueDiscriminators(entityEntries, "entityType");
455
+ const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));
456
+ for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`);
457
+ }
458
+ function collectModelAttributeEntries(namespace, path = []) {
459
+ const entries = [];
460
+ for (const [key, value] of Object.entries(namespace)) {
461
+ const currentPath = [...path, key];
462
+ if (isAuthoringModelAttributeDescriptor(value)) {
463
+ if (!isWellFormedDescriptor(value, "modelAttribute")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
464
+ entries.push({
465
+ path: currentPath.join("."),
466
+ discriminator: value.attribute
467
+ });
468
+ continue;
469
+ }
470
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
471
+ const record = blindCast(value);
472
+ if (typeof record["attribute"] === "string" && "spec" in record) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
473
+ entries.push(...collectModelAttributeEntries(value, currentPath));
474
+ }
475
+ }
476
+ return entries;
477
+ }
478
+ /**
479
+ * Throws when two modelAttribute contributions — at any paths, even
480
+ * different ones — claim the same bare `@@` attribute name. The family
481
+ * interpreter dispatches by attribute name, not by registration path, so
482
+ * two descriptors claiming the same name would have one silently shadow
483
+ * the other.
484
+ */
485
+ function assertUniqueModelAttributeNames(entries) {
486
+ const seen = /* @__PURE__ */ new Map();
487
+ for (const { path, discriminator: attribute } of entries) {
488
+ const existing = seen.get(attribute);
489
+ if (existing !== void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`);
490
+ seen.set(attribute, path);
491
+ }
492
+ }
493
+ function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
494
+ const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeDescriptor));
495
+ const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
496
+ const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
497
+ const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
498
+ for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor or type alias and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
499
+ for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor, type alias or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
500
+ assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);
501
+ assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace));
502
+ assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace);
503
+ }
504
+ function collectDescriptorNodes(namespace, isLeaf, path = []) {
505
+ const nodes = [];
506
+ for (const [key, value] of Object.entries(namespace)) {
507
+ const currentPath = [...path, key];
508
+ if (isLeaf(value)) {
509
+ nodes.push([currentPath.join("."), value]);
510
+ continue;
511
+ }
512
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath));
513
+ }
514
+ return nodes;
515
+ }
516
+ function collectSelectRefs(value, found) {
517
+ if (typeof value !== "object" || value === null) return;
518
+ if (isAuthoringSelectRef(value)) {
519
+ found.push(value);
520
+ for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found);
521
+ return;
522
+ }
523
+ if (isAuthoringArgRef(value)) {
524
+ collectSelectRefs(value.default, found);
525
+ return;
526
+ }
527
+ if (Array.isArray(value)) {
528
+ for (const entry of value) collectSelectRefs(entry, found);
529
+ return;
530
+ }
531
+ for (const entry of Object.values(value)) collectSelectRefs(entry, found);
532
+ }
533
+ function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) {
534
+ const selects = [];
535
+ collectSelectRefs(templateRoot, selects);
536
+ for (const select of selects) {
537
+ const position = `#${select.index + 1}`;
538
+ let descriptor = args?.[select.index];
539
+ if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`);
540
+ for (const segment of select.path ?? []) {
541
+ descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0;
542
+ if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`);
543
+ }
544
+ if (descriptor.kind !== "option") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`);
545
+ const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position;
546
+ const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value));
547
+ if (missing.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`);
548
+ const values = descriptor.values;
549
+ const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key));
550
+ if (unreachable.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`);
551
+ }
552
+ }
553
+ /**
554
+ * Every `select` template node must target an option argument whose `values`
555
+ * exactly cover the node's `cases` — a legal token with no case and a case no
556
+ * token can reach are both declaration bugs, caught here at pack-registration
557
+ * time rather than at first resolution.
558
+ */
559
+ function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) {
560
+ for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output);
561
+ for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeDescriptor)) if (isAuthoringTypeConstructorDescriptor(descriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output);
562
+ for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template);
563
+ }
564
+ function resolveAuthoringTemplateValue(template, args) {
565
+ if (template === void 0) return;
566
+ if (isAuthoringArgRef(template)) {
567
+ const value = readTemplateArgumentValue(args, template.index, template.path);
568
+ if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
569
+ return value;
570
+ }
571
+ if (isAuthoringSelectRef(template)) {
572
+ const value = readTemplateArgumentValue(args, template.index, template.path);
573
+ if (value === void 0) return;
574
+ if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new InternalError(`Authoring template select has no case for value "${String(value)}"`);
575
+ return resolveAuthoringTemplateValue(template.cases[value], args);
576
+ }
577
+ if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
578
+ if (typeof template === "object" && template !== null) {
579
+ const resolved = {};
580
+ for (const [key, value] of Object.entries(template)) {
581
+ const resolvedValue = resolveAuthoringTemplateValue(value, args);
582
+ if (resolvedValue !== void 0) resolved[key] = resolvedValue;
583
+ }
584
+ return resolved;
585
+ }
586
+ return template;
587
+ }
588
+ function validateAuthoringArgument(descriptor, value, path) {
589
+ if (value === void 0) {
590
+ if (descriptor.optional) return;
591
+ throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} is missing`);
592
+ }
593
+ if (descriptor.kind === "value") return;
594
+ if (descriptor.kind === "object") {
595
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be an object`);
596
+ const input = value;
597
+ const expectedKeys = new Set(Object.keys(descriptor.properties));
598
+ for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} contains unknown property "${key}"`);
599
+ for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
600
+ return;
601
+ }
602
+ if (descriptor.kind === "option") {
603
+ if (typeof value !== "string" || !descriptor.values.includes(value)) {
604
+ const quoted = descriptor.values.map((option) => JSON.stringify(option));
605
+ throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} ${quoted.length === 0 ? "takes no value" : `must be ${quoted.length === 1 ? quoted.join("") : `one of ${quoted.join(", ")}`}`}; received ${describeReceivedArgument(value)}`);
606
+ }
607
+ return;
608
+ }
609
+ if (typeof value !== "number" || Number.isNaN(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be a number`);
610
+ if (descriptor.integer && !Number.isInteger(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be an integer`);
611
+ if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be >= ${descriptor.minimum}, received ${value}`);
612
+ if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${path} must be <= ${descriptor.maximum}, received ${value}`);
613
+ }
614
+ function validateAuthoringHelperArguments(helperPath, descriptors, args) {
615
+ const expected = descriptors ?? [];
616
+ const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
617
+ if (args.length < minimumArgs || args.length > expected.length) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
618
+ expected.forEach((descriptor, index) => {
619
+ validateAuthoringArgument(descriptor, args[index], argumentLabel(helperPath, descriptor, index));
620
+ });
621
+ }
622
+ function argumentLabel(helperPath, descriptor, index) {
623
+ return descriptor.name === void 0 ? `Authoring helper argument at ${helperPath}[${index}]` : `Argument "${descriptor.name}" of ${helperPath}`;
624
+ }
625
+ function describeReceivedArgument(value) {
626
+ return typeof value === "string" ? JSON.stringify(value) : String(value);
627
+ }
628
+ function argumentIndexOf(template) {
629
+ let index;
630
+ visitTemplateArgRefs(template, (ref) => {
631
+ index ??= ref.index;
632
+ });
633
+ return index;
634
+ }
635
+ function issueKey(issue) {
636
+ const [first] = issue.path ?? [];
637
+ const key = typeof first === "object" && first !== null ? first.key : first;
638
+ return typeof key === "string" ? key : void 0;
639
+ }
640
+ function authoringTypeParamsIssue(template, typeParams, paramsSchema) {
641
+ if (template.typeParams === void 0 || paramsSchema === void 0) return void 0;
642
+ const result = paramsSchema["~standard"].validate(typeParams ?? {});
643
+ if (result instanceof Promise) throw new InternalError(`The parameter schema of codec "${template.codecId}" is asynchronous; authoring requires a synchronous schema.`);
644
+ const [issue] = result.issues ?? [];
645
+ if (issue === void 0) return void 0;
646
+ const key = issueKey(issue);
647
+ return {
648
+ message: issue.message,
649
+ argumentIndex: key === void 0 ? void 0 : argumentIndexOf(template.typeParams[key])
650
+ };
651
+ }
652
+ /**
653
+ * Checks the type parameters a constructor or preset produced against its codec's parameter schema, which is where the bounds of a data type's parameters are written. A failure names the argument the failing parameter came from.
654
+ */
655
+ function validateAuthoringTypeParams(helperPath, template, typeParams, paramsSchema) {
656
+ const issue = authoringTypeParamsIssue(template, typeParams, paramsSchema);
657
+ if (issue === void 0) return;
658
+ const { argumentIndex } = issue;
659
+ throw runtimeError("CONTRACT.ARGUMENT_INVALID", argumentIndex === void 0 ? `The type parameters of ${helperPath} are invalid: ${issue.message}` : `Authoring helper argument at ${helperPath}[${argumentIndex}] is invalid: ${issue.message}`, {
660
+ helperPath,
661
+ ...ifDefined("argumentIndex", argumentIndex)
662
+ });
663
+ }
664
+ function resolveAuthoringStorageTypeTemplate(template, args) {
665
+ const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
666
+ if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
667
+ const normalizedTypeParams = typeParams !== void 0 && Object.keys(typeParams).length === 0 ? void 0 : typeParams;
668
+ return {
669
+ codecId: template.codecId,
670
+ ...ifDefined("typeParams", normalizedTypeParams)
671
+ };
672
+ }
673
+ function resolveAuthoringColumnDefaultTemplate(template, args) {
674
+ if (template.kind === "literal") {
675
+ const value = resolveAuthoringTemplateValue(template.value, args);
676
+ if (value === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", "Resolved authoring literal default must not be undefined");
677
+ if (!isColumnDefaultLiteralInputValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
678
+ return {
679
+ kind: "literal",
680
+ value
681
+ };
682
+ }
683
+ const expression = resolveAuthoringTemplateValue(template.expression, args);
684
+ if (expression === void 0 || typeof expression === "object" && expression !== null) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
685
+ return {
686
+ kind: "function",
687
+ expression: String(expression)
688
+ };
689
+ }
690
+ function resolveExecutionMutationDefaultPhase(phase, template, args) {
691
+ const value = resolveAuthoringTemplateValue(template, args);
692
+ if (value === void 0) return;
693
+ if (!isExecutionMutationDefaultValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
694
+ if (value.params !== void 0 && Object.keys(value.params).length === 0) {
695
+ const { params: _unfilled, ...generator } = value;
696
+ return generator;
697
+ }
698
+ return value;
699
+ }
700
+ function resolveAuthoringExecutionDefaultsTemplate(template, args) {
701
+ const phases = {
702
+ ...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
703
+ ...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
704
+ };
705
+ return Object.keys(phases).length === 0 ? void 0 : phases;
706
+ }
707
+ function instantiateAuthoringTypeConstructor(descriptor, args) {
708
+ return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
709
+ }
710
+ function instantiateAuthoringTypeAlias(descriptor) {
711
+ const { output } = descriptor;
712
+ return {
713
+ type: resolveAuthoringStorageTypeTemplate(output.type, []),
714
+ ...ifDefined("onCreate", output.onCreate),
715
+ ...ifDefined("onUpdate", output.onUpdate)
716
+ };
717
+ }
718
+ const GENERATOR_PHASE_TEXT = {
719
+ onCreate: "on create",
720
+ onUpdate: "on update"
721
+ };
722
+ /**
723
+ * The generators the calls of the type alias at `path` resolve to for its column, or `undefined` when it calls none. A call that does not resolve is the pack's mistake, so it throws `CONTRACT.PACK_CONTRIBUTION_INVALID`. `length` is the column's length, in its data type's normal form, when the caller's family knows it.
724
+ */
725
+ function resolveTypeAliasGenerators(input) {
726
+ const { type, ...calls } = instantiateAuthoringTypeAlias(input.descriptor);
727
+ const phases = {};
728
+ for (const phase of ["onCreate", "onUpdate"]) {
729
+ const call = calls[phase];
730
+ if (call === void 0) continue;
731
+ const resolution = input.generatorFunctions.resolve(call, {
732
+ codecId: type.codecId,
733
+ typeParams: type.typeParams,
734
+ length: input.length
735
+ });
736
+ if (resolution.ok) {
737
+ phases[phase] = resolution.generator;
738
+ continue;
739
+ }
740
+ const written = `Type alias "${input.path}" calls ${call.name}() ${GENERATOR_PHASE_TEXT[phase]}`;
741
+ throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", resolution.reason === "refused" ? `${written}, which its codec "${type.codecId}" refuses: ${resolution.message}` : resolution.reason === "not-bound" ? `${written}, which does not apply to its codec "${type.codecId}".` : `${written}, but no component declares the generator function "${call.name}".`);
742
+ }
743
+ return phases.onCreate === void 0 && phases.onUpdate === void 0 ? void 0 : phases;
744
+ }
745
+ /**
746
+ * Refuses a type alias of `namespace` whose fixed type params its codec's parameter schema refuses, or whose generator call does not resolve for its codec and length. The control stack and the TypeScript builders call it on their assembled namespace, so PSL and TypeScript refuse the same packs, before any schema is read.
747
+ */
748
+ function assertTypeAliasesValid(namespace, lookups) {
749
+ for (const [path, descriptor] of collectDescriptorNodes(namespace, isAuthoringTypeDescriptor)) {
750
+ if (!isAuthoringTypeAliasDescriptor(descriptor)) continue;
751
+ const { type } = instantiateAuthoringTypeAlias(descriptor);
752
+ const issue = authoringTypeParamsIssue(descriptor.output.type, type.typeParams, lookups.paramsSchemaOf(type.codecId));
753
+ if (issue !== void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Type alias "${path}" fixes type parameters its codec "${type.codecId}" refuses: ${issue.message}`);
754
+ resolveTypeAliasGenerators({
755
+ path,
756
+ descriptor,
757
+ generatorFunctions: lookups.generatorFunctions,
758
+ length: lookups.fieldLength({
759
+ codecId: type.codecId,
760
+ typeParams: type.typeParams
761
+ })
762
+ });
763
+ }
764
+ }
765
+ /**
766
+ * The column a type constructor makes from the stored values of its arguments, as a reader that holds values rather than written arguments has them, or why its codec's parameter schema refuses the parameters they give. The schema check is {@link validateAuthoringTypeParams}'s.
767
+ */
768
+ function instantiateAuthoringTypeConstructorFromValues(descriptor, values, paramsSchema) {
769
+ const output = instantiateAuthoringTypeConstructor(descriptor, values);
770
+ const issue = authoringTypeParamsIssue(descriptor.output, output.typeParams, paramsSchema);
771
+ return issue === void 0 ? ok(output) : notOk(issue);
772
+ }
773
+ function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
774
+ if ("factory" in descriptor.output) {
775
+ const input = args[0];
776
+ return blindCast(descriptor.output.factory)(input, ctx);
777
+ }
778
+ validateAuthoringHelperArguments(helperPath, descriptor.args, args);
779
+ return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
780
+ }
781
+ function instantiateAuthoringFieldPreset(descriptor, args) {
782
+ return {
783
+ descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
784
+ nullable: descriptor.output.nullable ?? false,
785
+ ...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
786
+ ...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
787
+ id: descriptor.output.id ?? false,
788
+ unique: descriptor.output.unique ?? false
789
+ };
790
+ }
791
+ const UNKNOWN_CONTRIBUTOR = "<unknown>";
792
+ /** Merge every component's PSL support for its data types, refusing two claims on one key. */
793
+ function assembleAuthoringDataTypes(components) {
794
+ const merged = {};
795
+ const owners = /* @__PURE__ */ new Map();
796
+ for (const component of components) {
797
+ const contributedBy = component.id ?? UNKNOWN_CONTRIBUTOR;
798
+ for (const [key, entry] of Object.entries(component.authoring?.dataTypes ?? {})) {
799
+ const existingOwner = owners.get(key);
800
+ if (existingOwner !== void 0) throw runtimeError("CONTRACT.DATA_TYPE_ENTRY_DUPLICATE", `Duplicate authoring entry for "${key}". Component "${contributedBy}" conflicts with "${existingOwner}".`, {
801
+ key,
802
+ contributedBy,
803
+ owner: existingOwner
804
+ });
805
+ owners.set(key, contributedBy);
806
+ merged[key] = entry;
807
+ }
808
+ }
809
+ return merged;
810
+ }
811
+ function descriptorsIn(namespace, isLeaf, path = []) {
812
+ return Object.entries(namespace ?? {}).flatMap(([key, value]) => {
813
+ const currentPath = [...path, key];
814
+ if (isLeaf(value)) return [{
815
+ path: currentPath.join("."),
816
+ descriptor: value
817
+ }];
818
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return [];
819
+ return descriptorsIn(value, isLeaf, currentPath);
820
+ });
821
+ }
822
+ /** Every type constructor and field preset a component contributes. */
823
+ function contributedHelpers(component) {
824
+ return [...descriptorsIn(component.authoring?.type, isAuthoringTypeDescriptor).flatMap(({ path, descriptor }) => isAuthoringTypeConstructorDescriptor(descriptor) ? [{
825
+ path,
826
+ descriptor
827
+ }] : []), ...descriptorsIn(component.authoring?.field, isAuthoringFieldPresetDescriptor)].map((entry) => ({
828
+ ...entry,
829
+ contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
830
+ }));
831
+ }
832
+ /** The data types a contract source can write: each entry's own, and every type a plain-number entry classifies a number as. */
833
+ function writableDataTypes(entries) {
834
+ return new Set(entries.flatMap(({ key, entry }) => [key, ...entry.written.kind === "plain" && entry.written.syntax === "number" ? entry.written.types : []]));
835
+ }
836
+ /** Refuses a value argument whose data type is unregistered, or that no contract source can write, directly or through a cast, and a type-constructor argument that is not a value. */
837
+ function enforceValueArguments(support, contributed, writable) {
838
+ const { path, descriptor, contributedBy } = contributed;
839
+ const kind = descriptor.kind === "typeConstructor" ? "type constructor" : "field preset";
840
+ for (const [index, argument] of (descriptor.args ?? []).entries()) {
841
+ const label = `Argument ${argument.name === void 0 ? `#${index + 1}` : `"${argument.name}"`} of ${kind} "${path}"`;
842
+ if (argument.kind !== "value" && descriptor.kind === "typeConstructor") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `${label} contributed by "${contributedBy}" is an argument of kind "${argument.kind}", but a type constructor's argument is a value of a data type. Declare it as { kind: 'value', dataType: ... }, naming the data type its value belongs to.`, {
843
+ packId: contributedBy,
844
+ contribution: path,
845
+ reason: "type-constructor-argument-not-a-value"
846
+ });
847
+ if (argument.kind !== "value") continue;
848
+ const type = support.lookup.get(argument.dataType);
849
+ if (type === void 0) throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${label} names data type "${argument.dataType}", which no component registers. Contributed by "${contributedBy}".`, {
850
+ dataType: argument.dataType,
851
+ contributedBy
852
+ });
853
+ if (![argument.dataType, ...Object.keys(type.casts)].some((admittedType) => writable.has(admittedType))) throw runtimeError("CONTRACT.DATA_TYPE_NOT_WRITABLE", `${label} contributed by "${contributedBy}" takes a value of data type "${argument.dataType}", which no contract source can write.`, {
854
+ dataType: argument.dataType,
855
+ contributedBy
856
+ });
857
+ }
858
+ }
859
+ function textDataTypesOf(components) {
860
+ return components.flatMap((component) => (component.authoring?.textDataTypes ?? []).map((dataType) => ({
861
+ dataType,
862
+ contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
863
+ })));
864
+ }
865
+ /**
866
+ * The checks assembly makes across components on their data types, each naming the component and the id at fault:
867
+ *
868
+ * 1. every codec names a registered data type;
869
+ * 2. every authoring entry, and every type a number classifier returns, names a registered data type;
870
+ * 3. every type a cast takes values of is registered and can be written, because a cast from a type nobody can write is never exercised;
871
+ * 4. no two entries claim one tag or one plain form;
872
+ * 5. every text data type a component names is registered.
873
+ */
874
+ function enforceDataTypeAssemblyInvariants(input) {
875
+ const unregistered = (contributedBy, id, what) => {
876
+ throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${what} names data type "${id}", which no component registers. Contributed by "${contributedBy}".`, {
877
+ dataType: id,
878
+ contributedBy
879
+ });
880
+ };
881
+ for (const codec of input.codecs) if (!input.lookup.has(codec.dataType)) unregistered(codec.contributedBy, codec.dataType, `Codec "${codec.codecId}"`);
882
+ for (const { key, entry, contributedBy } of input.authoringEntries) {
883
+ if (!input.lookup.has(key)) unregistered(contributedBy, key, "Authoring entry");
884
+ if (entry.written.kind === "plain" && entry.written.syntax === "number") {
885
+ for (const classified of entry.written.types) if (!input.lookup.has(classified)) unregistered(contributedBy, classified, `The classifier of authoring entry "${key}"`);
886
+ }
887
+ }
888
+ for (const { dataType, contributedBy } of input.textDataTypes) if (!input.lookup.has(dataType)) unregistered(contributedBy, dataType, "The text data types");
889
+ const writable = writableDataTypes(input.authoringEntries);
890
+ for (const { type, contributedBy } of input.declaredTypes) {
891
+ const sources = [...Object.keys(type.casts), ...type.listCast?.of ?? []];
892
+ for (const source of sources) {
893
+ if (!input.lookup.has(source)) unregistered(contributedBy, source, `The casts of data type "${type.id}"`);
894
+ if (!writable.has(source)) throw runtimeError("CONTRACT.DATA_TYPE_NOT_WRITABLE", `Data type "${type.id}" casts from "${source}", which no contract source can write, so the cast is never exercised. Contributed by "${contributedBy}".`, {
895
+ dataType: type.id,
896
+ source,
897
+ contributedBy
898
+ });
899
+ }
900
+ }
901
+ const claimants = /* @__PURE__ */ new Map();
902
+ for (const { key, entry, contributedBy } of input.authoringEntries) {
903
+ const written = entry.written;
904
+ const claim = written.kind === "tag" ? `tag "${written.tag}"` : `plain ${written.syntax}`;
905
+ const existing = claimants.get(claim);
906
+ if (existing !== void 0) throw runtimeError("CONTRACT.DATA_TYPE_WRITTEN_FORM_DUPLICATE", `Two authoring entries claim the ${claim}: "${key}" from "${contributedBy}" conflicts with "${existing.key}" from "${existing.contributedBy}".`, {
907
+ claim,
908
+ key,
909
+ contributedBy,
910
+ owner: existing.key,
911
+ ownerContributedBy: existing.contributedBy
912
+ });
913
+ claimants.set(claim, {
914
+ key,
915
+ contributedBy
916
+ });
917
+ }
918
+ }
919
+ /**
920
+ * The data types the components register, with their authoring entries, as every contract source reads values with. Refuses two registrations of one data type or one entry key, every case {@link enforceDataTypeAssemblyInvariants} lists, a value argument of a type constructor or field preset whose data type is unregistered or that no contract source can write, and a type-constructor argument that is not a value. ADR 254.
921
+ */
922
+ function assembleDataTypeSupport(components, dataTypeOfCodec) {
923
+ const { lookup, declared } = assembleDataTypes(components);
924
+ const entries = assembleAuthoringDataTypes(components);
925
+ const contributedBy = (component) => component.id ?? UNKNOWN_CONTRIBUTOR;
926
+ const authoringEntries = components.flatMap((component) => Object.entries(component.authoring?.dataTypes ?? {}).map(([key, entry]) => ({
927
+ key,
928
+ entry,
929
+ contributedBy: contributedBy(component)
930
+ })));
931
+ enforceDataTypeAssemblyInvariants({
932
+ lookup,
933
+ declaredTypes: declared,
934
+ codecs: components.flatMap((component) => (component.types?.codecTypes?.codecDescriptors ?? []).map(({ codecId, dataType }) => ({
935
+ codecId,
936
+ dataType,
937
+ contributedBy: contributedBy(component)
938
+ }))),
939
+ authoringEntries,
940
+ textDataTypes: textDataTypesOf(components)
941
+ });
942
+ const support = {
943
+ entries,
944
+ lookup,
945
+ dataTypeOfCodec,
946
+ textDataTypes: [...new Set(components.flatMap((component) => component.authoring?.textDataTypes ?? []))]
947
+ };
948
+ const writable = writableDataTypes(authoringEntries);
949
+ for (const contributed of components.flatMap(contributedHelpers)) enforceValueArguments(support, contributed, writable);
950
+ return {
951
+ support,
952
+ declared
953
+ };
954
+ }
955
+ const TAGGED_LITERAL_MAX_BYTES = 65536;
956
+ /** The message a tagged literal's canonicalization failure is reported with, in PSL and in TypeScript. */
957
+ function describeTaggedLiteralFailure(reason) {
958
+ switch (reason) {
959
+ case "nul": return "Tagged literals must not contain NUL characters.";
960
+ case "too-large": return `Tagged literal exceeds ${TAGGED_LITERAL_MAX_BYTES} bytes.`;
961
+ }
962
+ }
963
+ const PSL_BACKTICK_ESCAPES = /* @__PURE__ */ new Set(["`", "\\"]);
964
+ const TEMPLATE_TAG_ESCAPES = /* @__PURE__ */ new Set([
965
+ "`",
966
+ "\\",
967
+ "$"
968
+ ]);
969
+ /** The escapes a PSL backtick string resolves: `` \` `` and `\\`. PSL has no interpolation, so `${` is ordinary text. */
970
+ function resolvePslBacktickEscapes(raw) {
971
+ return resolveEscapes(raw, PSL_BACKTICK_ESCAPES);
972
+ }
973
+ /** The escapes a TypeScript template tag resolves: the PSL two plus `\$`, the only way to write `${` in a template literal. */
974
+ function resolveTemplateTagEscapes(raw) {
975
+ return resolveEscapes(raw, TEMPLATE_TAG_ESCAPES);
976
+ }
977
+ /** Every other backslash sequence is kept as written, both characters, so a SQL body may contain `E'\n'` unchanged. */
978
+ function resolveEscapes(raw, escapes) {
979
+ let out = "";
980
+ let i = 0;
981
+ while (i < raw.length) {
982
+ const ch = raw.charAt(i);
983
+ const next = raw.charAt(i + 1);
984
+ if (ch === "\\" && escapes.has(next)) {
985
+ out += next;
986
+ i += 2;
987
+ continue;
988
+ }
989
+ out += ch;
990
+ i++;
991
+ }
992
+ return out;
993
+ }
994
+ const BLANK_LINE = /^[ \t]*$/;
995
+ const LEADING_INDENT = /^[ \t]*/;
996
+ const LINE_BREAK = /\r\n|\r|\n/g;
997
+ /**
998
+ * Turns the escape-resolved body of a tagged literal into its canonical text:
999
+ * newlines become `\n`, every blank line before the first non-blank line and
1000
+ * after the last one is dropped, common leading whitespace is removed, internal
1001
+ * blank lines become empty, and no trailing newline is added. The result is its
1002
+ * own canonical text. Fails on a NUL character or when the result is larger
1003
+ * than 65536 UTF-8 bytes.
1004
+ */
1005
+ function canonicalizeTaggedLiteralBody(resolved) {
1006
+ const nul = resolved.indexOf("\0");
1007
+ if (nul !== -1) return {
1008
+ ok: false,
1009
+ reason: "nul",
1010
+ offset: nul
1011
+ };
1012
+ const lines = splitLines(resolved);
1013
+ while (lines.length > 0 && BLANK_LINE.test(lines[0]?.text ?? "")) lines.shift();
1014
+ while (lines.length > 0 && BLANK_LINE.test(lines.at(-1)?.text ?? "")) lines.pop();
1015
+ const indent = commonIndent(lines);
1016
+ const bodyLines = lines.map((line) => BLANK_LINE.test(line.text) ? {
1017
+ text: "",
1018
+ start: line.start
1019
+ } : {
1020
+ text: line.text.slice(indent),
1021
+ start: line.start + indent
1022
+ });
1023
+ const excess = offsetWhereBytesExceed(bodyLines, TAGGED_LITERAL_MAX_BYTES);
1024
+ if (excess !== void 0) return {
1025
+ ok: false,
1026
+ reason: "too-large",
1027
+ offset: excess
1028
+ };
1029
+ return {
1030
+ ok: true,
1031
+ text: bodyLines.map((line) => line.text).join("\n")
1032
+ };
1033
+ }
1034
+ function splitLines(text) {
1035
+ const lines = [];
1036
+ let start = 0;
1037
+ for (const match of text.matchAll(LINE_BREAK)) {
1038
+ lines.push({
1039
+ text: text.slice(start, match.index),
1040
+ start
1041
+ });
1042
+ start = match.index + match[0].length;
1043
+ }
1044
+ lines.push({
1045
+ text: text.slice(start),
1046
+ start
1047
+ });
1048
+ return lines;
1049
+ }
1050
+ function commonIndent(lines) {
1051
+ let indent = Number.POSITIVE_INFINITY;
1052
+ for (const line of lines) {
1053
+ if (BLANK_LINE.test(line.text)) continue;
1054
+ indent = Math.min(indent, LEADING_INDENT.exec(line.text)?.[0].length ?? 0);
1055
+ }
1056
+ return Number.isFinite(indent) ? indent : 0;
1057
+ }
1058
+ /** The resolved-body offset of the first character that pushes the text past `limit` bytes. */
1059
+ function offsetWhereBytesExceed(lines, limit) {
1060
+ let bytes = 0;
1061
+ for (const [index, line] of lines.entries()) {
1062
+ if (index > 0) {
1063
+ bytes += 1;
1064
+ if (bytes > limit) return line.start;
1065
+ }
1066
+ let offsetInLine = 0;
1067
+ for (const char of line.text) {
1068
+ bytes += utf8Length(char.codePointAt(0) ?? 0);
1069
+ if (bytes > limit) return line.start + offsetInLine;
1070
+ offsetInLine += char.length;
1071
+ }
1072
+ }
1073
+ }
1074
+ function utf8Length(codePoint) {
1075
+ if (codePoint < 128) return 1;
1076
+ if (codePoint < 2048) return 2;
1077
+ if (codePoint < 65536) return 3;
1078
+ return 4;
1079
+ }
1080
+ function escapeQuotedText(text) {
1081
+ return text.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
1082
+ }
1083
+ /**
1084
+ * The PSL text of a tagged literal holding `text`: the backtick form, or the double-quote form when the text holds a
1085
+ * backtick, which reads better than escaping each backtick. A multi-line text starts on the line after the opening
1086
+ * backtick, so indentation a printer adds to an enclosing block is common to every line and the canonicalization
1087
+ * removes it. The literal's canonical text is `text` again only when {@link printedTaggedLiteralReadsBack} holds; text
1088
+ * with leading indentation or a carriage return, for example, does not read back. ADR 129.
1089
+ */
1090
+ function printTaggedLiteral(tag, text) {
1091
+ if (text.includes("`")) return `${tag}"${escapeQuotedText(text)}"`;
1092
+ const fenced = text.replace(/\\(?=\\|$)/g, "\\\\");
1093
+ return isPrintedOnOwnLines(text) ? `${tag}\`\n${fenced}\n\`` : `${tag}\`${fenced}\``;
1094
+ }
1095
+ function isPrintedOnOwnLines(text) {
1096
+ return !text.includes("`") && text.includes("\n");
1097
+ }
1098
+ /** Whether the literal {@link printTaggedLiteral} prints for `text` has `text` as its canonical text. */
1099
+ function printedTaggedLiteralReadsBack(text) {
1100
+ const canonical = canonicalizeTaggedLiteralBody(isPrintedOnOwnLines(text) ? `\n${text}\n` : text);
1101
+ return canonical.ok && canonical.text === text;
1102
+ }
1103
+ /**
1104
+ * TypeScript source for `text` in generated code: a template literal with `tag`, or `tsQuotedTextSource(text)`. It
1105
+ * writes a template only when the tag's TypeScript function canonicalizes its text as `canonicalizeTaggedLiteralBody`
1106
+ * does and that leaves `text` unchanged, which holds for `sql`. It also falls back when a line ends in a space or a
1107
+ * tab, which editors strip on save, and when `text` holds a character a template would carry unescaped and invisible.
1108
+ * A multi-line template's lines sit one level deeper than the line it opens on.
1109
+ */
1110
+ function tsTaggedTemplateSource(tag, text) {
1111
+ if (!templateHoldsUnchanged(text)) return {
1112
+ source: tsQuotedTextSource(text),
1113
+ usesTag: false
1114
+ };
1115
+ const escaped = tsTemplateText(text);
1116
+ if (!text.includes("\n")) return {
1117
+ source: `${tag}\`${escaped}\``,
1118
+ usesTag: true
1119
+ };
1120
+ return {
1121
+ source: `${tag}\`\n${escaped.split("\n").map((line) => line.length === 0 ? line : ` ${line}`).join("\n")}\n\``,
1122
+ usesTag: true
1123
+ };
1124
+ }
1125
+ const WHITESPACE_ONLY_LINE = /^\s+$/;
1126
+ const TRAILING_SPACE_OR_TAB = /[ \t]$/;
1127
+ function templateHoldsUnchanged(text) {
1128
+ const canonical = canonicalizeTaggedLiteralBody(text);
1129
+ if (!canonical.ok || canonical.text !== text) return false;
1130
+ const lines = text.split("\n");
1131
+ const indentTreatsAsBlank = (line) => WHITESPACE_ONLY_LINE.test(line) && !BLANK_LINE.test(line);
1132
+ if (lines.some((line) => indentTreatsAsBlank(line) || TRAILING_SPACE_OR_TAB.test(line))) return false;
1133
+ return !holdsCharacterThatNeedsAnEscape(text);
1134
+ }
1135
+ function holdsCharacterThatNeedsAnEscape(text) {
1136
+ for (const char of text) {
1137
+ const code = char.codePointAt(0) ?? 0;
1138
+ if (code < 32 && char !== "\n" && char !== " " || code === 127 || code === 8232 || code === 8233 || code >= 55296 && code <= 57343) return true;
1139
+ }
1140
+ return false;
1141
+ }
1142
+ /**
1143
+ * Canonical id for the wall-clock-now mutation default generator. It flows to the control-plane descriptor and the temporal field presets below, to each family's runtime generator, and to the authoring surfaces (PSL `temporal.updatedAt()`, TS `field.temporal.updatedAt()`) through the descriptor.
1144
+ */
1145
+ const TIMESTAMP_NOW_GENERATOR_ID = "timestampNow";
1146
+ /** Builds the control-plane descriptor for the wall-clock-now mutation default generator. */
1147
+ function timestampNowControlDescriptor() {
1148
+ return { id: TIMESTAMP_NOW_GENERATOR_ID };
1149
+ }
1150
+ /**
1151
+ * Builds the `temporal.{createdAt,updatedAt}` field-preset pair. `createdAt` lowers to an execution generator on `onCreate`; `updatedAt` lowers to the same generator on both `onCreate` and `onUpdate`. The target supplies the storage template of its timestamp codec, which the presets carry through unchanged; everything else is shared, so PSL and TS authoring lower to byte-identical contracts across targets.
1152
+ */
1153
+ /* @__NO_SIDE_EFFECTS__ */
1154
+ function temporalAuthoringPresets(input) {
1155
+ const { generatorId: requestedGeneratorId, ...storage } = input;
1156
+ const generatorId = requestedGeneratorId ?? "timestampNow";
1157
+ return {
1158
+ createdAt: {
1159
+ kind: "fieldPreset",
1160
+ output: {
1161
+ ...storage,
1162
+ executionDefaults: { onCreate: {
1163
+ kind: "generator",
1164
+ id: generatorId
1165
+ } }
1166
+ }
1167
+ },
1168
+ updatedAt: {
1169
+ kind: "fieldPreset",
1170
+ output: {
1171
+ ...storage,
1172
+ executionDefaults: {
1173
+ onCreate: {
1174
+ kind: "generator",
1175
+ id: generatorId
1176
+ },
1177
+ onUpdate: {
1178
+ kind: "generator",
1179
+ id: generatorId
1180
+ }
1181
+ }
1182
+ }
1183
+ }
1184
+ };
1185
+ }
1186
+ const NOW_CALL = {
1187
+ name: "now",
1188
+ args: {}
1189
+ };
1190
+ /**
1191
+ * Builds the `temporal.{CreatedAt,UpdatedAt}` type alias pair for a target's timestamp column type. `CreatedAt` calls `now()` on create; `UpdatedAt` calls it on create and on update. The target's `now()` binding for the codec picks the generator, so each alias stores what the matching `temporal.createdAt()` and `temporal.updatedAt()` presets store. `value` names the value the codec gives in TypeScript, such as `a JavaScript Date`, and ends each alias's documentation.
1192
+ */
1193
+ /* @__NO_SIDE_EFFECTS__ */
1194
+ function temporalTypeAliases(type, value) {
1195
+ return {
1196
+ CreatedAt: {
1197
+ kind: "typeAlias",
1198
+ documentation: `A timestamp the client sets to now when a row is created. Its value is ${value}.`,
1199
+ output: {
1200
+ type,
1201
+ onCreate: NOW_CALL
1202
+ }
1203
+ },
1204
+ UpdatedAt: {
1205
+ kind: "typeAlias",
1206
+ documentation: `A timestamp the client sets to now when a row is created and every time it is updated. Its value is ${value}.`,
1207
+ output: {
1208
+ type,
1209
+ onCreate: NOW_CALL,
1210
+ onUpdate: NOW_CALL
1211
+ }
1212
+ }
1213
+ };
1214
+ }
1215
+ const TEMPORAL_ON_CREATE_ARG = {
1216
+ name: "onCreate",
1217
+ kind: "option",
1218
+ values: ["now"],
1219
+ optional: true
1220
+ };
1221
+ const TEMPORAL_ON_UPDATE_ARG = {
1222
+ name: "onUpdate",
1223
+ kind: "option",
1224
+ values: ["now"],
1225
+ optional: true
1226
+ };
1227
+ /**
1228
+ * Selects a generator descriptor for the preset's `now` token. The token is preset vocabulary; the generator id never appears in a user's spelling (ADR 169 — these generators are preset-only).
1229
+ */
1230
+ function temporalPhaseTemplate(index, generatorId) {
1231
+ return {
1232
+ kind: "select",
1233
+ index,
1234
+ cases: { now: {
1235
+ kind: "generator",
1236
+ id: generatorId
1237
+ } }
1238
+ };
1239
+ }
1240
+ /**
1241
+ * {@link temporalPhaseTemplate} for a generator that takes params. `params` is the template of the generator's params, resolved against the preset's arguments.
1242
+ */
1243
+ function temporalPhaseTemplateWithParams(index, generatorId, params) {
1244
+ return {
1245
+ kind: "select",
1246
+ index,
1247
+ cases: { now: {
1248
+ kind: "generator",
1249
+ id: generatorId,
1250
+ params
1251
+ } }
1252
+ };
1253
+ }
1254
+ /**
1255
+ * Builds a `temporal.<codec>` field preset for a codec with no type parameters, carrying the codec's storage template through unchanged. Both phase arguments are optional, and omitting one omits that phase. `generatorId` names the generator a `now` argument selects, `timestampNow` when omitted.
1256
+ */
1257
+ /* @__NO_SIDE_EFFECTS__ */
1258
+ function temporalCodecPreset(input) {
1259
+ const { generatorId, ...storage } = input;
1260
+ const nowGeneratorId = generatorId ?? "timestampNow";
1261
+ return {
1262
+ kind: "fieldPreset",
1263
+ args: [TEMPORAL_ON_CREATE_ARG, TEMPORAL_ON_UPDATE_ARG],
1264
+ output: {
1265
+ ...storage,
1266
+ executionDefaults: {
1267
+ onCreate: temporalPhaseTemplate(0, nowGeneratorId),
1268
+ onUpdate: temporalPhaseTemplate(1, nowGeneratorId)
1269
+ }
1270
+ }
1271
+ };
1272
+ }
1273
+ //#endregion
1274
+ export { isAuthoringTypeAliasDescriptor as A, resolveTemplateTagEscapes as B, instantiateAuthoringTypeConstructorFromValues as C, isAuthoringModelAttributeDescriptor as D, isAuthoringFieldPresetDescriptor as E, printTaggedLiteral as F, temporalPhaseTemplateWithParams as G, temporalAuthoringPresets as H, printedTaggedLiteralReadsBack as I, tsTaggedTemplateSource as J, temporalTypeAliases as K, resolveAuthoringTemplateValue as L, isAuthoringTypeDescriptor as M, mergeAuthoringAttributeSpecs as N, isAuthoringPslBlockDescriptor as O, mergeAuthoringNamespaces as P, resolveEnumCodecId as R, instantiateAuthoringTypeConstructor as S, isAuthoringEntityTypeDescriptor as T, temporalCodecPreset as U, resolveTypeAliasGenerators as V, temporalPhaseTemplate as W, validateAuthoringTypeParams as X, validateAuthoringHelperArguments as Y, flushAuthoringWarnings as _, TIMESTAMP_NOW_GENERATOR_ID as a, instantiateAuthoringFieldPreset as b, assertNoCrossRegistryCollisions as c, canonicalizeTaggedLiteralBody as d, classifyEnumMemberType as f, describeTaggedLiteralFailure as g, contributedHelpers as h, TEMPORAL_ON_UPDATE_ARG as i, isAuthoringTypeConstructorDescriptor as j, isAuthoringSelectRef as k, assertResolvableTypeConstructorTemplates as l, collectScalarTypeConstructors as m, TAGGED_LITERAL_MAX_BYTES as n, assembleAuthoringDataTypes as o, collectContributedDescriptorPaths as p, timestampNowControlDescriptor as q, TEMPORAL_ON_CREATE_ARG as r, assembleDataTypeSupport as s, AUTHORING_TYPE_DESCRIPTOR_KINDS as t, assertTypeAliasesValid as u, getAuthoringTypeConstructor as v, isAuthoringArgRef as w, instantiateAuthoringTypeAlias as x, instantiateAuthoringEntityType as y, resolvePslBacktickEscapes as z };
1275
+
1276
+ //# sourceMappingURL=temporal-presets-5TK1pTYJ-DmhrnMP1.mjs.map