@prisma/orm-target-postgres 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/README.md +4 -6
  2. package/dist/adapter-5qylEP__.d.mts +403 -0
  3. package/dist/adapter-5qylEP__.d.mts.map +1 -0
  4. package/dist/{adapter-B0xsc80z-sYcF0RVF.mjs → adapter-svGTIjA2-1p-Iw8D2.mjs} +24 -30
  5. package/dist/adapter-svGTIjA2-1p-Iw8D2.mjs.map +1 -0
  6. package/dist/adapter.d.mts +11 -13
  7. package/dist/adapter.mjs +7 -8
  8. package/dist/adapter__adapter.d.mts +2 -2
  9. package/dist/adapter__adapter.mjs +3 -2
  10. package/dist/adapter__column-types.d.mts +2 -2
  11. package/dist/adapter__column-types.mjs +2 -2
  12. package/dist/adapter__control.d.mts +4 -5
  13. package/dist/adapter__control.mjs +11 -423
  14. package/dist/adapter__control.mjs.map +1 -1
  15. package/dist/adapter__runtime.d.mts +1 -1
  16. package/dist/adapter__runtime.mjs +29 -19
  17. package/dist/adapter__runtime.mjs.map +1 -1
  18. package/dist/adapter__sql-renderer.d.mts +1 -1
  19. package/dist/adapter__sql-renderer.mjs +1 -1
  20. package/dist/adapter__types.d.mts +4 -3
  21. package/dist/aggregates-CEqqEg8k.d.mts +318 -0
  22. package/dist/aggregates-CEqqEg8k.d.mts.map +1 -0
  23. package/dist/{aggregates-Dh6HPdvC.mjs → aggregates-Dw-lAutX.mjs} +105 -40
  24. package/dist/aggregates-Dw-lAutX.mjs.map +1 -0
  25. package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts +52 -0
  26. package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts.map +1 -0
  27. package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs +1342 -0
  28. package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs.map +1 -0
  29. package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs +58 -0
  30. package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs.map +1 -0
  31. package/dist/{canonicalize-CQlxSR4D-MnrT5gtW.d.mts → canonicalize-B-xvDOdd-G3yUeKj4.d.mts} +7 -3
  32. package/dist/canonicalize-B-xvDOdd-G3yUeKj4.d.mts.map +1 -0
  33. package/dist/{canonicalize-CrN3u_xM-D4MrOqcB.mjs → canonicalize-RdxoUHao-FTTkizfe.mjs} +15 -3
  34. package/dist/canonicalize-RdxoUHao-FTTkizfe.mjs.map +1 -0
  35. package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs +48 -0
  36. package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs.map +1 -0
  37. package/dist/{check-expressions-DRgG8RN5-DiA-22aC.d.mts → check-expressions-CtTzM58x-LloO-5Vf.d.mts} +14 -13
  38. package/dist/check-expressions-CtTzM58x-LloO-5Vf.d.mts.map +1 -0
  39. package/dist/{codec-descriptor-LT7BpQta-BaDM8UQQ.mjs → codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs} +12 -21
  40. package/dist/codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs.map +1 -0
  41. package/dist/codec-descriptor-Fb3UoQGb.d.mts +1 -0
  42. package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts +47 -0
  43. package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts.map +1 -0
  44. package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs +41 -0
  45. package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs.map +1 -0
  46. package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts +41 -0
  47. package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts.map +1 -0
  48. package/dist/codec-ids-CcB5uBNf.d.mts +1 -0
  49. package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs +61 -0
  50. package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs.map +1 -0
  51. package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts +53 -0
  52. package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts.map +1 -0
  53. package/dist/codec-types-BBACckHa.d.mts +2 -0
  54. package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts +84 -0
  55. package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts.map +1 -0
  56. package/dist/codecs-CADK7dCR-C8WToYQb.d.mts +724 -0
  57. package/dist/codecs-CADK7dCR-C8WToYQb.d.mts.map +1 -0
  58. package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs +1743 -0
  59. package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs.map +1 -0
  60. package/dist/codecs-CoEpEqjM.d.mts +31 -0
  61. package/dist/codecs-CoEpEqjM.d.mts.map +1 -0
  62. package/dist/column-types-B4zsV-u3.mjs +106 -0
  63. package/dist/column-types-B4zsV-u3.mjs.map +1 -0
  64. package/dist/column-types-Bs2V0j8T.d.mts +164 -0
  65. package/dist/column-types-Bs2V0j8T.d.mts.map +1 -0
  66. package/dist/{control-adapter-DFr4gS-r-DM3KcZdQ.mjs → contract-contributions-Xz2FpyfI-CeQZqHKf.mjs} +489 -292
  67. package/dist/contract-contributions-Xz2FpyfI-CeQZqHKf.mjs.map +1 -0
  68. package/dist/{contract-free-DzpGxLfb.d.mts → contract-free-B6-wuc6M.d.mts} +36 -6
  69. package/dist/contract-free-B6-wuc6M.d.mts.map +1 -0
  70. package/dist/{contract-free-aQ4nT-_R.mjs → contract-free-o7olebm9.mjs} +13 -9
  71. package/dist/contract-free-o7olebm9.mjs.map +1 -0
  72. package/dist/control--HupSPoV.d.mts +847 -0
  73. package/dist/control--HupSPoV.d.mts.map +1 -0
  74. package/dist/{control-BaUpALVp.d.mts → control-CQEjh4P7.d.mts} +2 -2
  75. package/dist/control-CQEjh4P7.d.mts.map +1 -0
  76. package/dist/{control-DLTOAEHj.d.mts → control-D4cTcpcJ.d.mts} +22 -48
  77. package/dist/control-D4cTcpcJ.d.mts.map +1 -0
  78. package/dist/{control-Y6FxMu3o.mjs → control-DZQwENIP.mjs} +21 -9
  79. package/dist/control-DZQwENIP.mjs.map +1 -0
  80. package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs → control-policy-DtU5u9Dm-44r_OF94.mjs} +444 -218
  81. package/dist/control-policy-DtU5u9Dm-44r_OF94.mjs.map +1 -0
  82. package/dist/{data-transform-ChZzy2dP-CxVCat_8.mjs → data-transform-h9agBu_c-RlC5A7aY.mjs} +12 -5
  83. package/dist/data-transform-h9agBu_c-RlC5A7aY.mjs.map +1 -0
  84. package/dist/{data-transform-Ck5FbyNO-BNE7QlAo.d.mts → data-transform-nGy9rz87-CE3DGlgn.d.mts} +15 -4
  85. package/dist/data-transform-nGy9rz87-CE3DGlgn.d.mts.map +1 -0
  86. package/dist/data-transform-nqkqNIb8.d.mts +1 -0
  87. package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs +128 -0
  88. package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs.map +1 -0
  89. package/dist/data-types--7V9yY1G.d.mts +99 -0
  90. package/dist/data-types--7V9yY1G.d.mts.map +1 -0
  91. package/dist/data-types-Chx0mjTP-DczU4S9b.mjs +950 -0
  92. package/dist/data-types-Chx0mjTP-DczU4S9b.mjs.map +1 -0
  93. package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts +45 -0
  94. package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts.map +1 -0
  95. package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs +647 -0
  96. package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs.map +1 -0
  97. package/dist/ddl-B8nQZTWN.d.mts +1 -0
  98. package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs +18 -0
  99. package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs.map +1 -0
  100. package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs +311 -0
  101. package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs.map +1 -0
  102. package/dist/default-normalizer-DO-cH75Q.d.mts +25 -0
  103. package/dist/default-normalizer-DO-cH75Q.d.mts.map +1 -0
  104. package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs +36 -0
  105. package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs.map +1 -0
  106. package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs +64 -0
  107. package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs.map +1 -0
  108. package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs +15 -0
  109. package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs.map +1 -0
  110. package/dist/{diff-database-schema-DsoNznGC.d.mts → diff-database-schema-BxzhZaVN.d.mts} +12 -7
  111. package/dist/diff-database-schema-BxzhZaVN.d.mts.map +1 -0
  112. package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs → diff-database-schema-DAEzWtzU-DoyVgKqh.mjs} +38 -18
  113. package/dist/diff-database-schema-DAEzWtzU-DoyVgKqh.mjs.map +1 -0
  114. package/dist/driver.d.mts +3 -3
  115. package/dist/driver.mjs +3 -2
  116. package/dist/driver__control.d.mts +1 -1
  117. package/dist/driver__control.mjs +1 -1
  118. package/dist/driver__runtime.d.mts +2 -2
  119. package/dist/driver__runtime.mjs +2 -639
  120. package/dist/errors-BrhQYgdL-IvZHPjwL.mjs +103 -0
  121. package/dist/errors-BrhQYgdL-IvZHPjwL.mjs.map +1 -0
  122. package/dist/{errors-CU4xIwwk.d.mts → errors-D3Mj-x0o.d.mts} +3 -3
  123. package/dist/errors-D3Mj-x0o.d.mts.map +1 -0
  124. package/dist/full-text-BYg7EVX2.mjs +39 -0
  125. package/dist/full-text-BYg7EVX2.mjs.map +1 -0
  126. package/dist/full-text-SDbfxrE_.d.mts +26 -0
  127. package/dist/full-text-SDbfxrE_.d.mts.map +1 -0
  128. package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts +27 -0
  129. package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts.map +1 -0
  130. package/dist/full-text-index-authoring-CN1L9C1k.d.mts +7 -0
  131. package/dist/full-text-index-authoring-CN1L9C1k.d.mts.map +1 -0
  132. package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs +195 -0
  133. package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs.map +1 -0
  134. package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts +71 -0
  135. package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts.map +1 -0
  136. package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs +139 -0
  137. package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs.map +1 -0
  138. package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs +54 -0
  139. package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs.map +1 -0
  140. package/dist/index-types-BihjrAAq-C2VnfAyF.mjs +14 -0
  141. package/dist/index-types-BihjrAAq-C2VnfAyF.mjs.map +1 -0
  142. package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts +60 -0
  143. package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts.map +1 -0
  144. package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs +1143 -0
  145. package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs.map +1 -0
  146. package/dist/{issue-planner-Biq9Ls7e.d.mts → issue-planner-D-On52xP.d.mts} +39 -9
  147. package/dist/issue-planner-D-On52xP.d.mts.map +1 -0
  148. package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts +7 -0
  149. package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts.map +1 -0
  150. package/dist/marker-lock-BviIbusV.d.mts +11 -0
  151. package/dist/marker-lock-BviIbusV.d.mts.map +1 -0
  152. package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs +11 -0
  153. package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs.map +1 -0
  154. package/dist/{migration-PTHAY9Cv.mjs → migration-Be_iuIpn.mjs} +5 -4
  155. package/dist/migration-Be_iuIpn.mjs.map +1 -0
  156. package/dist/migration-D4lMmLVj.d.mts +26 -0
  157. package/dist/migration-D4lMmLVj.d.mts.map +1 -0
  158. package/dist/{namespace-ids-xtp_ZY86-Cpp8PTxD.mjs → namespace-ids-xtp_ZY86-Cxc0dBbO.mjs} +2 -2
  159. package/dist/namespace-ids-xtp_ZY86-Cxc0dBbO.mjs.map +1 -0
  160. package/dist/native-type-normalizer-BaGa9eeb.d.mts +30 -0
  161. package/dist/native-type-normalizer-BaGa9eeb.d.mts.map +1 -0
  162. package/dist/native-type-normalizer-Cn-RGt_E.mjs +24 -0
  163. package/dist/native-type-normalizer-Cn-RGt_E.mjs.map +1 -0
  164. package/dist/{nodes-DAvDJLvJ-BBdvFXNa.mjs → nodes-G8VTh4PM-DNvIhHag.mjs} +78 -7
  165. package/dist/nodes-G8VTh4PM-DNvIhHag.mjs.map +1 -0
  166. package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts → nodes-s0Oe37jT-Cw3BU2gL.d.mts} +82 -29
  167. package/dist/nodes-s0Oe37jT-Cw3BU2gL.d.mts.map +1 -0
  168. package/dist/op-factory-call-CRaVUOb_.d.mts +1 -0
  169. package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-gGX-mZu--0QUG5xH4.mjs} +1014 -258
  170. package/dist/op-factory-call-gGX-mZu--0QUG5xH4.mjs.map +1 -0
  171. package/dist/{op-factory-call-BAeyLFYf-BAgG1h1C.d.mts → op-factory-call-nLHvNx0O-BTBhGbOF.d.mts} +169 -111
  172. package/dist/op-factory-call-nLHvNx0O-BTBhGbOF.d.mts.map +1 -0
  173. package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts +192 -0
  174. package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts.map +1 -0
  175. package/dist/operation-types-OXILTAOX.d.mts +1 -0
  176. package/dist/pack-2CYw2w-b.d.mts +1573 -0
  177. package/dist/pack-2CYw2w-b.d.mts.map +1 -0
  178. package/dist/{planner-CT-7zSfk.d.mts → planner-AD3Dt57t.d.mts} +23 -51
  179. package/dist/planner-AD3Dt57t.d.mts.map +1 -0
  180. package/dist/planner-VuR6URu3-CCUT2Osx.mjs +954 -0
  181. package/dist/planner-VuR6URu3-CCUT2Osx.mjs.map +1 -0
  182. package/dist/planner-ddl-builders-CPM3y7cQ.d.mts +16 -0
  183. package/dist/planner-ddl-builders-CPM3y7cQ.d.mts.map +1 -0
  184. package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs +28 -0
  185. package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs.map +1 -0
  186. package/dist/planner-identity-values-Dsq989Lh.d.mts +26 -0
  187. package/dist/planner-identity-values-Dsq989Lh.d.mts.map +1 -0
  188. package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs +70 -0
  189. package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs.map +1 -0
  190. package/dist/planner-produced-postgres-migration-BBUwtjA_.d.mts +1 -0
  191. package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs → planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs} +5 -5
  192. package/dist/planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs.map +1 -0
  193. package/dist/{planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts → planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts} +4 -4
  194. package/dist/planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts.map +1 -0
  195. package/dist/{planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs → planner-schema-lookup-BbUY9oVy.mjs} +2 -2
  196. package/dist/planner-schema-lookup-BbUY9oVy.mjs.map +1 -0
  197. package/dist/{planner-schema-lookup-C4DHAddq.d.mts → planner-schema-lookup-ceCNOGFf.d.mts} +2 -2
  198. package/dist/planner-schema-lookup-ceCNOGFf.d.mts.map +1 -0
  199. package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs +151 -0
  200. package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs.map +1 -0
  201. package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts +37 -0
  202. package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts.map +1 -0
  203. package/dist/planner-sql-checks-rEjFx_Jv.d.mts +1 -0
  204. package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs +14 -0
  205. package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs.map +1 -0
  206. package/dist/{planner-target-details-HkP4RrRO-_xPQVPF0.d.mts → planner-target-details-HkP4RrRO-D6VtK0jY.d.mts} +2 -2
  207. package/dist/planner-target-details-HkP4RrRO-D6VtK0jY.d.mts.map +1 -0
  208. package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs +11 -0
  209. package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs.map +1 -0
  210. package/dist/{postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts → postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts} +2 -2
  211. package/dist/postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts.map +1 -0
  212. package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs → postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs} +27 -14
  213. package/dist/postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs.map +1 -0
  214. package/dist/{postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts → postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts} +4 -4
  215. package/dist/postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map +1 -0
  216. package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs +1312 -0
  217. package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs.map +1 -0
  218. package/dist/{postgres-migration-BNsrwlxh-CwI5BqAu.d.mts → postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts} +135 -15
  219. package/dist/postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts.map +1 -0
  220. package/dist/{postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs → postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs} +2 -2
  221. package/dist/postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs.map +1 -0
  222. package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs +23 -0
  223. package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs.map +1 -0
  224. package/dist/{postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts → postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts} +2 -2
  225. package/dist/postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts.map +1 -0
  226. package/dist/{postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs → postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs} +3 -3
  227. package/dist/postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs.map +1 -0
  228. package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs → postgres-schema-C6w1rzOF-D1fdwqRx.mjs} +14 -12
  229. package/dist/postgres-schema-C6w1rzOF-D1fdwqRx.mjs.map +1 -0
  230. package/dist/{postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts → postgres-schema-Xsjt3RKO-bis-SVSB.d.mts} +4 -4
  231. package/dist/postgres-schema-Xsjt3RKO-bis-SVSB.d.mts.map +1 -0
  232. package/dist/{postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs → postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs} +2 -2
  233. package/dist/postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs.map +1 -0
  234. package/dist/prisma7-binding-BjiLA9F7.mjs +307 -0
  235. package/dist/prisma7-binding-BjiLA9F7.mjs.map +1 -0
  236. package/dist/prisma7-binding-a56klfkc.d.mts +1651 -0
  237. package/dist/prisma7-binding-a56klfkc.d.mts.map +1 -0
  238. package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs → render-ops-BgqtCw9Z-T8BPTX85.mjs} +17 -10
  239. package/dist/render-ops-BgqtCw9Z-T8BPTX85.mjs.map +1 -0
  240. package/dist/{render-ops-DPwhZt2W.d.mts → render-ops-Bl84i7ut.d.mts} +3 -3
  241. package/dist/render-ops-Bl84i7ut.d.mts.map +1 -0
  242. package/dist/{render-typescript-6sCFvMBh.d.mts → render-typescript-BysdXYpH.d.mts} +2 -2
  243. package/dist/render-typescript-BysdXYpH.d.mts.map +1 -0
  244. package/dist/{render-typescript-Dqp1Spgn-B128r1qw.mjs → render-typescript-Dqp1Spgn-B4mJhuVr.mjs} +2 -2
  245. package/dist/render-typescript-Dqp1Spgn-B4mJhuVr.mjs.map +1 -0
  246. package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs +34 -0
  247. package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs.map +1 -0
  248. package/dist/{runtime-lHBKgjB9.d.mts → runtime-C0VXuM0b.d.mts} +4 -3
  249. package/dist/runtime-C0VXuM0b.d.mts.map +1 -0
  250. package/dist/runtime-CXfxy5ED.mjs +660 -0
  251. package/dist/runtime-CXfxy5ED.mjs.map +1 -0
  252. package/dist/{runtime-_TfO66h5.d.mts → runtime-Ci_toEDZ.d.mts} +12 -4
  253. package/dist/runtime-Ci_toEDZ.d.mts.map +1 -0
  254. package/dist/{runtime-DOXznQe0.d.mts → runtime-DtjW0GP_.d.mts} +4 -4
  255. package/dist/runtime-DtjW0GP_.d.mts.map +1 -0
  256. package/dist/{schema-ir-annotations-DuuYh0gl.d.mts → schema-ir-annotations-BygaWBiC.d.mts} +2 -2
  257. package/dist/schema-ir-annotations-BygaWBiC.d.mts.map +1 -0
  258. package/dist/{schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts → schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts} +2 -2
  259. package/dist/schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts.map +1 -0
  260. package/dist/{normalize-error-CNjgVO71-CLlZ3CuJ.mjs → server-text-types-DeNPQpv5-DqX0h8WF.mjs} +45 -3
  261. package/dist/server-text-types-DeNPQpv5-DqX0h8WF.mjs.map +1 -0
  262. package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs → sql-renderer-BdWJPa5F-Ct0CPlXc.mjs} +113 -123
  263. package/dist/sql-renderer-BdWJPa5F-Ct0CPlXc.mjs.map +1 -0
  264. package/dist/{sql-renderer-BgC0ZgLS.d.mts → sql-renderer-BiBhge7D.d.mts} +9 -7
  265. package/dist/sql-renderer-BiBhge7D.d.mts.map +1 -0
  266. package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs → sql-utils-Bnw3JbWf-BN0gcjZB.mjs} +31 -8
  267. package/dist/sql-utils-Bnw3JbWf-BN0gcjZB.mjs.map +1 -0
  268. package/dist/{sql-utils-DW6fkczF.d.mts → sql-utils-CnnGiZBc.d.mts} +12 -4
  269. package/dist/sql-utils-CnnGiZBc.d.mts.map +1 -0
  270. package/dist/{table-source-ikHOZmhD-DriY1Lcr.d.mts → table-source-ikHOZmhD-vYcblBYv.d.mts} +2 -2
  271. package/dist/table-source-ikHOZmhD-vYcblBYv.d.mts.map +1 -0
  272. package/dist/target.d.mts +61 -49
  273. package/dist/target.mjs +45 -36
  274. package/dist/target__aggregates.d.mts +1 -1
  275. package/dist/target__aggregates.mjs +1 -1
  276. package/dist/target__codec-descriptor.d.mts +2 -2
  277. package/dist/target__codec-descriptor.mjs +1 -1
  278. package/dist/target__codec-ids.d.mts +3 -3
  279. package/dist/target__codec-ids.mjs +2 -2
  280. package/dist/target__codec-types.d.mts +4 -4
  281. package/dist/target__codecs.d.mts +4 -3
  282. package/dist/target__codecs.mjs +3 -3
  283. package/dist/target__contract-free.d.mts +3 -3
  284. package/dist/target__contract-free.mjs +4 -4
  285. package/dist/target__control.d.mts +4 -2
  286. package/dist/target__control.mjs +2501 -2
  287. package/dist/target__control.mjs.map +1 -0
  288. package/dist/target__data-transform.d.mts +2 -2
  289. package/dist/target__data-transform.mjs +1 -1
  290. package/dist/target__data-types.d.mts +2 -0
  291. package/dist/target__data-types.mjs +3 -0
  292. package/dist/target__ddl.d.mts +4 -4
  293. package/dist/target__ddl.mjs +2 -2
  294. package/dist/target__default-normalizer.d.mts +2 -2
  295. package/dist/target__default-normalizer.mjs +2 -2
  296. package/dist/target__diff-database-schema.d.mts +1 -1
  297. package/dist/target__diff-database-schema.mjs +1 -1
  298. package/dist/target__errors.d.mts +1 -1
  299. package/dist/target__errors.mjs +1 -1
  300. package/dist/target__full-text-index-authoring.d.mts +3 -0
  301. package/dist/target__full-text-index-authoring.mjs +3 -0
  302. package/dist/target__full-text.d.mts +4 -0
  303. package/dist/target__full-text.mjs +3 -0
  304. package/dist/target__issue-planner.d.mts +1 -1
  305. package/dist/target__issue-planner.mjs +1 -1
  306. package/dist/target__marker-lock.d.mts +2 -0
  307. package/dist/target__marker-lock.mjs +2 -0
  308. package/dist/target__migration.d.mts +4 -4
  309. package/dist/target__migration.mjs +5 -5
  310. package/dist/target__native-type-normalizer.d.mts +2 -2
  311. package/dist/target__native-type-normalizer.mjs +2 -2
  312. package/dist/target__op-factory-call.d.mts +3 -3
  313. package/dist/target__op-factory-call.mjs +2 -2
  314. package/dist/target__operation-types.d.mts +4 -0
  315. package/dist/target__pack.d.mts +3 -2
  316. package/dist/target__pack.mjs +1 -1
  317. package/dist/target__planner-ddl-builders.d.mts +2 -2
  318. package/dist/target__planner-ddl-builders.mjs +2 -2
  319. package/dist/target__planner-identity-values.d.mts +1 -1
  320. package/dist/target__planner-identity-values.mjs +1 -1
  321. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  322. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  323. package/dist/target__planner-schema-lookup.d.mts +1 -1
  324. package/dist/target__planner-schema-lookup.mjs +1 -1
  325. package/dist/target__planner-sql-checks.d.mts +3 -2
  326. package/dist/target__planner-sql-checks.mjs +2 -2
  327. package/dist/target__planner-target-details.d.mts +1 -1
  328. package/dist/target__planner.d.mts +1 -1
  329. package/dist/target__planner.mjs +2 -2
  330. package/dist/target__prisma7-binding.d.mts +2 -0
  331. package/dist/target__prisma7-binding.mjs +2 -0
  332. package/dist/target__render-ops.d.mts +1 -1
  333. package/dist/target__render-ops.mjs +1 -1
  334. package/dist/target__render-typescript.d.mts +1 -1
  335. package/dist/target__render-typescript.mjs +1 -1
  336. package/dist/target__rls-canonicalize.d.mts +2 -2
  337. package/dist/target__rls-canonicalize.mjs +2 -2
  338. package/dist/target__runtime.d.mts +6 -3
  339. package/dist/target__runtime.mjs +193 -4
  340. package/dist/target__runtime.mjs.map +1 -1
  341. package/dist/target__schema-ir-annotations.d.mts +1 -1
  342. package/dist/target__schema-ir-annotations.mjs +1 -1
  343. package/dist/target__sql-utils.d.mts +3 -2
  344. package/dist/target__sql-utils.mjs +4 -2
  345. package/dist/target__types.d.mts +7 -7
  346. package/dist/target__types.mjs +5 -5
  347. package/dist/types-AvjnIUna.d.mts +2 -0
  348. package/dist/types-D6lgKhE5-D1J9YJnd.d.mts +28 -0
  349. package/dist/types-D6lgKhE5-D1J9YJnd.d.mts.map +1 -0
  350. package/dist/{types-CjGjPLr5.d.mts → types-DOmgp_12.d.mts} +8 -8
  351. package/dist/types-DOmgp_12.d.mts.map +1 -0
  352. package/dist/{types-ue6jkJyF-BQJzjx1P.d.mts → types-ue6jkJyF-D79DmBTl.d.mts} +2 -2
  353. package/dist/types-ue6jkJyF-D79DmBTl.d.mts.map +1 -0
  354. package/package.json +22 -14
  355. package/dist/adapter-B0xsc80z-sYcF0RVF.mjs.map +0 -1
  356. package/dist/adapter-CPesdzv0.d.mts +0 -26
  357. package/dist/adapter-CPesdzv0.d.mts.map +0 -1
  358. package/dist/adapter__operation-types.d.mts +0 -2
  359. package/dist/aggregates-CgqNfj2O.d.mts +0 -10
  360. package/dist/aggregates-CgqNfj2O.d.mts.map +0 -1
  361. package/dist/aggregates-Dh6HPdvC.mjs.map +0 -1
  362. package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs +0 -773
  363. package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs.map +0 -1
  364. package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +0 -1
  365. package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +0 -1
  366. package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs +0 -41
  367. package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs.map +0 -1
  368. package/dist/check-expressions-DRgG8RN5-DiA-22aC.d.mts.map +0 -1
  369. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +0 -37
  370. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +0 -1
  371. package/dist/codec-descriptor-Bg-_412t.d.mts +0 -1
  372. package/dist/codec-descriptor-LT7BpQta-BaDM8UQQ.mjs.map +0 -1
  373. package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts +0 -35
  374. package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +0 -1
  375. package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs +0 -35
  376. package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +0 -1
  377. package/dist/codec-ids-DJ6j6pZc.d.mts +0 -1
  378. package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts +0 -84
  379. package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +0 -1
  380. package/dist/codec-types-bX63JRLf.d.mts +0 -2
  381. package/dist/codecs-B1HgsJZ2.mjs +0 -15
  382. package/dist/codecs-B1HgsJZ2.mjs.map +0 -1
  383. package/dist/codecs-BmPCJWqb-DveZGJvm.mjs +0 -1680
  384. package/dist/codecs-BmPCJWqb-DveZGJvm.mjs.map +0 -1
  385. package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts +0 -638
  386. package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +0 -1
  387. package/dist/codecs-DmCKO7dg.d.mts +0 -15
  388. package/dist/codecs-DmCKO7dg.d.mts.map +0 -1
  389. package/dist/column-types-BH-MU6uU.d.mts +0 -108
  390. package/dist/column-types-BH-MU6uU.d.mts.map +0 -1
  391. package/dist/column-types-Bh92dNjD.mjs +0 -126
  392. package/dist/column-types-Bh92dNjD.mjs.map +0 -1
  393. package/dist/contract-free-DzpGxLfb.d.mts.map +0 -1
  394. package/dist/contract-free-aQ4nT-_R.mjs.map +0 -1
  395. package/dist/control-2F195jJk.d.mts +0 -11
  396. package/dist/control-2F195jJk.d.mts.map +0 -1
  397. package/dist/control-BaUpALVp.d.mts.map +0 -1
  398. package/dist/control-DLTOAEHj.d.mts.map +0 -1
  399. package/dist/control-V7OkAC55.mjs +0 -1459
  400. package/dist/control-V7OkAC55.mjs.map +0 -1
  401. package/dist/control-Y6FxMu3o.mjs.map +0 -1
  402. package/dist/control-adapter-DFr4gS-r-DM3KcZdQ.mjs.map +0 -1
  403. package/dist/control-policy-B53lnBCT-B9K9Cj1x.mjs.map +0 -1
  404. package/dist/data-transform-BSM7TQpE.d.mts +0 -1
  405. package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +0 -1
  406. package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +0 -1
  407. package/dist/ddl-B4Rh8ntj.d.mts +0 -1
  408. package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs +0 -395
  409. package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs.map +0 -1
  410. package/dist/default-normalizer-B36TOul4.d.mts +0 -31
  411. package/dist/default-normalizer-B36TOul4.d.mts.map +0 -1
  412. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +0 -253
  413. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +0 -1
  414. package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs +0 -354
  415. package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs.map +0 -1
  416. package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs +0 -30
  417. package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs.map +0 -1
  418. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +0 -13
  419. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +0 -1
  420. package/dist/diff-database-schema-DKq76rCk-uehceHYz.mjs.map +0 -1
  421. package/dist/diff-database-schema-DsoNznGC.d.mts.map +0 -1
  422. package/dist/driver__runtime.mjs.map +0 -1
  423. package/dist/errors-CU4xIwwk.d.mts.map +0 -1
  424. package/dist/errors-DKjQzNaN-DFcF1thx.mjs +0 -39
  425. package/dist/errors-DKjQzNaN-DFcF1thx.mjs.map +0 -1
  426. package/dist/issue-planner-Biq9Ls7e.d.mts.map +0 -1
  427. package/dist/migration-PTHAY9Cv.mjs.map +0 -1
  428. package/dist/migration-aFeTWTOJ.d.mts +0 -25
  429. package/dist/migration-aFeTWTOJ.d.mts.map +0 -1
  430. package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +0 -1
  431. package/dist/native-type-normalizer-DqJlOTeX.d.mts +0 -19
  432. package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +0 -1
  433. package/dist/native-type-normalizer-yvd3tqv-.mjs +0 -38
  434. package/dist/native-type-normalizer-yvd3tqv-.mjs.map +0 -1
  435. package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +0 -1
  436. package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +0 -1
  437. package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +0 -1
  438. package/dist/op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map +0 -1
  439. package/dist/op-factory-call-BTU8I_x0.d.mts +0 -1
  440. package/dist/op-factory-call-H6zeDGLe-_1pAftJk.mjs.map +0 -1
  441. package/dist/operation-types-BfRocNI8.d.mts +0 -22
  442. package/dist/operation-types-BfRocNI8.d.mts.map +0 -1
  443. package/dist/pack-CySS3DQU.d.mts +0 -626
  444. package/dist/pack-CySS3DQU.d.mts.map +0 -1
  445. package/dist/planner-CT-7zSfk.d.mts.map +0 -1
  446. package/dist/planner-D0uogzvT-1WyGIC5p.mjs +0 -671
  447. package/dist/planner-D0uogzvT-1WyGIC5p.mjs.map +0 -1
  448. package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs +0 -102
  449. package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs.map +0 -1
  450. package/dist/planner-ddl-builders-ijp60-JO.d.mts +0 -19
  451. package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +0 -1
  452. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +0 -90
  453. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +0 -1
  454. package/dist/planner-identity-values-TfEhnoWa.d.mts +0 -25
  455. package/dist/planner-identity-values-TfEhnoWa.d.mts.map +0 -1
  456. package/dist/planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts.map +0 -1
  457. package/dist/planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs.map +0 -1
  458. package/dist/planner-produced-postgres-migration-D6C0T2xV.d.mts +0 -1
  459. package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +0 -1
  460. package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +0 -1
  461. package/dist/planner-sql-checks-CFgbRTJw.d.mts +0 -20
  462. package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +0 -1
  463. package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs +0 -152
  464. package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs.map +0 -1
  465. package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +0 -1
  466. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +0 -15
  467. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +0 -1
  468. package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +0 -1
  469. package/dist/postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs.map +0 -1
  470. package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +0 -1
  471. package/dist/postgres-migration-BNsrwlxh-CwI5BqAu.d.mts.map +0 -1
  472. package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs +0 -205
  473. package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs.map +0 -1
  474. package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +0 -1
  475. package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +0 -1
  476. package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +0 -1
  477. package/dist/postgres-schema-CF0yHESb-D7n2X21R.mjs.map +0 -1
  478. package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +0 -1
  479. package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +0 -1
  480. package/dist/render-ops-DOsRP0Po-BKn_c_Ia.mjs.map +0 -1
  481. package/dist/render-ops-DPwhZt2W.d.mts.map +0 -1
  482. package/dist/render-typescript-6sCFvMBh.d.mts.map +0 -1
  483. package/dist/render-typescript-Dqp1Spgn-B128r1qw.mjs.map +0 -1
  484. package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs +0 -22
  485. package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs.map +0 -1
  486. package/dist/runtime-DOXznQe0.d.mts.map +0 -1
  487. package/dist/runtime-_TfO66h5.d.mts.map +0 -1
  488. package/dist/runtime-lHBKgjB9.d.mts.map +0 -1
  489. package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +0 -1
  490. package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +0 -1
  491. package/dist/sql-renderer-BgC0ZgLS.d.mts.map +0 -1
  492. package/dist/sql-renderer-ComgusFq-BBlqM1fw.mjs.map +0 -1
  493. package/dist/sql-utils-DW6fkczF.d.mts.map +0 -1
  494. package/dist/sql-utils-DuzN3JZg-DiXy4Vah.mjs.map +0 -1
  495. package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +0 -1
  496. package/dist/types-B-4d5_4a.d.mts +0 -1
  497. package/dist/types-CjGjPLr5.d.mts.map +0 -1
  498. package/dist/types-CkryN1AS-BcQRGsDn.d.mts +0 -27
  499. package/dist/types-CkryN1AS-BcQRGsDn.d.mts.map +0 -1
  500. package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +0 -1
  501. /package/dist/{adapter__operation-types.mjs → target__operation-types.mjs} +0 -0
@@ -1,1459 +0,0 @@
1
- import { n as postgresError } from "./errors-DKjQzNaN-DFcF1thx.mjs";
2
- import { n as postgresResolveDefault } from "./default-normalizer-Ba5ZebHM-isV86rjy.mjs";
3
- import { t as postgresRenderCheckExpressions } from "./check-expressions-5vhxWaFy-CBcjFeur.mjs";
4
- import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-rilAH3ep-dAmiVLpe.mjs";
5
- import { a as postgresDiffSubjectGranularity, i as postgresDiffSubjectEntityKind } from "./postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs";
6
- import { t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs";
7
- import { r as renderDefaultLiteral } from "./planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs";
8
- import { n as contractToPostgresDatabaseSchemaNode, r as diffPostgresSchema } from "./diff-database-schema-DKq76rCk-uehceHYz.mjs";
9
- import { t as PostgresContractSerializer } from "./postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs";
10
- import { t as createPostgresMigrationPlanner } from "./planner-D0uogzvT-1WyGIC5p.mjs";
11
- import { blindCast } from "@prisma/orm-framework/utils/casts";
12
- import { UNBOUND_NAMESPACE_ID, coordinateKey, elementCoordinates } from "@prisma/orm-framework/components/ir";
13
- import { ifDefined } from "@prisma/orm-framework/utils/defined";
14
- import { composeCheckWirePrefix, computeCheckContentHash, computeIndexContentHash, formatWireName, parseWireName } from "@prisma/orm-family-sql/schema-ir/naming";
15
- import { assertDefined } from "@prisma/orm-framework/utils/assertions";
16
- import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
17
- import { buildNativeTypeExpander, runnerFailure, runnerSuccess } from "@prisma/orm-family-sql/family/control";
18
- import { SqlSchemaIR, SqlTableIR } from "@prisma/orm-family-sql/schema-ir/types";
19
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
20
- import { notOk, ok, okVoid } from "@prisma/orm-framework/utils/result";
21
- import { SqlSchemaVerifierBase } from "@prisma/orm-family-sql/family/ir";
22
- import { SqlQueryError } from "@prisma/orm-family-sql/errors";
23
- import { buildChildRelationField, deriveRelationFieldName, inferRelations, mapDefault, parseRawDefault, toEnumMemberName, toEnumName, toFieldName, toModelName } from "@prisma/orm-family-sql/family/psl-infer";
24
- import { UNSPECIFIED_PSL_NAMESPACE_ID, makePslNamespace, makePslNamespaceEntries } from "@prisma/orm-framework/components/psl-ast";
25
- import { isColumnDefault } from "@prisma/orm-framework/contract/types";
26
- //#region ../../../3-targets/3-targets/postgres/dist/control.mjs
27
- const LOCK_DOMAIN = "prisma_next.contract.marker";
28
- /**
29
- * Deep clones and freezes a record object to prevent mutation.
30
- * Recursively clones nested objects and arrays to ensure complete isolation.
31
- */
32
- function cloneAndFreezeRecord(value) {
33
- const cloned = {};
34
- for (const [key, val] of Object.entries(value)) if (val === null || val === void 0) cloned[key] = val;
35
- else if (Array.isArray(val)) cloned[key] = Object.freeze([...val]);
36
- else if (typeof val === "object") cloned[key] = cloneAndFreezeRecord(val);
37
- else cloned[key] = val;
38
- return Object.freeze(cloned);
39
- }
40
- function createPostgresMigrationRunner(family) {
41
- return new PostgresMigrationRunner(family);
42
- }
43
- var PostgresMigrationRunner = class {
44
- family;
45
- constructor(family) {
46
- this.family = family;
47
- }
48
- /**
49
- * Body of the migration runner without transaction management. The
50
- * caller ({@link PostgresMigrationRunner.execute}) owns the
51
- * `BEGIN`/`COMMIT`/`ROLLBACK` lifecycle.
52
- */
53
- async executeOnConnection(options) {
54
- const schema = options.schemaName ?? Object.keys(options.destinationContract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;
55
- const driver = options.driver;
56
- if (options.space !== void 0 && options.space !== options.plan.spaceId) throw postgresError("MIGRATION.CONTRACT_SPACE_VIOLATION", `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`, { meta: {
57
- space: options.space,
58
- planSpaceId: options.plan.spaceId
59
- } });
60
- const space = options.plan.spaceId;
61
- const lockKey = `${LOCK_DOMAIN}:${schema}:${space}`;
62
- const planOps = blindCast(await Promise.all(options.plan.operations));
63
- const destinationCheck = this.ensurePlanMatchesDestinationContract(options.plan.destination, options.destinationContract);
64
- if (!destinationCheck.ok) return destinationCheck;
65
- const policyCheck = this.enforcePolicyCompatibility(options.policy, planOps);
66
- if (!policyCheck.ok) return policyCheck;
67
- await this.acquireLock(driver, lockKey);
68
- const ensureResult = await this.ensureControlTables(driver, options.destinationContract);
69
- if (!ensureResult.ok) return ensureResult;
70
- const existingMarker = await this.family.readMarker({
71
- driver,
72
- space
73
- });
74
- const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);
75
- if (!markerCheck.ok) return markerCheck;
76
- const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);
77
- const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;
78
- const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;
79
- let applyValue;
80
- if (skipOperations) applyValue = {
81
- operationsExecuted: 0,
82
- executedOperations: []
83
- };
84
- else {
85
- const applyResult = await this.applyPlan(driver, options, planOps);
86
- if (!applyResult.ok) return applyResult;
87
- applyValue = applyResult.value;
88
- }
89
- if (space === APP_SPACE_ID) {
90
- const schemaNode = await this.family.introspect({
91
- driver,
92
- contract: options.destinationContract
93
- });
94
- const schemaVerifyResult = this.family.verifySchema({
95
- contract: options.destinationContract,
96
- schema: schemaNode,
97
- strict: options.strictVerification ?? true,
98
- frameworkComponents: options.frameworkComponents
99
- });
100
- if (!schemaVerifyResult.ok) return runnerFailure("MIGRATION.SCHEMA_VERIFY_FAILED", schemaVerifyResult.summary, {
101
- why: "The resulting database schema does not satisfy the destination contract.",
102
- meta: { issues: schemaVerifyResult.schema.issues }
103
- });
104
- }
105
- const incomingInvariants = options.plan.providedInvariants ?? [];
106
- const existingInvariants = new Set(existingMarker?.invariants ?? []);
107
- const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));
108
- if (!(isSelfEdge && applyValue.operationsExecuted === 0 && incomingIsSubsetOfExisting)) {
109
- const markerResult = await this.upsertMarker(driver, options, existingMarker, space);
110
- if (!markerResult.ok) return markerResult;
111
- await this.recordLedgerEntries(driver, options, applyValue.executedOperations, planOps.length);
112
- }
113
- return runnerSuccess({
114
- operationsPlanned: planOps.length,
115
- operationsExecuted: applyValue.operationsExecuted
116
- });
117
- }
118
- async execute(options) {
119
- const driver = options.driver;
120
- const perSpaceOptions = options.perSpaceOptions;
121
- if (perSpaceOptions.length === 0) return ok({ perSpaceResults: [] });
122
- await this.beginTransaction(driver);
123
- let committed = false;
124
- try {
125
- const perSpaceResults = [];
126
- for (const spaceOptions of perSpaceOptions) {
127
- const space = spaceOptions.space ?? spaceOptions.plan.spaceId;
128
- const result = await this.executeOnConnection({
129
- ...spaceOptions,
130
- driver,
131
- space
132
- });
133
- if (!result.ok) return notOk({
134
- ...result.failure,
135
- failingSpace: space
136
- });
137
- perSpaceResults.push({
138
- space,
139
- value: result.value
140
- });
141
- }
142
- await this.commitTransaction(driver);
143
- committed = true;
144
- return ok({ perSpaceResults });
145
- } finally {
146
- if (!committed) await this.rollbackTransaction(driver);
147
- }
148
- }
149
- async applyPlan(driver, options, ops) {
150
- const checks = options.executionChecks;
151
- const runPrechecks = checks?.prechecks !== false;
152
- const runPostchecks = checks?.postchecks !== false;
153
- const runIdempotency = checks?.idempotencyChecks !== false;
154
- let operationsExecuted = 0;
155
- const executedOperations = [];
156
- for (const operation of ops) {
157
- options.callbacks?.onOperationStart?.(operation);
158
- try {
159
- if (runPostchecks && runIdempotency) {
160
- if (await this.expectationsAreSatisfied(driver, operation.postcheck)) {
161
- executedOperations.push(this.createPostcheckPreSatisfiedSkipRecord(operation));
162
- continue;
163
- }
164
- }
165
- if (runPrechecks) {
166
- const precheckResult = await this.runExpectationSteps(driver, operation.precheck, operation, "precheck");
167
- if (!precheckResult.ok) return precheckResult;
168
- }
169
- const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);
170
- if (!executeResult.ok) return executeResult;
171
- if (runPostchecks) {
172
- const postcheckResult = await this.runExpectationSteps(driver, operation.postcheck, operation, "postcheck");
173
- if (!postcheckResult.ok) return postcheckResult;
174
- }
175
- executedOperations.push(operation);
176
- operationsExecuted += 1;
177
- } finally {
178
- options.callbacks?.onOperationComplete?.(operation);
179
- }
180
- }
181
- return ok({
182
- operationsExecuted,
183
- executedOperations
184
- });
185
- }
186
- async ensureControlTables(driver, contract) {
187
- const lowererContext = { contract };
188
- const [schemaQuery, ...tableQueries] = this.family.bootstrapControlTableQueries();
189
- if (schemaQuery === void 0) throw new InternalError("Postgres control-table bootstrap must include CREATE SCHEMA");
190
- await this.executeStatement(driver, await this.family.lowerAst(schemaQuery, lowererContext));
191
- const legacyDetection = await this.detectLegacyMarkerShape(driver);
192
- if (!legacyDetection.ok) return legacyDetection;
193
- for (const query of tableQueries) await this.executeStatement(driver, await this.family.lowerAst(query, lowererContext));
194
- return okVoid();
195
- }
196
- async detectLegacyMarkerShape(driver) {
197
- const result = await driver.query(`select column_name
198
- from information_schema.columns
199
- where table_schema = 'prisma_contract'
200
- and table_name = 'marker'`);
201
- if (result.rows.length === 0) return okVoid();
202
- const columns = new Set(result.rows.map((row) => row.column_name));
203
- if (columns.has("space")) return okVoid();
204
- return runnerFailure("MIGRATION.LEGACY_MARKER_SHAPE", "Legacy marker-table shape detected on prisma_contract.marker (no `space` column). Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop `prisma_contract.marker` and re-run `dbInit` to reinitialise from a clean baseline.", { meta: {
205
- table: "prisma_contract.marker",
206
- columns: [...columns].sort()
207
- } });
208
- }
209
- async runExpectationSteps(driver, steps, operation, phase) {
210
- for (const step of steps) {
211
- const result = await driver.query(step.sql, step.params ?? []);
212
- if (!this.stepResultIsTrue(result.rows)) return runnerFailure(phase === "precheck" ? "MIGRATION.PRECHECK_FAILED" : "MIGRATION.POSTCHECK_FAILED", `Operation ${operation.id} failed during ${phase}: ${step.description}`, { meta: {
213
- operationId: operation.id,
214
- phase,
215
- stepDescription: step.description
216
- } });
217
- }
218
- return okVoid();
219
- }
220
- async runExecuteSteps(driver, steps, operation) {
221
- for (const step of steps) try {
222
- await driver.query(step.sql, step.params ?? []);
223
- } catch (error) {
224
- if (SqlQueryError.is(error)) return runnerFailure("MIGRATION.EXECUTION_FAILED", `Operation ${operation.id} failed during execution: ${step.description}`, {
225
- why: error.message,
226
- meta: {
227
- operationId: operation.id,
228
- stepDescription: step.description,
229
- sql: step.sql,
230
- sqlState: error.sqlState,
231
- constraint: error.constraint,
232
- table: error.table,
233
- column: error.column,
234
- detail: error.detail
235
- }
236
- });
237
- throw error;
238
- }
239
- return okVoid();
240
- }
241
- stepResultIsTrue(rows) {
242
- if (!rows || rows.length === 0) return false;
243
- const firstRow = rows[0];
244
- const firstValue = firstRow ? Object.values(firstRow)[0] : void 0;
245
- if (typeof firstValue === "boolean") return firstValue;
246
- if (typeof firstValue === "number") return firstValue !== 0;
247
- if (typeof firstValue === "string") {
248
- const lower = firstValue.toLowerCase();
249
- if (lower === "t" || lower === "true" || lower === "1") return true;
250
- if (lower === "f" || lower === "false" || lower === "0") return false;
251
- return firstValue.length > 0;
252
- }
253
- return Boolean(firstValue);
254
- }
255
- async expectationsAreSatisfied(driver, steps) {
256
- if (steps.length === 0) return false;
257
- for (const step of steps) {
258
- const result = await driver.query(step.sql, step.params ?? []);
259
- if (!this.stepResultIsTrue(result.rows)) return false;
260
- }
261
- return true;
262
- }
263
- createPostcheckPreSatisfiedSkipRecord(operation) {
264
- const clonedMeta = operation.meta ? cloneAndFreezeRecord(operation.meta) : void 0;
265
- const runnerMeta = Object.freeze({
266
- skipped: true,
267
- reason: "postcheck_pre_satisfied"
268
- });
269
- const mergedMeta = Object.freeze({
270
- ...clonedMeta ?? {},
271
- runner: runnerMeta
272
- });
273
- const frozenPostcheck = Object.freeze([...operation.postcheck]);
274
- return Object.freeze({
275
- id: operation.id,
276
- label: operation.label,
277
- ...ifDefined("summary", operation.summary),
278
- operationClass: operation.operationClass,
279
- target: operation.target,
280
- precheck: Object.freeze([]),
281
- execute: Object.freeze([]),
282
- postcheck: frozenPostcheck,
283
- ...ifDefined("meta", operation.meta || mergedMeta ? mergedMeta : void 0)
284
- });
285
- }
286
- markerMatchesDestination(marker, plan) {
287
- if (!marker) return false;
288
- if (marker.storageHash !== plan.destination.storageHash) return false;
289
- if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) return false;
290
- return true;
291
- }
292
- enforcePolicyCompatibility(policy, operations) {
293
- const allowedClasses = new Set(policy.allowedOperationClasses);
294
- for (const operation of operations) if (!allowedClasses.has(operation.operationClass)) return runnerFailure("MIGRATION.POLICY_VIOLATION", `Operation ${operation.id} has class "${operation.operationClass}" which is not allowed by policy.`, {
295
- why: `Policy only allows: ${policy.allowedOperationClasses.join(", ")}.`,
296
- meta: {
297
- operationId: operation.id,
298
- operationClass: operation.operationClass,
299
- allowedClasses: policy.allowedOperationClasses
300
- }
301
- });
302
- return okVoid();
303
- }
304
- ensureMarkerCompatibility(marker, plan) {
305
- const origin = plan.origin ?? null;
306
- if (!origin) return okVoid();
307
- if (!marker) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Missing contract marker: expected origin storage hash ${origin.storageHash}.`, { meta: { expectedOriginStorageHash: origin.storageHash } });
308
- if (marker.storageHash !== origin.storageHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`, { meta: {
309
- markerStorageHash: marker.storageHash,
310
- expectedOriginStorageHash: origin.storageHash
311
- } });
312
- if (origin.profileHash && marker.profileHash !== origin.profileHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`, { meta: {
313
- markerProfileHash: marker.profileHash,
314
- expectedOriginProfileHash: origin.profileHash
315
- } });
316
- return okVoid();
317
- }
318
- ensurePlanMatchesDestinationContract(destination, contract) {
319
- if (destination.storageHash !== contract.storage.storageHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`, { meta: {
320
- planStorageHash: destination.storageHash,
321
- contractStorageHash: contract.storage.storageHash
322
- } });
323
- if (destination.profileHash && contract.profileHash && destination.profileHash !== contract.profileHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`, { meta: {
324
- planProfileHash: destination.profileHash,
325
- contractProfileHash: contract.profileHash
326
- } });
327
- return okVoid();
328
- }
329
- async upsertMarker(driver, options, existingMarker, space) {
330
- const destination = {
331
- storageHash: options.plan.destination.storageHash,
332
- profileHash: options.plan.destination.profileHash ?? options.destinationContract.profileHash ?? options.plan.destination.storageHash,
333
- invariants: options.plan.providedInvariants ?? []
334
- };
335
- if (!existingMarker) {
336
- await this.family.initMarker({
337
- driver,
338
- space,
339
- destination
340
- });
341
- return okVoid();
342
- }
343
- if (!await this.family.updateMarker({
344
- driver,
345
- space,
346
- expectedFrom: existingMarker.storageHash,
347
- destination
348
- })) return runnerFailure("MIGRATION.MARKER_CAS_FAILURE", "Marker was modified by another process during migration execution.", { meta: {
349
- space,
350
- expectedStorageHash: existingMarker.storageHash,
351
- destinationStorageHash: options.plan.destination.storageHash
352
- } });
353
- return okVoid();
354
- }
355
- async recordLedgerEntries(driver, options, executedOperations, planOpsLength) {
356
- const space = options.plan.spaceId;
357
- const edges = options.migrationEdges;
358
- const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);
359
- if (totalEdgeOps !== planOpsLength) throw new InternalError(`Ledger write: plan.operations length (${planOpsLength}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`);
360
- let offset = 0;
361
- for (const edge of edges) {
362
- const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);
363
- offset += edge.operationCount;
364
- await this.family.writeLedgerEntry({
365
- driver,
366
- space,
367
- entry: {
368
- edgeId: `${edge.from}->${edge.to}`,
369
- from: edge.from,
370
- to: edge.to,
371
- migrationName: edge.dirName,
372
- migrationHash: edge.migrationHash,
373
- operations: edgeOps,
374
- ...ifDefined("destinationContractJson", edge.destinationContractJson)
375
- }
376
- });
377
- }
378
- }
379
- async acquireLock(driver, key) {
380
- await driver.query("select pg_advisory_xact_lock(hashtext($1))", [key]);
381
- }
382
- async beginTransaction(driver) {
383
- await driver.query("BEGIN");
384
- }
385
- async commitTransaction(driver) {
386
- await driver.query("COMMIT");
387
- }
388
- async rollbackTransaction(driver) {
389
- await driver.query("ROLLBACK");
390
- }
391
- async executeStatement(driver, statement) {
392
- await driver.query(statement.sql, statement.params);
393
- }
394
- };
395
- /**
396
- * Postgres target `SchemaVerifier` concretion. Plugs into the
397
- * SQL-shared verification surface; production verification today still
398
- * routes through the family verify verdict (`verifySqlSchemaByDiff` over
399
- * `diffPostgresSchema`), which carries options (codec hooks,
400
- * normalizers, framework components) that the framework-level
401
- * `SchemaVerifyOptions` shape does not yet surface.
402
- *
403
- * The hooks return the empty list pending the call-site migration that
404
- * routes the existing verifier behaviour through the SPI — at that
405
- * point `verifyCommonSqlSchema` will likely lift onto the family base
406
- * (mirroring `verifyCommonMongoSchema`) and `verifyTargetExtensions`
407
- * will house Postgres-only kinds (functions, RLS policies in a future
408
- * project).
409
- */
410
- var PostgresSchemaVerifier = class extends SqlSchemaVerifierBase {
411
- verifyCommonSqlSchema(_options) {
412
- return [];
413
- }
414
- verifyTargetExtensions(_options) {
415
- return [];
416
- }
417
- };
418
- function buildFieldNamesByTable(tables) {
419
- const fieldNamesByTable = /* @__PURE__ */ new Map();
420
- for (const table of Object.values(tables)) {
421
- const assignmentOrder = [...Object.values(table.columns).map((column, index) => {
422
- const { name, map } = toFieldName(column.name);
423
- return {
424
- columnName: column.name,
425
- desiredFieldName: name,
426
- fieldMap: map,
427
- index
428
- };
429
- })].sort((left, right) => {
430
- const mapComparison = Number(left.fieldMap !== void 0) - Number(right.fieldMap !== void 0);
431
- if (mapComparison !== 0) return mapComparison;
432
- return left.index - right.index;
433
- });
434
- const usedFieldNames = /* @__PURE__ */ new Set();
435
- const tableFieldNames = /* @__PURE__ */ new Map();
436
- for (const column of assignmentOrder) {
437
- const fieldName = createUniqueFieldName(column.desiredFieldName, usedFieldNames);
438
- usedFieldNames.add(fieldName);
439
- tableFieldNames.set(column.columnName, {
440
- fieldName,
441
- fieldMap: column.fieldMap
442
- });
443
- }
444
- fieldNamesByTable.set(table.name, tableFieldNames);
445
- }
446
- return fieldNamesByTable;
447
- }
448
- function resolveColumnFieldName(fieldNamesByTable, tableName, columnName) {
449
- return fieldNamesByTable.get(tableName)?.get(columnName)?.fieldName ?? toFieldName(columnName).name;
450
- }
451
- function createUniqueFieldName(desiredName, usedFieldNames) {
452
- if (!usedFieldNames.has(desiredName)) return desiredName;
453
- let counter = 2;
454
- while (usedFieldNames.has(`${desiredName}${counter}`)) counter++;
455
- return `${desiredName}${counter}`;
456
- }
457
- function buildTopLevelNameMap(sources, normalize, kind, sourceKind) {
458
- const results = /* @__PURE__ */ new Map();
459
- const normalizedToSources = /* @__PURE__ */ new Map();
460
- for (const source of sources) {
461
- const normalized = normalize(source);
462
- results.set(source, normalized);
463
- normalizedToSources.set(normalized.name, [...normalizedToSources.get(normalized.name) ?? [], source]);
464
- }
465
- const duplicates = [...normalizedToSources.entries()].filter(([, conflictingSources]) => conflictingSources.length > 1);
466
- if (duplicates.length > 0) throw postgresError("CONTRACT.NAME_DUPLICATE", `PSL ${kind} name collisions detected:\n${duplicates.map(([normalizedName, conflictingSources]) => `- ${kind} "${normalizedName}" from ${sourceKind}s ${conflictingSources.map((source) => `"${source}"`).join(", ")}`).join("\n")}`, { meta: {
467
- kind,
468
- names: duplicates.map(([normalizedName]) => normalizedName)
469
- } });
470
- return results;
471
- }
472
- function topologicalSort(models, tables, modelNameMap) {
473
- const modelByName = /* @__PURE__ */ new Map();
474
- for (const model of models) modelByName.set(model.name, model);
475
- const deps = /* @__PURE__ */ new Map();
476
- const tableToModel = /* @__PURE__ */ new Map();
477
- for (const tableName of Object.keys(tables)) {
478
- const modelName = modelNameMap.get(tableName);
479
- assertDefined(modelName, `topologicalSort: no model name mapped for table "${tableName}"`);
480
- tableToModel.set(tableName, modelName);
481
- deps.set(modelName, /* @__PURE__ */ new Set());
482
- }
483
- for (const [tableName, table] of Object.entries(tables)) {
484
- const modelName = tableToModel.get(tableName);
485
- assertDefined(modelName, `topologicalSort: no model name recorded for table "${tableName}"`);
486
- const modelDeps = deps.get(modelName);
487
- assertDefined(modelDeps, `topologicalSort: no dependency set recorded for model "${modelName}"`);
488
- for (const fk of table.foreignKeys) {
489
- const refModelName = tableToModel.get(fk.referencedTable);
490
- if (refModelName && refModelName !== modelName) modelDeps.add(refModelName);
491
- }
492
- }
493
- const result = [];
494
- const visited = /* @__PURE__ */ new Set();
495
- const visiting = /* @__PURE__ */ new Set();
496
- const sortedNames = [...deps.keys()].sort();
497
- function visit(name) {
498
- if (visited.has(name)) return;
499
- if (visiting.has(name)) return;
500
- visiting.add(name);
501
- const nameDeps = deps.get(name);
502
- assertDefined(nameDeps, `topologicalSort: no dependency set recorded for model "${name}"`);
503
- const sortedDeps = [...nameDeps].sort();
504
- for (const dep of sortedDeps) visit(dep);
505
- visiting.delete(name);
506
- visited.add(name);
507
- const model = modelByName.get(name);
508
- assertDefined(model, `topologicalSort: no model block recorded for "${name}"`);
509
- result.push(model);
510
- }
511
- for (const name of sortedNames) visit(name);
512
- return result;
513
- }
514
- const SYNTHETIC_SPAN = {
515
- start: {
516
- offset: 0,
517
- line: 1,
518
- column: 1
519
- },
520
- end: {
521
- offset: 0,
522
- line: 1,
523
- column: 1
524
- }
525
- };
526
- function buildSimpleConstraintFieldAttribute(name, constraintName) {
527
- if (constraintName === void 0) return buildAttribute("field", name, []);
528
- return buildAttribute("field", name, [namedArg("map", `"${escapePslString(constraintName)}"`)]);
529
- }
530
- function parseDefaultAttributeString(attributeText) {
531
- return buildAttribute("field", "default", [positionalArg(attributeText.replace(/^@default\(/, "").replace(/\)$/, ""))]);
532
- }
533
- function buildMapAttribute(target, mapName) {
534
- return buildAttribute(target, "map", [positionalArg(`"${escapePslString(mapName)}"`)]);
535
- }
536
- function buildAttribute(target, name, args) {
537
- return {
538
- kind: "attribute",
539
- target,
540
- name,
541
- args,
542
- span: SYNTHETIC_SPAN
543
- };
544
- }
545
- function positionalArg(value) {
546
- return {
547
- kind: "positional",
548
- value,
549
- span: SYNTHETIC_SPAN
550
- };
551
- }
552
- function namedArg(name, value) {
553
- return {
554
- kind: "named",
555
- name,
556
- value,
557
- span: SYNTHETIC_SPAN
558
- };
559
- }
560
- function escapePslString(value) {
561
- return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
562
- }
563
- /**
564
- * Formats a resolved literal-default array as PSL literal-list syntax
565
- * (`[1, 2, 3]`, `["a", "b"]`, `[]`). PSL's list-literal grammar only accepts
566
- * string/number/boolean elements, so any other element (e.g. `null`, a
567
- * nested array/object) makes the value unrepresentable and this returns
568
- * `undefined`.
569
- */
570
- function formatPslListLiteralValue(elements) {
571
- const parts = [];
572
- for (const element of elements) if (typeof element === "string") parts.push(`"${escapePslString(element)}"`);
573
- else if (typeof element === "number" || typeof element === "boolean") parts.push(String(element));
574
- else return;
575
- return `[${parts.join(", ")}]`;
576
- }
577
- /**
578
- * Resolves a `SqlColumnIR.default` value into a normalized {@link ColumnDefault}.
579
- *
580
- * `SqlSchemaIR` types the column default as `string` (a raw database default
581
- * expression). Some legacy fixtures and tests still pass already-normalized
582
- * `ColumnDefault` objects in the same slot, so we accept either shape
583
- * defensively at runtime.
584
- */
585
- function parseColumnDefault(value, nativeType, rawDefaultParser) {
586
- if (typeof value === "string") return rawDefaultParser ? rawDefaultParser(value, nativeType) : void 0;
587
- return isColumnDefault(value) ? value : void 0;
588
- }
589
- const PSL_SCALAR_TYPE_NAMES = /* @__PURE__ */ new Set([
590
- "String",
591
- "Boolean",
592
- "Int",
593
- "BigInt",
594
- "Float",
595
- "Decimal",
596
- "DateTime",
597
- "Json",
598
- "Bytes"
599
- ]);
600
- /**
601
- * Builds one `native_enum` extension-block AST node per introspected enum
602
- * definition. Block names go through the shared top-level transform
603
- * (`toEnumName`, intra-enum collisions throw like model collisions) and are
604
- * then reserved against the model names — an enum whose PSL name a model
605
- * already claims gets a numeric suffix, with `@@map` carrying the real type
606
- * name. Members print as explicit `member = "value"` pairs: the member name
607
- * is the sanitized value (deduplicated within the block), the JSON-encoded
608
- * value carries the truth verbatim.
609
- */
610
- function buildNativeEnumBlocks(definitions, modelNames) {
611
- const enumNames = buildTopLevelNameMap([...definitions.keys()].sort(), toEnumName, "enum", "enum type");
612
- const usedTopLevelNames = new Set(PSL_SCALAR_TYPE_NAMES);
613
- for (const result of modelNames.values()) usedTopLevelNames.add(result.name);
614
- const enumNameMap = /* @__PURE__ */ new Map();
615
- const enumBlocks = [];
616
- for (const [typeName, result] of enumNames) {
617
- const name = createUniqueFieldName(result.name, usedTopLevelNames);
618
- usedTopLevelNames.add(name);
619
- enumNameMap.set(typeName, name);
620
- enumBlocks.push(buildNativeEnumBlock(name, typeName, definitions.get(typeName) ?? []));
621
- }
622
- return {
623
- enumNameMap,
624
- enumBlocks
625
- };
626
- }
627
- function buildNativeEnumBlock(name, typeName, values) {
628
- const usedMemberNames = /* @__PURE__ */ new Set();
629
- const parameters = {};
630
- for (const value of values) {
631
- const memberName = createUniqueFieldName(toEnumMemberName(value), usedMemberNames);
632
- usedMemberNames.add(memberName);
633
- parameters[memberName] = {
634
- kind: "value",
635
- raw: JSON.stringify(value),
636
- span: SYNTHETIC_SPAN
637
- };
638
- }
639
- return {
640
- kind: "native_enum",
641
- keyword: "native_enum",
642
- name,
643
- parameters,
644
- blockAttributes: name === typeName ? [] : [{
645
- name: "map",
646
- args: [{
647
- kind: "positional",
648
- value: `"${escapePslString(typeName)}"`,
649
- span: SYNTHETIC_SPAN
650
- }],
651
- span: SYNTHETIC_SPAN
652
- }],
653
- span: SYNTHETIC_SPAN
654
- };
655
- }
656
- /**
657
- * Coordinates every element a set of already-assembled contracts declare,
658
- * mapped to the {@link SqlDescribedContractSpace} that owns it and keyed by
659
- * the shared {@link coordinateKey} helper. `contract infer` uses this to omit
660
- * database elements a stack extension pack's contract space already
661
- * describes — reusing the same coordinate walk the contract-space aggregate
662
- * and cross-space collision check use (`elementCoordinates`), rather than a
663
- * bespoke per-entity-kind membership test — and, for a foreign key whose
664
- * referenced table an entry owns, to resolve the qualified cross-space
665
- * relation it describes.
666
- */
667
- function describedContractOwners(describedContracts) {
668
- const owners = /* @__PURE__ */ new Map();
669
- for (const entry of describedContracts) for (const coordinate of elementCoordinates(entry.contract.storage)) owners.set(coordinateKey(coordinate), entry);
670
- return owners;
671
- }
672
- function resolveCrossSpaceTarget(owner, namespaceId, tableName) {
673
- const domainNamespace = owner.contract.domain.namespaces[namespaceId];
674
- if (domainNamespace === void 0) return;
675
- for (const [modelName, model] of Object.entries(domainNamespace.models)) {
676
- const storage = blindCast(model.storage);
677
- if (storage.namespaceId !== namespaceId || storage.table !== tableName) continue;
678
- const fieldNamesByColumn = /* @__PURE__ */ new Map();
679
- for (const [fieldName, fieldStorage] of Object.entries(storage.fields)) fieldNamesByColumn.set(fieldStorage.column, { fieldName });
680
- return {
681
- spaceId: owner.spaceId,
682
- namespaceId,
683
- modelName,
684
- fieldNamesByColumn
685
- };
686
- }
687
- }
688
- /**
689
- * Classifies every foreign key on a surviving table into one of three cases.
690
- * A foreign key that carries a `referencedSchema` is checked against the
691
- * pack-owned coordinates first, so a pack-owned target wins even when a local
692
- * table happens to share its bare name; only foreign keys with no owned
693
- * coordinate fall through to the local/dangling distinction.
694
- *
695
- * - **Cross-space**: `referencedSchema` is set and a described contract owns
696
- * the coordinate `(referencedSchema, 'table', referencedTable)`. The
697
- * referenced table is absent from the tree (omitted because the pack
698
- * describes it, or never introspected — `contract infer` walks a single
699
- * namespace). Removed from `foreignKeys` (so `inferRelations` never falls
700
- * back to a bare, unqualified table name for it) and replaced with a
701
- * `RelationField` qualified with the owning pack's space id and namespace
702
- * id. `owners` holds only pack-declared coordinates, so an app's own table
703
- * (e.g. `public.users`) is never owned and cannot be captured here.
704
- * - **Local**: not a pack-owned coordinate, and the referenced table survived
705
- * introspection — left untouched, `inferRelations` handles it as before.
706
- * - **Dangling**: not a pack-owned coordinate, and the referenced table is
707
- * neither in the tree nor owned by any described contract. Removed from
708
- * `foreignKeys`, keeping the scalar column, rather than emitting a relation
709
- * to a model that was never defined.
710
- *
711
- * A pack that owns the referenced coordinate but declares no domain model
712
- * mapped to it is malformed; that case throws rather than degrading to a
713
- * silent drop, which would contradict the dangling definition above.
714
- */
715
- function resolveForeignKeys(tables, owners) {
716
- const resultTables = {};
717
- const extraRelationsByTable = /* @__PURE__ */ new Map();
718
- const crossSpaceFieldNamesByTable = /* @__PURE__ */ new Map();
719
- const danglingForeignKeysByTable = /* @__PURE__ */ new Map();
720
- for (const [tableName, table] of Object.entries(tables)) {
721
- const keptForeignKeys = [];
722
- for (const fk of table.foreignKeys) {
723
- if (fk.referencedSchema !== void 0) {
724
- const owner = owners.get(coordinateKey({
725
- namespaceId: fk.referencedSchema,
726
- entityKind: "table",
727
- entityName: fk.referencedTable
728
- }));
729
- if (owner !== void 0) {
730
- const target = resolveCrossSpaceTarget(owner, fk.referencedSchema, fk.referencedTable);
731
- if (target === void 0) throw postgresError("CONTRACT.PACK_CONTRIBUTION_INVALID", `contract infer: described contract space "${owner.spaceId}" owns storage coordinate "${fk.referencedSchema}.${fk.referencedTable}" but declares no domain model mapped to it. A pack that describes a table must also declare the domain model it maps to; this pack is malformed.`, { meta: {
732
- spaceId: owner.spaceId,
733
- tableName: fk.referencedTable
734
- } });
735
- if (!crossSpaceFieldNamesByTable.has(fk.referencedTable)) crossSpaceFieldNamesByTable.set(fk.referencedTable, target.fieldNamesByColumn);
736
- const fieldName = deriveRelationFieldName(fk.columns, fk.referencedTable);
737
- const optional = fk.columns.some((columnName) => table.columns[columnName]?.nullable ?? false);
738
- const relationField = {
739
- ...buildChildRelationField(fieldName, target.modelName, fk, optional, void 0, table),
740
- typeNamespaceId: target.namespaceId,
741
- typeContractSpaceId: target.spaceId
742
- };
743
- const existingRelations = extraRelationsByTable.get(tableName);
744
- if (existingRelations) existingRelations.push(relationField);
745
- else extraRelationsByTable.set(tableName, [relationField]);
746
- continue;
747
- }
748
- }
749
- if (tables[fk.referencedTable] !== void 0) keptForeignKeys.push(fk);
750
- else {
751
- const dangling = {
752
- columns: fk.columns,
753
- referencedSchema: fk.referencedSchema,
754
- referencedTable: fk.referencedTable
755
- };
756
- const existingDangling = danglingForeignKeysByTable.get(tableName);
757
- if (existingDangling) existingDangling.push(dangling);
758
- else danglingForeignKeysByTable.set(tableName, [dangling]);
759
- }
760
- }
761
- resultTables[tableName] = keptForeignKeys.length === table.foreignKeys.length ? table : new SqlTableIR({
762
- ...table,
763
- foreignKeys: keptForeignKeys
764
- });
765
- }
766
- return {
767
- tables: resultTables,
768
- extraRelationsByTable,
769
- crossSpaceFieldNamesByTable,
770
- danglingForeignKeysByTable
771
- };
772
- }
773
- /**
774
- * Explains a foreign key `resolveForeignKeys` dropped as dangling: the
775
- * database enforces it, but its target lives outside the introspected
776
- * schema, so infer has no model to point a relation at. The suggested fix
777
- * targets the common cause — an unconfigured extension pack's schema
778
- * (e.g. Supabase's `auth`).
779
- */
780
- function buildDanglingForeignKeyWarning(danglingForeignKeys, fieldNamesByTable, tableName) {
781
- return `Foreign key ${danglingForeignKeys.map((fk) => {
782
- const fieldNames = fk.columns.map((columnName) => resolveColumnFieldName(fieldNamesByTable, tableName, columnName));
783
- const target = fk.referencedSchema !== void 0 ? `${fk.referencedSchema}.${fk.referencedTable}` : fk.referencedTable;
784
- return `"${fieldNames.join(", ")}" -> "${target}"`;
785
- }).join(", ")} exists in the database, but its target schema is outside the introspected scope, so no relation field was generated. If the target schema is described by an extension pack, add it to extensions and re-run infer.`;
786
- }
787
- function buildModelConstraintAttribute(name, fields, constraintName) {
788
- const args = [positionalArg(`[${fields.join(", ")}]`)];
789
- if (constraintName !== void 0) args.push(namedArg("map", `"${escapePslString(constraintName)}"`));
790
- return buildAttribute("model", name, args);
791
- }
792
- /**
793
- * Emits one `@@index` attribute at full fidelity. The index's identity is
794
- * re-detected rather than trusted: `name:` is emitted only when the live name
795
- * parses as a wire name AND that hash recomputes from the introspected
796
- * content; otherwise the live name is adopted verbatim with `map:`.
797
- */
798
- function buildIndexAttribute(index, fieldNames) {
799
- const args = [];
800
- if (fieldNames !== void 0) args.push(positionalArg(`[${fieldNames.join(", ")}]`));
801
- else {
802
- assertDefined(index.expression, `buildIndexAttribute: index "${index.name}" carries neither columns nor expression; SqlIndexIR enforces exactly one`);
803
- args.push(namedArg("expression", `"${escapePslString(index.expression)}"`));
804
- }
805
- const parsed = parseWireName(index.name);
806
- const recomputed = computeIndexContentHash({
807
- ...index.columns !== void 0 ? { columns: index.columns } : {},
808
- ...index.expression !== void 0 ? { expression: index.expression } : {},
809
- ...index.where !== void 0 ? { where: index.where } : {},
810
- unique: index.unique,
811
- ...index.type !== void 0 ? { type: index.type } : {},
812
- ...index.options !== void 0 ? { options: index.options } : {}
813
- });
814
- if (parsed !== void 0 && parsed.hash === recomputed) args.push(namedArg("name", `"${escapePslString(parsed.prefix)}"`));
815
- else args.push(namedArg("map", `"${escapePslString(index.name)}"`));
816
- if (index.where !== void 0) args.push(namedArg("where", `"${escapePslString(index.where)}"`));
817
- if (index.unique) args.push(namedArg("unique", "true"));
818
- const hasOptions = index.options !== void 0 && Object.keys(index.options).length > 0;
819
- if (index.type !== void 0 || hasOptions) args.push(namedArg("type", `"${escapePslString(index.type ?? "btree")}"`));
820
- if (hasOptions) {
821
- const entries = Object.entries(index.options ?? {}).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, value]) => `${key}: "${escapePslString(String(value))}"`);
822
- args.push(namedArg("options", `{ ${entries.join(", ")} }`));
823
- }
824
- return buildAttribute("model", "index", args);
825
- }
826
- /**
827
- * Emits one `@@check` attribute for a live, non-derived check, always in the
828
- * `map:` form. Re-detecting `name:` is not attempted: the live expression is
829
- * Postgres's own reprint, but a wire-named check's hash was taken over the
830
- * author's original text, so recomputing the hash from the reprint would
831
- * essentially never match. `map:` plus the verbatim reprint is correct
832
- * regardless — a reprint compared against a later reprint of the same
833
- * expression is stable, so the emitted contract signs the live database with
834
- * zero pending operations. `buildPolicyBlocks` makes the same call for
835
- * `@@map` on adopted RLS policies, for the same reason.
836
- */
837
- function buildCheckAttribute(check) {
838
- return buildAttribute("model", "check", [namedArg("expression", `"${escapePslString(check.expression)}"`), namedArg("map", `"${escapePslString(check.name)}"`)]);
839
- }
840
- function buildModel(table, typeMap, enumNameMap, fieldNamesByTable, defaultMapping, rawDefaultParser, relationFields, danglingForeignKeys, rlsEnabled = false, policySkipNotes = []) {
841
- const { name: modelName, map: mapName } = toModelName(table.name);
842
- const fieldNameMap = fieldNamesByTable.get(table.name);
843
- const pkColumns = new Set(table.primaryKey?.columns ?? []);
844
- const isSinglePk = pkColumns.size === 1;
845
- const singlePkConstraintName = isSinglePk ? table.primaryKey?.name : void 0;
846
- const uniqueColumns = /* @__PURE__ */ new Map();
847
- for (const unique of table.uniques) if (unique.columns.length === 1) {
848
- const [columnName = ""] = unique.columns;
849
- const existingConstraintName = uniqueColumns.get(columnName);
850
- if (!uniqueColumns.has(columnName) || existingConstraintName === void 0 && unique.name) uniqueColumns.set(columnName, unique.name);
851
- }
852
- const derivedCheckNames = computeDerivedCheckNames(table);
853
- const fields = [];
854
- for (const column of Object.values(table.columns)) fields.push(buildScalarField(column, table, typeMap, enumNameMap, fieldNameMap, defaultMapping, rawDefaultParser, pkColumns, isSinglePk, singlePkConstraintName, uniqueColumns, derivedCheckNames));
855
- const usedFieldNames = new Set(fields.map((field) => field.name));
856
- for (const rel of relationFields) fields.push(buildRelationField(rel, table.name, fieldNamesByTable, usedFieldNames));
857
- const modelAttributes = [];
858
- if (table.primaryKey && table.primaryKey.columns.length > 1) {
859
- const pkFieldNames = table.primaryKey.columns.map((columnName) => resolveColumnFieldName(fieldNamesByTable, table.name, columnName));
860
- modelAttributes.push(buildModelConstraintAttribute("id", pkFieldNames, table.primaryKey.name));
861
- }
862
- for (const unique of table.uniques) if (unique.columns.length > 1) {
863
- const uniqueFieldNames = unique.columns.map((columnName) => resolveColumnFieldName(fieldNamesByTable, table.name, columnName));
864
- modelAttributes.push(buildModelConstraintAttribute("unique", uniqueFieldNames, unique.name));
865
- }
866
- for (const index of table.indexes) {
867
- const indexFieldNames = index.columns?.map((columnName) => resolveColumnFieldName(fieldNamesByTable, table.name, columnName));
868
- modelAttributes.push(buildIndexAttribute(index, indexFieldNames));
869
- }
870
- for (const check of table.checks ?? []) if (!derivedCheckNames.has(check.name)) modelAttributes.push(buildCheckAttribute(check));
871
- if (mapName) modelAttributes.push(buildMapAttribute("model", mapName));
872
- if (rlsEnabled) modelAttributes.push(buildAttribute("model", "rls", []));
873
- const warnings = [];
874
- if (!table.primaryKey) warnings.push("This table has no primary key in the database");
875
- if (danglingForeignKeys.length > 0) warnings.push(buildDanglingForeignKeyWarning(danglingForeignKeys, fieldNamesByTable, table.name));
876
- const commentLines = [...warnings.length > 0 ? [`// WARNING: ${warnings.join(" ")}`] : [], ...policySkipNotes];
877
- const comment = commentLines.length > 0 ? commentLines.join("\n") : void 0;
878
- return {
879
- kind: "model",
880
- name: modelName,
881
- fields,
882
- attributes: modelAttributes,
883
- span: SYNTHETIC_SPAN,
884
- ...comment !== void 0 ? { comment } : {}
885
- };
886
- }
887
- /**
888
- * The live check names that are derived: a live check's name matches
889
- * `formatWireName(composeCheckWirePrefix(table, column, kind), computeCheckContentHash(expression))`
890
- * for some column of the table and some candidate `postgresRenderCheckExpressions`
891
- * would render for that column. Never by comparing expressions — the live
892
- * body is a Postgres reprint, never the authored text. One set serves both
893
- * the `@noCheck` waiver below and `@@check` exclusion in `buildModel`, so the
894
- * two decisions cannot drift apart.
895
- *
896
- * `membership` is unreachable here today: infer never emits domain enums
897
- * (`enumType()` is not inferred), so no inferred column has member values and
898
- * no membership check is ever derived. The day domain-enum inference exists,
899
- * its slice extends this by threading the column's member values through.
900
- */
901
- function computeDerivedCheckNames(table) {
902
- const liveCheckNames = new Set((table.checks ?? []).map((check) => check.name));
903
- const derivedCheckNames = /* @__PURE__ */ new Set();
904
- for (const column of Object.values(table.columns)) for (const candidate of postgresRenderCheckExpressions({
905
- tableName: table.name,
906
- columnName: column.name,
907
- many: column.many === true,
908
- memberValues: void 0
909
- })) {
910
- const derivedName = formatWireName(composeCheckWirePrefix(table.name, column.name, candidate.kind), computeCheckContentHash(candidate.expression));
911
- if (liveCheckNames.has(derivedName)) derivedCheckNames.add(derivedName);
912
- }
913
- return derivedCheckNames;
914
- }
915
- function buildScalarField(column, table, typeMap, enumNameMap, fieldNameMap, defaultMapping, rawDefaultParser, pkColumns, isSinglePk, singlePkConstraintName, uniqueColumns, derivedCheckNames) {
916
- const resolvedField = fieldNameMap?.get(column.name);
917
- const fieldName = resolvedField?.fieldName ?? toFieldName(column.name).name;
918
- const fieldMap = resolvedField?.fieldMap;
919
- const resolution = typeMap.resolve(column.nativeType, table.annotations);
920
- if ("unsupported" in resolution) {
921
- const attrs = [];
922
- if (fieldMap !== void 0) attrs.push(buildMapAttribute("field", fieldMap));
923
- return {
924
- kind: "field",
925
- name: fieldName,
926
- typeName: `Unsupported("${escapePslString(resolution.nativeType)}")`,
927
- optional: column.nullable,
928
- list: column.many === true,
929
- attributes: attrs,
930
- span: SYNTHETIC_SPAN
931
- };
932
- }
933
- let typeName = resolution.pslType.name;
934
- let typeConstructor = resolution.pslType.args ? {
935
- kind: "typeConstructor",
936
- path: [resolution.pslType.name],
937
- args: resolution.pslType.args.map(positionalArg),
938
- span: SYNTHETIC_SPAN
939
- } : void 0;
940
- const enumPslName = enumNameMap.get(column.nativeType);
941
- if (enumPslName) {
942
- typeName = enumPslName;
943
- typeConstructor = {
944
- kind: "typeConstructor",
945
- path: ["pg", "enum"],
946
- args: [positionalArg(enumPslName)],
947
- span: SYNTHETIC_SPAN
948
- };
949
- }
950
- const attributes = [];
951
- const isId = isSinglePk && pkColumns.has(column.name);
952
- if (isId) attributes.push(buildSimpleConstraintFieldAttribute("id", singlePkConstraintName));
953
- if (column.default === void 0 && column.resolvedDefault?.kind === "function" && column.resolvedDefault.expression === "autoincrement()") attributes.push(parseDefaultAttributeString("@default(autoincrement())"));
954
- else if (column.many === true && column.resolvedDefault?.kind === "literal") {
955
- const formatted = Array.isArray(column.resolvedDefault.value) ? formatPslListLiteralValue(column.resolvedDefault.value) : void 0;
956
- if (formatted !== void 0) attributes.push(parseDefaultAttributeString(`@default(${formatted})`));
957
- } else if (column.default !== void 0) {
958
- const parsed = parseColumnDefault(column.default, column.nativeType, rawDefaultParser);
959
- if (parsed) {
960
- const result = mapDefault(parsed, defaultMapping);
961
- if ("attribute" in result) attributes.push(parseDefaultAttributeString(result.attribute));
962
- }
963
- }
964
- if (uniqueColumns.has(column.name) && !isId) {
965
- const uniqueConstraintName = uniqueColumns.get(column.name);
966
- attributes.push(buildSimpleConstraintFieldAttribute("unique", uniqueConstraintName));
967
- }
968
- if (column.many === true) {
969
- const waivedKinds = postgresRenderCheckExpressions({
970
- tableName: table.name,
971
- columnName: column.name,
972
- many: true,
973
- memberValues: void 0
974
- }).filter((candidate) => !derivedCheckNames.has(formatWireName(composeCheckWirePrefix(table.name, column.name, candidate.kind), computeCheckContentHash(candidate.expression)))).map((candidate) => candidate.kind);
975
- if (waivedKinds.length > 0) attributes.push(buildAttribute("field", "noCheck", waivedKinds.map(positionalArg)));
976
- }
977
- if (fieldMap !== void 0) attributes.push(buildMapAttribute("field", fieldMap));
978
- return {
979
- kind: "field",
980
- name: fieldName,
981
- typeName,
982
- ...ifDefined("typeConstructor", typeConstructor),
983
- optional: column.nullable,
984
- list: column.many === true,
985
- attributes,
986
- span: SYNTHETIC_SPAN
987
- };
988
- }
989
- function buildRelationField(rel, hostTableName, fieldNamesByTable, usedFieldNames) {
990
- const fieldName = createUniqueFieldName(rel.fieldName, usedFieldNames);
991
- usedFieldNames.add(fieldName);
992
- const args = [];
993
- if (rel.fields && rel.references) {
994
- if (rel.relationName) args.push(namedArg("name", `"${escapePslString(rel.relationName)}"`));
995
- args.push(namedArg("fields", `[${rel.fields.map((columnName) => resolveColumnFieldName(fieldNamesByTable, hostTableName, columnName)).join(", ")}]`));
996
- args.push(namedArg("references", `[${rel.references.map((columnName) => resolveColumnFieldName(fieldNamesByTable, rel.referencedTableName ?? "", columnName)).join(", ")}]`));
997
- if (rel.onDelete) args.push(namedArg("onDelete", rel.onDelete));
998
- if (rel.onUpdate) args.push(namedArg("onUpdate", rel.onUpdate));
999
- if (rel.fkName) args.push(namedArg("map", `"${escapePslString(rel.fkName)}"`));
1000
- if (rel.index === false) args.push(namedArg("index", "false"));
1001
- } else if (rel.relationName) args.push(namedArg("name", `"${escapePslString(rel.relationName)}"`));
1002
- const attrs = args.length > 0 ? [buildAttribute("field", "relation", args)] : [];
1003
- return {
1004
- kind: "field",
1005
- name: fieldName,
1006
- typeName: rel.typeName,
1007
- ...ifDefined("typeNamespaceId", rel.typeNamespaceId),
1008
- ...ifDefined("typeContractSpaceId", rel.typeContractSpaceId),
1009
- optional: rel.optional,
1010
- list: rel.list,
1011
- attributes: attrs,
1012
- span: SYNTHETIC_SPAN
1013
- };
1014
- }
1015
- const POLICY_OPERATION_KEYWORD = {
1016
- select: "policy_select",
1017
- insert: "policy_insert",
1018
- update: "policy_update",
1019
- delete: "policy_delete",
1020
- all: "policy_all"
1021
- };
1022
- /** The PSL tokenizer's identifier grammar: leading letter/underscore, then letters/digits/`_`/`-`. */
1023
- const PSL_IDENTIFIER = /^[\p{L}_][\p{L}\p{N}_-]*$/u;
1024
- /** Replaces invalid character runs with `_`; prepends `_` when the first character is invalid. */
1025
- function sanitizePolicyHead(raw) {
1026
- let head = raw.replace(/[^\p{L}\p{N}_-]+/gu, "_");
1027
- if (!/^[\p{L}_]/u.test(head)) head = `_${head}`;
1028
- return head;
1029
- }
1030
- /**
1031
- * Builds one `policy_<operation>` block per introspected policy. Every
1032
- * adopted policy is exact-named: a reprinted body never reliably re-hashes to
1033
- * the live suffix, so `@@map` always carries the physical name and the head
1034
- * is only an identifier. A policy granting to a role whose name is not a
1035
- * legal identifier cannot be authored at all — role references have no
1036
- * `@@map` escape — so it is skipped with a note.
1037
- */
1038
- function buildPolicyBlocks(policiesByTable, modelNameMap, reservedHeads = /* @__PURE__ */ new Set()) {
1039
- const all = [];
1040
- for (const [tableName, policies] of policiesByTable) for (const policy of policies) all.push({
1041
- policy,
1042
- tableName
1043
- });
1044
- all.sort((a, b) => {
1045
- if (a.policy.name !== b.policy.name) return a.policy.name < b.policy.name ? -1 : 1;
1046
- if (a.tableName !== b.tableName) return a.tableName < b.tableName ? -1 : 1;
1047
- return a.policy.operation < b.policy.operation ? -1 : a.policy.operation > b.policy.operation ? 1 : 0;
1048
- });
1049
- const usedHeads = new Set(reservedHeads);
1050
- const blocks = [];
1051
- const skipNotesByTable = /* @__PURE__ */ new Map();
1052
- for (const { policy, tableName } of all) {
1053
- const modelName = modelNameMap.get(tableName);
1054
- assertDefined(modelName, `buildPolicyBlocks: policy "${policy.name}" targets table "${tableName}" with no emitted model; tables and policies come from the same introspection walk`);
1055
- const badRole = policy.roles.find((role) => !PSL_IDENTIFIER.test(role));
1056
- if (badRole !== void 0) {
1057
- const notes = skipNotesByTable.get(tableName) ?? [];
1058
- notes.push(`// prisma-next: skipped policy "${policy.name}": role "${badRole}" is not a valid PSL identifier and role references cannot be escaped`);
1059
- skipNotesByTable.set(tableName, notes);
1060
- continue;
1061
- }
1062
- let head = sanitizePolicyHead(parseWireName(policy.name)?.prefix ?? policy.name);
1063
- if (usedHeads.has(head)) {
1064
- let n = 2;
1065
- while (usedHeads.has(`${head}_${n}`)) n += 1;
1066
- head = `${head}_${n}`;
1067
- }
1068
- usedHeads.add(head);
1069
- blocks.push({
1070
- kind: "policy",
1071
- keyword: POLICY_OPERATION_KEYWORD[policy.operation],
1072
- name: head,
1073
- parameters: {
1074
- target: {
1075
- kind: "ref",
1076
- identifier: modelName,
1077
- span: SYNTHETIC_SPAN
1078
- },
1079
- roles: {
1080
- kind: "list",
1081
- items: policy.roles.map((role) => ({
1082
- kind: "ref",
1083
- identifier: role,
1084
- span: SYNTHETIC_SPAN
1085
- })),
1086
- span: SYNTHETIC_SPAN
1087
- },
1088
- ...policy.using !== void 0 ? { using: {
1089
- kind: "value",
1090
- raw: JSON.stringify(policy.using),
1091
- span: SYNTHETIC_SPAN
1092
- } } : {},
1093
- ...policy.withCheck !== void 0 ? { withCheck: {
1094
- kind: "value",
1095
- raw: JSON.stringify(policy.withCheck),
1096
- span: SYNTHETIC_SPAN
1097
- } } : {},
1098
- ...policy.permissive ? {} : { permissive: {
1099
- kind: "value",
1100
- raw: "false",
1101
- span: SYNTHETIC_SPAN
1102
- } }
1103
- },
1104
- blockAttributes: [{
1105
- name: "map",
1106
- args: [{
1107
- kind: "positional",
1108
- value: `"${escapePslString(policy.name)}"`,
1109
- span: SYNTHETIC_SPAN
1110
- }],
1111
- span: SYNTHETIC_SPAN
1112
- }],
1113
- span: SYNTHETIC_SPAN
1114
- });
1115
- }
1116
- return {
1117
- blocks,
1118
- skipNotesByTable
1119
- };
1120
- }
1121
- const POSTGRES_FUNCTION_ATTRIBUTES = { "gen_random_uuid()": "@default(dbgenerated(\"gen_random_uuid()\"))" };
1122
- function formatDbGeneratedAttribute(expression) {
1123
- return `@default(dbgenerated(${JSON.stringify(expression)}))`;
1124
- }
1125
- function createPostgresDefaultMapping() {
1126
- return {
1127
- functionAttributes: POSTGRES_FUNCTION_ATTRIBUTES,
1128
- fallbackFunctionAttribute: formatDbGeneratedAttribute
1129
- };
1130
- }
1131
- const POSTGRES_TO_PSL = {
1132
- text: "String",
1133
- bool: "Boolean",
1134
- boolean: "Boolean",
1135
- int4: "Int",
1136
- integer: "Int",
1137
- int8: "BigInt",
1138
- bigint: "BigInt",
1139
- float8: "Float",
1140
- "double precision": "Float",
1141
- jsonb: "Jsonb",
1142
- bytea: "Bytes"
1143
- };
1144
- const PRESERVED_NATIVE_TYPES = {
1145
- "character varying": "VarChar",
1146
- character: "Char",
1147
- char: "Char",
1148
- varchar: "VarChar",
1149
- uuid: "Uuid",
1150
- inet: "Inet",
1151
- int2: "SmallInt",
1152
- smallint: "SmallInt",
1153
- float4: "Real",
1154
- real: "Real",
1155
- numeric: "Numeric",
1156
- decimal: "Numeric",
1157
- timestamp: "Timestamp",
1158
- "timestamp without time zone": "Timestamp",
1159
- timestamptz: "Timestamptz",
1160
- "timestamp with time zone": "Timestamptz",
1161
- date: "Date",
1162
- time: "Time",
1163
- "time without time zone": "Time",
1164
- timetz: "Timetz",
1165
- "time with time zone": "Timetz",
1166
- json: "Json"
1167
- };
1168
- const PARAMETERIZED_NATIVE_TYPES = {
1169
- "character varying": "VarChar",
1170
- character: "Char",
1171
- char: "Char",
1172
- varchar: "VarChar",
1173
- numeric: "Numeric",
1174
- decimal: "Numeric",
1175
- timestamp: "Timestamp",
1176
- timestamptz: "Timestamptz",
1177
- time: "Time",
1178
- timetz: "Timetz"
1179
- };
1180
- const PARAMETERIZED_TYPE_PATTERN = /^(.+?)\((.+)\)$/;
1181
- function getOwnMappingValue(map, key) {
1182
- return Object.hasOwn(map, key) ? map[key] : void 0;
1183
- }
1184
- function splitTypeParameterList(params) {
1185
- return params.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
1186
- }
1187
- function createPostgresTypeMap(enumTypeNames) {
1188
- return { resolve(nativeType) {
1189
- if (enumTypeNames?.has(nativeType)) return {
1190
- pslType: { name: nativeType },
1191
- nativeType
1192
- };
1193
- const paramMatch = nativeType.match(PARAMETERIZED_TYPE_PATTERN);
1194
- if (paramMatch) {
1195
- const [, baseType = nativeType, params = ""] = paramMatch;
1196
- const typeName = getOwnMappingValue(PARAMETERIZED_NATIVE_TYPES, baseType);
1197
- if (typeName) return {
1198
- pslType: {
1199
- name: typeName,
1200
- args: splitTypeParameterList(params)
1201
- },
1202
- nativeType,
1203
- typeParams: {
1204
- baseType,
1205
- params
1206
- }
1207
- };
1208
- }
1209
- const preservedType = getOwnMappingValue(PRESERVED_NATIVE_TYPES, nativeType);
1210
- if (preservedType) return {
1211
- pslType: { name: preservedType },
1212
- nativeType
1213
- };
1214
- const pslType = getOwnMappingValue(POSTGRES_TO_PSL, nativeType);
1215
- if (pslType) return {
1216
- pslType: { name: pslType },
1217
- nativeType
1218
- };
1219
- return {
1220
- unsupported: true,
1221
- nativeType
1222
- };
1223
- } };
1224
- }
1225
- /**
1226
- * Infers a PSL AST (for `printPsl`) from an introspected Postgres schema tree.
1227
- *
1228
- * Target-owned inference: it walks the `PostgresDatabaseSchemaNode` tree and
1229
- * owns the Postgres dialect knowledge — the native type map and default map.
1230
- * Relation inference, name transforms, generic default mapping, and raw-default
1231
- * parsing are shape-neutral utilities imported from the SQL family.
1232
- *
1233
- * The tree's tables (across its namespaces — `contract infer` introspects a
1234
- * single live namespace) are gathered into the model set and emitted in one
1235
- * bucket, alongside native-enum and RLS policy blocks. That bucket is named
1236
- * after the introspected schema when the content needs a `namespace { … }`
1237
- * wrap, and is the flat `UNSPECIFIED_PSL_NAMESPACE_ID` bucket otherwise. This
1238
- * entry point emits nothing else, so its output is always exactly one bucket
1239
- * and byte-identical to the prior flat inference. {@link buildPslDocumentAst}
1240
- * can emit a second, always-flat bucket for content that must stay top-level
1241
- * even under a wrap; no caller asks for one yet.
1242
- *
1243
- * `describedContracts` — the stack's extension packs' already-assembled
1244
- * contracts, each paired with its space id — is consulted while gathering
1245
- * tables: a table whose coordinate `(schemaName, 'table', tableName)` one of
1246
- * those contracts already declares is omitted, before the duplicate-name
1247
- * check below and before relation inference, so it cannot spuriously
1248
- * collide with an app table and never contributes a bare relation field. A
1249
- * surviving table's foreign key into an omitted, pack-owned table is not
1250
- * dropped: {@link resolveForeignKeys} rewrites it into a relation qualified
1251
- * with the pack's space id (`<spaceId>:<namespaceId>.<Model>`) instead.
1252
- */
1253
- function inferPostgresPslContract(tree, describedContracts) {
1254
- const namespaces = Object.values(tree.namespaces);
1255
- const owners = describedContractOwners(describedContracts ?? []);
1256
- const enumDefinitions = /* @__PURE__ */ new Map();
1257
- const packOwnedEnumTypesByNamespace = /* @__PURE__ */ new Map();
1258
- const enumNamespaceNames = /* @__PURE__ */ new Set();
1259
- for (const namespace of namespaces) for (const { typeName, members } of namespace.nativeEnums) {
1260
- const owner = owners.get(coordinateKey({
1261
- namespaceId: namespace.schemaName,
1262
- entityKind: "native_enum",
1263
- entityName: typeName
1264
- }));
1265
- if (owner !== void 0) {
1266
- const owned = packOwnedEnumTypesByNamespace.get(namespace.schemaName) ?? /* @__PURE__ */ new Map();
1267
- owned.set(typeName, owner.spaceId);
1268
- owned.set(`${namespace.schemaName}.${typeName}`, owner.spaceId);
1269
- packOwnedEnumTypesByNamespace.set(namespace.schemaName, owned);
1270
- continue;
1271
- }
1272
- enumDefinitions.set(typeName, members);
1273
- enumNamespaceNames.add(namespace.schemaName);
1274
- }
1275
- const tables = {};
1276
- const tableNamespaceNames = /* @__PURE__ */ new Set();
1277
- const rlsEnabledTables = /* @__PURE__ */ new Set();
1278
- const policiesByTable = /* @__PURE__ */ new Map();
1279
- for (const namespace of namespaces) {
1280
- const ownedEnumTypes = packOwnedEnumTypesByNamespace.get(namespace.schemaName);
1281
- for (const [tableName, table] of Object.entries(namespace.tables)) {
1282
- if (owners.has(coordinateKey({
1283
- namespaceId: namespace.schemaName,
1284
- entityKind: "table",
1285
- entityName: tableName
1286
- }))) continue;
1287
- if (tables[tableName] !== void 0) throw postgresError("CONTRACT.INFER_UNSUPPORTED", `contract infer: duplicate table name "${tableName}" across schemas is not yet supported (single-namespace PSL inference emits one flat bucket; multi-namespace \`namespace { … }\` output is a later slice).`, { meta: { tableName } });
1288
- if (ownedEnumTypes !== void 0) for (const column of Object.values(table.columns)) {
1289
- const owningSpaceId = ownedEnumTypes.get(column.nativeType);
1290
- if (owningSpaceId !== void 0) throw postgresError("CONTRACT.INFER_UNSUPPORTED", `contract infer: column "${tableName}"."${column.name}" is typed by native enum type "${column.nativeType}", which extension pack space "${owningSpaceId}" already describes. A cross-space enum-typed column has no authorable PSL form yet; describe the table in that pack's contract or retype the column before re-running contract infer.`, { meta: {
1291
- tableName,
1292
- columnName: column.name
1293
- } });
1294
- }
1295
- tables[tableName] = new SqlTableIR(table);
1296
- tableNamespaceNames.add(namespace.schemaName);
1297
- if (table.rlsEnabled) rlsEnabledTables.add(tableName);
1298
- if (table.policies.length > 0) policiesByTable.set(tableName, table.policies);
1299
- }
1300
- }
1301
- let wrapNamespaceName;
1302
- if (enumDefinitions.size > 0 || policiesByTable.size > 0) {
1303
- const contentNamespaces = /* @__PURE__ */ new Set([...enumNamespaceNames, ...tableNamespaceNames]);
1304
- if (contentNamespaces.size > 1) throw postgresError("CONTRACT.INFER_UNSUPPORTED", `contract infer: adopting native enums or RLS policies with content across multiple schemas is not yet supported (single-namespace PSL inference emits one \`namespace { … }\` block; multi-namespace output is a later slice). Schemas: ${[...contentNamespaces].sort().join(", ")}.`, { meta: { schemas: [...contentNamespaces].sort() } });
1305
- wrapNamespaceName = [...contentNamespaces][0];
1306
- }
1307
- const { tables: resolvedTables, extraRelationsByTable, crossSpaceFieldNamesByTable, danglingForeignKeysByTable } = resolveForeignKeys(tables, owners);
1308
- const schemaIR = new SqlSchemaIR({ tables: resolvedTables });
1309
- const enumTypeNames = new Set(enumDefinitions.keys());
1310
- if (wrapNamespaceName !== void 0) for (const typeName of enumDefinitions.keys()) enumTypeNames.add(`${wrapNamespaceName}.${typeName}`);
1311
- const enumInfo = {
1312
- typeNames: enumTypeNames,
1313
- definitions: enumDefinitions
1314
- };
1315
- return buildPslDocumentAst(schemaIR, {
1316
- typeMap: createPostgresTypeMap(enumInfo.typeNames),
1317
- defaultMapping: createPostgresDefaultMapping(),
1318
- parseRawDefault,
1319
- ...enumDefinitions.size > 0 ? { enumInfo } : {}
1320
- }, {
1321
- extraRelationsByTable,
1322
- crossSpaceFieldNamesByTable,
1323
- danglingForeignKeysByTable
1324
- }, wrapNamespaceName, {
1325
- rlsEnabledTables,
1326
- policiesByTable
1327
- });
1328
- }
1329
- /**
1330
- * Builds the PSL document for one introspected schema.
1331
- *
1332
- * `namespaceName` wraps the output in `namespace <name> { … }`; omit it for
1333
- * flat output. `topLevelExtensionBlocks` are declarations that must stay
1334
- * top-level even when a wrap applies, such as a recovered domain enum — a
1335
- * family `enum` inside a namespace is a hard diagnostic. They land in their
1336
- * own always-flat bucket when a wrap applies, and in the single flat bucket
1337
- * when none does; either way they print unwrapped.
1338
- *
1339
- * Their names are reserved before the policy blocks are built, so a policy
1340
- * renames itself out of the way. Against the rest of the top-level scope — the
1341
- * models, the native enums, PSL's scalar type names, and the other blocks in
1342
- * the list — a clash throws instead: a block's name is its contract key
1343
- * (`entries.valueSet[name]`, with no `@@map` escape), so it cannot be rewritten
1344
- * here.
1345
- */
1346
- function buildPslDocumentAst(schemaIR, options, foreignKeyExtras, namespaceName, rlsExtras, topLevelExtensionBlocks = []) {
1347
- const { typeMap, defaultMapping, parseRawDefault: rawDefaultParser } = options;
1348
- const { extraRelationsByTable, crossSpaceFieldNamesByTable, danglingForeignKeysByTable } = foreignKeyExtras;
1349
- const modelNames = buildTopLevelNameMap(Object.keys(schemaIR.tables), toModelName, "model", "table");
1350
- const modelNameMap = new Map([...modelNames].map(([tableName, result]) => [tableName, result.name]));
1351
- const { enumNameMap: bareEnumNameMap, enumBlocks } = buildNativeEnumBlocks(options.enumInfo?.definitions ?? /* @__PURE__ */ new Map(), modelNames);
1352
- const enumNameMap = new Map(bareEnumNameMap);
1353
- if (namespaceName !== void 0) for (const [typeName, pslName] of bareEnumNameMap) enumNameMap.set(`${namespaceName}.${typeName}`, pslName);
1354
- const fieldNamesByTable = new Map([...crossSpaceFieldNamesByTable, ...buildFieldNamesByTable(schemaIR.tables)]);
1355
- const { relationsByTable } = inferRelations(schemaIR.tables, modelNameMap);
1356
- const policyEmission = buildPolicyBlocks(rlsExtras?.policiesByTable ?? /* @__PURE__ */ new Map(), modelNameMap, /* @__PURE__ */ new Set([
1357
- ...modelNameMap.values(),
1358
- ...bareEnumNameMap.values(),
1359
- ...topLevelExtensionBlocks.map((block) => block.name)
1360
- ]));
1361
- const claimedTopLevelNames = /* @__PURE__ */ new Set([
1362
- ...PSL_SCALAR_TYPE_NAMES,
1363
- ...modelNameMap.values(),
1364
- ...bareEnumNameMap.values()
1365
- ]);
1366
- for (const block of topLevelExtensionBlocks) {
1367
- if (claimedTopLevelNames.has(block.name)) throw postgresError("CONTRACT.NAME_DUPLICATE", `contract infer: recovered ${block.keyword} "${block.name}" collides with a model, a native enum, a PSL scalar type, or another recovered declaration of the same name. Rename the recovered declaration, or exclude it.`, { meta: {
1368
- kind: block.keyword,
1369
- name: block.name
1370
- } });
1371
- claimedTopLevelNames.add(block.name);
1372
- }
1373
- const models = [];
1374
- for (const table of Object.values(schemaIR.tables)) models.push(buildModel(table, typeMap, enumNameMap, fieldNamesByTable, defaultMapping, rawDefaultParser, [...relationsByTable.get(table.name) ?? [], ...extraRelationsByTable.get(table.name) ?? []], danglingForeignKeysByTable.get(table.name) ?? [], rlsExtras?.rlsEnabledTables.has(table.name) ?? false, policyEmission.skipNotesByTable.get(table.name) ?? []));
1375
- const sortedModels = topologicalSort(models, schemaIR.tables, modelNameMap);
1376
- const separateTopLevelBucket = namespaceName !== void 0 && namespaceName !== UNSPECIFIED_PSL_NAMESPACE_ID && topLevelExtensionBlocks.length > 0;
1377
- const namespaces = [];
1378
- if (separateTopLevelBucket) namespaces.push(makePslNamespace({
1379
- kind: "namespace",
1380
- name: UNSPECIFIED_PSL_NAMESPACE_ID,
1381
- entries: makePslNamespaceEntries([], [], topLevelExtensionBlocks),
1382
- span: SYNTHETIC_SPAN
1383
- }));
1384
- namespaces.push(makePslNamespace({
1385
- kind: "namespace",
1386
- name: namespaceName ?? UNSPECIFIED_PSL_NAMESPACE_ID,
1387
- entries: makePslNamespaceEntries(sortedModels, [], [
1388
- ...separateTopLevelBucket ? [] : topLevelExtensionBlocks,
1389
- ...enumBlocks,
1390
- ...policyEmission.blocks
1391
- ]),
1392
- span: SYNTHETIC_SPAN
1393
- }));
1394
- return {
1395
- kind: "document",
1396
- sourceId: "<sql-schema-ir>",
1397
- namespaces,
1398
- span: SYNTHETIC_SPAN
1399
- };
1400
- }
1401
- function postgresRenderDefault(def, column) {
1402
- if (def.kind === "function") return def.expression;
1403
- return renderDefaultLiteral(def.value, column);
1404
- }
1405
- const postgresTargetDescriptor = {
1406
- ...postgresTargetDescriptorMeta,
1407
- contractSerializer: new PostgresContractSerializer(),
1408
- schemaVerifier: new PostgresSchemaVerifier(),
1409
- inferPslContract(schema, describedContracts) {
1410
- PostgresDatabaseSchemaNode.assert(schema);
1411
- return inferPostgresPslContract(schema, describedContracts);
1412
- },
1413
- diffSchema(input) {
1414
- return diffPostgresSchema(input);
1415
- },
1416
- classifySubjectGranularity: postgresDiffSubjectGranularity,
1417
- classifyEntityKind: postgresDiffSubjectEntityKind,
1418
- migrations: {
1419
- createPlanner(adapter) {
1420
- return createPostgresMigrationPlanner(adapter);
1421
- },
1422
- createRunner(family) {
1423
- return createPostgresMigrationRunner(family);
1424
- },
1425
- contractToSchema(contract, frameworkComponents) {
1426
- const expander = buildNativeTypeExpander(frameworkComponents);
1427
- return contractToPostgresDatabaseSchemaNode(blindCast(contract), {
1428
- annotationNamespace: "pg",
1429
- ...ifDefined("expandNativeType", expander),
1430
- renderDefault: postgresRenderDefault,
1431
- resolveDefault: postgresResolveDefault
1432
- });
1433
- }
1434
- },
1435
- create() {
1436
- return {
1437
- familyId: "sql",
1438
- targetId: "postgres"
1439
- };
1440
- },
1441
- /**
1442
- * Direct method for SQL-specific usage.
1443
- * @deprecated Use migrations.createPlanner() for CLI compatibility.
1444
- */
1445
- createPlanner(adapter) {
1446
- return createPostgresMigrationPlanner(adapter);
1447
- },
1448
- /**
1449
- * Direct method for SQL-specific usage.
1450
- * @deprecated Use migrations.createRunner() for CLI compatibility.
1451
- */
1452
- createRunner(family) {
1453
- return createPostgresMigrationRunner(family);
1454
- }
1455
- };
1456
- //#endregion
1457
- export { postgresTargetDescriptor as n, postgresRenderDefault as t };
1458
-
1459
- //# sourceMappingURL=control-V7OkAC55.mjs.map