@prisma/orm-family-sql 8.0.0-rc.1-dev.9 → 8.0.0-rc.1-dev.11

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 (238) hide show
  1. package/dist/{aggregate-descriptor-registry-DPV4z8MS.mjs → aggregate-descriptor-registry-DvPrQwzY.mjs} +11 -3
  2. package/dist/aggregate-descriptor-registry-DvPrQwzY.mjs.map +1 -0
  3. package/dist/{ast-DDAyIKdt.mjs → ast-B-eeN74F.mjs} +2 -2
  4. package/dist/ast-B-eeN74F.mjs.map +1 -0
  5. package/dist/{ast-UfF480P2.d.mts → ast-BwBkpAM7.d.mts} +3 -3
  6. package/dist/{ast-UfF480P2.d.mts.map → ast-BwBkpAM7.d.mts.map} +1 -1
  7. package/dist/{authoring-type-constructors-Blqoa2Ua-DymjrX_a.mjs → authoring-type-constructors-Blqoa2Ua-BR5-FhUN.mjs} +2 -2
  8. package/dist/{authoring-type-constructors-Blqoa2Ua-DymjrX_a.mjs.map → authoring-type-constructors-Blqoa2Ua-BR5-FhUN.mjs.map} +1 -1
  9. package/dist/builder.d.mts +2 -2
  10. package/dist/builder__runtime.d.mts +9 -9
  11. package/dist/builder__runtime.mjs +140 -78
  12. package/dist/builder__runtime.mjs.map +1 -1
  13. package/dist/builder__types.d.mts +2 -2
  14. package/dist/{codec-descriptor-registry-BK_ZTP-3.mjs → codec-descriptor-registry-BQPj9q8O.mjs} +2 -2
  15. package/dist/{codec-descriptor-registry-BK_ZTP-3.mjs.map → codec-descriptor-registry-BQPj9q8O.mjs.map} +1 -1
  16. package/dist/{config-types-DuhCZxnc.d.mts → config-types-JLo8FI3b.d.mts} +4 -4
  17. package/dist/{config-types-DuhCZxnc.d.mts.map → config-types-JLo8FI3b.d.mts.map} +1 -1
  18. package/dist/{config-types-1lEI_abO.mjs → config-types-THGAJYUu.mjs} +2 -2
  19. package/dist/{config-types-1lEI_abO.mjs.map → config-types-THGAJYUu.mjs.map} +1 -1
  20. package/dist/{contract-builder-B5ztYYVI.d.mts → contract-builder-94EfE12M.d.mts} +25 -7
  21. package/dist/{contract-builder-B5ztYYVI.d.mts.map → contract-builder-94EfE12M.d.mts.map} +1 -1
  22. package/dist/{contract-builder-DQ02XiKy.mjs → contract-builder-bNftqD4M.mjs} +18 -3
  23. package/dist/contract-builder-bNftqD4M.mjs.map +1 -0
  24. package/dist/contract-psl.d.mts +2 -2
  25. package/dist/contract-psl.mjs +1 -1
  26. package/dist/contract-psl__provider.d.mts +2 -2
  27. package/dist/contract-psl__provider.mjs +2 -2
  28. package/dist/contract-psl__provider.mjs.map +1 -1
  29. package/dist/contract-ts.d.mts +5 -4
  30. package/dist/contract-ts.mjs +3 -3
  31. package/dist/contract-ts__config-types.d.mts +1 -1
  32. package/dist/contract-ts__config-types.mjs +1 -1
  33. package/dist/contract-ts__contract-builder.d.mts +4 -3
  34. package/dist/contract-ts__contract-builder.mjs +2 -2
  35. package/dist/{contract-view-DB7yHLAp.d.mts → contract-view-CX3RJUrm.d.mts} +2 -2
  36. package/dist/{contract-view-DB7yHLAp.d.mts.map → contract-view-CX3RJUrm.d.mts.map} +1 -1
  37. package/dist/contract.d.mts +14 -14
  38. package/dist/contract.mjs +8 -8
  39. package/dist/contract__contract-view.d.mts +1 -1
  40. package/dist/contract__entity-kinds.d.mts +1 -1
  41. package/dist/contract__entity-kinds.mjs +1 -1
  42. package/dist/contract__factories.d.mts +1 -1
  43. package/dist/contract__factories.mjs +1 -1
  44. package/dist/contract__foreign-key-materialization.d.mts +1 -1
  45. package/dist/contract__foreign-key-materialization.mjs +1 -1
  46. package/dist/contract__index-naming.d.mts +1 -1
  47. package/dist/contract__index-naming.mjs +1 -1
  48. package/dist/contract__index-type-validation.d.mts +1 -1
  49. package/dist/contract__resolve-storage-table.d.mts +1 -1
  50. package/dist/contract__types.d.mts +6 -6
  51. package/dist/contract__types.mjs +3 -3
  52. package/dist/contract__validators.d.mts +1 -1
  53. package/dist/contract__validators.mjs +2 -2
  54. package/dist/control-adapter-B71_6j-D.d.mts +1 -0
  55. package/dist/{control-adapter-C99J7aEF-BvoknoRl.d.mts → control-adapter-C99J7aEF-D9Lhjafk.d.mts} +8 -8
  56. package/dist/{control-adapter-C99J7aEF-BvoknoRl.d.mts.map → control-adapter-C99J7aEF-D9Lhjafk.d.mts.map} +1 -1
  57. package/dist/{control-JKCfuZLF.d.mts → control-ewQAyuM8.d.mts} +14 -14
  58. package/dist/{control-JKCfuZLF.d.mts.map → control-ewQAyuM8.d.mts.map} +1 -1
  59. package/dist/{control-Bj2zT_YF.mjs → control-jeE2ibQ5.mjs} +8 -8
  60. package/dist/{control-Bj2zT_YF.mjs.map → control-jeE2ibQ5.mjs.map} +1 -1
  61. package/dist/{db-B5PMfDDd-ZnA9Kuky.d.mts → db-C5jmOFPM-DeJH09un.d.mts} +43 -25
  62. package/dist/db-C5jmOFPM-DeJH09un.d.mts.map +1 -0
  63. package/dist/{ddl-types-h_3_pXmq-DzkUGplM.d.mts → ddl-types-CBTOCoND-Ct-Dz4gJ.d.mts} +4 -4
  64. package/dist/{ddl-types-h_3_pXmq-DzkUGplM.d.mts.map → ddl-types-CBTOCoND-Ct-Dz4gJ.d.mts.map} +1 -1
  65. package/dist/{derived-checks-BDG-r9XD-CrpFUaO7.mjs → derived-checks-CmJgg-N0-Dt3bpEKZ.mjs} +93 -43
  66. package/dist/derived-checks-CmJgg-N0-Dt3bpEKZ.mjs.map +1 -0
  67. package/dist/{derived-checks-DPdD01O0-CXFJD5al.d.mts → derived-checks-DPdD01O0-BusNrgPr.d.mts} +3 -3
  68. package/dist/{derived-checks-DPdD01O0-CXFJD5al.d.mts.map → derived-checks-DPdD01O0-BusNrgPr.d.mts.map} +1 -1
  69. package/dist/{diff-DDfez6HZ.d.mts → diff-B_ttICMr.d.mts} +8 -8
  70. package/dist/{diff-DDfez6HZ.d.mts.map → diff-B_ttICMr.d.mts.map} +1 -1
  71. package/dist/{entity-kinds-3IFQq7Ho-DB6IN-V6.mjs → entity-kinds-BP9JRPX9-oeJ-t1iG.mjs} +14 -5
  72. package/dist/entity-kinds-BP9JRPX9-oeJ-t1iG.mjs.map +1 -0
  73. package/dist/{entity-kinds-FB5fUkUH.d.mts → entity-kinds-CcRX_9l5.d.mts} +4 -4
  74. package/dist/{entity-kinds-FB5fUkUH.d.mts.map → entity-kinds-CcRX_9l5.d.mts.map} +1 -1
  75. package/dist/{expression-Da4F0ehj.mjs → expression-CYVKobXp.mjs} +2 -2
  76. package/dist/{expression-Da4F0ehj.mjs.map → expression-CYVKobXp.mjs.map} +1 -1
  77. package/dist/{expression-CBHseNtv.d.mts → expression-X88ppPyv.d.mts} +5 -5
  78. package/dist/{expression-CBHseNtv.d.mts.map → expression-X88ppPyv.d.mts.map} +1 -1
  79. package/dist/{factories-BPmhxoFd.d.mts → factories-DBqPbIcf.d.mts} +4 -4
  80. package/dist/{factories-BPmhxoFd.d.mts.map → factories-DBqPbIcf.d.mts.map} +1 -1
  81. package/dist/{factories-BtnISekg.mjs → factories-MZugewOe.mjs} +3 -3
  82. package/dist/{factories-BtnISekg.mjs.map → factories-MZugewOe.mjs.map} +1 -1
  83. package/dist/family.d.mts +11 -11
  84. package/dist/family.mjs +4 -4
  85. package/dist/family__control-adapter.d.mts +2 -2
  86. package/dist/family__control.d.mts +3 -3
  87. package/dist/family__control.mjs +2 -2
  88. package/dist/family__diff.d.mts +2 -2
  89. package/dist/family__diff.mjs +1 -1
  90. package/dist/family__ir.d.mts +1 -1
  91. package/dist/family__ir.mjs +1 -1
  92. package/dist/family__migration.d.mts +1 -1
  93. package/dist/family__pack.mjs +1 -1
  94. package/dist/family__psl-infer.d.mts +1 -1
  95. package/dist/family__psl-infer.mjs +1 -1
  96. package/dist/family__runtime.d.mts +2 -2
  97. package/dist/{foreign-key-materialization-CetaZvuu.d.mts → foreign-key-materialization-CS5yxHpq.d.mts} +2 -2
  98. package/dist/{foreign-key-materialization-CetaZvuu.d.mts.map → foreign-key-materialization-CS5yxHpq.d.mts.map} +1 -1
  99. package/dist/{foreign-key-materialization-fH6cObko.mjs → foreign-key-materialization-ziwobURR.mjs} +2 -2
  100. package/dist/{foreign-key-materialization-fH6cObko.mjs.map → foreign-key-materialization-ziwobURR.mjs.map} +1 -1
  101. package/dist/{index-avHHFCFT.d.mts → index-CwtBEMZr.d.mts} +3 -3
  102. package/dist/{index-avHHFCFT.d.mts.map → index-CwtBEMZr.d.mts.map} +1 -1
  103. package/dist/{index-COS9qF9d.d.mts → index-DKWhjgoj.d.mts} +16 -16
  104. package/dist/{index-COS9qF9d.d.mts.map → index-DKWhjgoj.d.mts.map} +1 -1
  105. package/dist/{index-naming-BfRyBZR4.d.mts → index-naming-BD2dqoTC.d.mts} +2 -2
  106. package/dist/{index-naming-BfRyBZR4.d.mts.map → index-naming-BD2dqoTC.d.mts.map} +1 -1
  107. package/dist/{index-naming-BoGBcMmI-DE0Eu71F.mjs → index-naming-BoGBcMmI-CoehgjMK.mjs} +2 -2
  108. package/dist/{index-naming-BoGBcMmI-DE0Eu71F.mjs.map → index-naming-BoGBcMmI-CoehgjMK.mjs.map} +1 -1
  109. package/dist/{index-type-validation-0NdkDB_n.d.mts → index-type-validation-ko-AixNA.d.mts} +3 -3
  110. package/dist/{index-type-validation-0NdkDB_n.d.mts.map → index-type-validation-ko-AixNA.d.mts.map} +1 -1
  111. package/dist/{interpreter-5WgpL-ax-BIbrd_Xv.mjs → interpreter-BDZ_Y5U--CWQ831IX.mjs} +88 -4
  112. package/dist/interpreter-BDZ_Y5U--CWQ831IX.mjs.map +1 -0
  113. package/dist/{ir-VWQX6aGP.d.mts → ir-DS7g_cyQ.d.mts} +3 -3
  114. package/dist/{ir-VWQX6aGP.d.mts.map → ir-DS7g_cyQ.d.mts.map} +1 -1
  115. package/dist/lane-query-builder.d.mts +5 -5
  116. package/dist/{middleware-eb7YwdD4-CiyaANOv.d.mts → middleware-Bp5oIYM0-B-m0jAm8.d.mts} +3 -3
  117. package/dist/{middleware-eb7YwdD4-CiyaANOv.d.mts.map → middleware-Bp5oIYM0-B-m0jAm8.d.mts.map} +1 -1
  118. package/dist/middleware-g3HMYfJq.d.mts +1 -0
  119. package/dist/{migration-DvCs5-4I.d.mts → migration-D8_nHECs.d.mts} +4 -4
  120. package/dist/{migration-DvCs5-4I.d.mts.map → migration-D8_nHECs.d.mts.map} +1 -1
  121. package/dist/{naming-CEGRBbyW-BOa9Eun0.mjs → naming-BWkuWJJK-zuGIIJ49.mjs} +18 -3
  122. package/dist/naming-BWkuWJJK-zuGIIJ49.mjs.map +1 -0
  123. package/dist/{naming-DvlNocom-ClcApdiR.d.mts → naming-BsvzQPOq-qOWmknyp.d.mts} +17 -3
  124. package/dist/naming-BsvzQPOq-qOWmknyp.d.mts.map +1 -0
  125. package/dist/operations.d.mts +1 -1
  126. package/dist/orm-client.d.mts +150 -100
  127. package/dist/orm-client.d.mts.map +1 -1
  128. package/dist/orm-client.mjs +238 -196
  129. package/dist/orm-client.mjs.map +1 -1
  130. package/dist/plan-D3FQ6FXy.d.mts +2 -0
  131. package/dist/{plan-Bmp5R9sq-mVFXvLM7.d.mts → plan-DfLDIdep-qOGizVoO.d.mts} +5 -5
  132. package/dist/plan-DfLDIdep-qOGizVoO.d.mts.map +1 -0
  133. package/dist/{psl-infer-f5BgyRKm.mjs → psl-infer-Z4wA2xpx.mjs} +2 -2
  134. package/dist/{psl-infer-f5BgyRKm.mjs.map → psl-infer-Z4wA2xpx.mjs.map} +1 -1
  135. package/dist/{psl-infer-Dp_hwubv.d.mts → psl-infer-zSNyTUPT.d.mts} +3 -3
  136. package/dist/{psl-infer-Dp_hwubv.d.mts.map → psl-infer-zSNyTUPT.d.mts.map} +1 -1
  137. package/dist/query-lane-context-7V5_yUIr.d.mts +1 -0
  138. package/dist/{query-lane-context-DjyAyYht-DdovdGjc.d.mts → query-lane-context-CONNlrCx-D2biFONs.d.mts} +8 -6
  139. package/dist/query-lane-context-CONNlrCx-D2biFONs.d.mts.map +1 -0
  140. package/dist/relational-core.d.mts +12 -12
  141. package/dist/relational-core.mjs +4 -5
  142. package/dist/relational-core__aggregate-descriptor-registry.d.mts +2 -2
  143. package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
  144. package/dist/relational-core__ast.d.mts +4 -4
  145. package/dist/relational-core__ast.mjs +3 -4
  146. package/dist/relational-core__codec-descriptor-registry.d.mts +4 -4
  147. package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
  148. package/dist/relational-core__contract-free.d.mts +3 -3
  149. package/dist/relational-core__contract-free.mjs +1 -1
  150. package/dist/relational-core__contract-free.mjs.map +1 -1
  151. package/dist/relational-core__expression.d.mts +1 -1
  152. package/dist/relational-core__expression.mjs +1 -1
  153. package/dist/relational-core__middleware.d.mts +2 -2
  154. package/dist/relational-core__plan.d.mts +3 -3
  155. package/dist/relational-core__query-lane-context.d.mts +2 -2
  156. package/dist/relational-core__types.d.mts +2 -2
  157. package/dist/{resolve-storage-table-BJYVl94P.d.mts → resolve-storage-table-CQsGt37y.d.mts} +3 -3
  158. package/dist/{resolve-storage-table-BJYVl94P.d.mts.map → resolve-storage-table-CQsGt37y.d.mts.map} +1 -1
  159. package/dist/{runtime-CiGC1spO.d.mts → runtime-BNtp1bfZ.d.mts} +3 -3
  160. package/dist/{runtime-CiGC1spO.d.mts.map → runtime-BNtp1bfZ.d.mts.map} +1 -1
  161. package/dist/runtime.d.mts +3 -3
  162. package/dist/runtime.mjs +3 -3
  163. package/dist/{schema-differ-DpG_gnur-BgbN2De2.d.mts → schema-differ-DpG_gnur-BYIE9qrd.d.mts} +5 -5
  164. package/dist/{schema-differ-DpG_gnur-BgbN2De2.d.mts.map → schema-differ-DpG_gnur-BYIE9qrd.d.mts.map} +1 -1
  165. package/dist/schema-ir.d.mts +1 -1
  166. package/dist/schema-ir.mjs +1 -1
  167. package/dist/schema-ir__naming.d.mts +2 -2
  168. package/dist/schema-ir__naming.mjs +2 -2
  169. package/dist/schema-ir__types.d.mts +2 -2
  170. package/dist/schema-ir__types.mjs +1 -1
  171. package/dist/{schema-verify-C_PEdlAr-JK3UgFWU.mjs → schema-verify-C_PEdlAr-CIgsqZ4M.mjs} +2 -2
  172. package/dist/{schema-verify-C_PEdlAr-JK3UgFWU.mjs.map → schema-verify-C_PEdlAr-CIgsqZ4M.mjs.map} +1 -1
  173. package/dist/{serialized-index-B6udRZV1-Ciet0tVA.mjs → serialized-index-BhiuLIBO-CRf7KRr_.mjs} +4 -4
  174. package/dist/{serialized-index-B6udRZV1-Ciet0tVA.mjs.map → serialized-index-BhiuLIBO-CRf7KRr_.mjs.map} +1 -1
  175. package/dist/{serialized-index-CvprUx-6-CX0DYGLe.d.mts → serialized-index-CEzaHjsj-DM-61QzZ.d.mts} +4 -4
  176. package/dist/serialized-index-CEzaHjsj-DM-61QzZ.d.mts.map +1 -0
  177. package/dist/{sql-contract-serializer-2oBWuxTe-Bp9QfUjI.mjs → sql-contract-serializer-2oBWuxTe-UyjGkOIq.mjs} +4 -4
  178. package/dist/{sql-contract-serializer-2oBWuxTe-Bp9QfUjI.mjs.map → sql-contract-serializer-2oBWuxTe-UyjGkOIq.mjs.map} +1 -1
  179. package/dist/{sql-execution-plan-Da_d82pz-g3khvnbo.d.mts → sql-execution-plan-qxvHnFcA-eC6n5Ek9.d.mts} +3 -3
  180. package/dist/sql-execution-plan-qxvHnFcA-eC6n5Ek9.d.mts.map +1 -0
  181. package/dist/{sql-index-DsI8HAeK-SazZYeA2.d.mts → sql-index-DsI8HAeK-DsSFxBGF.d.mts} +2 -2
  182. package/dist/{sql-index-DsI8HAeK-SazZYeA2.d.mts.map → sql-index-DsI8HAeK-DsSFxBGF.d.mts.map} +1 -1
  183. package/dist/{sql-storage-aEsH6Fnv-_bWH3uY3.d.mts → sql-storage-DCUlYs47-Cosit03s.d.mts} +3 -3
  184. package/dist/{sql-storage-aEsH6Fnv-_bWH3uY3.d.mts.map → sql-storage-DCUlYs47-Cosit03s.d.mts.map} +1 -1
  185. package/dist/{storage-table-BcDudZC5-DZNZhjf2.mjs → storage-table-BDY-lx9O-t7-IoZ2B.mjs} +4 -3
  186. package/dist/{storage-table-BcDudZC5-DZNZhjf2.mjs.map → storage-table-BDY-lx9O-t7-IoZ2B.mjs.map} +1 -1
  187. package/dist/{storage-table-BTVeIKBx-Ba6wCjG5.d.mts → storage-table-DBbCqpt7-PAuyeZA6.d.mts} +8 -4
  188. package/dist/storage-table-DBbCqpt7-PAuyeZA6.d.mts.map +1 -0
  189. package/dist/types-BgOhriVC.d.mts +1 -0
  190. package/dist/{types-UhDfY1iX-C5wOQ0D5.mjs → types-Bj2O1m67-BLTU_6HK.mjs} +3 -3
  191. package/dist/{types-UhDfY1iX-C5wOQ0D5.mjs.map → types-Bj2O1m67-BLTU_6HK.mjs.map} +1 -1
  192. package/dist/{types-D-_2ZCos-9q6j1gKx.mjs → types-CSP6WmWn-DVuxsZJW.mjs} +35 -4
  193. package/dist/types-CSP6WmWn-DVuxsZJW.mjs.map +1 -0
  194. package/dist/{types-BpPwiK2b-DCMVWQ_F.d.mts → types-CYq2Cbzw-xEntZSCk.d.mts} +6 -6
  195. package/dist/{types-BpPwiK2b-DCMVWQ_F.d.mts.map → types-CYq2Cbzw-xEntZSCk.d.mts.map} +1 -1
  196. package/dist/types-DEBm1lFa.d.mts +1 -0
  197. package/dist/{types-CuvwcWTE.mjs → types-DHzMt9jy.mjs} +2 -2
  198. package/dist/{types-CuvwcWTE.mjs.map → types-DHzMt9jy.mjs.map} +1 -1
  199. package/dist/{types-dD8JJfeD-CS9uMlzW.d.mts → types-Dkm5SRCi-DOcQZ0KX.d.mts} +11 -11
  200. package/dist/{types-dD8JJfeD-CS9uMlzW.d.mts.map → types-Dkm5SRCi-DOcQZ0KX.d.mts.map} +1 -1
  201. package/dist/{types-C1F8xk0m-7rMwgIR6.d.mts → types-DtDXwS0i-BjB1HLTY.d.mts} +3 -3
  202. package/dist/{types-C1F8xk0m-7rMwgIR6.d.mts.map → types-DtDXwS0i-BjB1HLTY.d.mts.map} +1 -1
  203. package/dist/{types-BL_h3id0.d.mts → types-DuriYH5B.d.mts} +6 -6
  204. package/dist/{types-BL_h3id0.d.mts.map → types-DuriYH5B.d.mts.map} +1 -1
  205. package/dist/{types-IqZMLrFC-CcORLTOK.d.mts → types-IqZMLrFC-oV8-d-Fc.d.mts} +9 -9
  206. package/dist/{types-IqZMLrFC-CcORLTOK.d.mts.map → types-IqZMLrFC-oV8-d-Fc.d.mts.map} +1 -1
  207. package/dist/{types-BwePDa3m-CrVQ_8YI.d.mts → types-ZzeQKmYD-PJlaIsww.d.mts} +10 -4
  208. package/dist/types-ZzeQKmYD-PJlaIsww.d.mts.map +1 -0
  209. package/dist/{validators-w7IJlTcR.mjs → validators-Bgam9aM2.mjs} +0 -0
  210. package/dist/{validators-w7IJlTcR.mjs.map → validators-Bgam9aM2.mjs.map} +1 -1
  211. package/dist/{validators-Bl1TVj5n.d.mts → validators-CMi9UZNw.d.mts} +4 -3
  212. package/dist/validators-CMi9UZNw.d.mts.map +1 -0
  213. package/package.json +18 -18
  214. package/dist/aggregate-descriptor-registry-DPV4z8MS.mjs.map +0 -1
  215. package/dist/ast-DDAyIKdt.mjs.map +0 -1
  216. package/dist/codec-types-B_xmJL2m-CC_Q-_u9.mjs +0 -24
  217. package/dist/codec-types-B_xmJL2m-CC_Q-_u9.mjs.map +0 -1
  218. package/dist/contract-builder-DQ02XiKy.mjs.map +0 -1
  219. package/dist/control-adapter-BjSrEp2V.d.mts +0 -1
  220. package/dist/db-B5PMfDDd-ZnA9Kuky.d.mts.map +0 -1
  221. package/dist/derived-checks-BDG-r9XD-CrpFUaO7.mjs.map +0 -1
  222. package/dist/entity-kinds-3IFQq7Ho-DB6IN-V6.mjs.map +0 -1
  223. package/dist/interpreter-5WgpL-ax-BIbrd_Xv.mjs.map +0 -1
  224. package/dist/middleware-B8QoWWIx.d.mts +0 -1
  225. package/dist/naming-CEGRBbyW-BOa9Eun0.mjs.map +0 -1
  226. package/dist/naming-DvlNocom-ClcApdiR.d.mts.map +0 -1
  227. package/dist/plan-Bmp5R9sq-mVFXvLM7.d.mts.map +0 -1
  228. package/dist/plan-Cl6aCuij.d.mts +0 -2
  229. package/dist/query-lane-context-BhDJZFMh.d.mts +0 -1
  230. package/dist/query-lane-context-DjyAyYht-DdovdGjc.d.mts.map +0 -1
  231. package/dist/serialized-index-CvprUx-6-CX0DYGLe.d.mts.map +0 -1
  232. package/dist/sql-execution-plan-Da_d82pz-g3khvnbo.d.mts.map +0 -1
  233. package/dist/storage-table-BTVeIKBx-Ba6wCjG5.d.mts.map +0 -1
  234. package/dist/types--gTlnnvl.d.mts +0 -1
  235. package/dist/types-BwePDa3m-CrVQ_8YI.d.mts.map +0 -1
  236. package/dist/types-C-KBovJY.d.mts +0 -1
  237. package/dist/types-D-_2ZCos-9q6j1gKx.mjs.map +0 -1
  238. package/dist/validators-Bl1TVj5n.d.mts.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { t as resolveStorageTable } from "./resolve-storage-table-DZsfnzeW.mjs";
2
2
  import { i as isUniqueConstraintViolation } from "./dist-x6jvtkKM.mjs";
3
- import { B as isWhereExpr, C as LiteralExpr, D as OrExpr, F as SubqueryExpr, I as TableSource, L as UpdateAst, O as OrderByItem, P as SelectAst, R as WindowFuncExpr, S as ListExpression, T as NullCheckExpr, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, j as ProjectionItem, k as ParamRef, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as NotExpr, x as JsonObjectExpr, y as JoinAst } from "./types-D-_2ZCos-9q6j1gKx.mjs";
3
+ import { C as LiteralExpr, D as OrExpr, F as SubqueryExpr, I as TableSource, L as UpdateAst, O as OrderByItem, P as SelectAst, R as WindowFuncExpr, S as ListExpression, T as NullCheckExpr, U as isWhereExpr, V as isAggregateFn, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, j as ProjectionItem, k as ParamRef, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as NotExpr, x as JsonObjectExpr, y as JoinAst } from "./types-CSP6WmWn-DVuxsZJW.mjs";
4
4
  import { t as collectOrderedParamRefs } from "./util-DQQgv2j1-D6INZaRG.mjs";
5
- import { n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection } from "./ast-DDAyIKdt.mjs";
6
- import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-BK_ZTP-3.mjs";
5
+ import { n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection } from "./ast-B-eeN74F.mjs";
6
+ import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-BQPj9q8O.mjs";
7
7
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
8
8
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
9
9
  import { domainModelsAtDefaultNamespace } from "@prisma/orm-framework/contract/types";
@@ -12,6 +12,26 @@ import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
12
12
  import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
13
13
  import { AsyncIterableResult, createMetaBuilder, isRuntimeError, runtimeError } from "@prisma/orm-framework/components/runtime";
14
14
  //#region ../../../3-extensions/sql-orm-client/dist/index.mjs
15
+ const operationNamesByRegistry = /* @__PURE__ */ new WeakMap();
16
+ /**
17
+ * The operation vocabulary the composed registry contributes, in contribution
18
+ * order — the runtime mirror of the contract's emitted aggregate map, both
19
+ * settled from the same contributed descriptors. Cached per registry: the set
20
+ * is fixed at composition time, and every collection construction reads it.
21
+ */
22
+ function aggregateOperationNames(registry) {
23
+ const cached = operationNamesByRegistry.get(registry);
24
+ if (cached !== void 0) return cached;
25
+ const names = [];
26
+ const seen = /* @__PURE__ */ new Set();
27
+ for (const { operation } of registry.values()) {
28
+ if (seen.has(operation)) continue;
29
+ seen.add(operation);
30
+ names.push(operation);
31
+ }
32
+ operationNamesByRegistry.set(registry, names);
33
+ return names;
34
+ }
15
35
  function ormError(code, message, options) {
16
36
  return structuredError(code, message, options);
17
37
  }
@@ -343,70 +363,31 @@ function capabilityEnabled(value) {
343
363
  function isToOneCardinality(cardinality) {
344
364
  return cardinality === "1:1" || cardinality === "N:1";
345
365
  }
346
- function createAggregateBuilder(contract, namespaceId, modelName) {
366
+ /**
367
+ * The aggregate selector methods, one per operation the registry contributes —
368
+ * the runtime mirror of the contract's emitted aggregate map, which is what
369
+ * types the surface as {@link AggregateBuilder}. Each method builds a selector
370
+ * carrying the operation's name and, for a field-taking call, the field's
371
+ * storage column; what a selector resolves to is the plan compiler's question
372
+ * to the same registry.
373
+ */
374
+ function createAggregateBuilder(contract, aggregates, namespaceId, modelName) {
347
375
  const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
348
- return {
349
- count() {
350
- return {
351
- kind: "aggregate",
352
- fn: "count"
353
- };
354
- },
355
- sum(field) {
356
- return createFieldAggregateSelector(fieldToColumn, field, "sum");
357
- },
358
- avg(field) {
359
- return createFieldAggregateSelector(fieldToColumn, field, "avg");
360
- },
361
- min(field) {
362
- return createFieldAggregateSelector(fieldToColumn, field, "min");
363
- },
364
- max(field) {
365
- return createFieldAggregateSelector(fieldToColumn, field, "max");
366
- }
376
+ const builder = {};
377
+ for (const operation of aggregateOperationNames(aggregates)) builder[operation] = (field) => {
378
+ const column = field === void 0 ? void 0 : fieldToColumn[field] ?? field;
379
+ return {
380
+ kind: "aggregate",
381
+ fn: operation,
382
+ ...ifDefined("column", column)
383
+ };
367
384
  };
385
+ return blindCast(builder);
368
386
  }
369
387
  function isAggregateSelector(value) {
370
388
  if (!value || typeof value !== "object") return false;
371
389
  const candidate = value;
372
- if (candidate.kind !== "aggregate") return false;
373
- return candidate.fn === "count" || candidate.fn === "sum" || candidate.fn === "avg" || candidate.fn === "min" || candidate.fn === "max";
374
- }
375
- /**
376
- * The selector's result type is the contract's to state — it varies by target, operation, and the field's own codec — so the builder erases it here and each method's declared return type names it.
377
- */
378
- function createFieldAggregateSelector(fieldToColumn, field, fn) {
379
- return {
380
- kind: "aggregate",
381
- fn,
382
- column: fieldToColumn[field] ?? field
383
- };
384
- }
385
- /**
386
- * What an aggregate reads as when there is no row to read at all.
387
- *
388
- * SQL answers an empty input set itself — `count` collapses to zero, the rest
389
- * to null — so this covers only the degenerate case of a result set with no
390
- * row: an absent aggregate alias, or an include whose envelope never arrived.
391
- * Zero is a `bigint` because that is what both targets' `count` codecs decode
392
- * to; a count is a cardinality, and cardinalities are not capped at 2^53.
393
- */
394
- function emptyAggregateResult(fn) {
395
- return fn === "count" ? 0n : null;
396
- }
397
- function mapFieldsToColumns(contract, namespaceId, modelName, fieldNames) {
398
- const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
399
- return fieldNames.map((fieldName) => fieldToColumn[fieldName] ?? fieldName);
400
- }
401
- function mapCursorValuesToColumns(contract, namespaceId, modelName, cursorValues) {
402
- const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
403
- const mappedCursor = {};
404
- for (const [fieldName, value] of Object.entries(cursorValues)) {
405
- if (value === void 0) continue;
406
- const columnName = fieldToColumn[fieldName] ?? fieldName;
407
- mappedCursor[columnName] = value;
408
- }
409
- return mappedCursor;
390
+ return candidate.kind === "aggregate" && typeof candidate.fn === "string";
410
391
  }
411
392
  /**
412
393
  * What an aggregate resolves to: the codec its result carries, and the expression the target wants built for it.
@@ -421,13 +402,20 @@ function resolveAggregate(query) {
421
402
  if (resolved === void 0) throw unsupportedAggregate(query, input);
422
403
  return {
423
404
  codec: resolved.output,
405
+ nullable: resolved.nullable,
424
406
  input,
425
407
  lower: resolved.lower
426
408
  };
427
409
  }
428
- /** The codec an aggregate's result carries. Rejects a pair the composed stack declares no overload for, exactly as planning does. */
429
- function resolveAggregateOutputCodec(query) {
430
- return resolveAggregate(query).codec;
410
+ /**
411
+ * The plain SQL form of an operation in the closed aggregate alphabet.
412
+ * Registry composition guarantees every operation outside the alphabet
413
+ * carries a lowering hook, so a resolution without one for any other name is
414
+ * a composition bug, not a user error.
415
+ */
416
+ function plainAggregateExpr(fn, expr) {
417
+ if (!isAggregateFn(fn)) throw new InternalError(`aggregate operation '${fn}' is outside the SQL aggregate alphabet and resolved without a lowering hook`);
418
+ return new AggregateExpr(fn, expr);
431
419
  }
432
420
  function unsupportedAggregate(query, input) {
433
421
  return ormError("ORM.AGGREGATE_UNSUPPORTED", input === void 0 ? `The composed target declares no '${query.fn}' aggregate for a call without an input.` : `The composed target declares no '${query.fn}' aggregate over codec '${input.codecId}' (column '${query.column}' of table '${query.tableName}').`, {
@@ -445,6 +433,36 @@ function unsupportedAggregate(query, input) {
445
433
  function inputCodecRef(query) {
446
434
  return query.column === void 0 ? void 0 : codecRefForStorageColumn(query.contract.storage, query.namespaceId, query.tableName, query.column);
447
435
  }
436
+ /**
437
+ * What an aggregate reads as when there is no row to read at all.
438
+ *
439
+ * SQL answers an empty input set itself — a nullable-declared aggregate
440
+ * collapses to NULL, a non-nullable one to a value SQL still produces, a
441
+ * count's zero cardinality — so this covers only the degenerate case of a
442
+ * result set with no row: an absent aggregate alias, or an include whose
443
+ * envelope never arrived. The answer reads off the operation's declared row:
444
+ * NULL where the row is nullable, else zero decoded through the declared
445
+ * output codec — from canonical decimal text, the JSON form the wide-integer
446
+ * codecs a non-nullable aggregate carries read — so the application sees the
447
+ * same value shape a real row would produce.
448
+ */
449
+ function emptyAggregateResult(nullable, codec) {
450
+ return nullable ? null : codec.decodeJson("0");
451
+ }
452
+ function mapFieldsToColumns(contract, namespaceId, modelName, fieldNames) {
453
+ const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
454
+ return fieldNames.map((fieldName) => fieldToColumn[fieldName] ?? fieldName);
455
+ }
456
+ function mapCursorValuesToColumns(contract, namespaceId, modelName, cursorValues) {
457
+ const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
458
+ const mappedCursor = {};
459
+ for (const [fieldName, value] of Object.entries(cursorValues)) {
460
+ if (value === void 0) continue;
461
+ const columnName = fieldToColumn[fieldName] ?? fieldName;
462
+ mappedCursor[columnName] = value;
463
+ }
464
+ return mappedCursor;
465
+ }
448
466
  function stripHiddenMappedFields(contract, namespaceId, modelName, mapped, hiddenColumns) {
449
467
  if (hiddenColumns.length === 0) return;
450
468
  const columnToField = getColumnToFieldMap(contract, namespaceId, modelName);
@@ -611,7 +629,7 @@ function toAggregateProjection(contract, aggregates, namespaceId, tableName, sel
611
629
  expr: lower !== void 0 ? lower({
612
630
  expr: inputExpr,
613
631
  inputCodec
614
- }) : new AggregateExpr(selector.fn, inputExpr),
632
+ }) : plainAggregateExpr(selector.fn, inputExpr),
615
633
  codec
616
634
  };
617
635
  }
@@ -1579,7 +1597,7 @@ function buildIncludeAggregateExpr(scalar, childTableRef, lower, inputCodec) {
1579
1597
  expr,
1580
1598
  inputCodec
1581
1599
  });
1582
- return new AggregateExpr(scalar.fn, expr);
1600
+ return plainAggregateExpr(scalar.fn, expr);
1583
1601
  }
1584
1602
  /**
1585
1603
  * Build the inner SELECT for a `combine({ a, b, ... })` include.
@@ -2121,9 +2139,8 @@ function describeEnvelopeShape(value) {
2121
2139
  *
2122
2140
  * Contract: the envelope is always either
2123
2141
  * - a `{ value: <primitive> }` JSON object (the SQL path), or
2124
- * - `null` / `undefined` (the mutation read-back's
2125
- * `assignEmptyMutationIncludes` short-circuit before this decoder
2126
- * runs, for a parent absent from the read-back result).
2142
+ * - `null` / `undefined` (the mutation read-back's empty-include
2143
+ * short-circuit, for a parent absent from the read-back result).
2127
2144
  *
2128
2145
  * Any other shape — array, primitive, string that JSON-parses to
2129
2146
  * non-object — indicates a planner / decoder bug, so we throw
@@ -2132,21 +2149,16 @@ function describeEnvelopeShape(value) {
2132
2149
  *
2133
2150
  * The value passes through its own codec — the one the planner projected it
2134
2151
  * under — because it arrived inside a JSON document, where a count past 2^53
2135
- * would otherwise have been read as a rounded number. SQL semantics drive the
2136
- * empty-relation case: `COUNT(*)` over an empty input set is `0`;
2137
- * `SUM` / `AVG` / `MIN` / `MAX` over an empty input set return SQL
2138
- * `NULL`, which surfaces as `null` here. The outer `raw === null`
2139
- * fallback is defensive cover for an empty parent set; in single-query
2140
- * dispatch the correlated subquery always produces a row, so the inner
2141
- * envelope's `value` is always set by SQL.
2152
+ * would otherwise have been read as a rounded number. Resolution mirrors
2153
+ * planning the same registry, operation, and column so the empty-relation
2154
+ * answer derives from the operation's declared row: NULL where the row is
2155
+ * nullable, else the operation's zero. The outer `raw === null` fallback is
2156
+ * defensive cover for an empty parent set; in single-query dispatch the
2157
+ * correlated subquery always produces a row, so the inner envelope's `value`
2158
+ * is always set by SQL.
2142
2159
  */
2143
2160
  function decodeScalarIncludePayload(contract, context, include, scalar, raw) {
2144
- if (raw === null || raw === void 0) return emptyAggregateResult(scalar.fn);
2145
- const parsed = parseIncludePayload(raw);
2146
- 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.`);
2147
- const value = parsed["value"];
2148
- if (value === null || value === void 0) return emptyAggregateResult(scalar.fn);
2149
- const codecRef = resolveAggregateOutputCodec({
2161
+ const resolved = resolveAggregate({
2150
2162
  aggregates: context.aggregateDescriptors,
2151
2163
  contract,
2152
2164
  namespaceId: include.relatedNamespaceId,
@@ -2154,10 +2166,16 @@ function decodeScalarIncludePayload(contract, context, include, scalar, raw) {
2154
2166
  fn: scalar.fn,
2155
2167
  column: scalar.column
2156
2168
  });
2169
+ const codec = context.contractCodecs.forCodecRef(resolved.codec);
2170
+ if (raw === null || raw === void 0) return emptyAggregateResult(resolved.nullable, codec);
2171
+ const parsed = parseIncludePayload(raw);
2172
+ 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.`);
2173
+ const value = parsed["value"];
2174
+ if (value === null || value === void 0) return emptyAggregateResult(resolved.nullable, codec);
2157
2175
  return decodeIncludedJsonValue({
2158
2176
  table: include.relatedTableName,
2159
2177
  column: include.relationName
2160
- }, codecRef.codecId, context.contractCodecs.forCodecRef(codecRef), value);
2178
+ }, resolved.codec.codecId, codec, value);
2161
2179
  }
2162
2180
  function parseIncludedRows(include, value) {
2163
2181
  if (value === null || value === void 0) return [];
@@ -2328,7 +2346,7 @@ var GroupedCollection = class GroupedCollection {
2328
2346
  this.havingFilters = options.havingFilters;
2329
2347
  }
2330
2348
  having(predicate) {
2331
- const havingExpr = predicate(createHavingBuilder(this.contract, this.namespaceId, this.modelName, this.tableName));
2349
+ const havingExpr = predicate(createHavingBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName, this.tableName));
2332
2350
  return new GroupedCollection(this.ctx, this.modelName, {
2333
2351
  tableName: this.tableName,
2334
2352
  namespaceId: this.namespaceId,
@@ -2346,7 +2364,7 @@ var GroupedCollection = class GroupedCollection {
2346
2364
  * Annotations are merged into the compiled plan's `meta.annotations`.
2347
2365
  */
2348
2366
  async aggregate(fn, configure) {
2349
- const aggregateSpec = fn(createAggregateBuilder(this.contract, this.namespaceId, this.modelName));
2367
+ const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
2350
2368
  const aggregateEntries = Object.entries(aggregateSpec);
2351
2369
  if (aggregateEntries.length === 0) throw ormError("ORM.AGGREGATE_SELECTOR_MISSING", "groupBy().aggregate() requires at least one aggregation selector", { meta: {
2352
2370
  method: "groupBy.aggregate",
@@ -2371,26 +2389,28 @@ var GroupedCollection = class GroupedCollection {
2371
2389
  });
2372
2390
  }
2373
2391
  };
2374
- function createHavingBuilder(contract, namespaceId, modelName, tableName) {
2392
+ /**
2393
+ * The having metric methods, one per operation the registry contributes —
2394
+ * the runtime mirror of the contract's emitted aggregate map, which is what
2395
+ * types the surface as {@link HavingBuilder}. HAVING compares the value
2396
+ * inside the database, so only an operation's plain `AggregateExpr` form is
2397
+ * sound here: an operation outside the SQL aggregate alphabet exists only in
2398
+ * its descriptor-lowered form — a rendering for the driver boundary — and is
2399
+ * refused. The typed surface already excludes it; the runtime refusal covers
2400
+ * dynamic invocation.
2401
+ */
2402
+ function createHavingBuilder(contract, aggregates, namespaceId, modelName, tableName) {
2375
2403
  const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
2376
- const createMetricExpr = (fn, fieldName) => new AggregateExpr(fn, ColumnRef.of(tableName, fieldToColumn[fieldName] ?? fieldName));
2377
- return {
2378
- count() {
2379
- return createHavingComparisonMethods(AggregateExpr.count());
2380
- },
2381
- sum(field) {
2382
- return createHavingComparisonMethods(createMetricExpr("sum", field));
2383
- },
2384
- avg(field) {
2385
- return createHavingComparisonMethods(createMetricExpr("avg", field));
2386
- },
2387
- min(field) {
2388
- return createHavingComparisonMethods(createMetricExpr("min", field));
2389
- },
2390
- max(field) {
2391
- return createHavingComparisonMethods(createMetricExpr("max", field));
2392
- }
2404
+ const builder = {};
2405
+ for (const operation of aggregateOperationNames(aggregates)) builder[operation] = (field) => {
2406
+ if (!isAggregateFn(operation)) throw ormError("ORM.AGGREGATE_PROJECTION_ONLY", `Aggregate operation '${operation}' is projection-only: it has no plain SQL form for HAVING, ORDER BY, or comparison positions.`, {
2407
+ why: "An operation outside the SQL aggregate alphabet reaches SQL only through its descriptor's lowering hook — a rendering for the driver boundary. HAVING and ORDER BY compare the value inside the database, where that rendering would change SQL semantics.",
2408
+ fix: `Project '${operation}' in a select and filter or order on the projected value, or use an operation from the SQL aggregate alphabet.`,
2409
+ meta: { operation }
2410
+ });
2411
+ return createHavingComparisonMethods(new AggregateExpr(operation, field === void 0 ? void 0 : ColumnRef.of(tableName, fieldToColumn[field] ?? field)));
2393
2412
  };
2413
+ return blindCast(builder);
2394
2414
  }
2395
2415
  function createHavingComparisonMethods(metric) {
2396
2416
  const buildBinaryExpr = (op, value) => new BinaryExpr(op, metric, LiteralExpr.of(value));
@@ -2415,13 +2435,6 @@ function createHavingComparisonMethods(metric) {
2415
2435
  }
2416
2436
  };
2417
2437
  }
2418
- const aggregateFns = /* @__PURE__ */ new Set([
2419
- "count",
2420
- "sum",
2421
- "avg",
2422
- "min",
2423
- "max"
2424
- ]);
2425
2438
  function createIncludeScalar(fn, state, column) {
2426
2439
  return {
2427
2440
  kind: "includeScalar",
@@ -2439,7 +2452,7 @@ function createIncludeCombine(branches) {
2439
2452
  function isIncludeScalar(value) {
2440
2453
  if (typeof value !== "object" || value === null) return false;
2441
2454
  const candidate = value;
2442
- return candidate.kind === "includeScalar" && typeof candidate.fn === "string" && aggregateFns.has(candidate.fn) && isCollectionState(candidate.state);
2455
+ return candidate.kind === "includeScalar" && typeof candidate.fn === "string" && isCollectionState(candidate.state);
2443
2456
  }
2444
2457
  function isIncludeCombine(value) {
2445
2458
  if (typeof value !== "object" || value === null) return false;
@@ -3332,7 +3345,7 @@ function isWhereDirectInput(value) {
3332
3345
  function isMtiVariantInfo(variant) {
3333
3346
  return variant?.strategy === "mti";
3334
3347
  }
3335
- var Collection = class Collection {
3348
+ var CollectionImpl = class CollectionImpl {
3336
3349
  /** @internal */
3337
3350
  ctx;
3338
3351
  /** @internal */
@@ -3358,6 +3371,49 @@ var Collection = class Collection {
3358
3371
  this.state = options.state ?? emptyState();
3359
3372
  this.registry = options.registry ?? /* @__PURE__ */ new Map();
3360
3373
  this.includeRefinementMode = options.includeRefinementMode ?? false;
3374
+ this.#installAggregateReducers();
3375
+ }
3376
+ /**
3377
+ * Install one include-scalar reducer per operation the composed registry
3378
+ * contributes — the runtime mirror of the contract's emitted aggregate map,
3379
+ * which is what types the reducers as {@link AggregateIncludeReducers} on
3380
+ * the public {@link Collection} surface. The reducers live on the instance
3381
+ * because their names are the registry's, not the class declaration's.
3382
+ *
3383
+ * A name the collection already carries is skipped, and which member holds
3384
+ * it decides what the skip means. A `CollectionImpl` member is rejected at
3385
+ * ORM composition with `ORM.AGGREGATE_OPERATION_RESERVED`, since
3386
+ * {@link reservedCollectionMemberNames} scans this class. A member declared
3387
+ * by a custom collection class registered through `orm({ collections })`
3388
+ * falls outside that set, so it keeps the name and the operation gets no
3389
+ * reducer. The type level is what guards that case: {@link Collection}
3390
+ * intersects the class with {@link AggregateIncludeReducers}, so for any
3391
+ * contract whose emitted map carries the operation, a subclass member that
3392
+ * does not match the reducer's signature is a type error.
3393
+ */
3394
+ #installAggregateReducers() {
3395
+ for (const operation of aggregateOperationNames(this.ctx.context.aggregateDescriptors)) {
3396
+ if (operation in this) continue;
3397
+ Object.defineProperty(this, operation, {
3398
+ value: (field) => this.#includeScalarReducer(operation, field),
3399
+ writable: true,
3400
+ enumerable: false,
3401
+ configurable: true
3402
+ });
3403
+ }
3404
+ }
3405
+ /**
3406
+ * Scalar reducer — reduces a to-many relation to the operation's value over
3407
+ * the related rows. Use inside an `include(...)` refinement callback as
3408
+ * `include(..., (rel) => rel.count())`; throws if called elsewhere. The
3409
+ * parent row's relation field becomes that value instead of an array. A
3410
+ * call without a field aggregates over rows; a call with one aggregates the
3411
+ * field's storage column.
3412
+ */
3413
+ #includeScalarReducer(operation, field) {
3414
+ this.#assertIncludeRefinementMode(`${operation}()`);
3415
+ const column = field === void 0 ? void 0 : resolveFieldToColumn(this.contract, this.namespaceId, this.modelName, field);
3416
+ return createIncludeScalar(operation, this.state, column);
3361
3417
  }
3362
3418
  where(input) {
3363
3419
  const filter = normalizeWhereArg(typeof input === "function" ? input(createModelAccessor(this.ctx.context, this.namespaceId, this.modelName, this.state.variantName)) : isWhereDirectInput(input) ? input : shorthandToWhereExpr(this.ctx.context, this.namespaceId, this.modelName, input), {
@@ -3539,84 +3595,6 @@ var Collection = class Collection {
3539
3595
  });
3540
3596
  }
3541
3597
  /**
3542
- * Scalar reducer — reduces a to-many relation to the number of
3543
- * related rows. Use inside an `include(...)` refinement callback as
3544
- * `include(..., (rel) => rel.count())`; throws if called elsewhere.
3545
- * The parent row's relation field becomes that count instead of an
3546
- * array.
3547
- *
3548
- * ```typescript
3549
- * const users = await db.orm.User.include('posts', (posts) => posts.count()).all();
3550
- * // each user row: { ...user, posts: bigint }
3551
- * ```
3552
- */
3553
- count() {
3554
- this.#assertIncludeRefinementMode("count()");
3555
- return createIncludeScalar("count", this.state);
3556
- }
3557
- /**
3558
- * Scalar reducer — reduces a to-many relation to the sum of `field`
3559
- * across related rows. Returns `null` when there are no related
3560
- * rows. Use inside an `include(...)` refinement callback; throws if
3561
- * called elsewhere.
3562
- *
3563
- * ```typescript
3564
- * const users = await db.orm.User.include('posts', (posts) => posts.sum('views')).all();
3565
- * // each user row: { ...user, posts: bigint | null } — an int4 column's sum widens to int8
3566
- * ```
3567
- */
3568
- sum(field) {
3569
- this.#assertIncludeRefinementMode("sum()");
3570
- const columnName = resolveFieldToColumn(this.contract, this.namespaceId, this.modelName, field);
3571
- return createIncludeScalar("sum", this.state, columnName);
3572
- }
3573
- /**
3574
- * Scalar reducer — reduces a to-many relation to the average of
3575
- * `field` across related rows. Returns `null` when there are no
3576
- * related rows. Use inside an `include(...)` refinement callback;
3577
- * throws if called elsewhere.
3578
- *
3579
- * ```typescript
3580
- * const users = await db.orm.User.include('posts', (posts) => posts.avg('views')).all();
3581
- * // each user row: { ...user, posts: string | null } — PostgreSQL averages integers as numeric
3582
- * ```
3583
- */
3584
- avg(field) {
3585
- this.#assertIncludeRefinementMode("avg()");
3586
- const columnName = resolveFieldToColumn(this.contract, this.namespaceId, this.modelName, field);
3587
- return createIncludeScalar("avg", this.state, columnName);
3588
- }
3589
- /**
3590
- * Scalar reducer — reduces a to-many relation to the minimum value
3591
- * of `field` across related rows. Returns `null` when there are no
3592
- * related rows. Use inside an `include(...)` refinement callback;
3593
- * throws if called elsewhere.
3594
- *
3595
- * ```typescript
3596
- * const users = await db.orm.User.include('posts', (posts) => posts.min('views')).all();
3597
- * ```
3598
- */
3599
- min(field) {
3600
- this.#assertIncludeRefinementMode("min()");
3601
- const columnName = resolveFieldToColumn(this.contract, this.namespaceId, this.modelName, field);
3602
- return createIncludeScalar("min", this.state, columnName);
3603
- }
3604
- /**
3605
- * Scalar reducer — reduces a to-many relation to the maximum value
3606
- * of `field` across related rows. Returns `null` when there are no
3607
- * related rows. Use inside an `include(...)` refinement callback;
3608
- * throws if called elsewhere.
3609
- *
3610
- * ```typescript
3611
- * const users = await db.orm.User.include('posts', (posts) => posts.max('views')).all();
3612
- * ```
3613
- */
3614
- max(field) {
3615
- this.#assertIncludeRefinementMode("max()");
3616
- const columnName = resolveFieldToColumn(this.contract, this.namespaceId, this.modelName, field);
3617
- return createIncludeScalar("max", this.state, columnName);
3618
- }
3619
- /**
3620
3598
  * Produce multiple named sub-views of a to-many relation in a
3621
3599
  * single `include(...)`. Each branch is either another refined
3622
3600
  * collection (mapped to a row array on the parent) or a scalar
@@ -3681,7 +3659,7 @@ var Collection = class Collection {
3681
3659
  */
3682
3660
  cursor(cursorValues) {
3683
3661
  const mappedCursor = mapCursorValuesToColumns(this.contract, this.namespaceId, this.modelName, cursorValues);
3684
- if (Object.keys(mappedCursor).length === 0) return this;
3662
+ if (Object.keys(mappedCursor).length === 0) return blindCast(this);
3685
3663
  return this.#clone({ cursor: mappedCursor });
3686
3664
  }
3687
3665
  /**
@@ -3813,7 +3791,7 @@ var Collection = class Collection {
3813
3791
  * Annotations are merged into the compiled plan's `meta.annotations`.
3814
3792
  */
3815
3793
  async aggregate(fn, configure) {
3816
- const aggregateSpec = fn(createAggregateBuilder(this.contract, this.namespaceId, this.modelName));
3794
+ const aggregateSpec = fn(createAggregateBuilder(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.modelName));
3817
3795
  const entries = Object.entries(aggregateSpec);
3818
3796
  if (entries.length === 0) throw ormError("ORM.AGGREGATE_SELECTOR_MISSING", "aggregate() requires at least one aggregation selector", { meta: {
3819
3797
  method: "aggregate",
@@ -3828,7 +3806,7 @@ var Collection = class Collection {
3828
3806
  const compiled = mergeAnnotations(compileAggregate(this.contract, this.ctx.context.aggregateDescriptors, this.namespaceId, this.tableName, this.state.filters, aggregateSpec), annotationsMap);
3829
3807
  const row = (await executeQueryPlan(this.ctx.runtime, compiled).toArray())[0] ?? {};
3830
3808
  const result = {};
3831
- for (const [alias, selector] of entries) result[alias] = row[alias] ?? emptyAggregateResult(selector.fn);
3809
+ for (const [alias, selector] of entries) result[alias] = row[alias] ?? this.#emptyAggregateValue(selector);
3832
3810
  return blindCast(result);
3833
3811
  }
3834
3812
  async create(data, configure) {
@@ -4506,6 +4484,23 @@ var Collection = class Collection {
4506
4484
  namespaceId: this.namespaceId
4507
4485
  }))[0] ?? null;
4508
4486
  }
4487
+ /**
4488
+ * The value an aggregate alias reads as when the result set has no row to
4489
+ * read at all. Resolution mirrors planning — the same registry, operation,
4490
+ * and column — so the answer derives from the operation's declared row
4491
+ * rather than its name.
4492
+ */
4493
+ #emptyAggregateValue(selector) {
4494
+ const resolved = resolveAggregate({
4495
+ aggregates: this.ctx.context.aggregateDescriptors,
4496
+ contract: this.contract,
4497
+ namespaceId: this.namespaceId,
4498
+ tableName: this.tableName,
4499
+ fn: selector.fn,
4500
+ column: selector.column
4501
+ });
4502
+ return emptyAggregateResult(resolved.nullable, this.ctx.context.contractCodecs.forCodecRef(resolved.codec));
4503
+ }
4509
4504
  #assertIncludeRefinementMode(action) {
4510
4505
  if (this.includeRefinementMode) return;
4511
4506
  throw ormError("ORM.INCLUDE_INVALID", `${action} is only available inside include() refinement callbacks`, { meta: { action } });
@@ -4544,7 +4539,7 @@ var Collection = class Collection {
4544
4539
  }));
4545
4540
  }
4546
4541
  #createCollection(modelName, options) {
4547
- return blindCast(new ((this.registry.get(modelName)) ?? (blindCast(Collection)))(this.ctx, modelName, {
4542
+ return blindCast(new ((this.registry.get(modelName)) ?? (blindCast(CollectionImpl)))(this.ctx, modelName, {
4548
4543
  tableName: options.tableName,
4549
4544
  namespaceId: options.namespaceId,
4550
4545
  state: options.state,
@@ -4602,8 +4597,55 @@ var Collection = class Collection {
4602
4597
  return meta.annotations.size === 0 ? void 0 : meta.annotations;
4603
4598
  }
4604
4599
  };
4600
+ const collectionInstanceMemberNames = [
4601
+ "ctx",
4602
+ "contract",
4603
+ "modelName",
4604
+ "tableName",
4605
+ "namespaceId",
4606
+ "state",
4607
+ "registry",
4608
+ "includeRefinementMode"
4609
+ ];
4610
+ /**
4611
+ * Every member name the collection surface owns: the prototype's methods plus
4612
+ * the declared instance fields. A contributed aggregate operation may not
4613
+ * take one of these names — reducers install into the same flat namespace —
4614
+ * so ORM composition rejects any operation this set contains.
4615
+ */
4616
+ function reservedCollectionMemberNames() {
4617
+ return /* @__PURE__ */ new Set([...Object.getOwnPropertyNames(CollectionImpl.prototype), ...collectionInstanceMemberNames]);
4618
+ }
4619
+ const Collection = blindCast(CollectionImpl);
4620
+ /**
4621
+ * The class behind {@link Collection}, for package-internal prototype-chain
4622
+ * checks (`instanceof`) and default construction. The public constructor
4623
+ * surface carries a single construct signature returning the intersection,
4624
+ * which heritage clauses require; the raw class keeps the `Function` shape
4625
+ * those checks need.
4626
+ */
4627
+ const CollectionBase = CollectionImpl;
4628
+ /**
4629
+ * Reject a contributed aggregate operation whose name a collection member
4630
+ * already owns. Aggregate operations surface as reducer methods on the
4631
+ * collection, in one flat namespace with the builder members, so a same-named
4632
+ * operation would shadow the member it collides with — a client-surface
4633
+ * concern, enforced here where that surface is assembled.
4634
+ */
4635
+ function assertAggregateOperationsNotReserved(registry) {
4636
+ const reserved = reservedCollectionMemberNames();
4637
+ for (const operation of aggregateOperationNames(registry)) {
4638
+ if (!reserved.has(operation)) continue;
4639
+ throw ormError("ORM.AGGREGATE_OPERATION_RESERVED", `Aggregate operation '${operation}' is reserved: the name is a collection builder member.`, {
4640
+ why: "Aggregate operations surface as reducer methods on the collection, in one namespace with the query-builder members; a same-named operation would shadow the member it collides with.",
4641
+ fix: "Rename the contributed aggregate operation.",
4642
+ meta: { operation }
4643
+ });
4644
+ }
4645
+ }
4605
4646
  function orm(options) {
4606
4647
  const { runtime, collections, context } = options;
4648
+ assertAggregateOperationsNotReserved(context.aggregateDescriptors);
4607
4649
  const contract = context.contract;
4608
4650
  const ctx = {
4609
4651
  runtime,
@@ -4611,7 +4653,7 @@ function orm(options) {
4611
4653
  };
4612
4654
  const collectionRegistry = createCollectionRegistry(contract, collections);
4613
4655
  function buildCollection(namespaceId, modelName, tableName) {
4614
- return new (blindCast(collectionRegistry.get(modelName) ?? Collection))(ctx, modelName, {
4656
+ return new (blindCast(collectionRegistry.get(modelName) ?? CollectionBase))(ctx, modelName, {
4615
4657
  registry: collectionRegistry,
4616
4658
  namespaceId,
4617
4659
  ...tableName !== void 0 ? { tableName } : {}
@@ -4665,7 +4707,7 @@ function isCollectionClass(value) {
4665
4707
  if (typeof value !== "function") return false;
4666
4708
  const candidate = value;
4667
4709
  if (!candidate.prototype || typeof candidate.prototype !== "object") return false;
4668
- return candidate.prototype instanceof Collection;
4710
+ return candidate.prototype instanceof CollectionBase;
4669
4711
  }
4670
4712
  //#endregion
4671
4713
  export { Collection, GroupedCollection, all, and, createModelAccessor, emptyState, not, or, orm };