@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
@@ -1,1038 +0,0 @@
1
- import { U as PlanMeta } from "./domain-envelope-D6Wn9AmZ-BqZKTT9U.mjs";
2
- import { r as CodecCallContext } from "./codec-types-D6VRj2RE-BLElXc-O.mjs";
3
- //#region ../../../1-framework/1-core/framework-components/dist/runtime.d.mts
4
- //#region src/annotations.d.ts
5
- /**
6
- * The kinds of operations an annotation may apply to.
7
- *
8
- * - `'read'` — `SELECT` / `find` / `first` / `all` / `count` / aggregates.
9
- * - `'write'` — `INSERT` / `UPDATE` / `DELETE` / `create` / `update` / `delete` / `upsert`.
10
- *
11
- * Annotations declare which kinds they apply to via `defineAnnotation`'s
12
- * `applicableTo` option; lane terminals enforce the constraint at both the
13
- * type level (via `ValidAnnotations`) and at runtime (via
14
- * `assertAnnotationsApplicable`).
15
- *
16
- * Finer-grained kinds (`'select' | 'insert' | 'update' | 'delete' | 'upsert'`)
17
- * are deliberately deferred. The binary covers the common case (the cache
18
- * middleware applies to reads; an audit annotation would apply to writes;
19
- * tracing/OTel applies to both). When a real annotation surfaces that needs
20
- * a finer split, the union widens and existing handles remain typecheckable.
21
- */
22
- type OperationKind = 'read' | 'write';
23
- /**
24
- * An applied annotation. Carries the namespace, the typed payload, and the
25
- * `applicableTo` set the underlying handle declared. The `__annotation`
26
- * brand lets `read` distinguish branded user annotations from arbitrary
27
- * data that may happen to live under the same namespace key in
28
- * `plan.meta.annotations` (e.g. framework-internal metadata such as
29
- * `meta.annotations.codecs`).
30
- *
31
- * Constructed by calling an `AnnotationHandle` directly (e.g.
32
- * `cacheAnnotation({ ttl: 60 })`); never instantiated by hand.
33
- */
34
- interface AnnotationValue<Payload, Kinds extends OperationKind> {
35
- readonly __annotation: true;
36
- readonly namespace: string;
37
- readonly value: Payload;
38
- readonly applicableTo: ReadonlySet<Kinds>;
39
- }
40
- /**
41
- * Handle returned by `defineAnnotation`. The handle is **callable**: the
42
- * call signature wraps a `Payload` into an `AnnotationValue` ready to
43
- * pass to a lane terminal's variadic `annotations` argument. The handle
44
- * also carries static metadata as own properties:
45
- *
46
- * - `namespace` — the namespace string the handle was declared with.
47
- * - `applicableTo` — the frozen `ReadonlySet<Kinds>` consumed by both
48
- * the type-level `ValidAnnotations` gate and the runtime
49
- * `assertAnnotationsApplicable` gate.
50
- * - `read(plan)` — extract the `Payload` from a plan's `meta.annotations`
51
- * if a value was previously written under this handle's namespace.
52
- * Returns `undefined` when the annotation is absent or when the stored
53
- * value is not a branded `AnnotationValue` (e.g. framework-internal
54
- * metadata under the same namespace key).
55
- *
56
- * Handles are the only supported public entry point for reading and
57
- * writing annotations. Direct mutation of `plan.meta.annotations` is not
58
- * part of the public API.
59
- *
60
- * ```typescript
61
- * const cacheAnnotation = defineAnnotation<{ ttl: number }>()({
62
- * namespace: 'cache',
63
- * applicableTo: ['read'],
64
- * });
65
- *
66
- * // Call the handle to construct a value:
67
- * const applied = cacheAnnotation({ ttl: 60 });
68
- *
69
- * // Read a stored value off a plan:
70
- * const payload = cacheAnnotation.read(plan);
71
- * ```
72
- *
73
- * Note on the inherited `Function.prototype.apply`: because the handle is
74
- * a function, the property name `apply` resolves to JavaScript's built-in
75
- * `Function.prototype.apply` (which lets you invoke a function with an
76
- * array of arguments). This is **not** the construction entry point — to
77
- * build an `AnnotationValue`, call the handle directly. The
78
- * `AnnotationHandle` interface deliberately does not declare an `apply`
79
- * member of its own.
80
- */
81
- interface AnnotationHandle<Payload, Kinds extends OperationKind> {
82
- (value: Payload): AnnotationValue<Payload, Kinds>;
83
- readonly namespace: string;
84
- readonly applicableTo: ReadonlySet<Kinds>;
85
- read(plan: {
86
- readonly meta: {
87
- readonly annotations?: Record<string, unknown>;
88
- };
89
- }): Payload | undefined;
90
- }
91
- /**
92
- * Options accepted by `defineAnnotation`.
93
- *
94
- * `namespace` is the string key under which the annotation is stored in
95
- * `plan.meta.annotations`. **Reserved namespaces** include framework-
96
- * internal metadata keys; user handles must not use them:
97
- *
98
- * - `codecs` — used by the SQL emitter to record per-alias codec ids
99
- * (`meta.annotations.codecs[alias] = 'pg/text@1'`); the SQL runtime's
100
- * `decodeRow` reads from this key. A user `defineAnnotation('codecs')`
101
- * handle is not structurally prevented, but its behavior with the
102
- * emitter and the runtime is undefined and we make no compatibility
103
- * guarantees about it.
104
- * - Target-specific keys such as `pg` (and equivalents on other
105
- * targets) are similarly reserved for adapter / target use.
106
- *
107
- * `applicableTo` declares which operation kinds the annotation may attach
108
- * to. The lane terminals' type-level `ValidAnnotations<K, As>` gate rejects
109
- * annotations whose `Kinds` does not include the terminal's `K`; the
110
- * runtime helper `assertAnnotationsApplicable` does the equivalent at
111
- * runtime so casts and `any` cannot bypass the gate.
112
- */
113
- interface DefineAnnotationOptions<Kinds extends OperationKind> {
114
- readonly namespace: string;
115
- readonly applicableTo: readonly Kinds[];
116
- }
117
- /**
118
- * Defines a typed annotation handle.
119
- *
120
- * Two-step call form. The first step takes the `Payload` type argument
121
- * (TypeScript cannot infer `Payload` from anything in the options, so it
122
- * must be supplied explicitly); the second step takes the runtime options
123
- * and infers `Kinds` from the `applicableTo` array via a `const` type
124
- * parameter, so the operation kinds appear exactly once at the call site.
125
- *
126
- * @example
127
- * ```typescript
128
- * // Read-only annotation. Lane terminals like `db.User.first(...)` accept
129
- * // it; `db.User.create(...)` rejects it at the type level.
130
- * const cacheAnnotation = defineAnnotation<{ ttl?: number; skip?: boolean }>()({
131
- * namespace: 'cache',
132
- * applicableTo: ['read'],
133
- * }); // Kinds inferred as 'read'
134
- *
135
- * // Write-only annotation. Mirror image.
136
- * const auditAnnotation = defineAnnotation<{ actor: string }>()({
137
- * namespace: 'audit',
138
- * applicableTo: ['write'],
139
- * }); // Kinds inferred as 'write'
140
- *
141
- * // Annotation applicable to both kinds (e.g. tracing).
142
- * const otelAnnotation = defineAnnotation<{ traceId: string }>()({
143
- * namespace: 'otel',
144
- * applicableTo: ['read', 'write'],
145
- * }); // Kinds inferred as 'read' | 'write'
146
- * ```
147
- *
148
- * **Reserved namespaces.** See `DefineAnnotationOptions.namespace` for the
149
- * list of framework-internal namespaces (`codecs`, target-specific keys).
150
- * `defineAnnotation` does not structurally prevent a user from naming a
151
- * reserved namespace, but the framework makes no compatibility guarantee
152
- * about handles that do.
153
- */
154
- declare function defineAnnotation<Payload>(): <const Kinds extends OperationKind>(options: DefineAnnotationOptions<Kinds>) => AnnotationHandle<Payload, Kinds>;
155
- /**
156
- * Type-level applicability gate consumed by lane terminals.
157
- *
158
- * Maps a tuple of `AnnotationValue`s to a tuple where each element either
159
- * keeps its annotation type (when the annotation's declared `Kinds`
160
- * includes the terminal's operation kind `K`) or resolves to `never`
161
- * (when the kinds are incompatible). A `never` element makes the entire
162
- * tuple unassignable, surfacing the mismatch as a type error at the call
163
- * site of the terminal.
164
- *
165
- * The SQL DSL builders constrain their variadic `...annotations`
166
- * parameter via `As & ValidAnnotations<K, As>`. **The intersection is
167
- * load-bearing** — see the note below. The ORM terminals deliberately
168
- * sidestep this trick by taking one annotation per `meta.annotate(...)`
169
- * call (no variadic-tuple inference involved), so `ValidAnnotations` is
170
- * consumed only by the SQL DSL today.
171
- *
172
- * @example
173
- * ```typescript
174
- * class SelectQuery<Row> {
175
- * annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(
176
- * ...annotations: As & ValidAnnotations<'read', As>
177
- * ): SelectQuery<Row>;
178
- * }
179
- *
180
- * class InsertQuery<Row> {
181
- * annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(
182
- * ...annotations: As & ValidAnnotations<'write', As>
183
- * ): InsertQuery<Row>;
184
- * }
185
- *
186
- * db.users.select('id').annotate(cacheAnnotation({ ttl: 60 }));
187
- * // ✓ cacheAnnotation declares 'read'; SelectQuery.annotate requires 'read'.
188
- *
189
- * db.users.insert([{ name: 'Alice' }]).annotate(cacheAnnotation({ ttl: 60 }));
190
- * // ✗ cacheAnnotation declares 'read'; InsertQuery.annotate requires 'write'.
191
- * // Element resolves to `never` → tuple unassignable → type error.
192
- * ```
193
- *
194
- * **Why `As & ValidAnnotations<K, As>` and not `ValidAnnotations<K, As>`
195
- * alone.** TypeScript's variadic-tuple inference is too forgiving when
196
- * the parameter type refers to `As` only through `ValidAnnotations`: it
197
- * will pick an `As` that makes the call valid even when the gated tuple
198
- * would contain `never` for an inapplicable element. The intersection
199
- * pins `As` to the actual call-site tuple AND requires it to be
200
- * assignable to the gated form. A `never` element in the gated tuple
201
- * then collapses the corresponding intersection position to `never`,
202
- * and the inapplicable argument fails to assign — surfacing the mismatch
203
- * as a type error at the call site.
204
- *
205
- * The runtime helper `assertAnnotationsApplicable` covers the equivalent
206
- * check at runtime so casts and `any` cannot bypass this gate.
207
- */
208
- type ValidAnnotations<K extends OperationKind, As extends readonly AnnotationValue<unknown, OperationKind>[]> = { readonly [I in keyof As]: As[I] extends AnnotationValue<infer P, infer Kinds> ? K extends Kinds ? AnnotationValue<P, Kinds> : never : never; };
209
- /**
210
- * Runtime applicability gate. Throws `RUNTIME.ANNOTATION_INAPPLICABLE` if
211
- * any annotation in `annotations` declares an `applicableTo` set that does
212
- * not include `kind`. Used by lane terminals (SQL DSL builders' `.build()`,
213
- * ORM `Collection` terminals) to fail closed when the type-level
214
- * `ValidAnnotations` gate is bypassed via cast / `any` / dynamic
215
- * invocation.
216
- *
217
- * Passes silently on:
218
- * - empty arrays
219
- * - annotations whose `applicableTo` includes `kind`
220
- *
221
- * Throws on:
222
- * - any annotation whose `applicableTo` does not include `kind`. The
223
- * error names the offending annotation's `namespace` and the
224
- * `terminalName` so users can locate the misuse.
225
- *
226
- * @example
227
- * ```typescript
228
- * // Inside an ORM read terminal:
229
- * assertAnnotationsApplicable(annotations, 'read', 'first');
230
- * ```
231
- */
232
- declare function assertAnnotationsApplicable(annotations: readonly AnnotationValue<unknown, OperationKind>[], kind: OperationKind, terminalName: string): void;
233
- //#endregion
234
- //#region src/execution/async-iterable-result.d.ts
235
- declare class AsyncIterableResult<Row> implements AsyncIterable<Row>, PromiseLike<Row[]> {
236
- private readonly generator;
237
- private consumed;
238
- private consumedBy;
239
- private bufferedArrayPromise;
240
- constructor(generator: AsyncGenerator<Row, void, unknown>);
241
- [Symbol.asyncIterator](): AsyncIterator<Row>;
242
- toArray(): Promise<Row[]>;
243
- first(): Promise<Row | null>;
244
- firstOrThrow(): Promise<Row>;
245
- then<TResult1 = Row[], TResult2 = never>(onfulfilled?: ((value: Row[]) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
246
- }
247
- //#endregion
248
- //#region src/execution/query-plan.d.ts
249
- /**
250
- * Family-agnostic plan marker.
251
- *
252
- * Carries only `meta` (the family-agnostic plan metadata) and the optional
253
- * phantom `_row` parameter that lets type-level utilities recover the row
254
- * type from a plan value. SQL and Mongo extend this marker with their own
255
- * concrete shapes (`SqlQueryPlan`, `MongoQueryPlan`).
256
- *
257
- * `QueryPlan` is the *pre-lowering* marker — i.e. the surface a builder
258
- * produces before family-specific lowering turns it into an executable
259
- * plan (`ExecutionPlan`).
260
- */
261
- interface QueryPlan<Row = unknown> {
262
- readonly meta: PlanMeta;
263
- /**
264
- * Phantom property to carry the Row generic for type-level utilities.
265
- * Not set at runtime; used only for `ResultType` extraction.
266
- */
267
- readonly _row?: Row;
268
- }
269
- /**
270
- * Family-agnostic execution-plan marker.
271
- *
272
- * Extends `QueryPlan` with no additional structural fields — the marker
273
- * exists to nominally distinguish executable plans from pre-lowering plans
274
- * in the type system. Family-specific execution plans (`SqlExecutionPlan`,
275
- * `MongoExecutionPlan`) extend this marker with their concrete shapes
276
- * (e.g. `sql + params` for SQL, `wireCommand` for Mongo).
277
- */
278
- interface ExecutionPlan<Row = unknown> extends QueryPlan<Row> {}
279
- /**
280
- * Extracts the `Row` type from a plan via the phantom `_row` property.
281
- *
282
- * Works with any plan that extends `QueryPlan<Row>` — including
283
- * `ExecutionPlan<Row>`, `SqlQueryPlan<Row>`, `SqlExecutionPlan<Row>`,
284
- * `MongoQueryPlan<Row>`, and `MongoExecutionPlan<Row>`.
285
- *
286
- * The `_row` property must be present in the plan's static type for the
287
- * conditional to bind `R`; objects whose type lacks `_row` resolve to
288
- * `never`. Without the `keyof` guard, `extends { _row?: infer R }` would
289
- * silently match any object and infer `unknown`.
290
- *
291
- * Example: `type Row = ResultType<typeof plan>`.
292
- */
293
- type ResultType<P> = '_row' extends keyof P ? P extends {
294
- readonly _row?: infer R;
295
- } ? R : never : never;
296
- //#endregion
297
- //#region src/execution/runtime-middleware.d.ts
298
- interface RuntimeLog {
299
- info(event: unknown): void;
300
- warn(event: unknown): void;
301
- error(event: unknown): void;
302
- debug?(event: unknown): void;
303
- }
304
- /**
305
- * Per-operation context threaded through every middleware phase
306
- * (`beforeQuery`, `interceptQuery`, `onRow`, `afterQuery` for queries, and
307
- * `beforeExecute`, `interceptExecute`, `afterExecute` for executes). Allocated
308
- * once per runtime operation and shared by reference across all middleware in
309
- * the chain.
310
- *
311
- * - `signal` carries the per-operation `AbortSignal` -- the same reference
312
- * passed to the runtime call and the same reference threaded into the
313
- * per-call `CodecCallContext` (ADR 207). Middleware that wraps a
314
- * network-backed SDK forwards `ctx.signal` into that SDK to propagate caller
315
- * cancellation; pure-CPU middleware ignores it.
316
- *
317
- * Symmetric plumbing across all middleware phases is a deliberate choice: a
318
- * middleware that wraps a downstream observability hook or post-processor in
319
- * `afterQuery` / `afterExecute`, `interceptQuery` / `interceptExecute`, or
320
- * `onRow` needs the same cancellation reach as its before hook.
321
- */
322
- interface RuntimeMiddlewareContext {
323
- readonly contract: unknown;
324
- readonly mode: 'strict' | 'permissive';
325
- readonly now: () => number;
326
- readonly log: RuntimeLog;
327
- /**
328
- * Returns a stable string identifying the (storage, statement, params)
329
- * tuple of an execution. Two semantically equivalent executions return
330
- * the same string. Used by middleware that need per-execution identity
331
- * (caching, request coalescing).
332
- *
333
- * The family runtime owns the implementation:
334
- * - SQL: `meta.storageHash` + `exec.sql` + `canonicalStringify(exec.params)`
335
- * - Mongo: `meta.storageHash` + `canonicalStringify({ ...exec.command })`
336
- *
337
- * The method is `async` because the underlying digest helper
338
- * (`hashContent`) uses the WebCrypto API, whose `crypto.subtle.digest`
339
- * primitive is asynchronous by design.
340
- *
341
- * The returned string is intended to be consumed directly as a `Map` key
342
- * — it is not (and should not be) further hashed by callers.
343
- */
344
- contentHash(exec: ExecutionPlan): Promise<string>;
345
- /**
346
- * Per-operation cancellation signal threaded through every selected
347
- * middleware phase. Middleware that wraps async work or downstream
348
- * cancellable primitives should observe this and abort early when the
349
- * consumer cancels.
350
- */
351
- readonly signal?: AbortSignal;
352
- /**
353
- * Identifies the queryable scope this operation is running under.
354
- *
355
- * - `'runtime'` — top-level `runtime.query(plan)` or `runtime.execute(plan)`.
356
- * The default scope used by the standard read/write paths.
357
- * - `'connection'` — `connection.query(plan)` or `connection.execute(plan)`
358
- * after `runtime.connection()` checked out a connection from the pool.
359
- * - `'transaction'` — `transaction.query(plan)` or
360
- * `transaction.execute(plan)` inside an explicit transaction, or an
361
- * operation routed through `withTransaction`.
362
- *
363
- * Middleware that should only act at the top level read this field to
364
- * bypass non-runtime scopes. The cache middleware uses it to skip
365
- * caching inside transactions (where read-after-write coherence is the
366
- * caller's expectation) and dedicated connections (where the user has
367
- * explicitly stepped outside the shared cache surface). Observers that
368
- * don't care about the scope can ignore the field.
369
- *
370
- * Family runtimes populate this at context-construction time per
371
- * scope. Existing middleware that ignore the field are unaffected.
372
- */
373
- readonly scope: 'runtime' | 'connection' | 'transaction';
374
- /**
375
- * Identity for one `query()` or `execute()` call. The runtime mints a fresh
376
- * value via `crypto.randomUUID()` when it constructs the per-operation
377
- * context, then threads that context through every hook in the selected
378
- * query or execute lifecycle. Every hook in one call therefore observes
379
- * the same `planExecutionId`; two calls for the same plan observe distinct
380
- * values. Use this to correlate observations across a single operation
381
- * (tracing, timing, audit). See ADR 220.
382
- */
383
- readonly planExecutionId: string;
384
- }
385
- interface AfterResultBase {
386
- readonly latencyMs: number;
387
- /**
388
- * Indicates which execution path was selected.
389
- *
390
- * - `'driver'` — the default. The result came from the underlying driver via
391
- * `runDriver` / `runQueryWithMiddleware` or
392
- * `runExecuteWithMiddleware`'s normal path.
393
- * - `'middleware'` — a `RuntimeMiddleware.interceptQuery` or
394
- * `RuntimeMiddleware.interceptExecute` hook selected the middleware
395
- * interception path. This includes both supplying the result directly and
396
- * completing with an interceptor error; the driver was not invoked.
397
- *
398
- * Observers (telemetry, lints, budgets) that need to distinguish between
399
- * driver-served and middleware-served executions read this field.
400
- * Observers that don't care can ignore it.
401
- */
402
- readonly source: 'driver' | 'middleware';
403
- }
404
- interface AfterQueryResult extends AfterResultBase {
405
- readonly rowCount: number;
406
- readonly completed: boolean;
407
- }
408
- type AfterExecuteResult = AfterResultBase & ({
409
- readonly stats: RuntimeStatementStats;
410
- readonly completed: true;
411
- } | {
412
- readonly completed: false;
413
- });
414
- interface QueryInterceptResult {
415
- readonly rows: AsyncIterable<Record<string, unknown>> | Iterable<Record<string, unknown>>;
416
- }
417
- interface ExecuteInterceptResult {
418
- readonly stats: RuntimeStatementStats;
419
- }
420
- /**
421
- * Marker interface for family-specific param-ref mutators threaded into
422
- * `beforeQuery` or `beforeExecute` as the third argument. The framework treats
423
- * the mutator opaquely — it allocates and forwards the family's mutator
424
- * instance so the operation-specific middleware runners can stay
425
- * family-agnostic. SQL extends this with `SqlParamRefMutator` (over
426
- * `ParamRef`); Mongo extends this with `MongoParamRefMutator` (over
427
- * `MongoParamRef`).
428
- *
429
- * Extension authors target the family-specific mutator type, not this
430
- * marker.
431
- */
432
- declare const PARAM_REF_MUTATOR_BRAND: unique symbol;
433
- type ParamRefMutator = {
434
- readonly [PARAM_REF_MUTATOR_BRAND]?: never;
435
- };
436
- /**
437
- * Family-agnostic middleware SPI parameterized over the plan marker.
438
- *
439
- * `TPlan` defaults to the framework `QueryPlan` marker so a generic
440
- * middleware (e.g. cross-family telemetry) can be authored without
441
- * naming a family. Family-specific middleware (`SqlMiddleware`,
442
- * `MongoMiddleware`) narrow `TPlan` to their concrete plan type.
443
- *
444
- * `TMutator` is the family-specific {@link ParamRefMutator} the runtime
445
- * threads into `beforeQuery(plan, ctx, params)` or
446
- * `beforeExecute(plan, ctx, params)` as a third argument. Existing
447
- * `(plan)` / `(plan, ctx)` middleware bodies continue to compile — TypeScript
448
- * permits assigning a function with fewer parameters to a function-typed slot
449
- * that declares more. The third arg is additive.
450
- */
451
- interface RuntimeMiddleware<TPlan extends QueryPlan = QueryPlan, TMutator extends ParamRefMutator = ParamRefMutator> {
452
- readonly name: string;
453
- readonly familyId?: string;
454
- readonly targetId?: string;
455
- /**
456
- * Fires after the family runtime has produced a draft execution plan from
457
- * the AST, but before the family encodes parameter values to driver wire
458
- * format. Mutations applied via the family-specific `params` mutator are
459
- * visible to the subsequent encode step.
460
- *
461
- * Lifecycle position (SQL example):
462
- * `runBeforeCompile → lowerSqlPlan → beforeQuery → encodeParams → interceptQuery → driver query`.
463
- *
464
- * The `params` argument is a family-specific {@link ParamRefMutator}
465
- * scoped to the value slots of `ParamRef` nodes in the plan's AST.
466
- * Middleware that doesn't need to mutate params can ignore the argument;
467
- * existing `(plan)` / `(plan, ctx)` bodies stay compatible.
468
- *
469
- * `ctx.signal` carries the per-operation `AbortSignal`; middleware that
470
- * wraps a network SDK forwards it. Cooperative cancellation surfaces a
471
- * `RUNTIME.ABORTED { phase: 'beforeQuery' }` envelope promptly even when the
472
- * body ignores the signal.
473
- *
474
- * Intercept ordering: `interceptQuery` runs *after* this hook; an
475
- * interceptor that short-circuits the driver path still observes the
476
- * post-`beforeQuery`, fully-encoded plan. The trade-off is that any
477
- * `beforeQuery` SDK round-trips happen even when a downstream interceptor
478
- * would have skipped the driver entirely.
479
- */
480
- beforeQuery?(plan: TPlan, ctx: RuntimeMiddlewareContext, params?: TMutator): void | Promise<void>;
481
- /**
482
- * Optional short-circuit hook for query executions. Runs inside
483
- * `runQueryWithMiddleware`, after the orchestrator receives the lowered plan
484
- * and after the `beforeQuery` hook fires. Middleware run in registration
485
- * order; the first to return a non-`undefined` `QueryInterceptResult` wins,
486
- * and subsequent middleware's `interceptQuery` does not fire.
487
- *
488
- * On a hit, `beforeQuery` has already fired; `runDriver` and `onRow` are
489
- * skipped. `afterQuery` still fires with `source: 'middleware'`.
490
- *
491
- * Returning `undefined` (or omitting the hook entirely) signals passthrough
492
- * — execution proceeds through the normal driver path.
493
- *
494
- * Errors thrown inside `interceptQuery` are rethrown by
495
- * `runQueryWithMiddleware` as the original `Error` — no envelope is
496
- * guaranteed at this layer. Before rethrowing, `afterQuery` fires with
497
- * `completed: false` and `source: 'middleware'`. Errors thrown by
498
- * `afterQuery` during the error path remain swallowed (existing semantics,
499
- * unchanged).
500
- *
501
- * Used by middleware that need to short-circuit query execution and supply
502
- * rows directly: caching, mocks, rate limiting, circuit breaking.
503
- *
504
- * `rows` accepts both `Iterable` (arrays, sync generators) and `AsyncIterable`
505
- * (async generators). `for await` natively handles both via
506
- * `Symbol.asyncIterator` / `Symbol.iterator` fallback, so the orchestrator
507
- * does not need to branch on the variant. Cached arrays in the cache
508
- * middleware are the common case; streaming variants support future use
509
- * cases like mock layers replaying recordings.
510
- *
511
- * Row shape is `Record<string, unknown>` — the same untyped shape `onRow`
512
- * receives. The SQL runtime decodes intercepted rows through its normal
513
- * codec pass, so interceptors cache and return raw (undecoded) rows.
514
- */
515
- interceptQuery?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<QueryInterceptResult | undefined>;
516
- onRow?(row: Record<string, unknown>, plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<void>;
517
- afterQuery?(plan: TPlan, result: AfterQueryResult, ctx: RuntimeMiddlewareContext): Promise<void>;
518
- /**
519
- * Fires after the family runtime has produced a draft execution plan from
520
- * the AST, but before the family encodes parameter values to driver wire
521
- * format. Mutations applied via the family-specific `params` mutator are
522
- * visible to the subsequent encode step.
523
- *
524
- * Lifecycle position (SQL example):
525
- * `runBeforeCompile → lowerSqlPlan → beforeExecute → encodeParams → interceptExecute → driver execute`.
526
- *
527
- * The `params` argument is a family-specific {@link ParamRefMutator}
528
- * scoped to the value slots of `ParamRef` nodes in the plan's AST.
529
- * Middleware that doesn't need to mutate params can ignore the argument;
530
- * existing `(plan)` / `(plan, ctx)` bodies stay compatible.
531
- *
532
- * `ctx.signal` carries the per-operation `AbortSignal`; middleware that
533
- * wraps a network SDK forwards it. Cooperative cancellation surfaces a
534
- * `RUNTIME.ABORTED { phase: 'beforeExecute' }` envelope promptly even when
535
- * the body ignores the signal.
536
- *
537
- * Intercept ordering: `interceptExecute` runs *after* this hook; an
538
- * interceptor that short-circuits the driver path still observes the
539
- * post-`beforeExecute`, fully-encoded plan. The trade-off is that any
540
- * `beforeExecute` SDK round-trips happen even when a downstream interceptor
541
- * would have skipped the driver entirely.
542
- */
543
- beforeExecute?(plan: TPlan, ctx: RuntimeMiddlewareContext, params?: TMutator): void | Promise<void>;
544
- /**
545
- * Optional short-circuit hook for execute operations. Middleware run in
546
- * registration order; the first to return a non-`undefined`
547
- * `ExecuteInterceptResult` wins, and subsequent middleware's
548
- * `interceptExecute` does not fire.
549
- *
550
- * On a hit, `beforeExecute` has already fired; only the driver execute is
551
- * skipped. The statistics supplied in `stats` are returned eagerly; there is
552
- * no row stream and `onRow` is not fired. `afterExecute` still fires with
553
- * `source: 'middleware'`.
554
- *
555
- * Returning `undefined` (or omitting the hook entirely) signals passthrough
556
- * — execution proceeds through the normal driver path. Errors thrown inside
557
- * `interceptExecute` are rethrown by `runExecuteWithMiddleware` as the
558
- * original `Error`. Before rethrowing, `afterExecute` fires with
559
- * `completed: false`; errors thrown by `afterExecute` during the error path
560
- * remain swallowed.
561
- */
562
- interceptExecute?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<ExecuteInterceptResult | undefined>;
563
- afterExecute?(plan: TPlan, result: AfterExecuteResult, ctx: RuntimeMiddlewareContext): Promise<void>;
564
- }
565
- /**
566
- * Cross-family middleware — one that doesn't constrain `familyId` or
567
- * `targetId` and is therefore compatible with any family runtime's
568
- * middleware array (`SqlMiddleware[]`, `MongoMiddleware[]`, etc.).
569
- *
570
- * The intersection `RuntimeMiddleware & { familyId?: undefined; targetId?: undefined }`
571
- * pins both optional properties to exactly `undefined` (intersecting
572
- * `string | undefined` with `undefined` collapses to `undefined`). Under
573
- * `exactOptionalPropertyTypes: true`, the plain `RuntimeMiddleware` shape
574
- * — with `familyId?: string` — is *not* assignable to `SqlMiddleware`
575
- * (which narrows `familyId?: 'sql'`) because `string` is wider than
576
- * `'sql'`. Pinning the property to `undefined` makes the value a subtype
577
- * of every narrowed variant: `undefined` extends both `'sql' | undefined`
578
- * and `'mongo' | undefined`, so a `CrossFamilyMiddleware` value drops
579
- * into a SQL or Mongo middleware slot without a cast.
580
- *
581
- * Cross-family middleware factories (`createCacheMiddleware`, future
582
- * `audit` / OTel middleware) declare this as their return type so the
583
- * cross-family typing is named once rather than re-spelled at every call
584
- * site.
585
- */
586
- type CrossFamilyMiddleware<TPlan extends QueryPlan = QueryPlan> = RuntimeMiddleware<TPlan> & {
587
- readonly familyId?: undefined;
588
- readonly targetId?: undefined;
589
- };
590
- /**
591
- * Optional per-operation options accepted by every family runtime.
592
- *
593
- * `signal` is the per-operation cancellation signal. The runtime threads it
594
- * through middleware and codec calls; query row streams stop with
595
- * `RUNTIME.ABORTED` when the caller aborts. Omitting the option (or passing
596
- * `undefined`) preserves today's behavior bit-for-bit.
597
- */
598
- interface RuntimeExecuteOptions {
599
- readonly signal?: AbortSignal;
600
- readonly scope?: 'runtime' | 'connection' | 'transaction';
601
- }
602
- /**
603
- * Cross-family SPI for any runtime that can query or execute plans and be shut down.
604
- * Each family runtime (SQL, Mongo) satisfies this interface — SQL nominally,
605
- * Mongo structurally (due to its phantom Row parameter using a unique symbol).
606
- *
607
- * The `_row` intersection on `query` connects the `Row` type parameter to the
608
- * plan, mirroring how `QueryPlan<Row>` carries a phantom `_row?: Row`.
609
- */
610
- interface RuntimeStatementStats {
611
- readonly affectedRows: number;
612
- }
613
- interface RuntimeExecutor<TPlan extends QueryPlan> {
614
- query<Row>(plan: TPlan & {
615
- readonly _row?: Row;
616
- }, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
617
- execute(plan: TPlan, options?: RuntimeExecuteOptions): Promise<RuntimeStatementStats>;
618
- close(): Promise<void>;
619
- }
620
- declare function checkMiddlewareCompatibility(middleware: RuntimeMiddleware, runtimeFamilyId: string, runtimeTargetId: string): void;
621
- //#endregion
622
- //#region src/execution/before-execute-chain.d.ts
623
- /**
624
- * Runs every middleware's `beforeQuery` hook in registration order,
625
- * threading through the (optional) family-specific `paramsMutator`.
626
- *
627
- * Why this lives outside {@link runQueryWithMiddleware}: middleware that
628
- * mutates parameter values (e.g. cipherstash's bulk-encrypt SDK
629
- * round-trip) must run *before* the family runtime encodes those
630
- * parameters to driver wire format. Family runtimes call
631
- * `runBeforeQueryChain` between the AST → plan lowering step and
632
- * the parameter encode step; the encode then observes the mutator's
633
- * `currentParams()` view. `runQueryWithMiddleware` retains the rest of
634
- * the query lifecycle (`interceptQuery`, driver/row source loop, `onRow`,
635
- * `afterQuery`) but no longer fires `beforeQuery` itself.
636
- *
637
- * Lifecycle within this helper:
638
- *
639
- * 1. For each middleware in registration order, if `beforeQuery`
640
- * is implemented:
641
- * - `checkAborted(ctx, 'beforeQuery')` short-circuits if the
642
- * caller already aborted at entry.
643
- * - The hook is invoked with `(plan, ctx, paramsMutator)`. A
644
- * middleware body that ignores the mutator stays compatible —
645
- * JavaScript allows extra positional arguments.
646
- * - If the hook returns a Promise, it is raced against
647
- * `ctx.signal` via {@link raceAgainstAbort} so cooperative
648
- * cancellation surfaces a `RUNTIME.ABORTED { phase:
649
- * 'beforeQuery' }` envelope even when the body itself
650
- * ignores the signal.
651
- *
652
- * Error propagation: any error thrown by a `beforeQuery` body
653
- * (or surfaced by the abort race) propagates out of this helper
654
- * unchanged. Family runtime entry points await this helper before invoking
655
- * `runQueryWithMiddleware`, so a rejection prevents the runner and its
656
- * `afterQuery` hook from running.
657
- *
658
- * Relationship to {@link runQueryWithMiddleware}: the framework's
659
- * `RuntimeCore.query` template calls this helper between
660
- * `lower(plan)` and `runQueryWithMiddleware(...)`. Family runtimes that
661
- * override query preparation (e.g. SQL, which inlines lower + encode for
662
- * direct mutator threading) call this helper themselves at the
663
- * equivalent point — between the family's AST → draft-plan
664
- * lowering and the parameter-encode step.
665
- *
666
- * Intercept ordering: this helper fires unconditionally before
667
- * `runQueryWithMiddleware`. `interceptQuery` (inside
668
- * `runQueryWithMiddleware`) therefore observes the post-`beforeQuery`
669
- * plan — mutator mutations are visible in the params interceptors see.
670
- * The trade-off is documented on `RuntimeMiddleware.interceptQuery`.
671
- */
672
- declare function runBeforeQueryChain<TExec extends ExecutionPlan, TMutator extends ParamRefMutator = ParamRefMutator>(plan: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec, TMutator>>, ctx: RuntimeMiddlewareContext, paramsMutator?: TMutator): Promise<void>;
673
- /**
674
- * Runs every middleware's `beforeExecute` hook in registration order,
675
- * threading through the (optional) family-specific `paramsMutator`.
676
- *
677
- * Why this lives outside {@link runExecuteWithMiddleware}: middleware that
678
- * mutates parameter values (e.g. cipherstash's bulk-encrypt SDK
679
- * round-trip) must run *before* the family runtime encodes those
680
- * parameters to driver wire format. Family runtimes call
681
- * `runBeforeExecuteChain` between the AST → plan lowering step and
682
- * the parameter encode step; the encode then observes the mutator's
683
- * `currentParams()` view. `runExecuteWithMiddleware` retains the rest of
684
- * the execute lifecycle (`interceptExecute`, driver statistics execution,
685
- * `afterExecute`) but no longer fires `beforeExecute` itself.
686
- *
687
- * Lifecycle within this helper:
688
- *
689
- * 1. For each middleware in registration order, if `beforeExecute`
690
- * is implemented:
691
- * - `checkAborted(ctx, 'beforeExecute')` short-circuits if the
692
- * caller already aborted at entry.
693
- * - The hook is invoked with `(plan, ctx, paramsMutator)`. A
694
- * middleware body that ignores the mutator stays compatible —
695
- * JavaScript allows extra positional arguments.
696
- * - If the hook returns a Promise, it is raced against
697
- * `ctx.signal` via {@link raceAgainstAbort} so cooperative
698
- * cancellation surfaces a `RUNTIME.ABORTED { phase:
699
- * 'beforeExecute' }` envelope even when the body itself
700
- * ignores the signal.
701
- *
702
- * Error propagation: any error thrown by a `beforeExecute` body
703
- * (or surfaced by the abort race) propagates out of this helper
704
- * unchanged. Family runtime entry points await this helper before invoking
705
- * `runExecuteWithMiddleware`, so a rejection prevents the runner and its
706
- * `afterExecute` hook from running.
707
- *
708
- * Relationship to {@link runExecuteWithMiddleware}: the framework's
709
- * `RuntimeCore.execute` template calls this helper between
710
- * `lower(plan)` and `runExecuteWithMiddleware(...)`. Family runtimes that
711
- * override execute (e.g. SQL, which inlines lower + encode for
712
- * direct mutator threading) call this helper themselves at the
713
- * equivalent point — between the family's AST → draft-plan
714
- * lowering and the parameter-encode step.
715
- *
716
- * Intercept ordering: this helper fires unconditionally before
717
- * `runExecuteWithMiddleware`. `interceptExecute` (inside
718
- * `runExecuteWithMiddleware`) therefore observes the post-`beforeExecute`
719
- * plan — mutator mutations are visible in the params interceptors see.
720
- * The trade-off is documented on `RuntimeMiddleware.interceptExecute`.
721
- */
722
- declare function runBeforeExecuteChain<TExec extends ExecutionPlan, TMutator extends ParamRefMutator = ParamRefMutator>(plan: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec, TMutator>>, ctx: RuntimeMiddlewareContext, paramsMutator?: TMutator): Promise<void>;
723
- //#endregion
724
- //#region src/shared/runtime-error.d.ts
725
- interface RuntimeErrorEnvelope extends Error {
726
- readonly code: string;
727
- readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME' | 'DRIVER' | 'MIGRATION' | 'ORM';
728
- readonly severity: 'error';
729
- readonly details?: Record<string, unknown>;
730
- }
731
- /**
732
- * Type guard for the runtime-error envelope produced by `runtimeError`.
733
- *
734
- * Prefer this over duck-typing on `error.code` directly so consumers stay
735
- * insulated from the envelope's internal shape.
736
- */
737
- declare function isRuntimeError(error: unknown): error is RuntimeErrorEnvelope;
738
- declare function runtimeError(code: string, message: string, details?: Record<string, unknown>): RuntimeErrorEnvelope;
739
- //#endregion
740
- //#region src/execution/runtime-error.d.ts
741
- /**
742
- * Stable code emitted by the runtime when an in-flight `execute()`
743
- * is cancelled via the per-query `AbortSignal`. The envelope's
744
- * `details.phase` distinguishes where the abort was observed:
745
- *
746
- * - `'encode'` — abort fired during `encodeParams` (SQL) or
747
- * `resolveValue` (Mongo).
748
- * - `'decode'` — abort fired during `decodeRow` / `decodeField`.
749
- * - `'stream'` — abort fired between rows or before any codec call
750
- * (already-aborted at entry).
751
- * - `'beforeQuery'` / `'beforeExecute'` / `'afterQuery'` /
752
- * `'afterExecute'` / `'onRow'` — abort fired on entry to or during
753
- * the corresponding middleware phase
754
- * (cooperative cancellation per the param-transform seam).
755
- */
756
- declare const RUNTIME_ABORTED: "RUNTIME.ABORTED";
757
- /** Discriminator placed in `details.phase` of a `RUNTIME.ABORTED` envelope. */
758
- type RuntimeAbortedPhase = 'encode' | 'decode' | 'stream' | 'beforeQuery' | 'beforeExecute' | 'afterQuery' | 'afterExecute' | 'onRow';
759
- /**
760
- * Construct a `RUNTIME.ABORTED` envelope. Phase distinguishes where the
761
- * abort was observed — codec call sites (`encode` / `decode` / `stream`)
762
- * or operation-specific middleware seams, as
763
- * enumerated on {@link RuntimeAbortedPhase}. Cause carries
764
- * `signal.reason` verbatim from the platform — native abort produces a
765
- * `DOMException`, explicit `controller.abort(reason)` produces whatever
766
- * the caller passed. No synthesis happens here.
767
- */
768
- declare function runtimeAborted(phase: RuntimeAbortedPhase, cause?: unknown): RuntimeErrorEnvelope;
769
- //#endregion
770
- //#region src/execution/race-against-abort.d.ts
771
- /**
772
- * Throw a phase-tagged `RUNTIME.ABORTED` envelope if the supplied
773
- * context is already aborted at the precheck site. Centralises the
774
- * `if (ctx.signal?.aborted) throw runtimeAborted(...)` pattern that
775
- * every codec dispatch site (and the `beforeExecute` middleware phase)
776
- * repeats. Accepts both the framework `CodecCallContext` and the
777
- * `RuntimeMiddlewareContext`; both expose `signal?: AbortSignal`.
778
- */
779
- declare function checkAborted(ctx: {
780
- readonly signal?: AbortSignal;
781
- }, phase: RuntimeAbortedPhase): void;
782
- /**
783
- * Race a per-cell `Promise.all` (or any other in-flight work promise) against
784
- * the supplied abort signal so the runtime returns `RUNTIME.ABORTED` promptly
785
- * even when codec bodies ignore the signal. In-flight bodies that ignore the
786
- * signal are abandoned and run to completion in the background — the
787
- * cooperative-cancellation contract documented in ADR 204.
788
- *
789
- * Call sites still SHOULD pre-check `signal.aborted` and short-circuit with
790
- * a phase-tagged `RUNTIME.ABORTED` envelope before invoking this helper —
791
- * that path is the canonical "aborted at entry" surface and avoids
792
- * scheduling the work promise. As a defensive belt-and-braces, this helper
793
- * also handles the already-aborted case internally: `AbortSignal` does not
794
- * replay past abort events to listeners registered after the abort, so we
795
- * inspect `signal.aborted` synchronously and reject with the sentinel
796
- * before installing the listener. The rejection is still attributed to the
797
- * abort path via the sentinel-identity check.
798
- *
799
- * Distinguishing the rejection source is load-bearing for AC-ERR4
800
- * (`RUNTIME.ENCODE_FAILED` / `RUNTIME.DECODE_FAILED` pass through unchanged).
801
- * The semantically equivalent `abortable(signal)` helper in
802
- * `@internal/utils` rejects with `signal.reason ?? new DOMException(...)`,
803
- * which is not stably distinguishable from a codec-thrown error by identity
804
- * alone (a fresh fallback DOMException is allocated per call). We instead
805
- * track abort attribution with a unique sentinel: only the `onAbort` listener
806
- * installed here ever rejects with the sentinel, so an `error === sentinel`
807
- * identity check after the race is unambiguous.
808
- *
809
- * Lives in `framework-components` (rather than the SQL family, where it
810
- * originated in m2) so every family runtime that needs cooperative
811
- * cancellation around a codec-dispatch `Promise.all` (SQL encode + decode
812
- * today, Mongo encode in m3) shares the same attribution logic.
813
- */
814
- declare function raceAgainstAbort<T>(work: Promise<T>, signal: AbortSignal | undefined, phase: RuntimeAbortedPhase): Promise<T>;
815
- //#endregion
816
- //#region src/execution/run-with-middleware.d.ts
817
- /**
818
- * Drives a single query execution of `runDriver()` through the middleware
819
- * lifecycle's `interceptQuery` + row-source + termination phases.
820
- *
821
- * Lifecycle, in order:
822
- * 1. For each middleware in registration order: `interceptQuery(exec, ctx)`.
823
- * The first non-`undefined` result wins; subsequent middleware's
824
- * `interceptQuery` does not fire. On a hit, the runtime emits a
825
- * `middleware.interceptQuery` debug event naming the winning middleware,
826
- * switches the row source to the intercepted rows, and proceeds with
827
- * `source: 'middleware'`. On all-passthrough (every `interceptQuery`
828
- * returns `undefined` or is omitted), `source: 'driver'` is used and the
829
- * row source is `runDriver()`.
830
- * 2. Iterate the row source. On the driver path, for each row, for each
831
- * middleware in registration order: `onRow(row, exec, ctx)`; then yield
832
- * the row. On the intercepted hit path, `onRow` is skipped — intercepted
833
- * rows did not originate from a driver row stream — but rows are still
834
- * yielded to the consumer in order.
835
- * 3. On successful completion: for each middleware in registration order:
836
- * `afterQuery(exec, { rowCount, latencyMs, completed: true, source },
837
- * ctx)`.
838
- * 4. On any error thrown during steps 1–2: for each middleware in
839
- * registration order: `afterQuery(exec, { rowCount, latencyMs,
840
- * completed: false, source }, ctx)`. Errors thrown by `afterQuery`
841
- * during the error path are swallowed so they do not mask the original
842
- * error. The original error is then rethrown.
843
- *
844
- * `beforeQuery` is **not** fired here — see
845
- * {@link runBeforeQueryChain} in `before-execute-chain.ts`. Family runtimes
846
- * call that helper between the AST → plan lowering step and the parameter
847
- * encode step so middleware that mutates ParamRef values can have its
848
- * mutations visible to encode. `runQueryWithMiddleware` operates on the
849
- * fully-encoded plan; interceptors therefore observe a fully-mutated,
850
- * encoded plan.
851
- *
852
- * The `source` field on `AfterQueryResult` lets observers (telemetry, lints,
853
- * budgets) distinguish driver-served from middleware-served executions
854
- * without needing their own out-of-band signal.
855
- *
856
- * This helper is the single canonical implementation of the
857
- * intercept-and-row-source loop; family runtimes should not reimplement it.
858
- */
859
- declare function runQueryWithMiddleware<TExec extends ExecutionPlan, Row>(exec: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec>>, ctx: RuntimeMiddlewareContext, runDriver: () => AsyncIterable<Row>): AsyncIterableResult<Row>;
860
- /**
861
- * Drives a single execute operation through the middleware
862
- * `interceptExecute` + statistics + termination phases.
863
- *
864
- * Lifecycle, in order:
865
- * 1. For each middleware in registration order: `interceptExecute(exec, ctx)`.
866
- * The first non-`undefined` result wins; subsequent middleware's
867
- * `interceptExecute` does not fire. On a hit, the runtime emits a
868
- * `middleware.interceptExecute` debug event naming the winning middleware,
869
- * uses the returned `stats`, and proceeds with `source: 'middleware'`.
870
- * On all-passthrough (every `interceptExecute` returns `undefined` or is
871
- * omitted), `source: 'driver'` is used and `runDriver()` supplies the
872
- * statistics.
873
- * 2. Execute operations return eager statistics. There is no row stream and
874
- * `onRow` does not fire.
875
- * 3. On successful completion: for each middleware in registration order:
876
- * `afterExecute(exec, { stats, latencyMs, completed: true, source }, ctx)`.
877
- * 4. On any error thrown during steps 1–2: for each middleware in
878
- * registration order: `afterExecute(exec, { latencyMs, completed: false,
879
- * source }, ctx)`. Errors thrown by `afterExecute` during the error path
880
- * are swallowed so they do not mask the original error. The original
881
- * error is then rethrown.
882
- *
883
- * `beforeExecute` is **not** fired here — see
884
- * {@link runBeforeExecuteChain} in `before-execute-chain.ts`. Family runtimes
885
- * call that helper between the AST → plan lowering step and the parameter
886
- * encode step so middleware that mutates ParamRef values can have its
887
- * mutations visible to encode. `runExecuteWithMiddleware` operates on the
888
- * fully-encoded plan; interceptors therefore observe a fully-mutated,
889
- * encoded plan.
890
- *
891
- * The `source` field on `AfterExecuteResult` lets observers (telemetry, lints,
892
- * budgets) distinguish driver-served from middleware-served executions
893
- * without needing their own out-of-band signal.
894
- */
895
- declare function runExecuteWithMiddleware<TExec extends ExecutionPlan>(exec: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec>>, ctx: RuntimeMiddlewareContext, runDriver: () => Promise<RuntimeStatementStats>): Promise<RuntimeStatementStats>;
896
- //#endregion
897
- //#region src/execution/runtime-core.d.ts
898
- /**
899
- * Constructor options shared by every concrete `RuntimeCore` subclass.
900
- *
901
- * Family runtimes typically build the middleware list and the
902
- * `RuntimeMiddlewareContext` themselves (running compatibility checks,
903
- * narrowing the context's `contract` field, etc.) before calling `super`.
904
- */
905
- interface RuntimeCoreOptions<TMiddleware extends RuntimeMiddleware<ExecutionPlan>> {
906
- readonly middleware: ReadonlyArray<TMiddleware>;
907
- readonly ctx: RuntimeMiddlewareContext;
908
- }
909
- /**
910
- * Family-agnostic abstract runtime base.
911
- *
912
- * Defines the shared operation-specific middleware lifecycles:
913
- *
914
- * 1. `runBeforeCompile(plan)` — concrete; defaults to identity. SQL overrides
915
- * this to run its shared `beforeCompile` middleware-hook chain.
916
- * 2. `lower(plan)` — abstract. Each family produces its `*ExecutionPlan`
917
- * (SQL via `lowerSqlPlan`, Mongo via `adapter.lower`).
918
- * 3. Queries run `beforeQuery`; statements run `beforeExecute`. Both chains
919
- * run after lowering and before their matching driver terminal. Family
920
- * runtimes that expose a params mutator to downstream encoding override
921
- * the operation and call the matching helper at the pre-encode point.
922
- * 4. The matching runner processes `interceptQuery` or `interceptExecute`
923
- * before invoking the driver. Queries then fire `onRow` and `afterQuery`;
924
- * statements fire `afterExecute`.
925
- *
926
- * Concrete subclasses must implement `lower`, `runDriver`, `runExecute`, and
927
- * `close`.
928
- *
929
- * The class is generic over:
930
- * - `TPlan` — the family's pre-lowering plan type.
931
- * - `TExec` — the family's post-lowering (executable) plan type.
932
- * - `TMiddleware` — the family's middleware type. Constrained to
933
- * `RuntimeMiddleware<TExec>` because the operation-specific runners invoke
934
- * hooks with the lowered `TExec`. Middleware therefore sees the
935
- * post-lowering plan.
936
- */
937
- declare abstract class RuntimeCore<TPlan extends QueryPlan, TExec extends ExecutionPlan, TMiddleware extends RuntimeMiddleware<TExec>> implements RuntimeExecutor<TPlan> {
938
- protected readonly middleware: ReadonlyArray<TMiddleware>;
939
- protected readonly ctx: RuntimeMiddlewareContext;
940
- constructor(options: RuntimeCoreOptions<TMiddleware>);
941
- /**
942
- * Pre-lowering hook for plan rewriting. Defaults to identity. Subclasses
943
- * may override to run a `beforeCompile` middleware chain (SQL does this
944
- * to support typed AST rewrites — see `before-compile-chain.ts`).
945
- */
946
- protected runBeforeCompile(plan: TPlan): TPlan | Promise<TPlan>;
947
- /**
948
- * Lower a pre-lowering `TPlan` into the family's executable `TExec`.
949
- * Family-specific: SQL produces `{ sql, params, ast?, ... }`; Mongo
950
- * produces `{ command, ... }`.
951
- *
952
- * `ctx` carries per-operation cancellation (and any future fields on
953
- * `CodecCallContext`); concrete subclasses forward it to the encode-side
954
- * codec dispatch site. The runtime allocates one ctx per operation call
955
- * and threads the same reference everywhere; the
956
- * `signal` field inside may be `undefined`, but the ctx object itself
957
- * is always present.
958
- */
959
- protected abstract lower(plan: TPlan, ctx: CodecCallContext): TExec | Promise<TExec>;
960
- /**
961
- * Drive the underlying transport for a lowered `TExec`. Yields raw rows
962
- * directly from the driver as `Record<string, unknown>`; codec decoding
963
- * (if any) is the subclass's responsibility, applied by wrapping
964
- * `query()` rather than living inside this hook.
965
- *
966
- * The `Row` type parameter on `query()` is satisfied by the caller via
967
- * the plan's phantom `_row`; the runtime treats rows as opaque records
968
- * here and trusts the caller's row typing.
969
- */
970
- protected abstract runDriver(exec: TExec): AsyncIterable<Record<string, unknown>>;
971
- protected abstract runExecute(exec: TExec): Promise<RuntimeStatementStats>;
972
- abstract close(): Promise<void>;
973
- query<Row>(plan: TPlan & {
974
- readonly _row?: Row;
975
- }, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
976
- execute(plan: TPlan, options?: RuntimeExecuteOptions): Promise<RuntimeStatementStats>;
977
- }
978
- //#endregion
979
- //#region src/meta-builder.d.ts
980
- /**
981
- * Per-terminal meta configurator handed to user callbacks. The terminal's
982
- * operation kind `K` is fixed by the terminal that constructed the builder;
983
- * `annotate(...)` accepts only annotations whose declared `Kinds` include
984
- * `K`.
985
- *
986
- * The conditional parameter type
987
- * `K extends Kinds ? AnnotationValue<P, Kinds> : never` collapses to `never`
988
- * for inapplicable annotations, surfacing the mismatch as a type error at
989
- * the call site of `meta.annotate(...)`. No variadic-tuple inference is
990
- * involved — TypeScript infers `Kinds` from the annotation argument and
991
- * checks the conditional directly.
992
- *
993
- * The runtime gate inside `annotate` (via
994
- * `assertAnnotationsApplicable`) catches cast / `any` / dynamic bypasses
995
- * and throws `RUNTIME.ANNOTATION_INAPPLICABLE`.
996
- *
997
- * `annotate` returns the builder for chaining; the return value of the
998
- * configurator callback is unused, so both block-body and expression-body
999
- * callbacks compile.
1000
- *
1001
- * @example
1002
- * ```typescript
1003
- * await db.User.find({ id }, (meta) => meta.annotate(cacheAnnotation({ ttl: 60 })));
1004
- * await db.User.create(input, (meta) => {
1005
- * meta.annotate(auditAnnotation({ actor: 'system' }));
1006
- * meta.annotate(otelAnnotation({ traceId }));
1007
- * });
1008
- * ```
1009
- */
1010
- interface MetaBuilder<K extends OperationKind> {
1011
- annotate<P, Kinds extends OperationKind>(annotation: K extends Kinds ? AnnotationValue<P, Kinds> : never): this;
1012
- }
1013
- /**
1014
- * Lane-side view of a meta builder. Extends the public `MetaBuilder<K>`
1015
- * surface with `annotations` so lane terminals can read the recorded map
1016
- * after invoking the user configurator.
1017
- *
1018
- * Lane terminals construct one of these via `createMetaBuilder(kind, terminalName)`,
1019
- * pass it to the user callback as `MetaBuilder<K>` (the narrower public
1020
- * view), then read `meta.annotations` to thread the recorded values into
1021
- * `plan.meta.annotations`.
1022
- */
1023
- interface LaneMetaBuilder<K extends OperationKind> extends MetaBuilder<K> {
1024
- readonly annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;
1025
- }
1026
- /**
1027
- * Construct a lane-side meta builder for a terminal of operation kind `K`.
1028
- *
1029
- * Lane terminals call this with their `kind` (`'read'` or `'write'`) and a
1030
- * `terminalName` for error messages, hand the resulting builder to the
1031
- * user-supplied configurator callback (typed as `MetaBuilder<K>`, the
1032
- * narrower public view), and read `meta.annotations` afterwards to thread
1033
- * the recorded values into `plan.meta.annotations`.
1034
- */
1035
- declare function createMetaBuilder<K extends OperationKind>(kind: K, terminalName: string): LaneMetaBuilder<K>;
1036
- //#endregion
1037
- export { checkAborted as A, runtimeAborted as B, RuntimeExecutor as C, RuntimeStatementStats as D, RuntimeMiddlewareContext as E, raceAgainstAbort as F, runBeforeExecuteChain as I, runBeforeQueryChain as L, createMetaBuilder as M, defineAnnotation as N, ValidAnnotations as O, isRuntimeError as P, runExecuteWithMiddleware as R, RuntimeExecuteOptions as S, RuntimeMiddleware as T, runtimeError as V, ResultType as _, AsyncIterableResult as a, RuntimeCoreOptions as b, ExecuteInterceptResult as c, MetaBuilder as d, OperationKind as f, RUNTIME_ABORTED as g, QueryPlan as h, AnnotationValue as i, checkMiddlewareCompatibility as j, assertAnnotationsApplicable as k, ExecutionPlan as l, QueryInterceptResult as m, AfterQueryResult as n, CrossFamilyMiddleware as o, ParamRefMutator as p, AnnotationHandle as r, DefineAnnotationOptions as s, AfterExecuteResult as t, LaneMetaBuilder as u, RuntimeAbortedPhase as v, RuntimeLog as w, RuntimeErrorEnvelope as x, RuntimeCore as y, runQueryWithMiddleware as z };
1038
- //# sourceMappingURL=runtime-Cuxw8obj.d.mts.map