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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (564) hide show
  1. package/README.md +2 -6
  2. package/dist/{aggregate-descriptor-registry-C7hel5O7.mjs → aggregate-descriptor-registry-ZrKjxwQe.mjs} +5 -5
  3. package/dist/aggregate-descriptor-registry-ZrKjxwQe.mjs.map +1 -0
  4. package/dist/ast-D0miQ1B6.mjs +372 -0
  5. package/dist/ast-D0miQ1B6.mjs.map +1 -0
  6. package/dist/ast-YEMe_B8z.d.mts +292 -0
  7. package/dist/ast-YEMe_B8z.d.mts.map +1 -0
  8. package/dist/attribute-specs-DA_RwQFB.d.mts +114 -0
  9. package/dist/attribute-specs-DA_RwQFB.d.mts.map +1 -0
  10. package/dist/{authored-check-naming-Hf9990DV.mjs → authored-check-naming-BHGJhjqn.mjs} +5 -5
  11. package/dist/authored-check-naming-BHGJhjqn.mjs.map +1 -0
  12. package/dist/{authored-check-naming-BWBe-PVE.d.mts → authored-check-naming-D-o196ry.d.mts} +3 -3
  13. package/dist/authored-check-naming-D-o196ry.d.mts.map +1 -0
  14. package/dist/authoring-entity-types-CgKIgWq5-pEdfjam5.d.mts +9 -0
  15. package/dist/authoring-entity-types-CgKIgWq5-pEdfjam5.d.mts.map +1 -0
  16. package/dist/builder.d.mts +4 -3
  17. package/dist/builder__runtime.d.mts +29 -31
  18. package/dist/builder__runtime.d.mts.map +1 -1
  19. package/dist/builder__runtime.mjs +261 -191
  20. package/dist/builder__runtime.mjs.map +1 -1
  21. package/dist/builder__types.d.mts +6 -3
  22. package/dist/{canonicalization-hooks-dmXkOR4a.mjs → canonicalization-hooks-Ce1v_TDl.mjs} +2 -2
  23. package/dist/canonicalization-hooks-Ce1v_TDl.mjs.map +1 -0
  24. package/dist/{canonicalization-hooks-CYnW_sGn.d.mts → canonicalization-hooks-DyapQ0my.d.mts} +2 -2
  25. package/dist/canonicalization-hooks-DyapQ0my.d.mts.map +1 -0
  26. package/dist/{check-constraint-B7qGu6rc-HvQjjX82.d.mts → check-constraint-B7qGu6rc-Bk2ezWXu.d.mts} +4 -4
  27. package/dist/check-constraint-B7qGu6rc-Bk2ezWXu.d.mts.map +1 -0
  28. package/dist/{codec-descriptor-registry-N0dhtKaH.mjs → codec-descriptor-registry-CiiFzMtb.mjs} +13 -40
  29. package/dist/codec-descriptor-registry-CiiFzMtb.mjs.map +1 -0
  30. package/dist/collection-methods-BB8YH69u.d.mts +1 -0
  31. package/dist/collection-methods-D2UnCS0S-DOy2qHYS.d.mts +77 -0
  32. package/dist/collection-methods-D2UnCS0S-DOy2qHYS.d.mts.map +1 -0
  33. package/dist/{config-types-D9fdKG3g.d.mts → config-types-C-1mIiJO.d.mts} +5 -5
  34. package/dist/config-types-C-1mIiJO.d.mts.map +1 -0
  35. package/dist/{config-types-gAm54C_v.mjs → config-types-DkEeq_qq.mjs} +10 -6
  36. package/dist/config-types-DkEeq_qq.mjs.map +1 -0
  37. package/dist/{contract-builder-D4a5dT7j.mjs → contract-builder-50lF0kz1.mjs} +431 -226
  38. package/dist/contract-builder-50lF0kz1.mjs.map +1 -0
  39. package/dist/contract-builder-C_Zi57iD.d.mts +1967 -0
  40. package/dist/contract-builder-C_Zi57iD.d.mts.map +1 -0
  41. package/dist/contract-emitter.d.mts +4 -7
  42. package/dist/contract-emitter.d.mts.map +1 -1
  43. package/dist/contract-emitter.mjs +1 -1
  44. package/dist/{contract-errors-BCN6RVI5-5IHBF_lg.mjs → contract-errors-BCN6RVI5-DoH6b_KZ.mjs} +2 -2
  45. package/dist/contract-errors-BCN6RVI5-DoH6b_KZ.mjs.map +1 -0
  46. package/dist/contract-prisma7__provider.d.mts +97 -0
  47. package/dist/contract-prisma7__provider.d.mts.map +1 -0
  48. package/dist/contract-prisma7__provider.mjs +2011 -0
  49. package/dist/contract-prisma7__provider.mjs.map +1 -0
  50. package/dist/contract-psl.d.mts +18 -29
  51. package/dist/contract-psl.d.mts.map +1 -1
  52. package/dist/contract-psl.mjs +1 -1
  53. package/dist/contract-psl__attribute-specs.d.mts +2 -0
  54. package/dist/contract-psl__attribute-specs.mjs +2 -0
  55. package/dist/contract-psl__default-table-name.d.mts +7 -0
  56. package/dist/contract-psl__default-table-name.d.mts.map +1 -0
  57. package/dist/contract-psl__default-table-name.mjs +2 -0
  58. package/dist/contract-psl__diagnostics.d.mts +12 -0
  59. package/dist/contract-psl__diagnostics.d.mts.map +1 -0
  60. package/dist/contract-psl__diagnostics.mjs +2 -0
  61. package/dist/contract-psl__map-names.d.mts +16 -0
  62. package/dist/contract-psl__map-names.d.mts.map +1 -0
  63. package/dist/contract-psl__map-names.mjs +21 -0
  64. package/dist/contract-psl__map-names.mjs.map +1 -0
  65. package/dist/contract-psl__provider.d.mts +3 -3
  66. package/dist/contract-psl__provider.d.mts.map +1 -1
  67. package/dist/contract-psl__provider.mjs +95 -46
  68. package/dist/contract-psl__provider.mjs.map +1 -1
  69. package/dist/contract-ts.d.mts +5 -5
  70. package/dist/contract-ts.mjs +5 -4
  71. package/dist/contract-ts__config-types.d.mts +1 -1
  72. package/dist/contract-ts__config-types.mjs +1 -1
  73. package/dist/contract-ts__contract-builder.d.mts +4 -4
  74. package/dist/contract-ts__contract-builder.mjs +4 -3
  75. package/dist/{contract-view-BMR5IWk4.mjs → contract-view-DqpzeYeE.mjs} +2 -2
  76. package/dist/contract-view-DqpzeYeE.mjs.map +1 -0
  77. package/dist/{contract-view-CPHxoAEX.d.mts → contract-view-DuB35or0.d.mts} +3 -3
  78. package/dist/contract-view-DuB35or0.d.mts.map +1 -0
  79. package/dist/contract.d.mts +30 -28
  80. package/dist/contract.mjs +23 -18
  81. package/dist/contract__authored-check-naming.d.mts +1 -1
  82. package/dist/contract__authored-check-naming.mjs +1 -1
  83. package/dist/contract__canonicalization-hooks.d.mts +1 -1
  84. package/dist/contract__canonicalization-hooks.mjs +1 -1
  85. package/dist/contract__contract-view.d.mts +1 -1
  86. package/dist/contract__contract-view.mjs +1 -1
  87. package/dist/contract__data-type-support.d.mts +2 -0
  88. package/dist/contract__data-type-support.mjs +2 -0
  89. package/dist/contract__data-type.d.mts +2 -0
  90. package/dist/contract__data-type.mjs +3 -0
  91. package/dist/contract__entity-handle-lowering-hook.d.mts +2 -2
  92. package/dist/contract__entity-handle-lowering-hook.mjs +2 -2
  93. package/dist/contract__entity-kinds.d.mts +1 -1
  94. package/dist/contract__entity-kinds.mjs +1 -1
  95. package/dist/contract__factories.d.mts +1 -1
  96. package/dist/contract__factories.mjs +1 -1
  97. package/dist/contract__foreign-key-materialization.d.mts +2 -2
  98. package/dist/contract__foreign-key-materialization.mjs +3 -2
  99. package/dist/contract__index-naming.d.mts +2 -2
  100. package/dist/contract__index-naming.mjs +2 -2
  101. package/dist/contract__index-type-validation.d.mts +2 -2
  102. package/dist/contract__index-type-validation.mjs +1 -1
  103. package/dist/contract__index-types.d.mts +3 -3
  104. package/dist/contract__index-types.mjs +2 -2
  105. package/dist/contract__referential-action-sql.d.mts +1 -1
  106. package/dist/contract__referential-action-sql.mjs +1 -1
  107. package/dist/contract__resolve-storage-table.d.mts +1 -1
  108. package/dist/contract__resolve-storage-table.mjs +1 -1
  109. package/dist/contract__sql-expression.d.mts +2 -0
  110. package/dist/contract__sql-expression.mjs +2 -0
  111. package/dist/contract__types.d.mts +12 -12
  112. package/dist/contract__types.mjs +4 -4
  113. package/dist/contract__validators.d.mts +2 -2
  114. package/dist/contract__validators.mjs +3 -3
  115. package/dist/contract__value-set-derivation-hook.d.mts +1 -1
  116. package/dist/contract__value-set-derivation-hook.mjs +1 -1
  117. package/dist/control-BK50zF6c.mjs +2721 -0
  118. package/dist/control-BK50zF6c.mjs.map +1 -0
  119. package/dist/control-ChAUdOOu.d.mts +1416 -0
  120. package/dist/control-ChAUdOOu.d.mts.map +1 -0
  121. package/dist/{control-adapter-C99J7aEF-B7eQd7vD.d.mts → control-adapter-Bn0uhplA-BzP2uPqJ.d.mts} +27 -44
  122. package/dist/control-adapter-Bn0uhplA-BzP2uPqJ.d.mts.map +1 -0
  123. package/dist/control-adapter-NZ2kKc4x.d.mts +13 -0
  124. package/dist/control-adapter-NZ2kKc4x.d.mts.map +1 -0
  125. package/dist/control-adapter-SlQkTEwT.mjs +16 -0
  126. package/dist/control-adapter-SlQkTEwT.mjs.map +1 -0
  127. package/dist/data-type-BFSpaotu.mjs +52 -0
  128. package/dist/data-type-BFSpaotu.mjs.map +1 -0
  129. package/dist/data-type-DJIvKQHf.d.mts +158 -0
  130. package/dist/data-type-DJIvKQHf.d.mts.map +1 -0
  131. package/dist/data-type-support-BhSoPUFj.mjs +9 -0
  132. package/dist/data-type-support-BhSoPUFj.mjs.map +1 -0
  133. package/dist/data-type-support-CXpA0ex-.d.mts +7 -0
  134. package/dist/data-type-support-CXpA0ex-.d.mts.map +1 -0
  135. package/dist/{db-D18PrXKW-DvTv4JFn.d.mts → db-D1d75IvM-D4mRDC6w.d.mts} +123 -128
  136. package/dist/db-D1d75IvM-D4mRDC6w.d.mts.map +1 -0
  137. package/dist/{ddl-types-CXx4vPz6-BsgrnSUY.d.mts → ddl-types-By5mT2_S-CdaaFvsX.d.mts} +24 -29
  138. package/dist/ddl-types-By5mT2_S-CdaaFvsX.d.mts.map +1 -0
  139. package/dist/default-mapping-CAOONlKQ-4m07nb-O.d.mts +39 -0
  140. package/dist/default-mapping-CAOONlKQ-4m07nb-O.d.mts.map +1 -0
  141. package/dist/default-table-name-BfFY8qYR-CWZFDX6v.mjs +9 -0
  142. package/dist/default-table-name-BfFY8qYR-CWZFDX6v.mjs.map +1 -0
  143. package/dist/derived-checks-D5HVRvqN-BJx1gwPA.mjs +1508 -0
  144. package/dist/derived-checks-D5HVRvqN-BJx1gwPA.mjs.map +1 -0
  145. package/dist/{derived-checks-DPdD01O0-DGqOFjs6.d.mts → derived-checks-DpPkO6Dt-9U9UJZOo.d.mts} +4 -4
  146. package/dist/derived-checks-DpPkO6Dt-9U9UJZOo.d.mts.map +1 -0
  147. package/dist/diagnostics-RHJxoiIk.mjs +23 -0
  148. package/dist/diagnostics-RHJxoiIk.mjs.map +1 -0
  149. package/dist/{diff-DbTNVm2f.d.mts → diff-1qHOLoUB.d.mts} +23 -10
  150. package/dist/diff-1qHOLoUB.d.mts.map +1 -0
  151. package/dist/diff-C1rFOhek.mjs +21 -0
  152. package/dist/diff-C1rFOhek.mjs.map +1 -0
  153. package/dist/{dist-ZK6oeI5e.mjs → dist-C8Y-PPuE.mjs} +36 -212
  154. package/dist/dist-C8Y-PPuE.mjs.map +1 -0
  155. package/dist/{dist-C_q1_QR9.mjs → dist-CHz1hF8M.mjs} +2 -2
  156. package/dist/dist-CHz1hF8M.mjs.map +1 -0
  157. package/dist/{dist-x6jvtkKM.mjs → dist-CMDXybwm.mjs} +2 -2
  158. package/dist/dist-CMDXybwm.mjs.map +1 -0
  159. package/dist/{driver-types-BQtRkOJ0-Bv2RPSfr.d.mts → driver-types-DRsYeq3j-BimeCnUk.d.mts} +11 -2
  160. package/dist/driver-types-DRsYeq3j-BimeCnUk.d.mts.map +1 -0
  161. package/dist/entity-handle-lowering-hook-BJZSlVVF.mjs +16 -0
  162. package/dist/entity-handle-lowering-hook-BJZSlVVF.mjs.map +1 -0
  163. package/dist/{entity-handle-lowering-hook-CIvRKBfa.d.mts → entity-handle-lowering-hook-BuvLtgFi.d.mts} +8 -11
  164. package/dist/entity-handle-lowering-hook-BuvLtgFi.d.mts.map +1 -0
  165. package/dist/{entity-kinds-B5cUFU22.d.mts → entity-kinds-BPG2xCZV.d.mts} +7 -7
  166. package/dist/entity-kinds-BPG2xCZV.d.mts.map +1 -0
  167. package/dist/{entity-kinds-D7vwoN_T-CCBwFJy0.mjs → entity-kinds-JR5SAm5h-DOH6VUtL.mjs} +31 -28
  168. package/dist/entity-kinds-JR5SAm5h-DOH6VUtL.mjs.map +1 -0
  169. package/dist/{errors-B5g0xWro-mWH2C07F.mjs → errors-B5g0xWro-C8plbqga.mjs} +2 -2
  170. package/dist/errors-B5g0xWro-C8plbqga.mjs.map +1 -0
  171. package/dist/errors.d.mts +1 -1
  172. package/dist/errors.d.mts.map +1 -1
  173. package/dist/errors.mjs +1 -1
  174. package/dist/exports-C3wGYtID-D65DEUTC.mjs +2389 -0
  175. package/dist/exports-C3wGYtID-D65DEUTC.mjs.map +1 -0
  176. package/dist/{expression-FJK6Ar-d.d.mts → expression-6ld_ZQL6-fOuazzzm.d.mts} +37 -16
  177. package/dist/expression-6ld_ZQL6-fOuazzzm.d.mts.map +1 -0
  178. package/dist/expression-CieaNuRM-B1uVqxwd.d.mts +22 -0
  179. package/dist/expression-CieaNuRM-B1uVqxwd.d.mts.map +1 -0
  180. package/dist/expression-D8HstQiB.d.mts +2 -0
  181. package/dist/{expression-CX5mTA-z.mjs → expression-impl-B-XNINxr-BhN2sysZ.mjs} +41 -18
  182. package/dist/expression-impl-B-XNINxr-BhN2sysZ.mjs.map +1 -0
  183. package/dist/{factories-SVor5xIT.mjs → factories-Crobuxwn.mjs} +27 -20
  184. package/dist/factories-Crobuxwn.mjs.map +1 -0
  185. package/dist/{factories-P3qBQhO-.d.mts → factories-DbNP9qfs.d.mts} +16 -10
  186. package/dist/factories-DbNP9qfs.d.mts.map +1 -0
  187. package/dist/family.d.mts +17 -13
  188. package/dist/family.mjs +17 -12
  189. package/dist/family__control-adapter.d.mts +3 -3
  190. package/dist/family__control-adapter.mjs +2 -1
  191. package/dist/family__control.d.mts +5 -4
  192. package/dist/family__control.mjs +4 -4
  193. package/dist/family__diff.d.mts +2 -3
  194. package/dist/family__diff.mjs +2 -2
  195. package/dist/family__ir.d.mts +1 -1
  196. package/dist/family__ir.mjs +2 -2
  197. package/dist/family__migration.d.mts +1 -1
  198. package/dist/family__migration.mjs +1 -1
  199. package/dist/family__pack.d.mts +2 -249
  200. package/dist/family__pack.mjs +3 -18
  201. package/dist/family__psl-build.d.mts +3 -0
  202. package/dist/family__psl-build.mjs +3 -0
  203. package/dist/family__psl-infer.d.mts +2 -2
  204. package/dist/family__psl-infer.mjs +2 -2
  205. package/dist/family__runtime.d.mts +2 -2
  206. package/dist/family__runtime.mjs +2 -2
  207. package/dist/family__verify.d.mts +1 -1
  208. package/dist/family__verify.mjs +1 -1
  209. package/dist/foreign-key-materialization-48P2V8on.d.mts +98 -0
  210. package/dist/foreign-key-materialization-48P2V8on.d.mts.map +1 -0
  211. package/dist/foreign-key-materialization-BM59w_Xg.mjs +287 -0
  212. package/dist/foreign-key-materialization-BM59w_Xg.mjs.map +1 -0
  213. package/dist/{foreign-key-C-iTPuRT-C9ip8zFx.d.mts → foreign-key-qkDFfG8t-TaK_GYWR.d.mts} +21 -5
  214. package/dist/foreign-key-qkDFfG8t-TaK_GYWR.d.mts.map +1 -0
  215. package/dist/functions-CsOoN7I3.mjs +88 -0
  216. package/dist/functions-CsOoN7I3.mjs.map +1 -0
  217. package/dist/functions-EW-RrRn3.d.mts +73 -0
  218. package/dist/functions-EW-RrRn3.d.mts.map +1 -0
  219. package/dist/generator-functions-D_qdqBV--Bq296cED.mjs +544 -0
  220. package/dist/generator-functions-D_qdqBV--Bq296cED.mjs.map +1 -0
  221. package/dist/index-7nHHQsAj.d.mts +606 -0
  222. package/dist/index-7nHHQsAj.d.mts.map +1 -0
  223. package/dist/{index-C5I8D-MB.d.mts → index-Nqc3OHR_.d.mts} +4 -5
  224. package/dist/index-Nqc3OHR_.d.mts.map +1 -0
  225. package/dist/index-equivalence-DswCiq5l-CGsyPP9B.mjs +109 -0
  226. package/dist/index-equivalence-DswCiq5l-CGsyPP9B.mjs.map +1 -0
  227. package/dist/{index-naming-DREt6js7-CRH27yUv.mjs → index-naming-BOcJT1B3-mG8Fd6KN.mjs} +35 -9
  228. package/dist/index-naming-BOcJT1B3-mG8Fd6KN.mjs.map +1 -0
  229. package/dist/{index-naming-Ct65z5Xk.d.mts → index-naming-Cs6wwia3.d.mts} +15 -5
  230. package/dist/index-naming-Cs6wwia3.d.mts.map +1 -0
  231. package/dist/index-reference-4wsdeB7v-DCwswK-q.d.mts +67 -0
  232. package/dist/index-reference-4wsdeB7v-DCwswK-q.d.mts.map +1 -0
  233. package/dist/index-reference-BQSrkRfT.mjs +55 -0
  234. package/dist/index-reference-BQSrkRfT.mjs.map +1 -0
  235. package/dist/index-reference-D8ewQRJr.d.mts +1 -0
  236. package/dist/index-type-validation-DJEMmmw0.mjs +42 -0
  237. package/dist/index-type-validation-DJEMmmw0.mjs.map +1 -0
  238. package/dist/index-type-validation-fGGwAHWc.d.mts +16 -0
  239. package/dist/index-type-validation-fGGwAHWc.d.mts.map +1 -0
  240. package/dist/index-types-H1O43iYT-BD0VwPqV.d.mts +66 -0
  241. package/dist/index-types-H1O43iYT-BD0VwPqV.d.mts.map +1 -0
  242. package/dist/index-types-pC_5vADQ-BOOBi14R.mjs +95 -0
  243. package/dist/index-types-pC_5vADQ-BOOBi14R.mjs.map +1 -0
  244. package/dist/index-types-snhtt_Fo.d.mts +1 -0
  245. package/dist/interpreter-D5qk4B---CG0C7kdx.mjs +2280 -0
  246. package/dist/interpreter-D5qk4B---CG0C7kdx.mjs.map +1 -0
  247. package/dist/{ir-Bghjt-FG.d.mts → ir-BvptQsFW.d.mts} +11 -5
  248. package/dist/ir-BvptQsFW.d.mts.map +1 -0
  249. package/dist/{ir-I-xciGUH.mjs → ir-DzsUDO8e.mjs} +2 -2
  250. package/dist/ir-DzsUDO8e.mjs.map +1 -0
  251. package/dist/{middleware-AhTz1BOW-th-Suxuf.d.mts → middleware-DHkW6pRr-DM6hd9iZ.d.mts} +5 -5
  252. package/dist/middleware-DHkW6pRr-DM6hd9iZ.d.mts.map +1 -0
  253. package/dist/middleware-gqy3l13N.d.mts +1 -0
  254. package/dist/{middleware-CMr4CHNz-DHIUdxlm.mjs → middleware-yBAfiVWn-DZO0vCRQ.mjs} +3 -3
  255. package/dist/middleware-yBAfiVWn-DZO0vCRQ.mjs.map +1 -0
  256. package/dist/{migration-CK4oePIo.mjs → migration-BJQjkqFz.mjs} +4 -4
  257. package/dist/migration-BJQjkqFz.mjs.map +1 -0
  258. package/dist/{migration-CjDRZNep.d.mts → migration-Cxmpzaz0.d.mts} +6 -6
  259. package/dist/migration-Cxmpzaz0.d.mts.map +1 -0
  260. package/dist/{naming-CV9j2pXl-KARaDReS.d.mts → naming-BcD36g9T-Mfe_xGGL.d.mts} +9 -14
  261. package/dist/naming-BcD36g9T-Mfe_xGGL.d.mts.map +1 -0
  262. package/dist/{naming-DKr4TJd7-Cszhq9RV.mjs → naming-bM5qm5PY-jOg3JFMb.mjs} +20 -31
  263. package/dist/naming-bM5qm5PY-jOg3JFMb.mjs.map +1 -0
  264. package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs → opaque-sql-Dset3kln-CtsPDTXn.mjs} +24 -11
  265. package/dist/opaque-sql-Dset3kln-CtsPDTXn.mjs.map +1 -0
  266. package/dist/operations.d.mts +1 -1
  267. package/dist/operations.mjs +1 -1
  268. package/dist/orm-client.d.mts +817 -267
  269. package/dist/orm-client.d.mts.map +1 -1
  270. package/dist/orm-client.mjs +4719 -2942
  271. package/dist/orm-client.mjs.map +1 -1
  272. package/dist/pack-DA8HZ2mo.d.mts +535 -0
  273. package/dist/pack-DA8HZ2mo.d.mts.map +1 -0
  274. package/dist/pack-gSvGQWqs.mjs +80 -0
  275. package/dist/pack-gSvGQWqs.mjs.map +1 -0
  276. package/dist/{plan-CDxduYaN-pLIyyJaB.d.mts → plan-Cr4azjnG-CuL8FqXC.d.mts} +12 -8
  277. package/dist/plan-Cr4azjnG-CuL8FqXC.d.mts.map +1 -0
  278. package/dist/{plan-Dh0LbYIv-Crx5-ThG.mjs → plan-Dh0LbYIv-ubBSdUgl.mjs} +2 -2
  279. package/dist/plan-Dh0LbYIv-ubBSdUgl.mjs.map +1 -0
  280. package/dist/plan-Di6Gs2JD.d.mts +2 -0
  281. package/dist/psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs +42 -0
  282. package/dist/psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs.map +1 -0
  283. package/dist/psl-build-DFBG6vhz.mjs +426 -0
  284. package/dist/psl-build-DFBG6vhz.mjs.map +1 -0
  285. package/dist/psl-build-RelubU2E.d.mts +112 -0
  286. package/dist/psl-build-RelubU2E.d.mts.map +1 -0
  287. package/dist/psl-column-resolution-ChZqioOc-BREg4J7d.d.mts +24 -0
  288. package/dist/psl-column-resolution-ChZqioOc-BREg4J7d.d.mts.map +1 -0
  289. package/dist/psl-field-resolution-C5KQ7kzP-B0NwuRWV.mjs +1960 -0
  290. package/dist/psl-field-resolution-C5KQ7kzP-B0NwuRWV.mjs.map +1 -0
  291. package/dist/psl-infer--g4i84Go.mjs +201 -0
  292. package/dist/psl-infer--g4i84Go.mjs.map +1 -0
  293. package/dist/psl-infer-DzoxPZGd.d.mts +80 -0
  294. package/dist/psl-infer-DzoxPZGd.d.mts.map +1 -0
  295. package/dist/psl-names-C3cwe0rg-D1CTmC3a.mjs +66 -0
  296. package/dist/psl-names-C3cwe0rg-D1CTmC3a.mjs.map +1 -0
  297. package/dist/{query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts → query-lane-context-BCEoKy0_-CzmyavC9.d.mts} +20 -49
  298. package/dist/query-lane-context-BCEoKy0_-CzmyavC9.d.mts.map +1 -0
  299. package/dist/query-lane-context-VqH0mS9B.d.mts +1 -0
  300. package/dist/{referential-action-sql-DJ9ps6-S.d.mts → referential-action-sql-B2vKoUK6.d.mts} +3 -3
  301. package/dist/referential-action-sql-B2vKoUK6.d.mts.map +1 -0
  302. package/dist/{referential-action-sql-DSqkrySN.mjs → referential-action-sql-BLzCtTi8.mjs} +2 -2
  303. package/dist/referential-action-sql-BLzCtTi8.mjs.map +1 -0
  304. package/dist/relational-core.d.mts +14 -13
  305. package/dist/relational-core.mjs +8 -8
  306. package/dist/relational-core__aggregate-descriptor-registry.d.mts +2 -2
  307. package/dist/relational-core__aggregate-descriptor-registry.d.mts.map +1 -1
  308. package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
  309. package/dist/relational-core__ast.d.mts +5 -5
  310. package/dist/relational-core__ast.mjs +5 -5
  311. package/dist/relational-core__codec-descriptor-registry.d.mts +7 -8
  312. package/dist/relational-core__codec-descriptor-registry.d.mts.map +1 -1
  313. package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
  314. package/dist/relational-core__collection-methods.d.mts +3 -0
  315. package/dist/relational-core__contract-free.d.mts +18 -8
  316. package/dist/relational-core__contract-free.d.mts.map +1 -1
  317. package/dist/relational-core__contract-free.mjs +26 -10
  318. package/dist/relational-core__contract-free.mjs.map +1 -1
  319. package/dist/relational-core__expression.d.mts +4 -2
  320. package/dist/relational-core__expression.mjs +2 -2
  321. package/dist/relational-core__functions.d.mts +2 -0
  322. package/dist/relational-core__functions.mjs +2 -0
  323. package/dist/relational-core__index-reference.d.mts +3 -0
  324. package/dist/relational-core__index-reference.mjs +2 -0
  325. package/dist/relational-core__middleware.d.mts +2 -2
  326. package/dist/relational-core__middleware.mjs +1 -1
  327. package/dist/relational-core__plan.d.mts +4 -4
  328. package/dist/relational-core__plan.mjs +1 -1
  329. package/dist/relational-core__query-lane-context.d.mts +3 -3
  330. package/dist/relational-core__types.d.mts +2 -2
  331. package/dist/{resolve-storage-table-DZsfnzeW.mjs → resolve-storage-table-BHLQsOza.mjs} +3 -3
  332. package/dist/resolve-storage-table-BHLQsOza.mjs.map +1 -0
  333. package/dist/{resolve-storage-table-Nyrgk4h8.d.mts → resolve-storage-table-DCqtmnSU.d.mts} +4 -4
  334. package/dist/resolve-storage-table-DCqtmnSU.d.mts.map +1 -0
  335. package/dist/{runtime-tIHpGCcG.mjs → runtime-6tH1yOxK.mjs} +6 -6
  336. package/dist/runtime-6tH1yOxK.mjs.map +1 -0
  337. package/dist/{runtime-DpKF2Yu2.d.mts → runtime-CF6rAlE5.d.mts} +7 -8
  338. package/dist/runtime-CF6rAlE5.d.mts.map +1 -0
  339. package/dist/runtime.d.mts +5 -5
  340. package/dist/runtime.mjs +2 -1799
  341. package/dist/runtime__internal__prepared-query.d.mts +2 -2
  342. package/dist/runtime__internal__prepared-query.mjs +2 -2
  343. package/dist/{schema-differ-DpG_gnur-DFAtGezx.d.mts → schema-differ-DmP74bB8-tqHKiJ88.d.mts} +6 -6
  344. package/dist/schema-differ-DmP74bB8-tqHKiJ88.d.mts.map +1 -0
  345. package/dist/schema-ir.d.mts +2 -2
  346. package/dist/schema-ir.mjs +2 -2
  347. package/dist/schema-ir__naming.d.mts +1 -1
  348. package/dist/schema-ir__naming.mjs +1 -1
  349. package/dist/schema-ir__types.d.mts +3 -3
  350. package/dist/schema-ir__types.mjs +2 -2
  351. package/dist/{schema-verify-C_PEdlAr-Dxxjm6EM.mjs → schema-verify-C3wbdviw-DMjIubOr.mjs} +50 -8
  352. package/dist/schema-verify-C3wbdviw-DMjIubOr.mjs.map +1 -0
  353. package/dist/{serialized-index-CrgG8ct1-DG3JpHc7.d.mts → serialized-index-CrgG8ct1-DKVJ7TDX.d.mts} +4 -4
  354. package/dist/serialized-index-CrgG8ct1-DKVJ7TDX.d.mts.map +1 -0
  355. package/dist/{serialized-index-nBTwanKy-_ddEK4tk.mjs → serialized-index-DjCCnXB1-DMA7BtO2.mjs} +4 -4
  356. package/dist/serialized-index-DjCCnXB1-DMA7BtO2.mjs.map +1 -0
  357. package/dist/{sql-contract-serializer-2oBWuxTe-DKZTf2n8.mjs → sql-contract-serializer-sMY3prTx-D2BfrNxs.mjs} +41 -16
  358. package/dist/sql-contract-serializer-sMY3prTx-D2BfrNxs.mjs.map +1 -0
  359. package/dist/sql-data-type-D7M-YTTY-D2vRqDxn.mjs +400 -0
  360. package/dist/sql-data-type-D7M-YTTY-D2vRqDxn.mjs.map +1 -0
  361. package/dist/{sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts → sql-execution-plan-3uxYjHyu-DLknM-Pj.d.mts} +3 -3
  362. package/dist/sql-execution-plan-3uxYjHyu-DLknM-Pj.d.mts.map +1 -0
  363. package/dist/sql-expression-B4BrhGPi.d.mts +62 -0
  364. package/dist/sql-expression-B4BrhGPi.d.mts.map +1 -0
  365. package/dist/sql-expression-CKgKznXS.mjs +137 -0
  366. package/dist/sql-expression-CKgKznXS.mjs.map +1 -0
  367. package/dist/{sql-index-ByAAE7K8-DKj2V86p.d.mts → sql-index-ByAAE7K8-Dqtn_vUL.d.mts} +4 -4
  368. package/dist/sql-index-ByAAE7K8-Dqtn_vUL.d.mts.map +1 -0
  369. package/dist/{sql-node-kEz6YFZo-v2F7delx.d.mts → sql-node-kEz6YFZo-1ogT6Cxt.d.mts} +2 -2
  370. package/dist/sql-node-kEz6YFZo-1ogT6Cxt.d.mts.map +1 -0
  371. package/dist/{sql-storage-8LqxeLAY-DH4DdUXx.d.mts → sql-storage-DeCAh5Hi-CEM-m8cs.d.mts} +19 -22
  372. package/dist/sql-storage-DeCAh5Hi-CEM-m8cs.d.mts.map +1 -0
  373. package/dist/{storage-table-DSeWszOL-CI-cItEK.d.mts → storage-table-Bf1ZjnxO-pUj6pyP0.d.mts} +17 -24
  374. package/dist/storage-table-Bf1ZjnxO-pUj6pyP0.d.mts.map +1 -0
  375. package/dist/{storage-table-ZzbR-xzQ-BRoTQE_2.mjs → storage-table-DDvN83mw-DkbBFmK9.mjs} +12 -9
  376. package/dist/storage-table-DDvN83mw-DkbBFmK9.mjs.map +1 -0
  377. package/dist/{storage-value-set-BGlj5Uus-CvZD--GG.d.mts → storage-value-set-BGlj5Uus-ny2k-0PA.d.mts} +3 -3
  378. package/dist/storage-value-set-BGlj5Uus-ny2k-0PA.d.mts.map +1 -0
  379. package/dist/transaction-state-BfXhs7D7-DhmbySW9.mjs +45 -0
  380. package/dist/transaction-state-BfXhs7D7-DhmbySW9.mjs.map +1 -0
  381. package/dist/transaction-state-DR3nKTmH-D29jmVE-.d.mts +115 -0
  382. package/dist/transaction-state-DR3nKTmH-D29jmVE-.d.mts.map +1 -0
  383. package/dist/types-B9wSEUsV.d.mts +1 -0
  384. package/dist/{types-CUsJrvEl.mjs → types-CTdSkl0s.mjs} +13 -6
  385. package/dist/types-CTdSkl0s.mjs.map +1 -0
  386. package/dist/types-CkAd8SWm.d.mts +57 -0
  387. package/dist/types-CkAd8SWm.d.mts.map +1 -0
  388. package/dist/{types-IqZMLrFC-DcH8v_u3.d.mts → types-Cq6ImLAB-RlU4jJAX.d.mts} +27 -41
  389. package/dist/types-Cq6ImLAB-RlU4jJAX.d.mts.map +1 -0
  390. package/dist/{types-YStFFkKs-D9UAmnON.d.mts → types-CuCxAQat-Dz8P4xyt.d.mts} +141 -86
  391. package/dist/types-CuCxAQat-Dz8P4xyt.d.mts.map +1 -0
  392. package/dist/types-DfKvtJwS-CrpWTGBJ.d.mts +273 -0
  393. package/dist/types-DfKvtJwS-CrpWTGBJ.d.mts.map +1 -0
  394. package/dist/{types-4YenawkP-CwaaZSid.mjs → types-DoyiTsjg-2YMhMJDA.mjs} +181 -80
  395. package/dist/types-DoyiTsjg-2YMhMJDA.mjs.map +1 -0
  396. package/dist/{types-v3qxLLxo-DCeKv7yY.d.mts → types-DriMIMNQ-BkbsW7w3.d.mts} +68 -34
  397. package/dist/types-DriMIMNQ-BkbsW7w3.d.mts.map +1 -0
  398. package/dist/{types-Dt4e_jC--COeP8xzN.mjs → types-NTQsD2MS-xcLtvKO9.mjs} +83 -17
  399. package/dist/types-NTQsD2MS-xcLtvKO9.mjs.map +1 -0
  400. package/dist/{types-CyxGtOOh-BggSa6Fe.d.mts → types-TXO7x1BA-CYYIY8NI.d.mts} +14 -14
  401. package/dist/types-TXO7x1BA-CYYIY8NI.d.mts.map +1 -0
  402. package/dist/types-ljUNyiWe.d.mts +1 -0
  403. package/dist/{unique-constraint-M5TlQnJQ-BiIHJ85k.d.mts → unique-constraint-M5TlQnJQ-qX-maNUV.d.mts} +3 -3
  404. package/dist/unique-constraint-M5TlQnJQ-qX-maNUV.d.mts.map +1 -0
  405. package/dist/{util-DQQgv2j1-D6INZaRG.mjs → util-BBgcP3gI-CpL-0VuC.mjs} +12 -3
  406. package/dist/util-BBgcP3gI-CpL-0VuC.mjs.map +1 -0
  407. package/dist/{validators-CrWD6bSP.mjs → validators-BwA7ttZM.mjs} +0 -0
  408. package/dist/validators-BwA7ttZM.mjs.map +1 -0
  409. package/dist/{validators-Belo8QqM.d.mts → validators-FJs8HvFr.d.mts} +54 -16
  410. package/dist/validators-FJs8HvFr.d.mts.map +1 -0
  411. package/dist/{value-set-derivation-hook-BhgGVtw0.d.mts → value-set-derivation-hook-3E437jPU.d.mts} +3 -3
  412. package/dist/value-set-derivation-hook-3E437jPU.d.mts.map +1 -0
  413. package/dist/{value-set-derivation-hook-Di9JZ0X7.mjs → value-set-derivation-hook-HVaxhALD.mjs} +2 -2
  414. package/dist/value-set-derivation-hook-HVaxhALD.mjs.map +1 -0
  415. package/dist/{verify-u0UTdZgD-DSAaz9rW.mjs → verify-BVk5bjdH-DhKm6hB3.mjs} +8 -7
  416. package/dist/verify-BVk5bjdH-DhKm6hB3.mjs.map +1 -0
  417. package/dist/{verify-zDRnw0Rn.d.mts → verify-DHXbuZPB.d.mts} +2 -2
  418. package/dist/verify-DHXbuZPB.d.mts.map +1 -0
  419. package/package.json +33 -22
  420. package/dist/aggregate-descriptor-registry-C7hel5O7.mjs.map +0 -1
  421. package/dist/ast-HFcfQZr-.d.mts +0 -206
  422. package/dist/ast-HFcfQZr-.d.mts.map +0 -1
  423. package/dist/ast-Lbl4VwqP.mjs +0 -325
  424. package/dist/ast-Lbl4VwqP.mjs.map +0 -1
  425. package/dist/authored-check-naming-BWBe-PVE.d.mts.map +0 -1
  426. package/dist/authored-check-naming-Hf9990DV.mjs.map +0 -1
  427. package/dist/authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs +0 -316
  428. package/dist/authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs.map +0 -1
  429. package/dist/canonicalization-hooks-CYnW_sGn.d.mts.map +0 -1
  430. package/dist/canonicalization-hooks-dmXkOR4a.mjs.map +0 -1
  431. package/dist/check-constraint-B7qGu6rc-HvQjjX82.d.mts.map +0 -1
  432. package/dist/codec-descriptor-registry-N0dhtKaH.mjs.map +0 -1
  433. package/dist/config-types-D9fdKG3g.d.mts.map +0 -1
  434. package/dist/config-types-gAm54C_v.mjs.map +0 -1
  435. package/dist/contract-builder-CG_tGDbB.d.mts +0 -1360
  436. package/dist/contract-builder-CG_tGDbB.d.mts.map +0 -1
  437. package/dist/contract-builder-D4a5dT7j.mjs.map +0 -1
  438. package/dist/contract-errors-BCN6RVI5-5IHBF_lg.mjs.map +0 -1
  439. package/dist/contract-view-BMR5IWk4.mjs.map +0 -1
  440. package/dist/contract-view-CPHxoAEX.d.mts.map +0 -1
  441. package/dist/contract__pack-types.d.mts +0 -2
  442. package/dist/control-D3cB5YQp.mjs +0 -1267
  443. package/dist/control-D3cB5YQp.mjs.map +0 -1
  444. package/dist/control-DTLJ1WtZ.d.mts +0 -945
  445. package/dist/control-DTLJ1WtZ.d.mts.map +0 -1
  446. package/dist/control-adapter-C99J7aEF-B7eQd7vD.d.mts.map +0 -1
  447. package/dist/control-adapter-MZJQiwcE.d.mts +0 -1
  448. package/dist/db-D18PrXKW-DvTv4JFn.d.mts.map +0 -1
  449. package/dist/ddl-types-BGdnAbXo-DKPHPUGx.mjs.map +0 -1
  450. package/dist/ddl-types-CXx4vPz6-BsgrnSUY.d.mts.map +0 -1
  451. package/dist/derived-checks-DFMRmiAu-DGfB8aS4.mjs +0 -1057
  452. package/dist/derived-checks-DFMRmiAu-DGfB8aS4.mjs.map +0 -1
  453. package/dist/derived-checks-DPdD01O0-DGqOFjs6.d.mts.map +0 -1
  454. package/dist/diff-B16bL_IR.mjs +0 -13
  455. package/dist/diff-B16bL_IR.mjs.map +0 -1
  456. package/dist/diff-DbTNVm2f.d.mts.map +0 -1
  457. package/dist/dist-C_q1_QR9.mjs.map +0 -1
  458. package/dist/dist-ZK6oeI5e.mjs.map +0 -1
  459. package/dist/dist-x6jvtkKM.mjs.map +0 -1
  460. package/dist/driver-types-BQtRkOJ0-Bv2RPSfr.d.mts.map +0 -1
  461. package/dist/entity-handle-lowering-hook-CIvRKBfa.d.mts.map +0 -1
  462. package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs +0 -11
  463. package/dist/entity-handle-lowering-hook-DwLIKNiS.mjs.map +0 -1
  464. package/dist/entity-kinds-B5cUFU22.d.mts.map +0 -1
  465. package/dist/entity-kinds-D7vwoN_T-CCBwFJy0.mjs.map +0 -1
  466. package/dist/errors-B5g0xWro-mWH2C07F.mjs.map +0 -1
  467. package/dist/expression-CX5mTA-z.mjs.map +0 -1
  468. package/dist/expression-FJK6Ar-d.d.mts.map +0 -1
  469. package/dist/factories-P3qBQhO-.d.mts.map +0 -1
  470. package/dist/factories-SVor5xIT.mjs.map +0 -1
  471. package/dist/family__pack.d.mts.map +0 -1
  472. package/dist/family__pack.mjs.map +0 -1
  473. package/dist/foreign-key-C-iTPuRT-C9ip8zFx.d.mts.map +0 -1
  474. package/dist/foreign-key-materialization-CkvOzJWy.d.mts +0 -65
  475. package/dist/foreign-key-materialization-CkvOzJWy.d.mts.map +0 -1
  476. package/dist/foreign-key-materialization-Cu7-7LHl.mjs +0 -73
  477. package/dist/foreign-key-materialization-Cu7-7LHl.mjs.map +0 -1
  478. package/dist/index-C-vQOMY_.d.mts +0 -84
  479. package/dist/index-C-vQOMY_.d.mts.map +0 -1
  480. package/dist/index-C5I8D-MB.d.mts.map +0 -1
  481. package/dist/index-naming-Ct65z5Xk.d.mts.map +0 -1
  482. package/dist/index-naming-DREt6js7-CRH27yUv.mjs.map +0 -1
  483. package/dist/index-type-validation-COH4d78M.mjs +0 -17
  484. package/dist/index-type-validation-COH4d78M.mjs.map +0 -1
  485. package/dist/index-type-validation-CZ5L2lli.d.mts +0 -10
  486. package/dist/index-type-validation-CZ5L2lli.d.mts.map +0 -1
  487. package/dist/index-types-CNhHgKHi.d.mts +0 -1
  488. package/dist/index-types-DJQ_xwaE.mjs +0 -40
  489. package/dist/index-types-DJQ_xwaE.mjs.map +0 -1
  490. package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts +0 -31
  491. package/dist/index-types-DPVhsW0v-D-BikM4h.d.mts.map +0 -1
  492. package/dist/interpreter-DyiUUAWh-DYdjIpiE.mjs +0 -3680
  493. package/dist/interpreter-DyiUUAWh-DYdjIpiE.mjs.map +0 -1
  494. package/dist/ir-Bghjt-FG.d.mts.map +0 -1
  495. package/dist/ir-I-xciGUH.mjs.map +0 -1
  496. package/dist/lane-query-builder.d.mts +0 -236
  497. package/dist/lane-query-builder.d.mts.map +0 -1
  498. package/dist/lane-query-builder.mjs +0 -67
  499. package/dist/lane-query-builder.mjs.map +0 -1
  500. package/dist/middleware--TtoxUiW.d.mts +0 -1
  501. package/dist/middleware-AhTz1BOW-th-Suxuf.d.mts.map +0 -1
  502. package/dist/middleware-CMr4CHNz-DHIUdxlm.mjs.map +0 -1
  503. package/dist/migration-CK4oePIo.mjs.map +0 -1
  504. package/dist/migration-CjDRZNep.d.mts.map +0 -1
  505. package/dist/naming-CV9j2pXl-KARaDReS.d.mts.map +0 -1
  506. package/dist/naming-DKr4TJd7-Cszhq9RV.mjs.map +0 -1
  507. package/dist/pack-types-BcLTpwbv.d.mts +0 -14
  508. package/dist/pack-types-BcLTpwbv.d.mts.map +0 -1
  509. package/dist/plan-BHLdb0Z7.d.mts +0 -2
  510. package/dist/plan-CDxduYaN-pLIyyJaB.d.mts.map +0 -1
  511. package/dist/plan-Dh0LbYIv-Crx5-ThG.mjs.map +0 -1
  512. package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs +0 -22
  513. package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs.map +0 -1
  514. package/dist/prepared-statement-9QpkE6JG-C430V3MO.d.mts +0 -529
  515. package/dist/prepared-statement-9QpkE6JG-C430V3MO.d.mts.map +0 -1
  516. package/dist/psl-infer-CCAD6FWA.d.mts +0 -119
  517. package/dist/psl-infer-CCAD6FWA.d.mts.map +0 -1
  518. package/dist/psl-infer-Dk5kgKre.mjs +0 -362
  519. package/dist/psl-infer-Dk5kgKre.mjs.map +0 -1
  520. package/dist/query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts.map +0 -1
  521. package/dist/query-lane-context-XMvk7fmY.d.mts +0 -1
  522. package/dist/referential-action-sql-DJ9ps6-S.d.mts.map +0 -1
  523. package/dist/referential-action-sql-DSqkrySN.mjs.map +0 -1
  524. package/dist/resolve-storage-table-DZsfnzeW.mjs.map +0 -1
  525. package/dist/resolve-storage-table-Nyrgk4h8.d.mts.map +0 -1
  526. package/dist/runtime-DpKF2Yu2.d.mts.map +0 -1
  527. package/dist/runtime-tIHpGCcG.mjs.map +0 -1
  528. package/dist/runtime.mjs.map +0 -1
  529. package/dist/schema-differ-DpG_gnur-DFAtGezx.d.mts.map +0 -1
  530. package/dist/schema-verify-C_PEdlAr-Dxxjm6EM.mjs.map +0 -1
  531. package/dist/serialized-index-CrgG8ct1-DG3JpHc7.d.mts.map +0 -1
  532. package/dist/serialized-index-nBTwanKy-_ddEK4tk.mjs.map +0 -1
  533. package/dist/sql-contract-serializer-2oBWuxTe-DKZTf2n8.mjs.map +0 -1
  534. package/dist/sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts.map +0 -1
  535. package/dist/sql-index-ByAAE7K8-DKj2V86p.d.mts.map +0 -1
  536. package/dist/sql-node-kEz6YFZo-v2F7delx.d.mts.map +0 -1
  537. package/dist/sql-storage-8LqxeLAY-DH4DdUXx.d.mts.map +0 -1
  538. package/dist/storage-table-DSeWszOL-CI-cItEK.d.mts.map +0 -1
  539. package/dist/storage-table-ZzbR-xzQ-BRoTQE_2.mjs.map +0 -1
  540. package/dist/storage-value-set-BGlj5Uus-CvZD--GG.d.mts.map +0 -1
  541. package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs +0 -173
  542. package/dist/timestamp-now-generator-DRXygu32-DN9Qb1uI.mjs.map +0 -1
  543. package/dist/types-4YenawkP-CwaaZSid.mjs.map +0 -1
  544. package/dist/types-B0msOnBM.d.mts +0 -1
  545. package/dist/types-BDUG29Df-LE85dIXP.d.mts +0 -161
  546. package/dist/types-BDUG29Df-LE85dIXP.d.mts.map +0 -1
  547. package/dist/types-CUsJrvEl.mjs.map +0 -1
  548. package/dist/types-CyxGtOOh-BggSa6Fe.d.mts.map +0 -1
  549. package/dist/types-Dt4e_jC--COeP8xzN.mjs.map +0 -1
  550. package/dist/types-Dwcw0F8X.d.mts +0 -1
  551. package/dist/types-IqZMLrFC-DcH8v_u3.d.mts.map +0 -1
  552. package/dist/types-UcHa2cTe.d.mts +0 -17
  553. package/dist/types-UcHa2cTe.d.mts.map +0 -1
  554. package/dist/types-YStFFkKs-D9UAmnON.d.mts.map +0 -1
  555. package/dist/types-v3qxLLxo-DCeKv7yY.d.mts.map +0 -1
  556. package/dist/unique-constraint-M5TlQnJQ-BiIHJ85k.d.mts.map +0 -1
  557. package/dist/util-DQQgv2j1-D6INZaRG.mjs.map +0 -1
  558. package/dist/validators-Belo8QqM.d.mts.map +0 -1
  559. package/dist/validators-CrWD6bSP.mjs.map +0 -1
  560. package/dist/value-set-derivation-hook-BhgGVtw0.d.mts.map +0 -1
  561. package/dist/value-set-derivation-hook-Di9JZ0X7.mjs.map +0 -1
  562. package/dist/verify-u0UTdZgD-DSAaz9rW.mjs.map +0 -1
  563. package/dist/verify-zDRnw0Rn.d.mts.map +0 -1
  564. /package/dist/{contract__pack-types.mjs → relational-core__collection-methods.mjs} +0 -0
@@ -1,20 +1,117 @@
1
- import { r as StorageTable, t as StorageColumn } from "./storage-table-DSeWszOL-CI-cItEK.mjs";
2
- import { c as SqlStorage } from "./sql-storage-8LqxeLAY-DH4DdUXx.mjs";
3
- import { f as ExtractFieldOutputTypes, l as ExtractAggregateTypes, p as ExtractQueryOperationTypes, u as ExtractCodecTypes } from "./types-BDUG29Df-LE85dIXP.mjs";
4
- import "./types-UcHa2cTe.mjs";
5
- import { It as WhereArg, T as CodecRef$1, a as AndExpr, g as BinaryExpr, gt as OrderByItem, ht as OrExpr, pt as NullCheckExpr, r as AggregateFn, s as AnyExpression } from "./types-v3qxLLxo-DCeKv7yY.mjs";
6
- import "./ast-HFcfQZr-.mjs";
7
- import { o as Expression } from "./expression-FJK6Ar-d.mjs";
8
- import { r as ExecutionContext } from "./query-lane-context-Qa-eddrE-kuZ8Z86-.mjs";
9
- import "./query-lane-context-XMvk7fmY.mjs";
10
- import { h as RuntimeScope, o as ComputeColumnJsType } from "./types-CyxGtOOh-BggSa6Fe.mjs";
11
- import "./types-B0msOnBM.mjs";
1
+ import { t as StorageColumn } from "./storage-table-Bf1ZjnxO-pUj6pyP0.mjs";
2
+ import { l as SqlStorage } from "./sql-storage-DeCAh5Hi-CEM-m8cs.mjs";
3
+ import { D as QueryOperationTypesBase, d as ExtractAggregateTypes, f as ExtractCodecTypes, h as ExtractQueryOperationTypes, m as ExtractFieldOutputTypes, p as ExtractFieldInputTypes } from "./types-DfKvtJwS-CrpWTGBJ.mjs";
4
+ import { n as HasExecutionCreateDefault, r as IsOptionalCreateColumn } from "./types-CkAd8SWm.mjs";
5
+ import { Bt as TableSource, Ct as OrderByNulls, E as CodecRef$1, O as ColumnRef, St as OrderByItem, Ut as WhereArg, _ as BinaryExpr, a as AndExpr, c as AnyExpression, ct as LimitOffsetValue, dt as LockStrength, pt as LockingClause, r as AggregateFn, xt as OrExpr, yt as NullCheckExpr } from "./types-DriMIMNQ-BkbsW7w3.mjs";
6
+ import { n as SqlQueryPlan, t as Preparable } from "./plan-Cr4azjnG-CuL8FqXC.mjs";
7
+ import { C as TraitExpression, g as RawSqlInterpolation, i as CodecTypesBase, o as Expression, r as CodecExpression } from "./expression-6ld_ZQL6-fOuazzzm.mjs";
8
+ import "./expression-D8HstQiB.mjs";
9
+ import { n as BuiltinFunctions, t as BooleanCodecType } from "./functions-EW-RrRn3.mjs";
10
+ import { c as LockOptionCapabilities, l as LockStrengthCapabilities, u as LockWaitOptions } from "./ast-YEMe_B8z.mjs";
11
+ import { r as TableIndexReferences, t as IndexReference } from "./index-reference-4wsdeB7v-DCwswK-q.mjs";
12
+ import "./index-reference-D8ewQRJr.mjs";
13
+ import "./plan-Di6Gs2JD.mjs";
14
+ import { c as CollectionMethodRegistry, r as CollectionMethodContributionId, u as ContributedMethodSignature } from "./collection-methods-D2UnCS0S-DOy2qHYS.mjs";
15
+ import { n as ExecutionContext } from "./query-lane-context-BCEoKy0_-CzmyavC9.mjs";
16
+ import "./query-lane-context-VqH0mS9B.mjs";
17
+ import { h as RuntimeScope, o as ComputeColumnJsType } from "./types-TXO7x1BA-CYYIY8NI.mjs";
18
+ import "./types-B9wSEUsV.mjs";
19
+ import { l as PreparedFor, n as Declaration, o as ParamsFromDeclaration, t as BindSiteParams, u as PreparedStatement } from "./transaction-state-DR3nKTmH-D29jmVE-.mjs";
20
+ import "./collection-methods-BB8YH69u.mjs";
21
+ import { F as ActivitySourceTarget, W as Runtime, X as RuntimeQueryable$1 } from "./index-7nHHQsAj.mjs";
22
+ import { CodecDescriptorRef, ScalarFieldDeclarationBuilder } from "@prisma/orm-framework/components/codec";
12
23
  import { Contract } from "@prisma/orm-framework/contract/types";
13
- import { AnnotationValue, AsyncIterableResult, MetaBuilder, OperationKind } from "@prisma/orm-framework/components/runtime";
24
+ import { AsyncIterableResult, MetaBuilder, ResultType, RuntimeExecuteOptions } from "@prisma/orm-framework/components/runtime";
14
25
  import { SimplifyDeep } from "@prisma/orm-framework/utils/simplify-deep";
15
26
  //#region ../../../3-extensions/sql-orm-client/dist/index.d.mts
27
+ //#region src/table-scope.d.ts
28
+ interface TableStorageCoordinate {
29
+ readonly namespaceId: string;
30
+ readonly tableName: string;
31
+ }
32
+ interface AliasedTable {
33
+ readonly alias: string;
34
+ readonly storage: TableStorageCoordinate;
35
+ column(name: string): ColumnRef;
36
+ tableSource(contract: Contract<SqlStorage>): TableSource;
37
+ }
38
+ interface TableScope {
39
+ alias(preferred: string): string;
40
+ aliasTable(storage: TableStorageCoordinate): AliasedTable;
41
+ copy(): TableScope;
42
+ }
43
+ //#endregion
44
+ //#region src/collection-tables.d.ts
45
+ interface CollectionTables {
46
+ readonly scope: TableScope;
47
+ readonly root: AliasedTable;
48
+ readonly variants: ReadonlyMap<string, AliasedTable>;
49
+ }
50
+ declare function createCollectionTables(contract: Contract<SqlStorage>, namespaceId: string, modelName: string, tableName?: string): CollectionTables;
51
+ //#endregion
52
+ //#region src/collection-types.d.ts
53
+ declare const RowType: unique symbol;
54
+ declare const TypeState: unique symbol;
55
+ /** Something that yields values of type `Row`: a collection, whose row includes the relations and values `include` adds, or an include scalar or combine, which yields one value per parent row. */
56
+ interface HasRow<Row = unknown> {
57
+ readonly [RowType]: Row;
58
+ }
59
+ /** A collection whose type state is `State`. */
60
+ interface HasTypeState<State = CollectionTypeState> {
61
+ readonly [TypeState]: State;
62
+ }
63
+ /** The fact that a filter has been applied: the type-state flag `hasWhere` is `true`. Write `Filtered<C>` for a filtered collection; error messages print `HasWhere`. */
64
+ interface HasWhere extends HasTypeState<{
65
+ readonly hasWhere: true;
66
+ }> {}
67
+ /** The fact that an order has been applied: the type-state flag `hasOrderBy` is `true`. Write `Ordered<C>` for an ordered collection; error messages print `HasOrderBy`. */
68
+ interface HasOrderBy extends HasTypeState<{
69
+ readonly hasOrderBy: true;
70
+ }> {}
71
+ /** The fact that no variant has been selected: the type-state field `variantValue` is `undefined`. `variant()` needs it; error messages print `HasNoVariant`. */
72
+ interface HasNoVariant extends HasTypeState<{
73
+ readonly variantValue: undefined;
74
+ }> {}
75
+ declare const UniqueFilter: unique symbol;
76
+ interface HasUniqueFilter extends HasTypeState<{
77
+ readonly uniqueFilter: true;
78
+ }> {
79
+ readonly [UniqueFilter]: true;
80
+ }
81
+ interface HasNoUniqueFilter extends HasTypeState<{
82
+ readonly hasWhere: boolean;
83
+ readonly uniqueFilter?: never;
84
+ }> {
85
+ readonly [UniqueFilter]?: never;
86
+ }
87
+ type WithoutUniqueFilter<Self> = [Self] extends [HasTypeState<{
88
+ readonly uniqueFilter: true;
89
+ }>] ? never : unknown;
90
+ /** A collection with a filter applied: `C & HasWhere`. */
91
+ type Filtered<C> = C & HasWhere;
92
+ type UniquelyFiltered<C> = C & HasWhere & HasUniqueFilter;
93
+ /** A collection with an order applied: `C & HasOrderBy`. */
94
+ type Ordered<C> = C & HasOrderBy;
95
+ /** A collection whose rows also have the fields of `Added`, such as an included relation. */
96
+ type Including<C extends HasRow, Added> = C & HasRow<CollectionRowOf<C> & Added>;
97
+ /** A query fragment: a function from one collection to another. `collection.with(fragment)` runs it. A fragment that only adds conditions is also called a scope. */
98
+ type QueryFragment<In, Out> = (collection: In) => Out;
99
+ /** What a fragment made by `collection.fragment` accepts: a collection of the model, in the same namespace when the fragment's collection names one, whose rows have every field of the model and that is not narrowed to a variant. */
100
+ type ModelFragmentReceiver<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = HasRow<DefaultModelRow<TContract, ModelName, NsId>> & HasTypeState<[NsId] extends [never] ? {
101
+ readonly variantValue: undefined;
102
+ } : {
103
+ readonly variantValue: undefined;
104
+ readonly nsId: NsId;
105
+ }> & {
106
+ readonly modelName: ModelName;
107
+ };
108
+ /** The type state of a collection. */
109
+ type CollectionTypeStateOf<C extends HasTypeState> = C[typeof TypeState];
110
+ /** The rows a collection produces, as one object type. Declarations print it by this name, so it never names `RowType`. */
111
+ type CollectionRowOf<C extends HasRow> = C[typeof RowType] extends (infer Row extends C[typeof RowType]) ? { [K in keyof Row]: Row[K]; } : never;
112
+ //#endregion
16
113
  //#region src/types.d.ts
17
- interface IncludeScalar<Result> extends RowSelection<Result> {
114
+ interface IncludeScalar<Result> extends HasRow<Result> {
18
115
  readonly kind: 'includeScalar';
19
116
  /** An operation name from the contract's emitted aggregate map — an open vocabulary. */
20
117
  readonly fn: string;
@@ -30,7 +127,7 @@ interface IncludeScalarBranch {
30
127
  readonly selector: IncludeScalar<unknown>;
31
128
  }
32
129
  type IncludeCombineBranch = IncludeRowsBranch | IncludeScalarBranch;
33
- interface IncludeCombine<ResultShape extends Record<string, unknown>> extends RowSelection<ResultShape> {
130
+ interface IncludeCombine<ResultShape extends Record<string, unknown>> extends HasRow<ResultShape> {
34
131
  readonly kind: 'includeCombine';
35
132
  readonly branches: Readonly<Record<string, IncludeCombineBranch>>;
36
133
  }
@@ -52,16 +149,20 @@ interface IncludeExpr {
52
149
  readonly relatedModelName: string;
53
150
  readonly relatedNamespaceId: string;
54
151
  readonly relatedTableName: string;
55
- readonly localTableName: string;
56
- readonly targetColumn: string;
57
- readonly localColumn: string;
152
+ readonly localVariantValue?: string;
153
+ /** Target-side join columns, positionally paired with `localColumns`. */
154
+ readonly targetColumns: readonly string[];
155
+ /** Local-side join columns, positionally paired with `targetColumns`. */
156
+ readonly localColumns: readonly string[];
58
157
  readonly cardinality: RelationCardinalityTag | undefined;
59
158
  readonly through?: IncludeThroughDescriptor;
159
+ readonly junction?: AliasedTable;
60
160
  readonly nested: CollectionState;
61
161
  readonly scalar: IncludeScalar<unknown> | undefined;
62
162
  readonly combine: Readonly<Record<string, IncludeCombineBranch>> | undefined;
63
163
  }
64
164
  interface CollectionState {
165
+ readonly tables: CollectionTables;
65
166
  readonly filters: readonly AnyExpression[];
66
167
  readonly includes: readonly IncludeExpr[];
67
168
  readonly orderBy: readonly OrderByItem[] | undefined;
@@ -69,24 +170,27 @@ interface CollectionState {
69
170
  readonly distinct: readonly string[] | undefined;
70
171
  readonly distinctOn: readonly string[] | undefined;
71
172
  readonly selectedFields: readonly string[] | undefined;
72
- readonly limit: number | undefined;
73
- readonly offset: number | undefined;
74
- readonly variantName: string | undefined;
75
- /**
76
- * Annotations attached to this query at terminal-call time.
77
- * Populated transiently by terminal methods (`first`, `all`, `create`,
78
- * etc.) just before dispatch — `Collection` itself has no chainable
79
- * `.annotate()`. Stored as a `Map<namespace, AnnotationValue>` so
80
- * duplicate namespaces last-write-win. Empty on a fresh state.
81
- */
82
- readonly annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;
173
+ readonly limit: LimitOffsetValue | undefined;
174
+ readonly offset: LimitOffsetValue | undefined;
175
+ readonly variantValue: string | undefined;
176
+ readonly locking: ReadonlyArray<LockingClause> | undefined;
177
+ }
178
+ declare function emptyState(tables: CollectionTables): CollectionState;
179
+ /**
180
+ * `GroupedCollection`'s own post-group chain — orders/pages the grouped rows
181
+ * themselves. Kept separate from {@link CollectionState}: pre-group and
182
+ * post-group clauses are different clauses at different levels, and merging
183
+ * them into one state is the defect this shape exists to prevent.
184
+ */
185
+ interface GroupPagingState {
186
+ readonly orderBy: readonly OrderByItem[];
187
+ readonly limit: LimitOffsetValue | undefined;
188
+ readonly offset: LimitOffsetValue | undefined;
83
189
  }
84
- declare function emptyState(): CollectionState;
85
190
  interface CollectionTypeState {
86
191
  readonly hasOrderBy: boolean;
87
192
  readonly hasWhere: boolean;
88
- readonly hasUniqueFilter: boolean;
89
- readonly variantName: string | undefined;
193
+ readonly variantValue: string | undefined;
90
194
  /**
91
195
  * The namespace coordinate this collection resolves at — set by the
92
196
  * `orm.<ns>.<Model>` facet so the create/update/where input types (and the
@@ -99,10 +203,9 @@ interface CollectionTypeState {
99
203
  }
100
204
  type RelationCardinalityTag = '1:1' | 'N:1' | '1:N' | 'N:M';
101
205
  type DefaultCollectionTypeState = {
102
- readonly hasOrderBy: false;
103
- readonly hasWhere: false;
104
- readonly hasUniqueFilter: false;
105
- readonly variantName: undefined;
206
+ readonly hasOrderBy: boolean;
207
+ readonly hasWhere: boolean;
208
+ readonly variantValue: undefined;
106
209
  readonly nsId: never;
107
210
  };
108
211
  type WithNsId<State extends CollectionTypeState, NsId extends string> = Omit<State, 'nsId'> & {
@@ -116,7 +219,8 @@ interface RuntimeTransaction extends RuntimeScope {
116
219
  commit?(): Promise<void>;
117
220
  rollback?(): Promise<void>;
118
221
  }
119
- interface RuntimeQueryable extends RuntimeScope {
222
+ /** What the ORM sends its statements to. It must carry an `activitySource` member, as the SQL runtime's queryables, connections, transactions and activity handles do: every terminal method starts an `orm-call` activity through it, and a terminal method on a queryable without one fails with `ORM.ACTIVITY_SOURCE_MISSING`. The member is optional in this type only because the public runtime types do not show it. */
223
+ interface RuntimeQueryable extends RuntimeScope, Partial<ActivitySourceTarget> {
120
224
  connection?(): Promise<RuntimeConnection>;
121
225
  transaction?(): Promise<RuntimeTransaction>;
122
226
  }
@@ -124,27 +228,48 @@ interface CollectionContext<TContract extends Contract<SqlStorage>> {
124
228
  readonly runtime: RuntimeQueryable;
125
229
  readonly context: ExecutionContext<TContract>;
126
230
  }
127
- type ComparisonMethodFns<T> = {
128
- eq(value: T): AnyExpression;
129
- neq(value: T): AnyExpression;
231
+ type PredicateOperand<T, CodecId extends string> = T | Expression<{
232
+ codecId: CodecId;
233
+ nullable: false;
234
+ many?: never;
235
+ }>;
236
+ type ComparisonMethodFns<T, CodecId extends string = never> = {
237
+ eq(value: T | Expression<{
238
+ codecId: CodecId;
239
+ nullable: boolean;
240
+ many?: never;
241
+ }>): AnyExpression;
242
+ neq(value: T | Expression<{
243
+ codecId: CodecId;
244
+ nullable: boolean;
245
+ many?: never;
246
+ }>): AnyExpression;
130
247
  gt(value: T): AnyExpression;
131
248
  lt(value: T): AnyExpression;
132
249
  gte(value: T): AnyExpression;
133
250
  lte(value: T): AnyExpression;
134
- like(pattern: string): AnyExpression;
251
+ like(pattern: PredicateOperand<string, CodecId>): AnyExpression;
135
252
  in(values: readonly T[]): AnyExpression;
136
253
  notIn(values: readonly T[]): AnyExpression;
137
254
  isNull(): AnyExpression;
138
255
  isNotNull(): AnyExpression;
139
- asc(): OrderByItem;
140
- desc(): OrderByItem;
256
+ asc: Orderable['asc'];
257
+ desc: Orderable['desc'];
258
+ };
259
+ type OrderOptions = {
260
+ readonly nulls?: OrderByNulls;
261
+ };
262
+ /** A value the collection can order by: `asc`/`desc`, optionally placing nulls first or last. */
263
+ type Orderable = {
264
+ asc(options?: OrderOptions): OrderByItem;
265
+ desc(options?: OrderOptions): OrderByItem;
141
266
  };
142
267
  /**
143
268
  * Trait-gated comparison methods. Only methods whose required traits are all present in `Traits` are included.
144
269
  *
145
270
  * - `traits: []` → always available (isNull, isNotNull)
146
271
  */
147
- type ComparisonMethods<T, Traits> = { [K in keyof ComparisonMethodsMeta as [ComparisonMethodsMeta[K]['traits'][number]] extends [Traits] ? K : never]: ComparisonMethodFns<T>[K]; };
272
+ type ComparisonMethods<T, Traits, CodecId extends string = never> = { [K in keyof ComparisonMethodsMeta as [ComparisonMethodsMeta[K]['traits'][number]] extends [Traits] ? K : never]: ComparisonMethodFns<PredicateOperand<T, CodecId>, CodecId>[K]; };
148
273
  type QueryOperationReturnTraits<Returns, TCodecTypes extends Record<string, unknown>> = Returns extends {
149
274
  readonly codecId: infer Id extends string;
150
275
  } ? Id extends keyof TCodecTypes ? TCodecTypes[Id] extends {
@@ -187,7 +312,26 @@ type OpMatchesField<Op, CodecId extends string, CT extends Record<string, unknow
187
312
  } ? CodecId extends keyof CT ? CT[CodecId] extends {
188
313
  readonly traits: infer FieldTraits;
189
314
  } ? [RequiredTraits[number]] extends [FieldTraits] ? true : false : false : false : false : false;
190
- type FieldOperations<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string> = FieldCodecId<TContract, ModelName, FieldName> extends (infer CodecId extends string) ? ExtractQueryOperationTypes<TContract> extends (infer AllOps) ? { [OpName in keyof AllOps & string as OpMatchesField<AllOps[OpName], CodecId, ExtractCodecTypes<TContract>> extends true ? OpName : never]: QueryOperationMethod<AllOps[OpName], ExtractCodecTypes<TContract>>; } : unknown : unknown;
315
+ type CodecOperations<TContract extends Contract<SqlStorage>, CodecId extends string> = ExtractQueryOperationTypes<TContract> extends (infer AllOps) ? { [OpName in keyof AllOps & string as OpMatchesField<AllOps[OpName], CodecId, ExtractCodecTypes<TContract>> extends true ? OpName : never]: QueryOperationMethod<AllOps[OpName], ExtractCodecTypes<TContract>>; } : unknown;
316
+ type FieldOperations<TContract extends Contract<SqlStorage>, NsId extends string, ModelName extends string, FieldName extends string> = FieldCodecId<TContract, ModelName, FieldName, NsId> extends (infer CodecId extends string) ? ExtractQueryOperationTypes<TContract> extends (infer AllOps) ? { [OpName in keyof AllOps & string as OpMatchesField<AllOps[OpName], CodecId, ExtractCodecTypes<TContract>> extends true ? OpName : never]: QueryOperationMethod<AllOps[OpName], ExtractCodecTypes<TContract>>; } : unknown : unknown;
317
+ type CodecTraits<TContract extends Contract<SqlStorage>, CodecId extends string> = CodecId extends keyof ExtractCodecTypes<TContract> ? ExtractCodecTypes<TContract>[CodecId] extends {
318
+ readonly traits: infer T;
319
+ } ? T : never : never;
320
+ type CodecInput<TContract extends Contract<SqlStorage>, CodecId extends string> = CodecId extends keyof ExtractCodecTypes<TContract> ? ExtractCodecTypes<TContract>[CodecId] extends {
321
+ readonly input: infer I;
322
+ } ? I : unknown : unknown;
323
+ /**
324
+ * The model accessor's type for any field with the codec `CodecId` and the given nullability. A function of `{ deletedAt: CodecField<Contract, 'pg/timestamptz-temporal@1', true> }` is a `where` callback for every model with such a field. Values are checked against the codec's input type, as they are for a model's own fields.
325
+ */
326
+ type CodecField<TContract extends Contract<SqlStorage>, CodecId extends keyof ExtractCodecTypes<TContract> & string, Nullable extends boolean = false> = Expression<{
327
+ codecId: CodecId;
328
+ nullable: Nullable;
329
+ }> & ComparisonMethods<CodecInput<TContract, CodecId> | (Nullable extends true ? null : never), CodecTraits<TContract, CodecId>, CodecId> & CodecOperations<TContract, CodecId>;
330
+ /** The model accessor's type for a list field whose elements have the codec `CodecId`, as a fragment for any model declares it with `.many()`, or with `.many({ elementsNullable: true })` when `ElementNullable` is `true`. */
331
+ type CodecListField<TContract extends Contract<SqlStorage>, CodecId extends keyof ExtractCodecTypes<TContract> & string, Nullable extends boolean = false, ElementNullable extends boolean = false> = Expression<{
332
+ codecId: CodecId;
333
+ nullable: Nullable;
334
+ }> & ComparisonMethods<ReadonlyArray<CodecInput<TContract, CodecId> | (ElementNullable extends true ? null : never)> | (Nullable extends true ? null : never), CodecTraits<TContract, CodecId>, CodecId> & CodecOperations<TContract, CodecId>;
191
335
  /**
192
336
  * Declares trait requirements and runtime factory for each comparison method.
193
337
  *
@@ -233,11 +377,11 @@ declare const COMPARISON_METHODS_META: {
233
377
  };
234
378
  readonly asc: {
235
379
  readonly traits: readonly ["order"];
236
- readonly create: (left: AnyExpression) => () => OrderByItem;
380
+ readonly create: (left: AnyExpression) => (options?: OrderOptions) => OrderByItem;
237
381
  };
238
382
  readonly desc: {
239
383
  readonly traits: readonly ["order"];
240
- readonly create: (left: AnyExpression) => () => OrderByItem;
384
+ readonly create: (left: AnyExpression) => (options?: OrderOptions) => OrderByItem;
241
385
  };
242
386
  readonly isNull: {
243
387
  readonly traits: readonly [];
@@ -249,27 +393,115 @@ declare const COMPARISON_METHODS_META: {
249
393
  };
250
394
  };
251
395
  type ComparisonMethodsMeta = typeof COMPARISON_METHODS_META;
252
- type RelationPredicate<TContract extends Contract<SqlStorage>, ModelName extends string> = (model: ModelAccessor<TContract, ModelName>) => AnyExpression;
253
- type RelationPredicateInput<TContract extends Contract<SqlStorage>, ModelName extends string> = RelationPredicate<TContract, ModelName> | Record<string, unknown>;
254
- type RelationFilterAccessor<TContract extends Contract<SqlStorage>, RelatedModelName extends string> = {
255
- some(predicate?: RelationPredicateInput<TContract, RelatedModelName>): AnyExpression;
256
- every(predicate: RelationPredicateInput<TContract, RelatedModelName>): AnyExpression;
257
- none(predicate?: RelationPredicateInput<TContract, RelatedModelName>): AnyExpression;
396
+ type DomainNamespaceId<TContract extends Contract<SqlStorage>> = keyof TContract['domain']['namespaces'] & string;
397
+ type RelationPredicate<TContract extends Contract<SqlStorage>, NsId extends DomainNamespaceId<TContract>, ModelName extends string> = (model: ModelAccessor<TContract, ModelName, NsId>, tools: ModelCallbackTools<TContract, ModelName, NsId>) => Condition;
398
+ type RelationPredicateInput<TContract extends Contract<SqlStorage>, NsId extends DomainNamespaceId<TContract>, ModelName extends string> = RelationPredicate<TContract, NsId, ModelName> | Record<string, unknown>;
399
+ type RelationFilterAccessor<TContract extends Contract<SqlStorage>, RelatedNsId extends DomainNamespaceId<TContract>, RelatedModelName extends string> = {
400
+ some(predicate?: RelationPredicateInput<TContract, RelatedNsId, RelatedModelName>): AnyExpression;
401
+ every(predicate: RelationPredicateInput<TContract, RelatedNsId, RelatedModelName>): AnyExpression;
402
+ none(predicate?: RelationPredicateInput<TContract, RelatedNsId, RelatedModelName>): AnyExpression;
403
+ };
404
+ type RelationAccessorMethodName = keyof RelationFilterAccessor<Contract<SqlStorage>, never, string> | 'count';
405
+ type IsOrderable<Traits> = ['order'] extends [Traits] ? true : false;
406
+ type OrderableFields<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string> = { [K in keyof FieldsOf<TContract, ModelName, NsId> & string as IsOrderable<FieldTraits<TContract, ModelName, K, NsId>> extends true ? K : never]: Orderable; };
407
+ /** The fields of a model whose codec has the `order` trait. */
408
+ type OrderableFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = keyof OrderableFields<TContract, ModelName, NsId> & string;
409
+ /**
410
+ * A to-one relation inside `where`/`orderBy`: the relation filters plus each orderable scalar field of the related model. A related field named like a relation method is not exposed.
411
+ */
412
+ type ToOneRelationAccessor<TContract extends Contract<SqlStorage>, RelatedNsId extends DomainNamespaceId<TContract>, RelatedModelName extends string> = RelationFilterAccessor<TContract, RelatedNsId, RelatedModelName> & Omit<OrderableFields<TContract, RelatedModelName, RelatedNsId>, RelationAccessorMethodName>;
413
+ /**
414
+ * A to-many relation inside `where`/`orderBy`: the relation filters plus `count`, which orders by the number of related rows matching an optional predicate.
415
+ */
416
+ type ToManyRelationAccessor<TContract extends Contract<SqlStorage>, RelatedNsId extends DomainNamespaceId<TContract>, RelatedModelName extends string> = RelationFilterAccessor<TContract, RelatedNsId, RelatedModelName> & {
417
+ count(predicate?: RelationPredicateInput<TContract, RelatedNsId, RelatedModelName>): Orderable;
258
418
  };
259
419
  type ScalarModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in keyof FieldsOf<TContract, ModelName, NsId> & string]: Expression<{
260
420
  codecId: FieldCodecId<TContract, ModelName, K, NsId>;
261
421
  nullable: FieldNullable<TContract, ModelName, K, NsId>;
262
- }> & ComparisonMethods<FieldJsType<TContract, ModelName, K, NsId>, FieldTraits<TContract, ModelName, K, NsId>> & FieldOperations<TContract, ModelName, K>; };
263
- type RelationModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string> = { [K in RelationNames<TContract, ModelName>]: RelationFilterAccessor<TContract, RelatedModelName<TContract, ModelName, K> & string>; };
264
- type ModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ScalarModelAccessor<TContract, ModelName, NsId> & RelationModelAccessor<TContract, ModelName>;
422
+ }> & ComparisonMethods<FieldInputJsType<TContract, ModelName, K, NsId>, FieldTraits<TContract, ModelName, K, NsId>, FieldCodecId<TContract, ModelName, K, NsId>> & FieldOperations<TContract, NsId, ModelName, K>; };
423
+ type RelationModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in RelationNames<TContract, ModelName, NsId>]: RelationCardinality<TContract, ModelName, K, NsId> extends '1:1' | 'N:1' ? ToOneRelationAccessor<TContract, RelationTargetNamespace<TContract, ModelName, K, NsId>, RelatedModelName<TContract, ModelName, K, NsId> & string> : ToManyRelationAccessor<TContract, RelationTargetNamespace<TContract, ModelName, K, NsId>, RelatedModelName<TContract, ModelName, K, NsId> & string>; };
424
+ type ModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ScalarModelAccessor<TContract, ModelName, NsId> & RelationModelAccessor<TContract, ModelName, NsId>;
265
425
  /**
266
426
  * The predicate accessor for a collection narrowed to a variant. When a real
267
427
  * variant is selected its (possibly MTI) fields and relations are merged onto
268
- * the base accessor so `t.variant('Feature').where(x => x.priority…)` and
269
- * `t.variant('Feature').where(x => x.assignee.some(…))` type-check; with no
428
+ * the base accessor so `t.variant('feature').where(x => x.priority…)` and
429
+ * `t.variant('feature').where(x => x.assignee.some(…))` type-check; with no
270
430
  * variant the accessor is the plain base `ModelAccessor` and is unchanged.
271
431
  */
272
- type VariantAwareModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName extends string | undefined, NsId extends string = never> = [VariantName] extends [string] ? VariantName extends VariantNames<TContract, ModelName, NsId> ? ScalarModelAccessor<TContract, ModelName, NsId> & ScalarModelAccessor<TContract, VariantName, NsId> & RelationModelAccessor<TContract, ModelName> & RelationModelAccessor<TContract, VariantName> : ModelAccessor<TContract, ModelName, NsId> : ModelAccessor<TContract, ModelName, NsId>;
432
+ type VariantAwareModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue extends string | undefined, NsId extends string = never> = [VariantValue] extends [string] ? VariantValue extends DiscriminatorValues<TContract, ModelName, NsId> ? ScalarModelAccessor<TContract, ModelName, NsId> & ScalarModelAccessor<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> & RelationModelAccessor<TContract, ModelName, NsId> & RelationModelAccessor<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> : ModelAccessor<TContract, ModelName, NsId> : ModelAccessor<TContract, ModelName, NsId>;
433
+ /** A condition from `fns`. */
434
+ type FunctionCondition = Expression<BooleanCodecType>;
435
+ /** A condition: an ORM filter expression, or a condition from `fns`. */
436
+ type Condition = AnyExpression | FunctionCondition;
437
+ /** What a `where` callback may return: a filter, or a condition from `fns`. */
438
+ type WhereCallbackResult = WhereArg | FunctionCondition;
439
+ type IsBooleanCodec<CodecId, TCodecTypes extends Record<string, unknown>> = CodecId extends keyof TCodecTypes ? TCodecTypes[CodecId] extends {
440
+ readonly traits: infer Traits;
441
+ } ? 'boolean' extends Traits ? true : false : false : false;
442
+ /** A function's result in the ORM: a value, as opposed to a condition, also has `asc()` and `desc()`. */
443
+ type OrmFunctionResult<R, TCodecTypes extends Record<string, unknown>> = R extends Expression<infer Field> ? IsBooleanCodec<Field['codecId'], TCodecTypes> extends true ? R : R & Orderable : R;
444
+ type SameSignature<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
445
+ /**
446
+ * An operation's implementation with each result as {@link OrmFunctionResult}. Matching four call signatures reads the last four overloads, and TypeScript repeats the signatures of an implementation with fewer; a single signature stays one. An implementation with five or more overloads loses all but its last four, and a generic signature keeps its parameters at their constraints.
447
+ */
448
+ type OrmOperation<Impl, CT extends Record<string, unknown>> = Impl extends {
449
+ (...args: infer A1): infer R1;
450
+ (...args: infer A2): infer R2;
451
+ (...args: infer A3): infer R3;
452
+ (...args: infer A4): infer R4;
453
+ } ? SameSignature<[A1, R1] | [A2, R2] | [A3, R3], [A4, R4]> extends true ? (...args: A4) => OrmFunctionResult<R4, CT> : {
454
+ (...args: A1): OrmFunctionResult<R1, CT>;
455
+ (...args: A2): OrmFunctionResult<R2, CT>;
456
+ (...args: A3): OrmFunctionResult<R3, CT>;
457
+ (...args: A4): OrmFunctionResult<R4, CT>;
458
+ } : Impl;
459
+ /** `fns.raw` in the ORM: its result also has `asc()` and `desc()`. */
460
+ interface OrmRawSqlBuilder {
461
+ returns<S extends string>(spec: S): Expression<{
462
+ codecId: S;
463
+ nullable: false;
464
+ }> & Orderable;
465
+ returns<S extends string, N extends boolean = false>(spec: {
466
+ readonly codecId: S;
467
+ readonly nullable?: N;
468
+ }): Expression<{
469
+ codecId: S;
470
+ nullable: N;
471
+ }> & Orderable;
472
+ }
473
+ type OrmRawSqlTag = (strings: TemplateStringsArray, ...values: RawSqlInterpolation[]) => OrmRawSqlBuilder;
474
+ /** `fns.and` and `fns.or` in the ORM: they also take ORM conditions, such as `p.title.ilike(...)`. */
475
+ type OrmLogicalFunction<CT extends Record<string, {
476
+ readonly input: unknown;
477
+ }>> = (...conditions: (AnyExpression | CodecExpression<'pg/bool@1', boolean, CT>)[]) => FunctionCondition;
478
+ /** The SQL query builder's functions over the given codec types and query operations, as the ORM's callbacks receive them. */
479
+ type OrmFunctionsOf<CT extends Record<string, {
480
+ readonly input: unknown;
481
+ }>, OT extends QueryOperationTypesBase> = Omit<BuiltinFunctions<CT>, 'raw' | 'and' | 'or'> & {
482
+ readonly raw: OrmRawSqlTag;
483
+ readonly and: OrmLogicalFunction<CT>;
484
+ readonly or: OrmLogicalFunction<CT>;
485
+ } & { readonly [K in keyof OT]: OrmOperation<OT[K]['impl'], CT>; };
486
+ /** The SQL query builder's functions for a contract, as the ORM's callbacks receive them. */
487
+ type OrmFunctions<TContract extends Contract<SqlStorage>> = OrmFunctionsOf<ExtractCodecTypes<TContract>, ExtractQueryOperationTypes<TContract>>;
488
+ /** The indexes of the table a model is stored in, keyed by the name the contract source gave each. */
489
+ type ModelIndexReferences<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = string extends NsId ? Readonly<Record<string, IndexReference>> : TableIndexReferences<NamespaceTableDef<TContract, ModelTableName<TContract, ModelName, NsId> & string, ResolvedNsId<TContract, ModelName, NsId>>>;
490
+ /** One model as a collection method contribution reads it: the contract's target, the model's fields and relations, and its storage table. */
491
+ type CollectionMethodModelTypeOf<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string> = {
492
+ readonly target: TContract['target'];
493
+ readonly name: ModelName;
494
+ readonly fields: FieldsOf<TContract, ModelName, NsId>;
495
+ readonly relations: ModelDef<TContract, ModelName, NsId> extends {
496
+ readonly relations: infer Relations extends object;
497
+ } ? Relations : Record<string, never>;
498
+ readonly table: NamespaceTableDef<TContract, ModelTableName<TContract, ModelName, NsId> & string, ResolvedNsId<TContract, ModelName, NsId>>;
499
+ };
500
+ /** The second argument of a `where` or `orderBy` callback: the SQL query builder's functions, and the model's indexes. */
501
+ interface ModelCallbackTools<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> {
502
+ readonly fns: OrmFunctions<TContract>;
503
+ readonly indexes: ModelIndexReferences<TContract, ModelName, NsId>;
504
+ }
273
505
  /**
274
506
  * The flat default row of a single model: its own declared fields mapped to
275
507
  * their JS types, with no variant flattening. Use this when you want exactly
@@ -283,6 +515,10 @@ type VariantAwareModelAccessor<TContract extends Contract<SqlStorage>, ModelName
283
515
  * re-expressed in terms of `InferRootRow`.
284
516
  */
285
517
  type DefaultModelRow<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in keyof FieldsOf<TContract, ModelName, NsId> & string]: FieldJsType<TContract, ModelName, K, NsId>; };
518
+ /**
519
+ * The values a filter, `create` or `update` accepts for each of a model's own fields. A field whose read type is refined by its type parameters, such as `Char<36>`, accepts its codec's input type, such as `string`.
520
+ */
521
+ type DefaultModelInputRow<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in keyof FieldsOf<TContract, ModelName, NsId> & string]: FieldInputJsType<TContract, ModelName, K, NsId>; };
286
522
  type Simplify<T> = { [K in keyof T]: T[K]; } & {};
287
523
  type VariantRow<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
288
524
  readonly discriminator: {
@@ -290,20 +526,30 @@ type VariantRow<TContract extends Contract<SqlStorage>, ModelName extends string
290
526
  };
291
527
  readonly variants: infer V;
292
528
  } ? V extends Record<string, {
293
- readonly value: string;
294
- }> ? { [VK in keyof V]: VK extends string & CollectionModelName<TContract> ? Simplify<Omit<DefaultModelRow<TContract, ModelName, NsId>, DiscField> & DefaultModelRow<TContract, VK, NsId> & Record<DiscField, V[VK]['value']>> : never; }[keyof V] : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId>;
529
+ readonly model: string;
530
+ }> ? { [Value in keyof V & string]: V[Value]['model'] extends (infer VK extends string & CollectionModelName<TContract>) ? Simplify<Omit<DefaultModelRow<TContract, ModelName, NsId>, DiscField> & DefaultModelRow<TContract, VK, VariantModelNamespace<TContract, ModelName, Value, NsId>> & Record<DiscField, Value>> : never; }[keyof V & string] : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId>;
295
531
  type InferRootRow<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = VariantRow<TContract, ModelName, NsId>;
296
- type VariantNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
532
+ type DiscriminatorValues<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
297
533
  readonly variants: infer V extends Record<string, unknown>;
298
534
  } ? keyof V & string : never;
299
- type VariantModelRow<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
535
+ type VariantModelName<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
536
+ readonly variants: infer V;
537
+ } ? VariantValue extends keyof V ? V[VariantValue] extends {
538
+ readonly model: infer Model extends string;
539
+ } ? Model : never : never : never;
540
+ type VariantModelNamespace<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, NsId extends string = never> = [NsId] extends [never] ? never : ModelDef<TContract, ModelName, NsId> extends {
541
+ readonly variants: infer V;
542
+ } ? VariantValue extends keyof V ? V[VariantValue] extends {
543
+ readonly namespace: infer Namespace extends string;
544
+ } ? ContractNamespaceKey<TContract, Namespace> : never : never : never;
545
+ type VariantModelRow<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
300
546
  readonly discriminator: {
301
547
  readonly field: infer DiscField extends string;
302
548
  };
303
549
  readonly variants: infer V;
304
550
  } ? V extends Record<string, {
305
- readonly value: string;
306
- }> ? VariantName extends keyof V & string & CollectionModelName<TContract> ? Simplify<Omit<DefaultModelRow<TContract, ModelName, NsId>, DiscField> & DefaultModelRow<TContract, VariantName, NsId> & Record<DiscField, V[VariantName]['value']>> : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId>;
551
+ readonly model: string;
552
+ }> ? VariantValue extends keyof V ? V[VariantValue]['model'] extends (infer VK extends string & CollectionModelName<TContract>) ? Simplify<Omit<DefaultModelRow<TContract, ModelName, NsId>, DiscField> & DefaultModelRow<TContract, VK, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> & Record<DiscField, VariantValue>> : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId> : DefaultModelRow<TContract, ModelName, NsId>;
307
553
  /**
308
554
  * The value an aggregate hands the application, read from the contract's emitted aggregate map.
309
555
  *
@@ -430,22 +676,24 @@ type IncludeReducerMethod<TContract extends Contract<SqlStorage>, ModelName exte
430
676
  * index signature off the collection surface.
431
677
  */
432
678
  type AggregateIncludeReducers<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = string extends AggregateOperationNames<TContract> ? AggregateOperationsUnavailable : { readonly [Op in AggregateOperationNames<TContract>]: IncludeReducerMethod<TContract, ModelName, Op, NsId>; };
433
- type HavingComparisonMethods<T> = Pick<ComparisonMethods<T, 'equality' | 'order'>, 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte'>;
679
+ type HavingComparisonMethods<T, CodecId extends string = never> = Pick<ComparisonMethods<T, 'equality' | 'order', CodecId>, 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte'>;
434
680
  /**
435
- * The value a HAVING comparison accepts. The comparison happens inside the
436
- * database, where the operand is an inlined numeric literal — so the
437
- * comparand stays `number` regardless of the result's application
438
- * representation. A field-taking metric compares as `number | null` — a
681
+ * Literal HAVING comparands stay `number` regardless of the result's application
682
+ * representation; prepared comparands carry the declared aggregate output codec.
683
+ * A field-taking metric compares as `number | null` — a
439
684
  * grouped value's SQL domain includes NULL; a no-input metric reads
440
685
  * nullability off its declared row, so `count()` compares as plain `number`.
441
686
  */
442
687
  type HavingZeroArgComparand<Row> = Row extends {
443
688
  readonly nullable: infer Nullable extends boolean;
444
689
  } ? Nullable extends true ? number | null : number : never;
445
- type FieldHavingCall<TContract extends Contract<SqlStorage>, ModelName extends string, Op extends string, NsId extends string> = <FieldName extends AggregateFieldNames<TContract, ModelName, Op, NsId>>(field: FieldName) => HavingComparisonMethods<number | null>;
690
+ type AggregateOutputCodecId<Row> = Row extends {
691
+ readonly output: infer Id extends string;
692
+ } ? Id : never;
693
+ type FieldHavingCall<TContract extends Contract<SqlStorage>, ModelName extends string, Op extends string, NsId extends string> = <FieldName extends AggregateFieldNames<TContract, ModelName, Op, NsId>>(field: FieldName) => HavingComparisonMethods<number | null, AggregateOutputCodecId<AggregateRowFor<TContract, Op, FieldCodecId<TContract, ModelName, FieldName, NsId>>>>;
446
694
  type HavingMethod<TContract extends Contract<SqlStorage>, ModelName extends string, Op extends string, NsId extends string> = HasZeroArgCall<TContract, Op> extends true ? {
447
- (): HavingComparisonMethods<HavingZeroArgComparand<AggregateRowFor<TContract, Op, never>>>;
448
- <FieldName extends AggregateFieldNames<TContract, ModelName, Op, NsId>>(field: FieldName): HavingComparisonMethods<number | null>;
695
+ (): HavingComparisonMethods<HavingZeroArgComparand<AggregateRowFor<TContract, Op, never>>, AggregateOutputCodecId<AggregateRowFor<TContract, Op, never>>>;
696
+ <FieldName extends AggregateFieldNames<TContract, ModelName, Op, NsId>>(field: FieldName): HavingComparisonMethods<number | null, AggregateOutputCodecId<AggregateRowFor<TContract, Op, FieldCodecId<TContract, ModelName, FieldName, NsId>>>>;
449
697
  } : FieldHavingCall<TContract, ModelName, Op, NsId>;
450
698
  /**
451
699
  * The metric surface `groupBy().having()` hands its callback, derived from
@@ -458,7 +706,11 @@ type HavingMethod<TContract extends Contract<SqlStorage>, ModelName extends stri
458
706
  * methods.
459
707
  */
460
708
  type HavingBuilder<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = string extends AggregateOperationNames<TContract> ? AggregateOperationsUnavailable : { readonly [Op in AggregateOperationNames<TContract> & AggregateFn]: HavingMethod<TContract, ModelName, Op, NsId>; };
461
- type ShorthandWhereFilter<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Partial<{ [K in keyof DefaultModelRow<TContract, ModelName, NsId> & string]: DefaultModelRow<TContract, ModelName, NsId>[K] | null | undefined; }>;
709
+ type ShorthandWhereFilter<TContract extends Contract<SqlStorage>, NsId extends DomainNamespaceId<TContract>, ModelName extends string> = Partial<{ [K in keyof DefaultModelInputRow<TContract, ModelName, NsId> & string]: DefaultModelInputRow<TContract, ModelName, NsId>[K] | ('equality' extends FieldTraits<TContract, ModelName, K, NsId> ? Expression<{
710
+ codecId: FieldCodecId<TContract, ModelName, K, NsId>;
711
+ nullable: boolean;
712
+ many?: never;
713
+ }> : never) | null | undefined; }>;
462
714
  type NamespaceModelsOf<TContract extends Contract<SqlStorage>, NsId extends string> = NsId extends keyof TContract['domain']['namespaces'] ? TContract['domain']['namespaces'][NsId]['models'] extends (infer M extends Record<string, unknown>) ? M : Record<string, never> : Record<string, never>;
463
715
  type ScannedModelDef<TContract extends Contract<SqlStorage>, ModelName extends string> = { [Ns in keyof TContract['domain']['namespaces']]: ModelName extends keyof TContract['domain']['namespaces'][Ns]['models'] ? TContract['domain']['namespaces'][Ns]['models'][ModelName] : never; }[keyof TContract['domain']['namespaces']];
464
716
  type ModelDef<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = [NsId] extends [never] ? ScannedModelDef<TContract, ModelName> : ModelName extends keyof NamespaceModelsOf<TContract, NsId> ? NamespaceModelsOf<TContract, NsId>[ModelName] : never;
@@ -511,6 +763,8 @@ type ResolvedStorageColumn<TContract extends Contract<SqlStorage>, ModelName ext
511
763
  type FieldStorageJsType<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = ResolvedStorageColumn<TContract, ModelName, FieldName, NsId> extends (infer Col extends StorageColumn) ? Col extends StorageColumn ? ComputeColumnJsType<TContract, ResolvedNsId<TContract, ModelName, NsId>, ModelTableName<TContract, ModelName, NsId> & string, FieldColumnName<TContract, ModelName, FieldName, NsId> & string, ExtractCodecTypes<TContract>> : never : never;
512
764
  type NamespaceFieldOutputType<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = ResolvedNsId<TContract, ModelName, NsId> extends (infer Ns extends string) ? ExtractFieldOutputTypes<TContract> extends (infer Outputs) ? Ns extends keyof Outputs ? Outputs[Ns] extends (infer NamespaceOutputs) ? ModelName extends keyof NamespaceOutputs ? NamespaceOutputs[ModelName] extends (infer ModelOutputs) ? FieldName extends keyof ModelOutputs ? ModelOutputs[FieldName] : never : never : never : never : never : never : never;
513
765
  type FieldJsType<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = [NamespaceFieldOutputType<TContract, ModelName, FieldName, NsId>] extends [never] ? [FieldStorageJsType<TContract, ModelName, FieldName, NsId>] extends [never] ? unknown : FieldStorageJsType<TContract, ModelName, FieldName, NsId> : NamespaceFieldOutputType<TContract, ModelName, FieldName, NsId>;
766
+ type NamespaceFieldInputType<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = ResolvedNsId<TContract, ModelName, NsId> extends (infer Ns extends string) ? ExtractFieldInputTypes<TContract> extends (infer Inputs) ? Ns extends keyof Inputs ? Inputs[Ns] extends (infer NamespaceInputs) ? ModelName extends keyof NamespaceInputs ? NamespaceInputs[ModelName] extends (infer ModelInputs) ? FieldName extends keyof ModelInputs ? ModelInputs[FieldName] : never : never : never : never : never : never : never;
767
+ type FieldInputJsType<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = [NamespaceFieldInputType<TContract, ModelName, FieldName, NsId>] extends [never] ? FieldJsType<TContract, ModelName, FieldName, NsId> : NamespaceFieldInputType<TContract, ModelName, FieldName, NsId>;
514
768
  type FieldStorageColumn<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = ResolvedStorageColumn<TContract, ModelName, FieldName, NsId>;
515
769
  type FieldCodecId<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = FieldStorageColumn<TContract, ModelName, FieldName, NsId> extends {
516
770
  readonly codecId: infer Id extends string;
@@ -522,27 +776,13 @@ type FieldTraits<TContract extends Contract<SqlStorage>, ModelName extends strin
522
776
  readonly traits: infer T;
523
777
  } ? T : never : never : never;
524
778
  type NumericFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in keyof DefaultModelRow<TContract, ModelName, NsId> & string]: 'numeric' extends FieldTraits<TContract, ModelName, K, NsId> ? K : never; }[keyof DefaultModelRow<TContract, ModelName, NsId> & string];
525
- type ExecutionDefaultEntry<TContract extends Contract<SqlStorage>> = TContract['execution'] extends {
526
- readonly mutations: {
527
- readonly defaults: infer Defaults;
528
- };
529
- } ? Defaults extends ReadonlyArray<unknown> ? Defaults[number] : never : never;
530
- type HasExecutionCreateDefault<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = [Extract<ExecutionDefaultEntry<TContract>, {
531
- readonly ref: {
532
- readonly table: ModelTableName<TContract, ModelName, NsId>;
533
- readonly column: FieldColumnName<TContract, ModelName, FieldName, NsId>;
534
- } & ([NsId] extends [never] ? unknown : {
535
- readonly namespace: NsId;
536
- });
537
- readonly onCreate?: unknown;
538
- }>] extends [never] ? false : true;
539
- type IsOptionalCreateField<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = FieldStorageColumn<TContract, ModelName, FieldName, NsId> extends (infer Column) ? Column extends StorageColumn ? Column['nullable'] extends true ? true : Column extends {
540
- readonly default: unknown;
541
- } ? true : HasExecutionCreateDefault<TContract, ModelName, FieldName, NsId> : HasExecutionCreateDefault<TContract, ModelName, FieldName, NsId> : HasExecutionCreateDefault<TContract, ModelName, FieldName, NsId>;
779
+ type FieldHasExecutionCreateDefault<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = HasExecutionCreateDefault<TContract, ResolvedNsId<TContract, ModelName, NsId>, ModelTableName<TContract, ModelName, NsId>, FieldColumnName<TContract, ModelName, FieldName, NsId>>;
780
+ type IsOptionalCreateField<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string, NsId extends string = never> = FieldStorageColumn<TContract, ModelName, FieldName, NsId> extends (infer Column) ? Column extends StorageColumn ? IsOptionalCreateColumn<TContract, Column, ResolvedNsId<TContract, ModelName, NsId>, ModelTableName<TContract, ModelName, NsId>, FieldColumnName<TContract, ModelName, FieldName, NsId>> : FieldHasExecutionCreateDefault<TContract, ModelName, FieldName, NsId> : FieldHasExecutionCreateDefault<TContract, ModelName, FieldName, NsId>;
542
781
  type CreateFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = keyof DefaultModelRow<TContract, ModelName, NsId> & string;
543
782
  type RequiredCreateFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in CreateFieldNames<TContract, ModelName, NsId>]-?: IsOptionalCreateField<TContract, ModelName, K, NsId> extends true ? never : K; }[CreateFieldNames<TContract, ModelName, NsId>];
544
783
  type OptionalCreateFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = { [K in CreateFieldNames<TContract, ModelName, NsId>]-?: IsOptionalCreateField<TContract, ModelName, K, NsId> extends true ? K : never; }[CreateFieldNames<TContract, ModelName, NsId>];
545
- type CreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Pick<DefaultModelRow<TContract, ModelName, NsId>, RequiredCreateFieldNames<TContract, ModelName, NsId>> & Partial<Pick<DefaultModelRow<TContract, ModelName, NsId>, OptionalCreateFieldNames<TContract, ModelName, NsId>>> & RelationMutationFields<TContract, ModelName, 'create'>;
784
+ type RowCreateFields<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Pick<DefaultModelInputRow<TContract, ModelName, NsId>, RequiredCreateFieldNames<TContract, ModelName, NsId>> & Partial<Pick<DefaultModelInputRow<TContract, ModelName, NsId>, OptionalCreateFieldNames<TContract, ModelName, NsId>>>;
785
+ type CreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = RowCreateFields<TContract, ModelName, NsId> & RelationMutationFields<TContract, ModelName, 'create'>;
546
786
  type IsPolymorphicBase<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
547
787
  readonly discriminator: unknown;
548
788
  readonly variants: Record<string, unknown>;
@@ -552,8 +792,15 @@ type DiscriminatorFieldName<TContract extends Contract<SqlStorage>, ModelName ex
552
792
  readonly field: infer F extends string;
553
793
  };
554
794
  } ? F : never;
555
- type VariantCreateInput<TContract extends Contract<SqlStorage>, BaseModelName extends string, VariantName extends string, NsId extends string = never> = Omit<CreateInput<TContract, BaseModelName, NsId>, DiscriminatorFieldName<TContract, BaseModelName, NsId>> & CreateInput<TContract, VariantName, NsId>;
556
- type ResolvedCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, VName extends string | undefined, NsId extends string = never> = IsPolymorphicBase<TContract, ModelName, NsId> extends true ? VName extends string ? VariantCreateInput<TContract, ModelName, VName, NsId> : never : CreateInput<TContract, ModelName, NsId>;
795
+ type VariantCreateInput<TContract extends Contract<SqlStorage>, BaseModelName extends string, VariantValue extends string, NsId extends string = never> = VariantValue extends string ? Omit<CreateInput<TContract, BaseModelName, NsId>, DiscriminatorFieldName<TContract, BaseModelName, NsId>> & CreateInput<TContract, VariantModelName<TContract, BaseModelName, VariantValue, NsId>, VariantModelNamespace<TContract, BaseModelName, VariantValue, NsId>> : never;
796
+ /**
797
+ * An input with no keys is `Record<string, never>`, not `{}`: TypeScript accepts any object where `{}` is expected, so a model with no fields would accept any key.
798
+ */
799
+ type ClosedWhenEmpty<T> = [keyof T] extends [never] ? Record<string, never> : T;
800
+ /** The scalar fields an update of the model takes. For a model with no fields, it rejects every key. */
801
+ type ScalarUpdateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ClosedWhenEmpty<Partial<DefaultModelInputRow<TContract, ModelName, NsId>>>;
802
+ type ResolvedCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue extends string | undefined, NsId extends string = never> = ClosedWhenEmpty<IsPolymorphicBase<TContract, ModelName, NsId> extends true ? VariantValue extends string ? VariantCreateInput<TContract, ModelName, VariantValue, NsId> : never : CreateInput<TContract, ModelName, NsId>>;
803
+ type ResolvedScalarCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue extends string | undefined, NsId extends string = never> = ClosedWhenEmpty<IsPolymorphicBase<TContract, ModelName, NsId> extends true ? VariantValue extends string ? Omit<RowCreateFields<TContract, ModelName, NsId>, DiscriminatorFieldName<TContract, ModelName, NsId>> & RowCreateFields<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> : never : RowCreateFields<TContract, ModelName, NsId>>;
557
804
  type ModelStorageTableDef<TContract extends Contract<SqlStorage>, ModelName extends string> = ModelTableName<TContract, ModelName> extends (infer TableName extends string) ? NamespaceTableDef<TContract, TableName> : never;
558
805
  type PrimaryKeyConstraintColumns<TContract extends Contract<SqlStorage>, ModelName extends string> = ModelStorageTableDef<TContract, ModelName> extends {
559
806
  readonly primaryKey: {
@@ -566,8 +813,8 @@ type UniqueConstraintColumns<TContract extends Contract<SqlStorage>, ModelName e
566
813
  readonly columns: infer Columns extends readonly string[];
567
814
  } ? Columns : never : never : never;
568
815
  type FieldNameForColumn<TContract extends Contract<SqlStorage>, ModelName extends string, ColumnName extends string> = { [K in keyof DefaultModelRow<TContract, ModelName> & string]: FieldColumnName<TContract, ModelName, K> extends ColumnName ? K : never; }[keyof DefaultModelRow<TContract, ModelName> & string] extends (infer Matched) ? Matched extends string ? Matched : ColumnName : ColumnName;
569
- type RowValueForField<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string> = FieldName extends keyof DefaultModelRow<TContract, ModelName> ? DefaultModelRow<TContract, ModelName>[FieldName] : unknown;
570
- type CriterionFromConstraintColumns<TContract extends Contract<SqlStorage>, ModelName extends string, Columns extends readonly string[]> = string extends Columns[number] ? Record<string, unknown> : { [C in Columns[number] as FieldNameForColumn<TContract, ModelName, C>]: RowValueForField<TContract, ModelName, FieldNameForColumn<TContract, ModelName, C>>; };
816
+ type RowValueForField<TContract extends Contract<SqlStorage>, ModelName extends string, FieldName extends string> = FieldName extends keyof DefaultModelInputRow<TContract, ModelName> ? DefaultModelInputRow<TContract, ModelName>[FieldName] : unknown;
817
+ type CriterionFromConstraintColumns<TContract extends Contract<SqlStorage>, ModelName extends string, Columns extends readonly string[]> = string extends Columns[number] ? Record<string, unknown> : { [C in Columns[number] as FieldNameForColumn<TContract, ModelName, C>]: Exclude<RowValueForField<TContract, ModelName, FieldNameForColumn<TContract, ModelName, C>>, null>; };
571
818
  type ConstraintColumnsUnion<TContract extends Contract<SqlStorage>, ModelName extends string> = PrimaryKeyConstraintColumns<TContract, ModelName> | UniqueConstraintColumns<TContract, ModelName>;
572
819
  type UniqueConstraintCriterion<TContract extends Contract<SqlStorage>, ModelName extends string> = ConstraintColumnsUnion<TContract, ModelName> extends (infer Columns) ? Columns extends readonly string[] ? CriterionFromConstraintColumns<TContract, ModelName, Columns> : never : never;
573
820
  type RelationConnectCriterion<TContract extends Contract<SqlStorage>, ModelName extends string> = [UniqueConstraintCriterion<TContract, ModelName>] extends [never] ? Record<string, unknown> : UniqueConstraintCriterion<TContract, ModelName>;
@@ -658,55 +905,43 @@ type ChildForeignKeyFieldNames<TContract extends Contract<SqlStorage>, ModelName
658
905
  } ? Fields[number] : never : never;
659
906
  type NestedOptionalCreateFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = OptionalCreateFieldNames<TContract, ModelName, NsId> | Extract<ChildForeignKeyFieldNames<TContract, ModelName>, CreateFieldNames<TContract, ModelName, NsId>>;
660
907
  type NestedRequiredCreateFieldNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Exclude<CreateFieldNames<TContract, ModelName, NsId>, NestedOptionalCreateFieldNames<TContract, ModelName, NsId>>;
661
- type NestedCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Pick<DefaultModelRow<TContract, ModelName, NsId>, NestedRequiredCreateFieldNames<TContract, ModelName, NsId>> & Partial<Pick<DefaultModelRow<TContract, ModelName, NsId>, NestedOptionalCreateFieldNames<TContract, ModelName, NsId>>>;
908
+ type NestedCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Pick<DefaultModelInputRow<TContract, ModelName, NsId>, NestedRequiredCreateFieldNames<TContract, ModelName, NsId>> & Partial<Pick<DefaultModelInputRow<TContract, ModelName, NsId>, NestedOptionalCreateFieldNames<TContract, ModelName, NsId>>>;
662
909
  type AtLeastOne<T> = keyof T extends never ? never : { [K in keyof T]-?: Pick<T, K> & Partial<Omit<T, K>>; }[keyof T];
663
910
  type MutationCreateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = NestedCreateInput<TContract, ModelName, NsId> & RelationMutationFields<TContract, ModelName, 'create'>;
664
911
  type MutationCreateInputWithRelations<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = NestedCreateInput<TContract, ModelName, NsId> & AtLeastOne<RelationMutationFields<TContract, ModelName, 'create'>>;
665
- type MutationUpdateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = Partial<DefaultModelRow<TContract, ModelName, NsId>> & RelationMutationFields<TContract, ModelName, 'update'>;
912
+ type MutationUpdateInput<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ClosedWhenEmpty<Partial<DefaultModelInputRow<TContract, ModelName, NsId>> & RelationMutationFields<TContract, ModelName, 'update'>>;
666
913
  type ModelRelations<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ModelDef<TContract, ModelName, NsId> extends {
667
914
  readonly relations: infer R;
668
915
  } ? R extends Record<string, unknown> ? R : Record<string, never> : Record<string, never>;
669
916
  type ExactRecord<T> = T extends Record<string, unknown> ? string extends keyof T ? Record<string, never> : T : Record<string, never>;
670
917
  type RelationsOf<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = ExactRecord<ModelRelations<TContract, ModelName, NsId>>;
671
918
  type RelationNames<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = (string extends keyof RelationsOf<TContract, ModelName, NsId> ? never : { [K in keyof RelationsOf<TContract, ModelName, NsId>]: RelationsOf<TContract, ModelName, NsId>[K] extends never ? never : K; }[keyof RelationsOf<TContract, ModelName, NsId>]) & string;
672
- type IsUnion<T, Whole = T> = T extends Whole ? ([Whole] extends [T] ? false : true) : never;
673
- type IsSingletonString<T> = [T] extends [string] ? string extends T ? false : IsUnion<T> extends true ? false : true : false;
674
- type SelectedVariantNames<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName, NsId extends string> = [VariantName] extends [string] ? string extends VariantName ? VariantNames<TContract, ModelName, NsId> : VariantName : never;
675
- type VariantDeclaredRelationKeys<TContract extends Contract<SqlStorage>, VariantName extends string, NsId extends string> = VariantName extends string ? keyof RelationsOf<TContract, VariantName, NsId> : never;
676
- type SelectedVariantDeclaredRelationKeys<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName, NsId extends string> = VariantDeclaredRelationKeys<TContract, SelectedVariantNames<TContract, ModelName, VariantName, NsId>, NsId>;
677
- type VariantAwareIncludeRelationNames<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName, NsId extends string = never> = IsSingletonString<VariantName> extends true ? RelationNames<TContract, Extract<VariantName, string>, NsId> | Exclude<RelationNames<TContract, ModelName, NsId>, keyof RelationsOf<TContract, Extract<VariantName, string>, NsId>> : [VariantName] extends [string] ? Exclude<RelationNames<TContract, ModelName, NsId>, SelectedVariantDeclaredRelationKeys<TContract, ModelName, VariantName, NsId>> : RelationNames<TContract, ModelName, NsId>;
678
- type IncludeRelationOwner<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName, RelName extends string, NsId extends string = never> = IsSingletonString<VariantName> extends true ? RelName extends keyof RelationsOf<TContract, Extract<VariantName, string>, NsId> ? Extract<VariantName, string> : ModelName : ModelName;
919
+ type IsUnion$1<T, Whole = T> = T extends Whole ? ([Whole] extends [T] ? false : true) : never;
920
+ type IsSingletonString<T> = [T] extends [string] ? string extends T ? false : IsUnion$1<T> extends true ? false : true : false;
921
+ type VariantDeclaredRelationKeys<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, NsId extends string> = VariantValue extends string ? keyof RelationsOf<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> : never;
922
+ type SelectedVariantDeclaredRelationKeys<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, NsId extends string> = VariantDeclaredRelationKeys<TContract, ModelName, string extends VariantValue ? DiscriminatorValues<TContract, ModelName, NsId> : VariantValue, NsId>;
923
+ type VariantAwareIncludeRelationNames<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, NsId extends string = never> = IsSingletonString<VariantValue> extends true ? RelationNames<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> | Exclude<RelationNames<TContract, ModelName, NsId>, keyof RelationsOf<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>>> : [VariantValue] extends [string] ? Exclude<RelationNames<TContract, ModelName, NsId>, SelectedVariantDeclaredRelationKeys<TContract, ModelName, VariantValue, NsId>> : RelationNames<TContract, ModelName, NsId>;
924
+ type IncludeRelationOwner<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, RelName extends string, NsId extends string = never> = IsSingletonString<VariantValue> extends true ? RelName extends keyof RelationsOf<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> ? VariantModelName<TContract, ModelName, VariantValue, NsId> : ModelName : ModelName;
925
+ type IncludeRelationOwnerNamespace<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue, RelName extends string, NsId extends string = never> = IsSingletonString<VariantValue> extends true ? RelName extends keyof RelationsOf<TContract, VariantModelName<TContract, ModelName, VariantValue, NsId>, VariantModelNamespace<TContract, ModelName, VariantValue, NsId>> ? VariantModelNamespace<TContract, ModelName, VariantValue, NsId> : NsId : NsId;
679
926
  type RelationModelName<Relation> = Relation extends {
680
927
  readonly to: {
681
928
  readonly model: infer To extends string;
682
929
  };
683
930
  } ? To : never;
684
931
  type RelatedModelName<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = RelationsOf<TContract, ModelName, NsId> extends (infer Rels) ? Rels extends Record<string, unknown> ? RelName extends keyof Rels ? RelationModelName<Rels[RelName]> : never : never : never;
932
+ type ContractNamespaceKey<TContract extends Contract<SqlStorage>, NsId extends string> = { [K in keyof TContract['domain']['namespaces'] & string]: NsId extends K ? K : never; }[keyof TContract['domain']['namespaces'] & string];
685
933
  type RelationTargetNamespace<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = [NsId] extends [never] ? never : RelationsOf<TContract, ModelName, NsId> extends (infer Rels) ? Rels extends Record<string, unknown> ? RelName extends keyof Rels ? Rels[RelName] extends {
686
934
  readonly to: {
687
935
  readonly namespace: infer N extends string;
688
936
  };
689
- } ? N : never : never : never : never;
937
+ } ? ContractNamespaceKey<TContract, N> : never : never : never : never;
690
938
  type RelationCardinalityFromRelation<Relation> = Relation extends {
691
939
  readonly cardinality: infer Cardinality extends RelationCardinalityTag;
692
940
  } ? Cardinality : '1:N';
693
941
  type RelationCardinality<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = RelationsOf<TContract, ModelName, NsId> extends (infer Rels) ? Rels extends Record<string, unknown> ? RelName extends keyof Rels ? RelationCardinalityFromRelation<Rels[RelName]> : '1:N' : '1:N' : '1:N';
694
- type RelationLocalFieldColumns<TContract extends Contract<SqlStorage>, ModelName extends string, Relation> = Relation extends {
695
- readonly on: {
696
- readonly localFields: infer Fields extends readonly string[];
697
- };
698
- } ? MapFieldsToColumns<TContract, ModelName, Fields> : readonly [];
699
- type MapFieldsToColumns<TContract extends Contract<SqlStorage>, ModelName extends string, Fields extends readonly string[]> = Fields extends readonly [infer Head extends string, ...infer Tail extends string[]] ? readonly [FieldColumnName<TContract, ModelName, Head>, ...MapFieldsToColumns<TContract, ModelName, Tail>] : readonly [];
700
- type AnyColumnNullable<Columns extends Record<string, StorageColumn>, ColNames extends readonly string[]> = ColNames extends readonly [infer Head extends string, ...infer Tail extends string[]] ? Head extends keyof Columns ? Columns[Head]['nullable'] extends true ? true : AnyColumnNullable<Columns, Tail> : true : false;
701
- type HasForeignKeyForCols<FKs extends readonly unknown[], Cols extends readonly string[]> = FKs extends readonly [infer Head, ...infer Tail extends unknown[]] ? Head extends {
702
- readonly source: {
703
- readonly columns: Cols;
704
- };
705
- } ? true : HasForeignKeyForCols<Tail, Cols> : false;
706
- type IsFkSideOfRelation<Table extends StorageTable, ParentCols extends readonly string[]> = Table extends {
707
- readonly foreignKeys: infer FKs extends readonly unknown[];
708
- } ? HasForeignKeyForCols<FKs, ParentCols> : false;
709
- type IsToOneRelationNullable<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = ModelTableName<TContract, ModelName, NsId> extends (infer TableName extends string) ? NamespaceTableDef<TContract, TableName, ResolvedNsId<TContract, ModelName, NsId>> extends (infer Table extends StorageTable) ? RelationsOf<TContract, ModelName, NsId> extends (infer Rels extends Record<string, unknown>) ? RelName extends keyof Rels ? RelationLocalFieldColumns<TContract, ModelName, Rels[RelName]> extends (infer Cols extends readonly string[]) ? IsFkSideOfRelation<Table, Cols> extends true ? AnyColumnNullable<Table['columns'], Cols> : true : true : true : true : true : true;
942
+ type IsToOneRelationNullable<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = RelationsOf<TContract, ModelName, NsId> extends (infer Rels extends Record<string, unknown>) ? RelName extends keyof Rels ? Rels[RelName] extends {
943
+ readonly nullable: false;
944
+ } ? false : true : true : true;
710
945
  type IncludeRelationValue<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, IncludedRow, NsId extends string = never> = RelationCardinality<TContract, ModelName, RelName, NsId> extends '1:1' | 'N:1' ? IsToOneRelationNullable<TContract, ModelName, RelName, NsId> extends true ? IncludedRow | null : IncludedRow : IncludedRow[];
711
946
  type CollectionModelName<TContract extends Contract<SqlStorage>> = { [Ns in keyof TContract['domain']['namespaces']]: keyof TContract['domain']['namespaces'][Ns]['models'] & string; }[keyof TContract['domain']['namespaces']];
712
947
  //#endregion
@@ -722,14 +957,11 @@ type CollectionConstructor<TContract extends Contract<SqlStorage>> = new (ctx: C
722
957
  type WithWhereState<State extends CollectionTypeState> = Omit<State, 'hasWhere'> & {
723
958
  readonly hasWhere: true;
724
959
  };
725
- type WithOrderByState<State extends CollectionTypeState> = Omit<State, 'hasOrderBy'> & {
726
- readonly hasOrderBy: true;
727
- };
728
- type WithVariantState<State extends CollectionTypeState, V extends string> = Omit<State, 'variantName'> & {
729
- readonly variantName: V;
960
+ type WithVariantState<State extends CollectionTypeState, V extends string> = Omit<State, 'variantValue'> & {
961
+ readonly variantValue: V;
730
962
  };
731
963
  type IncludedRelationsForRow<TContract extends Contract<SqlStorage>, ModelName extends string, Row> = Omit<Row, keyof DefaultModelRow<TContract, ModelName>>;
732
- type IncludeRefinementTerminals = 'all' | 'first' | 'aggregate' | 'groupBy' | 'create' | 'createAll' | 'createAndCount' | 'update' | 'updateAll' | 'updateAndCount' | 'delete' | 'deleteAll' | 'deleteAndCount' | 'upsert';
964
+ type IncludeRefinementTerminals = 'all' | 'first' | 'firstOrThrow' | 'aggregate' | 'groupBy' | 'create' | 'createAll' | 'createAndCount' | 'update' | 'updateAll' | 'updateAndCount' | 'delete' | 'deleteAll' | 'deleteAndCount' | 'upsert';
733
965
  /**
734
966
  * The members a to-one refinement collection strips: the scalar reducers the
735
967
  * contract's emitted aggregate map declares, plus `combine`. Both reduce a
@@ -738,54 +970,262 @@ type IncludeRefinementTerminals = 'all' | 'first' | 'aggregate' | 'groupBy' | 'c
738
970
  * subtracting the non-literal key set would strip the whole surface.
739
971
  */
740
972
  type IncludeRefinementScalarMethods<TContract extends Contract<SqlStorage>> = (string extends keyof ExtractAggregateTypes<TContract> & string ? never : keyof ExtractAggregateTypes<TContract> & string) | 'combine';
741
- type IncludeRefinementCollection<TContract extends Contract<SqlStorage>, ModelName extends string, Row, State extends CollectionTypeState, IsToMany extends boolean> = Omit<Collection<TContract, ModelName, Row, State>, IncludeRefinementTerminals | (IsToMany extends true ? never : IncludeRefinementScalarMethods<TContract>)>;
973
+ type IncludeRefinementCollection<TContract extends Contract<SqlStorage>, ModelName extends string, Row, State extends CollectionTypeState, IsToMany extends boolean> = Omit<Collection<TContract, ModelName, Row, State>, IncludeRefinementTerminals | 'whereUnique' | (IsToMany extends true ? never : IncludeRefinementScalarMethods<TContract>)>;
742
974
  type IsToManyRelation<TContract extends Contract<SqlStorage>, ModelName extends string, RelName extends string, NsId extends string = never> = RelationCardinality<TContract, ModelName, RelName, NsId> extends '1:N' | 'N:M' ? true : false;
743
975
  type IncludeRefinementResult<TContract extends Contract<SqlStorage>, RelatedName extends string, IsToMany extends boolean> = IncludeRefinementCollection<TContract, RelatedName, unknown, CollectionTypeState, IsToMany> | (IsToMany extends true ? IncludeScalar<unknown> | IncludeCombine<Record<string, unknown>> : never);
744
- declare const RowType: unique symbol;
745
- interface RowSelection<T> {
746
- [RowType]: T;
747
- }
748
- type IncludeRefinementValue<TContract extends Contract<SqlStorage>, ParentModelName extends string, RelName extends string, DefaultIncludedRow, RefinedResult, NsId extends string = never> = RefinedResult extends RowSelection<infer V> ? RefinedResult extends {
976
+ type IncludeRefinementValue<TContract extends Contract<SqlStorage>, ParentModelName extends string, RelName extends string, DefaultIncludedRow, RefinedResult, NsId extends string = never> = RefinedResult extends HasRow<infer V> ? RefinedResult extends {
749
977
  readonly kind: 'includeScalar' | 'includeCombine';
750
- } ? V : IncludeRelationValue<TContract, ParentModelName, RelName, V, NsId> : IncludeRelationValue<TContract, ParentModelName, RelName, DefaultIncludedRow, NsId>;
978
+ } ? V : RefinedIncludeRelationValue<TContract, ParentModelName, RelName, CollectionRowOf<HasRow<V>>, NsId> : IncludeRelationValue<TContract, ParentModelName, RelName, DefaultIncludedRow, NsId>;
979
+ /**
980
+ * A refined to-one include is nullable whatever the relation's `nullable` flag
981
+ * says: the refinement's filter can exclude the related row.
982
+ */
983
+ type RefinedIncludeRelationValue<TContract extends Contract<SqlStorage>, ParentModelName extends string, RelName extends string, IncludedRow, NsId extends string = never> = RelationCardinality<TContract, ParentModelName, RelName, NsId> extends '1:1' | 'N:1' ? IncludedRow | null : IncludedRow[];
984
+ type WhereInput<TContract extends Contract<SqlStorage>, NsId extends string, ModelName extends string, VariantValue extends string | undefined = undefined> = ((model: VariantAwareModelAccessor<TContract, ModelName, VariantValue, NsId>, tools: ModelCallbackTools<TContract, ModelName, NsId>) => WhereCallbackResult) | ShorthandWhereFilter<TContract, NsId, ModelName>;
985
+ //#endregion
986
+ //#region src/collection-methods.d.ts
987
+ type MethodsOf<Entry, Model> = (Entry & {
988
+ readonly model: Model;
989
+ })['methods' & keyof Entry];
990
+ type ContributedTables<Model> = { readonly [Id in CollectionMethodContributionId]: MethodsOf<CollectionMethodRegistry[Id], Model>; };
991
+ type MethodNames<Tables> = { [Id in keyof Tables]: keyof Tables[Id]; }[keyof Tables];
992
+ type SignatureFrom<Tables, Name> = { [Id in keyof Tables]: Name extends keyof Tables[Id] ? Tables[Id][Name] : never; }[keyof Tables];
993
+ type IsUnion<T, All = T> = T extends unknown ? ([All] extends [T] ? false : true) : never;
994
+ /** The type of a method name that more than one contribution gives the same model. Calling it is a compile error that names the model and the contributions. */
995
+ interface CollectionMethodNameClash<Name, ModelName, Contributions> {
996
+ readonly clash: `more than one contribution gives model "${ModelName & string}" a collection method named "${Name & string}"`;
997
+ readonly contributions: Contributions;
998
+ }
999
+ /** What a contributed method returns: the collection it was called on, with `Filtered` and `Ordered` added as its signature declares. */
1000
+ type ContributedMethodResult<Signature, Self> = Signature extends {
1001
+ readonly filters: true;
1002
+ } ? Signature extends {
1003
+ readonly orders: true;
1004
+ } ? Ordered<Filtered<Self>> : Filtered<Self> : Signature extends {
1005
+ readonly orders: true;
1006
+ } ? Ordered<Self> : Self;
1007
+ type ContributedCollectionMethod<Signature extends ContributedMethodSignature, Self> = <Receiver extends Self = Self>(...args: Signature['parameters']) => ContributedMethodResult<Signature, Receiver>;
1008
+ type MergedTable<Tables, ModelName> = { readonly [Name in MethodNames<Tables>]: { [Id in keyof Tables]: Name extends keyof Tables[Id] ? Id : never; }[keyof Tables] extends (infer Ids) ? true extends IsUnion<Ids> ? CollectionMethodNameClash<Name, ModelName, Ids> : SignatureFrom<Tables, Name> : never; };
1009
+ /** Each contributed method of a model, by name, with its signature. It does not depend on the receiver, so TypeScript computes it once per model. */
1010
+ type ModelContributedMethodTable<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string> = string extends ModelName | NsId ? Record<never, never> : MergedTable<ContributedTables<CollectionMethodModelTypeOf<TContract, ModelName, NsId>>, ModelName>;
1011
+ /** The contributed methods of a model's collection `Self`: the type of `using`. */
1012
+ type ContributedCollectionMethods<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string, Self, Table = ModelContributedMethodTable<TContract, ModelName, NsId>> = { readonly [Name in keyof Table]: Table[Name] extends ContributedMethodSignature ? ContributedCollectionMethod<Table[Name], Self> : Table[Name]; };
1013
+ //#endregion
1014
+ //#region src/fragments.d.ts
1015
+ type FieldMultiplicity = false | {
1016
+ readonly elementNullable: boolean;
1017
+ };
1018
+ /** A field declared by its codec and nullability, for a fragment written without a field builder. `many` declares a list field as a contract field records one: `{ elementNullable: false }`, or `{ elementNullable: true }` when its elements may be null. */
1019
+ interface DeclaredField<CodecId extends string = string, Nullable extends boolean = boolean, Many extends FieldMultiplicity = false> {
1020
+ readonly codecId: CodecId;
1021
+ readonly nullable: Nullable;
1022
+ readonly many?: Many | undefined;
1023
+ }
1024
+ type AnyDeclaredField = DeclaredField<string, boolean, FieldMultiplicity>;
1025
+ type MultiplicityOf<Many> = Many extends {
1026
+ readonly elementNullable: infer ElementNullable extends boolean;
1027
+ } ? {
1028
+ readonly elementNullable: ElementNullable;
1029
+ } : false;
1030
+ type DeclaredMultiplicity<Field> = Field extends {
1031
+ readonly many?: false | undefined;
1032
+ } ? false : Field extends {
1033
+ readonly many?: infer Many;
1034
+ } ? MultiplicityOf<Exclude<Many, undefined>> : false;
1035
+ type BuiltMultiplicity<Builder> = Builder extends {
1036
+ build(): infer Built;
1037
+ } ? DeclaredMultiplicity<Built> : false;
1038
+ /** A field builder from the contract DSL, such as `field.text().optional()`, with the codec and nullability it declares. */
1039
+ type DeclaredFieldsFragmentFieldBuilder<CodecId extends string = string, Nullable extends boolean = boolean> = ScalarFieldDeclarationBuilder<CodecDescriptorRef<CodecId>, Nullable>;
1040
+ /** The fields a fragment for any model needs, each declared with a field builder or a {@link DeclaredField}. */
1041
+ type DeclaredFieldsFragmentFieldDeclarations<CodecId extends string = string> = Readonly<Record<string, DeclaredFieldsFragmentFieldBuilder<CodecId> | DeclaredField<CodecId, boolean, FieldMultiplicity>>>;
1042
+ type DeclarationField<Declaration> = Declaration extends DeclaredFieldsFragmentFieldBuilder<infer Id, infer Nullable> ? DeclaredField<Id, Nullable, BuiltMultiplicity<Declaration>> : Declaration extends DeclaredField<infer Id, infer Nullable, FieldMultiplicity> ? DeclaredField<Id, Nullable, DeclaredMultiplicity<Declaration>> : never;
1043
+ /** The declared fields with each builder read as its codec and nullability. */
1044
+ type DeclaredFields<Declarations extends DeclaredFieldsFragmentFieldDeclarations> = { readonly [K in keyof Declarations]: DeclarationField<Declarations[K]>; } extends (infer Fields) ? { readonly [K in keyof Fields]: Fields[K]; } : never;
1045
+ /** The model accessor of a fragment for any model: only the declared fields, typed by codec. */
1046
+ type DeclaredFieldsFragmentModelAccessor<TContract extends Contract<SqlStorage>, Fields extends Readonly<Record<string, AnyDeclaredField>>> = { readonly [K in keyof Fields]: Fields[K]['codecId'] extends keyof ExtractCodecTypes<TContract> & string ? DeclaredMultiplicity<Fields[K]> extends {
1047
+ readonly elementNullable: infer ElementNullable extends boolean;
1048
+ } ? CodecListField<TContract, Fields[K]['codecId'], Fields[K]['nullable'], ElementNullable> : CodecField<TContract, Fields[K]['codecId'], Fields[K]['nullable']> : never; };
1049
+ declare const FragmentFactsType: unique symbol;
1050
+ /** What the body of a fragment for any model has established. A flag that is `boolean` is not known; `true` is established. */
1051
+ interface FragmentFacts {
1052
+ readonly hasWhere: boolean;
1053
+ readonly hasOrderBy: boolean;
1054
+ }
1055
+ /** The second argument of a `where` or `orderBy` callback in the body of a fragment for any model: every function, and no index, as the body does not know its model. */
1056
+ interface DeclaredFieldsFragmentCallbackTools<TContract extends Contract<SqlStorage>> {
1057
+ readonly fns: OrmFunctions<TContract>;
1058
+ readonly indexes: Readonly<Record<never, never>>;
1059
+ }
1060
+ type OrderSelector<Row, TContract extends Contract<SqlStorage>> = (row: Row, tools: DeclaredFieldsFragmentCallbackTools<TContract>) => OrderByItem;
1061
+ /** The collection the body of a fragment for any model receives: the methods that keep the row, on the declared fields, and what has been established so far. */
1062
+ interface DeclaredFieldsFragmentCollection<Row, Facts extends FragmentFacts, TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
1063
+ readonly [FragmentFactsType]: Facts;
1064
+ where(fn: (row: Row, tools: DeclaredFieldsFragmentCallbackTools<TContract>) => WhereCallbackResult): DeclaredFieldsFragmentCollection<Row, {
1065
+ readonly hasWhere: true;
1066
+ readonly hasOrderBy: Facts['hasOrderBy'];
1067
+ }, TContract>;
1068
+ orderBy(selection: OrderSelector<Row, TContract> | ReadonlyArray<OrderSelector<Row, TContract>>): DeclaredFieldsFragmentCollection<Row, {
1069
+ readonly hasWhere: Facts['hasWhere'];
1070
+ readonly hasOrderBy: true;
1071
+ }, TContract>;
1072
+ limit(n: number): DeclaredFieldsFragmentCollection<Row, Facts, TContract>;
1073
+ offset(n: number): DeclaredFieldsFragmentCollection<Row, Facts, TContract>;
1074
+ }
1075
+ type ContractFieldMultiplicity<Field> = Field extends {
1076
+ readonly many: infer Many;
1077
+ } ? MultiplicityOf<Many> : false;
1078
+ /** The declared fields that the model lacks, or has with another codec or nullability, as a list where the declaration has one value or the reverse, or as a list whose elements differ in nullability from the declared ones. For a union of models, the fields any of them lacks. */
1079
+ type MissingDeclaredFieldsFragmentFields<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string, Fields extends Readonly<Record<string, AnyDeclaredField>>> = ModelName extends string ? { [K in keyof Fields & string]: K extends keyof FieldsOf<TContract, ModelName, NsId> ? [FieldCodecId<TContract, ModelName, K, NsId>, FieldNullable<TContract, ModelName, K, NsId>, ContractFieldMultiplicity<FieldsOf<TContract, ModelName, NsId>[K]>] extends [Fields[K]['codecId'], Fields[K]['nullable'], DeclaredMultiplicity<Fields[K]>] ? [Fields[K]['codecId'], Fields[K]['nullable'], DeclaredMultiplicity<Fields[K]>] extends [FieldCodecId<TContract, ModelName, K, NsId>, FieldNullable<TContract, ModelName, K, NsId>, ContractFieldMultiplicity<FieldsOf<TContract, ModelName, NsId>[K]>] ? never : K : K : K; }[keyof Fields & string] : never;
1080
+ /** What a fragment for any model requires of its receiver beyond the collection's own members: nothing when the model has the declared fields, otherwise a property whose name says why it is refused. */
1081
+ type DeclaredFieldsFragmentFieldsCheck<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string, Fields extends Readonly<Record<string, AnyDeclaredField>>> = string extends ModelName ? {
1082
+ readonly 'the fragment could not read the model of the collection from its type': ModelName;
1083
+ } : [MissingDeclaredFieldsFragmentFields<TContract, ModelName, NsId, Fields>] extends [never] ? unknown : {
1084
+ readonly 'the model has no field that matches the declaration in the fragment': MissingDeclaredFieldsFragmentFields<TContract, ModelName, NsId, Fields>;
1085
+ };
1086
+ /** A collection plus the filter and order a fragment's body established. */
1087
+ type WithFacts<C, Facts extends FragmentFacts> = Facts['hasOrderBy'] extends true ? Ordered<Facts['hasWhere'] extends true ? Filtered<C> : C> : Facts['hasWhere'] extends true ? Filtered<C> : C;
1088
+ /**
1089
+ * A fragment made by the client's `fragment` method: it accepts a collection of any model that has the declared fields, checked against the collection's own contract, model and namespace, and returns that collection with what the body established. `with` reads the result from the receiver's type and the fragment's facts.
1090
+ */
1091
+ interface DeclaredFieldsFragment<TContract extends Contract<SqlStorage>, Fields extends Readonly<Record<string, AnyDeclaredField>>, Facts extends FragmentFacts> {
1092
+ <C, ModelName extends string, ReceiverContract extends Contract<SqlStorage> = TContract, NsId extends string = never>(collection: C & HasTypeState<{
1093
+ readonly nsId: NsId;
1094
+ }> & {
1095
+ readonly modelName: ModelName;
1096
+ readonly ctx: {
1097
+ readonly context: {
1098
+ readonly contract: ReceiverContract;
1099
+ };
1100
+ };
1101
+ } & DeclaredFieldsFragmentFieldsCheck<ReceiverContract, ModelName, NsId, Fields>): WithFacts<C, Facts>;
1102
+ readonly [FragmentFactsType]: Facts;
1103
+ }
1104
+ interface ModelCollection$1<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string> {
1105
+ readonly ctx: {
1106
+ readonly context: ExecutionContext<TContract>;
1107
+ };
1108
+ readonly modelName: ModelName;
1109
+ readonly namespaceId: NsId;
1110
+ readonly tableName: string;
1111
+ }
1112
+ /**
1113
+ * An `orderBy` selector for a field named by a string, such as an order parameter of a request. `allowed` lists the fields a request may order by. A name that is not in `allowed` or not an orderable field of the collection's model, and a direction other than `asc` or `desc`, throw `ORM.ARGUMENT_INVALID`. An undefined direction is `asc`.
1114
+ *
1115
+ * ```ts
1116
+ * db.Post.orderBy(orderByField(db.Post, input.orderBy, input.direction, ['title', 'createdAt']));
1117
+ * ```
1118
+ */
1119
+ declare function orderByField<TContract extends Contract<SqlStorage>, ModelName extends string, const Allowed extends OrderableFieldNames<TContract, ModelName, NsId>, NsId extends string = never>(collection: ModelCollection$1<TContract, ModelName, NsId>, name: string, direction: string | undefined, allowed: readonly [Allowed, ...Allowed[]]): (row: { readonly [K in Allowed]: Orderable; }) => OrderByItem;
751
1120
  //#endregion
752
1121
  //#region src/grouped-collection.d.ts
753
1122
  interface GroupedCollectionInit {
754
1123
  readonly tableName: string;
755
1124
  readonly namespaceId: string;
756
- readonly baseFilters: readonly AnyExpression[];
1125
+ readonly preGroupState: CollectionState;
757
1126
  readonly groupByFields: readonly string[];
758
1127
  readonly groupByColumns: readonly string[];
759
1128
  readonly havingFilters: readonly AnyExpression[];
1129
+ readonly postGroup: GroupPagingState;
760
1130
  }
761
1131
  type GroupByFieldName<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string = never> = keyof DefaultModelRow<TContract, ModelName, NsId> & string;
762
- declare class GroupedCollection<TContract extends Contract<SqlStorage>, ModelName extends string, GroupFields extends readonly GroupByFieldName<TContract, ModelName, NsId>[], NsId extends string = never> {
1132
+ type GroupedAggregateRow<TContract extends Contract<SqlStorage>, ModelName extends string, GroupFields extends readonly GroupByFieldName<TContract, ModelName, NsId>[], NsId extends string, Spec extends AggregateSpec> = SimplifyDeep<Pick<DefaultModelRow<TContract, ModelName, NsId>, GroupFields[number]> & AggregateResult<Spec>>;
1133
+ declare class GroupedCollection<TContract extends Contract<SqlStorage>, ModelName extends string, GroupFields extends readonly GroupByFieldName<TContract, ModelName, NsId>[], NsId extends string = never, HasOrderBy extends boolean = false> {
1134
+ #private;
763
1135
  readonly ctx: CollectionContext<TContract>;
764
1136
  private readonly contract;
765
1137
  readonly modelName: ModelName;
766
1138
  readonly tableName: string;
767
- readonly namespaceId: string;
768
- readonly baseFilters: readonly AnyExpression[];
1139
+ readonly namespaceId: NsId;
1140
+ readonly preGroupState: CollectionState;
769
1141
  readonly groupByFields: readonly string[];
770
1142
  readonly groupByColumns: readonly string[];
771
1143
  readonly havingFilters: readonly AnyExpression[];
1144
+ readonly postGroup: GroupPagingState;
772
1145
  constructor(ctx: CollectionContext<TContract>, modelName: ModelName, options: GroupedCollectionInit);
773
- having(predicate: (having: HavingBuilder<TContract, ModelName, NsId>) => AnyExpression): GroupedCollection<TContract, ModelName, GroupFields, NsId>;
1146
+ having(predicate: (having: HavingBuilder<TContract, ModelName, NsId>) => AnyExpression): GroupedCollection<TContract, ModelName, GroupFields, NsId, HasOrderBy>;
1147
+ /**
1148
+ * Append an `ORDER BY` clause on the grouped rows themselves — orders by
1149
+ * group key. Ordering by an aggregate alias needs a builder surface over
1150
+ * the aliases and isn't supported here. Unlocks post-group `limit(...)` /
1151
+ * `offset(...)`, which page a group order that would otherwise be undefined.
1152
+ */
1153
+ orderBy(selection: ((model: Pick<ModelAccessor<TContract, ModelName, NsId>, GroupFields[number]>) => OrderByItem) | readonly [(model: Pick<ModelAccessor<TContract, ModelName, NsId>, GroupFields[number]>) => OrderByItem, ...ReadonlyArray<(model: Pick<ModelAccessor<TContract, ModelName, NsId>, GroupFields[number]>) => OrderByItem>]): GroupedCollection<TContract, ModelName, GroupFields, NsId, true>;
1154
+ /**
1155
+ * Apply `LIMIT n` to the grouped rows. Replaces any previous post-group
1156
+ * limit. Requires a prior `orderBy(...)` — a database may return groups in
1157
+ * any order, so "the first n groups" is undefined without one.
1158
+ */
1159
+ limit(n: HasOrderBy extends true ? number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>> : never): GroupedCollection<TContract, ModelName, GroupFields, NsId, HasOrderBy>;
1160
+ /**
1161
+ * Apply `OFFSET n` to the grouped rows. Replaces any previous post-group
1162
+ * offset. Requires a prior `orderBy(...)`, same as `limit(...)` — both
1163
+ * pagination methods need a deterministic group order.
1164
+ */
1165
+ offset(n: HasOrderBy extends true ? number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>> : never): GroupedCollection<TContract, ModelName, GroupFields, NsId, HasOrderBy>;
1166
+ get prepared(): {
1167
+ aggregate: <Spec extends AggregateSpec>(fn: (aggregate: AggregateBuilder<TContract, ModelName, NsId>) => Spec, configure?: (meta: MetaBuilder<"read">) => void) => Preparable<Record<string, unknown>, Promise<SimplifyDeep<Pick<DefaultModelRow<TContract, ModelName, NsId>, GroupFields[number]> & AggregateResult<Spec>>[]>>;
1168
+ };
774
1169
  /**
775
1170
  * Read terminal: run a grouped aggregate query.
776
1171
  *
777
1172
  * Accepts an optional `configure` callback that receives a
778
- * `MetaBuilder<'read'>` for attaching typed annotations.
779
- * Annotations are merged into the compiled plan's `meta.annotations`.
1173
+ * `MetaBuilder<'read'>` for attaching typed annotations to the call.
780
1174
  */
781
- aggregate<Spec extends AggregateSpec>(fn: (aggregate: AggregateBuilder<TContract, ModelName, NsId>) => Spec, configure?: (meta: MetaBuilder<'read'>) => void): Promise<Array<SimplifyDeep<Pick<DefaultModelRow<TContract, ModelName, NsId>, GroupFields[number]> & AggregateResult<Spec>>>>;
1175
+ aggregate<Spec extends AggregateSpec>(fn: (aggregate: AggregateBuilder<TContract, ModelName, NsId>) => Spec, configure?: (meta: MetaBuilder<'read'>) => void): Promise<Array<GroupedAggregateRow<TContract, ModelName, GroupFields, NsId, Spec>>>;
1176
+ }
1177
+ //#endregion
1178
+ //#region src/prepared-collection.d.ts
1179
+ interface PreparedCollection<TContract extends Contract<SqlStorage>, ModelName extends string, Row, State extends CollectionTypeState> extends HasTypeState<State> {
1180
+ aggregate<Spec extends AggregateSpec, Self = unknown>(this: Self & HasNoUniqueFilter, selector: (aggregate: AggregateBuilder<TContract, ModelName, State['nsId']>) => Spec, configure?: (meta: MetaBuilder<'read'>) => void): Preparable<Record<string, unknown>, Promise<AggregateResult<Spec>>>;
1181
+ all<Self>(this: Self & HasNoUniqueFilter, configure?: (meta: MetaBuilder<'read'>) => void): Preparable<Record<string, unknown>, AsyncIterableResult<Row>>;
1182
+ first(filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Preparable<Record<string, unknown>, Promise<Row | null>>;
1183
+ firstOrThrow(filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Preparable<Record<string, unknown>, Promise<Row>>;
782
1184
  }
783
1185
  //#endregion
784
1186
  //#region src/collection.d.ts
785
1187
  type WhereDirectInput = WhereArg;
786
- declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName extends string, Row = SimplifyDeep<InferRootRow<TContract, ModelName>>, State extends CollectionTypeState = DefaultCollectionTypeState> implements RowSelection<Row> {
1188
+ type OrderBySelector<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName extends string | undefined, NsId extends string> = (model: VariantAwareModelAccessor<TContract, ModelName, VariantName, NsId>, tools: ModelCallbackTools<TContract, ModelName, NsId>) => OrderByItem;
1189
+ type LockMethodArgs<Capabilities, Strength extends LockStrength> = Capabilities extends LockStrengthCapabilities[Strength] & LockOptionCapabilities['of'] ? [options?: LockWaitOptions<Capabilities>] : never;
1190
+ type WriteConfigure = (meta: MetaBuilder<'write'>) => void;
1191
+ /**
1192
+ * Ask the database to skip rows that collide with a unique constraint
1193
+ * instead of failing the whole statement.
1194
+ *
1195
+ * `conflictOn` names the scalar fields of the constraint to watch; omit
1196
+ * it to skip on any unique constraint of the table. Requires the
1197
+ * contract capability `insertOnConflictSkip`, and
1198
+ * `insertOnConflictWithoutTarget` as well when `conflictOn` is omitted.
1199
+ */
1200
+ interface CreateConflictOptions<TContract extends Contract<SqlStorage>, ModelName extends string> {
1201
+ readonly onConflict: 'skip';
1202
+ readonly conflictOn?: readonly (keyof DefaultModelRow<TContract, ModelName> & string)[];
1203
+ }
1204
+ /** What `fragment` reads from the collection it is called on: its contract, its model and its query state. */
1205
+ interface FragmentSource {
1206
+ readonly modelName: string;
1207
+ readonly namespaceId: string;
1208
+ readonly state: CollectionState;
1209
+ readonly ctx: {
1210
+ readonly context: {
1211
+ readonly contract: Contract<SqlStorage>;
1212
+ };
1213
+ };
1214
+ }
1215
+ type ContractOf<C extends FragmentSource> = C['ctx']['context']['contract'];
1216
+ type ModelNameOf<C extends FragmentSource> = C['modelName'];
1217
+ /** The compile error `fragment` gives on a collection whose type records a filter, an order or an include. */
1218
+ interface FragmentNeedsRootCollection {
1219
+ readonly fragmentNeedsRootCollection: 'the fragment is built from the model alone, so call fragment on the root collection of the model';
1220
+ }
1221
+ type HasRowBeyondModel<Self extends FragmentSource, NsId extends string> = Self extends HasRow ? [Exclude<keyof CollectionRowOf<Self>, keyof DefaultModelRow<ContractOf<Self>, ModelNameOf<Self>, NsId>>] extends [never] ? false : true : false;
1222
+ type RootCollectionOnly<Self extends FragmentSource, NsId extends string> = Self extends HasWhere | HasOrderBy ? FragmentNeedsRootCollection : HasRowBeyondModel<Self, NsId> extends true ? FragmentNeedsRootCollection : unknown;
1223
+ type ModelFragmentBody<TContract extends Contract<SqlStorage>, ModelName extends string, NsId extends string> = [NsId] extends [never] ? Collection<TContract, ModelName> : Collection<TContract, ModelName, InferRootRow<TContract, ModelName, NsId>, WithNsId<DefaultCollectionTypeState, NsId>>;
1224
+ declare class CollectionBase<TContract extends Contract<SqlStorage>, ModelName extends string, Row = SimplifyDeep<InferRootRow<TContract, ModelName>>, State extends CollectionTypeState = DefaultCollectionTypeState> implements HasRow<Row>, HasTypeState<State> {
787
1225
  #private;
1226
+ readonly [TypeState]: State;
788
1227
  readonly [RowType]: Row;
1228
+ readonly _row?: CollectionRowOf<this>;
789
1229
  /** @internal */
790
1230
  readonly ctx: CollectionContext<TContract>;
791
1231
  /** @internal */
@@ -795,7 +1235,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
795
1235
  /** @internal */
796
1236
  readonly tableName: string;
797
1237
  /** @internal */
798
- readonly namespaceId: string;
1238
+ readonly namespaceId: State['nsId'];
799
1239
  /** @internal */
800
1240
  readonly state: CollectionState;
801
1241
  /** @internal */
@@ -822,30 +1262,57 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
822
1262
  * const adults = await db.orm.User.where({ active: true }).where((u) => u.age.gt(18)).all();
823
1263
  * ```
824
1264
  */
825
- where(fn: (model: VariantAwareModelAccessor<TContract, ModelName, State['variantName'], State['nsId']>) => WhereDirectInput): Collection<TContract, ModelName, Row, WithWhereState<State>>;
826
- where(input: WhereDirectInput): Collection<TContract, ModelName, Row, WithWhereState<State>>;
827
- where(fn: (model: VariantAwareModelAccessor<TContract, ModelName, State['variantName'], State['nsId']>) => WhereArg): Collection<TContract, ModelName, Row, WithWhereState<State>>;
828
- where(filters: ShorthandWhereFilter<TContract, ModelName, State['nsId']>): Collection<TContract, ModelName, Row, WithWhereState<State>>;
1265
+ where<Self>(this: Self, fn: (model: VariantAwareModelAccessor<TContract, ModelName, State['variantValue'], State['nsId']>, tools: ModelCallbackTools<TContract, ModelName, State['nsId']>) => WhereCallbackResult): Filtered<Self>;
1266
+ where<Self>(this: Self, input: WhereDirectInput): Filtered<Self>;
1267
+ where<Self>(this: Self, filters: ShorthandWhereFilter<TContract, State['nsId'], ModelName>): Filtered<Self>;
829
1268
  /**
830
- * Narrow a polymorphic model to a specific variant. The returned
831
- * collection has the variant's row shape and a discriminator filter
832
- * is automatically applied. Chaining `.variant(...)` again replaces
833
- * the previous variant filter.
1269
+ * The collection methods packages contribute for this model. Each contribution reads the model and names its methods. Each method returns this collection with the method's filter and order added.
1270
+ */
1271
+ get using(): ContributedCollectionMethods<TContract, ModelName, State['nsId'], this>;
1272
+ whereUnique<Self>(this: Self, criterion: UniqueConstraintCriterion<TContract, ModelName>): UniquelyFiltered<Self>;
1273
+ /**
1274
+ * Call `fn`, a query fragment, with this collection and return its result. `fn` may be a scope, which only imposes conditions and declares the fields it needs, or a fragment for what `where` cannot express, such as a shared `select` and `include`, an order or a limit. A condition on one row that needs no declared fields is `where(rowFragment)`. For a fragment made by the client's `fragment` method, the result is this collection's own type plus the filter and order the fragment's body established.
1275
+ */
1276
+ with<Self, Facts extends FragmentFacts>(this: Self, fragment: ((collection: NoInfer<Self>) => unknown) & {
1277
+ readonly [FragmentFactsType]: Facts;
1278
+ }): WithFacts<Self, Facts>;
1279
+ with<Self, Out>(this: Self, fn: (collection: Self) => Out): Out;
1280
+ /**
1281
+ * Define a query fragment for this collection's model, such as a shared `select` and `include`. The body is typed once, against the model's plain collection. The fragment can be applied to any collection of the model that `select` and `variant` have not narrowed.
1282
+ *
1283
+ * The fragment is built from the model alone, so call `fragment` on the model's root collection. On a collection with chained calls it throws `ORM.ARGUMENT_INVALID`. The type check is partial: it refuses a collection whose type records a filter, an order or an include, and a collection typed by a type parameter, such as `this` in a class method; it does not see `limit`, `offset`, `select`, `cursor`, `distinct`, `variant` or a lock, a union with a root collection, or a value typed as the plain collection.
1284
+ *
1285
+ * ```ts
1286
+ * const summary = db.Post.fragment((posts) => posts.select('id', 'title').include('user'));
1287
+ * db.User.include('posts', (posts) => posts.with(summary));
1288
+ * ```
1289
+ */
1290
+ fragment<Self extends FragmentSource, NsId extends string, Result>(this: Self & HasTypeState<{
1291
+ readonly nsId: NsId;
1292
+ }> & RootCollectionOnly<Self, NsId>, body: (collection: ModelFragmentBody<ContractOf<Self>, ModelNameOf<Self>, NsId>) => Result): QueryFragment<ModelFragmentReceiver<ContractOf<Self>, ModelNameOf<Self>, NsId>, Result>;
1293
+ /**
1294
+ * Narrow a polymorphic model to the variant declared with the given
1295
+ * discriminator value. The returned collection has the variant's row
1296
+ * shape and a discriminator filter is automatically applied. Call
1297
+ * `.variant(...)` once, on the base collection: a collection that
1298
+ * already has a variant selected refuses it. To select a different
1299
+ * variant, start again from the base collection.
834
1300
  *
835
1301
  * ```typescript
836
1302
  * // Read only admin users (STI):
837
- * const admins = await db.orm.User.variant('Admin').all();
1303
+ * const admins = await db.orm.User.variant('admin').all();
838
1304
  *
839
1305
  * // Iterate the rows:
840
- * for await (const admin of db.orm.User.variant('Admin').all()) {
1306
+ * for await (const admin of db.orm.User.variant('admin').all()) {
841
1307
  * console.log(admin.role);
842
1308
  * }
843
1309
  *
844
1310
  * // Insert under a variant — discriminator is injected automatically:
845
- * await db.orm.User.variant('Admin').create({ name: 'Ada', role: 'super' });
1311
+ * await db.orm.User.variant('admin').create({ name: 'Ada', role: 'super' });
846
1312
  * ```
847
1313
  */
848
- variant<V extends VariantNames<TContract, ModelName>>(variantName: V): Collection<TContract, ModelName, VariantModelRow<TContract, ModelName, V>, WithVariantState<WithWhereState<State>, V>>;
1314
+ variant<V extends DiscriminatorValues<TContract, ModelName, S['nsId']>, S extends CollectionTypeState = State>(this: HasTypeState<S> & HasNoVariant, value: V): Collection<TContract, ModelName, VariantModelRow<TContract, ModelName, V, S['nsId']>, WithVariantState<WithWhereState<S>, V>>;
1315
+ variant<V extends DiscriminatorValues<TContract, ModelName, State['nsId']>>(this: HasNoVariant, value: V): Collection<TContract, ModelName, VariantModelRow<TContract, ModelName, V, State['nsId']>, WithVariantState<WithWhereState<State>, V>>;
849
1316
  /**
850
1317
  * Eagerly load a related model. The relation appears on every
851
1318
  * returned row under its declared name; to-one relations are mapped
@@ -862,7 +1329,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
862
1329
  *
863
1330
  * // Refine the related collection:
864
1331
  * const withRecent = await db.orm.User.include('posts', (posts) =>
865
- * posts.where({ published: true }).orderBy((p) => p.createdAt.desc()).take(5),
1332
+ * posts.where({ published: true }).orderBy((p) => p.createdAt.desc()).limit(5),
866
1333
  * ).all();
867
1334
  *
868
1335
  * // Reduce a to-many relation to a scalar value:
@@ -870,11 +1337,12 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
870
1337
  *
871
1338
  * // Multiple sub-views via combine():
872
1339
  * const overview = await db.orm.User.include('posts', (posts) =>
873
- * posts.combine({ recent: posts.take(3), total: posts.count() }),
1340
+ * posts.combine({ recent: posts.limit(3), total: posts.count() }),
874
1341
  * ).all();
875
1342
  * ```
876
1343
  */
877
- include<RelName extends VariantAwareIncludeRelationNames<TContract, ModelName, State['variantName'], State['nsId']>, RelationOwner extends string = IncludeRelationOwner<TContract, ModelName, State['variantName'], RelName, State['nsId']> & string, RelatedName extends RelatedModelName<TContract, RelationOwner, RelName, State['nsId']> & string = RelatedModelName<TContract, RelationOwner, RelName, State['nsId']> & string, TargetNs extends string = RelationTargetNamespace<TContract, RelationOwner, RelName, State['nsId']>, IsToMany extends boolean = IsToManyRelation<TContract, RelationOwner, RelName, State['nsId']>, RefinedResult extends IncludeRefinementResult<TContract, RelatedName, IsToMany> = IncludeRefinementCollection<TContract, RelatedName, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, CollectionTypeState, IsToMany>>(relationName: RelName, refineFn?: (collection: IncludeRefinementCollection<TContract, RelatedName, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, DefaultCollectionTypeState, IsToMany>) => RefinedResult): Collection<TContract, ModelName, SimplifyDeep<Row & { [K in RelName]: IncludeRefinementValue<TContract, RelationOwner, K, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, RefinedResult, State['nsId']>; }>, State>;
1344
+ include<RelName extends VariantAwareIncludeRelationNames<TContract, ModelName, State['variantValue'], State['nsId']>, RelationOwner extends string = IncludeRelationOwner<TContract, ModelName, State['variantValue'], RelName, State['nsId']> & string, OwnerNs extends string = IncludeRelationOwnerNamespace<TContract, ModelName, State['variantValue'], RelName, State['nsId']>, RelatedName extends RelatedModelName<TContract, RelationOwner, RelName, OwnerNs> & string = RelatedModelName<TContract, RelationOwner, RelName, OwnerNs> & string, TargetNs extends string = RelationTargetNamespace<TContract, RelationOwner, RelName, OwnerNs>, Self extends HasRow = never>(this: Self, relationName: RelName): Including<Self, { [K in RelName]: IncludeRelationValue<TContract, RelationOwner, K, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, OwnerNs>; }>;
1345
+ include<RelName extends VariantAwareIncludeRelationNames<TContract, ModelName, State['variantValue'], State['nsId']>, RelationOwner extends string = IncludeRelationOwner<TContract, ModelName, State['variantValue'], RelName, State['nsId']> & string, OwnerNs extends string = IncludeRelationOwnerNamespace<TContract, ModelName, State['variantValue'], RelName, State['nsId']>, RelatedName extends RelatedModelName<TContract, RelationOwner, RelName, OwnerNs> & string = RelatedModelName<TContract, RelationOwner, RelName, OwnerNs> & string, TargetNs extends string = RelationTargetNamespace<TContract, RelationOwner, RelName, OwnerNs>, IsToMany extends boolean = IsToManyRelation<TContract, RelationOwner, RelName, OwnerNs>, RefinedResult extends IncludeRefinementResult<TContract, RelatedName, IsToMany> = IncludeRefinementCollection<TContract, RelatedName, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, CollectionTypeState, IsToMany>, Self extends HasRow = never>(this: Self, relationName: RelName, refineFn: (collection: IncludeRefinementCollection<TContract, RelatedName, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, DefaultCollectionTypeState, IsToMany>) => RefinedResult): Including<Self, { [K in RelName]: IncludeRefinementValue<TContract, RelationOwner, K, SimplifyDeep<InferRootRow<TContract, RelatedName, TargetNs>>, RefinedResult, OwnerNs>; }>;
878
1346
  /**
879
1347
  * Project the row down to a subset of scalar fields. Previously
880
1348
  * included relations are preserved on the resulting row shape; only
@@ -889,6 +1357,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
889
1357
  * }
890
1358
  * ```
891
1359
  */
1360
+ select<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]], S extends CollectionTypeState = State, R = Row>(this: HasTypeState<S> & HasRow<R>, ...fields: Fields): Collection<TContract, ModelName, SimplifyDeep<Pick<DefaultModelRow<TContract, ModelName>, Fields[number]> & IncludedRelationsForRow<TContract, ModelName, R>>, S>;
892
1361
  select<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]]>(...fields: Fields): Collection<TContract, ModelName, SimplifyDeep<Pick<DefaultModelRow<TContract, ModelName>, Fields[number]> & IncludedRelationsForRow<TContract, ModelName, Row>>, State>;
893
1362
  /**
894
1363
  * Append an `ORDER BY` clause. Pass a single selector callback or an
@@ -907,7 +1376,8 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
907
1376
  * .all();
908
1377
  * ```
909
1378
  */
910
- orderBy(selection: ((model: VariantAwareModelAccessor<TContract, ModelName, State['variantName']>) => OrderByItem) | ReadonlyArray<(model: VariantAwareModelAccessor<TContract, ModelName, State['variantName']>) => OrderByItem>): Collection<TContract, ModelName, Row, WithOrderByState<State>>;
1379
+ orderBy<Self extends WithoutUniqueFilter<Self>>(this: Self, selection: OrderBySelector<TContract, ModelName, State['variantValue'], State['nsId']> | ReadonlyArray<OrderBySelector<TContract, ModelName, State['variantValue'], State['nsId']>>): Ordered<Self>;
1380
+ orderBy<Self>(this: Self & HasNoUniqueFilter, selection: OrderBySelector<TContract, ModelName, State['variantValue'], State['nsId']> | ReadonlyArray<OrderBySelector<TContract, ModelName, State['variantValue'], State['nsId']>>): Ordered<Self>;
911
1381
  /**
912
1382
  * Switch to grouped-aggregate mode. Returns a `GroupedCollection`
913
1383
  * whose `.aggregate(...)` terminal produces one row per group with
@@ -921,7 +1391,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
921
1391
  * // [{ userId: 1, count: 3, totalViews: 120 }, ...]
922
1392
  * ```
923
1393
  */
924
- groupBy<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName, State['nsId']> & string, ...(keyof DefaultModelRow<TContract, ModelName, State['nsId']> & string)[]]>(...fields: Fields): GroupedCollection<TContract, ModelName, Fields, State['nsId']>;
1394
+ groupBy<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName, State['nsId']> & string, ...(keyof DefaultModelRow<TContract, ModelName, State['nsId']> & string)[]], Self = unknown>(this: Self & HasNoUniqueFilter, ...fields: Fields): GroupedCollection<TContract, ModelName, Fields, State['nsId']>;
925
1395
  /**
926
1396
  * Produce multiple named sub-views of a to-many relation in a
927
1397
  * single `include(...)`. Each branch is either another refined
@@ -932,7 +1402,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
932
1402
  * ```typescript
933
1403
  * const users = await db.orm.User.include('posts', (posts) =>
934
1404
  * posts.combine({
935
- * recent: posts.where({ published: true }).take(3),
1405
+ * recent: posts.where({ published: true }).limit(3),
936
1406
  * total: posts.count(),
937
1407
  * averageViews: posts.avg('views'),
938
1408
  * }),
@@ -943,7 +1413,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
943
1413
  * // }
944
1414
  * ```
945
1415
  */
946
- combine<Spec extends Record<string, CollectionImpl<TContract, ModelName, unknown, CollectionTypeState> | IncludeScalar<unknown>>>(spec: Spec): IncludeCombine<{ [K in keyof Spec]: Spec[K] extends IncludeScalar<infer ScalarResult> ? ScalarResult : Spec[K] extends CollectionImpl<TContract, ModelName, infer BranchRow, CollectionTypeState> ? BranchRow[] : never; }>;
1416
+ combine<Spec extends Record<string, IncludeRefinementCollection<TContract, ModelName, unknown, CollectionTypeState, true> | IncludeScalar<unknown>>>(spec: Spec): IncludeCombine<{ [K in keyof Spec]: Spec[K] extends IncludeScalar<infer ScalarResult> ? ScalarResult : Spec[K] extends HasRow ? CollectionRowOf<Spec[K]>[] : never; }>;
947
1417
  /**
948
1418
  * Resume pagination from a known cursor position. Requires a prior
949
1419
  * `orderBy(...)` so the cursor has a stable basis; provide a value
@@ -953,18 +1423,19 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
953
1423
  * ```typescript
954
1424
  * const page1 = await db.orm.Post
955
1425
  * .orderBy((p) => p.createdAt.desc())
956
- * .take(20)
1426
+ * .limit(20)
957
1427
  * .all();
958
1428
  *
959
1429
  * const last = page1[page1.length - 1]!;
960
1430
  * const page2 = await db.orm.Post
961
1431
  * .orderBy((p) => p.createdAt.desc())
962
1432
  * .cursor({ createdAt: last.createdAt })
963
- * .take(20)
1433
+ * .limit(20)
964
1434
  * .all();
965
1435
  * ```
966
1436
  */
967
- cursor(cursorValues: State['hasOrderBy'] extends true ? Partial<Record<keyof DefaultModelRow<TContract, ModelName> & string, unknown>> : never): Collection<TContract, ModelName, Row, State>;
1437
+ cursor<Self extends HasOrderBy & WithoutUniqueFilter<Self>>(this: Self, cursorValues: Partial<Record<keyof DefaultModelRow<TContract, ModelName> & string, unknown>>): Self;
1438
+ cursor<Self extends HasOrderBy>(this: Self & HasNoUniqueFilter, cursorValues: Partial<Record<keyof DefaultModelRow<TContract, ModelName> & string, unknown>>): Self;
968
1439
  /**
969
1440
  * Emit `SELECT DISTINCT` keyed on the given fields. Replaces any
970
1441
  * previous `distinct(...)` / `distinctOn(...)` selection.
@@ -973,13 +1444,16 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
973
1444
  * const groups = await db.orm.User.distinct('country', 'role').all();
974
1445
  * ```
975
1446
  */
976
- distinct<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]]>(...fields: Fields): Collection<TContract, ModelName, Row, State>;
1447
+ distinct<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]], Self extends WithoutUniqueFilter<Self>>(this: Self, ...fields: Fields): Self;
1448
+ distinct<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]], Self>(this: Self & HasNoUniqueFilter, ...fields: Fields): Self;
977
1449
  /**
978
1450
  * Emit `SELECT DISTINCT ON (fields)` — keep the first row per
979
1451
  * distinct key according to the current `orderBy(...)`. Requires a
980
1452
  * prior `orderBy(...)`; replaces any previous `distinct(...)` /
981
1453
  * `distinctOn(...)` selection.
982
1454
  *
1455
+ * Requires the `postgres.distinctOn` capability.
1456
+ *
983
1457
  * ```typescript
984
1458
  * // Latest post per user:
985
1459
  * const latestPerUser = await db.orm.Post
@@ -988,27 +1462,66 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
988
1462
  * .all();
989
1463
  * ```
990
1464
  */
991
- distinctOn<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]]>(...fields: State['hasOrderBy'] extends true ? Fields : never): Collection<TContract, ModelName, Row, State>;
1465
+ distinctOn<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]], Self extends HasOrderBy & WithoutUniqueFilter<Self>>(this: Self, ...fields: TContract['capabilities'] extends {
1466
+ postgres: {
1467
+ distinctOn: true;
1468
+ };
1469
+ } ? Fields : never): Self;
1470
+ distinctOn<Fields extends readonly [keyof DefaultModelRow<TContract, ModelName> & string, ...(keyof DefaultModelRow<TContract, ModelName> & string)[]], Self extends HasOrderBy>(this: Self & HasNoUniqueFilter, ...fields: TContract['capabilities'] extends {
1471
+ postgres: {
1472
+ distinctOn: true;
1473
+ };
1474
+ } ? Fields : never): Self;
1475
+ /**
1476
+ * Lock the selected rows of this model with `FOR UPDATE` until the transaction ends.
1477
+ *
1478
+ * Requires the `sql.forUpdate` and `sql.lockOf` capabilities, because the lock always names the model's table with `OF`.
1479
+ *
1480
+ * ```typescript
1481
+ * const job = await tx.orm.Job.where({ state: 'queued' }).limit(1).forUpdate({ skipLocked: true }).first();
1482
+ * ```
1483
+ */
1484
+ forUpdate<Self>(this: Self, ...options: LockMethodArgs<TContract['capabilities'], 'forUpdate'>): Self;
1485
+ /**
1486
+ * Lock the selected rows of this model with `FOR NO KEY UPDATE` until the transaction ends. Unlike `forUpdate`, it does not block foreign-key checks from rows that reference them.
1487
+ *
1488
+ * Requires the `postgres.forNoKeyUpdate` and `sql.lockOf` capabilities, because the lock always names the model's table with `OF`.
1489
+ */
1490
+ forNoKeyUpdate<Self>(this: Self, ...options: LockMethodArgs<TContract['capabilities'], 'forNoKeyUpdate'>): Self;
1491
+ /**
1492
+ * Lock the selected rows of this model with `FOR SHARE` until the transaction ends; other transactions may share-lock them but not write them.
1493
+ *
1494
+ * Requires the `sql.forShare` and `sql.lockOf` capabilities, because the lock always names the model's table with `OF`.
1495
+ */
1496
+ forShare<Self>(this: Self, ...options: LockMethodArgs<TContract['capabilities'], 'forShare'>): Self;
1497
+ /**
1498
+ * Lock the selected rows of this model with `FOR KEY SHARE` until the transaction ends; only deletes and key changes are blocked.
1499
+ *
1500
+ * Requires the `postgres.forKeyShare` and `sql.lockOf` capabilities, because the lock always names the model's table with `OF`.
1501
+ */
1502
+ forKeyShare<Self>(this: Self, ...options: LockMethodArgs<TContract['capabilities'], 'forKeyShare'>): Self;
992
1503
  /**
993
1504
  * Apply `LIMIT n`. Replaces any previous limit set on this collection.
994
1505
  *
995
1506
  * ```typescript
996
- * const firstTen = await db.orm.User.orderBy((u) => u.id.asc()).take(10).all();
1507
+ * const firstTen = await db.orm.User.orderBy((u) => u.id.asc()).limit(10).all();
997
1508
  * ```
998
1509
  */
999
- take(n: number): Collection<TContract, ModelName, Row, State>;
1510
+ limit<Self extends WithoutUniqueFilter<Self>>(this: Self, n: number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>>): Self;
1511
+ limit<Self>(this: Self & HasNoUniqueFilter, n: number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>>): Self;
1000
1512
  /**
1001
1513
  * Apply `OFFSET n`. Replaces any previous offset set on this collection.
1002
1514
  *
1003
1515
  * ```typescript
1004
1516
  * const page2 = await db.orm.User
1005
1517
  * .orderBy((u) => u.id.asc())
1006
- * .skip(10)
1007
- * .take(10)
1518
+ * .offset(10)
1519
+ * .limit(10)
1008
1520
  * .all();
1009
1521
  * ```
1010
1522
  */
1011
- skip(n: number): Collection<TContract, ModelName, Row, State>;
1523
+ offset<Self extends WithoutUniqueFilter<Self>>(this: Self, n: number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>>): Self;
1524
+ offset<Self>(this: Self & HasNoUniqueFilter, n: number | TraitExpression<readonly ['numeric'], false, ExtractCodecTypes<TContract>>): Self;
1012
1525
  /**
1013
1526
  * Read terminal: execute the query and stream every matching row.
1014
1527
  *
@@ -1019,15 +1532,9 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1019
1532
  * whichever fits the caller. A single result can only be consumed
1020
1533
  * once.
1021
1534
  *
1022
- * Streaming is the default and the expected execution model. The
1023
- * only scenarios that fall back to buffering internally before
1024
- * yielding are drivers that cannot expose a cursor to the
1025
- * underlying database, and — for queries with `include(...)` —
1026
- * targets whose SQL dialect supports neither lateral joins nor
1027
- * correlated subqueries (so child rows cannot be stitched in a
1028
- * single streaming query). These are implementation details below
1029
- * the public API; the iteration shape itself is genuinely
1030
- * streaming whenever the driver and plan allow it.
1535
+ * Queries without `include(...)` stream rows as the driver yields them (drivers that cannot
1536
+ * expose a cursor buffer internally first). Queries with `include(...)` read the whole parent
1537
+ * result set into memory before yielding the first row.
1031
1538
  *
1032
1539
  * ```typescript
1033
1540
  * // Thenable — collect to an array:
@@ -1040,17 +1547,15 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1040
1547
  * }
1041
1548
  * ```
1042
1549
  *
1043
- * Accepts an optional `configure` callback that receives a
1044
- * `MetaBuilder<'read'>` so the caller can attach typed user
1045
- * annotations to the executed plan. `meta.annotate(...)` enforces
1046
- * applicability at the type level and at runtime; annotations are
1047
- * merged into `plan.meta.annotations` at compile time.
1550
+ * Accepts an optional `configure` callback that receives a `MetaBuilder<'read'>` so the caller can attach typed user annotations to the call. `meta.annotate(...)` enforces applicability at the type level and at runtime. Every terminal method runs as one `orm-call` activity that carries the annotations; the statements it sends carry none.
1048
1551
  *
1049
1552
  * ```typescript
1050
- * await db.orm.User.all((meta) => meta.annotate(cacheAnnotation({ ttl: 60 })));
1553
+ * await db.orm.User.all((meta) => meta.annotate(cacheAnnotation({ key: 'users' })));
1051
1554
  * ```
1052
1555
  */
1053
- all(configure?: (meta: MetaBuilder<'read'>) => void): AsyncIterableResult<Row>;
1556
+ all<Self extends this>(this: Self & HasNoUniqueFilter, configure?: (meta: MetaBuilder<'read'>) => void): AsyncIterableResult<CollectionRowOf<Self>>;
1557
+ all<Self>(this: Self & HasNoUniqueFilter, configure?: (meta: MetaBuilder<'read'>) => void): AsyncIterableResult<CollectionRowOf<this>>;
1558
+ get prepared(): PreparedCollection<TContract, ModelName, CollectionRowOf<this>, CollectionTypeStateOf<this>>;
1054
1559
  /**
1055
1560
  * Read terminal: return the first matching row, or `null` if none
1056
1561
  * match. Optionally accepts a filter (callback or shorthand object)
@@ -1071,14 +1576,14 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1071
1576
  *
1072
1577
  * // Annotate without filtering further:
1073
1578
  * await db.orm.User.first(undefined, (meta) =>
1074
- * meta.annotate(cacheAnnotation({ ttl: 60 })),
1579
+ * meta.annotate(cacheAnnotation({})),
1075
1580
  * );
1076
1581
  * ```
1077
1582
  */
1078
- first(): Promise<Row | null>;
1079
- first(filter: undefined, configure: (meta: MetaBuilder<'read'>) => void): Promise<Row | null>;
1080
- first(filter: (model: VariantAwareModelAccessor<TContract, ModelName, State['variantName'], State['nsId']>) => WhereArg, configure?: (meta: MetaBuilder<'read'>) => void): Promise<Row | null>;
1081
- first(filter: ShorthandWhereFilter<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'read'>) => void): Promise<Row | null>;
1583
+ first<Self extends this>(this: Self, filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Promise<CollectionRowOf<Self> | null>;
1584
+ first(filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Promise<CollectionRowOf<this> | null>;
1585
+ firstOrThrow<Self extends this>(this: Self, filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Promise<CollectionRowOf<Self>>;
1586
+ firstOrThrow(filter?: WhereInput<TContract, State['nsId'], ModelName, State['variantValue']>, configure?: (meta: MetaBuilder<'read'>) => void): Promise<CollectionRowOf<this>>;
1082
1587
  /**
1083
1588
  * Read terminal: run an aggregate query (count, sum, avg, min, max)
1084
1589
  * built via the `AggregateBuilder` callback. Returns one object
@@ -1097,21 +1602,21 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1097
1602
  * ```
1098
1603
  *
1099
1604
  * Accepts an optional `configure` callback that receives a
1100
- * `MetaBuilder<'read'>` for attaching typed annotations.
1101
- * Annotations are merged into the compiled plan's `meta.annotations`.
1605
+ * `MetaBuilder<'read'>` for attaching typed annotations to the call.
1102
1606
  */
1103
- aggregate<Spec extends AggregateSpec>(fn: (aggregate: AggregateBuilder<TContract, ModelName, State['nsId']>) => Spec, configure?: (meta: MetaBuilder<'read'>) => void): Promise<AggregateResult<Spec>>;
1607
+ aggregate<Spec extends AggregateSpec, Self = unknown>(this: Self & HasNoUniqueFilter, fn: (aggregate: AggregateBuilder<TContract, ModelName, State['nsId']>) => Spec, configure?: (meta: MetaBuilder<'read'>) => void): Promise<AggregateResult<Spec>>;
1104
1608
  /**
1105
1609
  * Write terminal: insert one row and return it (with any configured
1106
1610
  * `select(...)` / `include(...)` projections applied to the returned
1107
1611
  * shape).
1108
1612
  *
1109
- * Related rows can be created or linked through relation callbacks
1110
- * on parent/child-owned relations (one-to-one or one-to-many).
1111
- * The callback receives a mutator exposing `create(...)` and
1112
- * `connect(...)`; `disconnect(...)` is only supported in nested
1113
- * `update(...)` mutations. Many-to-many relations are not yet
1114
- * supported as nested-mutation targets.
1613
+ * Related rows can be created or linked through relation callbacks on any relation: to-one
1614
+ * (1:1, N:1), to-many (1:N), and many-to-many (N:M, written through the junction table). The
1615
+ * callback receives a mutator exposing `create(...)` and `connect(...)`; `disconnect(...)` is
1616
+ * only supported in nested `update(...)` mutations. To-one relations take a single row or
1617
+ * criterion.
1618
+ * N:M `create`/`connect` are unavailable when the junction has required columns the relation API
1619
+ * cannot populate.
1115
1620
  *
1116
1621
  * ```typescript
1117
1622
  * // Simple insert:
@@ -1136,19 +1641,11 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1136
1641
  * });
1137
1642
  * ```
1138
1643
  *
1139
- * Accepts an optional `configure` callback that receives a
1140
- * `MetaBuilder<'write'>` for attaching typed annotations.
1141
- * Annotations are merged into the compiled mutation plan's
1142
- * `meta.annotations`.
1143
- *
1144
- * Note: when the input contains nested-mutation callbacks, the
1145
- * operation is executed as a graph of internal queries via
1146
- * `withMutationScope`. In that path, annotations apply to the
1147
- * logical `create()` call but do not currently flow into each
1148
- * constituent SQL statement issued for the related rows.
1644
+ * Accepts an optional `configure` callback that receives a `MetaBuilder<'write'>` for attaching typed annotations to the call, including when the input contains relation callbacks and the call sends several statements and a read-back.
1149
1645
  */
1150
- create(data: ResolvedCreateInput<TContract, ModelName, State['variantName'], State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<Row>;
1151
- create(data: MutationCreateInputWithRelations<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<Row>;
1646
+ create<Self extends this>(this: Self, data: ResolvedCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<Self>>;
1647
+ create<Self extends this>(this: Self, data: MutationCreateInputWithRelations<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<Self>>;
1648
+ create(data: MutationCreateInputWithRelations<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<this>>;
1152
1649
  /**
1153
1650
  * Write terminal: insert many rows and stream the inserted rows.
1154
1651
  *
@@ -1170,16 +1667,25 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1170
1667
  * for await (const row of db.orm.User.createAll(seedUsers)) {
1171
1668
  * console.log('inserted', row.id);
1172
1669
  * }
1670
+ *
1671
+ * // Let the database skip rows that collide with a unique
1672
+ * // constraint; only the rows it inserted come back:
1673
+ * const inserted = await db.orm.User.createAll(seedUsers, {
1674
+ * onConflict: 'skip',
1675
+ * conflictOn: ['email'],
1676
+ * });
1173
1677
  * ```
1174
1678
  *
1175
1679
  * Accepts an optional `configure` callback that receives a
1176
1680
  * `MetaBuilder<'write'>` for attaching typed annotations to the
1177
- * compiled insert plan.
1681
+ * call. It may be passed in second position when there are no options.
1178
1682
  */
1179
- createAll(data: readonly ResolvedCreateInput<TContract, ModelName, State['variantName'], State['nsId']>[], configure?: (meta: MetaBuilder<'write'>) => void): AsyncIterableResult<Row>;
1683
+ createAll<Self extends this>(this: Self, data: readonly ResolvedScalarCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>[], optionsOrConfigure?: CreateConflictOptions<TContract, ModelName> | WriteConfigure, configure?: WriteConfigure): AsyncIterableResult<CollectionRowOf<Self>>;
1684
+ createAll(data: readonly ResolvedScalarCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>[], optionsOrConfigure?: CreateConflictOptions<TContract, ModelName> | WriteConfigure, configure?: WriteConfigure): AsyncIterableResult<CollectionRowOf<this>>;
1180
1685
  /**
1181
1686
  * Write terminal: insert many rows without materializing the
1182
- * inserted rows, returning the number of inserted records.
1687
+ * inserted rows, returning the number of rows the database reports
1688
+ * inserting.
1183
1689
  *
1184
1690
  * Prefer `createAll(...)` when you need the returned rows; prefer
1185
1691
  * this when you only need to know how many rows were inserted (the
@@ -1191,11 +1697,17 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1191
1697
  * { email: 'b@example.com' },
1192
1698
  * ]);
1193
1699
  * // inserted === 2
1700
+ *
1701
+ * // Let the database skip rows that collide with a unique
1702
+ * // constraint; the count is how many it actually inserted:
1703
+ * const added = await db.orm.User.createAndCount(seedUsers, {
1704
+ * onConflict: 'skip',
1705
+ * });
1194
1706
  * ```
1195
1707
  *
1196
1708
  * Not supported on MTI variants — use `createAll(...)` instead.
1197
1709
  */
1198
- createAndCount(data: readonly ResolvedCreateInput<TContract, ModelName, State['variantName']>[], configure?: (meta: MetaBuilder<'write'>) => void): Promise<number>;
1710
+ createAndCount(data: readonly ResolvedScalarCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>[], optionsOrConfigure?: CreateConflictOptions<TContract, ModelName> | WriteConfigure, configure?: WriteConfigure): Promise<number>;
1199
1711
  /**
1200
1712
  * Write terminal: insert a row, or update the existing row on
1201
1713
  * conflict. Returns the resulting row (the inserted one or the
@@ -1212,13 +1724,14 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1212
1724
  * conflictOn: { email: 'alice@example.com' },
1213
1725
  * });
1214
1726
  *
1215
- * // Conditional create — `update: {}` keeps the existing row
1216
- * // unchanged. `conflictOn` must reference the constraint that
1217
- * // makes the row "already exist"; omit only when the conflict is
1218
- * // on the primary key. On conflict,
1219
- * // `ON CONFLICT DO NOTHING RETURNING ...` may return zero rows,
1220
- * // so a follow-up reload is issued to fetch and return the
1221
- * // existing row.
1727
+ * // Conditional create: with `update: {}` the row is returned whether it
1728
+ * // was inserted or already existed. When it already exists, the conflict
1729
+ * // clause assigns the first conflict column its own value, which is an
1730
+ * // update: update triggers fire, the row is locked until the transaction
1731
+ * // ends, the caller needs UPDATE privilege on the table, and the call
1732
+ * // fails if that column is generated. `conflictOn` must reference the
1733
+ * // constraint that makes the row "already exist"; omit it only when the
1734
+ * // conflict is on the primary key.
1222
1735
  * await db.orm.User.upsert({
1223
1736
  * create: { email: 'alice@example.com', name: 'Alice' },
1224
1737
  * update: {},
@@ -1228,23 +1741,31 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1228
1741
  *
1229
1742
  * Not supported on MTI variants.
1230
1743
  */
1744
+ upsert<Self extends this>(this: Self, input: {
1745
+ create: ResolvedScalarCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>;
1746
+ update: ScalarUpdateInput<TContract, ModelName>;
1747
+ conflictOn?: UniqueConstraintCriterion<TContract, ModelName>;
1748
+ }, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<Self>>;
1231
1749
  upsert(input: {
1232
- create: ResolvedCreateInput<TContract, ModelName, State['variantName']>;
1233
- update: Partial<DefaultModelRow<TContract, ModelName>>;
1750
+ create: ResolvedScalarCreateInput<TContract, ModelName, State['variantValue'], State['nsId']>;
1751
+ update: ScalarUpdateInput<TContract, ModelName>;
1234
1752
  conflictOn?: UniqueConstraintCriterion<TContract, ModelName>;
1235
- }, configure?: (meta: MetaBuilder<'write'>) => void): Promise<Row>;
1753
+ }, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<this>>;
1236
1754
  /**
1237
1755
  * Write terminal: update a single matching row — the first one the
1238
1756
  * filter matches — and return it (or `null` when no row matched).
1239
1757
  * Requires a prior `.where(...)` — calling `update(...)` on an
1240
1758
  * unfiltered collection is a type error.
1241
1759
  *
1242
- * Related rows can be created or relinked through relation
1243
- * callbacks on parent/child-owned relations (one-to-one or
1244
- * one-to-many). The callback receives a mutator exposing
1245
- * `create(...)`, `connect(...)`, and `disconnect(...)`. Nested
1246
- * updates against existing related rows, and many-to-many relations
1247
- * as nested-mutation targets, are not supported through this API.
1760
+ * The row is the one `first()` returns, so an order, an offset, a cursor, `distinct` and `distinctOn` choose it; after `limit(0)` no row changes and the result is `null`. An update with a relation callback finds its row by the filter alone, so it throws `ORM.ARGUMENT_INVALID` on a collection with an order, a limit, an offset, a cursor, `distinct` or `distinctOn`.
1761
+ *
1762
+ * Related rows can be created, linked, or unlinked through relation callbacks on any relation:
1763
+ * to-one (1:1, N:1), to-many (1:N), and many-to-many (N:M, written through the junction table).
1764
+ * The callback receives a mutator exposing `create(...)`, `connect(...)`, and `disconnect(...)`.
1765
+ * A to-one `disconnect()` clears the foreign key; a to-many `disconnect()` with no criteria
1766
+ * unlinks every related row; an N:M `disconnect()` requires criteria. N:M `create`/`connect` are
1767
+ * unavailable when the junction has required columns the relation API cannot populate. Nested
1768
+ * updates against existing related rows are not supported through this API.
1248
1769
  *
1249
1770
  * ```typescript
1250
1771
  * // Update one row by id:
@@ -1262,18 +1783,12 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1262
1783
  * ```
1263
1784
  *
1264
1785
  * Accepts an optional `configure` callback that receives a
1265
- * `MetaBuilder<'write'>` for attaching typed annotations.
1266
- *
1267
- * Note: when the input contains nested-mutation callbacks, the
1268
- * operation is executed as a graph of internal queries via
1269
- * `withMutationScope`. In that path, annotations apply to the logical
1270
- * `update()` call but do not currently flow into each constituent SQL
1271
- * statement issued for the related rows.
1786
+ * `MetaBuilder<'write'>` for attaching typed annotations to the call, including when the input contains relation callbacks.
1272
1787
  */
1273
- update(data: State['hasWhere'] extends true ? MutationUpdateInput<TContract, ModelName, State['nsId']> : never, configure?: (meta: MetaBuilder<'write'>) => void): Promise<Row | null>;
1788
+ update<Self extends HasWhere>(this: Self, data: MutationUpdateInput<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<Self & HasRow<CollectionRowOf<this>>> | null>;
1274
1789
  /**
1275
1790
  * Write terminal: update every matching row and stream the updated
1276
- * rows. Requires a prior `.where(...)` filter.
1791
+ * rows. Requires a prior `.where(...)` filter. Throws `ORM.ARGUMENT_INVALID` on a collection with a limit, an offset, a cursor, `distinct` or `distinctOn`, which the statement cannot apply.
1277
1792
  *
1278
1793
  * The returned `AsyncIterableResult<Row>` is BOTH a thenable that
1279
1794
  * resolves to `Row[]` AND an async iterable that streams updated
@@ -1296,11 +1811,11 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1296
1811
  * Accepts an optional `configure` callback that receives a
1297
1812
  * `MetaBuilder<'write'>` for attaching typed annotations.
1298
1813
  */
1299
- updateAll(data: State['hasWhere'] extends true ? Partial<DefaultModelRow<TContract, ModelName, State['nsId']>> : never, configure?: (meta: MetaBuilder<'write'>) => void): AsyncIterableResult<Row>;
1814
+ updateAll<Self extends HasWhere>(this: Self & HasNoUniqueFilter, data: ScalarUpdateInput<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): AsyncIterableResult<CollectionRowOf<Self & HasRow<CollectionRowOf<this>>>>;
1300
1815
  /**
1301
1816
  * Write terminal: update every matching row without returning them,
1302
1817
  * resolving to the count of rows that were updated. Requires a prior
1303
- * `.where(...)` filter.
1818
+ * `.where(...)` filter. Throws `ORM.ARGUMENT_INVALID` on a collection with a limit, an offset, a cursor, `distinct` or `distinctOn`, which the statement cannot apply.
1304
1819
  *
1305
1820
  * Prefer `updateAll(...)` when you need the updated rows; prefer
1306
1821
  * this when you only need the affected-row count.
@@ -1311,12 +1826,12 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1311
1826
  * .updateAndCount({ published: true });
1312
1827
  * ```
1313
1828
  */
1314
- updateAndCount(data: State['hasWhere'] extends true ? Partial<DefaultModelRow<TContract, ModelName, State['nsId']>> : never, configure?: (meta: MetaBuilder<'write'>) => void): Promise<number>;
1829
+ updateAndCount<Self extends HasWhere>(this: Self & HasNoUniqueFilter, data: ScalarUpdateInput<TContract, ModelName, State['nsId']>, configure?: (meta: MetaBuilder<'write'>) => void): Promise<number>;
1315
1830
  /**
1316
1831
  * Write terminal: delete a single matching row — the first one the
1317
1832
  * filter matches — and return it (or `null` when no row matched).
1318
1833
  * Requires a prior `.where(...)` — calling `delete()` on an
1319
- * unfiltered collection is a type error.
1834
+ * unfiltered collection is a type error. The row is the one `first()` returns, so an order, an offset, a cursor, `distinct` and `distinctOn` choose it; after `limit(0)` no row is deleted and the result is `null`.
1320
1835
  *
1321
1836
  * ```typescript
1322
1837
  * const deleted = await db.orm.User.where({ id: 1 }).delete();
@@ -1326,10 +1841,10 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1326
1841
  * Accepts an optional `configure` callback that receives a
1327
1842
  * `MetaBuilder<'write'>` for attaching typed annotations.
1328
1843
  */
1329
- delete(this: State['hasWhere'] extends true ? Collection<TContract, ModelName, Row, State> : never, configure?: (meta: MetaBuilder<'write'>) => void): Promise<Row | null>;
1844
+ delete<Self extends HasWhere>(this: Self, configure?: (meta: MetaBuilder<'write'>) => void): Promise<CollectionRowOf<Self & HasRow<CollectionRowOf<this>>> | null>;
1330
1845
  /**
1331
1846
  * Write terminal: delete every matching row and stream the deleted
1332
- * rows. Requires a prior `.where(...)` filter.
1847
+ * rows. Requires a prior `.where(...)` filter. Throws `ORM.ARGUMENT_INVALID` on a collection with a limit, an offset, a cursor, `distinct` or `distinctOn`, which the statement cannot apply.
1333
1848
  *
1334
1849
  * The returned `AsyncIterableResult<Row>` is BOTH a thenable that
1335
1850
  * resolves to `Row[]` AND an async iterable that streams deleted
@@ -1350,11 +1865,11 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1350
1865
  * Accepts an optional `configure` callback that receives a
1351
1866
  * `MetaBuilder<'write'>` for attaching typed annotations.
1352
1867
  */
1353
- deleteAll(this: State['hasWhere'] extends true ? Collection<TContract, ModelName, Row, State> : never, configure?: (meta: MetaBuilder<'write'>) => void): AsyncIterableResult<Row>;
1868
+ deleteAll<Self extends HasWhere>(this: Self & HasNoUniqueFilter, configure?: (meta: MetaBuilder<'write'>) => void): AsyncIterableResult<CollectionRowOf<Self & HasRow<CollectionRowOf<this>>>>;
1354
1869
  /**
1355
1870
  * Write terminal: delete every matching row without returning them,
1356
1871
  * resolving to the count of rows that were deleted. Requires a prior
1357
- * `.where(...)` filter.
1872
+ * `.where(...)` filter. Throws `ORM.ARGUMENT_INVALID` on a collection with a limit, an offset, a cursor, `distinct` or `distinctOn`, which the statement cannot apply.
1358
1873
  *
1359
1874
  * Prefer `deleteAll(...)` when you need the deleted rows; prefer
1360
1875
  * this when you only need the affected-row count.
@@ -1363,7 +1878,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1363
1878
  * const removed = await db.orm.Post.where({ archived: true }).deleteAndCount();
1364
1879
  * ```
1365
1880
  */
1366
- deleteAndCount(this: State['hasWhere'] extends true ? Collection<TContract, ModelName, Row, State> : never, configure?: (meta: MetaBuilder<'write'>) => void): Promise<number>;
1881
+ deleteAndCount<Self extends HasWhere>(this: Self & HasNoUniqueFilter, configure?: (meta: MetaBuilder<'write'>) => void): Promise<number>;
1367
1882
  }
1368
1883
  /**
1369
1884
  * The public collection surface: the chainable builder and terminal methods
@@ -1373,7 +1888,7 @@ declare class CollectionImpl<TContract extends Contract<SqlStorage>, ModelName e
1373
1888
  * chaining preserves it, and a contributed operation surfaces without any
1374
1889
  * client change.
1375
1890
  */
1376
- type Collection<TContract extends Contract<SqlStorage>, ModelName extends string, Row = SimplifyDeep<InferRootRow<TContract, ModelName>>, State extends CollectionTypeState = DefaultCollectionTypeState> = CollectionImpl<TContract, ModelName, Row, State> & AggregateIncludeReducers<TContract, ModelName, State['nsId']>;
1891
+ type Collection<TContract extends Contract<SqlStorage>, ModelName extends string, Row = SimplifyDeep<InferRootRow<TContract, ModelName>>, State extends CollectionTypeState = DefaultCollectionTypeState> = CollectionBase<TContract, ModelName, Row, State> & AggregateIncludeReducers<TContract, ModelName, State['nsId']>;
1377
1892
  /**
1378
1893
  * The constructor face of {@link Collection}: constructing — or subclassing,
1379
1894
  * as custom collections registered via `orm({ collections })` do — yields the
@@ -1386,29 +1901,64 @@ interface CollectionSurfaceConstructor {
1386
1901
  declare const Collection: CollectionSurfaceConstructor;
1387
1902
  //#endregion
1388
1903
  //#region src/filters.d.ts
1389
- declare function and(...exprs: AnyExpression[]): AndExpr;
1390
- declare function or(...exprs: AnyExpression[]): OrExpr;
1391
- declare function not(expr: AnyExpression): AnyExpression;
1904
+ declare function and(...exprs: Condition[]): AndExpr;
1905
+ declare function or(...exprs: Condition[]): OrExpr;
1906
+ declare function not(expr: Condition): AnyExpression;
1392
1907
  declare function all(): AnyExpression;
1393
1908
  //#endregion
1394
1909
  //#region src/model-accessor.d.ts
1395
- declare function createModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, VariantName extends string | undefined = undefined>(context: ExecutionContext<TContract>, namespaceId: string, modelName: ModelName, variantName?: VariantName): VariantAwareModelAccessor<TContract, ModelName, VariantName>;
1910
+ declare function createModelAccessor<TContract extends Contract<SqlStorage>, ModelName extends string, VariantValue extends string | undefined = undefined, NsId extends string = string>(context: ExecutionContext<TContract>, namespaceId: NsId, modelName: ModelName, tables: CollectionTables, variantValue?: VariantValue): VariantAwareModelAccessor<TContract, ModelName, VariantValue, NsId>;
1396
1911
  //#endregion
1397
1912
  //#region src/orm.d.ts
1398
- interface OrmOptions<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>>> {
1913
+ interface OrmOptions<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> {
1399
1914
  readonly runtime: RuntimeQueryable;
1400
- readonly collections?: Collections;
1915
+ readonly collections?: TCollections;
1401
1916
  readonly context: ExecutionContext<TContract>;
1402
1917
  }
1403
1918
  type ModelNames<TContract extends Contract<SqlStorage>> = CollectionModelName<TContract>;
1404
1919
  type AnyCollectionClass = new (...args: never[]) => object;
1405
- type CustomCollectionForKey<Collections extends Partial<Record<string, AnyCollectionClass>>, Key extends string> = Key extends keyof Collections ? Collections[Key] extends AnyCollectionClass ? InstanceType<Collections[Key]> : never : never;
1406
- type ModelCollection<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>>, NsId extends string, ModelName extends ModelNames<TContract>> = [CustomCollectionForKey<Collections, ModelName>] extends [never] ? Collection<TContract, ModelName, InferRootRow<TContract, ModelName, NsId>, WithNsId<DefaultCollectionTypeState, NsId>> : CustomCollectionForKey<Collections, ModelName>;
1920
+ /** Custom collection classes keyed by model name, as `orm({ collections })` and the clients take them. */
1921
+ type CollectionClasses = Partial<Record<string, AnyCollectionClass>>;
1922
+ /** No custom collection classes: the default of `orm()` and of every client type. */
1923
+ type NoCollectionClasses = Record<never, never>;
1924
+ type CustomCollectionForKey<TCollections extends CollectionClasses, Key extends string> = Key extends keyof TCollections ? TCollections[Key] extends AnyCollectionClass ? InstanceType<TCollections[Key]> : never : never;
1925
+ type ModelCollection<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses, NsId extends string, ModelName extends ModelNames<TContract>> = [CustomCollectionForKey<TCollections, ModelName>] extends [never] ? Collection<TContract, ModelName, InferRootRow<TContract, ModelName, NsId>, WithNsId<DefaultCollectionTypeState, NsId>> : CustomCollectionForKey<TCollections, ModelName>;
1407
1926
  type NamespaceModelNames<TContract extends Contract<SqlStorage>, NsId extends keyof TContract['domain']['namespaces']> = keyof TContract['domain']['namespaces'][NsId]['models'] & string & ModelNames<TContract>;
1408
- type OrmNamespace<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>>, NsId extends keyof TContract['domain']['namespaces']> = { [K in NamespaceModelNames<TContract, NsId>]: ModelCollection<TContract, Collections, NsId & string, K>; };
1409
- type NamespacedClientMap<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>>> = { [Ns in keyof TContract['domain']['namespaces']]: OrmNamespace<TContract, Collections, Ns>; };
1410
- type OrmClient<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>>> = NamespacedClientMap<TContract, Collections>;
1411
- declare function orm<TContract extends Contract<SqlStorage>, Collections extends Partial<Record<string, AnyCollectionClass>> = Record<never, never>>(options: OrmOptions<TContract, Collections>): OrmClient<TContract, Collections>;
1927
+ type OrmNamespace<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses, NsId extends keyof TContract['domain']['namespaces']> = { [K in NamespaceModelNames<TContract, NsId>]: ModelCollection<TContract, TCollections, NsId & string, K>; };
1928
+ type NamespacedClientMap<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = { [Ns in keyof TContract['domain']['namespaces']]: OrmNamespace<TContract, TCollections, Ns>; };
1929
+ /** The members of the ORM client that sit beside its namespaces, such as `fragment`. */
1930
+ interface OrmClientRootMembers<TContract extends Contract<SqlStorage>> {
1931
+ /**
1932
+ * Define a query fragment for any model that has the declared fields. Declare each field with a field builder from the contract DSL or with `{ codecId, nullable }`, and a list field with `.many()` or `many: { elementNullable: false }`, or `.many({ elementsNullable: true })` or `many: { elementNullable: true }` when its elements may be null. The body sees only the declared fields and may call `where`, `orderBy`, `limit` and `offset`; `updateAll`, `updateAndCount`, `deleteAll` and `deleteAndCount` throw `ORM.ARGUMENT_INVALID` after a fragment that set a limit or an offset, as they do for any limit, offset, cursor, `distinct` or `distinctOn` they would ignore. The fragment accepts a collection of any model whose fields include the declared ones with the same codec and nullability, a list with the same element nullability exactly where the declaration declares one, and returns that collection with the filter and order the body applied.
1933
+ *
1934
+ * ```ts
1935
+ * const notDeleted = db.orm.fragment(
1936
+ * { deletedAt: field.temporal.timestamptz().optional() },
1937
+ * (rows) => rows.where((r) => r.deletedAt.isNull()),
1938
+ * );
1939
+ * db.orm.public.Post.with(notDeleted).deleteAll();
1940
+ * ```
1941
+ */
1942
+ fragment<const Declarations extends DeclaredFieldsFragmentFieldDeclarations<keyof ExtractCodecTypes<TContract> & string>, Facts extends FragmentFacts>(fields: Declarations, body: (rows: DeclaredFieldsFragmentCollection<DeclaredFieldsFragmentModelAccessor<TContract, DeclaredFields<Declarations>>, FragmentFacts, TContract>) => DeclaredFieldsFragmentCollection<DeclaredFieldsFragmentModelAccessor<TContract, DeclaredFields<Declarations>>, Facts, TContract>): DeclaredFieldsFragment<TContract, DeclaredFields<Declarations>, Facts>;
1943
+ }
1944
+ type OrmClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = NamespacedClientMap<TContract, TCollections> & ('fragment' extends keyof TContract['domain']['namespaces'] ? unknown : OrmClientRootMembers<TContract>);
1945
+ declare function orm<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses>(options: OrmOptions<TContract, TCollections>): OrmClient<TContract, TCollections>;
1946
+ /**
1947
+ * Checks that each custom collection class is a `Collection` subclass registered under a model the contract has, and returns the classes by model name. `orm()` calls it, and a client calls it when it is created, so a wrong class fails there and not on the first query.
1948
+ */
1949
+ declare function checkCollectionClasses<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses>(contract: TContract, collections: TCollections | undefined): ReadonlyMap<string, AnyCollectionClass>;
1950
+ //#endregion
1951
+ //#region src/prepared-row-query.d.ts
1952
+ interface PreparedRowQuery<Params, Result> {
1953
+ query(target: RuntimeQueryable$1, params: Params, options?: RuntimeExecuteOptions): Result;
1954
+ }
1955
+ /** The `prepare` member a client and its transactions offer, typed by the client's contract. */
1956
+ interface PrepareMember<TContract extends Contract<SqlStorage>> {
1957
+ prepare<D extends Declaration<CT>, Q extends SqlQueryPlan | Preparable<unknown, unknown>, CT extends CodecTypesBase = ExtractCodecTypes<TContract>>(declaration: D, callback: (params: BindSiteParams<D>) => Q): Promise<PreparedFrom<ParamsFromDeclaration<D, CT>, Q>>;
1958
+ }
1959
+ type PreparedFrom<Params, Q extends SqlQueryPlan | Preparable<unknown, unknown>> = Q extends Preparable<unknown, infer Result> ? PreparedRowQuery<Params, Result> : PreparedFor<Params, ResultType<Q>>;
1960
+ declare function prepareQuery<D extends Declaration<CT>, Q extends SqlQueryPlan | Preparable<unknown, unknown>, CT extends CodecTypesBase>(runtime: Runtime, declaration: D, callback: (params: BindSiteParams<D>) => Q): Promise<PreparedFrom<ParamsFromDeclaration<D, CT>, Q>>;
1961
+ declare function createPreparedRowQuery<Params, DbRow, Result>(description: Preparable<DbRow, Result>, statement: PreparedStatement<Params, DbRow>): PreparedRowQuery<Params, Result>;
1412
1962
  //#endregion
1413
- export { type AggregateBuilder, type AggregateResult, type AggregateSpec, Collection, type CollectionContext, type CollectionModelName, type CollectionState, type CollectionTypeState, type ComparisonMethods, type CreateInput, type DefaultCollectionTypeState, type DefaultModelRow, GroupedCollection, type IncludeExpr, type ModelAccessor, type NumericFieldNames, type OrmOptions, type RelatedModelName, type RelationFilterAccessor, type RelationMutator, type RelationNames, type RelationPredicate, type RelationPredicateInput, type RelationsOf, type RuntimeQueryable, type ShorthandWhereFilter, type UniqueConstraintCriterion, all, and, createModelAccessor, emptyState, not, or, orm };
1963
+ export { type AggregateBuilder, type AggregateIncludeReducers, type AggregateResult, type AggregateSelector, type AggregateSpec, type AliasedTable, type CodecField, type CodecListField, Collection, type CollectionClasses, type CollectionContext, type CollectionMethodNameClash, type CollectionModelName, type CollectionRowOf, type CollectionState, type CollectionTables, type CollectionTypeState, type CollectionTypeStateOf, type ComparisonMethods, type Condition, type ContributedCollectionMethod, type ContributedCollectionMethods, type ContributedMethodResult, type CreateInput, type DeclaredField, type DeclaredFieldsFragment, type DeclaredFieldsFragmentCallbackTools, type DefaultCollectionTypeState, type DefaultModelRow, type Filtered, type FragmentFacts, type FunctionCondition, GroupedCollection, type HasNoVariant, type HasOrderBy, type HasRow, type HasTypeState, type HasUniqueFilter, type HasWhere, type IncludeExpr, type IncludeScalar, type Including, type ModelAccessor, type ModelCallbackTools, type ModelContributedMethodTable, type ModelIndexReferences, type NoCollectionClasses, type NumericFieldNames, type OrderOptions, type Orderable, type OrderableFieldNames, type Ordered, type OrmClientRootMembers, type OrmFunctions, type OrmFunctionsOf, type OrmOptions, type OrmRawSqlBuilder, type OrmRawSqlTag, type PrepareMember, type PreparedCollection, type PreparedFrom, type PreparedRowQuery, type QueryFragment, type RelatedModelName, type RelationFilterAccessor, type RelationMutator, type RelationNames, type RelationPredicate, type RelationPredicateInput, type RelationsOf, type RowType, type RuntimeQueryable, type ScalarUpdateInput, type ShorthandWhereFilter, type TableScope, type TableStorageCoordinate, type ToManyRelationAccessor, type ToOneRelationAccessor, type TypeState, type UniqueConstraintCriterion, type UniquelyFiltered, type WhereCallbackResult, all, and, checkCollectionClasses, createCollectionTables, createModelAccessor, createPreparedRowQuery, emptyState, not, or, orderByField, orm, prepareQuery };
1414
1964
  //# sourceMappingURL=orm-client.d.mts.map