@prisma/orm-family-sql 8.0.0-rc.18-dev.16 → 8.0.0-rc.18-dev.18

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 (281) hide show
  1. package/dist/{aggregate-descriptor-registry-DrJ1vHEo.mjs → aggregate-descriptor-registry-Dd7Uj7DJ.mjs} +3 -3
  2. package/dist/{aggregate-descriptor-registry-DrJ1vHEo.mjs.map → aggregate-descriptor-registry-Dd7Uj7DJ.mjs.map} +1 -1
  3. package/dist/{ast-BDwGvnKK.mjs → ast-CBO3PEJF.mjs} +73 -47
  4. package/dist/ast-CBO3PEJF.mjs.map +1 -0
  5. package/dist/{ast-BoM9T1b2.d.mts → ast-Dzsat0Zb.d.mts} +27 -26
  6. package/dist/ast-Dzsat0Zb.d.mts.map +1 -0
  7. package/dist/{attribute-specs-D7EhHD08.d.mts → attribute-specs-2I2xuKEa.d.mts} +4 -3
  8. package/dist/attribute-specs-2I2xuKEa.d.mts.map +1 -0
  9. package/dist/{authored-check-naming-CO3GA46Y.mjs → authored-check-naming-CIX7Bbyh.mjs} +3 -3
  10. package/dist/{authored-check-naming-CO3GA46Y.mjs.map → authored-check-naming-CIX7Bbyh.mjs.map} +1 -1
  11. package/dist/{authoring-entity-types-CZ-vdwYS-Cl5erH9X.d.mts → authoring-entity-types-CZ-vdwYS-BpyuSxbj.d.mts} +2 -2
  12. package/dist/{authoring-entity-types-CZ-vdwYS-Cl5erH9X.d.mts.map → authoring-entity-types-CZ-vdwYS-BpyuSxbj.d.mts.map} +1 -1
  13. package/dist/{authoring-type-constructors-0Iv2zdwS-yMnSyGBK.mjs → authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs} +2 -2
  14. package/dist/{authoring-type-constructors-0Iv2zdwS-yMnSyGBK.mjs.map → authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs.map} +1 -1
  15. package/dist/builder.d.mts +3 -3
  16. package/dist/builder__runtime.d.mts +7 -7
  17. package/dist/builder__runtime.mjs +2 -2
  18. package/dist/builder__types.d.mts +5 -5
  19. package/dist/{codec-descriptor-registry-Bg9OjQf_.mjs → codec-descriptor-registry-4kw8FPpo.mjs} +2 -2
  20. package/dist/{codec-descriptor-registry-Bg9OjQf_.mjs.map → codec-descriptor-registry-4kw8FPpo.mjs.map} +1 -1
  21. package/dist/{collection-methods-BnR4UjcW-C_55W2m0.d.mts → collection-methods-B-tM7OPZ-v8HK9Txa.d.mts} +3 -3
  22. package/dist/{collection-methods-BnR4UjcW-C_55W2m0.d.mts.map → collection-methods-B-tM7OPZ-v8HK9Txa.d.mts.map} +1 -1
  23. package/dist/collection-methods-DQAFcGEB.d.mts +1 -0
  24. package/dist/{config-types-ni1nb_HA.mjs → config-types-ComQZUlA.mjs} +2 -2
  25. package/dist/{config-types-ni1nb_HA.mjs.map → config-types-ComQZUlA.mjs.map} +1 -1
  26. package/dist/{contract-builder-CH0AIjsv.d.mts → contract-builder-De_fyZGT.d.mts} +6 -6
  27. package/dist/{contract-builder-CH0AIjsv.d.mts.map → contract-builder-De_fyZGT.d.mts.map} +1 -1
  28. package/dist/{contract-builder-CiYVj56_.mjs → contract-builder-fQ3gkIR5.mjs} +5 -5
  29. package/dist/{contract-builder-CiYVj56_.mjs.map → contract-builder-fQ3gkIR5.mjs.map} +1 -1
  30. package/dist/contract-emitter.mjs +1 -1
  31. package/dist/contract-prisma7__provider.d.mts +12 -6
  32. package/dist/contract-prisma7__provider.d.mts.map +1 -1
  33. package/dist/contract-prisma7__provider.mjs +48 -43
  34. package/dist/contract-prisma7__provider.mjs.map +1 -1
  35. package/dist/contract-psl.d.mts +2 -2
  36. package/dist/contract-psl.d.mts.map +1 -1
  37. package/dist/contract-psl.mjs +1 -1
  38. package/dist/contract-psl__attribute-specs.d.mts +1 -1
  39. package/dist/contract-psl__attribute-specs.mjs +1 -1
  40. package/dist/contract-psl__provider.mjs +2 -2
  41. package/dist/contract-psl__provider.mjs.map +1 -1
  42. package/dist/contract-ts.d.mts +2 -2
  43. package/dist/contract-ts.mjs +4 -4
  44. package/dist/contract-ts__config-types.mjs +1 -1
  45. package/dist/contract-ts__contract-builder.d.mts +2 -2
  46. package/dist/contract-ts__contract-builder.mjs +3 -3
  47. package/dist/contract.d.mts +6 -6
  48. package/dist/contract.mjs +15 -15
  49. package/dist/contract__authored-check-naming.mjs +1 -1
  50. package/dist/contract__data-type-support.d.mts +2 -2
  51. package/dist/contract__data-type-support.mjs +2 -2
  52. package/dist/contract__data-type.d.mts +2 -2
  53. package/dist/contract__data-type.mjs +3 -3
  54. package/dist/contract__entity-kinds.mjs +1 -1
  55. package/dist/contract__factories.mjs +1 -1
  56. package/dist/contract__foreign-key-materialization.d.mts +1 -1
  57. package/dist/contract__foreign-key-materialization.mjs +2 -2
  58. package/dist/contract__index-naming.mjs +1 -1
  59. package/dist/contract__sql-expression.d.mts +2 -2
  60. package/dist/contract__sql-expression.mjs +2 -2
  61. package/dist/contract__types.mjs +3 -3
  62. package/dist/contract__validators.d.mts +1 -1
  63. package/dist/contract__validators.mjs +2 -2
  64. package/dist/{control-DXqMl_gd.mjs → control-ClahTAD-.mjs} +246 -40
  65. package/dist/control-ClahTAD-.mjs.map +1 -0
  66. package/dist/{control-adapter-CkFfBVei-DGf1LihO.d.mts → control-adapter-BCopdpsT-DIHCWbq_.d.mts} +9 -26
  67. package/dist/control-adapter-BCopdpsT-DIHCWbq_.d.mts.map +1 -0
  68. package/dist/control-adapter-BsSf5pqM.d.mts +1 -0
  69. package/dist/{control-CPg4LwJV.d.mts → control-mpACqp72.d.mts} +72 -39
  70. package/dist/control-mpACqp72.d.mts.map +1 -0
  71. package/dist/{data-type-CYsho6Yd.d.mts → data-type-B8N33s-_.d.mts} +14 -7
  72. package/dist/data-type-B8N33s-_.d.mts.map +1 -0
  73. package/dist/{numeral-text-Cqu87pVe-DJCqBaSC.mjs → data-type-DKk8Unnz.mjs} +2 -2
  74. package/dist/data-type-DKk8Unnz.mjs.map +1 -0
  75. package/dist/{data-type-support-CfhpAKLX.mjs → data-type-support-C5-XxxeB.mjs} +11 -24
  76. package/dist/data-type-support-C5-XxxeB.mjs.map +1 -0
  77. package/dist/{data-type-support-4TcZuD7d.d.mts → data-type-support-CBcYhSkD.d.mts} +12 -16
  78. package/dist/data-type-support-CBcYhSkD.d.mts.map +1 -0
  79. package/dist/{db-BmrN9nRS-CzyybGKR.d.mts → db-BmrN9nRS-xynLbnAy.d.mts} +10 -10
  80. package/dist/{db-BmrN9nRS-CzyybGKR.d.mts.map → db-BmrN9nRS-xynLbnAy.d.mts.map} +1 -1
  81. package/dist/{ddl-types-DtKZjNtN-DWQeO79o.d.mts → ddl-types-CoP6yAw9-BDp3W_5g.d.mts} +4 -4
  82. package/dist/{ddl-types-DtKZjNtN-DWQeO79o.d.mts.map → ddl-types-CoP6yAw9-BDp3W_5g.d.mts.map} +1 -1
  83. package/dist/{default-mapping-B8_APB1M-CWcTmSQW.d.mts → default-mapping-CEISdj2g-DF1LzGBR.d.mts} +7 -5
  84. package/dist/default-mapping-CEISdj2g-DF1LzGBR.d.mts.map +1 -0
  85. package/dist/{derived-checks-Cgx_VgS3-CmFqNFgU.mjs → derived-checks-CrvMQTJF-DlxFFtNM.mjs} +18 -18
  86. package/dist/derived-checks-CrvMQTJF-DlxFFtNM.mjs.map +1 -0
  87. package/dist/{diff-CVVGktZG.d.mts → diff-Bd9ILpZL.d.mts} +20 -7
  88. package/dist/diff-Bd9ILpZL.d.mts.map +1 -0
  89. package/dist/diff-DZ82XaGR.mjs +21 -0
  90. package/dist/diff-DZ82XaGR.mjs.map +1 -0
  91. package/dist/{dist-Cg2lL1hR.mjs → dist-DAHIT4AS.mjs} +2 -2
  92. package/dist/{dist-Cg2lL1hR.mjs.map → dist-DAHIT4AS.mjs.map} +1 -1
  93. package/dist/{entity-kinds-CQ_jwgYv-HA5t2SE0.mjs → entity-kinds-CQ_jwgYv-DoOBWwvX.mjs} +3 -3
  94. package/dist/{entity-kinds-CQ_jwgYv-HA5t2SE0.mjs.map → entity-kinds-CQ_jwgYv-DoOBWwvX.mjs.map} +1 -1
  95. package/dist/exports-DVsHk8HP-DrH_2a-H.mjs +2371 -0
  96. package/dist/exports-DVsHk8HP-DrH_2a-H.mjs.map +1 -0
  97. package/dist/{expression-Ck1wys3N-Cdc7eUQS.d.mts → expression-BzrfOiPC-3NqR8UzK.d.mts} +4 -4
  98. package/dist/{expression-Ck1wys3N-Cdc7eUQS.d.mts.map → expression-BzrfOiPC-3NqR8UzK.d.mts.map} +1 -1
  99. package/dist/expression-CeerCjQG.d.mts +2 -0
  100. package/dist/{expression-CNBCbbzU-DOXKUxQs.d.mts → expression-sOY1120I-DOykEQlw.d.mts} +4 -4
  101. package/dist/expression-sOY1120I-DOykEQlw.d.mts.map +1 -0
  102. package/dist/{factories-vDQ3S5gW.mjs → factories-DkD3nMYt.mjs} +3 -3
  103. package/dist/{factories-vDQ3S5gW.mjs.map → factories-DkD3nMYt.mjs.map} +1 -1
  104. package/dist/family.d.mts +14 -14
  105. package/dist/family.mjs +8 -8
  106. package/dist/family__control-adapter.d.mts +2 -2
  107. package/dist/family__control.d.mts +5 -5
  108. package/dist/family__control.mjs +4 -4
  109. package/dist/family__diff.d.mts +1 -2
  110. package/dist/family__diff.mjs +2 -2
  111. package/dist/family__ir.d.mts +1 -1
  112. package/dist/family__ir.mjs +1 -1
  113. package/dist/family__migration.d.mts +1 -1
  114. package/dist/family__pack.d.mts +1 -1
  115. package/dist/family__pack.mjs +2 -2
  116. package/dist/family__psl-build.d.mts +2 -2
  117. package/dist/family__psl-build.mjs +1 -1
  118. package/dist/family__psl-infer.d.mts +1 -1
  119. package/dist/family__psl-infer.mjs +1 -1
  120. package/dist/{foreign-key-materialization-DJ6uhBba.d.mts → foreign-key-materialization-DCaDnUs-.d.mts} +3 -3
  121. package/dist/{foreign-key-materialization-DJ6uhBba.d.mts.map → foreign-key-materialization-DCaDnUs-.d.mts.map} +1 -1
  122. package/dist/{foreign-key-materialization-DibQ9Hjg.mjs → foreign-key-materialization-DfNPQL9G.mjs} +4 -4
  123. package/dist/{foreign-key-materialization-DibQ9Hjg.mjs.map → foreign-key-materialization-DfNPQL9G.mjs.map} +1 -1
  124. package/dist/{functions-DSwXxsTg.d.mts → functions-Cp8soSAv.d.mts} +3 -3
  125. package/dist/{functions-DSwXxsTg.d.mts.map → functions-Cp8soSAv.d.mts.map} +1 -1
  126. package/dist/{index-C8jUgdUh.d.mts → index-BxlXOVeT.d.mts} +30 -23
  127. package/dist/{index-C8jUgdUh.d.mts.map → index-BxlXOVeT.d.mts.map} +1 -1
  128. package/dist/{index-equivalence-DswCiq5l-DlC2yTK1.mjs → index-equivalence-DswCiq5l-BsphajRC.mjs} +2 -2
  129. package/dist/{index-equivalence-DswCiq5l-DlC2yTK1.mjs.map → index-equivalence-DswCiq5l-BsphajRC.mjs.map} +1 -1
  130. package/dist/{index-naming-BOcJT1B3-CeEoP8t3.mjs → index-naming-BOcJT1B3-18gQUduD.mjs} +2 -2
  131. package/dist/{index-naming-BOcJT1B3-CeEoP8t3.mjs.map → index-naming-BOcJT1B3-18gQUduD.mjs.map} +1 -1
  132. package/dist/index-reference-CWppFpUV.d.mts +1 -0
  133. package/dist/{index-reference-DJX-CNsb-D5uoBnH_.d.mts → index-reference-DJaQLZA3-DxmYkkX-.d.mts} +3 -3
  134. package/dist/{index-reference-DJX-CNsb-D5uoBnH_.d.mts.map → index-reference-DJaQLZA3-DxmYkkX-.d.mts.map} +1 -1
  135. package/dist/{interpreter-CvmBTYyI-DNl-jr2E.mjs → interpreter-CFj2aTEP-BHL3TOqk.mjs} +13 -11
  136. package/dist/interpreter-CFj2aTEP-BHL3TOqk.mjs.map +1 -0
  137. package/dist/{ir-D0Vpm5O9.d.mts → ir-DgNo535E.d.mts} +4 -2
  138. package/dist/ir-DgNo535E.d.mts.map +1 -0
  139. package/dist/ir-I-xciGUH.mjs.map +1 -1
  140. package/dist/middleware-IqWk9Eff.d.mts +1 -0
  141. package/dist/{middleware-YsFLC19Y-5mJZCBWq.d.mts → middleware-oCT0RWkt-AFlRNCOD.d.mts} +3 -3
  142. package/dist/{middleware-YsFLC19Y-5mJZCBWq.d.mts.map → middleware-oCT0RWkt-AFlRNCOD.d.mts.map} +1 -1
  143. package/dist/{migration-ESRa6312.d.mts → migration-lg_VgP_F.d.mts} +2 -2
  144. package/dist/{migration-ESRa6312.d.mts.map → migration-lg_VgP_F.d.mts.map} +1 -1
  145. package/dist/{naming-CT8tRisJ-DLHKo0Hm.mjs → naming-bM5qm5PY-DdginUhA.mjs} +2 -2
  146. package/dist/{naming-CT8tRisJ-DLHKo0Hm.mjs.map → naming-bM5qm5PY-DdginUhA.mjs.map} +1 -1
  147. package/dist/{opaque-sql-BWxbqe5a-GGKfyakq.mjs → opaque-sql-Dset3kln-BzzXoO94.mjs} +3 -3
  148. package/dist/opaque-sql-Dset3kln-BzzXoO94.mjs.map +1 -0
  149. package/dist/orm-client.d.mts +28 -60
  150. package/dist/orm-client.d.mts.map +1 -1
  151. package/dist/orm-client.mjs +564 -233
  152. package/dist/orm-client.mjs.map +1 -1
  153. package/dist/{pack-BtGENS4_.d.mts → pack-CyjyMUN0.d.mts} +3 -3
  154. package/dist/{pack-BtGENS4_.d.mts.map → pack-CyjyMUN0.d.mts.map} +1 -1
  155. package/dist/plan-BZpZafiQ.d.mts +2 -0
  156. package/dist/{plan-cGEaSXHv-yuz43WrR.d.mts → plan-Cbed2eDu-BZM3geSm.d.mts} +3 -3
  157. package/dist/plan-Cbed2eDu-BZM3geSm.d.mts.map +1 -0
  158. package/dist/{psl-build-PXVtl8gM.d.mts → psl-build-BHQfP1_C.d.mts} +5 -5
  159. package/dist/{psl-build-PXVtl8gM.d.mts.map → psl-build-BHQfP1_C.d.mts.map} +1 -1
  160. package/dist/{psl-build-8bx9WTUt.mjs → psl-build-BsJ6eChh.mjs} +118 -84
  161. package/dist/psl-build-BsJ6eChh.mjs.map +1 -0
  162. package/dist/{psl-column-resolution-BCkhNzOK-Bbrs_WzK.d.mts → psl-column-resolution-BCkhNzOK-mW_8C9vr.d.mts} +2 -2
  163. package/dist/{psl-column-resolution-BCkhNzOK-Bbrs_WzK.d.mts.map → psl-column-resolution-BCkhNzOK-mW_8C9vr.d.mts.map} +1 -1
  164. package/dist/{psl-field-resolution-SPNDr-jr-CH_gs3Oy.mjs → psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs} +76 -66
  165. package/dist/psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs.map +1 -0
  166. package/dist/{psl-infer-g040TwAr.d.mts → psl-infer-B6iemK9i.d.mts} +4 -4
  167. package/dist/{psl-infer-g040TwAr.d.mts.map → psl-infer-B6iemK9i.d.mts.map} +1 -1
  168. package/dist/{psl-infer-CG0_wra6.mjs → psl-infer-HPi_YMeE.mjs} +2 -2
  169. package/dist/{psl-infer-CG0_wra6.mjs.map → psl-infer-HPi_YMeE.mjs.map} +1 -1
  170. package/dist/{query-lane-context-C42-u9L1-BSJoP83K.d.mts → query-lane-context-BLOPW1rQ-Bn3ugl9a.d.mts} +5 -5
  171. package/dist/{query-lane-context-C42-u9L1-BSJoP83K.d.mts.map → query-lane-context-BLOPW1rQ-Bn3ugl9a.d.mts.map} +1 -1
  172. package/dist/query-lane-context-Dpep1Fzy.d.mts +1 -0
  173. package/dist/relational-core.d.mts +12 -12
  174. package/dist/relational-core.mjs +2 -2
  175. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  176. package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
  177. package/dist/relational-core__ast.d.mts +3 -3
  178. package/dist/relational-core__ast.mjs +2 -2
  179. package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
  180. package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
  181. package/dist/relational-core__collection-methods.d.mts +2 -2
  182. package/dist/relational-core__contract-free.d.mts +3 -3
  183. package/dist/relational-core__contract-free.mjs +2 -2
  184. package/dist/relational-core__contract-free.mjs.map +1 -1
  185. package/dist/relational-core__expression.d.mts +3 -3
  186. package/dist/relational-core__functions.d.mts +1 -1
  187. package/dist/relational-core__index-reference.d.mts +2 -2
  188. package/dist/relational-core__middleware.d.mts +2 -2
  189. package/dist/relational-core__plan.d.mts +3 -3
  190. package/dist/relational-core__query-lane-context.d.mts +2 -2
  191. package/dist/relational-core__types.d.mts +2 -2
  192. package/dist/runtime.d.mts +5 -5
  193. package/dist/runtime.mjs +1 -2289
  194. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  195. package/dist/{schema-differ-CqWOkoW9-uVU2SdFf.d.mts → schema-differ-DmP74bB8-BGA6fzOv.d.mts} +4 -4
  196. package/dist/{schema-differ-CqWOkoW9-uVU2SdFf.d.mts.map → schema-differ-DmP74bB8-BGA6fzOv.d.mts.map} +1 -1
  197. package/dist/schema-ir.d.mts +2 -2
  198. package/dist/schema-ir.mjs +2 -2
  199. package/dist/schema-ir__naming.mjs +1 -1
  200. package/dist/schema-ir__types.d.mts +3 -3
  201. package/dist/schema-ir__types.mjs +2 -2
  202. package/dist/{schema-verify-DIfHSB4I-wt28gB9e.mjs → schema-verify-BwRdzbHb-B9vFrm3T.mjs} +22 -6
  203. package/dist/schema-verify-BwRdzbHb-B9vFrm3T.mjs.map +1 -0
  204. package/dist/{serialized-index-52COq1yV-D8zJP-Xl.mjs → serialized-index-52COq1yV-CUJ2F65u.mjs} +3 -3
  205. package/dist/{serialized-index-52COq1yV-D8zJP-Xl.mjs.map → serialized-index-52COq1yV-CUJ2F65u.mjs.map} +1 -1
  206. package/dist/{sql-contract-serializer-DDaAVCQr-Ba3XOCG6.mjs → sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs} +12 -7
  207. package/dist/sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs.map +1 -0
  208. package/dist/{data-type-DU0mtme5.mjs → sql-data-type-Dabuwxet-BljsNjBu.mjs} +32 -13
  209. package/dist/sql-data-type-Dabuwxet-BljsNjBu.mjs.map +1 -0
  210. package/dist/{sql-execution-plan-C7XauPPu-BgBp89vP.d.mts → sql-execution-plan-Dam5yMZg-Bc_eneSz.d.mts} +3 -3
  211. package/dist/sql-execution-plan-Dam5yMZg-Bc_eneSz.d.mts.map +1 -0
  212. package/dist/{sql-expression-BWrjmY6M.d.mts → sql-expression-BAtH-2UU.d.mts} +6 -6
  213. package/dist/sql-expression-BAtH-2UU.d.mts.map +1 -0
  214. package/dist/{sql-expression-DSRILiU2.mjs → sql-expression-BJCuy-WI.mjs} +15 -9
  215. package/dist/sql-expression-BJCuy-WI.mjs.map +1 -0
  216. package/dist/{storage-table-DN36E2yE-Bm5eKeGw.mjs → storage-table-DN36E2yE-0ncS821l.mjs} +2 -2
  217. package/dist/{storage-table-DN36E2yE-Bm5eKeGw.mjs.map → storage-table-DN36E2yE-0ncS821l.mjs.map} +1 -1
  218. package/dist/{transaction-state-DR3nKTmH-D5eFB250.d.mts → transaction-state-DR3nKTmH-n_12DsnU.d.mts} +9 -9
  219. package/dist/{transaction-state-DR3nKTmH-D5eFB250.d.mts.map → transaction-state-DR3nKTmH-n_12DsnU.d.mts.map} +1 -1
  220. package/dist/types-BLyhYk6B.d.mts +1 -0
  221. package/dist/{types-DvhckjSz-Cm0Oodhr.mjs → types-CaVn_xxe-D9WdU3Iy.mjs} +81 -157
  222. package/dist/types-CaVn_xxe-D9WdU3Iy.mjs.map +1 -0
  223. package/dist/{types-Cl4MLNrS-BXDsTb9U.d.mts → types-Cv5t6_Ly-CcBWTpfM.d.mts} +6 -6
  224. package/dist/{types-Cl4MLNrS-BXDsTb9U.d.mts.map → types-Cv5t6_Ly-CcBWTpfM.d.mts.map} +1 -1
  225. package/dist/{types-Sh5HuaZE-BwZNUDEi.d.mts → types-DVaVM20q-B-QcMIOa.d.mts} +9 -20
  226. package/dist/types-DVaVM20q-B-QcMIOa.d.mts.map +1 -0
  227. package/dist/{types-CzxOObSY-Cq3t_HCe.d.mts → types-DaYtBAYT-B22gkh5z.d.mts} +5 -5
  228. package/dist/{types-CzxOObSY-Cq3t_HCe.d.mts.map → types-DaYtBAYT-B22gkh5z.d.mts.map} +1 -1
  229. package/dist/{types-GS3fwvoX.mjs → types-M_FeBD9w.mjs} +2 -2
  230. package/dist/{types-GS3fwvoX.mjs.map → types-M_FeBD9w.mjs.map} +1 -1
  231. package/dist/types-_7TbRpPw.d.mts +1 -0
  232. package/dist/{types-C-z8HyiZ-1Nhw0pHj.d.mts → types-c1iIhJep-DdMj6TNl.d.mts} +49 -51
  233. package/dist/types-c1iIhJep-DdMj6TNl.d.mts.map +1 -0
  234. package/dist/{validators-DlpO67uZ.mjs → validators-Bvfk0aN7.mjs} +14 -11
  235. package/dist/validators-Bvfk0aN7.mjs.map +1 -0
  236. package/dist/{validators-R-Wsy5Rr.d.mts → validators-CTZ-hU2l.d.mts} +4 -1
  237. package/dist/validators-CTZ-hU2l.d.mts.map +1 -0
  238. package/package.json +18 -18
  239. package/dist/ast-BDwGvnKK.mjs.map +0 -1
  240. package/dist/ast-BoM9T1b2.d.mts.map +0 -1
  241. package/dist/attribute-specs-D7EhHD08.d.mts.map +0 -1
  242. package/dist/collection-methods-CyUXbXVw.d.mts +0 -1
  243. package/dist/control-CPg4LwJV.d.mts.map +0 -1
  244. package/dist/control-DXqMl_gd.mjs.map +0 -1
  245. package/dist/control-adapter-CkFfBVei-DGf1LihO.d.mts.map +0 -1
  246. package/dist/control-adapter-DDjgBMy3.d.mts +0 -1
  247. package/dist/data-type-CYsho6Yd.d.mts.map +0 -1
  248. package/dist/data-type-DU0mtme5.mjs.map +0 -1
  249. package/dist/data-type-support-4TcZuD7d.d.mts.map +0 -1
  250. package/dist/data-type-support-CfhpAKLX.mjs.map +0 -1
  251. package/dist/default-mapping-B8_APB1M-CWcTmSQW.d.mts.map +0 -1
  252. package/dist/derived-checks-Cgx_VgS3-CmFqNFgU.mjs.map +0 -1
  253. package/dist/diff-B16bL_IR.mjs +0 -13
  254. package/dist/diff-B16bL_IR.mjs.map +0 -1
  255. package/dist/diff-CVVGktZG.d.mts.map +0 -1
  256. package/dist/expression-CNBCbbzU-DOXKUxQs.d.mts.map +0 -1
  257. package/dist/expression-DUYovBa6.d.mts +0 -2
  258. package/dist/index-reference-DGQdSRjQ.d.mts +0 -1
  259. package/dist/interpreter-CvmBTYyI-DNl-jr2E.mjs.map +0 -1
  260. package/dist/ir-D0Vpm5O9.d.mts.map +0 -1
  261. package/dist/middleware-Bp-R5o9E.d.mts +0 -1
  262. package/dist/numeral-text-Cqu87pVe-DJCqBaSC.mjs.map +0 -1
  263. package/dist/opaque-sql-BWxbqe5a-GGKfyakq.mjs.map +0 -1
  264. package/dist/plan-DdpaNNu1.d.mts +0 -2
  265. package/dist/plan-cGEaSXHv-yuz43WrR.d.mts.map +0 -1
  266. package/dist/psl-build-8bx9WTUt.mjs.map +0 -1
  267. package/dist/psl-field-resolution-SPNDr-jr-CH_gs3Oy.mjs.map +0 -1
  268. package/dist/query-lane-context-C4xq68Mr.d.mts +0 -1
  269. package/dist/runtime.mjs.map +0 -1
  270. package/dist/schema-verify-DIfHSB4I-wt28gB9e.mjs.map +0 -1
  271. package/dist/sql-contract-serializer-DDaAVCQr-Ba3XOCG6.mjs.map +0 -1
  272. package/dist/sql-execution-plan-C7XauPPu-BgBp89vP.d.mts.map +0 -1
  273. package/dist/sql-expression-BWrjmY6M.d.mts.map +0 -1
  274. package/dist/sql-expression-DSRILiU2.mjs.map +0 -1
  275. package/dist/types-BSBsW0qR.d.mts +0 -1
  276. package/dist/types-C-z8HyiZ-1Nhw0pHj.d.mts.map +0 -1
  277. package/dist/types-CJK7FBdw.d.mts +0 -1
  278. package/dist/types-DvhckjSz-Cm0Oodhr.mjs.map +0 -1
  279. package/dist/types-Sh5HuaZE-BwZNUDEi.d.mts.map +0 -1
  280. package/dist/validators-DlpO67uZ.mjs.map +0 -1
  281. package/dist/validators-R-Wsy5Rr.d.mts.map +0 -1
@@ -2,19 +2,22 @@ import { t as resolveStorageTable } from "./resolve-storage-table-DZsfnzeW.mjs";
2
2
  import { i as isUniqueConstraintViolation } from "./dist-x6jvtkKM.mjs";
3
3
  import { A as ParamRef, C as LiteralExpr, E as NullCheckExpr, F as SelectAst, G as isOrderByNulls, I as SubqueryExpr, L as TableSource, M as ProjectionItem, O as OrExpr, R as UpdateAst, S as ListExpression, T as NotExpr, U as isAggregateFn, V as checkLimitOffset, W as isOrderByDirection, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, k as OrderByItem, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, q as isWhereExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as LockingClause, x as JsonObjectExpr, y as JoinAst, z as WindowFuncExpr } from "./types-NTQsD2MS-DAP2yVDn.mjs";
4
4
  import { t as collectOrderedParamRefs } from "./util-BBgcP3gI-XJBkxo1K.mjs";
5
- import { C as lockStrengthCapabilities, S as lockOptionCapabilities, T as missingCapability, n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection, w as lockWaitPolicyOf, x as lockIncompatible } from "./ast-BDwGvnKK.mjs";
5
+ import { C as lockStrengthCapabilities, S as lockOptionCapabilities, T as missingCapability, n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection, w as lockWaitPolicyOf, x as lockIncompatible } from "./ast-CBO3PEJF.mjs";
6
6
  import { a as isExpression, s as toExpr, t as ExpressionImpl } from "./expression-impl-B-XNINxr-vYwKVFeP.mjs";
7
- import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-Bg9OjQf_.mjs";
7
+ import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-4kw8FPpo.mjs";
8
8
  import { t as createFunctions } from "./functions-0YWByawj.mjs";
9
9
  import { t as createIndexReferences } from "./index-reference-DR62gjQS.mjs";
10
10
  import { o as settlementOf } from "./transaction-state-BfXhs7D7-3k10jZ8I.mjs";
11
+ import { p as findActivitySource } from "./exports-DVsHk8HP-DrH_2a-H.mjs";
11
12
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
12
13
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
13
14
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
14
15
  import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
15
16
  import { domainModelsAtDefaultNamespace } from "@prisma/orm-framework/contract/types";
17
+ import { canonicalStringify } from "@prisma/orm-framework/utils/canonical-stringify";
16
18
  import { AsyncIterableResult, createMetaBuilder, isRuntimeError, runtimeError } from "@prisma/orm-framework/components/runtime";
17
19
  import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
20
+ import { hashContent } from "@prisma/orm-framework/utils/hash-content";
18
21
  //#region ../../../3-extensions/sql-orm-client/dist/index.mjs
19
22
  const operationNamesByRegistry = /* @__PURE__ */ new WeakMap();
20
23
  /**
@@ -626,7 +629,7 @@ function resolveAggregate(query) {
626
629
  if (resolved === void 0) throw unsupportedAggregate(query, input);
627
630
  const nullability = resolved.nullable ? { nullable: true } : {
628
631
  nullable: false,
629
- emptyResultJson: resolved.emptyResultJson
632
+ emptyResultWire: resolved.emptyResultWire
630
633
  };
631
634
  return {
632
635
  codec: resolved.output,
@@ -669,13 +672,12 @@ function inputCodecRef(query) {
669
672
  * count's zero cardinality — so this covers only the degenerate case of a
670
673
  * result set with no row: an absent aggregate alias, or an include whose
671
674
  * envelope never arrived. The answer reads off the operation's declared row:
672
- * NULL where the row is nullable, else the value the row declares, decoded
673
- * through the codec it declared beside it — so the application sees the same
674
- * value shape a real row would produce, in whichever form that codec's
675
- * canonical JSON takes.
675
+ * NULL where the row is nullable, else the wire value the row declares, read
676
+ * with the declared codec's `fromWire` — so the application sees the same value
677
+ * shape a real row would produce.
676
678
  */
677
- function emptyAggregateResult(result, codec) {
678
- return result.nullable ? null : codec.decodeJson(result.emptyResultJson);
679
+ async function emptyAggregateResult(result, codec) {
680
+ return result.nullable ? null : codec.fromWire(result.emptyResultWire, {});
679
681
  }
680
682
  /** The columns of a model's own and inherited fields, for operations that apply each column to the model's table: `groupBy`, `distinct` and `distinctOn`. */
681
683
  function mapFieldsToColumns(contract, namespaceId, modelName, fieldNames) {
@@ -955,54 +957,20 @@ function checkedOrderByItem(dir, expr, options) {
955
957
  function deriveParamsFromAst(ast) {
956
958
  return { params: collectOrderedParamRefs(ast).map((p) => p.kind === "param-ref" ? p.value : void 0) };
957
959
  }
958
- function buildOrmPlanMeta(contract, annotations) {
959
- const annotationRecord = annotations !== void 0 && annotations.size > 0 ? Object.freeze(Object.fromEntries(annotations)) : void 0;
960
+ function buildOrmPlanMeta(contract) {
960
961
  return {
961
962
  target: contract.target,
962
963
  targetFamily: contract.targetFamily,
963
964
  storageHash: contract.storage.storageHash,
964
965
  ...ifDefined("profileHash", contract.profileHash),
965
- ...ifDefined("annotations", annotationRecord),
966
966
  lane: "orm-client"
967
967
  };
968
968
  }
969
- function buildOrmQueryPlan(contract, ast, params, annotations) {
969
+ function buildOrmQueryPlan(contract, ast, params) {
970
970
  return Object.freeze({
971
971
  ast,
972
972
  params: [...params],
973
- meta: buildOrmPlanMeta(contract, annotations)
974
- });
975
- }
976
- /**
977
- * Merges annotations into an existing `SqlQueryPlan`'s
978
- * `meta.annotations` and returns a new frozen plan.
979
- *
980
- * Used by the ORM dispatch path to attach terminal-call annotations to
981
- * plans produced by mutation compile functions (which don't take
982
- * annotations as parameters). Reads compile through `compileSelect`-
983
- * family functions that pass `state.annotations` directly to
984
- * `buildOrmQueryPlan`; this helper is the alternate path for write
985
- * terminals where annotations arrive at the call site, not via state.
986
- *
987
- * Returns the input plan unchanged when `annotations` is undefined
988
- * or empty. Reserved namespaces already on the input plan (`codecs`, target keys such as `pg`)
989
- * win over caller-supplied entries under the same key —
990
- * see the reserved-namespace policy on `defineAnnotation`.
991
- */
992
- function mergeAnnotations(plan, annotations) {
993
- if (annotations === void 0 || annotations.size === 0) return plan;
994
- const callerEntries = {};
995
- for (const [namespace, value] of annotations) callerEntries[namespace] = value;
996
- const mergedAnnotations = Object.freeze({
997
- ...callerEntries,
998
- ...plan.meta.annotations ?? {}
999
- });
1000
- return Object.freeze({
1001
- ...plan,
1002
- meta: Object.freeze({
1003
- ...plan.meta,
1004
- annotations: mergedAnnotations
1005
- })
973
+ meta: buildOrmPlanMeta(contract)
1006
974
  });
1007
975
  }
1008
976
  function bindWhereExpr(contract, expr, aliases) {
@@ -1350,8 +1318,7 @@ function emptyState(tables) {
1350
1318
  limit: void 0,
1351
1319
  offset: void 0,
1352
1320
  variantValue: void 0,
1353
- locking: void 0,
1354
- annotations: /* @__PURE__ */ new Map()
1321
+ locking: void 0
1355
1322
  };
1356
1323
  }
1357
1324
  function emptyGroupPagingState() {
@@ -2371,7 +2338,7 @@ function collectionSelectAst(contract, modelName, state) {
2371
2338
  function compileSelect(contract, modelName, state) {
2372
2339
  const ast = collectionSelectAst(contract, modelName, state);
2373
2340
  const { params } = deriveParamsFromAst(ast);
2374
- return buildOrmQueryPlan(contract, ast, params, state.annotations);
2341
+ return buildOrmQueryPlan(contract, ast, params);
2375
2342
  }
2376
2343
  function collectionSelectWithIncludesAst(contract, aggregates, modelName, state) {
2377
2344
  assertLockCompatible(state);
@@ -2396,7 +2363,7 @@ function collectionSelectWithIncludesAst(contract, aggregates, modelName, state)
2396
2363
  function compileSelectWithIncludes(contract, aggregates, modelName, state) {
2397
2364
  const ast = collectionSelectWithIncludesAst(contract, aggregates, modelName, state);
2398
2365
  const { params } = deriveParamsFromAst(ast);
2399
- return buildOrmQueryPlan(contract, ast, params, state.annotations);
2366
+ return buildOrmQueryPlan(contract, ast, params);
2400
2367
  }
2401
2368
  function queryPlanRows(scope, plan) {
2402
2369
  return scope.query(plan);
@@ -2450,7 +2417,7 @@ function createPreparedRowsConsumer(options) {
2450
2417
  raw,
2451
2418
  mapped: mapRow(raw)
2452
2419
  }));
2453
- for (const parent of parents) for (const include of includes) parent.mapped[include.alias] = include.consume(parent.raw[include.alias]);
2420
+ for (const parent of parents) for (const include of includes) parent.mapped[include.alias] = await include.consume(parent.raw[include.alias]);
2454
2421
  for (const parent of parents) yield castRow(parent.mapped);
2455
2422
  })());
2456
2423
  }
@@ -2473,10 +2440,10 @@ function createPreparedIncludeConsumer(context, include) {
2473
2440
  }));
2474
2441
  return {
2475
2442
  alias,
2476
- consume: (raw) => {
2443
+ consume: async (raw) => {
2477
2444
  const parsed = parseCombineEnvelope(include, raw);
2478
2445
  const result = {};
2479
- for (const branch of branches) result[branch.name] = branch.consume(parsed[branch.name]);
2446
+ for (const branch of branches) result[branch.name] = await branch.consume(parsed[branch.name]);
2480
2447
  return result;
2481
2448
  }
2482
2449
  };
@@ -2498,16 +2465,17 @@ function createPreparedIncludeConsumer(context, include) {
2498
2465
  const fused = deferResolution(() => createPreparedIncludedRowDecoder(contract, include, bindingFor));
2499
2466
  return {
2500
2467
  alias,
2501
- consume: (raw) => {
2468
+ consume: async (raw) => {
2502
2469
  const rows = parseIncludedRows(include, raw);
2503
2470
  if (rows.length === 0) return toOne ? null : [];
2504
2471
  const decoder = fused();
2505
2472
  if (!decoder || !rows.every(decoder.matches)) return consumeRowInclude(rows, mapRow, bindingFor, nested, toOne);
2506
- const mapped = rows.map((row) => {
2507
- const result = decoder.decode(row);
2508
- for (const child of nested) result[child.alias] = child.consume(row[child.alias]);
2509
- return result;
2510
- });
2473
+ const mapped = [];
2474
+ for (const row of rows) {
2475
+ const result = await decoder.decode(row);
2476
+ for (const child of nested) result[child.alias] = await child.consume(row[child.alias]);
2477
+ mapped.push(result);
2478
+ }
2511
2479
  return toOne ? mapped[0] ?? null : mapped;
2512
2480
  }
2513
2481
  };
@@ -2529,10 +2497,10 @@ function createPreparedIncludedRowDecoder(contract, include, bindingFor) {
2529
2497
  return {
2530
2498
  key,
2531
2499
  field: fieldOf(key),
2532
- decode(value) {
2500
+ async decode(value) {
2533
2501
  if (value === null || value === void 0) return value;
2534
2502
  const resolved = binding();
2535
- return resolved ? decodeIncludedColumnValue(resolved.ref, resolved.codecId, resolved.codec, value) : value;
2503
+ return resolved ? decodeIncludedColumnValue(resolved, value) : value;
2536
2504
  }
2537
2505
  };
2538
2506
  });
@@ -2541,9 +2509,9 @@ function createPreparedIncludedRowDecoder(contract, include, bindingFor) {
2541
2509
  const actual = Object.keys(row);
2542
2510
  return actual.length === keys.length && actual.every((key, index) => key === keys[index]);
2543
2511
  },
2544
- decode(row) {
2512
+ async decode(row) {
2545
2513
  const result = {};
2546
- for (const operation of operations) result[operation.field] = operation.decode(row[operation.key]);
2514
+ for (const operation of operations) result[operation.field] = await operation.decode(row[operation.key]);
2547
2515
  return result;
2548
2516
  }
2549
2517
  };
@@ -2572,24 +2540,37 @@ function describeCollectionFirstOrThrow(options) {
2572
2540
  consume: (source) => rows.consume(source).firstOrThrow()
2573
2541
  };
2574
2542
  }
2575
- function dispatchCollectionRows(options) {
2576
- const { context, runtime, state, modelName, namespaceId } = options;
2577
- const descriptionOptions = {
2578
- context,
2579
- state,
2580
- modelName,
2581
- namespaceId
2582
- };
2543
+ function describeCollectionQuery(options) {
2544
+ const { context, state, modelName, namespaceId } = options;
2583
2545
  if (state.includes.length === 0) {
2584
- const query = describeExecutionRows(descriptionOptions);
2585
- return query.consume(queryPlanRows(runtime, query.plan));
2546
+ const query = describeExecutionRows(options);
2547
+ return {
2548
+ plan: () => query.plan,
2549
+ rows: (scope) => runQuery(scope, query)
2550
+ };
2586
2551
  }
2587
2552
  resolvePolymorphismInfo(context.contract, namespaceId, modelName);
2588
- const generator = async function* () {
2589
- const query = describeExecutionRows(descriptionOptions);
2590
- yield* query.consume(queryPlanRows(runtime, query.plan));
2553
+ let compiled;
2554
+ const query = () => {
2555
+ compiled ??= describeExecutionRows(options);
2556
+ return compiled;
2591
2557
  };
2592
- return new AsyncIterableResult(generator());
2558
+ return {
2559
+ plan: () => query().plan,
2560
+ rows: (scope) => {
2561
+ const generator = async function* () {
2562
+ yield* runQuery(scope, query());
2563
+ };
2564
+ return new AsyncIterableResult(generator());
2565
+ }
2566
+ };
2567
+ }
2568
+ function runQuery(scope, query) {
2569
+ return query.consume(queryPlanRows(scope, query.plan));
2570
+ }
2571
+ function dispatchCollectionRows(options) {
2572
+ const { runtime, ...descriptionOptions } = options;
2573
+ return describeCollectionQuery(descriptionOptions).rows(runtime);
2593
2574
  }
2594
2575
  function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
2595
2576
  const { contract } = context;
@@ -2604,7 +2585,7 @@ function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
2604
2585
  };
2605
2586
  });
2606
2587
  const bindings = /* @__PURE__ */ new WeakMap();
2607
- for (const parent of parentRows) for (const include of state.includes) parent.mapped[include.relationName] = decodeIncludePayload(contract, context, include, parent.raw[include.relationName], bindings);
2588
+ for (const parent of parentRows) for (const include of state.includes) parent.mapped[include.relationName] = await decodeIncludePayload(contract, context, include, parent.raw[include.relationName], bindings);
2608
2589
  for (const row of parentRows) yield blindCast(row.mapped);
2609
2590
  };
2610
2591
  return new AsyncIterableResult(generator());
@@ -2648,7 +2629,7 @@ function consumeIncludeRows(context, state, namespaceId, modelName, rows) {
2648
2629
  * each branch is dispatched to the row or scalar decoder per its
2649
2630
  * declared shape (see `decodeCombineIncludePayload`).
2650
2631
  */
2651
- function decodeIncludePayload(contract, context, include, raw, bindings) {
2632
+ async function decodeIncludePayload(contract, context, include, raw, bindings) {
2652
2633
  if (include.scalar) return decodeScalarIncludePayload(contract, context, include, include.scalar, raw);
2653
2634
  if (include.combine) return decodeCombineIncludePayload(contract, context, include, include.combine, raw, bindings);
2654
2635
  const rawChildren = parseIncludedRows(include, raw);
@@ -2672,17 +2653,17 @@ function decodeIncludePayload(contract, context, include, raw, bindings) {
2672
2653
  consume: (value) => decodeIncludePayload(contract, context, nested, value, bindings)
2673
2654
  })), isToOneCardinality(include.cardinality));
2674
2655
  }
2675
- function consumeRowInclude(rawChildren, mapChildRow, bindingFor, nested, toOne) {
2656
+ async function consumeRowInclude(rawChildren, mapChildRow, bindingFor, nested, toOne) {
2676
2657
  const mappedChildren = [];
2677
2658
  for (const childRow of rawChildren) {
2678
- const decodedChildRow = decodeIncludedStorageRow(childRow, bindingFor);
2659
+ const decodedChildRow = await decodeIncludedStorageRow(childRow, bindingFor);
2679
2660
  const mapped = mapChildRow(decodedChildRow);
2680
- for (const child of nested) mapped[child.alias] = child.consume(decodedChildRow[child.alias]);
2661
+ for (const child of nested) mapped[child.alias] = await child.consume(decodedChildRow[child.alias]);
2681
2662
  mappedChildren.push(mapped);
2682
2663
  }
2683
2664
  return toOne ? mappedChildren[0] ?? null : mappedChildren;
2684
2665
  }
2685
- function decodeIncludedStorageRow(row, bindingFor) {
2666
+ async function decodeIncludedStorageRow(row, bindingFor) {
2686
2667
  const decoded = {};
2687
2668
  for (const [key, value] of Object.entries(row)) {
2688
2669
  if (value === null || value === void 0) {
@@ -2690,7 +2671,7 @@ function decodeIncludedStorageRow(row, bindingFor) {
2690
2671
  continue;
2691
2672
  }
2692
2673
  const binding = bindingFor(key);
2693
- decoded[key] = binding ? decodeIncludedColumnValue(binding.ref, binding.codecId, binding.codec, value) : value;
2674
+ decoded[key] = binding ? await decodeIncludedColumnValue(binding, value) : value;
2694
2675
  }
2695
2676
  return decoded;
2696
2677
  }
@@ -2702,7 +2683,11 @@ function resolveIncludedColumnBinding(contract, context, include, key) {
2702
2683
  return {
2703
2684
  ref,
2704
2685
  codec,
2705
- codecId: context.codecDescriptors.codecRefForColumn(ref.namespaceId, ref.table, ref.column)?.codecId ?? ref.storageColumn.codecId
2686
+ codecId: context.codecDescriptors.codecRefForColumn(ref.namespaceId, ref.table, ref.column)?.codecId ?? ref.storageColumn.codecId,
2687
+ ctx: { column: {
2688
+ table: ref.table,
2689
+ name: ref.column
2690
+ } }
2706
2691
  };
2707
2692
  }
2708
2693
  function resolveIncludedColumnRef(contract, include, key) {
@@ -2730,7 +2715,8 @@ function resolveIncludedColumnRef(contract, include, key) {
2730
2715
  };
2731
2716
  }
2732
2717
  }
2733
- function decodeIncludedColumnValue(ref, codecId, codec, value) {
2718
+ async function decodeIncludedColumnValue(binding, value) {
2719
+ const { ref, codecId } = binding;
2734
2720
  if (ref.storageColumn.many !== false) {
2735
2721
  if (!Array.isArray(value)) wrapIncludedDecodeFailure(/* @__PURE__ */ new TypeError(`expected an array from the driver for many-typed column, got ${typeof value}`), ref, codecId);
2736
2722
  const decoded = [];
@@ -2739,16 +2725,19 @@ function decodeIncludedColumnValue(ref, codecId, codec, value) {
2739
2725
  decoded.push(null);
2740
2726
  continue;
2741
2727
  }
2742
- decoded.push(decodeIncludedJsonValue(ref, codecId, codec, element));
2728
+ decoded.push(await decodeIncludedJsonValue(binding, element));
2743
2729
  }
2744
2730
  return decoded;
2745
2731
  }
2746
- return decodeIncludedJsonValue(ref, codecId, codec, value);
2732
+ return decodeIncludedJsonValue(binding, value);
2747
2733
  }
2748
- /** `ref` names the value for a decode failure; an aggregate names its relation where a column would name itself. */
2749
- function decodeIncludedJsonValue(ref, codecId, codec, value) {
2734
+ /**
2735
+ * Reads a value the database put into JSON with its codec's `fromWire`, with the call context an ordinary row's cell gets. `ref` names the value for a decode failure; an aggregate names its relation where a column would name itself.
2736
+ */
2737
+ async function decodeIncludedJsonValue(binding, value) {
2738
+ const { ref, codecId, codec, ctx } = binding;
2750
2739
  try {
2751
- return codec.decodeJson(blindCast(value));
2740
+ return await codec.fromWire(value, ctx);
2752
2741
  } catch (error) {
2753
2742
  if (isRuntimeError(error)) throw error;
2754
2743
  wrapIncludedDecodeFailure(error, ref, codecId);
@@ -2785,18 +2774,18 @@ function wrapIncludedDecodeFailure(error, ref, codecId) {
2785
2774
  * bug — `parseCombineEnvelope` throws loudly rather than papering over
2786
2775
  * it with an empty shape.
2787
2776
  */
2788
- function decodeCombineIncludePayload(contract, context, include, branches, raw, bindings) {
2777
+ async function decodeCombineIncludePayload(contract, context, include, branches, raw, bindings) {
2789
2778
  const parsed = parseCombineEnvelope(include, raw);
2790
2779
  const result = {};
2791
2780
  for (const [branchName, branch] of Object.entries(branches)) {
2792
2781
  const branchRaw = parsed[branchName];
2793
- if (branch.kind === "rows") result[branchName] = decodeIncludePayload(contract, context, {
2782
+ if (branch.kind === "rows") result[branchName] = await decodeIncludePayload(contract, context, {
2794
2783
  ...include,
2795
2784
  nested: branch.state,
2796
2785
  scalar: void 0,
2797
2786
  combine: void 0
2798
2787
  }, branchRaw, bindings);
2799
- else result[branchName] = decodeScalarIncludePayload(contract, context, include, branch.selector, branchRaw);
2788
+ else result[branchName] = await decodeScalarIncludePayload(contract, context, include, branch.selector, branchRaw);
2800
2789
  }
2801
2790
  return result;
2802
2791
  }
@@ -2855,16 +2844,21 @@ function resolveScalarIncludeMetadata(contract, context, include, scalar) {
2855
2844
  codec: context.contractCodecs.forCodecRef(resolved.codec)
2856
2845
  };
2857
2846
  }
2858
- function consumeScalarInclude(include, resolved, codec, raw) {
2847
+ async function consumeScalarInclude(include, resolved, codec, raw) {
2859
2848
  if (raw === null || raw === void 0) return emptyAggregateResult(resolved, codec);
2860
2849
  const parsed = parseIncludePayload(raw);
2861
2850
  if (!isPlainObjectEnvelope(parsed)) throw new InternalError(`scalar() envelope for include "${include.relationName}" has unexpected shape (expected object, got ${describeEnvelopeShape(parsed)}); this indicates a planner or decoder bug.`);
2862
2851
  const value = parsed["value"];
2863
2852
  if (value === null || value === void 0) return emptyAggregateResult(resolved, codec);
2864
2853
  return decodeIncludedJsonValue({
2865
- table: include.relatedTableName,
2866
- column: include.relationName
2867
- }, resolved.codec.codecId, codec, value);
2854
+ ref: {
2855
+ table: include.relatedTableName,
2856
+ column: include.relationName
2857
+ },
2858
+ codecId: resolved.codec.codecId,
2859
+ codec,
2860
+ ctx: {}
2861
+ }, value);
2868
2862
  }
2869
2863
  function parseIncludedRows(include, value) {
2870
2864
  if (value === null || value === void 0) return [];
@@ -3792,6 +3786,313 @@ function buildJoinWhere(contract, parentNamespaceId, parentModelName, parentTabl
3792
3786
  if (joinExprs.length === 1 && firstExpr !== void 0) return firstExpr;
3793
3787
  return and(...joinExprs);
3794
3788
  }
3789
+ /** The hash input of a read is the content hash of the plan it sends first. */
3790
+ function planHashInput(plan) {
3791
+ return (source) => source.planContentHash(plan());
3792
+ }
3793
+ /** The hash input of a prepared read is the content hash of the statement with the parameters this execution binds. */
3794
+ function preparedHashInput(statement, params) {
3795
+ return (source) => source.planContentHash({
3796
+ statement,
3797
+ params
3798
+ });
3799
+ }
3800
+ /** A write's statements depend on earlier results, so its hash input is the model it writes. */
3801
+ function modelHashInput(namespaceId, modelName) {
3802
+ return async () => ({
3803
+ namespace: namespaceId,
3804
+ model: modelName
3805
+ });
3806
+ }
3807
+ function isRecord(value) {
3808
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3809
+ }
3810
+ const ormResults = {
3811
+ rows: (value) => Array.isArray(value),
3812
+ row: (value) => isRecord(value),
3813
+ rowOrNull: (value) => value === null || isRecord(value),
3814
+ count: (value) => typeof value === "number"
3815
+ };
3816
+ async function ormCallContentHash(source, call) {
3817
+ return hashContent(canonicalStringify({
3818
+ kind: "orm-call",
3819
+ method: call.method,
3820
+ hashInput: await call.hashInput(source)
3821
+ }));
3822
+ }
3823
+ /** Starts the call in the same turn as the terminal method, so a runtime closed after the method returns waits for it. The content hash is computed only when a middleware asks for it. */
3824
+ function startOrmCall(source, call) {
3825
+ return source.startActivity({
3826
+ kind: "orm-call",
3827
+ contentHash: () => ormCallContentHash(source, call),
3828
+ ...call.annotations === void 0 ? {} : { annotations: call.annotations }
3829
+ });
3830
+ }
3831
+ /** Ends a call whose work failed. The runtime has ended the activity `failed` even when `end` rejects, so the caller gets the error that failed the call; the error from `end`, such as one an `activityEnded` hook threw, becomes its `cause` when it has none. */
3832
+ async function endFailed(handle, failure) {
3833
+ try {
3834
+ await handle.end({ outcome: "failed" });
3835
+ } catch (endError) {
3836
+ if (failure instanceof Error && failure.cause === void 0) failure.cause = endError;
3837
+ }
3838
+ }
3839
+ async function interceptedResult(handle, call, intercepted) {
3840
+ const { result } = intercepted;
3841
+ if (!call.accepts(result)) {
3842
+ const invalid = ormError("ORM.INTERCEPTED_RESULT_INVALID", `A middleware answered ${call.method}() with a value that is not a result of ${call.method}()`, { meta: { method: call.method } });
3843
+ await endFailed(handle, invalid);
3844
+ throw invalid;
3845
+ }
3846
+ await handle.end({ outcome: "succeeded" });
3847
+ return result;
3848
+ }
3849
+ function activitySourceOf(queryable, method) {
3850
+ const source = findActivitySource(queryable);
3851
+ if (source === void 0) throw ormError("ORM.ACTIVITY_SOURCE_MISSING", `${method}() runs as an orm-call activity, and the queryable it was given has no activity source`, {
3852
+ fix: "Pass the ORM a runtime, connection or transaction from the SQL runtime, or a wrapper that keeps its [activitySource] member.",
3853
+ meta: { method }
3854
+ });
3855
+ return source;
3856
+ }
3857
+ async function runOrmCall(queryable, call, run) {
3858
+ const handle = await startOrmCall(activitySourceOf(queryable, call.method), call);
3859
+ if (handle.intercepted !== void 0) return interceptedResult(handle, call, handle.intercepted);
3860
+ let result;
3861
+ try {
3862
+ result = await run(handle);
3863
+ } catch (error) {
3864
+ await endFailed(handle, error);
3865
+ throw error;
3866
+ }
3867
+ await handle.end({
3868
+ outcome: "succeeded",
3869
+ result
3870
+ });
3871
+ return result;
3872
+ }
3873
+ /** The call ends when the caller reads to the end, stops early or the stream fails. Its result holds the rows only when it carries annotations, so an unannotated stream does not hold its rows. */
3874
+ function streamOrmCall(queryable, call, run) {
3875
+ return new AsyncIterableResult(new OrmCallRows(activitySourceOf(queryable, call.method), call, run));
3876
+ }
3877
+ const done = {
3878
+ done: true,
3879
+ value: void 0
3880
+ };
3881
+ /**
3882
+ * The rows of a streaming call. The call starts on the first `next()`. Like an async generator, it runs one `next()`, `return()` or `throw()` at a time and queues the calls that overlap it; unlike one, it forwards each row from the statement's iterator with a single promise.
3883
+ */
3884
+ var OrmCallRows = class {
3885
+ #source;
3886
+ #call;
3887
+ #run;
3888
+ #state = "idle";
3889
+ #handle;
3890
+ #inner;
3891
+ #intercepted;
3892
+ #collected;
3893
+ #busy = false;
3894
+ #waiting = [];
3895
+ constructor(source, call, run) {
3896
+ this.#source = source;
3897
+ this.#call = call;
3898
+ this.#run = run;
3899
+ }
3900
+ next() {
3901
+ return this.#enqueue(() => this.#next());
3902
+ }
3903
+ return() {
3904
+ return this.#enqueue(() => this.#return());
3905
+ }
3906
+ throw(error) {
3907
+ return this.#enqueue(() => this.#throw(error));
3908
+ }
3909
+ [Symbol.asyncIterator]() {
3910
+ return this;
3911
+ }
3912
+ async [Symbol.asyncDispose]() {
3913
+ await this.return();
3914
+ }
3915
+ #enqueue(operation) {
3916
+ if (!this.#busy) {
3917
+ this.#busy = true;
3918
+ return operation();
3919
+ }
3920
+ return new Promise((resolve, reject) => {
3921
+ this.#waiting.push(() => {
3922
+ operation().then(resolve, reject);
3923
+ });
3924
+ });
3925
+ }
3926
+ #release() {
3927
+ const waiting = this.#waiting.shift();
3928
+ if (waiting === void 0) this.#busy = false;
3929
+ else waiting();
3930
+ }
3931
+ #next() {
3932
+ switch (this.#state) {
3933
+ case "idle": return this.#start().then(() => this.#next(), (error) => {
3934
+ this.#release();
3935
+ throw error;
3936
+ });
3937
+ case "running": return this.#nextRow();
3938
+ case "intercepted": {
3939
+ const row = this.#intercepted?.next();
3940
+ this.#release();
3941
+ if (row === void 0 || row.done === true) {
3942
+ this.#state = "finished";
3943
+ return Promise.resolve(done);
3944
+ }
3945
+ return Promise.resolve({
3946
+ done: false,
3947
+ value: row.value
3948
+ });
3949
+ }
3950
+ default:
3951
+ this.#release();
3952
+ return Promise.resolve(done);
3953
+ }
3954
+ }
3955
+ async #return() {
3956
+ try {
3957
+ const handle = this.#handle;
3958
+ if (this.#state !== "running" || handle === void 0) {
3959
+ this.#state = "finished";
3960
+ return done;
3961
+ }
3962
+ this.#state = "finished";
3963
+ try {
3964
+ await this.#inner?.return?.();
3965
+ } catch (error) {
3966
+ await endFailed(handle, error);
3967
+ throw error;
3968
+ }
3969
+ await handle.end({ outcome: "stopped" });
3970
+ return done;
3971
+ } finally {
3972
+ this.#release();
3973
+ }
3974
+ }
3975
+ async #throw(error) {
3976
+ try {
3977
+ const handle = this.#handle;
3978
+ if (this.#state !== "running" || handle === void 0) {
3979
+ this.#state = "finished";
3980
+ throw error;
3981
+ }
3982
+ this.#state = "finished";
3983
+ try {
3984
+ await this.#inner?.return?.();
3985
+ } catch {}
3986
+ await endFailed(handle, error);
3987
+ throw error;
3988
+ } finally {
3989
+ this.#release();
3990
+ }
3991
+ }
3992
+ async #start() {
3993
+ let handle;
3994
+ try {
3995
+ handle = await startOrmCall(this.#source, this.#call);
3996
+ } catch (error) {
3997
+ this.#state = "finished";
3998
+ throw error;
3999
+ }
4000
+ this.#handle = handle;
4001
+ if (handle.intercepted !== void 0) {
4002
+ try {
4003
+ const rows = await interceptedResult(handle, this.#call, handle.intercepted);
4004
+ this.#intercepted = rows[Symbol.iterator]();
4005
+ } catch (error) {
4006
+ this.#state = "finished";
4007
+ throw error;
4008
+ }
4009
+ this.#state = "intercepted";
4010
+ return;
4011
+ }
4012
+ const annotations = this.#call.annotations;
4013
+ this.#collected = annotations !== void 0 && annotations.size > 0 ? [] : void 0;
4014
+ try {
4015
+ this.#inner = this.#run(handle)[Symbol.asyncIterator]();
4016
+ } catch (error) {
4017
+ this.#state = "finished";
4018
+ await endFailed(handle, error);
4019
+ throw error;
4020
+ }
4021
+ this.#state = "running";
4022
+ }
4023
+ #nextRow() {
4024
+ const inner = this.#inner;
4025
+ const handle = this.#handle;
4026
+ if (inner === void 0 || handle === void 0) {
4027
+ this.#release();
4028
+ return Promise.resolve(done);
4029
+ }
4030
+ let pending;
4031
+ try {
4032
+ pending = inner.next();
4033
+ } catch (error) {
4034
+ return this.#fail(handle, error);
4035
+ }
4036
+ return pending.then((result) => {
4037
+ if (result.done !== true) {
4038
+ this.#collected?.push(result.value);
4039
+ this.#release();
4040
+ return result;
4041
+ }
4042
+ this.#state = "finished";
4043
+ const collected = this.#collected;
4044
+ return handle.end(collected === void 0 ? { outcome: "succeeded" } : {
4045
+ outcome: "succeeded",
4046
+ result: collected
4047
+ }).then(() => {
4048
+ this.#release();
4049
+ return done;
4050
+ }, (endError) => {
4051
+ this.#release();
4052
+ throw endError;
4053
+ });
4054
+ }, (error) => this.#fail(handle, error));
4055
+ }
4056
+ async #fail(handle, error) {
4057
+ try {
4058
+ this.#state = "finished";
4059
+ await endFailed(handle, error);
4060
+ throw error;
4061
+ } finally {
4062
+ this.#release();
4063
+ }
4064
+ }
4065
+ };
4066
+ const preparedOrmCall = Symbol("preparedOrmCall");
4067
+ function asPreparedOrmCall(preparable, call) {
4068
+ return {
4069
+ ...preparable,
4070
+ [preparedOrmCall]: call
4071
+ };
4072
+ }
4073
+ function isPreparableOrmCall(preparable) {
4074
+ return preparedOrmCall in preparable;
4075
+ }
4076
+ function preparedOrmCallOf(preparable) {
4077
+ return isPreparableOrmCall(preparable) ? preparable[preparedOrmCall] : void 0;
4078
+ }
4079
+ function preparedRowsCall(method, annotations, consume) {
4080
+ return (target, rows, hashInput) => streamOrmCall(target, {
4081
+ method,
4082
+ annotations,
4083
+ hashInput,
4084
+ accepts: ormResults.rows
4085
+ }, (queryable) => consume(rows(queryable)));
4086
+ }
4087
+ function preparedValueCall(method, annotations, consume, accepts) {
4088
+ return (target, rows, hashInput) => runOrmCall(target, {
4089
+ method,
4090
+ annotations,
4091
+ hashInput,
4092
+ accepts
4093
+ }, (queryable) => consume(rows(queryable)));
4094
+ }
4095
+ const groupedAggregateMethod = "groupBy.aggregate";
3795
4096
  var GroupedCollection = class GroupedCollection {
3796
4097
  ctx;
3797
4098
  contract;
@@ -3879,21 +4180,34 @@ var GroupedCollection = class GroupedCollection {
3879
4180
  offset: typeof n === "number" ? n : toExpr(n)
3880
4181
  } });
3881
4182
  }
4183
+ get prepared() {
4184
+ return { aggregate: (fn, configure) => {
4185
+ const description = this.#describeAggregate(fn);
4186
+ return asPreparedOrmCall(description, preparedValueCall(groupedAggregateMethod, this.#annotations(configure), description.consume, ormResults.rows));
4187
+ } };
4188
+ }
3882
4189
  /**
3883
4190
  * Read terminal: run a grouped aggregate query.
3884
4191
  *
3885
4192
  * Accepts an optional `configure` callback that receives a
3886
- * `MetaBuilder<'read'>` for attaching typed annotations.
3887
- * Annotations are merged into the compiled plan's `meta.annotations`.
4193
+ * `MetaBuilder<'read'>` for attaching typed annotations to the call.
3888
4194
  */
3889
- get prepared() {
3890
- return { aggregate: (fn, configure) => this.#describeAggregate(fn, configure) };
3891
- }
3892
4195
  async aggregate(fn, configure) {
3893
- const description = this.#describeAggregate(fn, configure);
3894
- return description.consume(queryPlanRows(this.ctx.runtime, description.plan));
4196
+ const description = this.#describeAggregate(fn);
4197
+ return runOrmCall(this.ctx.runtime, {
4198
+ method: groupedAggregateMethod,
4199
+ annotations: this.#annotations(configure),
4200
+ hashInput: planHashInput(() => description.plan),
4201
+ accepts: ormResults.rows
4202
+ }, (queryable) => runQuery(queryable, description));
4203
+ }
4204
+ #annotations(configure) {
4205
+ if (configure === void 0) return void 0;
4206
+ const meta = createMetaBuilder("read", groupedAggregateMethod);
4207
+ configure(meta);
4208
+ return meta.annotations.size > 0 ? meta.annotations : void 0;
3895
4209
  }
3896
- #describeAggregate(fn, configure) {
4210
+ #describeAggregate(fn) {
3897
4211
  const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
3898
4212
  const aggregateEntries = Object.entries(aggregateSpec);
3899
4213
  if (aggregateEntries.length === 0) throw ormError("ORM.AGGREGATE_SELECTOR_MISSING", "groupBy().aggregate() requires at least one aggregation selector", { meta: {
@@ -3905,13 +4219,7 @@ var GroupedCollection = class GroupedCollection {
3905
4219
  model: this.modelName,
3906
4220
  alias
3907
4221
  } });
3908
- let annotationsMap;
3909
- if (configure !== void 0) {
3910
- const meta = createMetaBuilder("read", "groupBy.aggregate");
3911
- configure(meta);
3912
- if (meta.annotations.size > 0) annotationsMap = meta.annotations;
3913
- }
3914
- const compiled = mergeAnnotations(compileGroupedAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.preGroupState, this.groupByColumns, aggregateSpec, combineWhereExprs(this.havingFilters), this.modelName, this.postGroup), annotationsMap);
4222
+ const compiled = compileGroupedAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.preGroupState, this.groupByColumns, aggregateSpec, combineWhereExprs(this.havingFilters), this.modelName, this.postGroup);
3915
4223
  const mapRow = createStorageRowMapper(this.contract, this.namespaceId, this.modelName);
3916
4224
  return {
3917
4225
  plan: compiled,
@@ -4989,36 +5297,33 @@ function whereOf(collection) {
4989
5297
  const { context, state } = collection;
4990
5298
  return countMutationWhere(context.contract, state.tables, state.filters, state.variantValue);
4991
5299
  }
4992
- function queryGraph(graph, ctx, annotations, callerRows) {
5300
+ function queryGraph(graph, ctx, callerRows) {
4993
5301
  returnCallerColumns(graph, callerRows);
4994
5302
  const [only, ...others] = graph.nodes();
4995
5303
  if (only !== void 0 && others.length === 0 && only[0] === graph.result) {
4996
5304
  const [id, node] = only;
4997
- const run = runOn(ctx, annotations);
5305
+ const run = runOn(ctx, ctx.runtime);
4998
5306
  return shapeRows(graph, id, rowStream(node.execute(inputsOf(graph, id, []), run)), callerRows);
4999
5307
  }
5000
5308
  const generator = async function* () {
5001
- yield* (await runAllNodes(graph, ctx, annotations, callerRows)).rows;
5309
+ yield* (await runAllNodes(graph, ctx, callerRows)).rows;
5002
5310
  };
5003
5311
  return new AsyncIterableResult(generator());
5004
5312
  }
5005
- async function executeGraph(graph, ctx, annotations) {
5006
- return { affectedRows: (await runAllNodes(graph, ctx, annotations, void 0)).count };
5313
+ async function executeGraph(graph, ctx) {
5314
+ return { affectedRows: (await runAllNodes(graph, ctx, void 0)).count };
5007
5315
  }
5008
5316
  function returnCallerColumns(graph, callerRows) {
5009
5317
  const { context, modelName, state } = callerRows;
5010
5318
  const columns = returningProjection(context.contract, modelName, state.tables.root, state.selectedFields);
5011
5319
  for (const [id, node] of graph.nodes()) if (id === graph.result && node instanceof StatementNode) graph.replace(id, node.withReturning(columns));
5012
5320
  }
5013
- function runAllNodes(graph, ctx, annotations, callerRows) {
5014
- if (graph.nodes().length > 1) return withMutationScope(ctx.runtime, (scope) => runNodesInOrder(graph, {
5015
- ...ctx,
5016
- runtime: scope
5017
- }, annotations, callerRows));
5018
- return runNodesInOrder(graph, ctx, annotations, callerRows);
5321
+ function runAllNodes(graph, ctx, callerRows) {
5322
+ if (graph.nodes().length > 1) return withMutationScope(ctx.runtime, (scope) => runNodesInOrder(graph, ctx, scope, callerRows));
5323
+ return runNodesInOrder(graph, ctx, ctx.runtime, callerRows);
5019
5324
  }
5020
- async function runNodesInOrder(graph, ctx, annotations, callerRows) {
5021
- const run = runOn(ctx, annotations);
5325
+ async function runNodesInOrder(graph, ctx, scope, callerRows) {
5326
+ const run = runOn(ctx, scope);
5022
5327
  const collected = [];
5023
5328
  let rows = [];
5024
5329
  let count = 0;
@@ -5042,12 +5347,12 @@ function inputsOf(graph, id, collected) {
5042
5347
  else outputs[name] = slot.length === 0 ? null : slot.map(outputOf);
5043
5348
  return outputs;
5044
5349
  }
5045
- function runOn(ctx, annotations) {
5350
+ function runOn(ctx, scope) {
5046
5351
  const { contract } = ctx.context;
5047
- const planOf = (ast) => mergeAnnotations(buildOrmQueryPlan(contract, ast, deriveParamsFromAst(ast).params), annotations);
5352
+ const planOf = (ast) => buildOrmQueryPlan(contract, ast, deriveParamsFromAst(ast).params);
5048
5353
  return {
5049
- query: (ast) => queryPlanRows(ctx.runtime, planOf(ast)),
5050
- execute: async (ast) => (await ctx.runtime.execute(planOf(ast))).affectedRows
5354
+ query: (ast) => queryPlanRows(scope, planOf(ast)),
5355
+ execute: async (ast) => (await scope.execute(planOf(ast))).affectedRows
5051
5356
  };
5052
5357
  }
5053
5358
  function shapeRows(graph, id, storageRows, callerRows) {
@@ -5547,22 +5852,36 @@ var CollectionBase = class CollectionBase {
5547
5852
  return this.#cloneSelf({ offset: typeof n === "number" ? n : toExpr(n) });
5548
5853
  }
5549
5854
  all(configure) {
5550
- return this.#withAnnotationsFromMeta(configure, "all").#dispatch();
5855
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "all");
5856
+ const query = describeCollectionQuery(this.#descriptionOptions());
5857
+ return streamOrmCall(this.ctx.runtime, this.#readCall("all", annotations, query.plan, ormResults.rows), query.rows);
5551
5858
  }
5552
5859
  get prepared() {
5553
5860
  return blindCast({
5554
- aggregate: (fn, configure) => this.#describeAggregate(fn, configure),
5861
+ aggregate: (fn, configure) => this.#preparedAggregate(fn, configure),
5555
5862
  all: (configure) => {
5556
- return describeCollectionRows(this.#withAnnotationsFromMeta(configure, "all").#descriptionOptions());
5863
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "all");
5864
+ const description = describeCollectionRows(this.#descriptionOptions());
5865
+ return asPreparedOrmCall(description, preparedRowsCall("all", annotations, description.consume));
5557
5866
  },
5558
5867
  first: (filter, configure) => {
5559
- return describeCollectionFirst(this.#forFirst(filter, configure, "first").#descriptionOptions());
5868
+ const scoped = this.#forFirst(filter);
5869
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "first");
5870
+ const description = describeCollectionFirst(scoped.#descriptionOptions());
5871
+ return asPreparedOrmCall(description, preparedValueCall("first", annotations, description.consume, ormResults.rowOrNull));
5560
5872
  },
5561
5873
  firstOrThrow: (filter, configure) => {
5562
- return describeCollectionFirstOrThrow(this.#forFirst(filter, configure, "firstOrThrow").#descriptionOptions());
5874
+ const scoped = this.#forFirst(filter);
5875
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "firstOrThrow");
5876
+ const description = describeCollectionFirstOrThrow(scoped.#descriptionOptions());
5877
+ return asPreparedOrmCall(description, preparedValueCall("firstOrThrow", annotations, description.consume, ormResults.row));
5563
5878
  }
5564
5879
  });
5565
5880
  }
5881
+ #preparedAggregate(fn, configure) {
5882
+ const description = this.#describeAggregate(fn);
5883
+ return asPreparedOrmCall(description, preparedValueCall("aggregate", this.#collectAnnotationsFromMeta(configure, "read", "aggregate"), description.consume, ormResults.row));
5884
+ }
5566
5885
  #descriptionOptions() {
5567
5886
  return {
5568
5887
  context: this.ctx.context,
@@ -5571,20 +5890,49 @@ var CollectionBase = class CollectionBase {
5571
5890
  namespaceId: this.namespaceId
5572
5891
  };
5573
5892
  }
5574
- #forFirst(filter, configure, terminalName) {
5575
- return (filter === void 0 ? this : typeof filter === "function" ? this.where(filter) : this.where(filter)).limit(1).#withAnnotationsFromMeta(configure, terminalName);
5893
+ #forFirst(filter) {
5894
+ return (filter === void 0 ? this : typeof filter === "function" ? this.where(filter) : this.where(filter)).limit(1);
5895
+ }
5896
+ #readCall(method, annotations, plan, accepts) {
5897
+ return {
5898
+ method,
5899
+ annotations,
5900
+ hashInput: planHashInput(plan),
5901
+ accepts
5902
+ };
5903
+ }
5904
+ #writeCall(method, annotations, accepts) {
5905
+ return {
5906
+ method,
5907
+ annotations,
5908
+ hashInput: modelHashInput(this.namespaceId, this.modelName),
5909
+ accepts
5910
+ };
5911
+ }
5912
+ #on(queryable) {
5913
+ return {
5914
+ ...this.ctx,
5915
+ runtime: queryable
5916
+ };
5576
5917
  }
5577
5918
  async first(filter, configure) {
5578
- return consumeFirstRow(this.#forFirst(filter, configure, "first").#dispatch());
5919
+ const scoped = this.#forFirst(filter);
5920
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "first");
5921
+ const query = describeCollectionQuery(scoped.#descriptionOptions());
5922
+ return runOrmCall(this.ctx.runtime, this.#readCall("first", annotations, query.plan, ormResults.rowOrNull), (queryable) => consumeFirstRow(query.rows(queryable)));
5579
5923
  }
5580
5924
  async firstOrThrow(filter, configure) {
5581
- return this.#forFirst(filter, configure, "firstOrThrow").#dispatch().firstOrThrow();
5925
+ const scoped = this.#forFirst(filter);
5926
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "firstOrThrow");
5927
+ const query = describeCollectionQuery(scoped.#descriptionOptions());
5928
+ return runOrmCall(this.ctx.runtime, this.#readCall("firstOrThrow", annotations, query.plan, ormResults.row), (queryable) => query.rows(queryable).firstOrThrow());
5582
5929
  }
5583
5930
  async aggregate(fn, configure) {
5584
- const description = this.#describeAggregate(fn, configure);
5585
- return description.consume(queryPlanRows(this.ctx.runtime, description.plan));
5931
+ const description = this.#describeAggregate(fn);
5932
+ const annotations = this.#collectAnnotationsFromMeta(configure, "read", "aggregate");
5933
+ return runOrmCall(this.ctx.runtime, this.#readCall("aggregate", annotations, () => description.plan, ormResults.row), (queryable) => runQuery(queryable, description));
5586
5934
  }
5587
- #describeAggregate(fn, configure) {
5935
+ #describeAggregate(fn) {
5588
5936
  assertLockCompatible(this.state, "aggregate");
5589
5937
  const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
5590
5938
  const entries = Object.entries(aggregateSpec);
@@ -5597,8 +5945,7 @@ var CollectionBase = class CollectionBase {
5597
5945
  model: this.modelName,
5598
5946
  alias
5599
5947
  } });
5600
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "read", "aggregate");
5601
- const compiled = mergeAnnotations(compileAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.state, aggregateSpec, this.modelName), annotationsMap);
5948
+ const compiled = compileAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.state, aggregateSpec, this.modelName);
5602
5949
  const results = entries.map(([alias, selector]) => {
5603
5950
  const resolved = resolveAggregate({
5604
5951
  aggregates: this.ctx.context.aggregateDescriptors,
@@ -5618,33 +5965,36 @@ var CollectionBase = class CollectionBase {
5618
5965
  plan: compiled,
5619
5966
  async consume(source) {
5620
5967
  const row = (await source.toArray())[0] ?? {};
5621
- return blindCast(Object.fromEntries(results.map(({ alias, resolved, codec }) => {
5622
- return [alias, (Object.hasOwn(row, alias) ? row[alias] : void 0) ?? emptyAggregateResult(resolved, codec)];
5623
- })));
5968
+ return blindCast(Object.fromEntries(await Promise.all(results.map(async ({ alias, resolved, codec }) => {
5969
+ return [alias, (Object.hasOwn(row, alias) ? row[alias] : void 0) ?? await emptyAggregateResult(resolved, codec)];
5970
+ }))));
5624
5971
  }
5625
5972
  };
5626
5973
  }
5627
5974
  async create(data, configure) {
5628
5975
  assertLockCompatible(this.state, "mutation");
5629
5976
  assertReturningCapability(this.contract, "create()");
5630
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "create");
5977
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "create");
5978
+ return runOrmCall(this.ctx.runtime, this.#writeCall("create", annotations, ormResults.row), (queryable) => this.#create(queryable, data));
5979
+ }
5980
+ async #create(queryable, data) {
5631
5981
  if (hasNestedMutationCallbacks(this.contract, this.namespaceId, this.modelName, blindCast(data))) {
5632
5982
  const createdRow = await executeNestedCreateMutation({
5633
5983
  context: this.ctx.context,
5634
- runtime: this.ctx.runtime,
5984
+ runtime: queryable,
5635
5985
  namespaceId: this.namespaceId,
5636
5986
  modelName: this.modelName,
5637
5987
  data: blindCast(data)
5638
5988
  });
5639
5989
  const identityCriterion = buildRowIdentityFilterFromRow(this.contract, this.namespaceId, this.modelName, createdRow);
5640
- const reloaded = await this.#reloadMutationRowByIdentity(identityCriterion);
5990
+ const reloaded = await this.#reloadMutationRowByIdentity(queryable, identityCriterion);
5641
5991
  if (!reloaded) throw ormError("ORM.MUTATION_ROW_MISSING", `create() for model "${this.modelName}" did not return a row`, { meta: {
5642
5992
  operation: "create",
5643
5993
  model: this.modelName
5644
5994
  } });
5645
5995
  return reloaded;
5646
5996
  }
5647
- const created = (await this.#createAllWithAnnotations([blindCast(data)], annotationsMap))[0];
5997
+ const created = (await this.#createAllRows([blindCast(data)])(queryable))[0];
5648
5998
  if (created) return created;
5649
5999
  throw ormError("ORM.MUTATION_ROW_MISSING", `create() for model "${this.modelName}" did not return a row`, { meta: {
5650
6000
  operation: "create",
@@ -5655,21 +6005,24 @@ var CollectionBase = class CollectionBase {
5655
6005
  assertLockCompatible(this.state, "mutation");
5656
6006
  const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
5657
6007
  const conflictSkip = this.#resolveConflictSkip(options, "createAll()");
5658
- return this.#createAllWithAnnotations(data, this.#collectAnnotationsFromMeta(configureCallback, "write", "createAll"), conflictSkip);
6008
+ const annotations = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAll");
6009
+ return streamOrmCall(this.ctx.runtime, this.#writeCall("createAll", annotations, ormResults.rows), this.#createAllRows(data, conflictSkip));
5659
6010
  }
5660
- #createAllWithAnnotations(data, annotationsMap, conflictSkip) {
6011
+ #createAllRows(data, conflictSkip) {
5661
6012
  if (data.length === 0) {
5662
6013
  const generator = async function* () {};
5663
- return new AsyncIterableResult(generator());
6014
+ return () => new AsyncIterableResult(generator());
5664
6015
  }
5665
6016
  assertReturningCapability(this.contract, "createAll()");
5666
6017
  const rows = blindCast(data);
5667
6018
  const mtiContext = this.#resolveMtiCreateContext();
5668
6019
  if (mtiContext) {
5669
6020
  const variantTable = requireVariantTable(this.state.tables, mtiContext.variant.value);
5670
- return queryGraph(createAllVariantGraph(this.#descriptionWithoutIncludes(), variantTable, mtiContext.variant.modelName, this.#variantCreateRows(rows, mtiContext, variantTable)), this.ctx, annotationsMap, this.#descriptionWithoutIncludes());
6021
+ const graph = createAllVariantGraph(this.#descriptionWithoutIncludes(), variantTable, mtiContext.variant.modelName, this.#variantCreateRows(rows, mtiContext, variantTable));
6022
+ return (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionWithoutIncludes());
5671
6023
  }
5672
- return queryGraph(createAllGraph(this.#descriptionOptions(), this.#createValues(rows), conflictSkip), this.ctx, annotationsMap, this.#descriptionOptions());
6024
+ const graph = createAllGraph(this.#descriptionOptions(), this.#createValues(rows), conflictSkip);
6025
+ return (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionOptions());
5673
6026
  }
5674
6027
  #createValues(rows) {
5675
6028
  const mappedRows = this.#mapCreateRows(rows);
@@ -5794,17 +6147,24 @@ var CollectionBase = class CollectionBase {
5794
6147
  assertLockCompatible(this.state, "mutation");
5795
6148
  const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
5796
6149
  const conflictSkip = this.#resolveConflictSkip(options, "createAndCount()");
5797
- if (data.length === 0) return 0;
6150
+ const annotations = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAndCount");
6151
+ const call = this.#writeCall("createAndCount", annotations, ormResults.count);
6152
+ if (data.length === 0) return runOrmCall(this.ctx.runtime, call, async () => 0);
5798
6153
  this.#assertNotMtiVariant("createAndCount()");
5799
- const annotationsMap = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAndCount");
5800
6154
  const rows = blindCast(data);
5801
- return (await executeGraph(createAllGraph(this.#descriptionWithoutIncludes(), this.#createValues(rows), conflictSkip), this.ctx, annotationsMap)).affectedRows;
6155
+ const graph = createAllGraph(this.#descriptionWithoutIncludes(), this.#createValues(rows), conflictSkip);
6156
+ return this.#countCall(call, graph);
6157
+ }
6158
+ #countCall(call, graph) {
6159
+ return runOrmCall(this.ctx.runtime, call, async (queryable) => {
6160
+ return (await executeGraph(graph, this.#on(queryable))).affectedRows;
6161
+ });
5802
6162
  }
5803
6163
  async upsert(input, configure) {
5804
6164
  assertLockCompatible(this.state, "mutation");
5805
6165
  assertReturningCapability(this.contract, "upsert()");
5806
6166
  this.#assertNotMtiVariant("upsert()");
5807
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "upsert");
6167
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "upsert");
5808
6168
  const createValues = this.#mapCreateRows([blindCast(input.create)])[0] ?? {};
5809
6169
  applyCreateDefaults(this.ctx, this.namespaceId, this.tableName, [createValues]);
5810
6170
  const updateValues = mapModelDataToStorageRow(this.contract, this.namespaceId, this.modelName, input.update);
@@ -5814,22 +6174,28 @@ var CollectionBase = class CollectionBase {
5814
6174
  method: "upsert",
5815
6175
  model: this.modelName
5816
6176
  } });
5817
- const row = await consumeFirstRow(queryGraph(upsertGraph(this.#descriptionOptions(), createValues, updateValues, conflictColumns), this.ctx, annotationsMap, this.#descriptionOptions()));
5818
- if (row) return row;
5819
- throw ormError("ORM.MUTATION_ROW_MISSING", `upsert() for model "${this.modelName}" did not return a row`, { meta: {
5820
- operation: "upsert",
5821
- model: this.modelName
5822
- } });
6177
+ const graph = upsertGraph(this.#descriptionOptions(), createValues, updateValues, conflictColumns);
6178
+ return runOrmCall(this.ctx.runtime, this.#writeCall("upsert", annotations, ormResults.row), async (queryable) => {
6179
+ const row = await consumeFirstRow(queryGraph(graph, this.#on(queryable), this.#descriptionOptions()));
6180
+ if (row) return row;
6181
+ throw ormError("ORM.MUTATION_ROW_MISSING", `upsert() for model "${this.modelName}" did not return a row`, { meta: {
6182
+ operation: "upsert",
6183
+ model: this.modelName
6184
+ } });
6185
+ });
5823
6186
  }
5824
6187
  async update(data, configure) {
5825
6188
  assertLockCompatible(this.state, "mutation");
5826
6189
  assertReturningCapability(this.contract, "update()");
5827
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "update");
6190
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "update");
6191
+ return runOrmCall(this.ctx.runtime, this.#writeCall("update", annotations, ormResults.rowOrNull), (queryable) => this.#update(queryable, data));
6192
+ }
6193
+ async #update(queryable, data) {
5828
6194
  if (hasNestedMutationCallbacks(this.contract, this.namespaceId, this.modelName, blindCast(data))) {
5829
6195
  assertRelationUpdateIgnoresNothing(this.state, this.modelName);
5830
6196
  const updatedRow = await executeNestedUpdateMutation({
5831
6197
  context: this.ctx.context,
5832
- runtime: this.ctx.runtime,
6198
+ runtime: queryable,
5833
6199
  namespaceId: this.namespaceId,
5834
6200
  modelName: this.modelName,
5835
6201
  tables: this.state.tables,
@@ -5838,45 +6204,55 @@ var CollectionBase = class CollectionBase {
5838
6204
  });
5839
6205
  if (!updatedRow) return null;
5840
6206
  const identityCriterion = buildRowIdentityFilterFromRow(this.contract, this.namespaceId, this.modelName, updatedRow);
5841
- return this.#reloadMutationRowByIdentity(identityCriterion);
6207
+ return this.#reloadMutationRowByIdentity(queryable, identityCriterion);
5842
6208
  }
5843
6209
  assertModelFieldNames(this.contract, this.namespaceId, this.modelName, blindCast(data));
5844
6210
  const values = this.#updateValues(blindCast(data));
5845
- return consumeFirstRow(queryGraph(updateFirstGraph(this.#descriptionOptions(), values), this.ctx, annotationsMap, this.#descriptionOptions()));
6211
+ return consumeFirstRow(queryGraph(updateFirstGraph(this.#descriptionOptions(), values), this.#on(queryable), this.#descriptionOptions()));
5846
6212
  }
5847
6213
  updateAll(data, configure) {
5848
6214
  assertBulkWriteIgnoresNothing(this.state, this.modelName, "updateAll");
5849
6215
  assertLockCompatible(this.state, "mutation");
5850
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "updateAll");
6216
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "updateAll");
5851
6217
  assertReturningCapability(this.contract, "updateAll()");
5852
- return queryGraph(updateAllGraph(this.#descriptionOptions(), this.#updateValues(data)), this.ctx, annotationsMap, this.#descriptionOptions());
6218
+ const graph = updateAllGraph(this.#descriptionOptions(), this.#updateValues(data));
6219
+ return this.#rowsCall("updateAll", annotations, graph);
6220
+ }
6221
+ #rowsCall(method, annotations, graph) {
6222
+ return streamOrmCall(this.ctx.runtime, this.#writeCall(method, annotations, ormResults.rows), (queryable) => queryGraph(graph, this.#on(queryable), this.#descriptionOptions()));
6223
+ }
6224
+ #firstRowCall(method, annotations, graph) {
6225
+ return runOrmCall(this.ctx.runtime, this.#writeCall(method, annotations, ormResults.rowOrNull), (queryable) => consumeFirstRow(queryGraph(graph, this.#on(queryable), this.#descriptionOptions())));
5853
6226
  }
5854
6227
  async updateAndCount(data, configure) {
5855
6228
  assertBulkWriteIgnoresNothing(this.state, this.modelName, "updateAndCount");
5856
6229
  assertLockCompatible(this.state, "mutation");
5857
6230
  const values = this.#updateValues(data);
5858
6231
  const graph = Object.keys(values).length === 0 ? new Graph() : updateAllGraph(this.#descriptionWithoutIncludes(), values);
5859
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "updateAndCount");
5860
- return (await executeGraph(graph, this.ctx, annotationsMap)).affectedRows;
6232
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "updateAndCount");
6233
+ return this.#countCall(this.#writeCall("updateAndCount", annotations, ormResults.count), graph);
5861
6234
  }
5862
6235
  async delete(configure) {
5863
6236
  assertLockCompatible(this.state, "mutation");
5864
6237
  assertReturningCapability(this.contract, "delete()");
5865
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "delete");
5866
- return consumeFirstRow(queryGraph(deleteFirstGraph(this.#descriptionOptions()), this.ctx, annotationsMap, this.#descriptionOptions()));
6238
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "delete");
6239
+ const graph = deleteFirstGraph(this.#descriptionOptions());
6240
+ return this.#firstRowCall("delete", annotations, graph);
5867
6241
  }
5868
6242
  deleteAll(configure) {
5869
6243
  assertBulkWriteIgnoresNothing(this.state, this.modelName, "deleteAll");
5870
6244
  assertLockCompatible(this.state, "mutation");
5871
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "deleteAll");
6245
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "deleteAll");
5872
6246
  assertReturningCapability(this.contract, "deleteAll()");
5873
- return queryGraph(deleteAllGraph(this.#descriptionOptions()), this.ctx, annotationsMap, this.#descriptionOptions());
6247
+ const graph = deleteAllGraph(this.#descriptionOptions());
6248
+ return this.#rowsCall("deleteAll", annotations, graph);
5874
6249
  }
5875
6250
  async deleteAndCount(configure) {
5876
6251
  assertBulkWriteIgnoresNothing(this.state, this.modelName, "deleteAndCount");
5877
6252
  assertLockCompatible(this.state, "mutation");
5878
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "deleteAndCount");
5879
- return (await executeGraph(deleteAllGraph(this.#descriptionWithoutIncludes()), this.ctx, annotationsMap)).affectedRows;
6253
+ const annotations = this.#collectAnnotationsFromMeta(configure, "write", "deleteAndCount");
6254
+ const graph = deleteAllGraph(this.#descriptionWithoutIncludes());
6255
+ return this.#countCall(this.#writeCall("deleteAndCount", annotations, ormResults.count), graph);
5880
6256
  }
5881
6257
  #descriptionWithoutIncludes() {
5882
6258
  return {
@@ -5892,10 +6268,10 @@ var CollectionBase = class CollectionBase {
5892
6268
  if (Object.keys(values).length > 0) applyUpdateDefaults(this.ctx, this.namespaceId, this.tableName, values);
5893
6269
  return values;
5894
6270
  }
5895
- async #reloadMutationRowByIdentity(criterion) {
5896
- return this.#reloadMutationRowByCriterion(criterion, "row identity");
6271
+ async #reloadMutationRowByIdentity(queryable, criterion) {
6272
+ return this.#reloadMutationRowByCriterion(queryable, criterion, "row identity");
5897
6273
  }
5898
- async #reloadMutationRowByCriterion(criterion, criterionLabel) {
6274
+ async #reloadMutationRowByCriterion(queryable, criterion, criterionLabel) {
5899
6275
  const whereExpr = shorthandToWhereExpr(this.ctx.context, this.namespaceId, this.modelName, blindCast(criterion), this.state.tables.root);
5900
6276
  if (!whereExpr) throw new InternalError(`Failed to build ${criterionLabel} filter for mutation result on model "${this.modelName}"`);
5901
6277
  const resultState = {
@@ -5907,7 +6283,7 @@ var CollectionBase = class CollectionBase {
5907
6283
  };
5908
6284
  return (await dispatchCollectionRows({
5909
6285
  context: this.ctx.context,
5910
- runtime: this.ctx.runtime,
6286
+ runtime: queryable,
5911
6287
  state: resultState,
5912
6288
  modelName: this.modelName,
5913
6289
  namespaceId: this.namespaceId
@@ -5929,12 +6305,6 @@ var CollectionBase = class CollectionBase {
5929
6305
  });
5930
6306
  return this.#cloneSelf({ locking: [...this.state.locking ?? [], clause] });
5931
6307
  }
5932
- #clone(overrides) {
5933
- return this.#createSelf({
5934
- ...this.state,
5935
- ...overrides
5936
- });
5937
- }
5938
6308
  #cloneSelf(overrides) {
5939
6309
  return blindCast(this.#createSelf({
5940
6310
  ...this.state,
@@ -5965,48 +6335,6 @@ var CollectionBase = class CollectionBase {
5965
6335
  includeRefinementMode: options.includeRefinementMode ?? this.includeRefinementMode
5966
6336
  }));
5967
6337
  }
5968
- #dispatch() {
5969
- return dispatchCollectionRows({
5970
- context: this.ctx.context,
5971
- runtime: this.ctx.runtime,
5972
- state: this.state,
5973
- modelName: this.modelName,
5974
- namespaceId: this.namespaceId
5975
- });
5976
- }
5977
- /**
5978
- * Invokes the user-supplied configurator (if any) against a freshly
5979
- * constructed read meta builder, and returns a clone whose
5980
- * `state.annotations` carries the recorded map. Used by read
5981
- * terminals that flow annotations through state (`all`, `first`).
5982
- *
5983
- * Returns the receiver unchanged when no configurator was supplied
5984
- * or when the configurator did not call `meta.annotate(...)`. The
5985
- * meta builder's `annotate` method enforces applicability at the
5986
- * type level and at runtime, so terminal code does not need to
5987
- * re-validate.
5988
- */
5989
- #withAnnotationsFromMeta(configure, terminalName) {
5990
- if (configure === void 0) return this;
5991
- const meta = createMetaBuilder("read", terminalName);
5992
- configure(meta);
5993
- if (meta.annotations.size === 0) return this;
5994
- const next = new Map(this.state.annotations);
5995
- for (const [namespace, value] of meta.annotations) next.set(namespace, value);
5996
- return blindCast(this.#clone({ annotations: next }));
5997
- }
5998
- /**
5999
- * Invokes the user-supplied configurator (if any) against a freshly
6000
- * constructed meta builder of the given operation kind, and returns
6001
- * the recorded annotation map (or `undefined` when empty). Used by
6002
- * terminals where annotations don't flow through `state` — the
6003
- * compiled plan is post-wrapped via `mergeAnnotations` instead.
6004
- * Read terminals `all` and `first` populate `state.annotations`
6005
- * via `#withAnnotationsFromMeta` instead; `aggregate` uses this
6006
- * post-wrap path because `compileAggregate` does not forward `state.annotations` into the plan.
6007
- * The meta builder's `annotate` method enforces applicability at the
6008
- * type level and at runtime.
6009
- */
6010
6338
  #collectAnnotationsFromMeta(configure, kind, terminalName) {
6011
6339
  if (configure === void 0) return;
6012
6340
  const meta = createMetaBuilder(kind, terminalName);
@@ -6133,7 +6461,10 @@ async function prepareQuery(runtime, declaration, callback) {
6133
6461
  }
6134
6462
  function createPreparedRowQuery(description, statement) {
6135
6463
  return Object.freeze({ query(target, params, options) {
6136
- return description.consume(statement.query(target, params, options));
6464
+ const rows = (queryable) => statement.query(queryable, params, options);
6465
+ const call = preparedOrmCallOf(description);
6466
+ if (call === void 0) return description.consume(rows(target));
6467
+ return call(target, rows, preparedHashInput(statement, params));
6137
6468
  } });
6138
6469
  }
6139
6470
  //#endregion