@prisma/orm-target-postgres 0.16.0-dev.36

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 (279) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/dist/adapter-CWvVo0PV.d.mts +22 -0
  4. package/dist/adapter-CWvVo0PV.d.mts.map +1 -0
  5. package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs +70 -0
  6. package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs.map +1 -0
  7. package/dist/adapter.d.mts +12 -0
  8. package/dist/adapter.mjs +7 -0
  9. package/dist/adapter__adapter.d.mts +2 -0
  10. package/dist/adapter__adapter.mjs +2 -0
  11. package/dist/adapter__column-types.d.mts +2 -0
  12. package/dist/adapter__column-types.mjs +2 -0
  13. package/dist/adapter__control.d.mts +5 -0
  14. package/dist/adapter__control.mjs +441 -0
  15. package/dist/adapter__control.mjs.map +1 -0
  16. package/dist/adapter__operation-types.d.mts +2 -0
  17. package/dist/adapter__operation-types.mjs +1 -0
  18. package/dist/adapter__runtime.d.mts +2 -0
  19. package/dist/adapter__runtime.mjs +38 -0
  20. package/dist/adapter__runtime.mjs.map +1 -0
  21. package/dist/adapter__types.d.mts +4 -0
  22. package/dist/adapter__types.mjs +1 -0
  23. package/dist/authoring-03FwIL2k-kPjZAp3s.mjs +757 -0
  24. package/dist/authoring-03FwIL2k-kPjZAp3s.mjs.map +1 -0
  25. package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts +34 -0
  26. package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +1 -0
  27. package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs +59 -0
  28. package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +1 -0
  29. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +37 -0
  30. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +1 -0
  31. package/dist/codec-descriptor-Bg-_412t.d.mts +1 -0
  32. package/dist/codec-descriptor-CB6x0xEu-C-Zn2IEz.mjs +135 -0
  33. package/dist/codec-descriptor-CB6x0xEu-C-Zn2IEz.mjs.map +1 -0
  34. package/dist/codec-ids-CsOU3xDv-mPI0INiF.d.mts +33 -0
  35. package/dist/codec-ids-CsOU3xDv-mPI0INiF.d.mts.map +1 -0
  36. package/dist/codec-ids-fgafMLR7.d.mts +1 -0
  37. package/dist/codec-ids-tX7Svtz--BuOfRaVU.mjs +33 -0
  38. package/dist/codec-ids-tX7Svtz--BuOfRaVU.mjs.map +1 -0
  39. package/dist/codec-types-BHwY9Ff-.d.mts +2 -0
  40. package/dist/codec-types-mWhnDEAf-CAQzGFnF.d.mts +82 -0
  41. package/dist/codec-types-mWhnDEAf-CAQzGFnF.d.mts.map +1 -0
  42. package/dist/codecs-CBl0nD44-CaWPc1bd.mjs +1486 -0
  43. package/dist/codecs-CBl0nD44-CaWPc1bd.mjs.map +1 -0
  44. package/dist/codecs-CHIVTNZs.mjs +15 -0
  45. package/dist/codecs-CHIVTNZs.mjs.map +1 -0
  46. package/dist/codecs-Cvqvb9pV-Cdc51FKY.d.mts +589 -0
  47. package/dist/codecs-Cvqvb9pV-Cdc51FKY.d.mts.map +1 -0
  48. package/dist/codecs-DBn-uIv-.d.mts +15 -0
  49. package/dist/codecs-DBn-uIv-.d.mts.map +1 -0
  50. package/dist/column-types-BH-MU6uU.d.mts +108 -0
  51. package/dist/column-types-BH-MU6uU.d.mts.map +1 -0
  52. package/dist/column-types-CwAyCgp2.mjs +126 -0
  53. package/dist/column-types-CwAyCgp2.mjs.map +1 -0
  54. package/dist/contract-free-BZUS18FU.mjs +118 -0
  55. package/dist/contract-free-BZUS18FU.mjs.map +1 -0
  56. package/dist/contract-free-DzpGxLfb.d.mts +258 -0
  57. package/dist/contract-free-DzpGxLfb.d.mts.map +1 -0
  58. package/dist/control-2F195jJk.d.mts +11 -0
  59. package/dist/control-2F195jJk.d.mts.map +1 -0
  60. package/dist/control-6WFTtLAM.mjs +60 -0
  61. package/dist/control-6WFTtLAM.mjs.map +1 -0
  62. package/dist/control-B-FTbEnE.d.mts +22 -0
  63. package/dist/control-B-FTbEnE.d.mts.map +1 -0
  64. package/dist/control-D85zv_aY.d.mts +199 -0
  65. package/dist/control-D85zv_aY.d.mts.map +1 -0
  66. package/dist/control-DRMWptiJ.mjs +1355 -0
  67. package/dist/control-DRMWptiJ.mjs.map +1 -0
  68. package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs +1901 -0
  69. package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs.map +1 -0
  70. package/dist/control-policy-Cl3RRSPg-CT3QGpR3.mjs +1257 -0
  71. package/dist/control-policy-Cl3RRSPg-CT3QGpR3.mjs.map +1 -0
  72. package/dist/data-transform-BSM7TQpE.d.mts +1 -0
  73. package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs +53 -0
  74. package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +1 -0
  75. package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts +38 -0
  76. package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +1 -0
  77. package/dist/ddl-B4Rh8ntj.d.mts +1 -0
  78. package/dist/ddl-BdP4q3KY-Duef4uHw.mjs +395 -0
  79. package/dist/ddl-BdP4q3KY-Duef4uHw.mjs.map +1 -0
  80. package/dist/default-normalizer-B36TOul4.d.mts +31 -0
  81. package/dist/default-normalizer-B36TOul4.d.mts.map +1 -0
  82. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +253 -0
  83. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +1 -0
  84. package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs +351 -0
  85. package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs.map +1 -0
  86. package/dist/descriptor-meta-DnHabAS3-C53XXPQw.mjs +28 -0
  87. package/dist/descriptor-meta-DnHabAS3-C53XXPQw.mjs.map +1 -0
  88. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +13 -0
  89. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +1 -0
  90. package/dist/diff-database-schema-BfRs2vrG-D2o4KII0.mjs +390 -0
  91. package/dist/diff-database-schema-BfRs2vrG-D2o4KII0.mjs.map +1 -0
  92. package/dist/diff-database-schema-DsoNznGC.d.mts +38 -0
  93. package/dist/diff-database-schema-DsoNznGC.d.mts.map +1 -0
  94. package/dist/driver.d.mts +3 -0
  95. package/dist/driver.mjs +2 -0
  96. package/dist/driver__control.d.mts +2 -0
  97. package/dist/driver__control.mjs +2 -0
  98. package/dist/driver__runtime.d.mts +2 -0
  99. package/dist/driver__runtime.mjs +597 -0
  100. package/dist/driver__runtime.mjs.map +1 -0
  101. package/dist/errors-DCcVX4j1.d.mts +32 -0
  102. package/dist/errors-DCcVX4j1.d.mts.map +1 -0
  103. package/dist/errors-kYxOQjdD-D4T3rbVp.mjs +39 -0
  104. package/dist/errors-kYxOQjdD-D4T3rbVp.mjs.map +1 -0
  105. package/dist/issue-planner-jkY6p-Ca.d.mts +105 -0
  106. package/dist/issue-planner-jkY6p-Ca.d.mts.map +1 -0
  107. package/dist/migration-CBSAPE8S.d.mts +25 -0
  108. package/dist/migration-CBSAPE8S.d.mts.map +1 -0
  109. package/dist/migration-PTHAY9Cv.mjs +21 -0
  110. package/dist/migration-PTHAY9Cv.mjs.map +1 -0
  111. package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs +7 -0
  112. package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +1 -0
  113. package/dist/native-type-normalizer-DqJlOTeX.d.mts +19 -0
  114. package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +1 -0
  115. package/dist/native-type-normalizer-yvd3tqv-.mjs +38 -0
  116. package/dist/native-type-normalizer-yvd3tqv-.mjs.map +1 -0
  117. package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts +235 -0
  118. package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +1 -0
  119. package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs +255 -0
  120. package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +1 -0
  121. package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs +121 -0
  122. package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +1 -0
  123. package/dist/op-factory-call-DifL68KT-Bo6pxs-R.mjs +2009 -0
  124. package/dist/op-factory-call-DifL68KT-Bo6pxs-R.mjs.map +1 -0
  125. package/dist/op-factory-call-FEA5mnWH.d.mts +1 -0
  126. package/dist/op-factory-call-jd4cgfjA-CyNT4YVn.d.mts +521 -0
  127. package/dist/op-factory-call-jd4cgfjA-CyNT4YVn.d.mts.map +1 -0
  128. package/dist/operation-types-BfRocNI8.d.mts +22 -0
  129. package/dist/operation-types-BfRocNI8.d.mts.map +1 -0
  130. package/dist/pack-DFM4tmob.d.mts +610 -0
  131. package/dist/pack-DFM4tmob.d.mts.map +1 -0
  132. package/dist/planner-Bmje9ii8-B99fEsNM.mjs +588 -0
  133. package/dist/planner-Bmje9ii8-B99fEsNM.mjs.map +1 -0
  134. package/dist/planner-DL4Bh5Nk.d.mts +163 -0
  135. package/dist/planner-DL4Bh5Nk.d.mts.map +1 -0
  136. package/dist/planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs +102 -0
  137. package/dist/planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs.map +1 -0
  138. package/dist/planner-ddl-builders-ijp60-JO.d.mts +19 -0
  139. package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +1 -0
  140. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +90 -0
  141. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +1 -0
  142. package/dist/planner-identity-values-TfEhnoWa.d.mts +25 -0
  143. package/dist/planner-identity-values-TfEhnoWa.d.mts.map +1 -0
  144. package/dist/planner-produced-postgres-migration-B0PQLLUb-qsS6cQqX.d.mts +25 -0
  145. package/dist/planner-produced-postgres-migration-B0PQLLUb-qsS6cQqX.d.mts.map +1 -0
  146. package/dist/planner-produced-postgres-migration-C3GPZWeC.d.mts +1 -0
  147. package/dist/planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs +47 -0
  148. package/dist/planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs.map +1 -0
  149. package/dist/planner-schema-lookup-C4DHAddq.d.mts +21 -0
  150. package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +1 -0
  151. package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs +57 -0
  152. package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +1 -0
  153. package/dist/planner-sql-checks-CFgbRTJw.d.mts +20 -0
  154. package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +1 -0
  155. package/dist/planner-sql-checks-DRc_78n8-C9nHOrvU.mjs +152 -0
  156. package/dist/planner-sql-checks-DRc_78n8-C9nHOrvU.mjs.map +1 -0
  157. package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts +12 -0
  158. package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +1 -0
  159. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +15 -0
  160. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +1 -0
  161. package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts +36 -0
  162. package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +1 -0
  163. package/dist/postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs +144 -0
  164. package/dist/postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs.map +1 -0
  165. package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts +285 -0
  166. package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +1 -0
  167. package/dist/postgres-migration-CDJj7CvD-Bsqs_fVo.d.mts +260 -0
  168. package/dist/postgres-migration-CDJj7CvD-Bsqs_fVo.d.mts.map +1 -0
  169. package/dist/postgres-migration-CJshdIZn-DYYjgdD0.mjs +201 -0
  170. package/dist/postgres-migration-CJshdIZn-DYYjgdD0.mjs.map +1 -0
  171. package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs +45 -0
  172. package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +1 -0
  173. package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts +61 -0
  174. package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +1 -0
  175. package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs +204 -0
  176. package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +1 -0
  177. package/dist/postgres-schema-KSzLDONj-CsXGoY8b.mjs +421 -0
  178. package/dist/postgres-schema-KSzLDONj-CsXGoY8b.mjs.map +1 -0
  179. package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts +269 -0
  180. package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +1 -0
  181. package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs +212 -0
  182. package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +1 -0
  183. package/dist/render-ops-DPwhZt2W.d.mts +11 -0
  184. package/dist/render-ops-DPwhZt2W.d.mts.map +1 -0
  185. package/dist/render-ops-DxzTxSsv-Bz85uUHk.mjs +34 -0
  186. package/dist/render-ops-DxzTxSsv-Bz85uUHk.mjs.map +1 -0
  187. package/dist/render-typescript-6sCFvMBh.d.mts +21 -0
  188. package/dist/render-typescript-6sCFvMBh.d.mts.map +1 -0
  189. package/dist/render-typescript-Cw3lFO28-Cx0lXWmv.mjs +117 -0
  190. package/dist/render-typescript-Cw3lFO28-Cx0lXWmv.mjs.map +1 -0
  191. package/dist/resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs +22 -0
  192. package/dist/resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs.map +1 -0
  193. package/dist/runtime-BbSRVwdd.d.mts +12 -0
  194. package/dist/runtime-BbSRVwdd.d.mts.map +1 -0
  195. package/dist/runtime-CDewySU9.d.mts +55 -0
  196. package/dist/runtime-CDewySU9.d.mts.map +1 -0
  197. package/dist/runtime-_TfO66h5.d.mts +32 -0
  198. package/dist/runtime-_TfO66h5.d.mts.map +1 -0
  199. package/dist/schema-ir-annotations-DuuYh0gl.d.mts +15 -0
  200. package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +1 -0
  201. package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts +30 -0
  202. package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +1 -0
  203. package/dist/sql-utils-BnBlQxyh-DaX9Nb7Z.mjs +90 -0
  204. package/dist/sql-utils-BnBlQxyh-DaX9Nb7Z.mjs.map +1 -0
  205. package/dist/sql-utils-DW6fkczF.d.mts +62 -0
  206. package/dist/sql-utils-DW6fkczF.d.mts.map +1 -0
  207. package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts +15 -0
  208. package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +1 -0
  209. package/dist/target.d.mts +47 -0
  210. package/dist/target.mjs +34 -0
  211. package/dist/target__codec-descriptor.d.mts +3 -0
  212. package/dist/target__codec-descriptor.mjs +2 -0
  213. package/dist/target__codec-ids.d.mts +3 -0
  214. package/dist/target__codec-ids.mjs +2 -0
  215. package/dist/target__codec-types.d.mts +4 -0
  216. package/dist/target__codec-types.mjs +1 -0
  217. package/dist/target__codecs.d.mts +3 -0
  218. package/dist/target__codecs.mjs +3 -0
  219. package/dist/target__contract-free.d.mts +3 -0
  220. package/dist/target__contract-free.mjs +4 -0
  221. package/dist/target__control.d.mts +2 -0
  222. package/dist/target__control.mjs +2 -0
  223. package/dist/target__data-transform.d.mts +3 -0
  224. package/dist/target__data-transform.mjs +2 -0
  225. package/dist/target__ddl.d.mts +4 -0
  226. package/dist/target__ddl.mjs +2 -0
  227. package/dist/target__default-normalizer.d.mts +2 -0
  228. package/dist/target__default-normalizer.mjs +2 -0
  229. package/dist/target__diff-database-schema.d.mts +2 -0
  230. package/dist/target__diff-database-schema.mjs +2 -0
  231. package/dist/target__errors.d.mts +2 -0
  232. package/dist/target__errors.mjs +2 -0
  233. package/dist/target__issue-planner.d.mts +2 -0
  234. package/dist/target__issue-planner.mjs +2 -0
  235. package/dist/target__migration.d.mts +4 -0
  236. package/dist/target__migration.mjs +5 -0
  237. package/dist/target__native-type-normalizer.d.mts +2 -0
  238. package/dist/target__native-type-normalizer.mjs +2 -0
  239. package/dist/target__op-factory-call.d.mts +3 -0
  240. package/dist/target__op-factory-call.mjs +2 -0
  241. package/dist/target__pack.d.mts +2 -0
  242. package/dist/target__pack.mjs +2 -0
  243. package/dist/target__planner-ddl-builders.d.mts +2 -0
  244. package/dist/target__planner-ddl-builders.mjs +2 -0
  245. package/dist/target__planner-identity-values.d.mts +2 -0
  246. package/dist/target__planner-identity-values.mjs +2 -0
  247. package/dist/target__planner-produced-postgres-migration.d.mts +3 -0
  248. package/dist/target__planner-produced-postgres-migration.mjs +2 -0
  249. package/dist/target__planner-schema-lookup.d.mts +2 -0
  250. package/dist/target__planner-schema-lookup.mjs +2 -0
  251. package/dist/target__planner-sql-checks.d.mts +2 -0
  252. package/dist/target__planner-sql-checks.mjs +2 -0
  253. package/dist/target__planner-target-details.d.mts +2 -0
  254. package/dist/target__planner-target-details.mjs +1 -0
  255. package/dist/target__planner.d.mts +2 -0
  256. package/dist/target__planner.mjs +3 -0
  257. package/dist/target__render-ops.d.mts +2 -0
  258. package/dist/target__render-ops.mjs +2 -0
  259. package/dist/target__render-typescript.d.mts +2 -0
  260. package/dist/target__render-typescript.mjs +2 -0
  261. package/dist/target__rls-canonicalize.d.mts +2 -0
  262. package/dist/target__rls-canonicalize.mjs +2 -0
  263. package/dist/target__runtime.d.mts +3 -0
  264. package/dist/target__runtime.mjs +23 -0
  265. package/dist/target__runtime.mjs.map +1 -0
  266. package/dist/target__schema-ir-annotations.d.mts +2 -0
  267. package/dist/target__schema-ir-annotations.mjs +2 -0
  268. package/dist/target__sql-utils.d.mts +2 -0
  269. package/dist/target__sql-utils.mjs +2 -0
  270. package/dist/target__types.d.mts +7 -0
  271. package/dist/target__types.mjs +5 -0
  272. package/dist/types-CkryN1AS-6MNZLjLY.d.mts +27 -0
  273. package/dist/types-CkryN1AS-6MNZLjLY.d.mts.map +1 -0
  274. package/dist/types-Cp_Jf2tk.d.mts +1 -0
  275. package/dist/types-ue6jkJyF-BQJzjx1P.d.mts +10 -0
  276. package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +1 -0
  277. package/dist/types-xa86TkcV.d.mts +32 -0
  278. package/dist/types-xa86TkcV.d.mts.map +1 -0
  279. package/package.json +95 -0
@@ -0,0 +1,28 @@
1
+ import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs";
2
+ import { O as postgresQualifyColumnType } from "./codecs-CBl0nD44-CaWPc1bd.mjs";
3
+ import { h as postgresCreateNamespace } from "./postgres-schema-KSzLDONj-CsXGoY8b.mjs";
4
+ import { a as postgresAuthoringTypes, i as postgresAuthoringPslBlockDescriptors, n as postgresAuthoringFieldPresets, o as postgresLowerEntityHandles, r as postgresAuthoringModelAttributes, t as postgresAuthoringEntityTypes } from "./authoring-03FwIL2k-kPjZAp3s.mjs";
5
+ import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs";
6
+ import { type } from "arktype";
7
+ import { defineIndexTypes } from "@prisma/orm-family-sql/contract/index-types";
8
+ //#region ../../../3-targets/3-targets/postgres/dist/descriptor-meta-DnHabAS3.mjs
9
+ const postgresIndexTypes = defineIndexTypes().add("btree", { options: type("object") }).add("hash", { options: type("object") }).add("gin", { options: type("object") }).add("gist", { options: type("object") }).add("spgist", { options: type("object") }).add("brin", { options: type("object") });
10
+ const postgresTargetDescriptorMeta = {
11
+ ...postgresTargetDescriptorMetaRuntime,
12
+ defaultNamespaceId: DEFAULT_NAMESPACE_ID,
13
+ indexTypes: postgresIndexTypes,
14
+ authoring: {
15
+ type: postgresAuthoringTypes,
16
+ field: postgresAuthoringFieldPresets,
17
+ entityTypes: postgresAuthoringEntityTypes,
18
+ pslBlockDescriptors: postgresAuthoringPslBlockDescriptors,
19
+ modelAttributes: postgresAuthoringModelAttributes,
20
+ createNamespace: postgresCreateNamespace,
21
+ qualifyColumnType: postgresQualifyColumnType,
22
+ lowerEntityHandles: postgresLowerEntityHandles
23
+ }
24
+ };
25
+ //#endregion
26
+ export { postgresTargetDescriptorMeta as t };
27
+
28
+ //# sourceMappingURL=descriptor-meta-DnHabAS3-C53XXPQw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-DnHabAS3-C53XXPQw.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/descriptor-meta-DnHabAS3.mjs"],"sourcesContent":["import { O as postgresQualifyColumnType } from \"./codecs-CBl0nD44.mjs\";\nimport { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { a as postgresAuthoringTypes, i as postgresAuthoringPslBlockDescriptors, n as postgresAuthoringFieldPresets, o as postgresLowerEntityHandles, r as postgresAuthoringModelAttributes, t as postgresAuthoringEntityTypes } from \"./authoring-03FwIL2k.mjs\";\nimport { t as postgresTargetDescriptorMetaRuntime } from \"./descriptor-meta-runtime-UwYdV8fD.mjs\";\nimport { type } from \"arktype\";\nimport { defineIndexTypes } from \"@internal/sql-contract/index-types\";\n//#region src/core/index-types.ts\nconst postgresIndexTypes = defineIndexTypes().add(\"btree\", { options: type(\"object\") }).add(\"hash\", { options: type(\"object\") }).add(\"gin\", { options: type(\"object\") }).add(\"gist\", { options: type(\"object\") }).add(\"spgist\", { options: type(\"object\") }).add(\"brin\", { options: type(\"object\") });\nconst postgresTargetDescriptorMeta = {\n\t...postgresTargetDescriptorMetaRuntime,\n\tdefaultNamespaceId: DEFAULT_NAMESPACE_ID,\n\tindexTypes: postgresIndexTypes,\n\tauthoring: {\n\t\ttype: postgresAuthoringTypes,\n\t\tfield: postgresAuthoringFieldPresets,\n\t\tentityTypes: postgresAuthoringEntityTypes,\n\t\tpslBlockDescriptors: postgresAuthoringPslBlockDescriptors,\n\t\tmodelAttributes: postgresAuthoringModelAttributes,\n\t\tcreateNamespace: postgresCreateNamespace,\n\t\tqualifyColumnType: postgresQualifyColumnType,\n\t\tlowerEntityHandles: postgresLowerEntityHandles\n\t}\n};\n//#endregion\nexport { postgresTargetDescriptorMeta as t };\n\n//# sourceMappingURL=descriptor-meta-DnHabAS3.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,qBAAqB,iBAAiB,CAAC,CAAC,IAAI,SAAS,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC;AACpS,MAAM,+BAA+B;CACpC,GAAG;CACH,oBAAoB;CACpB,YAAY;CACZ,WAAW;EACV,MAAM;EACN,OAAO;EACP,aAAa;EACb,qBAAqB;EACrB,iBAAiB;EACjB,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;CACrB;AACD"}
@@ -0,0 +1,13 @@
1
+ //#region ../../../3-targets/3-targets/postgres/dist/descriptor-meta-runtime-UwYdV8fD.mjs
2
+ const postgresTargetDescriptorMetaRuntime = {
3
+ kind: "target",
4
+ familyId: "sql",
5
+ targetId: "postgres",
6
+ id: "postgres",
7
+ version: "0.0.1",
8
+ capabilities: {}
9
+ };
10
+ //#endregion
11
+ export { postgresTargetDescriptorMetaRuntime as t };
12
+
13
+ //# sourceMappingURL=descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/descriptor-meta-runtime-UwYdV8fD.mjs"],"sourcesContent":["const postgresTargetDescriptorMetaRuntime = {\n\tkind: \"target\",\n\tfamilyId: \"sql\",\n\ttargetId: \"postgres\",\n\tid: \"postgres\",\n\tversion: \"0.0.1\",\n\tcapabilities: {}\n};\n//#endregion\nexport { postgresTargetDescriptorMetaRuntime as t };\n\n//# sourceMappingURL=descriptor-meta-runtime-UwYdV8fD.mjs.map"],"mappings":";AAAA,MAAM,sCAAsC;CAC3C,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAChB"}
@@ -0,0 +1,390 @@
1
+ import { n as postgresError } from "./errors-kYxOQjdD-D4T3rbVp.mjs";
2
+ import { d as isPostgresSchema } from "./postgres-schema-KSzLDONj-CsXGoY8b.mjs";
3
+ import { n as postgresResolveDefault } from "./default-normalizer-Ba5ZebHM-isV86rjy.mjs";
4
+ import { a as postgresDiffSubjectGranularity, n as PostgresSchemaNodeKind, r as PostgresTableSchemaNode, t as PostgresNativeEnumSchemaNode } from "./postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs";
5
+ import { i as PostgresRoleSchemaNode, n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs";
6
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs";
7
+ import { d as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-Cl3RRSPg-CT3QGpR3.mjs";
8
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
9
+ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
10
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
11
+ import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
12
+ import { diffSchemas, issueOutcome } from "@prisma/orm-framework/components/control";
13
+ import { buildNativeTypeExpander, contractNamespaceToSchemaIR } from "@prisma/orm-family-sql/family/control";
14
+ import { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from "@prisma/orm-family-sql/schema-ir/types";
15
+ import { classifyDiffSubjectGranularity } from "@prisma/orm-family-sql/family/diff";
16
+ //#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema-BfRs2vrG.mjs
17
+ /** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */
18
+ function databaseStep() {
19
+ return {
20
+ nodeKind: PostgresSchemaNodeKind.database,
21
+ id: "database"
22
+ };
23
+ }
24
+ function tableDependsOn(namespaceId, tableName) {
25
+ return [
26
+ databaseStep(),
27
+ {
28
+ nodeKind: PostgresSchemaNodeKind.namespace,
29
+ id: namespaceId
30
+ },
31
+ {
32
+ nodeKind: PostgresSchemaNodeKind.table,
33
+ id: tableName
34
+ }
35
+ ];
36
+ }
37
+ function roleDependsOn(role) {
38
+ return [databaseStep(), {
39
+ nodeKind: PostgresSchemaNodeKind.role,
40
+ id: role
41
+ }];
42
+ }
43
+ /**
44
+ * The chains from a table-child object (foreign key, index, unique, primary
45
+ * key) to each of the own columns it is built on, in the Postgres tree.
46
+ * Dropping a covered column auto-drops the object, so the object's drop must
47
+ * precede the column's; the graph derives that direction from these edges.
48
+ */
49
+ function columnDependsOn(namespaceId, tableName, columns) {
50
+ return columns.map((column) => [...tableDependsOn(namespaceId, tableName), {
51
+ nodeKind: RelationalSchemaNodeKind.column,
52
+ id: `column:${column}`
53
+ }]);
54
+ }
55
+ function toPolicyNode(policy, namespaceId) {
56
+ return new PostgresPolicySchemaNode({
57
+ naming: namingOf(policy.name, policy.prefix),
58
+ tableName: policy.tableName,
59
+ namespaceId,
60
+ operation: policy.operation,
61
+ roles: [...policy.roles],
62
+ using: policy.using,
63
+ withCheck: policy.withCheck,
64
+ permissive: policy.permissive,
65
+ dependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]
66
+ });
67
+ }
68
+ /**
69
+ * Projects a Postgres contract into the expected schema-diff tree: a
70
+ * `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`
71
+ * per Postgres namespace, each holding its `PostgresTableSchemaNode`s with
72
+ * their `PostgresPolicySchemaNode`s, plus the database roles on the root.
73
+ *
74
+ * Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,
75
+ * single `{ tables }` map (and throws on cross-namespace name collisions, with
76
+ * no RLS/role concept) for SQLite's single-schema world. This is the
77
+ * Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.
78
+ * It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)
79
+ * for column/FK/index building and only adds the Postgres tree/policy/role shape.
80
+ *
81
+ * Tables are grouped by their owning namespace (resolved DDL schema name) so
82
+ * the tree mirrors Postgres's object hierarchy. The DDL schema name is
83
+ * resolved once per namespace.
84
+ *
85
+ * A policy that references a table absent from its namespace is a malformed
86
+ * contract — the loop throws rather than fabricating a stub table.
87
+ */
88
+ function contractToPostgresDatabaseSchemaNode(contract, options) {
89
+ if (contract === null) return new PostgresDatabaseSchemaNode({
90
+ namespaces: {},
91
+ roles: [],
92
+ existingSchemas: [],
93
+ pgVersion: ""
94
+ });
95
+ const namespaces = {};
96
+ const roles = [];
97
+ const ownedSchemas = [];
98
+ for (const ns of Object.values(contract.storage.namespaces)) {
99
+ if (!isPostgresSchema(ns)) continue;
100
+ for (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({
101
+ name: role.name,
102
+ namespaceId: role.namespaceId
103
+ }));
104
+ if (ns.id === UNBOUND_NAMESPACE_ID) {
105
+ if (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== "role" && Object.keys(slot).length > 0)) continue;
106
+ }
107
+ const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);
108
+ ownedSchemas.push(ddlSchema);
109
+ const sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;
110
+ const policiesByTable = /* @__PURE__ */ new Map();
111
+ for (const policy of Object.values(ns.policy)) {
112
+ const list = policiesByTable.get(policy.tableName) ?? [];
113
+ list.push(toPolicyNode(policy, ddlSchema));
114
+ policiesByTable.set(policy.tableName, list);
115
+ }
116
+ const tables = {};
117
+ for (const tableName of Object.keys(ns.table)) {
118
+ const sqlTable = sqlTables[tableName];
119
+ if (sqlTable === void 0) continue;
120
+ const foreignKeys = sqlTable.foreignKeys.map((fk) => {
121
+ const resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);
122
+ return new SqlForeignKeyIR({
123
+ columns: fk.columns,
124
+ referencedTable: fk.referencedTable,
125
+ referencedColumns: fk.referencedColumns,
126
+ referencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,
127
+ ...ifDefined("name", fk.name),
128
+ ...ifDefined("onDelete", fk.onDelete),
129
+ ...ifDefined("onUpdate", fk.onUpdate),
130
+ ...ifDefined("annotations", fk.annotations),
131
+ resolvedReferencedNamespace,
132
+ dependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]
133
+ });
134
+ });
135
+ const uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({
136
+ columns: u.columns,
137
+ ...ifDefined("name", u.name),
138
+ ...ifDefined("annotations", u.annotations),
139
+ dependsOn: columnDependsOn(ddlSchema, tableName, u.columns)
140
+ }));
141
+ const indexes = sqlTable.indexes.map((i) => {
142
+ const base = {
143
+ naming: namingOf(i.name, i.prefix),
144
+ where: i.where,
145
+ unique: i.unique,
146
+ partial: i.partial,
147
+ type: i.type,
148
+ options: i.options,
149
+ annotations: i.annotations,
150
+ dependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))
151
+ };
152
+ return new SqlIndexIR(i.expression !== void 0 ? {
153
+ ...base,
154
+ expression: i.expression
155
+ } : {
156
+ ...base,
157
+ columns: i.columns ?? []
158
+ });
159
+ });
160
+ const primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({
161
+ columns: sqlTable.primaryKey.columns,
162
+ ...ifDefined("name", sqlTable.primaryKey.name),
163
+ dependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)
164
+ }) : void 0;
165
+ tables[tableName] = new PostgresTableSchemaNode({
166
+ name: sqlTable.name,
167
+ columns: sqlTable.columns,
168
+ foreignKeys,
169
+ uniques,
170
+ indexes,
171
+ ...ifDefined("primaryKey", primaryKey),
172
+ ...ifDefined("annotations", sqlTable.annotations),
173
+ ...ifDefined("checks", sqlTable.checks),
174
+ policies: policiesByTable.get(tableName) ?? [],
175
+ rlsEnabled: Object.hasOwn(ns.rls, tableName)
176
+ });
177
+ }
178
+ for (const [tableName, tablePolicies] of policiesByTable) {
179
+ if (!(tableName in tables)) {
180
+ const policyName = tablePolicies[0]?.name ?? "(unknown)";
181
+ throw postgresError("CONTRACT.POLICY_INVALID", `contract-to-postgres-database-schema-node: policy "${policyName}" references table "${tableName}" not present in namespace "${ddlSchema}"`, { meta: {
182
+ policyName,
183
+ tableName,
184
+ namespaceId: ddlSchema,
185
+ reason: "table-missing"
186
+ } });
187
+ }
188
+ if (!Object.hasOwn(ns.rls, tableName)) {
189
+ const policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? "(unknown)";
190
+ throw postgresError("CONTRACT.POLICY_INVALID", `contract-to-postgres-database-schema-node: policy "${policyLabel}" targets table "${tableName}" in namespace "${ddlSchema}", which is not RLS-controlled. Mark the model with @@rls (entries.rls["${tableName}"]) or remove the policy.`, { meta: {
191
+ policyName: policyLabel,
192
+ tableName,
193
+ namespaceId: ddlSchema,
194
+ reason: "table-not-rls-controlled"
195
+ } });
196
+ }
197
+ }
198
+ namespaces[ddlSchema] = new PostgresNamespaceSchemaNode({
199
+ schemaName: ddlSchema,
200
+ tables,
201
+ nativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({
202
+ typeName: entity.typeName,
203
+ namespaceId: ddlSchema,
204
+ members: entity.members,
205
+ ...ifDefined("control", entity.control)
206
+ }))
207
+ });
208
+ }
209
+ return new PostgresDatabaseSchemaNode({
210
+ namespaces,
211
+ roles,
212
+ existingSchemas: ownedSchemas,
213
+ pgVersion: ""
214
+ });
215
+ }
216
+ /**
217
+ * Whether a diff issue's subject node is cluster-scoped — it carries its own
218
+ * `namespaceId` field (only role and policy diff nodes do) and that
219
+ * coordinate is the unbound sentinel, meaning the node is not owned by any
220
+ * schema/namespace. A role node is always cluster-scoped (roles are
221
+ * cluster-level objects); a policy node's `namespaceId` is always its
222
+ * table's resolved DDL schema, never the sentinel. Namespace-ownership
223
+ * scoping (which compares `issue.path[1]` against the set of DDL schemas
224
+ * the contract owns) makes no sense for a cluster-scoped subject — its path
225
+ * segment at that index is the object's own name, not a schema name — so
226
+ * such an issue bypasses that scoping entirely.
227
+ */
228
+ function isClusterScopedIssue(issue) {
229
+ const node = issue.expected ?? issue.actual;
230
+ return node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;
231
+ }
232
+ function nodeNamespaceId(node) {
233
+ if (!Object.hasOwn(node, "namespaceId")) return void 0;
234
+ return blindCast(node).namespaceId;
235
+ }
236
+ function ownedSchemaNames(expected) {
237
+ const policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));
238
+ return /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);
239
+ }
240
+ /**
241
+ * Drops contract namespaces that declare no tables from the verdict-diff
242
+ * expected tree and the relational owned-schema set. The legacy relational
243
+ * walk skipped a table-less namespace (e.g. an enums-only schema) before
244
+ * pairing, so neither its DDL schema's absence nor that schema's live
245
+ * relational contents ever reached the verdict — the pruned tree
246
+ * reproduces that. The prune loses no expected policies: policies attach
247
+ * to tables, so a table-less namespace carries none (the projection
248
+ * throws on a policy referencing an absent table). Live policies in a
249
+ * pruned schema remain governed via the full owned set (see
250
+ * {@link diffPostgresSchema}).
251
+ */
252
+ function pruneTableLessNamespaces(expected) {
253
+ const namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));
254
+ return new PostgresDatabaseSchemaNode({
255
+ namespaces,
256
+ roles: [...expected.roles],
257
+ existingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),
258
+ pgVersion: expected.pgVersion
259
+ });
260
+ }
261
+ /**
262
+ * Resolves a verdict-diff issue's subject's declared control policy directly
263
+ * from the contract, by delegating to the same node-typed resolver
264
+ * ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to
265
+ * gate DDL calls. `undefined` when the issue resolves to no contract subject.
266
+ *
267
+ * A role issue resolves through that same resolver to `external`
268
+ * unconditionally (see its role branch), regardless of the contract's own
269
+ * default policy: a role is referenced by the contract but not owned, and
270
+ * `external`'s existing semantics — a missing declared subject still fails,
271
+ * every extra is suppressed — are exactly the wanted asymmetric grading for
272
+ * a cluster object the framework does not own.
273
+ */
274
+ function resolveControlPolicy(issue, contract) {
275
+ return resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;
276
+ }
277
+ /**
278
+ * The Postgres full-tree node diff for the family verify verdict: derive
279
+ * the expected tree (resolved leaf values, expander threaded, FK schemas
280
+ * resolved, table-less namespaces pruned), run the generic
281
+ * differ over the trees as derived, and scope out `not-expected` findings under namespaces the
282
+ * contract does not own. Ownership scoping bypasses cluster-scoped subjects
283
+ * (roles today), mirroring the legacy decomposition: relational extras check
284
+ * the PRUNED owned set (the legacy
285
+ * per-namespace walk never visited a table-less namespace, so its live
286
+ * relational contents are invisible), while `structural` extras (RLS
287
+ * policies) check the FULL owned set (the legacy policy diff governed
288
+ * every contract schema regardless of tables — RLS governance does not
289
+ * shrink because a namespace declares no tables). The codec `verifyType`
290
+ * hooks run once per contract namespace with tables against that
291
+ * namespace's paired actual node (the hooks read namespace-scoped state
292
+ * such as `nativeEnums`).
293
+ */
294
+ function diffPostgresSchema(input) {
295
+ const postgresContract = blindCast(input.contract);
296
+ PostgresDatabaseSchemaNode.assert(input.schema);
297
+ const actual = input.schema;
298
+ const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {
299
+ annotationNamespace: "pg",
300
+ ...ifDefined("expandNativeType", buildNativeTypeExpander(input.frameworkComponents)),
301
+ resolveDefault: postgresResolveDefault
302
+ });
303
+ const expected = pruneTableLessNamespaces(fullExpected);
304
+ const relationalOwned = ownedSchemaNames(expected);
305
+ const structuralOwned = ownedSchemaNames(fullExpected);
306
+ return {
307
+ issues: diffSchemas(expected, actual).filter((issue) => {
308
+ if (issueOutcome(issue) !== "not-expected") return true;
309
+ if (isClusterScopedIssue(issue)) return true;
310
+ const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
311
+ const namespaceSegment = issue.path[1];
312
+ if (namespaceSegment === void 0) return true;
313
+ return (granularity === "structural" ? structuralOwned : relationalOwned).has(namespaceSegment);
314
+ }),
315
+ resolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),
316
+ namespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))
317
+ };
318
+ }
319
+ /**
320
+ * Adds an empty namespace node to the actual tree for every expected namespace
321
+ * absent from it. The relational plan diff pairs on namespace: a contract
322
+ * namespace whose live schema does not exist yet must surface each of its
323
+ * tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace
324
+ * `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`
325
+ * with no tables). Padding makes the namespaces pair, so only table/column/
326
+ * policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized
327
+ * namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the
328
+ * tree diff — matching the retired per-namespace-paired relational walk, which
329
+ * paired a missing schema against an empty namespace node.
330
+ */
331
+ function padActualNamespaces(expected, actual) {
332
+ const namespaces = { ...actual.namespaces };
333
+ let padded = false;
334
+ for (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {
335
+ namespaces[schemaName] = new PostgresNamespaceSchemaNode({
336
+ schemaName,
337
+ tables: {}
338
+ });
339
+ padded = true;
340
+ }
341
+ if (!padded) return actual;
342
+ return new PostgresDatabaseSchemaNode({
343
+ namespaces,
344
+ roles: [...actual.roles],
345
+ existingSchemas: [...actual.existingSchemas],
346
+ pgVersion: actual.pgVersion
347
+ });
348
+ }
349
+ /**
350
+ * The Postgres planner's diff input: the SAME tree-building
351
+ * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,
352
+ * table-less namespaces pruned, cluster-scope-aware ownership filter) plus
353
+ * actual namespace padding (so a missing
354
+ * schema's tables surface as `not-found` instead of a swallowed namespace
355
+ * `not-found`). One differ drives both verify and plan; this is the
356
+ * plan-side derivation. The single issue list covers tables / columns /
357
+ * constraints / indexes / defaults AND policies — the caller splits it
358
+ * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in
359
+ * `CREATE SCHEMA` separately.
360
+ */
361
+ function buildPostgresPlanDiff(input) {
362
+ const postgresContract = blindCast(input.contract);
363
+ PostgresDatabaseSchemaNode.assert(input.actualSchema);
364
+ const actual = input.actualSchema;
365
+ const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {
366
+ annotationNamespace: "pg",
367
+ ...ifDefined("expandNativeType", buildNativeTypeExpander(input.frameworkComponents)),
368
+ resolveDefault: postgresResolveDefault
369
+ });
370
+ const expected = pruneTableLessNamespaces(fullExpected);
371
+ const paddedActual = padActualNamespaces(expected, actual);
372
+ const relationalOwned = ownedSchemaNames(expected);
373
+ const structuralOwned = ownedSchemaNames(fullExpected);
374
+ return {
375
+ expected,
376
+ actual: paddedActual,
377
+ issues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {
378
+ if (issueOutcome(issue) !== "not-expected") return true;
379
+ if (isClusterScopedIssue(issue)) return true;
380
+ const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
381
+ const namespaceSegment = issue.path[1];
382
+ if (namespaceSegment === void 0) return true;
383
+ return (granularity === "structural" ? structuralOwned : relationalOwned).has(namespaceSegment);
384
+ })
385
+ };
386
+ }
387
+ //#endregion
388
+ export { contractToPostgresDatabaseSchemaNode as n, diffPostgresSchema as r, buildPostgresPlanDiff as t };
389
+
390
+ //# sourceMappingURL=diff-database-schema-BfRs2vrG-D2o4KII0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-database-schema-BfRs2vrG-D2o4KII0.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-BfRs2vrG.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Ba5ZebHM.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-Cl3RRSPg.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\n\t\toperation: policy.operation,\n\t\troles: [...policy.roles],\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\n}\n/**\n* Projects a Postgres contract into the expected schema-diff tree: a\n* `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n* per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n* their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n*\n* Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n* single `{ tables }` map (and throws on cross-namespace name collisions, with\n* no RLS/role concept) for SQLite's single-schema world. This is the\n* Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n* It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n* for column/FK/index building and only adds the Postgres tree/policy/role shape.\n*\n* Tables are grouped by their owning namespace (resolved DDL schema name) so\n* the tree mirrors Postgres's object hierarchy. The DDL schema name is\n* resolved once per namespace.\n*\n* A policy that references a table absent from its namespace is a malformed\n* contract — the loop throws rather than fabricating a stub table.\n*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\n/**\n* Whether a diff issue's subject node is cluster-scoped — it carries its own\n* `namespaceId` field (only role and policy diff nodes do) and that\n* coordinate is the unbound sentinel, meaning the node is not owned by any\n* schema/namespace. A role node is always cluster-scoped (roles are\n* cluster-level objects); a policy node's `namespaceId` is always its\n* table's resolved DDL schema, never the sentinel. Namespace-ownership\n* scoping (which compares `issue.path[1]` against the set of DDL schemas\n* the contract owns) makes no sense for a cluster-scoped subject — its path\n* segment at that index is the object's own name, not a schema name — so\n* such an issue bypasses that scoping entirely.\n*/\nfunction isClusterScopedIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n/**\n* Drops contract namespaces that declare no tables from the verdict-diff\n* expected tree and the relational owned-schema set. The legacy relational\n* walk skipped a table-less namespace (e.g. an enums-only schema) before\n* pairing, so neither its DDL schema's absence nor that schema's live\n* relational contents ever reached the verdict — the pruned tree\n* reproduces that. The prune loses no expected policies: policies attach\n* to tables, so a table-less namespace carries none (the projection\n* throws on a policy referencing an absent table). Live policies in a\n* pruned schema remain governed via the full owned set (see\n* {@link diffPostgresSchema}).\n*/\nfunction pruneTableLessNamespaces(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\n}\n/**\n* Resolves a verdict-diff issue's subject's declared control policy directly\n* from the contract, by delegating to the same node-typed resolver\n* ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n* gate DDL calls. `undefined` when the issue resolves to no contract subject.\n*\n* A role issue resolves through that same resolver to `external`\n* unconditionally (see its role branch), regardless of the contract's own\n* default policy: a role is referenced by the contract but not owned, and\n* `external`'s existing semantics — a missing declared subject still fails,\n* every extra is suppressed — are exactly the wanted asymmetric grading for\n* a cluster object the framework does not own.\n*/\nfunction resolveControlPolicy(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\n}\n/**\n* The Postgres full-tree node diff for the family verify verdict: derive\n* the expected tree (resolved leaf values, expander threaded, FK schemas\n* resolved, table-less namespaces pruned), run the generic\n* differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n* contract does not own. Ownership scoping bypasses cluster-scoped subjects\n* (roles today), mirroring the legacy decomposition: relational extras check\n* the PRUNED owned set (the legacy\n* per-namespace walk never visited a table-less namespace, so its live\n* relational contents are invisible), while `structural` extras (RLS\n* policies) check the FULL owned set (the legacy policy diff governed\n* every contract schema regardless of tables — RLS governance does not\n* shrink because a namespace declares no tables). The codec `verifyType`\n* hooks run once per contract namespace with tables against that\n* namespace's paired actual node (the hooks read namespace-scoped state\n* such as `nativeEnums`).\n*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\n}\n/**\n* Adds an empty namespace node to the actual tree for every expected namespace\n* absent from it. The relational plan diff pairs on namespace: a contract\n* namespace whose live schema does not exist yet must surface each of its\n* tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n* `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n* with no tables). Padding makes the namespaces pair, so only table/column/\n* policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n* namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n* tree diff — matching the retired per-namespace-paired relational walk, which\n* paired a missing schema against an empty namespace node.\n*/\nfunction padActualNamespaces(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\n}\n/**\n* The Postgres planner's diff input: the SAME tree-building\n* `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n* table-less namespaces pruned, cluster-scope-aware ownership filter) plus\n* actual namespace padding (so a missing\n* schema's tables surface as `not-found` instead of a swallowed namespace\n* `not-found`). One differ drives both verify and plan; this is the\n* plan-side derivation. The single issue list covers tables / columns /\n* constraints / indexes / defaults AND policies — the caller splits it\n* (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n* `CREATE SCHEMA` separately.\n*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-BfRs2vrG.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;CACD;AACD;AACA,SAAS,cAAc,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B;EAC/F,CAAC;CACF;AACD"}
@@ -0,0 +1,38 @@
1
+ import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-CyfpHXDr-BqyozkQE.mjs";
2
+ import { n as SqlSchemaDiffNode } from "./schema-node-kinds-qlnURWJy-Bo30pwTM.mjs";
3
+ import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
4
+ import { SchemaDiffIssue } from "@prisma/orm-framework/components/control";
5
+ import "@prisma/orm-family-sql/family/control";
6
+ import { SqlSchemaIRNode } from "@prisma/orm-family-sql/schema-ir/types";
7
+ import { Contract } from "@prisma/orm-framework/contract/types";
8
+ import { TargetBoundComponentDescriptor } from "@prisma/orm-framework/components/components";
9
+ //#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema.d.mts
10
+ //#region src/core/migrations/diff-database-schema.d.ts
11
+ interface PostgresPlanDiff {
12
+ /** The desired ("end") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */
13
+ readonly expected: PostgresDatabaseSchemaNode;
14
+ /** The live ("start") tree, padded with empty namespaces so a missing schema's tables pair. */
15
+ readonly actual: PostgresDatabaseSchemaNode;
16
+ /** The one node diff over the two trees: relational + policy drift, cluster-scope-aware ownership filtered. */
17
+ readonly issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[];
18
+ }
19
+ /**
20
+ * The Postgres planner's diff input: the SAME tree-building
21
+ * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,
22
+ * table-less namespaces pruned, cluster-scope-aware ownership filter) plus
23
+ * actual namespace padding (so a missing
24
+ * schema's tables surface as `not-found` instead of a swallowed namespace
25
+ * `not-found`). One differ drives both verify and plan; this is the
26
+ * plan-side derivation. The single issue list covers tables / columns /
27
+ * constraints / indexes / defaults AND policies — the caller splits it
28
+ * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in
29
+ * `CREATE SCHEMA` separately.
30
+ */
31
+ declare function buildPostgresPlanDiff(input: {
32
+ readonly contract: Contract<SqlStorage>;
33
+ readonly actualSchema: SqlSchemaIRNode;
34
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
35
+ }): PostgresPlanDiff;
36
+ //#endregion
37
+ export { buildPostgresPlanDiff as t };
38
+ //# sourceMappingURL=diff-database-schema-DsoNznGC.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-database-schema-DsoNznGC.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema.d.mts"],"mappings":";;;;;;;;;;UASU;;WAEC,UAAU;;WAEV,QAAQ;;WAER,iBAAiB,gBAAgB;;;;;;;;;;;;;;iBAc3B,sBAAsB;WAC5B,UAAU,SAAS;WACnB,cAAc;WACd,qBAAqB,cAAc;IAC1C"}
@@ -0,0 +1,3 @@
1
+ import { t as PostgresControlDriver } from "./control-B-FTbEnE.mjs";
2
+ import { i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-CDewySU9.mjs";
3
+ export { type PostgresBinding, PostgresControlDriver, type PostgresDriverCreateOptions, PostgresRuntimeDriver, type QueryResult };
@@ -0,0 +1,2 @@
1
+ import { t as PostgresControlDriver } from "./control-6WFTtLAM.mjs";
2
+ export { PostgresControlDriver };
@@ -0,0 +1,2 @@
1
+ import { n as postgresDriverDescriptor, t as PostgresControlDriver } from "./control-B-FTbEnE.mjs";
2
+ export { PostgresControlDriver, postgresDriverDescriptor as default };
@@ -0,0 +1,2 @@
1
+ import { n as postgresDriverDescriptor, t as PostgresControlDriver } from "./control-6WFTtLAM.mjs";
2
+ export { PostgresControlDriver, postgresDriverDescriptor as default };
@@ -0,0 +1,2 @@
1
+ import { a as postgresRuntimeDriverDescriptor, i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-CDewySU9.mjs";
2
+ export { type PostgresBinding, type PostgresDriverCreateOptions, PostgresRuntimeDriver, type QueryResult, postgresRuntimeDriverDescriptor as default };