@prisma/orm-framework 8.0.0-rc.2-dev.2 → 8.0.0-rc.20

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,1059 @@
1
+ import { t as blindCast } from "./casts-DpaahrlC-Bd5n2coI.mjs";
2
+ import { t as canonicalStringify } from "./canonical-stringify-DY4NaAJi.mjs";
3
+ import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
4
+ //#region ../../../1-framework/1-core/framework-components/dist/runtime.mjs
5
+ /**
6
+ * Stable code emitted by the runtime when an in-flight `execute()`
7
+ * is cancelled via the per-query `AbortSignal`. The envelope's
8
+ * `details.phase` distinguishes where the abort was observed:
9
+ *
10
+ * - `'encode'` — abort fired during `encodeParams` (SQL) or
11
+ * `resolveValue` (Mongo).
12
+ * - `'decode'` — abort fired during `decodeRow` / `decodeField`.
13
+ * - `'stream'` — abort fired between rows or before any codec call
14
+ * (already-aborted at entry).
15
+ * - `'beforeEncode'` / `'onRow'` — abort fired on entry to or during
16
+ * the corresponding middleware phase
17
+ * (cooperative cancellation per the param-transform seam).
18
+ */
19
+ const RUNTIME_ABORTED = "RUNTIME.ABORTED";
20
+ /**
21
+ * Construct a `RUNTIME.ABORTED` envelope. Phase distinguishes where the
22
+ * abort was observed — codec call sites (`encode` / `decode` / `stream`)
23
+ * or operation-specific middleware seams, as
24
+ * enumerated on {@link RuntimeAbortedPhase}. Cause carries
25
+ * `signal.reason` verbatim from the platform — native abort produces a
26
+ * `DOMException`, explicit `controller.abort(reason)` produces whatever
27
+ * the caller passed. No synthesis happens here.
28
+ */
29
+ function runtimeAborted(phase, cause) {
30
+ const envelope = runtimeError(RUNTIME_ABORTED, `Operation aborted during ${phase}`, { phase });
31
+ return Object.assign(envelope, { cause });
32
+ }
33
+ /**
34
+ * Defines a typed annotation handle.
35
+ *
36
+ * Two-step call form. The first step takes the `Payload` type argument
37
+ * (TypeScript cannot infer `Payload` from anything in the options, so it
38
+ * must be supplied explicitly); the second step takes the runtime options
39
+ * and infers `Kinds` from the `applicableTo` array via a `const` type
40
+ * parameter, so the operation kinds appear exactly once at the call site.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * // Read-only annotation. Lane terminals like `db.User.first(...)` accept
45
+ * // it; `db.User.create(...)` rejects it at the type level.
46
+ * const cacheAnnotation = defineAnnotation<{ ttl?: number; skip?: boolean }>()({
47
+ * namespace: 'cache',
48
+ * applicableTo: ['read'],
49
+ * }); // Kinds inferred as 'read'
50
+ *
51
+ * // Write-only annotation. Mirror image.
52
+ * const auditAnnotation = defineAnnotation<{ actor: string }>()({
53
+ * namespace: 'audit',
54
+ * applicableTo: ['write'],
55
+ * }); // Kinds inferred as 'write'
56
+ *
57
+ * // Annotation applicable to both kinds (e.g. tracing).
58
+ * const otelAnnotation = defineAnnotation<{ traceId: string }>()({
59
+ * namespace: 'otel',
60
+ * applicableTo: ['read', 'write'],
61
+ * }); // Kinds inferred as 'read' | 'write'
62
+ * ```
63
+ *
64
+ * **Reserved namespaces.** See `DefineAnnotationOptions.namespace` for the
65
+ * list of framework-internal namespaces (`codecs`, target-specific keys).
66
+ * `defineAnnotation` does not structurally prevent a user from naming a
67
+ * reserved namespace, but the framework makes no compatibility guarantee
68
+ * about handles that do.
69
+ */
70
+ function defineAnnotation() {
71
+ return (options) => {
72
+ const namespace = options.namespace;
73
+ const applicableTo = Object.freeze(new Set(options.applicableTo));
74
+ function handle(value) {
75
+ return Object.freeze({
76
+ __annotation: true,
77
+ namespace,
78
+ value,
79
+ applicableTo
80
+ });
81
+ }
82
+ function read(source) {
83
+ const stored = "meta" in source ? source.meta.annotations?.[namespace] : source.annotations.get(namespace);
84
+ if (!isAnnotationValue(stored)) return;
85
+ if (stored.namespace !== namespace) return;
86
+ return stored.value;
87
+ }
88
+ return Object.freeze(Object.assign(handle, {
89
+ namespace,
90
+ applicableTo,
91
+ read
92
+ }));
93
+ };
94
+ }
95
+ /**
96
+ * Runtime applicability gate. Throws `RUNTIME.ANNOTATION_INAPPLICABLE` if
97
+ * any annotation in `annotations` declares an `applicableTo` set that does
98
+ * not include `kind`. Used by lane terminals (SQL DSL builders' `.build()`,
99
+ * ORM `Collection` terminals) to fail closed when the type-level
100
+ * `ValidAnnotations` gate is bypassed via cast / `any` / dynamic
101
+ * invocation.
102
+ *
103
+ * Passes silently on:
104
+ * - empty arrays
105
+ * - annotations whose `applicableTo` includes `kind`
106
+ *
107
+ * Throws on:
108
+ * - any annotation whose `applicableTo` does not include `kind`. The
109
+ * error names the offending annotation's `namespace` and the
110
+ * `terminalName` so users can locate the misuse.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * // Inside an ORM read terminal:
115
+ * assertAnnotationsApplicable(annotations, 'read', 'first');
116
+ * ```
117
+ */
118
+ function assertAnnotationsApplicable(annotations, kind, terminalName) {
119
+ for (const annotation of annotations) if (!annotation.applicableTo.has(kind)) {
120
+ const applicableTo = Array.from(annotation.applicableTo);
121
+ const kinds = applicableTo.join(" and ");
122
+ throw runtimeError("RUNTIME.ANNOTATION_INAPPLICABLE", `An annotation that applies only to ${kinds} operations was given to a ${kind} operation. Remove it from the ${kind} and put it on a ${kinds} operation instead.`, {
123
+ namespace: annotation.namespace,
124
+ terminalName,
125
+ kind,
126
+ applicableTo
127
+ });
128
+ }
129
+ }
130
+ const noAnnotations = /* @__PURE__ */ new Map();
131
+ /** The branded annotation values in a plan's `meta.annotations`, keyed by namespace. */
132
+ function brandedAnnotations(annotations) {
133
+ if (annotations === void 0) return noAnnotations;
134
+ let branded;
135
+ for (const [namespace, value] of Object.entries(annotations)) {
136
+ if (!isAnnotationValue(value)) continue;
137
+ branded ??= /* @__PURE__ */ new Map();
138
+ branded.set(namespace, value);
139
+ }
140
+ return branded ?? noAnnotations;
141
+ }
142
+ /**
143
+ * Type guard for branded annotation values stored in `plan.meta.annotations`.
144
+ *
145
+ * Internal — used by `AnnotationHandle.read` to distinguish user
146
+ * annotations (created by calling a handle returned from
147
+ * `defineAnnotation(...)`) from framework-internal metadata that may
148
+ * happen to live under the same namespace key.
149
+ */
150
+ function isAnnotationValue(value) {
151
+ if (value === null || typeof value !== "object") return false;
152
+ return value.__annotation === true;
153
+ }
154
+ const resolved = Promise.resolve();
155
+ /** The children of a transaction or a client activity: which are open, and which have ended and wait to be finalized. */
156
+ var ActivityChildren = class {
157
+ #options;
158
+ #held = [];
159
+ #open = 0;
160
+ #finalized;
161
+ constructor(options) {
162
+ this.#options = options;
163
+ }
164
+ /** The children that have started and not ended. */
165
+ get open() {
166
+ return this.#open;
167
+ }
168
+ add(child) {
169
+ const options = this.#options;
170
+ const entry = options.inTransaction && options.holdFinishedChildren ? {
171
+ child,
172
+ ended: false
173
+ } : void 0;
174
+ if (entry !== void 0) this.#held.push(entry);
175
+ this.#open++;
176
+ let ended = false;
177
+ return {
178
+ statementFailed: options.statementFailed,
179
+ transactionAcceptsChildren: options.transactionAcceptsChildren,
180
+ ended: async (own) => {
181
+ if (ended) return;
182
+ ended = true;
183
+ this.#open--;
184
+ if (!options.inTransaction) {
185
+ options.childFinalized(own);
186
+ await child.finalize(own);
187
+ } else if (this.#finalized !== void 0) await child.finalize(this.#finalized);
188
+ else if (entry !== void 0) entry.ended = true;
189
+ }
190
+ };
191
+ }
192
+ /** Finalizes the children that have ended, in start order, with `result`; a child that ends later is finalized with it then. `undefined` when no ended child waited. */
193
+ finalize(result) {
194
+ if (this.#finalized !== void 0) return void 0;
195
+ this.#finalized = result;
196
+ const held = this.#held.splice(0);
197
+ if (held.length === 0) return void 0;
198
+ return (async () => {
199
+ for (const { child, ended } of held) if (ended) await child.finalize(result);
200
+ })();
201
+ }
202
+ };
203
+ function notAcceptingChildrenError(parent, reason) {
204
+ return runtimeError("RUNTIME.ACTIVITY_NOT_ACCEPTING_CHILDREN", `An activity was started beneath ${parent.kind === "transaction" ? "a transaction" : `a '${parent.kind}' activity`} ${parent.kind === "transaction" ? "that no longer accepts children: its commit() or rollback() has been called" : reason === "parent" ? "that has ended" : "whose transaction no longer accepts children"}`, {
205
+ parentKind: parent.kind,
206
+ parentId: parent.id
207
+ });
208
+ }
209
+ function createStateStore() {
210
+ let states;
211
+ return {
212
+ state(key) {
213
+ states ??= /* @__PURE__ */ new Map();
214
+ let state = states.get(key);
215
+ if (state === void 0) {
216
+ state = {};
217
+ states.set(key, state);
218
+ }
219
+ return state;
220
+ },
221
+ clear() {
222
+ states = void 0;
223
+ }
224
+ };
225
+ }
226
+ function hooksOf(middleware) {
227
+ const hooks = {
228
+ anyStarted: false,
229
+ anyEnded: false,
230
+ anyFinalized: false
231
+ };
232
+ for (const mw of middleware) {
233
+ hooks.anyStarted ||= mw.activityStarted !== void 0;
234
+ hooks.anyEnded ||= mw.activityEnded !== void 0;
235
+ hooks.anyFinalized ||= mw.activityFinalized !== void 0;
236
+ }
237
+ return hooks;
238
+ }
239
+ function createActivityRecord(middleware, activity, fields, parent) {
240
+ const store = createStateStore();
241
+ let finalized = false;
242
+ let started = middleware.length;
243
+ const ctx = contextBeneath(fields, parent, store);
244
+ const { anyStarted, anyEnded, anyFinalized } = hooksOf(middleware);
245
+ return {
246
+ activity,
247
+ ctx,
248
+ started() {
249
+ if (!anyStarted) return resolved;
250
+ return (async () => {
251
+ for (let index = 0; index < middleware.length; index++) {
252
+ const mw = middleware[index];
253
+ if (!mw?.activityStarted) continue;
254
+ try {
255
+ await mw.activityStarted(activity, ctx);
256
+ } catch (error) {
257
+ started = index + 1;
258
+ throw error;
259
+ }
260
+ }
261
+ })();
262
+ },
263
+ ended(result) {
264
+ if (!anyEnded) return void 0;
265
+ return (async () => {
266
+ let firstError;
267
+ for (let index = 0; index < started; index++) {
268
+ const mw = middleware[index];
269
+ if (!mw?.activityEnded) continue;
270
+ try {
271
+ await mw.activityEnded(activity, result, ctx);
272
+ } catch (error) {
273
+ if (result.outcome === "succeeded") firstError ??= { error };
274
+ else logHookError(ctx, "middleware.activityEnded.error", mw.name, error);
275
+ }
276
+ }
277
+ if (firstError !== void 0) throw firstError.error;
278
+ })();
279
+ },
280
+ finalize(result) {
281
+ if (finalized) return resolved;
282
+ finalized = true;
283
+ if (!anyFinalized) {
284
+ store.clear();
285
+ return resolved;
286
+ }
287
+ return (async () => {
288
+ for (let index = 0; index < started; index++) {
289
+ const mw = middleware[index];
290
+ if (!mw?.activityFinalized) continue;
291
+ try {
292
+ await mw.activityFinalized(activity, result, ctx);
293
+ } catch (error) {
294
+ logHookError(ctx, "middleware.activityFinalized.error", mw.name, error);
295
+ }
296
+ }
297
+ store.clear();
298
+ })();
299
+ }
300
+ };
301
+ }
302
+ /**
303
+ * The context of work that belongs to no activity but runs beneath `parent`, such as compiling a plan outside any statement: `parent` and `inTransaction()` as a child of `parent` would have them, and state of its own.
304
+ */
305
+ function createContextBeneath(fields, parent) {
306
+ return contextBeneath(fields, parent, createStateStore());
307
+ }
308
+ function contextBeneath(fields, parent, store) {
309
+ const parentCtx = parent?.ctx;
310
+ const parentIsTransaction = parent?.activity.kind === "transaction";
311
+ return blindCast({
312
+ ...fields,
313
+ parent: parentCtx,
314
+ state: store.state,
315
+ inTransaction: () => parentIsTransaction || (parentCtx?.inTransaction() ?? false)
316
+ });
317
+ }
318
+ function logHookError(ctx, event, middleware, error) {
319
+ try {
320
+ ctx.log.error({
321
+ event,
322
+ middleware,
323
+ error
324
+ });
325
+ } catch {}
326
+ }
327
+ /**
328
+ * Ends an activity: its `activityEnded` hooks, then its finalization, which its parent holds or performs, or which happens at once with `own` when it has no parent. The finalization runs even when an `activityEnded` hook fails the activity; that error is rethrown afterwards.
329
+ */
330
+ function endActivity(record, result, own, slot, finalize) {
331
+ const ended = record.ended(result);
332
+ if (ended === void 0) return slot === void 0 ? finalize(own) : slot.ended(own);
333
+ return finishAfterEndedHooks(ended, own, slot, finalize);
334
+ }
335
+ async function finishAfterEndedHooks(ended, own, slot, finalize) {
336
+ let endedError;
337
+ try {
338
+ await ended;
339
+ } catch (error) {
340
+ endedError = { error };
341
+ }
342
+ if (slot === void 0) await finalize(own);
343
+ else await slot.ended(own);
344
+ if (endedError !== void 0) throw endedError.error;
345
+ }
346
+ var AsyncIterableResult = class {
347
+ generator;
348
+ consumed = false;
349
+ consumedBy;
350
+ bufferedArrayPromise;
351
+ constructor(generator) {
352
+ this.generator = generator;
353
+ }
354
+ [Symbol.asyncIterator]() {
355
+ if (this.consumed) throw runtimeError("RUNTIME.ITERATOR_CONSUMED", `AsyncIterableResult iterator has already been consumed via ${this.consumedBy === "bufferedArray" ? "toArray()/then()" : "for-await loop"}. Each AsyncIterableResult can only be iterated once.`, {
356
+ consumedBy: this.consumedBy,
357
+ suggestion: this.consumedBy === "bufferedArray" ? "If you need to iterate multiple times, store the results from toArray() in a variable and reuse that." : "If you need to iterate multiple times, use toArray() to collect all results first."
358
+ });
359
+ this.consumed = true;
360
+ this.consumedBy = "iterator";
361
+ return this.generator;
362
+ }
363
+ toArray() {
364
+ if (this.consumedBy === "iterator") return Promise.reject(runtimeError("RUNTIME.ITERATOR_CONSUMED", "AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.", {
365
+ consumedBy: this.consumedBy,
366
+ suggestion: "The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating."
367
+ }));
368
+ if (this.bufferedArrayPromise) return this.bufferedArrayPromise;
369
+ this.consumed = true;
370
+ this.consumedBy = "bufferedArray";
371
+ this.bufferedArrayPromise = (async () => {
372
+ const out = [];
373
+ for await (const item of this.generator) out.push(item);
374
+ return out;
375
+ })();
376
+ return this.bufferedArrayPromise;
377
+ }
378
+ async first() {
379
+ return (await this.toArray())[0] ?? null;
380
+ }
381
+ async firstOrThrow() {
382
+ const row = await this.first();
383
+ if (row === null) throw runtimeError("RUNTIME.NO_ROWS", "Expected at least one row, but none were returned", {});
384
+ return row;
385
+ }
386
+ then(onfulfilled, onrejected) {
387
+ return this.toArray().then(onfulfilled, onrejected);
388
+ }
389
+ };
390
+ /**
391
+ * Starts a client activity: its `activityStarted` hooks, then each `intercept.onActivity` handler in registration order until one returns a result. When a hook or a handler throws, the activity ends `failed`, is finalized, and the error is rethrown. Rejects at once, running no hook, when `kind` has no hyphen (such as `statement` or `transaction`) or when `parent` no longer accepts children.
392
+ */
393
+ async function startClientActivity(activity, options) {
394
+ const kind = activity.kind;
395
+ if (!kind.includes("-")) throw runtimeError("RUNTIME.ACTIVITY_KIND_RESERVED", `A client activity kind contains a hyphen, such as 'orm-call', and '${kind}' does not. Kinds without one, such as 'statement' and 'transaction', belong to the runtime.`, { kind });
396
+ const run = new ClientActivityRunImpl(activity, options);
397
+ try {
398
+ await run.start();
399
+ } catch (error) {
400
+ await run.finish({
401
+ outcome: "failed",
402
+ source: "client"
403
+ });
404
+ throw error;
405
+ }
406
+ for (const mw of options.middleware) {
407
+ const intercept = mw.intercept;
408
+ if (intercept?.onActivity === void 0) continue;
409
+ let intercepted;
410
+ try {
411
+ intercepted = await intercept.onActivity(run.activity, run.ctx);
412
+ } catch (error) {
413
+ await run.finish({
414
+ outcome: "failed",
415
+ source: "middleware"
416
+ });
417
+ throw error;
418
+ }
419
+ if (intercepted === void 0) continue;
420
+ run.ctx.log.debug?.({
421
+ event: "middleware.intercept.onActivity",
422
+ middleware: mw.name
423
+ });
424
+ run.intercept(intercepted.result);
425
+ break;
426
+ }
427
+ return run;
428
+ }
429
+ var ClientActivityRunImpl = class {
430
+ activity;
431
+ ctx;
432
+ #record;
433
+ #children;
434
+ #slot;
435
+ #intercepted;
436
+ #ended = false;
437
+ #everythingBeneathCommitted = true;
438
+ constructor(activity, options) {
439
+ const computeContentHash = activity.contentHash;
440
+ let contentHash;
441
+ let id;
442
+ this.activity = {
443
+ get id() {
444
+ id ??= crypto.randomUUID();
445
+ return id;
446
+ },
447
+ kind: activity.kind,
448
+ contentHash: () => {
449
+ contentHash ??= computeContentHash();
450
+ return contentHash;
451
+ },
452
+ annotations: activity.annotations ?? brandedAnnotations(void 0)
453
+ };
454
+ this.#record = createActivityRecord(options.middleware, this.activity, options.context, options.parent);
455
+ this.ctx = this.#record.ctx;
456
+ this.#children = new ActivityChildren({
457
+ inTransaction: this.ctx.inTransaction(),
458
+ holdFinishedChildren: options.holdFinishedChildren,
459
+ statementFailed: () => this.#slot?.statementFailed(),
460
+ transactionAcceptsChildren: () => this.#slot?.transactionAcceptsChildren() ?? true,
461
+ childFinalized: (result) => {
462
+ if (result.outcome !== "committed") this.#everythingBeneathCommitted = false;
463
+ }
464
+ });
465
+ this.#slot = options.parent?.adopt(this);
466
+ }
467
+ get intercepted() {
468
+ return this.#intercepted;
469
+ }
470
+ start() {
471
+ return this.#record.started();
472
+ }
473
+ intercept(result) {
474
+ this.#intercepted = { result: blindCast(result) };
475
+ }
476
+ acceptsChildren() {
477
+ return !this.#ended && (this.#slot?.transactionAcceptsChildren() ?? true);
478
+ }
479
+ assertAcceptsChildren() {
480
+ if (this.#ended) throw notAcceptingChildrenError(this.activity, "parent");
481
+ if (!(this.#slot?.transactionAcceptsChildren() ?? true)) throw notAcceptingChildrenError(this.activity, "transaction");
482
+ }
483
+ adopt(child) {
484
+ this.assertAcceptsChildren();
485
+ return this.#children.add(child);
486
+ }
487
+ end(end) {
488
+ if (this.#ended) return Promise.reject(runtimeError("RUNTIME.ACTIVITY_ALREADY_ENDED", `The '${this.activity.kind}' activity has already ended`, {
489
+ kind: this.activity.kind,
490
+ id: this.activity.id
491
+ }));
492
+ const openChildren = this.#children.open;
493
+ if (openChildren > 0) return this.finish({
494
+ outcome: "failed",
495
+ source: "client"
496
+ }).then(() => {
497
+ throw runtimeError("RUNTIME.ACTIVITY_CHILDREN_OPEN", `The '${this.activity.kind}' activity ended while ${openChildren} ${openChildren === 1 ? "activity" : "activities"} beneath it had not ended`, {
498
+ kind: this.activity.kind,
499
+ id: this.activity.id,
500
+ openChildren
501
+ });
502
+ });
503
+ const intercepted = this.#intercepted;
504
+ if (end.result === void 0 && intercepted !== void 0) return this.finish({
505
+ outcome: end.outcome,
506
+ source: "middleware",
507
+ result: intercepted.result
508
+ });
509
+ return this.finish({
510
+ outcome: end.outcome,
511
+ source: "client",
512
+ result: end.result
513
+ });
514
+ }
515
+ finish(ended) {
516
+ this.#ended = true;
517
+ const { kind } = this.activity;
518
+ const result = ended.result === void 0 ? {
519
+ kind,
520
+ outcome: ended.outcome,
521
+ source: ended.source
522
+ } : {
523
+ kind,
524
+ outcome: ended.outcome,
525
+ source: ended.source,
526
+ result: ended.result
527
+ };
528
+ const own = { outcome: ended.outcome === "succeeded" && this.#everythingBeneathCommitted ? "committed" : "unknown" };
529
+ return endActivity(this.#record, result, own, this.#slot, (finalized) => this.finalize(finalized));
530
+ }
531
+ finalize(result) {
532
+ const children = this.#children.finalize(result);
533
+ return children === void 0 ? this.#record.finalize(result) : children.then(() => this.#record.finalize(result));
534
+ }
535
+ };
536
+ /** Registers every generator the contributors provide, by id. Two contributors providing one id is an error naming both. */
537
+ function collectMutationDefaultGenerators(contributors) {
538
+ const generators = /* @__PURE__ */ new Map();
539
+ const owners = /* @__PURE__ */ new Map();
540
+ for (const contributor of contributors) {
541
+ const nextGenerators = contributor.mutationDefaultGenerators?.() ?? [];
542
+ for (const generator of nextGenerators) {
543
+ const existingOwner = owners.get(generator.id);
544
+ if (existingOwner !== void 0) throw runtimeError("RUNTIME.DUPLICATE_MUTATION_DEFAULT_GENERATOR", `Duplicate mutation default generator '${generator.id}'.`, {
545
+ id: generator.id,
546
+ existingOwner,
547
+ incomingOwner: contributor.id
548
+ });
549
+ generators.set(generator.id, generator);
550
+ owners.set(generator.id, contributor.id);
551
+ }
552
+ }
553
+ return generators;
554
+ }
555
+ /** Fails when the contract's mutation defaults name a generator the registry does not hold, listing every missing id and the fields that need it. */
556
+ function assertMutationDefaultGeneratorsAvailable(execution, generatorRegistry) {
557
+ const defaults = execution?.mutations.defaults ?? [];
558
+ if (defaults.length === 0) return;
559
+ const fieldsById = /* @__PURE__ */ new Map();
560
+ for (const mutationDefault of defaults) {
561
+ const phaseIds = new Set([mutationDefault.onCreate, mutationDefault.onUpdate].flatMap((phase) => phase?.kind === "generator" && !generatorRegistry.has(phase.id) ? [phase.id] : []));
562
+ for (const id of phaseIds) {
563
+ const fields = fieldsById.get(id) ?? [];
564
+ fields.push(`${mutationDefault.ref.entry}.${mutationDefault.ref.field}`);
565
+ fieldsById.set(id, fields);
566
+ }
567
+ }
568
+ if (fieldsById.size === 0) return;
569
+ const ids = [...fieldsById.keys()];
570
+ const needs = [...fieldsById].map(([id, fields]) => `'${id}' for ${listInProse(fields)}`);
571
+ throw runtimeError("RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING", `${ids.length === 1 ? `Contract requires mutation default generator ${needs[0]}, but no runtime component in the execution stack provides it.` : `Contract requires mutation default generators ${listInProse(needs)}, but no runtime component in the execution stack provides them.`} ${WHERE_GENERATORS_COME_FROM}`, {
572
+ ids,
573
+ fields: [...fieldsById.values()].flat()
574
+ });
575
+ }
576
+ const WHERE_GENERATORS_COME_FROM = "Built-in generators such as 'timestampNow' come from the database adapter's runtime descriptor, and others from the extension pack that defines them; include that component in the execution stack.";
577
+ function listInProse(items) {
578
+ return items.length > 1 ? `${items.slice(0, -1).join(", ")} and ${items.at(-1)}` : items.join("");
579
+ }
580
+ function computeExecutionDefaultValue(spec, generatorRegistry) {
581
+ const generator = generatorRegistry.get(spec.id);
582
+ if (!generator) throw runtimeError("RUNTIME.MUTATION_DEFAULT_GENERATOR_MISSING", `Contract references mutation default generator '${spec.id}' but no runtime component in the execution stack provides it. ${WHERE_GENERATORS_COME_FROM}`, { id: spec.id });
583
+ return generator.generate(spec.params);
584
+ }
585
+ /**
586
+ * The defaults to write for one record: for each mutation default of the entry and namespace whose phase matches `op`, the generated value of every field the values do not carry. An update with no keys gets none.
587
+ */
588
+ function applyMutationDefaults(execution, generatorRegistry, options) {
589
+ const defaults = execution?.mutations.defaults ?? [];
590
+ if (defaults.length === 0) return [];
591
+ const isEmptyUpdate = options.op === "update" && Object.keys(options.values).length === 0;
592
+ const applied = [];
593
+ const appliedFields = /* @__PURE__ */ new Set();
594
+ const rowCache = /* @__PURE__ */ new Map();
595
+ for (const mutationDefault of defaults) {
596
+ if (mutationDefault.ref.entry !== options.entry) continue;
597
+ if (mutationDefault.ref.namespace !== options.namespace) continue;
598
+ const defaultSpec = options.op === "create" ? mutationDefault.onCreate : mutationDefault.onUpdate;
599
+ if (!defaultSpec) continue;
600
+ if (isEmptyUpdate) continue;
601
+ const fieldName = mutationDefault.ref.field;
602
+ if (Object.hasOwn(options.values, fieldName) || appliedFields.has(fieldName)) continue;
603
+ applied.push({
604
+ field: fieldName,
605
+ value: resolveScopedValue(defaultSpec, generatorRegistry, rowCache, options.defaultValueCache)
606
+ });
607
+ appliedFields.add(fieldName);
608
+ }
609
+ return applied;
610
+ }
611
+ function resolveScopedValue(spec, generatorRegistry, rowCache, queryCache) {
612
+ const cache = scopedCache(generatorRegistry.get(spec.id)?.stability, rowCache, queryCache);
613
+ if (!cache) return computeExecutionDefaultValue(spec, generatorRegistry);
614
+ const key = spec.params === void 0 ? spec.id : `${spec.id} ${canonicalStringify(spec.params)}`;
615
+ if (cache.has(key)) return cache.get(key);
616
+ const value = computeExecutionDefaultValue(spec, generatorRegistry);
617
+ cache.set(key, value);
618
+ return value;
619
+ }
620
+ function scopedCache(stability, rowCache, queryCache) {
621
+ switch (stability) {
622
+ case "row": return rowCache;
623
+ case "query": return queryCache;
624
+ default: return;
625
+ }
626
+ }
627
+ /**
628
+ * Throw a phase-tagged `RUNTIME.ABORTED` envelope if the supplied
629
+ * context is already aborted at the precheck site. Centralises the
630
+ * `if (ctx.signal?.aborted) throw runtimeAborted(...)` pattern that
631
+ * every codec dispatch site (and the `beforeEncode` middleware phase)
632
+ * repeats. Accepts both the framework `CodecCallContext` and the
633
+ * `ActivityContext`; both expose `signal?: AbortSignal`.
634
+ */
635
+ function checkAborted(ctx, phase) {
636
+ if (ctx.signal?.aborted) throw runtimeAborted(phase, ctx.signal.reason);
637
+ }
638
+ /**
639
+ * Race a per-cell `Promise.all` (or any other in-flight work promise) against
640
+ * the supplied abort signal so the runtime returns `RUNTIME.ABORTED` promptly
641
+ * even when codec bodies ignore the signal. In-flight bodies that ignore the
642
+ * signal are abandoned and run to completion in the background — the
643
+ * cooperative-cancellation contract documented in ADR 204.
644
+ *
645
+ * Call sites still SHOULD pre-check `signal.aborted` and short-circuit with
646
+ * a phase-tagged `RUNTIME.ABORTED` envelope before invoking this helper —
647
+ * that path is the canonical "aborted at entry" surface and avoids
648
+ * scheduling the work promise. As a defensive belt-and-braces, this helper
649
+ * also handles the already-aborted case internally: `AbortSignal` does not
650
+ * replay past abort events to listeners registered after the abort, so we
651
+ * inspect `signal.aborted` synchronously and reject with the sentinel
652
+ * before installing the listener. The rejection is still attributed to the
653
+ * abort path via the sentinel-identity check.
654
+ *
655
+ * Distinguishing the rejection source is load-bearing for AC-ERR4
656
+ * (`RUNTIME.ENCODE_FAILED` / `RUNTIME.DECODE_FAILED` pass through unchanged).
657
+ * The semantically equivalent `abortable(signal)` helper in
658
+ * `@internal/utils` rejects with `signal.reason ?? new DOMException(...)`,
659
+ * which is not stably distinguishable from a codec-thrown error by identity
660
+ * alone (a fresh fallback DOMException is allocated per call). We instead
661
+ * track abort attribution with a unique sentinel: only the `onAbort` listener
662
+ * installed here ever rejects with the sentinel, so an `error === sentinel`
663
+ * identity check after the race is unambiguous.
664
+ *
665
+ * Lives in `framework-components` (rather than the SQL family, where it
666
+ * originated in m2) so every family runtime that needs cooperative
667
+ * cancellation around a codec-dispatch `Promise.all` (SQL encode + decode
668
+ * today, Mongo encode in m3) shares the same attribution logic.
669
+ */
670
+ async function raceAgainstAbort(work, signal, phase) {
671
+ if (signal === void 0) return await work;
672
+ const sentinel = { reason: void 0 };
673
+ let onAbort;
674
+ const abortPromise = new Promise((_, reject) => {
675
+ if (signal.aborted) {
676
+ sentinel.reason = signal.reason;
677
+ reject(sentinel);
678
+ return;
679
+ }
680
+ onAbort = () => {
681
+ sentinel.reason = signal.reason;
682
+ reject(sentinel);
683
+ };
684
+ signal.addEventListener("abort", onAbort, { once: true });
685
+ });
686
+ try {
687
+ return await Promise.race([work, abortPromise]);
688
+ } catch (error) {
689
+ if (error === sentinel) throw runtimeAborted(phase, sentinel.reason);
690
+ throw error;
691
+ } finally {
692
+ if (onAbort) signal.removeEventListener("abort", onAbort);
693
+ }
694
+ }
695
+ /**
696
+ * Runs one `query()` statement as an activity. The activity starts on the first `next()`: `activityStarted`, then `body`'s rows, then `activityEnded` and, unless a transaction holds it, `activityFinalized`. Each fires exactly once, whether the body succeeds, throws (`failed`) or the caller stops reading (`stopped`). When the parent no longer accepts work, the first `next()` rejects and no hook runs.
697
+ */
698
+ function streamStatement(options, body) {
699
+ return { [Symbol.asyncIterator]() {
700
+ let thrownByCaller;
701
+ const generator = streamStatementRows(options, body, (error) => thrownByCaller !== void 0 && thrownByCaller.error === error);
702
+ return {
703
+ next: () => generator.next(),
704
+ return: () => generator.return(void 0),
705
+ throw: (error) => {
706
+ thrownByCaller = { error };
707
+ return generator.throw(error);
708
+ }
709
+ };
710
+ } };
711
+ }
712
+ async function* streamStatementRows(options, body, isThrownByCaller) {
713
+ const statement = new StatementActivityRunImpl(options, "rows");
714
+ statement.attach();
715
+ let outcome = "stopped";
716
+ try {
717
+ await statement.start();
718
+ yield* body(statement);
719
+ outcome = "succeeded";
720
+ } catch (error) {
721
+ if (!isThrownByCaller(error)) outcome = "failed";
722
+ throw error;
723
+ } finally {
724
+ await statement.end(outcome);
725
+ }
726
+ }
727
+ /**
728
+ * Runs one `execute()` statement as an activity: `activityStarted`, then `body`, then `activityEnded` and, unless a transaction holds it, `activityFinalized`, each exactly once. When the parent no longer accepts work, it rejects and no hook runs.
729
+ */
730
+ async function executeStatement(options, body) {
731
+ const statement = new StatementActivityRunImpl(options, "stats");
732
+ statement.attach();
733
+ let outcome = "failed";
734
+ try {
735
+ await statement.start();
736
+ const stats = await body(statement);
737
+ outcome = "succeeded";
738
+ return stats;
739
+ } finally {
740
+ await statement.end(outcome);
741
+ }
742
+ }
743
+ var StatementActivityRunImpl = class {
744
+ activity;
745
+ ctx;
746
+ #middleware;
747
+ #parent;
748
+ #record;
749
+ #slot;
750
+ #runStartedAt;
751
+ #source = "driver";
752
+ #rowCount = 0;
753
+ #stats;
754
+ constructor(options, returns) {
755
+ const { plan } = options;
756
+ let annotations;
757
+ this.activity = {
758
+ id: crypto.randomUUID(),
759
+ kind: "statement",
760
+ returns,
761
+ plan,
762
+ get annotations() {
763
+ annotations ??= brandedAnnotations(plan.meta.annotations);
764
+ return annotations;
765
+ }
766
+ };
767
+ this.#middleware = options.middleware;
768
+ this.#parent = options.parent;
769
+ this.#record = createActivityRecord(options.middleware, this.activity, options.context, options.parent);
770
+ this.ctx = this.#record.ctx;
771
+ }
772
+ /** Adopts the statement into its parent; throws when the parent no longer accepts work. */
773
+ attach() {
774
+ this.#slot = this.#parent?.adopt(this.#record);
775
+ }
776
+ start() {
777
+ return this.#record.started();
778
+ }
779
+ end(outcome) {
780
+ if (outcome === "failed") this.#slot?.statementFailed();
781
+ return endActivity(this.#record, this.#endedResult(outcome), { outcome: outcome === "succeeded" ? "committed" : "unknown" }, this.#slot, this.#record.finalize);
782
+ }
783
+ async beforeEncode(draft, params) {
784
+ for (const mw of this.#middleware) {
785
+ if (!mw.beforeEncode) continue;
786
+ checkAborted(this.ctx, "beforeEncode");
787
+ const work = mw.beforeEncode(draft, this.ctx, params);
788
+ if (work !== void 0) await raceAgainstAbort(Promise.resolve(work), this.ctx.signal, "beforeEncode");
789
+ }
790
+ }
791
+ async *runQuery(exec, runDriver) {
792
+ this.#runStartedAt = Date.now();
793
+ let rows;
794
+ for (const mw of this.#middleware) {
795
+ const intercept = mw.intercept;
796
+ if (intercept?.onQuery === void 0) continue;
797
+ this.#source = "middleware";
798
+ const result = await intercept.onQuery(exec, this.ctx);
799
+ if (result === void 0) {
800
+ this.#source = "driver";
801
+ continue;
802
+ }
803
+ this.ctx.log.debug?.({
804
+ event: "middleware.intercept.onQuery",
805
+ middleware: mw.name
806
+ });
807
+ rows = blindCast(result.rows);
808
+ break;
809
+ }
810
+ if (rows === void 0) {
811
+ for await (const row of runDriver()) {
812
+ for (const mw of this.#middleware) if (mw.onRow) await mw.onRow(blindCast(row), exec, this.ctx);
813
+ this.#rowCount++;
814
+ yield row;
815
+ }
816
+ return;
817
+ }
818
+ for await (const row of rows) {
819
+ this.#rowCount++;
820
+ yield row;
821
+ }
822
+ }
823
+ async runExecute(exec, runDriver) {
824
+ this.#runStartedAt = Date.now();
825
+ for (const mw of this.#middleware) {
826
+ const intercept = mw.intercept;
827
+ if (intercept?.onExecute === void 0) continue;
828
+ this.#source = "middleware";
829
+ const result = await intercept.onExecute(exec, this.ctx);
830
+ if (result === void 0) {
831
+ this.#source = "driver";
832
+ continue;
833
+ }
834
+ this.ctx.log.debug?.({
835
+ event: "middleware.intercept.onExecute",
836
+ middleware: mw.name
837
+ });
838
+ this.#stats = result.stats;
839
+ return result.stats;
840
+ }
841
+ this.#stats = await runDriver();
842
+ return this.#stats;
843
+ }
844
+ #endedResult(outcome) {
845
+ const base = {
846
+ kind: "statement",
847
+ outcome,
848
+ latencyMs: this.#runStartedAt === void 0 ? 0 : Date.now() - this.#runStartedAt,
849
+ source: this.#source
850
+ };
851
+ if (this.activity.returns === "rows") return {
852
+ ...base,
853
+ returns: "rows",
854
+ rowCount: this.#rowCount
855
+ };
856
+ return outcome === "succeeded" && this.#stats !== void 0 ? {
857
+ ...base,
858
+ returns: "stats",
859
+ stats: this.#stats
860
+ } : {
861
+ ...base,
862
+ returns: "stats"
863
+ };
864
+ }
865
+ };
866
+ /**
867
+ * Family-agnostic abstract runtime base. Each `query()` and `execute()` call is one statement activity, run in this order: `activityStarted`, `runBeforeCompile`, `lower`, `beforeEncode`, `intercept`, the driver with `onRow`, `activityEnded`, then `activityFinalized`. It has no parent, so it is finalized right after it ends.
868
+ *
869
+ * Concrete subclasses implement `lower`, `runDriver`, `runExecute` and `close`.
870
+ */
871
+ var RuntimeCore = class {
872
+ middleware;
873
+ ctx;
874
+ constructor(options) {
875
+ this.middleware = [...options.middleware];
876
+ this.ctx = options.ctx;
877
+ }
878
+ /** Pre-lowering hook for plan rewriting. Defaults to identity. */
879
+ runBeforeCompile(plan) {
880
+ return plan;
881
+ }
882
+ query(plan, options) {
883
+ const self = this;
884
+ const codecCtx = codecContextOf(options);
885
+ const statement = streamStatement({
886
+ middleware: this.middleware,
887
+ plan,
888
+ context: this.contextFieldsFor(codecCtx, options),
889
+ parent: void 0
890
+ }, async function* (run) {
891
+ checkAborted(codecCtx, "stream");
892
+ const compiled = await self.runBeforeCompile(plan);
893
+ const exec = await self.lower(compiled, codecCtx);
894
+ await run.beforeEncode(exec);
895
+ yield* run.runQuery(exec, () => blindCast(self.runDriver(exec)));
896
+ });
897
+ async function* generator() {
898
+ yield* statement;
899
+ }
900
+ return new AsyncIterableResult(generator());
901
+ }
902
+ execute(plan, options) {
903
+ const codecCtx = codecContextOf(options);
904
+ return executeStatement({
905
+ middleware: this.middleware,
906
+ plan,
907
+ context: this.contextFieldsFor(codecCtx, options),
908
+ parent: void 0
909
+ }, async (run) => {
910
+ checkAborted(codecCtx, "stream");
911
+ const compiled = await this.runBeforeCompile(plan);
912
+ const exec = await this.lower(compiled, codecCtx);
913
+ await run.beforeEncode(exec);
914
+ return run.runExecute(exec, () => this.runExecute(exec));
915
+ });
916
+ }
917
+ contextFieldsFor(codecCtx, options) {
918
+ return {
919
+ ...this.ctx,
920
+ ...codecCtx,
921
+ scope: options?.scope ?? this.ctx.scope
922
+ };
923
+ }
924
+ };
925
+ function codecContextOf(options) {
926
+ const signal = options?.signal;
927
+ return signal === void 0 ? {} : { signal };
928
+ }
929
+ function checkMiddlewareCompatibility(middleware, runtimeFamilyId, runtimeTargetId) {
930
+ if (middleware.targetId !== void 0 && middleware.familyId === void 0) throw runtimeError("RUNTIME.MIDDLEWARE_INCOMPATIBLE", `Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`, {
931
+ middleware: middleware.name,
932
+ targetId: middleware.targetId
933
+ });
934
+ if (middleware.familyId !== void 0 && middleware.familyId !== runtimeFamilyId) throw runtimeError("RUNTIME.MIDDLEWARE_FAMILY_MISMATCH", `Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`, {
935
+ middleware: middleware.name,
936
+ middlewareFamilyId: middleware.familyId,
937
+ runtimeFamilyId
938
+ });
939
+ if (middleware.targetId !== void 0 && middleware.targetId !== runtimeTargetId) throw runtimeError("RUNTIME.MIDDLEWARE_TARGET_MISMATCH", `Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`, {
940
+ middleware: middleware.name,
941
+ middlewareTargetId: middleware.targetId,
942
+ runtimeTargetId
943
+ });
944
+ }
945
+ /**
946
+ * Phantom key an emitted model type carries to name its relation properties.
947
+ * Never present at runtime; `Scalars` and `Shape` read it to tell relations from fields.
948
+ */
949
+ const RelationKeys = Symbol("RelationKeys");
950
+ /**
951
+ * Starts a transaction activity and runs its `activityStarted` hooks. When one of them throws, the transaction ends `failed`, is finalized `rolled-back`, and the error is rethrown. Rejects at once, running no hook, when `parent` no longer accepts children.
952
+ */
953
+ async function startTransactionActivity(options) {
954
+ const run = new TransactionActivityRunImpl(options);
955
+ try {
956
+ await run.start();
957
+ } catch (error) {
958
+ await run.end({
959
+ by: "rollback",
960
+ outcome: "failed",
961
+ commitAttempted: false
962
+ });
963
+ throw error;
964
+ }
965
+ return run;
966
+ }
967
+ var TransactionActivityRunImpl = class {
968
+ activity;
969
+ ctx;
970
+ #record;
971
+ #children;
972
+ #slot;
973
+ #aStatementFailed = false;
974
+ #ended = false;
975
+ #acceptingChildren = true;
976
+ constructor(options) {
977
+ this.activity = {
978
+ id: crypto.randomUUID(),
979
+ kind: "transaction",
980
+ annotations: brandedAnnotations(void 0)
981
+ };
982
+ this.#record = createActivityRecord(options.middleware, this.activity, options.context, options.parent);
983
+ this.ctx = this.#record.ctx;
984
+ this.#children = new ActivityChildren({
985
+ inTransaction: true,
986
+ holdFinishedChildren: options.holdFinishedChildren,
987
+ statementFailed: () => {
988
+ this.#aStatementFailed = true;
989
+ },
990
+ transactionAcceptsChildren: () => this.#acceptingChildren,
991
+ childFinalized: () => {}
992
+ });
993
+ this.#slot = options.parent?.adopt(this);
994
+ }
995
+ start() {
996
+ return this.#record.started();
997
+ }
998
+ acceptsChildren() {
999
+ return this.#acceptingChildren;
1000
+ }
1001
+ adopt(child) {
1002
+ if (!this.#acceptingChildren) throw notAcceptingChildrenError(this.activity, "parent");
1003
+ return this.#children.add(child);
1004
+ }
1005
+ stopAcceptingChildren() {
1006
+ this.#acceptingChildren = false;
1007
+ }
1008
+ async end(settlement) {
1009
+ if (this.#ended) return;
1010
+ this.#ended = true;
1011
+ this.#acceptingChildren = false;
1012
+ await endActivity(this.#record, {
1013
+ kind: "transaction",
1014
+ outcome: settlement.outcome
1015
+ }, this.#finalizedResult(settlement), this.#slot, (result) => this.finalize(result));
1016
+ }
1017
+ async finalize(result) {
1018
+ await this.#children.finalize(result);
1019
+ await this.#record.finalize(result);
1020
+ }
1021
+ #finalizedResult(settlement) {
1022
+ if (settlement.by === "rollback") return { outcome: settlement.commitAttempted ? "unknown" : "rolled-back" };
1023
+ return { outcome: settlement.outcome === "succeeded" && !this.#aStatementFailed ? "committed" : "unknown" };
1024
+ }
1025
+ };
1026
+ var MetaBuilderImpl = class {
1027
+ #kind;
1028
+ #terminalName;
1029
+ #annotations = /* @__PURE__ */ new Map();
1030
+ constructor(kind, terminalName) {
1031
+ this.#kind = kind;
1032
+ this.#terminalName = terminalName;
1033
+ }
1034
+ get annotations() {
1035
+ return this.#annotations;
1036
+ }
1037
+ annotate(annotation) {
1038
+ const value = annotation;
1039
+ assertAnnotationsApplicable([value], this.#kind, this.#terminalName);
1040
+ this.#annotations.set(value.namespace, value);
1041
+ return this;
1042
+ }
1043
+ };
1044
+ /**
1045
+ * Construct a lane-side meta builder for a terminal of operation kind `K`.
1046
+ *
1047
+ * Lane terminals call this with their `kind` (`'read'` or `'write'`) and a
1048
+ * `terminalName` for error messages, hand the resulting builder to the
1049
+ * user-supplied configurator callback (typed as `MetaBuilder<K>`, the
1050
+ * narrower public view), and read `meta.annotations` afterwards to thread
1051
+ * the recorded values into `plan.meta.annotations`.
1052
+ */
1053
+ function createMetaBuilder(kind, terminalName) {
1054
+ return new MetaBuilderImpl(kind, terminalName);
1055
+ }
1056
+ //#endregion
1057
+ export { runtimeAborted as _, applyMutationDefaults as a, streamStatement as b, checkAborted as c, createContextBeneath as d, createMetaBuilder as f, raceAgainstAbort as g, executeStatement as h, RuntimeCore as i, checkMiddlewareCompatibility as l, defineAnnotation as m, RUNTIME_ABORTED as n, assertAnnotationsApplicable as o, createStateStore as p, RelationKeys as r, assertMutationDefaultGeneratorsAvailable as s, AsyncIterableResult as t, collectMutationDefaultGenerators as u, startClientActivity as v, startTransactionActivity as y };
1058
+
1059
+ //# sourceMappingURL=runtime-DSYSc98Y.mjs.map