@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
@@ -0,0 +1,1508 @@
1
+ import { i as indexTypeRegistryOf } from "./index-types-pC_5vADQ-BOOBi14R.mjs";
2
+ import { i as computeCheckContentHash, r as composeCheckWirePrefix, s as derivedCheckPrefixes } from "./naming-bM5qm5PY-jOg3JFMb.mjs";
3
+ import { r as lowerAuthoredIndex } from "./index-naming-BOcJT1B3-mG8Fd6KN.mjs";
4
+ import { t as lowerAuthoredCheck } from "./authored-check-naming-BHGJhjqn.mjs";
5
+ import { t as sqlContractCanonicalizationHooks } from "./canonicalization-hooks-Ce1v_TDl.mjs";
6
+ import { p as sqlDataTypeOfCodec, y as validateSqlTypeParams } from "./sql-data-type-D7M-YTTY-D2vRqDxn.mjs";
7
+ import { c as StorageTable, i as Index, t as CheckConstraint } from "./storage-table-DDvN83mw-DkbBFmK9.mjs";
8
+ import { n as checkConstraintInputFromSerialized } from "./serialized-index-DjCCnXB1-DMA7BtO2.mjs";
9
+ import { m as valueSetEntityKind, p as tableEntityKind } from "./entity-kinds-JR5SAm5h-DOH6VUtL.mjs";
10
+ import { a as materializeForeignKeysAndIndexes } from "./foreign-key-materialization-BM59w_Xg.mjs";
11
+ import { t as validateIndexTypes } from "./index-type-validation-DJEMmmw0.mjs";
12
+ import { c as isMaterializedSqlNamespace, d as nonEmptyTypeParams, f as toStorageTypeInstance, o as SqlStorage, s as applyFkDefaults } from "./types-CTdSkl0s.mjs";
13
+ import { h as validateStorageSemantics } from "./validators-BwA7ttZM.mjs";
14
+ import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-HVaxhALD.mjs";
15
+ import { isStructuredError, structuredError } from "@prisma/orm-framework/utils/structured-error";
16
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
17
+ import { flushAuthoringWarnings, isAuthoringEntityTypeDescriptor } from "@prisma/orm-framework/components/authoring";
18
+ import { compareCodeUnits } from "@prisma/orm-framework/contract/hashing-utils";
19
+ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
20
+ import { codecForRef, dataTypeParams } from "@prisma/orm-framework/components/codec";
21
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
22
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
23
+ import { asNamespaceId, coreHash, crossRef, effectiveControlPolicy } from "@prisma/orm-framework/contract/types";
24
+ import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
25
+ import { encodeEnumTypeMembers, resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
26
+ import { buildExecutionSection, computeProfileHash, computeStorageHash } from "@prisma/orm-framework/contract/hashing";
27
+ import { invariant } from "@prisma/orm-framework/utils/assertions";
28
+ import { applySpecifierDefaultControlPolicy } from "@prisma/orm-framework/contract/apply-specifier-default-control-policy";
29
+ //#region ../../../2-sql-family/2-authoring/contract-ts/dist/derived-checks-D5HVRvqN.mjs
30
+ function contractError(code, message, options) {
31
+ return structuredError(code, message, options);
32
+ }
33
+ /**
34
+ * Whether a field is stored in a list column. A list of scalars is; a list of value objects is not, because it is stored in one column whose value is the whole list, as one JSON array.
35
+ */
36
+ function storedAsListColumn(field) {
37
+ return field.list && !field.typedByValueObject;
38
+ }
39
+ /** Whether a field or member is typed by a value object. */
40
+ function isValueObjectMember(field) {
41
+ return "valueObjectName" in field;
42
+ }
43
+ /** Describes one column, declared by a model's field or by a table node. */
44
+ function describeColumn(column, site) {
45
+ return {
46
+ columnName: column.columnName,
47
+ descriptor: column.descriptor,
48
+ nullable: column.nullable,
49
+ many: column.many === true ? { elementNullable: column.elementNullable === true } : false,
50
+ default: column.default,
51
+ enumTypeHandle: column.enumTypeHandle,
52
+ site
53
+ };
54
+ }
55
+ /**
56
+ * The member values a membership check must enforce, encoded exactly as the
57
+ * column stores them. Membership predicates support strings and finite numbers.
58
+ */
59
+ function checkMemberValues(handle, codecLookup) {
60
+ const encoded = encodeEnumTypeMembers(handle, codecLookup, "the column").map((member) => member.value);
61
+ const values = [];
62
+ for (const value of encoded) {
63
+ if (typeof value !== "string" && !(typeof value === "number" && Number.isFinite(value))) throw contractError("CONTRACT.ENUM_INVALID", `enumType("${handle.enumName}"): CHECK constraint members must encode to strings or finite numbers.`, { meta: {
64
+ enumName: handle.enumName,
65
+ reason: "unsupported-member-value"
66
+ } });
67
+ values.push(value);
68
+ }
69
+ return values;
70
+ }
71
+ /**
72
+ * The refs of a field typed by an authored enum: the domain enum and its storage value set. Authored enums are registered in the default namespace, whatever namespace the field's model is in.
73
+ */
74
+ function enumValueSetRefs(enumHandle, defaultNamespaceId) {
75
+ if (enumHandle === void 0) return void 0;
76
+ const common = {
77
+ namespaceId: defaultNamespaceId,
78
+ entityName: enumHandle.enumName
79
+ };
80
+ return {
81
+ domain: {
82
+ plane: "domain",
83
+ entityKind: "enum",
84
+ ...common
85
+ },
86
+ storage: {
87
+ plane: "storage",
88
+ entityKind: "valueSet",
89
+ ...common
90
+ }
91
+ };
92
+ }
93
+ function buildDomainField(field, defaultNamespaceId) {
94
+ if (isValueObjectMember(field)) return {
95
+ type: {
96
+ kind: "valueObject",
97
+ name: field.valueObjectName
98
+ },
99
+ nullable: field.nullable,
100
+ many: field.many ? { elementNullable: field.elementNullable === true } : false
101
+ };
102
+ return {
103
+ type: {
104
+ kind: "scalar",
105
+ codecId: field.descriptor.codecId,
106
+ ...ifDefined("typeParams", nonEmptyTypeParams(field.descriptor.typeParams))
107
+ },
108
+ nullable: field.nullable,
109
+ many: field.many ? { elementNullable: field.elementNullable === true } : false,
110
+ ...ifDefined("valueSet", enumValueSetRefs(field.enumTypeHandle, defaultNamespaceId)?.domain)
111
+ };
112
+ }
113
+ /** How an error message names the column: `Field "Model.field"` or `Column "table.column"`. */
114
+ function columnSiteSubject(site) {
115
+ return site.kind === "field" ? `Field "${site.modelName}.${site.fieldName}"` : `Column "${site.tableName}.${site.columnName}"`;
116
+ }
117
+ /** The error metadata that locates the column. */
118
+ function columnSiteMeta(site) {
119
+ return site.kind === "field" ? {
120
+ modelName: site.modelName,
121
+ fieldName: site.fieldName
122
+ } : {
123
+ namespaceId: site.namespaceId,
124
+ tableName: site.tableName,
125
+ columnName: site.columnName
126
+ };
127
+ }
128
+ /** How an error message names the owner: `model "User"` or `table "audit_rows" in namespace "public"`. */
129
+ function referenceOwnerSubject(owner) {
130
+ return owner.kind === "model" ? `model "${owner.modelName}"` : `table "${owner.tableName}" in namespace "${owner.namespaceId}"`;
131
+ }
132
+ /** The error metadata that locates the owner. */
133
+ function referenceOwnerMeta(owner) {
134
+ return owner.kind === "model" ? { sourceModel: owner.modelName } : {
135
+ sourceTable: owner.tableName,
136
+ sourceNamespaceId: owner.namespaceId
137
+ };
138
+ }
139
+ /** A declared namespace coordinate, where an omitted or empty one means the target's default namespace. */
140
+ function namespaceIdOrDefault(namespaceId, defaultNamespaceId) {
141
+ return namespaceId !== void 0 && namespaceId.length > 0 ? namespaceId : defaultNamespaceId;
142
+ }
143
+ function assertKnownTargetModel(modelsByName, modelsByCoordinate, owner, targetModelName, targetNamespaceId, context) {
144
+ const targetModel = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? modelsByCoordinate.get(`${targetNamespaceId}:${targetModelName}`) : modelsByName.get(targetModelName);
145
+ if (!targetModel) {
146
+ const qualified = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? `${targetNamespaceId}.${targetModelName}` : targetModelName;
147
+ throw contractError("CONTRACT.MODEL_UNKNOWN", `${context} on ${referenceOwnerSubject(owner)} references unknown model "${qualified}"`, { meta: {
148
+ ...referenceOwnerMeta(owner),
149
+ targetModel: qualified,
150
+ context
151
+ } });
152
+ }
153
+ return targetModel;
154
+ }
155
+ function assertTargetTableMatches(owner, targetModel, referencedTableName, context) {
156
+ if (targetModel.tableName !== referencedTableName) throw contractError("CONTRACT.TABLE_MISMATCH", `${context} on ${referenceOwnerSubject(owner)} references table "${referencedTableName}" but model "${targetModel.modelName}" maps to "${targetModel.tableName}"`, { meta: {
157
+ ...referenceOwnerMeta(owner),
158
+ referencedTable: referencedTableName,
159
+ mappedTable: targetModel.tableName,
160
+ context
161
+ } });
162
+ }
163
+ function modelNamespaceId(model, defaultNamespaceId) {
164
+ return namespaceIdOrDefault(model.namespaceId, defaultNamespaceId);
165
+ }
166
+ function modelLookupsOf(definition) {
167
+ const defaultNamespaceId = definition.target.defaultNamespaceId;
168
+ const { models } = definition;
169
+ return {
170
+ defaultNamespaceId,
171
+ modelsByName: new Map(models.map((m) => [m.modelName, m])),
172
+ modelsByCoordinate: new Map(models.map((m) => [`${modelNamespaceId(m, defaultNamespaceId)}:${m.modelName}`, m])),
173
+ tableNamespaceByName: new Map(models.map((m) => [m.tableName, modelNamespaceId(m, defaultNamespaceId)]))
174
+ };
175
+ }
176
+ function toOneNullabilityContradictionMessage(location, contradiction) {
177
+ return contradiction === "declared-optional" ? `${location} is optional but every local field it joins on is required` : `${location} is required but a local field it joins on is nullable`;
178
+ }
179
+ function toOneRelationNullable(semanticModel, relation) {
180
+ const location = `Relation "${semanticModel.modelName}.${relation.fieldName}"`;
181
+ if (relation.nullable === void 0) throw contractError("CONTRACT.RELATION_INVALID", `${location} with cardinality "${relation.cardinality}" must state whether it is nullable`, { meta: {
182
+ modelName: semanticModel.modelName,
183
+ relationName: relation.fieldName,
184
+ reason: "to-one-nullability-missing"
185
+ } });
186
+ const localColumns = relation.on.parentColumns;
187
+ const { contradiction } = resolveToOneRelationNullable({
188
+ declaredNullable: relation.nullable,
189
+ localFieldNullability: semanticModel.fields.filter((field) => localColumns.includes(field.columnName)).map((field) => field.nullable),
190
+ ownsReference: relation.cardinality === "N:1"
191
+ });
192
+ if (contradiction !== void 0) throw contractError("CONTRACT.RELATION_INVALID", relation.cardinality === "N:1" ? toOneNullabilityContradictionMessage(location, contradiction) : `${location} is required but does not own the foreign key, so nothing in storage guarantees the related row exists`, { meta: {
193
+ modelName: semanticModel.modelName,
194
+ relationName: relation.fieldName,
195
+ reason: "to-one-nullability-mismatch"
196
+ } });
197
+ return relation.nullable;
198
+ }
199
+ function buildThroughDescriptor(through, tableNamespaceByName, targetModel, modelName, fieldName, defaultNamespaceId) {
200
+ if (!tableNamespaceByName.has(through.table)) throw contractError("CONTRACT.MODEL_UNKNOWN", `buildSqlContractFromDefinition: junction table "${through.table}" for relation "${modelName}.${fieldName}" is not a declared model.`, { meta: {
201
+ sourceModel: modelName,
202
+ relationName: fieldName,
203
+ junctionTable: through.table
204
+ } });
205
+ const namespaceId = through.namespaceId ?? defaultNamespaceId;
206
+ return {
207
+ table: through.table,
208
+ namespaceId,
209
+ parentColumns: through.parentColumns,
210
+ childColumns: through.childColumns,
211
+ targetColumns: targetColumnsForJunction(targetModel, fieldName)
212
+ };
213
+ }
214
+ function targetColumnsForJunction(targetModel, fieldName) {
215
+ const primaryKeyColumns = targetModel.id?.columns;
216
+ if (primaryKeyColumns && primaryKeyColumns.length > 0) return primaryKeyColumns;
217
+ const firstUnique = targetModel.uniques?.find((u) => u.columns.length > 0);
218
+ if (firstUnique) return firstUnique.columns;
219
+ throw contractError("CONTRACT.IDENTITY_INVALID", `M:N target model "${targetModel.modelName}" (relation field "${fieldName}") has no primary id or unique key to derive junction targetColumns.`, { meta: {
220
+ modelName: targetModel.modelName,
221
+ reason: "no-key-for-junction-target-columns"
222
+ } });
223
+ }
224
+ /** The field of `model` that maps a relation's join column. A relation joins on fields, so a column no field maps is refused. */
225
+ function joinFieldOf(owner, relation, model, columnToField, column) {
226
+ const field = columnToField.get(column);
227
+ if (field !== void 0) return field;
228
+ throw contractError("CONTRACT.RELATION_INVALID", `Relation "${owner.modelName}.${relation.fieldName}" joins on column "${column}" of table "${model.tableName}", which no field of model "${model.modelName}" maps. A relation joins on fields; declare a field for the column.`, { meta: {
229
+ modelName: owner.modelName,
230
+ relationName: relation.fieldName,
231
+ column,
232
+ reason: "join-column-not-a-field"
233
+ } });
234
+ }
235
+ /** Lowers a model's relations. `columnToField` maps the model's columns to the fields that hold them. */
236
+ function lowerRelations(semanticModel, columnToField, lookups) {
237
+ const { defaultNamespaceId } = lookups;
238
+ const modelRelations = {};
239
+ for (const relation of semanticModel.relations ?? []) {
240
+ if (relation.spaceId !== void 0) {
241
+ const targetNamespaceId = relation.namespaceId ?? defaultNamespaceId;
242
+ const localFields = relation.on.parentColumns.map((col) => joinFieldOf(semanticModel, relation, semanticModel, columnToField, col));
243
+ modelRelations[relation.fieldName] = {
244
+ to: crossRef(relation.toModel, targetNamespaceId, relation.spaceId),
245
+ cardinality: "N:1",
246
+ nullable: toOneRelationNullable(semanticModel, relation),
247
+ on: {
248
+ localFields,
249
+ targetFields: relation.on.childColumns
250
+ }
251
+ };
252
+ continue;
253
+ }
254
+ const owner = {
255
+ kind: "model",
256
+ modelName: semanticModel.modelName
257
+ };
258
+ const targetModel = assertKnownTargetModel(lookups.modelsByName, lookups.modelsByCoordinate, owner, relation.toModel, relation.toNamespaceId, "Relation");
259
+ invariant(relation.toTable !== void 0, `Relation "${semanticModel.modelName}.${relation.fieldName}" is local but carries no target table; only cross-space relations may leave it unset.`);
260
+ assertTargetTableMatches(owner, targetModel, relation.toTable, "Relation");
261
+ const targetColumnToField = new Map(targetModel.fields.map((f) => [f.columnName, f.fieldName]));
262
+ const to = crossRef(relation.toModel, relation.toNamespaceId !== void 0 && relation.toNamespaceId.length > 0 ? relation.toNamespaceId : modelNamespaceId(targetModel, defaultNamespaceId));
263
+ const joinField = (model, fields, column) => joinFieldOf(semanticModel, relation, model, fields, column);
264
+ const on = {
265
+ localFields: relation.on.parentColumns.map((col) => joinField(semanticModel, columnToField, col)),
266
+ targetFields: relation.through !== void 0 ? [...relation.on.childColumns] : relation.on.childColumns.map((col) => joinField(targetModel, targetColumnToField, col))
267
+ };
268
+ if (relation.cardinality === "N:M") {
269
+ if (!relation.through) throw contractError("CONTRACT.RELATION_INVALID", `Relation "${semanticModel.modelName}.${relation.fieldName}" with cardinality "N:M" requires through metadata`, { meta: {
270
+ modelName: semanticModel.modelName,
271
+ relationName: relation.fieldName,
272
+ reason: "many-to-many-missing-through"
273
+ } });
274
+ modelRelations[relation.fieldName] = {
275
+ to,
276
+ cardinality: "N:M",
277
+ on,
278
+ through: buildThroughDescriptor(relation.through, lookups.tableNamespaceByName, targetModel, semanticModel.modelName, relation.fieldName, defaultNamespaceId)
279
+ };
280
+ } else if (relation.cardinality === "1:N") modelRelations[relation.fieldName] = {
281
+ to,
282
+ cardinality: "1:N",
283
+ on
284
+ };
285
+ else modelRelations[relation.fieldName] = {
286
+ to,
287
+ cardinality: relation.cardinality,
288
+ nullable: toOneRelationNullable(semanticModel, relation),
289
+ on
290
+ };
291
+ }
292
+ return modelRelations;
293
+ }
294
+ /** The key of a table among all tables of a contract: its namespace and its name. */
295
+ function tableKey(namespaceId, tableName) {
296
+ return JSON.stringify([namespaceId, tableName]);
297
+ }
298
+ /** Resolves a foreign key's target. A cross-space key keeps its foreign space; a local key names either a model of this definition and that model's table, or a table a model or table node declares. */
299
+ function resolveForeignKey(fk, sourceTable, context) {
300
+ const source = {
301
+ namespaceId: asNamespaceId(sourceTable.namespaceId),
302
+ tableName: sourceTable.tableName,
303
+ columns: fk.columns
304
+ };
305
+ const options = {
306
+ ...applyFkDefaults({
307
+ ...ifDefined("constraint", fk.constraint),
308
+ ...ifDefined("index", fk.index)
309
+ }, context.foreignKeyDefaults),
310
+ ...ifDefined("name", fk.name),
311
+ ...ifDefined("onDelete", fk.onDelete),
312
+ ...ifDefined("onUpdate", fk.onUpdate)
313
+ };
314
+ if (fk.references.spaceId !== void 0) return {
315
+ source,
316
+ target: {
317
+ namespaceId: asNamespaceId(fk.references.namespaceId ?? context.defaultNamespaceId),
318
+ tableName: fk.references.table,
319
+ columns: fk.references.columns,
320
+ spaceId: fk.references.spaceId
321
+ },
322
+ ...options
323
+ };
324
+ const { references } = fk;
325
+ if (references.model === void 0) {
326
+ const namespaceId = namespaceIdOrDefault(references.namespaceId, context.defaultNamespaceId);
327
+ if (!context.declaredTables.has(tableKey(namespaceId, references.table))) throw contractError("CONTRACT.TABLE_UNKNOWN", `Foreign key on ${referenceOwnerSubject(sourceTable.owner)} references table "${references.table}" in namespace "${namespaceId}", which no model or table node declares. Declare the table with a model or a table node, or correct the name.`, { meta: {
328
+ ...referenceOwnerMeta(sourceTable.owner),
329
+ referencedTable: references.table,
330
+ namespaceId
331
+ } });
332
+ return {
333
+ source,
334
+ target: {
335
+ namespaceId: asNamespaceId(namespaceId),
336
+ tableName: references.table,
337
+ columns: references.columns
338
+ },
339
+ ...options
340
+ };
341
+ }
342
+ const targetModel = assertKnownTargetModel(context.modelsByName, context.modelsByCoordinate, sourceTable.owner, references.model, fk.references.namespaceId, "Foreign key");
343
+ assertTargetTableMatches(sourceTable.owner, targetModel, fk.references.table, "Foreign key");
344
+ return {
345
+ source,
346
+ target: {
347
+ namespaceId: asNamespaceId(namespaceIdOrDefault(fk.references.namespaceId, modelNamespaceId(targetModel, context.defaultNamespaceId))),
348
+ tableName: fk.references.table,
349
+ columns: fk.references.columns
350
+ },
351
+ ...options
352
+ };
353
+ }
354
+ /**
355
+ * Resolves a deferred entity-ref column descriptor (e.g. a `pg.enum(handle)`
356
+ * column) against the field's now-known owning namespace: attaches the
357
+ * storage `valueSet` ref the collected entity's derived value-set is stored
358
+ * under. `typeParams.typeName` stays bare here — schema
359
+ * qualification (e.g. `auth.aal_level`) is a target concern applied in the
360
+ * next step, `qualifyColumnDescriptor`. A descriptor with no `entityRef` (the
361
+ * ordinary case) passes through unchanged.
362
+ */
363
+ function resolveEntityRefDescriptor(descriptor, namespaceId) {
364
+ const entityRef = descriptor.entityRef;
365
+ if (entityRef === void 0) return descriptor;
366
+ return {
367
+ ...descriptor,
368
+ valueSet: {
369
+ plane: "storage",
370
+ entityKind: "valueSet",
371
+ namespaceId,
372
+ entityName: entityRef.entityName
373
+ }
374
+ };
375
+ }
376
+ /**
377
+ * Structural check for a target that contributes a `qualifyColumnType` hook
378
+ * on its authoring contributions. Duck-typed (mirroring
379
+ * `contract-psl`'s `hasColumnFromEntityHook`) so the SQL family stays blind
380
+ * to the target's qualification logic and no framework/family interface has
381
+ * to name the hook.
382
+ */
383
+ function hasColumnTypeQualifier(authoring) {
384
+ return "qualifyColumnType" in authoring && typeof authoring.qualifyColumnType === "function";
385
+ }
386
+ /**
387
+ * Structural check for a target that contributes a `renderCheckExpressions`
388
+ * hook, duck-typed for the same reason {@link hasColumnTypeQualifier} is: the
389
+ * SQL family stays blind to the target's predicate syntax.
390
+ */
391
+ function hasCheckExpressionRenderer(authoring) {
392
+ return "renderCheckExpressions" in authoring && typeof authoring.renderCheckExpressions === "function";
393
+ }
394
+ function resolveCheckExpressionRenderer(target) {
395
+ const authoring = target.authoring;
396
+ if (authoring === void 0) return void 0;
397
+ return hasCheckExpressionRenderer(authoring) ? authoring.renderCheckExpressions : void 0;
398
+ }
399
+ function resolveColumnTypeQualifier(target) {
400
+ const authoring = target.authoring;
401
+ if (authoring === void 0) return void 0;
402
+ return hasColumnTypeQualifier(authoring) ? authoring.qualifyColumnType : void 0;
403
+ }
404
+ /**
405
+ * Applies the target's `qualifyColumnType` hook to a scalar column descriptor.
406
+ * A descriptor whose codec the target leaves unchanged passes through untouched.
407
+ */
408
+ function qualifyColumnDescriptor(descriptor, namespaceId, qualify) {
409
+ if (qualify === void 0) return descriptor;
410
+ const qualified = qualify({
411
+ codecId: descriptor.codecId,
412
+ ...ifDefined("typeParams", descriptor.typeParams)
413
+ }, namespaceId);
414
+ if (qualified.typeParams === descriptor.typeParams) return descriptor;
415
+ return {
416
+ ...descriptor,
417
+ ...ifDefined("typeParams", qualified.typeParams)
418
+ };
419
+ }
420
+ /**
421
+ * A column's descriptor as its namespace makes it: a deferred entity ref gets its storage value set, and the target's `qualifyColumnType` hook qualifies the type for the namespace.
422
+ */
423
+ function resolveColumnDescriptor(descriptor, namespaceId, qualify) {
424
+ const resolved = resolveEntityRefDescriptor(descriptor, namespaceId);
425
+ return qualifyColumnDescriptor(resolved, resolved.valueSet?.namespaceId ?? namespaceId, qualify);
426
+ }
427
+ /**
428
+ * Converts one model into the storage it implies and its domain model. Other models are read only to resolve the references this one makes to them.
429
+ */
430
+ function describeModel(model, context) {
431
+ const namespaceId = modelNamespaceId(model, context.defaultNamespaceId);
432
+ const { tableName } = model;
433
+ const fieldToColumn = {};
434
+ const domainFields = {};
435
+ const executionDefaults = [];
436
+ for (const field of model.fields) {
437
+ const executionDefault = executionDefaultOf(field);
438
+ fieldToColumn[field.fieldName] = field.columnName;
439
+ domainFields[field.fieldName] = buildDomainField(isValueObjectMember(field) ? field : {
440
+ ...field,
441
+ descriptor: resolveColumnDescriptor(field.descriptor, namespaceId, context.qualifyColumnType)
442
+ }, context.defaultNamespaceId);
443
+ if (executionDefault) executionDefaults.push({
444
+ ref: {
445
+ namespace: namespaceId,
446
+ entry: tableName,
447
+ field: field.columnName
448
+ },
449
+ ...ifDefined("onCreate", executionDefault.onCreate),
450
+ ...ifDefined("onUpdate", executionDefault.onUpdate)
451
+ });
452
+ }
453
+ const storage = describeModelStorage(model, namespaceId, (model.foreignKeys ?? []).map((fk) => resolveForeignKey(fk, {
454
+ namespaceId,
455
+ tableName: model.tableName,
456
+ owner: {
457
+ kind: "model",
458
+ modelName: model.modelName
459
+ }
460
+ }, context)));
461
+ const storageFields = {};
462
+ for (const [fieldName, columnName] of Object.entries(fieldToColumn)) storageFields[fieldName] = { column: columnName };
463
+ const columnToField = new Map(Object.entries(fieldToColumn).map(([field, col]) => [col, field]));
464
+ return {
465
+ storage,
466
+ domain: {
467
+ namespaceId,
468
+ modelName: model.modelName,
469
+ model: {
470
+ storage: {
471
+ table: tableName,
472
+ namespaceId,
473
+ fields: storageFields
474
+ },
475
+ fields: domainFields,
476
+ relations: lowerRelations(model, columnToField, context)
477
+ },
478
+ executionDefaults
479
+ }
480
+ };
481
+ }
482
+ /**
483
+ * Single-table-inheritance variants share their base model's table: the variant's columns must already be on that table, and it has no table of its own. That leaves an authored check nowhere to attach, so it is refused here as a backstop; the PSL surface refuses it earlier, at interpretation, with a diagnostic that names the base model.
484
+ */
485
+ function describeModelStorage(model, namespaceId, foreignKeys) {
486
+ const { tableName } = model;
487
+ const columns = model.fields.map((field) => describeFieldColumn(model.modelName, field));
488
+ if (model.sharesBaseTable) {
489
+ if (model.checks && model.checks.length > 0) throw contractError("CONTRACT.CHECK_ON_STI_VARIANT", `Model "${model.modelName}" declares a check constraint but shares its base model's storage table (single-table inheritance) and has no table of its own to declare it on. Declare the check on the base model instead.`, { meta: {
490
+ tableName,
491
+ modelName: model.modelName
492
+ } });
493
+ return {
494
+ kind: "baseTable",
495
+ modelName: model.modelName,
496
+ namespaceId,
497
+ tableName,
498
+ columns
499
+ };
500
+ }
501
+ return {
502
+ kind: "ownTable",
503
+ modelName: model.modelName,
504
+ table: {
505
+ namespaceId,
506
+ tableName,
507
+ columns,
508
+ control: model.control,
509
+ id: model.id,
510
+ uniques: model.uniques ?? [],
511
+ indexes: model.indexes ?? [],
512
+ checks: model.checks ?? [],
513
+ foreignKeys
514
+ }
515
+ };
516
+ }
517
+ function describeFieldColumn(modelName, field) {
518
+ const site = {
519
+ kind: "field",
520
+ modelName,
521
+ fieldName: field.fieldName
522
+ };
523
+ if (isValueObjectMember(field)) return describeColumn({
524
+ columnName: field.columnName,
525
+ descriptor: field.descriptor,
526
+ nullable: field.nullable,
527
+ ...ifDefined("default", field.default)
528
+ }, site);
529
+ return describeColumn(field, site);
530
+ }
531
+ function executionDefaultOf(field) {
532
+ return field.executionDefaults?.onCreate || field.executionDefaults?.onUpdate ? field.executionDefaults : void 0;
533
+ }
534
+ /** Describes a table node: its columns, and its foreign keys resolved against the definition's models and tables. */
535
+ function describeTableNode(table, context) {
536
+ const namespaceId = namespaceIdOrDefault(table.namespaceId, context.defaultNamespaceId);
537
+ const { tableName } = table;
538
+ const owner = {
539
+ kind: "tableNode",
540
+ namespaceId,
541
+ tableName
542
+ };
543
+ return {
544
+ namespaceId,
545
+ tableName,
546
+ columns: table.columns.map((column) => describeColumn(column, {
547
+ kind: "tableNode",
548
+ namespaceId,
549
+ tableName,
550
+ columnName: column.columnName
551
+ })),
552
+ id: table.id,
553
+ uniques: table.uniques ?? [],
554
+ indexes: table.indexes ?? [],
555
+ checks: table.checks ?? [],
556
+ foreignKeys: (table.foreignKeys ?? []).map((fk) => resolveForeignKey(fk, {
557
+ namespaceId,
558
+ tableName,
559
+ owner
560
+ }, context)),
561
+ control: table.control
562
+ };
563
+ }
564
+ /**
565
+ * The codec that encodes one column's default, built with the column's own `typeParams`, because a parameterized codec checks its params when it encodes and reads a default. Only a column has params; every other encode site takes the representative instance.
566
+ */
567
+ function columnCodec(codecId, typeParams, codecLookup) {
568
+ return codecForRef(codecLookup, {
569
+ codecId,
570
+ ...ifDefined("typeParams", typeParams === void 0 ? void 0 : blindCast(typeParams))
571
+ });
572
+ }
573
+ /** The JSON the contract stores for a value: the codec gives the value of its data type under the column's parameters, which the type refuses when they exclude it, and the codec reads it back, refusing a value its application value cannot hold. */
574
+ function encodeViaCodec(value, codec) {
575
+ if (codec) {
576
+ const stored = codec.toDataTypeValue(value);
577
+ codec.fromDataTypeValue(stored);
578
+ return codec.dataType.toContract(stored);
579
+ }
580
+ return blindCast(value);
581
+ }
582
+ function defaultRefusal(site, cause, elementPosition) {
583
+ const subject = elementPosition === void 0 ? "default" : `default (element ${elementPosition})`;
584
+ const reason = cause instanceof Error ? cause.message : String(cause);
585
+ return contractError("CONTRACT.DEFAULT_INVALID", `${columnSiteSubject(site)} has a ${subject} that its codec refuses: ${reason}`, {
586
+ cause,
587
+ meta: {
588
+ ...columnSiteMeta(site),
589
+ codecId: site.codecId,
590
+ reason: "codec-refused-default",
591
+ ...ifDefined("elementPosition", elementPosition)
592
+ }
593
+ });
594
+ }
595
+ /** The refusal of a literal default by a data type that has no literal values, such as a raw column's. */
596
+ function noLiteralValuesRefusal(site, cause) {
597
+ return contractError("CONTRACT.DEFAULT_INVALID", `${columnSiteSubject(site)} has a literal default. ${cause.message}`, {
598
+ cause,
599
+ meta: {
600
+ ...columnSiteMeta(site),
601
+ codecId: site.codecId,
602
+ reason: "no-literal-values"
603
+ }
604
+ });
605
+ }
606
+ function encodeDefaultValue(value, codec, site, elementPosition) {
607
+ try {
608
+ return encodeViaCodec(value, codec);
609
+ } catch (cause) {
610
+ if (cause instanceof InternalError) throw cause;
611
+ if (isStructuredError(cause) && cause.code === "CONTRACT.LITERAL_VALUES_ABSENT") throw noLiteralValuesRefusal(site, cause);
612
+ throw defaultRefusal(site, cause, elementPosition);
613
+ }
614
+ }
615
+ function codecForDefault(codecLookup, resolveCodec, site) {
616
+ const codec = buildCodecForDefault(codecLookup, resolveCodec, site);
617
+ if (codec === void 0) throw contractError("CONTRACT.DEFAULT_INVALID", `${columnSiteSubject(site)} has a default, but no pack in the contract declares its codec "${site.codecId}", so the default cannot be checked. List the pack that owns the codec in \`extensions\`.`, { meta: {
618
+ ...columnSiteMeta(site),
619
+ codecId: site.codecId,
620
+ reason: "codec-not-found"
621
+ } });
622
+ return codec;
623
+ }
624
+ function buildCodecForDefault(codecLookup, resolveCodec, site) {
625
+ try {
626
+ return resolveCodec(codecLookup);
627
+ } catch (cause) {
628
+ if (!isStructuredError(cause) || cause.code !== "RUNTIME.TYPE_PARAMS_INVALID") throw cause;
629
+ throw contractError("CONTRACT.ARGUMENT_INVALID", `${columnSiteSubject(site)} has type parameters that its codec does not accept: ${cause.message}`, {
630
+ cause,
631
+ meta: {
632
+ ...columnSiteMeta(site),
633
+ codecId: site.codecId,
634
+ reason: "type-params-invalid"
635
+ }
636
+ });
637
+ }
638
+ }
639
+ function encodeColumnDefault(defaultInput, codecLookup, resolveCodec, site, many = false, elementNullable = false) {
640
+ if (defaultInput.kind === "function") return {
641
+ kind: "function",
642
+ expression: defaultInput.expression
643
+ };
644
+ if ("inStoredForm" in defaultInput && defaultInput.inStoredForm === true) return {
645
+ kind: "literal",
646
+ value: blindCast(defaultInput.value)
647
+ };
648
+ if (many) {
649
+ if (!Array.isArray(defaultInput.value)) throw contractError("CONTRACT.DEFAULT_INVALID", `${columnSiteSubject(site)} is a list field, so its default is an array; received ${typeof defaultInput.value}. Call .many() before .default().`, { meta: {
650
+ ...columnSiteMeta(site),
651
+ codecId: site.codecId,
652
+ reason: "list-default-not-array"
653
+ } });
654
+ const codec = codecForDefault(codecLookup, resolveCodec, site);
655
+ return {
656
+ kind: "literal",
657
+ value: defaultInput.value.map((element, index) => {
658
+ if (element !== null) return encodeDefaultValue(element, codec, site, index + 1);
659
+ if (elementNullable) return null;
660
+ throw new InternalError("Literal default on a strict list column cannot contain null elements.");
661
+ })
662
+ };
663
+ }
664
+ return {
665
+ kind: "literal",
666
+ value: encodeDefaultValue(defaultInput.value, codecForDefault(codecLookup, resolveCodec, site), site)
667
+ };
668
+ }
669
+ /**
670
+ * Records a deferred column's entity-ref into the namespace-scoped collection
671
+ * accumulator (`namespaceId → entityKind → entityName`) — folded into the same
672
+ * namespace assembly `deriveEntityValueSets`/`entries.<kind>` step as the
673
+ * entities-channel attachments, so a column-collected entity gets its
674
+ * value-set the same way an entities-channel one does.
675
+ *
676
+ * The same handle reused by many columns in one namespace is normal (a native
677
+ * enum type backs any number of columns) and records the identical entity once.
678
+ * Two *different* entity instances sharing a name+kind in one namespace is a
679
+ * name collision — the emitted `entries.valueSet.<name>` could only reflect one
680
+ * of them, silently mismatching the other column's type/cast. PSL hard-errors
681
+ * on the equivalent (`PSL_DUPLICATE_DECLARATION`); the TS path rejects it too.
682
+ */
683
+ function collectEntityFromColumn(collected, namespaceId, entityRef) {
684
+ const forNs = collected[namespaceId] ?? {};
685
+ const forKind = forNs[entityRef.entityKind] ?? {};
686
+ const existing = forKind[entityRef.entityName];
687
+ if (existing !== void 0 && existing !== entityRef.entity) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: two different "${entityRef.entityKind}" entities named "${entityRef.entityName}" in namespace "${namespaceId}" — pack-entity names must be unique per namespace.`, { meta: {
688
+ kind: entityRef.entityKind,
689
+ name: entityRef.entityName,
690
+ namespaceId
691
+ } });
692
+ forKind[entityRef.entityName] = entityRef.entity;
693
+ forNs[entityRef.entityKind] = forKind;
694
+ collected[namespaceId] = forNs;
695
+ }
696
+ /**
697
+ * Merges a namespace's entities-channel attachments (lowered from the
698
+ * `entities` handle list, carried on `ContractDefinition.attachedEntities`)
699
+ * with the entities collected from that namespace's deferred entity-ref
700
+ * columns. A column-collected entity that shadows a *different* attached
701
+ * entity of the same kind+name (or vice-versa) is the same name-collision bug
702
+ * `collectEntityFromColumn` guards against across columns, so it is rejected
703
+ * the same way — by entity identity, so the same handle attached and used by
704
+ * a column does not throw.
705
+ */
706
+ function mergeColumnAndAttachedEntities(namespaceId, attached, columnCollected) {
707
+ if (attached === void 0) return columnCollected;
708
+ if (columnCollected === void 0) return attached;
709
+ const kinds = /* @__PURE__ */ new Set([...Object.keys(attached), ...Object.keys(columnCollected)]);
710
+ const result = {};
711
+ for (const kind of kinds) {
712
+ const attachedForKind = attached[kind];
713
+ const columnForKind = columnCollected[kind];
714
+ for (const [name, entity] of Object.entries(columnForKind ?? {})) {
715
+ const existing = attachedForKind?.[name];
716
+ if (existing !== void 0 && existing !== entity) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: two different "${kind}" entities named "${name}" in namespace "${namespaceId}" — a column-referenced entity conflicts with an attached one; pack-entity names must be unique per namespace.`, { meta: {
717
+ kind,
718
+ name,
719
+ namespaceId
720
+ } });
721
+ }
722
+ result[kind] = {
723
+ ...attachedForKind,
724
+ ...columnForKind
725
+ };
726
+ }
727
+ return result;
728
+ }
729
+ /**
730
+ * Entry kinds the framework assembler itself manages (`table` from models,
731
+ * `valueSet` from `enums` and attached-entity value-set derivation). A
732
+ * pack-attached entity claiming one of these would silently clobber or be
733
+ * clobbered by the managed slot, so it is rejected outright.
734
+ */
735
+ const MANAGED_ENTRY_KINDS = /* @__PURE__ */ new Set([tableEntityKind.kind, valueSetEntityKind.kind]);
736
+ function assertNoManagedEntityKinds(namespaceId, entitiesForNs) {
737
+ if (entitiesForNs === void 0) return;
738
+ for (const kind of Object.keys(entitiesForNs)) if (MANAGED_ENTRY_KINDS.has(kind)) throw contractError("CONTRACT.ENTITY_KIND_INVALID", `buildSqlContractFromDefinition: attached entity in namespace "${namespaceId}" declares entry kind "${kind}", which is managed by the framework (table/valueSet) and cannot be attached.`, { meta: {
739
+ entityKind: kind,
740
+ namespaceId
741
+ } });
742
+ }
743
+ /**
744
+ * Walks the flat `entityTypes` namespace tree contributed by the target pack
745
+ * and every extension pack, indexing descriptors by their `discriminator` —
746
+ * the same string a pack entity's entries-map key (`entries.<kind>`) uses.
747
+ * Mirrors `contract-psl`'s `buildEntityTypesByDiscriminator`, recomposed here
748
+ * from the packs `ContractDefinition` already carries (`target` +
749
+ * `extensions`) since the TS assembler has no single pre-merged
750
+ * `AuthoringContributions` input to read the way the PSL interpreter does.
751
+ */
752
+ function collectEntityTypeDescriptorsByDiscriminator(definition) {
753
+ const result = /* @__PURE__ */ new Map();
754
+ const walk = (namespace) => {
755
+ for (const value of Object.values(namespace)) if (isAuthoringEntityTypeDescriptor(value)) result.set(value.discriminator, value);
756
+ else walk(value);
757
+ };
758
+ const components = [definition.target, ...Object.values(definition.extensions ?? {})];
759
+ for (const component of components) {
760
+ const entityTypes = component.authoring?.entityTypes;
761
+ if (entityTypes !== void 0) walk(entityTypes);
762
+ }
763
+ return result;
764
+ }
765
+ /**
766
+ * Derives value-sets for every pack entity declared in one namespace,
767
+ * reusing the same `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook
768
+ * `contract-psl`'s `lowerExtensionBlocksForNamespace` folds into
769
+ * `entries.valueSet` on the PSL path — so a TS-attached entity (e.g. a
770
+ * native enum) gets its value-set the same way. Entity kinds with no
771
+ * registered descriptor, or whose descriptor output doesn't derive a
772
+ * value-set, contribute nothing.
773
+ */
774
+ function deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator) {
775
+ if (entitiesForNs === void 0) return void 0;
776
+ let result;
777
+ for (const [kind, entitiesByName] of Object.entries(entitiesForNs)) {
778
+ const descriptor = entityTypesByDiscriminator.get(kind);
779
+ if (descriptor === void 0) continue;
780
+ for (const [name, entity] of Object.entries(entitiesByName)) {
781
+ const derivedValueSet = deriveValueSetFromEntity(descriptor.output, entity);
782
+ if (derivedValueSet === void 0) continue;
783
+ result ??= {};
784
+ result[name] = derivedValueSet;
785
+ }
786
+ }
787
+ return result;
788
+ }
789
+ /**
790
+ * Merges a namespace's `enumType()`-derived value-sets with its pack-entity-
791
+ * derived value-sets. Both land in the same `entries.valueSet[name]` slot —
792
+ * which drives value-set → codec typing and the domain-enum CHECK — so a
793
+ * same-named entry in both would let one silently overwrite the other and
794
+ * corrupt whichever column resolves against it. The same collision class the
795
+ * `mergeColumnAndAttachedEntities` guard rejects; the PSL path already hard-errors
796
+ * on the equivalent (`interpretPslDocumentToSqlContract`). Reject it here too.
797
+ */
798
+ function mergeNamespaceValueSets(namespaceId, enumValueSets, packValueSets) {
799
+ if (enumValueSets !== void 0 && packValueSets !== void 0) {
800
+ for (const name of Object.keys(packValueSets)) if (Object.hasOwn(enumValueSets, name)) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: value-set "${name}" in namespace "${namespaceId}" is derived from both an enum and a pack entity — names must be unique per namespace.`, { meta: {
801
+ kind: "valueSet",
802
+ name,
803
+ namespaceId
804
+ } });
805
+ }
806
+ return {
807
+ ...enumValueSets,
808
+ ...packValueSets
809
+ };
810
+ }
811
+ /**
812
+ * Names the target's rendered checks and lowers them into contract entities.
813
+ *
814
+ * Naming is composed family-side ({@link composeCheckWirePrefix}) rather than
815
+ * by the target, and suffixed with the predicate's content hash. Composing
816
+ * family-side is what makes the truncation safe — two prefixes that truncate
817
+ * alike still differ in their hashes, and the family can see that the
818
+ * (table, column, kind) triple they were built from is unique per table,
819
+ * rather than having to assume something about SQL text it declares itself
820
+ * unable to read.
821
+ */
822
+ function lowerRenderedChecks(tableName, candidates) {
823
+ return candidates.map((candidate) => new CheckConstraint({
824
+ naming: {
825
+ kind: "wire",
826
+ prefix: composeCheckWirePrefix(tableName, candidate.columnName, candidate.kind),
827
+ hash: computeCheckContentHash(candidate.expression)
828
+ },
829
+ expression: candidate.expression
830
+ }));
831
+ }
832
+ function validateColumnTypeParams(dataType, typeParams, site) {
833
+ try {
834
+ validateSqlTypeParams(dataType, dataTypeParams(dataType, typeParams));
835
+ } catch (cause) {
836
+ if (!isStructuredError(cause) || cause.code !== "CONTRACT.TYPE_PARAMS_INVALID") throw cause;
837
+ throw contractError("CONTRACT.TYPE_PARAMS_INVALID", `${columnSiteSubject(site)} has type parameters that its data type does not accept: ${cause.message}`, {
838
+ cause,
839
+ meta: {
840
+ ...cause.meta,
841
+ ...columnSiteMeta(site)
842
+ }
843
+ });
844
+ }
845
+ }
846
+ /**
847
+ * Lowers one column into its storage column and the enforcement checks its shape derives.
848
+ *
849
+ * A column whose type constructor refers to a pack entity (e.g. `pg.enum(handle)`) records that entity, and its descriptor is resolved against the column's namespace and handed to the target's `qualifyColumnType` hook. An opt-out from derived checks on a table that derives none is dropped, never persisted: the policy may also be stamped after the build by a specifier.
850
+ *
851
+ * Member values reach the check renderer only for a column typed by an `enumType()` handle: that column is a plain scalar with no native type of its own to enforce membership. A value set resolved by a type constructor binds the column to a native type that already enforces it.
852
+ */
853
+ function lowerColumn(description, placement, context) {
854
+ const { site, many } = description;
855
+ const { codecLookup } = context.lookups;
856
+ const entityRef = description.descriptor.entityRef;
857
+ if (entityRef !== void 0) collectEntityFromColumn(context.collectedColumnEntities, placement.namespaceId, entityRef);
858
+ const descriptor = resolveColumnDescriptor(description.descriptor, placement.namespaceId, context.qualifyColumnType);
859
+ const elementNullable = many !== false && many.elementNullable;
860
+ const codecId = descriptor.codecId;
861
+ const typeParams = nonEmptyTypeParams(descriptor.typeParams);
862
+ const dataType = sqlDataTypeOfCodec(codecId, context.lookups);
863
+ validateColumnTypeParams(dataType, typeParams, site);
864
+ const encodedDefault = description.default !== void 0 ? encodeColumnDefault(description.default, codecLookup, (lookup) => columnCodec(codecId, typeParams, lookup), {
865
+ ...site,
866
+ codecId
867
+ }, many !== false, elementNullable) : void 0;
868
+ const enumRefs = enumValueSetRefs(description.enumTypeHandle, context.defaultNamespaceId);
869
+ invariant(enumRefs === void 0 || descriptor.valueSet === void 0, `${columnSiteSubject(site)} is typed by a domain enum and also carries a storage value set from its type constructor.`);
870
+ const valueSet = enumRefs?.storage ?? descriptor.valueSet;
871
+ const column = {
872
+ dataType: dataType.id,
873
+ codecId,
874
+ nullable: description.nullable,
875
+ many,
876
+ ...ifDefined("typeParams", descriptor.typeParams),
877
+ ...ifDefined("default", encodedDefault),
878
+ ...ifDefined("valueSet", valueSet)
879
+ };
880
+ const render = context.renderCheckExpressions;
881
+ if (render === void 0 || !placement.derivesChecks) return {
882
+ column,
883
+ derivedChecks: []
884
+ };
885
+ const { enumTypeHandle } = description;
886
+ const candidates = render({
887
+ tableName: placement.tableName,
888
+ columnName: description.columnName,
889
+ many: many !== false,
890
+ elementNullable,
891
+ memberValues: enumTypeHandle !== void 0 ? checkMemberValues(enumTypeHandle, codecLookup) : void 0
892
+ });
893
+ return {
894
+ column,
895
+ derivedChecks: lowerRenderedChecks(placement.tableName, candidates)
896
+ };
897
+ }
898
+ const DERIVABLE_CHECK_KINDS = ["membership", "elementNotNull"];
899
+ /**
900
+ * Which of `columnNames` could have produced `prefix` for some
901
+ * {@link CheckKind} — the reverse of {@link derivedCheckPrefixes}, used only
902
+ * to name the collision in `CONTRACT.CHECK_NAME_RESERVED`'s message. Callers
903
+ * already know `prefix` is a member of `derivedCheckPrefixes(tableName,
904
+ * columnNames)`, so the result is never empty.
905
+ */
906
+ function columnsProducingCheckPrefix(tableName, columnNames, prefix) {
907
+ return columnNames.filter((columnName) => DERIVABLE_CHECK_KINDS.some((kind) => composeCheckWirePrefix(tableName, columnName, kind) === prefix));
908
+ }
909
+ /**
910
+ * Lowers one table: each of its columns, then its indexes, checks, primary key, uniques and foreign keys, with the backing indexes its foreign keys need.
911
+ *
912
+ * Checks are derived only for tables Prisma 8 owns: the contract describes an external schema, it does not prescribe enforcement for it. This reads the policy the source declares; a policy applied by a contract specifier lands after the build and is handled by `stripDerivedChecksFromNonManagedTables`. Authored checks are kept whatever the policy: they are the author's statement about a constraint they know exists.
913
+ */
914
+ function lowerTable(table, context) {
915
+ const { tableName } = table;
916
+ const derivesChecks = effectiveControlPolicy(table.control, context.defaultControlPolicy) === "managed";
917
+ const placement = {
918
+ namespaceId: table.namespaceId,
919
+ tableName,
920
+ derivesChecks
921
+ };
922
+ const columns = {};
923
+ const checks = [];
924
+ for (const description of table.columns) {
925
+ const lowered = lowerColumn(description, placement, context);
926
+ columns[description.columnName] = lowered.column;
927
+ checks.push(...lowered.derivedChecks);
928
+ }
929
+ const uniques = table.uniques.map((u) => ({
930
+ columns: u.columns,
931
+ ...ifDefined("name", u.name)
932
+ }));
933
+ const declaredIndexes = table.indexes.map((index) => ({
934
+ namedByUser: index.name !== void 0 || index.map !== void 0,
935
+ index: lowerAuthoredIndex(tableName, authoredIndexInput(index), context.warnings, context.indexTypeRegistry)
936
+ }));
937
+ checks.push(...lowerAuthoredChecks(tableName, Object.keys(columns), table.checks, context));
938
+ const primaryKey = table.id ? {
939
+ columns: table.id.columns,
940
+ ...ifDefined("name", table.id.name)
941
+ } : void 0;
942
+ const { foreignKeys, indexes } = materializeForeignKeysAndIndexes({
943
+ tableName,
944
+ foreignKeys: table.foreignKeys,
945
+ declaredIndexes,
946
+ uniques,
947
+ primaryKey,
948
+ warnings: context.warnings,
949
+ indexTypes: context.indexTypeRegistry
950
+ });
951
+ return {
952
+ columns,
953
+ ...ifDefined("control", table.control),
954
+ uniques,
955
+ indexes: indexes.map((i) => new Index(i)),
956
+ foreignKeys,
957
+ ...primaryKey ? { primaryKey } : {},
958
+ ...checks.length > 0 ? { checks: inCanonicalOrder(checks) } : {}
959
+ };
960
+ }
961
+ /**
962
+ * The checks sorted by name in UTF-16 code-unit order, the order contract canonicalization gives them. The table's storage is then the same whichever declaration each column came from and in whatever order the columns were listed.
963
+ */
964
+ function inCanonicalOrder(checks) {
965
+ return [...checks].sort((a, b) => compareCodeUnits(a.name, b.name));
966
+ }
967
+ function authoredIndexInput(index) {
968
+ return blindCast({
969
+ ...ifDefined("columns", index.columns),
970
+ ...ifDefined("expression", index.expression),
971
+ where: index.where,
972
+ unique: index.unique,
973
+ map: index.map,
974
+ name: index.name,
975
+ type: index.type,
976
+ options: index.options
977
+ });
978
+ }
979
+ /** Names the authored checks, and refuses one whose name could be taken for a derived check of a column of this table. */
980
+ function lowerAuthoredChecks(tableName, tableColumnNames, authoredChecks, context) {
981
+ if (authoredChecks.length === 0) return [];
982
+ const reservedCheckPrefixes = derivedCheckPrefixes(tableName, tableColumnNames);
983
+ return authoredChecks.map((authoredCheck) => {
984
+ const lowered = lowerAuthoredCheck(tableName, authoredCheck, context.warnings);
985
+ if (lowered.naming.kind === "wire" && reservedCheckPrefixes.has(lowered.naming.prefix)) {
986
+ const collidingColumns = columnsProducingCheckPrefix(tableName, tableColumnNames, lowered.naming.prefix);
987
+ const columnList = collidingColumns.map((name) => `"${name}"`).join(", ");
988
+ throw contractError("CONTRACT.CHECK_NAME_RESERVED", `Check "${lowered.naming.prefix}" on table "${tableName}": this name's prefix matches the shape a derived enforcement check would use for column${collidingColumns.length === 1 ? "" : "s"} ${columnList} of this table, so it can't be told apart from one. Choose a different name.`, { meta: {
989
+ tableName,
990
+ prefix: lowered.naming.prefix,
991
+ collidingColumns
992
+ } });
993
+ }
994
+ return new CheckConstraint(lowered);
995
+ });
996
+ }
997
+ /** How a refusal names each table-level property. Typed by every key of {@link TableProperties}, so a new property cannot be left out of the check. */
998
+ const tablePropertyLabels = {
999
+ id: "a primary key",
1000
+ uniques: "unique constraints",
1001
+ indexes: "indexes",
1002
+ checks: "check constraints",
1003
+ foreignKeys: "foreign keys",
1004
+ control: "a control policy"
1005
+ };
1006
+ function isTableProperty(key) {
1007
+ return Object.hasOwn(tablePropertyLabels, key);
1008
+ }
1009
+ /**
1010
+ * Collects the tables the models and table nodes describe, one per namespace and table name: the models' tables in model order, then the tables only table nodes declare.
1011
+ *
1012
+ * A table node for a table a model maps adds its columns to that table and nothing else, because the model owns the table's table-level properties. A table node for any other table is the whole table. A single-table variant adds nothing: each of its columns must already be on its base's table, which the base owns, and no table node may declare a column a variant's field maps. A variant whose table no model owns is not checked.
1013
+ *
1014
+ * Every table comes out with its foreign keys from exactly one declaration, a model or a table node, in the order that declaration lists them.
1015
+ */
1016
+ function mergeTables(storages, tableNodes) {
1017
+ const tables = /* @__PURE__ */ new Map();
1018
+ const modelOfTable = /* @__PURE__ */ new Map();
1019
+ for (const storage of storages) {
1020
+ if (storage.kind !== "ownTable") continue;
1021
+ const { table } = storage;
1022
+ const key = tableKey(table.namespaceId, table.tableName);
1023
+ if (tables.has(key)) throw contractError("CONTRACT.NAME_DUPLICATE", `buildSqlContractFromDefinition: duplicate table "${table.tableName}" in namespace "${table.namespaceId}".`, { meta: {
1024
+ kind: "table",
1025
+ name: table.tableName,
1026
+ namespaceId: table.namespaceId
1027
+ } });
1028
+ tables.set(key, table);
1029
+ modelOfTable.set(key, storage.modelName);
1030
+ }
1031
+ const variants = storages.filter((storage) => storage.kind === "baseTable");
1032
+ const variantColumnSites = variantColumnSitesByTable(variants);
1033
+ const tableNodeKeys = /* @__PURE__ */ new Set();
1034
+ for (const tableNode of tableNodes) {
1035
+ const key = tableKey(tableNode.namespaceId, tableNode.tableName);
1036
+ if (tableNodeKeys.has(key)) throw contractError("CONTRACT.NAME_DUPLICATE", `Table "${tableNode.tableName}" in namespace "${tableNode.namespaceId}" is declared by two table nodes.`, { meta: {
1037
+ kind: "table",
1038
+ name: tableNode.tableName,
1039
+ namespaceId: tableNode.namespaceId
1040
+ } });
1041
+ tableNodeKeys.add(key);
1042
+ const columnSites = variantColumnSites.get(key) ?? /* @__PURE__ */ new Map();
1043
+ const modelName = modelOfTable.get(key);
1044
+ const modelled = tables.get(key);
1045
+ if (modelName === void 0 || modelled === void 0) {
1046
+ tables.set(key, {
1047
+ ...tableNode,
1048
+ columns: withColumns([], tableNode, columnSites)
1049
+ });
1050
+ continue;
1051
+ }
1052
+ assertOnlyColumns(tableNode, modelName);
1053
+ tables.set(key, {
1054
+ ...modelled,
1055
+ columns: withColumns(modelled.columns, tableNode, columnSites)
1056
+ });
1057
+ }
1058
+ for (const variant of variants) {
1059
+ const table = tables.get(tableKey(variant.namespaceId, variant.tableName));
1060
+ if (table !== void 0) assertVariantColumnsOnBaseTable(variant, table);
1061
+ }
1062
+ return [...tables.values()];
1063
+ }
1064
+ /** For each table, the variant field that maps each variant column; the first variant to map a column names it. */
1065
+ function variantColumnSitesByTable(variants) {
1066
+ const sites = /* @__PURE__ */ new Map();
1067
+ for (const variant of variants) {
1068
+ const key = tableKey(variant.namespaceId, variant.tableName);
1069
+ const byColumn = sites.get(key) ?? /* @__PURE__ */ new Map();
1070
+ for (const column of variant.columns) if (!byColumn.has(column.columnName)) byColumn.set(column.columnName, column.site);
1071
+ sites.set(key, byColumn);
1072
+ }
1073
+ return sites;
1074
+ }
1075
+ /**
1076
+ * The table's columns with the table node's columns added. A column some field already declares is refused, and the error names the field the author wrote: a single-table variant's field when a variant maps the column, even though the base table carries a copy of it.
1077
+ */
1078
+ function withColumns(columns, tableNode, variantColumnSites) {
1079
+ const sites = new Map(columns.map((column) => [column.columnName, column.site]));
1080
+ for (const column of tableNode.columns) {
1081
+ const earlier = variantColumnSites.get(column.columnName) ?? sites.get(column.columnName);
1082
+ if (earlier !== void 0) {
1083
+ const problem = earlier.kind === "field" ? `is declared by field "${earlier.modelName}.${earlier.fieldName}" and again by a table node` : "is listed twice by its table node";
1084
+ throw contractError("CONTRACT.NAME_DUPLICATE", `Column "${column.columnName}" of table "${tableNode.tableName}" ${problem}.`, { meta: {
1085
+ kind: "column",
1086
+ name: column.columnName,
1087
+ tableName: tableNode.tableName,
1088
+ namespaceId: tableNode.namespaceId
1089
+ } });
1090
+ }
1091
+ sites.set(column.columnName, column.site);
1092
+ }
1093
+ return [...columns, ...tableNode.columns];
1094
+ }
1095
+ function isStated(value) {
1096
+ return Array.isArray(value) ? value.length > 0 : value !== void 0;
1097
+ }
1098
+ function assertOnlyColumns(tableNode, modelName) {
1099
+ const property = Object.keys(tablePropertyLabels).filter(isTableProperty).find((name) => isStated(tableNode[name]));
1100
+ if (property === void 0) return;
1101
+ throw contractError("CONTRACT.TABLE_OWNED_BY_MODEL", `A table node for table "${tableNode.tableName}" states ${tablePropertyLabels[property]}, but model "${modelName}" maps that table and owns its table-level properties. A table node for a modelled table may only add columns.`, { meta: {
1102
+ namespaceId: tableNode.namespaceId,
1103
+ tableName: tableNode.tableName,
1104
+ modelName,
1105
+ property
1106
+ } });
1107
+ }
1108
+ function assertVariantColumnsOnBaseTable(variant, table) {
1109
+ const present = new Set(table.columns.map((column) => column.columnName));
1110
+ const missing = variant.columns.find((column) => !present.has(column.columnName));
1111
+ if (missing === void 0) return;
1112
+ throw contractError("CONTRACT.VARIANT_COLUMN_NOT_ON_BASE_TABLE", `Model "${variant.modelName}" shares table "${variant.tableName}" with its base model (single-table inheritance), but its column "${missing.columnName}" is not on that table. The base model owns the table; declare the column there.`, { meta: {
1113
+ modelName: variant.modelName,
1114
+ namespaceId: variant.namespaceId,
1115
+ tableName: variant.tableName,
1116
+ columnName: missing.columnName
1117
+ } });
1118
+ }
1119
+ /** A definition's `types` key used to declare type aliases; it is refused so an old definition does not silently lose its aliases. */
1120
+ function refuseTypesKey(definition, subject) {
1121
+ if (!Object.hasOwn(definition, "types")) return;
1122
+ const types = Reflect.get(definition, "types");
1123
+ throw contractError("CONTRACT.TYPES_KEY_REMOVED", `${subject} no longer takes a "types" key. Write a type alias as a constant, such as const Slug = field.column(type.VarChar(64)), and use it as a field. Register a database type of a contract space under "databaseTypes".`, { meta: { keys: typeof types === "object" && types !== null ? Object.keys(types) : [] } });
1124
+ }
1125
+ /**
1126
+ * A warning for each column a table node adds to a table some model maps, when the column is required and has no default. The ORM writes only the columns fields map, so every insert it makes into that table fails. Prisma 7 accepts such a schema, so this warns rather than refuses.
1127
+ */
1128
+ function requiredUnmappedColumnWarnings(storages, tables) {
1129
+ const modelOfTable = /* @__PURE__ */ new Map();
1130
+ for (const storage of storages) if (storage.kind === "ownTable") modelOfTable.set(tableKey(storage.table.namespaceId, storage.table.tableName), storage.modelName);
1131
+ const warnings = [];
1132
+ for (const table of tables) {
1133
+ const modelName = modelOfTable.get(tableKey(table.namespaceId, table.tableName));
1134
+ if (modelName === void 0) continue;
1135
+ for (const column of table.columns) {
1136
+ if (column.site.kind !== "tableNode" || column.nullable || column.default !== void 0) continue;
1137
+ warnings.push({
1138
+ code: "PN_COLUMN_REQUIRED_UNMAPPED",
1139
+ message: `Column "${column.columnName}" of table "${table.tableName}" is required and has no default, and no field of model "${modelName}" maps it, so every insert the ORM makes into the table fails. Make the column nullable, give it a database default, or map it with a field.`,
1140
+ item: `table "${table.tableName}": column "${column.columnName}"`,
1141
+ summary: "columns are required, have no default, and no field maps them, so every insert the ORM makes into their tables fails. Make each column nullable, give it a database default, or map it with a field."
1142
+ });
1143
+ }
1144
+ }
1145
+ return warnings;
1146
+ }
1147
+ function assertStorageSemantics(contract, indexTypeRegistry, codecLookup) {
1148
+ const semanticErrors = validateStorageSemantics(contract.storage);
1149
+ if (semanticErrors.length > 0) throw contractError("CONTRACT.VALIDATION_FAILED", `Contract semantic validation failed: ${semanticErrors.join("; ")}`, { meta: { errors: semanticErrors } });
1150
+ validateIndexTypes(contract, indexTypeRegistry, (codecId) => codecLookup.descriptorFor(codecId)?.traits);
1151
+ }
1152
+ function collectStorageNamespaceCoordinateIds(definition) {
1153
+ const defaultNamespaceId = definition.target.defaultNamespaceId;
1154
+ const declared = [
1155
+ ...definition.namespaces ?? [],
1156
+ ...definition.models.map((model) => model.namespaceId),
1157
+ ...(definition.tables ?? []).map((table) => table.namespaceId),
1158
+ ...Object.keys(definition.attachedEntities ?? {})
1159
+ ];
1160
+ return /* @__PURE__ */ new Set([defaultNamespaceId, ...declared.map((id) => namespaceIdOrDefault(id, defaultNamespaceId))]);
1161
+ }
1162
+ function ensureUnboundNamespaceSlot(namespaces, createNamespace) {
1163
+ if (Object.hasOwn(namespaces, UNBOUND_NAMESPACE_ID)) return namespaces;
1164
+ const unbound = createNamespace({
1165
+ id: UNBOUND_NAMESPACE_ID,
1166
+ entries: { table: {} }
1167
+ });
1168
+ return {
1169
+ [UNBOUND_NAMESPACE_ID]: unbound,
1170
+ ...namespaces
1171
+ };
1172
+ }
1173
+ function declaredTableKeys(definition) {
1174
+ const defaultNamespaceId = definition.target.defaultNamespaceId;
1175
+ return /* @__PURE__ */ new Set([...definition.models.map((model) => tableKey(modelNamespaceId(model, defaultNamespaceId), model.tableName)), ...(definition.tables ?? []).map((table) => tableKey(namespaceIdOrDefault(table.namespaceId, defaultNamespaceId), table.tableName))]);
1176
+ }
1177
+ /**
1178
+ * Builds the contract in two stages. First each model is converted on its own into the table it describes and its domain model, and each table node into the table it describes. Then the tables are merged, each is lowered, and the contract is assembled.
1179
+ */
1180
+ function enabledCapabilities(matrix) {
1181
+ const enabled = {};
1182
+ for (const [namespace, flags] of Object.entries(matrix)) {
1183
+ const enabledFlags = Object.fromEntries(Object.entries(flags).filter(([, flag]) => flag).map(([name]) => [name, true]));
1184
+ if (Object.keys(enabledFlags).length > 0) enabled[namespace] = enabledFlags;
1185
+ }
1186
+ return enabled;
1187
+ }
1188
+ function buildSqlContractFromDefinition(definition, codecLookup, dataTypeLookup) {
1189
+ refuseTypesKey(definition, "buildSqlContractFromDefinition");
1190
+ const lookups = {
1191
+ codecLookup,
1192
+ dataTypeLookup
1193
+ };
1194
+ const target = definition.target.targetId;
1195
+ const defaultNamespaceId = definition.target.defaultNamespaceId;
1196
+ const indexTypeRegistry = indexTypeRegistryOf(definition.target, Object.values(definition.extensions ?? {}));
1197
+ const qualifyColumnType = resolveColumnTypeQualifier(definition.target);
1198
+ const databaseTypes = definition.databaseTypes ?? {};
1199
+ const targetFamily = "sql";
1200
+ const domainEnumsByNs = {};
1201
+ const storageValueSetsByNs = {};
1202
+ for (const [enumName, handle] of Object.entries(definition.enums ?? {})) {
1203
+ if (enumName !== handle.enumName) throw contractError("CONTRACT.ENUM_INVALID", `enum declaration key "${enumName}" must match enumType name "${handle.enumName}". Aliases are not supported.`, { meta: {
1204
+ enumName: handle.enumName,
1205
+ declarationKey: enumName,
1206
+ reason: "key-name-mismatch"
1207
+ } });
1208
+ const nsId = defaultNamespaceId;
1209
+ let domainSlot = domainEnumsByNs[nsId];
1210
+ if (domainSlot === void 0) {
1211
+ domainSlot = {};
1212
+ domainEnumsByNs[nsId] = domainSlot;
1213
+ }
1214
+ const storedMembers = encodeEnumTypeMembers(handle, codecLookup, "the column");
1215
+ domainSlot[enumName] = {
1216
+ codecId: handle.codecId,
1217
+ members: storedMembers
1218
+ };
1219
+ let storageSlot = storageValueSetsByNs[nsId];
1220
+ if (storageSlot === void 0) {
1221
+ storageSlot = {};
1222
+ storageValueSetsByNs[nsId] = storageSlot;
1223
+ }
1224
+ storageSlot[enumName] = {
1225
+ kind: "valueSet",
1226
+ values: storedMembers.map((member) => member.value)
1227
+ };
1228
+ }
1229
+ const modelDescriptionContext = {
1230
+ ...modelLookupsOf(definition),
1231
+ declaredTables: declaredTableKeys(definition),
1232
+ foreignKeyDefaults: definition.foreignKeyDefaults,
1233
+ qualifyColumnType
1234
+ };
1235
+ const components = definition.models.map((model) => describeModel(model, modelDescriptionContext));
1236
+ const tableNodes = (definition.tables ?? []).map((table) => describeTableNode(table, modelDescriptionContext));
1237
+ const authoringWarnings = [...definition.warnings ?? []];
1238
+ const collectedColumnEntities = {};
1239
+ const tableLoweringContext = {
1240
+ lookups,
1241
+ defaultNamespaceId,
1242
+ qualifyColumnType,
1243
+ renderCheckExpressions: resolveCheckExpressionRenderer(definition.target),
1244
+ collectedColumnEntities,
1245
+ defaultControlPolicy: definition.defaultControlPolicy,
1246
+ indexTypeRegistry,
1247
+ warnings: authoringWarnings
1248
+ };
1249
+ const tablesByNamespace = {};
1250
+ const modelStorages = components.map((c) => c.storage);
1251
+ const tables = mergeTables(modelStorages, tableNodes);
1252
+ authoringWarnings.push(...requiredUnmappedColumnWarnings(modelStorages, tables));
1253
+ for (const table of tables) {
1254
+ const namespaceTables = tablesByNamespace[table.namespaceId] ?? {};
1255
+ namespaceTables[table.tableName] = lowerTable(table, tableLoweringContext);
1256
+ tablesByNamespace[table.namespaceId] = namespaceTables;
1257
+ }
1258
+ const executionDefaults = components.flatMap((c) => c.domain.executionDefaults);
1259
+ const modelsByNamespace = {};
1260
+ for (const { domain } of components) {
1261
+ const namespaceModels = modelsByNamespace[domain.namespaceId] ?? {};
1262
+ namespaceModels[domain.modelName] = domain.model;
1263
+ modelsByNamespace[domain.namespaceId] = namespaceModels;
1264
+ }
1265
+ const roots = buildRoots(components);
1266
+ const documentTypes = Object.fromEntries(Object.entries(databaseTypes).map(([name, entry]) => [name, toStorageTypeInstance({
1267
+ codecId: entry.codecId,
1268
+ dataType: sqlDataTypeOfCodec(entry.codecId, lookups).id,
1269
+ typeParams: entry.typeParams
1270
+ })]));
1271
+ const namespaceCoordinateIds = collectStorageNamespaceCoordinateIds(definition);
1272
+ const { createNamespace } = definition;
1273
+ const entityTypesByDiscriminator = collectEntityTypeDescriptorsByDiscriminator(definition);
1274
+ const namespaces = Object.fromEntries([...namespaceCoordinateIds].sort().map((id) => {
1275
+ const entitiesForNs = mergeColumnAndAttachedEntities(id, definition.attachedEntities?.[id], collectedColumnEntities[id]);
1276
+ assertNoManagedEntityKinds(id, entitiesForNs);
1277
+ const enumValueSetEntries = storageValueSetsByNs[id];
1278
+ const packValueSetEntries = deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator);
1279
+ const valueSetEntries = enumValueSetEntries !== void 0 || packValueSetEntries !== void 0 ? mergeNamespaceValueSets(id, enumValueSetEntries, packValueSetEntries) : void 0;
1280
+ const nsInput = {
1281
+ id,
1282
+ entries: {
1283
+ table: tablesByNamespace[id] ?? {},
1284
+ ...entitiesForNs,
1285
+ ...valueSetEntries !== void 0 && Object.keys(valueSetEntries).length > 0 ? { valueSet: valueSetEntries } : {}
1286
+ }
1287
+ };
1288
+ return [id, createNamespace(nsInput)];
1289
+ }));
1290
+ const storageWithoutHash = {
1291
+ ...Object.keys(documentTypes).length > 0 ? { types: documentTypes } : {},
1292
+ namespaces: defaultNamespaceId === UNBOUND_NAMESPACE_ID ? ensureUnboundNamespaceSlot(namespaces, createNamespace) : namespaces
1293
+ };
1294
+ const storageHash = definition.storageHash ? coreHash(definition.storageHash) : computeStorageHash({
1295
+ target,
1296
+ targetFamily,
1297
+ storage: blindCast(storageWithoutHash),
1298
+ ...sqlContractCanonicalizationHooks
1299
+ });
1300
+ const storage = new SqlStorage({
1301
+ ...storageWithoutHash,
1302
+ storageHash
1303
+ });
1304
+ const extensionNamespaces = definition.extensions ? Object.values(definition.extensions).map((pack) => pack.id) : void 0;
1305
+ const extensions = { ...definition.extensions || {} };
1306
+ if (extensionNamespaces) {
1307
+ for (const namespace of extensionNamespaces) if (!Object.hasOwn(extensions, namespace)) extensions[namespace] = {};
1308
+ }
1309
+ const capabilities = enabledCapabilities(mergeCapabilityMatrices({}, [
1310
+ definition.target,
1311
+ ...definition.capabilities ? [{ capabilities: definition.capabilities }] : [],
1312
+ ...Object.values(definition.extensions ?? {})
1313
+ ]));
1314
+ const profileHash = computeProfileHash({
1315
+ target,
1316
+ targetFamily,
1317
+ capabilities: {}
1318
+ });
1319
+ const executionWithHash = buildExecutionSection({
1320
+ target,
1321
+ targetFamily,
1322
+ defaults: executionDefaults
1323
+ });
1324
+ const valueObjects = definition.valueObjects && definition.valueObjects.length > 0 ? Object.fromEntries(definition.valueObjects.map((vo) => [vo.name, { fields: Object.fromEntries(vo.fields.map((f) => [f.fieldName, buildDomainField(f, defaultNamespaceId)])) }])) : void 0;
1325
+ const domainNamespaceIds = new Set(Object.keys(modelsByNamespace));
1326
+ if (domainNamespaceIds.size === 0) domainNamespaceIds.add(defaultNamespaceId);
1327
+ if (valueObjects !== void 0) domainNamespaceIds.add(defaultNamespaceId);
1328
+ for (const nsId of Object.keys(domainEnumsByNs)) domainNamespaceIds.add(nsId);
1329
+ const domainNamespaces = Object.fromEntries([...domainNamespaceIds].sort().map((namespaceId) => {
1330
+ const modelsInNs = modelsByNamespace[namespaceId] ?? {};
1331
+ const enumsInNs = domainEnumsByNs[namespaceId];
1332
+ return [namespaceId, {
1333
+ models: modelsInNs,
1334
+ ...namespaceId === defaultNamespaceId && valueObjects !== void 0 ? { valueObjects } : {},
1335
+ ...enumsInNs !== void 0 && Object.keys(enumsInNs).length > 0 ? { enum: enumsInNs } : {}
1336
+ }];
1337
+ }));
1338
+ const contract = {
1339
+ target,
1340
+ targetFamily,
1341
+ ...ifDefined("defaultControlPolicy", definition.defaultControlPolicy),
1342
+ domain: { namespaces: domainNamespaces },
1343
+ roots,
1344
+ storage,
1345
+ ...executionWithHash ? { execution: executionWithHash } : {},
1346
+ extensions,
1347
+ capabilities,
1348
+ profileHash,
1349
+ meta: {}
1350
+ };
1351
+ assertStorageSemantics(contract, indexTypeRegistry, codecLookup);
1352
+ flushAuthoringWarnings(authoringWarnings);
1353
+ return contract;
1354
+ }
1355
+ /**
1356
+ * Aggregate roots, one per model that owns a table, keyed by bare storage table name. When two models in different namespaces map to the same bare table name, the bare key would collide, so those entries fall back to a namespace-qualified key. Single-namespace contracts never collide and keep their bare keys.
1357
+ */
1358
+ function buildRoots(components) {
1359
+ const rootEntries = components.flatMap(({ storage, domain }) => storage.kind === "ownTable" ? [{
1360
+ tableName: storage.table.tableName,
1361
+ namespaceId: domain.namespaceId,
1362
+ ref: crossRef(domain.modelName, domain.namespaceId)
1363
+ }] : []);
1364
+ const rootTableNameCounts = /* @__PURE__ */ new Map();
1365
+ for (const entry of rootEntries) rootTableNameCounts.set(entry.tableName, (rootTableNameCounts.get(entry.tableName) ?? 0) + 1);
1366
+ const roots = {};
1367
+ for (const entry of rootEntries) {
1368
+ const key = (rootTableNameCounts.get(entry.tableName) ?? 0) > 1 ? `${entry.namespaceId}.${entry.tableName}` : entry.tableName;
1369
+ roots[key] = entry.ref;
1370
+ }
1371
+ return roots;
1372
+ }
1373
+ /**
1374
+ * The one step every SQL contract specifier funnels its loaded contract
1375
+ * through: stamp the specifier's default control policy, then strip derived
1376
+ * checks from every table the stamped policy leaves non-managed. Composing the
1377
+ * two here is what keeps the managed-only consequence from being skipped on
1378
+ * any specifier route.
1379
+ */
1380
+ function applySqlSpecifierControlPolicy(contract, defaultControlPolicy, createNamespace) {
1381
+ return stripDerivedChecksFromNonManagedTables(applySpecifierDefaultControlPolicy(contract, defaultControlPolicy), createNamespace);
1382
+ }
1383
+ /**
1384
+ * Removes generated enforcement checks from every table whose effective
1385
+ * control policy is not `managed`.
1386
+ *
1387
+ * A check is derived iff its wire prefix is one derivation would produce for
1388
+ * some column of its table — {@link derivedCheckPrefixes} enumerates that
1389
+ * set. Wire-naming alone no longer identifies derivation: an authored
1390
+ * `name:` check (`@@check` / `check()`) is wire-named too, so a bare
1391
+ * `check.prefix === undefined` test would delete an author's own constraint
1392
+ * from every non-`managed` table. The prefix-shape rule tests against the
1393
+ * table's own columns instead of the naming mode, so an authored check with
1394
+ * an unrelated prefix survives.
1395
+ *
1396
+ * The rule is weaker than recomputing the content hash `contract infer`
1397
+ * uses: that needs `postgresRenderCheckExpressions` to know what a kind
1398
+ * renders, and this funnel has no target descriptor to reach it through. It
1399
+ * can only ask whether some column could have produced a prefix of this
1400
+ * shape, not whether this exact column produced this exact check. The gap
1401
+ * that opens — an authored name that collides with a derived-prefix shape —
1402
+ * is closed at authoring time instead: such a name is rejected
1403
+ * (`CONTRACT.CHECK_NAME_RESERVED`) before it ever reaches storage.
1404
+ *
1405
+ * Why derivation stops at the namespace boundary: the contract *describes* an
1406
+ * external schema, it does not *prescribe* enforcement for it. Deriving a check
1407
+ * for a table Prisma 8 never creates declares a constraint the live database
1408
+ * has no reason to carry, and `external` fails verify on a declared shape the
1409
+ * database lacks — an unfixable failure, since no plan may emit DDL there
1410
+ * either.
1411
+ *
1412
+ * This is the post-build half of the rule. Authoring skips derivation for a
1413
+ * table whose policy is known in the source; this pass catches the policy a
1414
+ * contract *specifier* applies after the contract is already built, which is
1415
+ * the only signal a pack like the Supabase extension gives. Specifiers reach
1416
+ * it through `applySqlSpecifierControlPolicy` above.
1417
+ *
1418
+ * Returns the contract unchanged (same reference) when nothing is stripped.
1419
+ * When something is, the storage hash is recomputed — the stripped contract
1420
+ * describes different storage.
1421
+ */
1422
+ function stripDerivedChecksFromNonManagedTables(contract, createNamespace) {
1423
+ const storage = contract.storage;
1424
+ if (!isSqlStorageShaped(storage)) return contract;
1425
+ let anyStripped = false;
1426
+ const namespaces = {};
1427
+ for (const [namespaceId, namespace] of Object.entries(storage.namespaces)) {
1428
+ if (!isMaterializedSqlNamespace(namespace)) return contract;
1429
+ const tables = namespace.entries["table"];
1430
+ if (tables === void 0) {
1431
+ namespaces[namespaceId] = namespace;
1432
+ continue;
1433
+ }
1434
+ let namespaceStripped = false;
1435
+ const nextTables = {};
1436
+ for (const [tableName, table] of Object.entries(tables)) {
1437
+ const stripped = StorageTable.is(table) ? withoutDerivedChecks(tableName, table, contract.defaultControlPolicy) : table;
1438
+ if (stripped !== table) namespaceStripped = true;
1439
+ nextTables[tableName] = stripped;
1440
+ }
1441
+ if (!namespaceStripped) {
1442
+ namespaces[namespaceId] = namespace;
1443
+ continue;
1444
+ }
1445
+ anyStripped = true;
1446
+ namespaces[namespaceId] = createNamespace({
1447
+ id: namespace.id,
1448
+ entries: {
1449
+ ...namespace.entries,
1450
+ table: nextTables
1451
+ }
1452
+ });
1453
+ }
1454
+ if (!anyStripped) return contract;
1455
+ const storageWithoutHash = {
1456
+ namespaces,
1457
+ ...ifDefined("types", storage.types)
1458
+ };
1459
+ return {
1460
+ ...contract,
1461
+ storage: new SqlStorage({
1462
+ ...storageWithoutHash,
1463
+ storageHash: computeStorageHash({
1464
+ target: contract.target,
1465
+ targetFamily: contract.targetFamily,
1466
+ storage: storageWithoutHash,
1467
+ ...sqlContractCanonicalizationHooks
1468
+ })
1469
+ })
1470
+ };
1471
+ }
1472
+ /**
1473
+ * Structural stand-in for `instanceof SqlStorage`: like the checks it wraps, a
1474
+ * storage instance can arrive from a realm whose IR classes are a separate
1475
+ * copy (the dist e2e shape), where an `instanceof` test would miss.
1476
+ */
1477
+ function isSqlStorageShaped(x) {
1478
+ if (typeof x !== "object" || x === null || !("namespaces" in x)) return false;
1479
+ return typeof x.namespaces === "object" && x.namespaces !== null;
1480
+ }
1481
+ /** The table itself when it keeps every check, a rebuilt one when it does not. */
1482
+ function withoutDerivedChecks(tableName, table, contractDefault) {
1483
+ const checks = table.checks;
1484
+ if (checks === void 0 || checks.length === 0) return table;
1485
+ if (effectiveControlPolicy(table.control, contractDefault) === "managed") return table;
1486
+ const columnNames = Object.keys(table.columns);
1487
+ invariant(columnNames.length > 0, `withoutDerivedChecks: table "${tableName}" carries checks but its column map is empty. The caller must pass the table's real, complete column set — an empty or partial map makes every check misclassify as non-derived and survive the strip.`);
1488
+ const derivedPrefixes = derivedCheckPrefixes(tableName, columnNames);
1489
+ const kept = checks.filter((check) => check.prefix === void 0 || !derivedPrefixes.has(check.prefix));
1490
+ if (kept.length === checks.length) return table;
1491
+ return new StorageTable({
1492
+ columns: table.columns,
1493
+ uniques: table.uniques,
1494
+ indexes: table.indexes,
1495
+ foreignKeys: table.foreignKeys,
1496
+ ...ifDefined("primaryKey", table.primaryKey),
1497
+ ...ifDefined("control", table.control),
1498
+ ...kept.length > 0 ? { checks: kept.map((check) => checkConstraintInputFromSerialized({
1499
+ name: check.name,
1500
+ ...ifDefined("prefix", check.prefix),
1501
+ expression: check.expression
1502
+ })) } : {}
1503
+ });
1504
+ }
1505
+ //#endregion
1506
+ export { refuseTypesKey as a, isValueObjectMember as i, buildSqlContractFromDefinition as n, storedAsListColumn as o, contractError as r, toOneNullabilityContradictionMessage as s, applySqlSpecifierControlPolicy as t };
1507
+
1508
+ //# sourceMappingURL=derived-checks-D5HVRvqN-BJx1gwPA.mjs.map