@prisma/orm-toolchain 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 (321) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +28 -0
  3. package/dist/aggregate-B4mhR4Sk.mjs +1012 -0
  4. package/dist/aggregate-B4mhR4Sk.mjs.map +1 -0
  5. package/dist/aggregate-BflrjWPO.d.mts +803 -0
  6. package/dist/aggregate-BflrjWPO.d.mts.map +1 -0
  7. package/dist/bin__prisma-next.mjs +800 -0
  8. package/dist/bin__prisma-next.mjs.map +1 -0
  9. package/dist/cli-telemetry.d.mts +367 -0
  10. package/dist/cli-telemetry.d.mts.map +1 -0
  11. package/dist/cli-telemetry.mjs +48 -0
  12. package/dist/cli-telemetry.mjs.map +1 -0
  13. package/dist/cli-telemetry__sender.d.mts +1 -0
  14. package/dist/cli-telemetry__sender.mjs +1 -0
  15. package/dist/cli.d.mts +31 -0
  16. package/dist/cli.d.mts.map +1 -0
  17. package/dist/cli.mjs +180 -0
  18. package/dist/cli.mjs.map +1 -0
  19. package/dist/cli__commands__contract-emit.d.mts +2 -0
  20. package/dist/cli__commands__contract-emit.mjs +2 -0
  21. package/dist/cli__commands__contract-infer.d.mts +7 -0
  22. package/dist/cli__commands__contract-infer.d.mts.map +1 -0
  23. package/dist/cli__commands__contract-infer.mjs +2 -0
  24. package/dist/cli__commands__db-init.d.mts +7 -0
  25. package/dist/cli__commands__db-init.d.mts.map +1 -0
  26. package/dist/cli__commands__db-init.mjs +2 -0
  27. package/dist/cli__commands__db-schema.d.mts +7 -0
  28. package/dist/cli__commands__db-schema.d.mts.map +1 -0
  29. package/dist/cli__commands__db-schema.mjs +2 -0
  30. package/dist/cli__commands__db-sign.d.mts +7 -0
  31. package/dist/cli__commands__db-sign.d.mts.map +1 -0
  32. package/dist/cli__commands__db-sign.mjs +2 -0
  33. package/dist/cli__commands__db-update.d.mts +7 -0
  34. package/dist/cli__commands__db-update.d.mts.map +1 -0
  35. package/dist/cli__commands__db-update.mjs +2 -0
  36. package/dist/cli__commands__db-verify.d.mts +7 -0
  37. package/dist/cli__commands__db-verify.d.mts.map +1 -0
  38. package/dist/cli__commands__db-verify.mjs +2 -0
  39. package/dist/cli__commands__migrate.d.mts +66 -0
  40. package/dist/cli__commands__migrate.d.mts.map +1 -0
  41. package/dist/cli__commands__migrate.mjs +2 -0
  42. package/dist/cli__commands__migration-check.d.mts +64 -0
  43. package/dist/cli__commands__migration-check.d.mts.map +1 -0
  44. package/dist/cli__commands__migration-check.mjs +3 -0
  45. package/dist/cli__commands__migration-graph.d.mts +36 -0
  46. package/dist/cli__commands__migration-graph.d.mts.map +1 -0
  47. package/dist/cli__commands__migration-graph.mjs +2 -0
  48. package/dist/cli__commands__migration-list.d.mts +79 -0
  49. package/dist/cli__commands__migration-list.d.mts.map +1 -0
  50. package/dist/cli__commands__migration-list.mjs +2 -0
  51. package/dist/cli__commands__migration-log.d.mts +20 -0
  52. package/dist/cli__commands__migration-log.d.mts.map +1 -0
  53. package/dist/cli__commands__migration-log.mjs +2 -0
  54. package/dist/cli__commands__migration-new.d.mts +7 -0
  55. package/dist/cli__commands__migration-new.d.mts.map +1 -0
  56. package/dist/cli__commands__migration-new.mjs +2 -0
  57. package/dist/cli__commands__migration-plan.d.mts +79 -0
  58. package/dist/cli__commands__migration-plan.d.mts.map +1 -0
  59. package/dist/cli__commands__migration-plan.mjs +2 -0
  60. package/dist/cli__commands__migration-show.d.mts +27 -0
  61. package/dist/cli__commands__migration-show.d.mts.map +1 -0
  62. package/dist/cli__commands__migration-show.mjs +2 -0
  63. package/dist/cli__commands__migration-status.d.mts +55 -0
  64. package/dist/cli__commands__migration-status.d.mts.map +1 -0
  65. package/dist/cli__commands__migration-status.mjs +3 -0
  66. package/dist/cli__commands__ref.d.mts +34 -0
  67. package/dist/cli__commands__ref.d.mts.map +1 -0
  68. package/dist/cli__commands__ref.mjs +2 -0
  69. package/dist/cli__commands__telemetry.d.mts +7 -0
  70. package/dist/cli__commands__telemetry.d.mts.map +1 -0
  71. package/dist/cli__commands__telemetry.mjs +2 -0
  72. package/dist/cli__config-types.d.mts +2 -0
  73. package/dist/cli__config-types.mjs +2 -0
  74. package/dist/cli__control-api.d.mts +141 -0
  75. package/dist/cli__control-api.d.mts.map +1 -0
  76. package/dist/cli__control-api.mjs +4 -0
  77. package/dist/cli__init-output.d.mts +37 -0
  78. package/dist/cli__init-output.d.mts.map +1 -0
  79. package/dist/cli__init-output.mjs +2 -0
  80. package/dist/cli__migration-cli.d.mts +79 -0
  81. package/dist/cli__migration-cli.d.mts.map +1 -0
  82. package/dist/cli__migration-cli.mjs +407 -0
  83. package/dist/cli__migration-cli.mjs.map +1 -0
  84. package/dist/client-75qrAPqf-DZAVUxFa.mjs +1606 -0
  85. package/dist/client-75qrAPqf-DZAVUxFa.mjs.map +1 -0
  86. package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs +1671 -0
  87. package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs.map +1 -0
  88. package/dist/config-loader.d.mts +18 -0
  89. package/dist/config-loader.d.mts.map +1 -0
  90. package/dist/config-loader.mjs +2 -0
  91. package/dist/constants-CM-w38DQ-Cz_EXbOc.mjs +10 -0
  92. package/dist/constants-CM-w38DQ-Cz_EXbOc.mjs.map +1 -0
  93. package/dist/constants-Dkcn8Qu4.d.mts +10 -0
  94. package/dist/constants-Dkcn8Qu4.d.mts.map +1 -0
  95. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs +36 -0
  96. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs.map +1 -0
  97. package/dist/contract-emit-0hSjbuxp-BBOKldTZ.mjs +148 -0
  98. package/dist/contract-emit-0hSjbuxp-BBOKldTZ.mjs.map +1 -0
  99. package/dist/contract-emit-B65_UiFn.d.mts +7 -0
  100. package/dist/contract-emit-B65_UiFn.d.mts.map +1 -0
  101. package/dist/contract-emit-B6odMoem-CK3diBPk.mjs +359 -0
  102. package/dist/contract-emit-B6odMoem-CK3diBPk.mjs.map +1 -0
  103. package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs +56 -0
  104. package/dist/contract-enrichment-DrMvvY2A-DxNGeF4d.mjs.map +1 -0
  105. package/dist/contract-infer-BnkqpftN-DVM2eKJ3.mjs +73 -0
  106. package/dist/contract-infer-BnkqpftN-DVM2eKJ3.mjs.map +1 -0
  107. package/dist/contract-snapshot-store-CbqynbtE.d.mts +28 -0
  108. package/dist/contract-snapshot-store-CbqynbtE.d.mts.map +1 -0
  109. package/dist/contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs +118 -0
  110. package/dist/contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map +1 -0
  111. package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs +302 -0
  112. package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map +1 -0
  113. package/dist/db-init-Vbkb_TKZ.mjs +153 -0
  114. package/dist/db-init-Vbkb_TKZ.mjs.map +1 -0
  115. package/dist/db-schema-ClQCu3xY.mjs +47 -0
  116. package/dist/db-schema-ClQCu3xY.mjs.map +1 -0
  117. package/dist/db-sign-jjXDgQ1u.mjs +175 -0
  118. package/dist/db-sign-jjXDgQ1u.mjs.map +1 -0
  119. package/dist/db-update-BQlrqtDD.mjs +183 -0
  120. package/dist/db-update-BQlrqtDD.mjs.map +1 -0
  121. package/dist/db-verify-CKPsRFrj-3udprZQD.mjs +396 -0
  122. package/dist/db-verify-CKPsRFrj-3udprZQD.mjs.map +1 -0
  123. package/dist/domain-type-generation-DAn9y5d2-BgoT5uKI.mjs +334 -0
  124. package/dist/domain-type-generation-DAn9y5d2-BgoT5uKI.mjs.map +1 -0
  125. package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts +63 -0
  126. package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +1 -0
  127. package/dist/emitter.d.mts +75 -0
  128. package/dist/emitter.d.mts.map +1 -0
  129. package/dist/emitter.mjs +3 -0
  130. package/dist/emitter__domain-type-generation.d.mts +2 -0
  131. package/dist/emitter__domain-type-generation.mjs +2 -0
  132. package/dist/emitter__type-expression-safety.d.mts +6 -0
  133. package/dist/emitter__type-expression-safety.d.mts.map +1 -0
  134. package/dist/emitter__type-expression-safety.mjs +2 -0
  135. package/dist/errors--qsXZUtL.d.mts +72 -0
  136. package/dist/errors--qsXZUtL.d.mts.map +1 -0
  137. package/dist/errors-IpZm1Skp-BH495dRd.mjs +378 -0
  138. package/dist/errors-IpZm1Skp-BH495dRd.mjs.map +1 -0
  139. package/dist/exports-BN0vFTxG.mjs +276 -0
  140. package/dist/exports-BN0vFTxG.mjs.map +1 -0
  141. package/dist/exports-B_xhKZmC.mjs +1436 -0
  142. package/dist/exports-B_xhKZmC.mjs.map +1 -0
  143. package/dist/exports-D3-NwrMA-CadaBGQ3.mjs +154 -0
  144. package/dist/exports-D3-NwrMA-CadaBGQ3.mjs.map +1 -0
  145. package/dist/exports-Dl2aGAk7.mjs +119 -0
  146. package/dist/exports-Dl2aGAk7.mjs.map +1 -0
  147. package/dist/format-ByDm2goZ-DKLyhNHo.mjs +101 -0
  148. package/dist/format-ByDm2goZ-DKLyhNHo.mjs.map +1 -0
  149. package/dist/framework-components-CjshQKHA-Dlp6Leo5.mjs +58 -0
  150. package/dist/framework-components-CjshQKHA-Dlp6Leo5.mjs.map +1 -0
  151. package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts +35 -0
  152. package/dist/global-flags-BpoOYtNZ-CHZD3fud.d.mts.map +1 -0
  153. package/dist/graph-bDjJ4GL9-BhFevsJS.d.mts +28 -0
  154. package/dist/graph-bDjJ4GL9-BhFevsJS.d.mts.map +1 -0
  155. package/dist/graph-membership-DW6nnbyQ-Bp2KcVwR.mjs +14 -0
  156. package/dist/graph-membership-DW6nnbyQ-Bp2KcVwR.mjs.map +1 -0
  157. package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs +64 -0
  158. package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +1 -0
  159. package/dist/hash-XZYYKJ-i.d.mts +53 -0
  160. package/dist/hash-XZYYKJ-i.d.mts.map +1 -0
  161. package/dist/import-roots-B6CtsWXb.d.mts +119 -0
  162. package/dist/import-roots-B6CtsWXb.d.mts.map +1 -0
  163. package/dist/import-roots-NDOIEDVj.mjs +217 -0
  164. package/dist/import-roots-NDOIEDVj.mjs.map +1 -0
  165. package/dist/init-DHctXAI9-DSlaaYXN.mjs +2186 -0
  166. package/dist/init-DHctXAI9-DSlaaYXN.mjs.map +1 -0
  167. package/dist/inspect-live-schema-CnwYTRZ0-BErPHMni.mjs +91 -0
  168. package/dist/inspect-live-schema-CnwYTRZ0-BErPHMni.mjs.map +1 -0
  169. package/dist/invariants-B5wLrgQS.d.mts +39 -0
  170. package/dist/invariants-B5wLrgQS.d.mts.map +1 -0
  171. package/dist/invariants-lXzy6txi-DAoP4nTE.mjs +57 -0
  172. package/dist/invariants-lXzy6txi-DAoP4nTE.mjs.map +1 -0
  173. package/dist/io-C8TdyBKt-DloEBi70.mjs +313 -0
  174. package/dist/io-C8TdyBKt-DloEBi70.mjs.map +1 -0
  175. package/dist/io-DYfeLJxR.d.mts +1 -0
  176. package/dist/io-sr4CO9_t-C3eV_kn-.d.mts +125 -0
  177. package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +1 -0
  178. package/dist/ledger-origin-BGRN77Oy.d.mts +6 -0
  179. package/dist/ledger-origin-BGRN77Oy.d.mts.map +1 -0
  180. package/dist/ledger-origin-D7PN4Fon.mjs +9 -0
  181. package/dist/ledger-origin-D7PN4Fon.mjs.map +1 -0
  182. package/dist/metadata-2nbOAGsV-uYNeq2Cp.d.mts +2 -0
  183. package/dist/metadata-BtscDay2.d.mts +1 -0
  184. package/dist/migrate-Cb_iv264.mjs +500 -0
  185. package/dist/migrate-Cb_iv264.mjs.map +1 -0
  186. package/dist/migration-B2ljMJim.d.mts +155 -0
  187. package/dist/migration-B2ljMJim.d.mts.map +1 -0
  188. package/dist/migration-BuUmO7It.mjs +209 -0
  189. package/dist/migration-BuUmO7It.mjs.map +1 -0
  190. package/dist/migration-check-CcG-fB8r-CDs5C9vt.mjs +597 -0
  191. package/dist/migration-check-CcG-fB8r-CDs5C9vt.mjs.map +1 -0
  192. package/dist/migration-command-scaffold-BCuoeAki-B1pVGX8d.mjs +103 -0
  193. package/dist/migration-command-scaffold-BCuoeAki-B1pVGX8d.mjs.map +1 -0
  194. package/dist/migration-graph-CBf9ORe7-B4xAF8GN.mjs +500 -0
  195. package/dist/migration-graph-CBf9ORe7-B4xAF8GN.mjs.map +1 -0
  196. package/dist/migration-graph-DkoCC0Qy.mjs +185 -0
  197. package/dist/migration-graph-DkoCC0Qy.mjs.map +1 -0
  198. package/dist/migration-graph-Dqndu0i5.d.mts +9 -0
  199. package/dist/migration-graph-Dqndu0i5.d.mts.map +1 -0
  200. package/dist/migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs +1945 -0
  201. package/dist/migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs.map +1 -0
  202. package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts +124 -0
  203. package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts.map +1 -0
  204. package/dist/migration-list-BFBeo1_X-c0kqYokL.mjs +228 -0
  205. package/dist/migration-list-BFBeo1_X-c0kqYokL.mjs.map +1 -0
  206. package/dist/migration-log-CS5IWcNq-BQ-32Low.mjs +220 -0
  207. package/dist/migration-log-CS5IWcNq-BQ-32Low.mjs.map +1 -0
  208. package/dist/migration-new-BurCjyaQ.mjs +168 -0
  209. package/dist/migration-new-BurCjyaQ.mjs.map +1 -0
  210. package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs +38 -0
  211. package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs.map +1 -0
  212. package/dist/migration-plan-q_L84PN1-BWE0LTH6.mjs +759 -0
  213. package/dist/migration-plan-q_L84PN1-BWE0LTH6.mjs.map +1 -0
  214. package/dist/migration-show-Bx5I5aW9.mjs +171 -0
  215. package/dist/migration-show-Bx5I5aW9.mjs.map +1 -0
  216. package/dist/migration-status-CFlzlRmu-DewBN8Ys.mjs +444 -0
  217. package/dist/migration-status-CFlzlRmu-DewBN8Ys.mjs.map +1 -0
  218. package/dist/migration-tools.d.mts +23 -0
  219. package/dist/migration-tools.mjs +17 -0
  220. package/dist/migration-tools__aggregate.d.mts +2 -0
  221. package/dist/migration-tools__aggregate.mjs +2 -0
  222. package/dist/migration-tools__constants.d.mts +2 -0
  223. package/dist/migration-tools__constants.mjs +2 -0
  224. package/dist/migration-tools__contract-snapshot-store.d.mts +2 -0
  225. package/dist/migration-tools__contract-snapshot-store.mjs +2 -0
  226. package/dist/migration-tools__errors.d.mts +2 -0
  227. package/dist/migration-tools__errors.mjs +2 -0
  228. package/dist/migration-tools__graph.d.mts +2 -0
  229. package/dist/migration-tools__graph.mjs +1 -0
  230. package/dist/migration-tools__hash.d.mts +2 -0
  231. package/dist/migration-tools__hash.mjs +2 -0
  232. package/dist/migration-tools__invariants.d.mts +2 -0
  233. package/dist/migration-tools__invariants.mjs +2 -0
  234. package/dist/migration-tools__io.d.mts +3 -0
  235. package/dist/migration-tools__io.mjs +2 -0
  236. package/dist/migration-tools__ledger-origin.d.mts +2 -0
  237. package/dist/migration-tools__ledger-origin.mjs +2 -0
  238. package/dist/migration-tools__metadata.d.mts +3 -0
  239. package/dist/migration-tools__metadata.mjs +1 -0
  240. package/dist/migration-tools__migration-graph.d.mts +3 -0
  241. package/dist/migration-tools__migration-graph.mjs +3 -0
  242. package/dist/migration-tools__migration-ts.d.mts +2 -0
  243. package/dist/migration-tools__migration-ts.mjs +2 -0
  244. package/dist/migration-tools__migration.d.mts +2 -0
  245. package/dist/migration-tools__migration.mjs +2 -0
  246. package/dist/migration-tools__package.d.mts +3 -0
  247. package/dist/migration-tools__package.mjs +1 -0
  248. package/dist/migration-tools__ref-resolution.d.mts +2 -0
  249. package/dist/migration-tools__ref-resolution.mjs +2 -0
  250. package/dist/migration-tools__refs.d.mts +2 -0
  251. package/dist/migration-tools__refs.mjs +2 -0
  252. package/dist/migration-tools__spaces.d.mts +3 -0
  253. package/dist/migration-tools__spaces.mjs +3 -0
  254. package/dist/migration-ts-CNaAtK8C.d.mts +38 -0
  255. package/dist/migration-ts-CNaAtK8C.d.mts.map +1 -0
  256. package/dist/migration-ts-FyF55c4M.mjs +67 -0
  257. package/dist/migration-ts-FyF55c4M.mjs.map +1 -0
  258. package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs +13 -0
  259. package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs.map +1 -0
  260. package/dist/output-DWNYqZGc-D2sRgLAm.mjs +109 -0
  261. package/dist/output-DWNYqZGc-D2sRgLAm.mjs.map +1 -0
  262. package/dist/package-CfWiDNrr-ZR4HM_Iz.d.mts +21 -0
  263. package/dist/package-CfWiDNrr-ZR4HM_Iz.d.mts.map +1 -0
  264. package/dist/package-N9PPdFV_.d.mts +3 -0
  265. package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs +43 -0
  266. package/dist/progress-adapter-CjAeTxY_-BXYSd1eY.mjs.map +1 -0
  267. package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs +99 -0
  268. package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs.map +1 -0
  269. package/dist/publish-surface.d.mts +3 -0
  270. package/dist/publish-surface.mjs +3 -0
  271. package/dist/publish-surface__import-roots.d.mts +2 -0
  272. package/dist/publish-surface__import-roots.mjs +2 -0
  273. package/dist/publish-surface__shells.d.mts +2 -0
  274. package/dist/publish-surface__shells.mjs +2 -0
  275. package/dist/quick-reference-mongo.md +114 -0
  276. package/dist/quick-reference-postgres.md +93 -0
  277. package/dist/readme-mongo.md +35 -0
  278. package/dist/readme-postgres.md +34 -0
  279. package/dist/ref-B6cTthTi.mjs +171 -0
  280. package/dist/ref-B6cTthTi.mjs.map +1 -0
  281. package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs +57 -0
  282. package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs.map +1 -0
  283. package/dist/ref-resolution-BjJBWPjX.mjs +250 -0
  284. package/dist/ref-resolution-BjJBWPjX.mjs.map +1 -0
  285. package/dist/ref-resolution-COGOSL57.d.mts +127 -0
  286. package/dist/ref-resolution-COGOSL57.d.mts.map +1 -0
  287. package/dist/refs-BDbB9BRB-D6Za3Q49.mjs +241 -0
  288. package/dist/refs-BDbB9BRB-D6Za3Q49.mjs.map +1 -0
  289. package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts +43 -0
  290. package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts.map +1 -0
  291. package/dist/schemas-CeGMYFYX-h3OcU__O.d.mts +192 -0
  292. package/dist/schemas-CeGMYFYX-h3OcU__O.d.mts.map +1 -0
  293. package/dist/schemas-KhXMzNA_-CzZ7GFX_.mjs +112 -0
  294. package/dist/schemas-KhXMzNA_-CzZ7GFX_.mjs.map +1 -0
  295. package/dist/shells-BenrJHp2.mjs +602 -0
  296. package/dist/shells-BenrJHp2.mjs.map +1 -0
  297. package/dist/shells-COHV_Ozf.d.mts +135 -0
  298. package/dist/shells-COHV_Ozf.d.mts.map +1 -0
  299. package/dist/spaces-C27bA-xc.mjs +267 -0
  300. package/dist/spaces-C27bA-xc.mjs.map +1 -0
  301. package/dist/spaces-DxFj5y8l.d.mts +415 -0
  302. package/dist/spaces-DxFj5y8l.d.mts.map +1 -0
  303. package/dist/telemetry-CmbCa3Ld-CmE5zcIG.mjs +120 -0
  304. package/dist/telemetry-CmbCa3Ld-CmE5zcIG.mjs.map +1 -0
  305. package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts +133 -0
  306. package/dist/terminal-ui-BN4QOsm5-Bf3pim46.d.mts.map +1 -0
  307. package/dist/type-expression-safety-CgHTWypx.mjs +8 -0
  308. package/dist/type-expression-safety-CgHTWypx.mjs.map +1 -0
  309. package/dist/types-DZWEs4si-D8UlyJI0.d.mts +893 -0
  310. package/dist/types-DZWEs4si-D8UlyJI0.d.mts.map +1 -0
  311. package/dist/verify-DnVNjc5C-BGdsblBK.mjs +283 -0
  312. package/dist/verify-DnVNjc5C-BGdsblBK.mjs.map +1 -0
  313. package/dist/verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs +252 -0
  314. package/dist/verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs.map +1 -0
  315. package/dist/verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts +136 -0
  316. package/dist/verify-contract-spaces-Cc1u_wJo-BilPJS2S.d.mts.map +1 -0
  317. package/dist/vite-plugin-contract-emit.d.mts +54 -0
  318. package/dist/vite-plugin-contract-emit.d.mts.map +1 -0
  319. package/dist/vite-plugin-contract-emit.mjs +303 -0
  320. package/dist/vite-plugin-contract-emit.mjs.map +1 -0
  321. package/package.json +127 -0
@@ -0,0 +1,135 @@
1
+ //#region ../../../0-shared/publish-surface/dist/shells.d.mts
2
+ //#region src/shells.d.ts
3
+ /**
4
+ * Canonical mapping of internal workspace packages to public publish shells
5
+ * (ADR 242). Each internal package becomes a subpath entrypoint namespace of
6
+ * exactly one published `@prisma/orm-*` shell: the internal root export maps
7
+ * to `@prisma/<shell>/<entry>` and each internal subpath `./x` maps to
8
+ * `@prisma/<shell>/<entry>/x`.
9
+ *
10
+ * Consumed by the shell build (`@repo/tsdown/shell-build`), by the
11
+ * emitters' import-root resolution (`./import-roots`), and later by the
12
+ * publish-surface lint.
13
+ */
14
+ /**
15
+ * How an application acquires a shell, which decides whether emitted code may
16
+ * name it. See `directDependencyShells` in `./import-roots`.
17
+ */
18
+ type ShellKind =
19
+ /** Installed directly only by a decomposed application. */
20
+ 'platform' |
21
+ /** The one-package install for a database; carries the platform shells. */
22
+ 'facade' |
23
+ /** Installed directly alongside whatever else the application uses. */
24
+ 'extension';
25
+ interface ShellPackageMapping {
26
+ /** Internal package directory, relative to the repository root. */
27
+ readonly dir: string;
28
+ /**
29
+ * Internal package name, e.g. `@internal/contract`. Declared rather than
30
+ * read from `dir/package.json` so specifier resolution works inside a
31
+ * published bundle, where the workspace is not on disk. A test keeps the
32
+ * two in step.
33
+ */
34
+ readonly name: string;
35
+ /**
36
+ * Entrypoint namespace inside the shell. The empty string places the
37
+ * package directly at the shell's own namespace, so its `./x` export
38
+ * becomes `@prisma/<shell>/x` — the shape facades and extension packs
39
+ * use, where the shell publishes a single internal package under its
40
+ * own name.
41
+ */
42
+ readonly entry: string;
43
+ /**
44
+ * Whether the package contributes entrypoints. Defaults to true.
45
+ *
46
+ * Set false for code that belongs in this shell's bundle but that nothing
47
+ * imports by name — the shell still owns it, so a sibling depending on it
48
+ * resolves within the shell rather than across one, but no `exports` entry
49
+ * is published and the module is reached only through whatever already
50
+ * pulls it in.
51
+ */
52
+ readonly published?: boolean;
53
+ }
54
+ interface ShellReexportMapping {
55
+ /** Internal package name whose surface is forwarded, e.g. `@internal/contract`. */
56
+ readonly package: string;
57
+ /** Entrypoint namespace inside this shell that forwards to it. */
58
+ readonly entry: string;
59
+ /**
60
+ * Whether `<entry>` itself forwards the package as a whole. Set false when
61
+ * the shell's own code already owns that name and only the subpaths
62
+ * `<entry>/x` should forward. Defaults to true.
63
+ */
64
+ readonly root?: boolean;
65
+ /**
66
+ * The subpaths of `package` this entry forwards, without the `./` prefix.
67
+ * Omitted forwards every subpath the package exports.
68
+ *
69
+ * Forwarding a whole package costs one published entrypoint per subpath it
70
+ * exports, which is the right price for a surface an application uses as a
71
+ * whole. It is the wrong price for a large tooling package a facade needs a
72
+ * corner of: listing the subpaths keeps the rest of that package off the
73
+ * published surface, so it stays free to change.
74
+ */
75
+ readonly subpaths?: readonly string[];
76
+ }
77
+ interface ShellDefinition {
78
+ /** Shell directory relative to the repository root. */
79
+ readonly dir: string;
80
+ readonly kind: ShellKind;
81
+ readonly packages: readonly ShellPackageMapping[];
82
+ /**
83
+ * Surfaces of *other* shells republished under this shell's own
84
+ * entrypoints. Nothing is copied: each generated entry re-exports the
85
+ * sibling shell's published entrypoint, which the shell declares as an
86
+ * exact-pinned dependency. Facades carry the contract surfaces this way
87
+ * so that code generated for an application that installs only the
88
+ * facade imports nothing but a direct dependency (ADR 242).
89
+ */
90
+ readonly reexports?: readonly ShellReexportMapping[];
91
+ /**
92
+ * Bin scripts carried by the shell: bin name to a dist file of one of the
93
+ * internal packages (relative to the repository root). The file is bundled
94
+ * as a side-effect entry named `bin/<binName>`, and published both as the
95
+ * `bin` field and as the `./bin/<binName>` entrypoint so another shell can
96
+ * forward it.
97
+ */
98
+ readonly bins?: Readonly<Record<string, string>>;
99
+ /**
100
+ * Bin scripts this shell re-exposes from another shell: bin name to that
101
+ * shell's `./bin/<binName>` entrypoint. The generated launcher imports the
102
+ * sibling for its side effects, so the command runs the one published copy
103
+ * of the program rather than a second one.
104
+ *
105
+ * Facades carry the CLI this way because an application installs only the
106
+ * facade, and package managers put a package manager's own direct
107
+ * dependencies on `PATH` — a transitively installed bin is not runnable.
108
+ */
109
+ readonly forwardedBins?: Readonly<Record<string, string>>;
110
+ /**
111
+ * Sibling shells this shell requires the installer to provide, declared as
112
+ * peer dependencies rather than pulled in as its own copy.
113
+ *
114
+ * Extension packs use this for the target shell they extend (ADR 242).
115
+ * A hard dependency would let an application upgrade the facade without
116
+ * upgrading the extension and end up with two copies of the target — the
117
+ * codec and operation registries would silently diverge and `instanceof`
118
+ * would stop holding. As a peer, that combination fails to install
119
+ * instead.
120
+ */
121
+ readonly peerShells?: readonly ShellName[];
122
+ /**
123
+ * Extra dist files to copy into the shell's dist root (globs relative to
124
+ * the repository root), e.g. templates an internal package reads next to
125
+ * its code via `import.meta.dirname`.
126
+ */
127
+ readonly copy?: readonly string[];
128
+ }
129
+ type ShellName = '@prisma/orm-framework' | '@prisma/orm-toolchain' | '@prisma/orm-family-sql' | '@prisma/orm-family-mongo' | '@prisma/orm-target-postgres' | '@prisma/orm-target-sqlite' | '@prisma/orm-target-mongo' | '@prisma/orm-postgres' | '@prisma/orm-sqlite' | '@prisma/orm-mongo' | '@prisma/orm-extension-postgis' | '@prisma/orm-extension-pgvector' | '@prisma/orm-extension-paradedb' | '@prisma/orm-extension-supabase' | '@prisma/orm-extension-arktype-json' | '@prisma/orm-extension-middleware-cache';
130
+ declare const publicShells: ReadonlyMap<ShellName, ShellDefinition>;
131
+ /** Export subpaths that never ship in a shell (test-only surfaces). */
132
+ declare const excludedSubpaths: readonly RegExp[];
133
+ //#endregion
134
+ export { ShellReexportMapping as a, ShellPackageMapping as i, ShellKind as n, excludedSubpaths as o, ShellName as r, publicShells as s, ShellDefinition as t };
135
+ //# sourceMappingURL=shells-COHV_Ozf.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shells-COHV_Ozf.d.mts","names":[],"sources":["../../../../0-shared/publish-surface/dist/shells.d.mts"],"mappings":";;;;;;;;;;;;;;;;;KAgBK;;;;;;;UAOK;;WAEC;;;;;;;WAOA;;;;;;;;WAQA;;;;;;;;;;WAUA;;UAED;;WAEC;;WAEA;;;;;;WAMA;;;;;;;;;;;WAWA;;UAED;;WAEC;WACA,MAAM;WACN,mBAAmB;;;;;;;;;WASnB,qBAAqB;;;;;;;;WAQrB,OAAO,SAAS;;;;;;;;;;;WAWhB,gBAAgB,SAAS;;;;;;;;;;;;WAYzB,sBAAsB;;;;;;WAMtB;;KAEN;cACS,cAAc,YAAY,WAAW;;cAErC,2BAA2B"}
@@ -0,0 +1,267 @@
1
+ import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
+ import { o as writeContractSnapshot } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
3
+ import { s as readMigrationsDir } from "./io-C8TdyBKt-DloEBi70.mjs";
4
+ import { l as reconstructGraph, o as findPathWithDecision } from "./migration-graph-CBf9ORe7-B4xAF8GN.mjs";
5
+ import { c as spaceMigrationDirectory, i as assertValidSpaceId, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID } from "./verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs";
6
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
7
+ import { join } from "pathe";
8
+ import { mkdir, writeFile } from "node:fs/promises";
9
+ import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
10
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
11
+ import { computeStorageHash } from "@prisma/orm-framework/contract/hashing";
12
+ //#region ../../../1-framework/3-tooling/migration/dist/exports/spaces.mjs
13
+ /**
14
+ * Assert that an extension descriptor is self-consistent: the
15
+ * `headRef.hash` it publishes must match the canonical hash recomputed
16
+ * from its `contractSpace.contractJson`.
17
+ *
18
+ * Recomputes via {@link computeStorageHash} — the same canonical-JSON
19
+ * pipeline the descriptor's own emit pipeline produced the hash with —
20
+ * over `(target, targetFamily, storage)`. Mismatch indicates the
21
+ * extension author bumped `contractJson` without rerunning emit, leaving
22
+ * the descriptor's `headRef.hash` stale; the consumer-side helpers
23
+ * (drift detection, on-disk artefact emission, runner marker writes) all
24
+ * trust `headRef.hash` as the canonical identity, so a stale value would
25
+ * silently corrupt every downstream boundary.
26
+ *
27
+ * Synchronous, pure, no I/O. Throws
28
+ * `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH` on failure with both the
29
+ * recomputed and published hashes in `details` so callers can surface a
30
+ * clear remediation hint without re-deriving them.
31
+ */
32
+ function assertDescriptorSelfConsistency(inputs) {
33
+ const { storageHash: _stripped, ...storageWithoutHash } = inputs.storage;
34
+ const recomputed = computeStorageHash({
35
+ target: inputs.target,
36
+ targetFamily: inputs.targetFamily,
37
+ storage: storageWithoutHash,
38
+ ...ifDefined("shouldPreserveEmpty", inputs.shouldPreserveEmpty),
39
+ ...ifDefined("sortStorage", inputs.sortStorage)
40
+ });
41
+ if (recomputed !== inputs.headRefHash) throw errorDescriptorHeadHashMismatch({
42
+ extensionId: inputs.extensionId,
43
+ recomputedHash: recomputed,
44
+ headRefHash: inputs.headRefHash
45
+ });
46
+ }
47
+ /**
48
+ * Compute the apply path for an extension contract space — the shortest
49
+ * sequence of on-disk migration packages that walks the live marker
50
+ * forward to the on-disk head ref hash, covering every required
51
+ * invariant.
52
+ *
53
+ * Reads only on-disk artifacts (`migrations/<spaceId>/refs/head.json`
54
+ * and the per-space migration packages). **Does not import any
55
+ * extension descriptor module** — `db init` / `db update` must remain
56
+ * runnable without the descriptor source on disk.
57
+ *
58
+ * Behaviour:
59
+ * - Returns `{ kind: 'ok', pathOps: [], … }` when the marker is already
60
+ * at the recorded head and no required invariants are missing.
61
+ * - Returns `{ kind: 'unreachable' }` when the marker hash is not
62
+ * structurally connected to the recorded head in the graph.
63
+ * - Returns `{ kind: 'unsatisfiable', missing, … }` when the marker is
64
+ * reachable but no path covers the required invariants.
65
+ * - Returns `{ kind: 'contractSpaceHeadRefMissing' }` when the per-space
66
+ * `refs/head.json` is absent — the precheck verifier should already
67
+ * have rejected this case, but the helper is defensive so callers can
68
+ * surface a coherent error rather than throw.
69
+ */
70
+ async function computeExtensionSpaceApplyPath(inputs) {
71
+ const { projectMigrationsDir, spaceId, currentMarkerHash, currentMarkerInvariants } = inputs;
72
+ const contractSpaceHeadRef = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);
73
+ if (contractSpaceHeadRef === null) return { kind: "contractSpaceHeadRefMissing" };
74
+ const { packages } = await readMigrationsDir(spaceMigrationDirectory(projectMigrationsDir, spaceId), { migrationsDir: projectMigrationsDir });
75
+ const graph = reconstructGraph(packages);
76
+ const fromHash = currentMarkerHash ?? "empty";
77
+ const required = new Set(contractSpaceHeadRef.invariants.filter((id) => !currentMarkerInvariants.includes(id)));
78
+ const outcome = findPathWithDecision(graph, fromHash, contractSpaceHeadRef.hash, { required });
79
+ if (outcome.kind === "unreachable") return {
80
+ kind: "unreachable",
81
+ contractSpaceHeadRef
82
+ };
83
+ if (outcome.kind === "unsatisfiable") return {
84
+ kind: "unsatisfiable",
85
+ contractSpaceHeadRef,
86
+ missing: outcome.missing,
87
+ structuralPath: outcome.structuralPath.map(({ dirName, to }) => ({
88
+ dirName,
89
+ to
90
+ }))
91
+ };
92
+ const packagesByHash = new Map(packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));
93
+ const pathOps = [];
94
+ const walkedMigrationDirs = [];
95
+ const providedInvariantsSet = /* @__PURE__ */ new Set();
96
+ for (const edge of outcome.decision.selectedPath) {
97
+ const pkg = packagesByHash.get(edge.migrationHash);
98
+ if (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space "${spaceId}"`);
99
+ walkedMigrationDirs.push(pkg.dirName);
100
+ for (const op of pkg.ops) pathOps.push(op);
101
+ for (const invariant of pkg.metadata.providedInvariants) providedInvariantsSet.add(invariant);
102
+ }
103
+ return {
104
+ kind: "ok",
105
+ contractSpaceHeadRef,
106
+ providedInvariants: [...providedInvariantsSet].sort(),
107
+ pathOps,
108
+ walkedMigrationDirs
109
+ };
110
+ }
111
+ /**
112
+ * Materialise a typed {@link ContractSpace} from the JSON artefacts a
113
+ * contract-space extension package emits to disk.
114
+ *
115
+ * Extension descriptors wire `contract.json`, per-migration
116
+ * `migration.json` / `ops.json`, and `refs/head.json` to the framework's
117
+ * typed surfaces. TypeScript widens JSON imports to a structural record
118
+ * that does not preserve readonly modifiers or branded scalars (e.g.
119
+ * `StorageHashBase<'abc123...'>`), so authoring the descriptor inline
120
+ * forces every wiring site to cast through `unknown`. This helper
121
+ * encapsulates the single narrowing point: descriptor sources stay
122
+ * cast-free, and the (necessary) coercion is colocated with the
123
+ * documentation explaining why it is safe.
124
+ *
125
+ * Safety: the JSON files passed here are produced by the framework's own
126
+ * emit pipeline (`prisma-next contract emit` and `MigrationCLI.run`)
127
+ * and re-validated downstream by the runner / verifier. The descriptor
128
+ * is a pass-through wiring layer — no descriptor consumer treats the
129
+ * narrowed types as a stronger guarantee than "these came from the
130
+ * canonical emit pipeline".
131
+ *
132
+ * The helper does not introspect or schema-validate the inputs; runtime
133
+ * validation is the responsibility of `family.deserializeContract`
134
+ * (codec-aware, invoked at control-stack construction) and the
135
+ * per-migration `readMigrationPackage` reader used when loading
136
+ * from disk. JSON-imported packages flow through the descriptor without
137
+ * a disk read, so the equivalent runtime guarantee comes from the emit
138
+ * pipeline that produced the JSON in the first place.
139
+ */
140
+ function contractSpaceFromJson(inputs) {
141
+ const migrations = inputs.migrations.map((m) => ({
142
+ dirName: m.dirName,
143
+ metadata: m.metadata,
144
+ ops: m.ops
145
+ }));
146
+ return {
147
+ contractJson: inputs.contractJson,
148
+ migrations,
149
+ headRef: inputs.headRef
150
+ };
151
+ }
152
+ /**
153
+ * Emit the per-space artifacts — the head contract snapshot (written into
154
+ * the migrations-root-wide `snapshots/` store, keyed by `headRef.hash`) and
155
+ * `refs/head.json` — under `<projectMigrationsDir>/<spaceId>/`.
156
+ *
157
+ * The head contract snapshot is write-if-absent (see
158
+ * {@link writeContractSnapshot}): a changed extension contract has a new
159
+ * hash, so it lands as a new store entry; an unchanged hash means identical
160
+ * canonical content already sits there. `refs/head.json` stays
161
+ * always-overwrite: the framework owns it, so running `migrate` twice with
162
+ * the same inputs is a no-op observably (idempotent), but the helper does
163
+ * not check pre-existing contents — re-emit always wins.
164
+ *
165
+ * Path layout matches the convention in
166
+ * [`spaceMigrationDirectory`](./space-layout.ts). The space id is
167
+ * validated against `[a-z][a-z0-9_-]{0,63}` via
168
+ * {@link assertValidSpaceId} for filesystem-safety reasons; the helper
169
+ * accepts every space uniformly (including the app space, default
170
+ * `'app'`).
171
+ *
172
+ * The migrations directory and space subdirectory are created if they
173
+ * do not yet exist (`mkdir { recursive: true }`).
174
+ */
175
+ async function emitContractSpaceArtifacts(projectMigrationsDir, spaceId, inputs) {
176
+ assertValidSpaceId(spaceId);
177
+ const refsDir = spaceRefsDirectory(join(projectMigrationsDir, spaceId));
178
+ await mkdir(refsDir, { recursive: true });
179
+ await writeContractSnapshot(projectMigrationsDir, inputs.headRef.hash, {
180
+ contractJson: inputs.contract,
181
+ contractDts: inputs.contractDts
182
+ });
183
+ const sortedInvariants = [...inputs.headRef.invariants].sort();
184
+ const headJson = canonicalizeJson({
185
+ hash: inputs.headRef.hash,
186
+ invariants: sortedInvariants
187
+ });
188
+ await writeFile(join(refsDir, "head.json"), `${headJson}\n`);
189
+ }
190
+ /**
191
+ * Read the on-disk state the per-space verifier needs:
192
+ *
193
+ * - The list of contract-space directories under
194
+ * `<projectMigrationsDir>/` (via
195
+ * {@link import('./verify-contract-spaces').listContractSpaceDirectories}).
196
+ * - The on-disk head ref `(hash, invariants)` for each declared extension space
197
+ * (via {@link readContractSpaceHeadRef}; missing on-disk artefacts are simply
198
+ * omitted — the verifier reports them as `declaredButUnmigrated`).
199
+ *
200
+ * Synchronous in spirit but async due to filesystem reads. Reads only
201
+ * the user's repo. **Does not import any extension descriptor module.**
202
+ *
203
+ * Composition convention: pure target-agnostic primitive in
204
+ * `1-framework`; the SQL family (and any future target family) wires
205
+ * it into its `dbInit` / `verify` flows alongside its own marker-row
206
+ * read before invoking `verifyContractSpaces`.
207
+ */
208
+ async function gatherDiskContractSpaceState(args) {
209
+ const { projectMigrationsDir, loadedSpaceIds } = args;
210
+ const spaceDirsOnDisk = await listContractSpaceDirectories(projectMigrationsDir);
211
+ const headRefsBySpace = /* @__PURE__ */ new Map();
212
+ for (const spaceId of loadedSpaceIds) {
213
+ if (spaceId === APP_SPACE_ID) continue;
214
+ const head = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);
215
+ if (head !== null) headRefsBySpace.set(spaceId, head);
216
+ }
217
+ return {
218
+ spaceDirsOnDisk,
219
+ headRefsBySpace
220
+ };
221
+ }
222
+ /**
223
+ * Iterate the per-space planner across a set of loaded contract spaces
224
+ * and return a deterministic shape regardless of declaration order.
225
+ *
226
+ * Behaviour:
227
+ *
228
+ * - The output is sorted alphabetically by `spaceId`. Two callers
229
+ * passing the same set of inputs in different orders observe
230
+ * byte-identical outputs.
231
+ * - The per-space planner (`planSpace`) is called exactly once per
232
+ * input, in alphabetical-by-spaceId order. Its return value is
233
+ * attached to the corresponding output entry verbatim.
234
+ * - Duplicate `spaceId`s in the input array throw
235
+ * `MIGRATION.DUPLICATE_SPACE_ID` before any `planSpace` call runs,
236
+ * keeping the planner pure when the input is malformed.
237
+ *
238
+ * The signature is generic over `TContract` and `TPackage` because the
239
+ * shape is framework-neutral (SQL family today, Mongo family
240
+ * eventually). Callers wire in whatever contract value and migration
241
+ * package shape their family already speaks.
242
+ *
243
+ * Synchronous: the underlying per-space planner (target's
244
+ * `MigrationPlanner.plan(...)`) is synchronous; callers that need to
245
+ * resolve async I/O (e.g. reading on-disk `contract.json` from disk)
246
+ * resolve it before calling `planAllSpaces` and pass the materialised
247
+ * inputs through.
248
+ */
249
+ function planAllSpaces(inputs, planSpace) {
250
+ const seen = /* @__PURE__ */ new Set();
251
+ for (const input of inputs) {
252
+ if (seen.has(input.spaceId)) throw errorDuplicateSpaceId(input.spaceId);
253
+ seen.add(input.spaceId);
254
+ }
255
+ return [...inputs].sort((a, b) => {
256
+ if (a.spaceId < b.spaceId) return -1;
257
+ if (a.spaceId > b.spaceId) return 1;
258
+ return 0;
259
+ }).map((input) => ({
260
+ spaceId: input.spaceId,
261
+ migrationPackages: planSpace(input)
262
+ }));
263
+ }
264
+ //#endregion
265
+ export { gatherDiskContractSpaceState as a, emitContractSpaceArtifacts as i, computeExtensionSpaceApplyPath as n, planAllSpaces as o, contractSpaceFromJson as r, assertDescriptorSelfConsistency as t };
266
+
267
+ //# sourceMappingURL=spaces-C27bA-xc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spaces-C27bA-xc.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/spaces.mjs"],"sourcesContent":["import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from \"../errors-IpZm1Skp.mjs\";\nimport { o as writeContractSnapshot } from \"../contract-snapshot-store-sf5nP4mb.mjs\";\nimport { s as readMigrationsDir } from \"../io-C8TdyBKt.mjs\";\nimport \"../constants-CM-w38DQ.mjs\";\nimport { l as reconstructGraph, o as findPathWithDecision } from \"../migration-graph-CBf9ORe7.mjs\";\nimport { a as RESERVED_SPACE_SUBDIR_NAMES, c as isValidSpaceId, i as APP_SPACE_ID, l as spaceMigrationDirectory, n as verifyContractSpaces, o as SPACE_REFS_DIRNAME, r as readContractSpaceHeadRef, s as assertValidSpaceId, t as listContractSpaceDirectories, u as spaceRefsDirectory } from \"../verify-contract-spaces-BZDcJsuA.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { join } from \"pathe\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { computeStorageHash } from \"@internal/contract/hashing\";\n//#region src/assert-descriptor-self-consistency.ts\n/**\n* Assert that an extension descriptor is self-consistent: the\n* `headRef.hash` it publishes must match the canonical hash recomputed\n* from its `contractSpace.contractJson`.\n*\n* Recomputes via {@link computeStorageHash} — the same canonical-JSON\n* pipeline the descriptor's own emit pipeline produced the hash with —\n* over `(target, targetFamily, storage)`. Mismatch indicates the\n* extension author bumped `contractJson` without rerunning emit, leaving\n* the descriptor's `headRef.hash` stale; the consumer-side helpers\n* (drift detection, on-disk artefact emission, runner marker writes) all\n* trust `headRef.hash` as the canonical identity, so a stale value would\n* silently corrupt every downstream boundary.\n*\n* Synchronous, pure, no I/O. Throws\n* `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH` on failure with both the\n* recomputed and published hashes in `details` so callers can surface a\n* clear remediation hint without re-deriving them.\n*/\nfunction assertDescriptorSelfConsistency(inputs) {\n\tconst { storageHash: _stripped, ...storageWithoutHash } = inputs.storage;\n\tconst recomputed = computeStorageHash({\n\t\ttarget: inputs.target,\n\t\ttargetFamily: inputs.targetFamily,\n\t\tstorage: storageWithoutHash,\n\t\t...ifDefined(\"shouldPreserveEmpty\", inputs.shouldPreserveEmpty),\n\t\t...ifDefined(\"sortStorage\", inputs.sortStorage)\n\t});\n\tif (recomputed !== inputs.headRefHash) throw errorDescriptorHeadHashMismatch({\n\t\textensionId: inputs.extensionId,\n\t\trecomputedHash: recomputed,\n\t\theadRefHash: inputs.headRefHash\n\t});\n}\n//#endregion\n//#region src/compute-extension-space-apply-path.ts\n/**\n* Compute the apply path for an extension contract space — the shortest\n* sequence of on-disk migration packages that walks the live marker\n* forward to the on-disk head ref hash, covering every required\n* invariant.\n*\n* Reads only on-disk artifacts (`migrations/<spaceId>/refs/head.json`\n* and the per-space migration packages). **Does not import any\n* extension descriptor module** — `db init` / `db update` must remain\n* runnable without the descriptor source on disk.\n*\n* Behaviour:\n* - Returns `{ kind: 'ok', pathOps: [], … }` when the marker is already\n* at the recorded head and no required invariants are missing.\n* - Returns `{ kind: 'unreachable' }` when the marker hash is not\n* structurally connected to the recorded head in the graph.\n* - Returns `{ kind: 'unsatisfiable', missing, … }` when the marker is\n* reachable but no path covers the required invariants.\n* - Returns `{ kind: 'contractSpaceHeadRefMissing' }` when the per-space\n* `refs/head.json` is absent — the precheck verifier should already\n* have rejected this case, but the helper is defensive so callers can\n* surface a coherent error rather than throw.\n*/\nasync function computeExtensionSpaceApplyPath(inputs) {\n\tconst { projectMigrationsDir, spaceId, currentMarkerHash, currentMarkerInvariants } = inputs;\n\tconst contractSpaceHeadRef = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\tif (contractSpaceHeadRef === null) return { kind: \"contractSpaceHeadRefMissing\" };\n\tconst { packages } = await readMigrationsDir(spaceMigrationDirectory(projectMigrationsDir, spaceId), { migrationsDir: projectMigrationsDir });\n\tconst graph = reconstructGraph(packages);\n\tconst fromHash = currentMarkerHash ?? \"empty\";\n\tconst required = new Set(contractSpaceHeadRef.invariants.filter((id) => !currentMarkerInvariants.includes(id)));\n\tconst outcome = findPathWithDecision(graph, fromHash, contractSpaceHeadRef.hash, { required });\n\tif (outcome.kind === \"unreachable\") return {\n\t\tkind: \"unreachable\",\n\t\tcontractSpaceHeadRef\n\t};\n\tif (outcome.kind === \"unsatisfiable\") return {\n\t\tkind: \"unsatisfiable\",\n\t\tcontractSpaceHeadRef,\n\t\tmissing: outcome.missing,\n\t\tstructuralPath: outcome.structuralPath.map(({ dirName, to }) => ({\n\t\t\tdirName,\n\t\t\tto\n\t\t}))\n\t};\n\tconst packagesByHash = new Map(packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\tconst pathOps = [];\n\tconst walkedMigrationDirs = [];\n\tconst providedInvariantsSet = /* @__PURE__ */ new Set();\n\tfor (const edge of outcome.decision.selectedPath) {\n\t\tconst pkg = packagesByHash.get(edge.migrationHash);\n\t\tif (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space \"${spaceId}\"`);\n\t\twalkedMigrationDirs.push(pkg.dirName);\n\t\tfor (const op of pkg.ops) pathOps.push(op);\n\t\tfor (const invariant of pkg.metadata.providedInvariants) providedInvariantsSet.add(invariant);\n\t}\n\treturn {\n\t\tkind: \"ok\",\n\t\tcontractSpaceHeadRef,\n\t\tprovidedInvariants: [...providedInvariantsSet].sort(),\n\t\tpathOps,\n\t\twalkedMigrationDirs\n\t};\n}\n//#endregion\n//#region src/contract-space-from-json.ts\n/**\n* Materialise a typed {@link ContractSpace} from the JSON artefacts a\n* contract-space extension package emits to disk.\n*\n* Extension descriptors wire `contract.json`, per-migration\n* `migration.json` / `ops.json`, and `refs/head.json` to the framework's\n* typed surfaces. TypeScript widens JSON imports to a structural record\n* that does not preserve readonly modifiers or branded scalars (e.g.\n* `StorageHashBase<'abc123...'>`), so authoring the descriptor inline\n* forces every wiring site to cast through `unknown`. This helper\n* encapsulates the single narrowing point: descriptor sources stay\n* cast-free, and the (necessary) coercion is colocated with the\n* documentation explaining why it is safe.\n*\n* Safety: the JSON files passed here are produced by the framework's own\n* emit pipeline (`prisma-next contract emit` and `MigrationCLI.run`)\n* and re-validated downstream by the runner / verifier. The descriptor\n* is a pass-through wiring layer — no descriptor consumer treats the\n* narrowed types as a stronger guarantee than \"these came from the\n* canonical emit pipeline\".\n*\n* The helper does not introspect or schema-validate the inputs; runtime\n* validation is the responsibility of `family.deserializeContract`\n* (codec-aware, invoked at control-stack construction) and the\n* per-migration `readMigrationPackage` reader used when loading\n* from disk. JSON-imported packages flow through the descriptor without\n* a disk read, so the equivalent runtime guarantee comes from the emit\n* pipeline that produced the JSON in the first place.\n*/\nfunction contractSpaceFromJson(inputs) {\n\tconst migrations = inputs.migrations.map((m) => ({\n\t\tdirName: m.dirName,\n\t\tmetadata: m.metadata,\n\t\tops: m.ops\n\t}));\n\treturn {\n\t\tcontractJson: inputs.contractJson,\n\t\tmigrations,\n\t\theadRef: inputs.headRef\n\t};\n}\n//#endregion\n//#region src/emit-contract-space-artifacts.ts\n/**\n* Emit the per-space artifacts — the head contract snapshot (written into\n* the migrations-root-wide `snapshots/` store, keyed by `headRef.hash`) and\n* `refs/head.json` — under `<projectMigrationsDir>/<spaceId>/`.\n*\n* The head contract snapshot is write-if-absent (see\n* {@link writeContractSnapshot}): a changed extension contract has a new\n* hash, so it lands as a new store entry; an unchanged hash means identical\n* canonical content already sits there. `refs/head.json` stays\n* always-overwrite: the framework owns it, so running `migrate` twice with\n* the same inputs is a no-op observably (idempotent), but the helper does\n* not check pre-existing contents — re-emit always wins.\n*\n* Path layout matches the convention in\n* [`spaceMigrationDirectory`](./space-layout.ts). The space id is\n* validated against `[a-z][a-z0-9_-]{0,63}` via\n* {@link assertValidSpaceId} for filesystem-safety reasons; the helper\n* accepts every space uniformly (including the app space, default\n* `'app'`).\n*\n* The migrations directory and space subdirectory are created if they\n* do not yet exist (`mkdir { recursive: true }`).\n*/\nasync function emitContractSpaceArtifacts(projectMigrationsDir, spaceId, inputs) {\n\tassertValidSpaceId(spaceId);\n\tconst refsDir = spaceRefsDirectory(join(projectMigrationsDir, spaceId));\n\tawait mkdir(refsDir, { recursive: true });\n\tawait writeContractSnapshot(projectMigrationsDir, inputs.headRef.hash, {\n\t\tcontractJson: inputs.contract,\n\t\tcontractDts: inputs.contractDts\n\t});\n\tconst sortedInvariants = [...inputs.headRef.invariants].sort();\n\tconst headJson = canonicalizeJson({\n\t\thash: inputs.headRef.hash,\n\t\tinvariants: sortedInvariants\n\t});\n\tawait writeFile(join(refsDir, \"head.json\"), `${headJson}\\n`);\n}\n//#endregion\n//#region src/gather-disk-contract-space-state.ts\n/**\n* Read the on-disk state the per-space verifier needs:\n*\n* - The list of contract-space directories under\n* `<projectMigrationsDir>/` (via\n* {@link import('./verify-contract-spaces').listContractSpaceDirectories}).\n* - The on-disk head ref `(hash, invariants)` for each declared extension space\n* (via {@link readContractSpaceHeadRef}; missing on-disk artefacts are simply\n* omitted — the verifier reports them as `declaredButUnmigrated`).\n*\n* Synchronous in spirit but async due to filesystem reads. Reads only\n* the user's repo. **Does not import any extension descriptor module.**\n*\n* Composition convention: pure target-agnostic primitive in\n* `1-framework`; the SQL family (and any future target family) wires\n* it into its `dbInit` / `verify` flows alongside its own marker-row\n* read before invoking `verifyContractSpaces`.\n*/\nasync function gatherDiskContractSpaceState(args) {\n\tconst { projectMigrationsDir, loadedSpaceIds } = args;\n\tconst spaceDirsOnDisk = await listContractSpaceDirectories(projectMigrationsDir);\n\tconst headRefsBySpace = /* @__PURE__ */ new Map();\n\tfor (const spaceId of loadedSpaceIds) {\n\t\tif (spaceId === APP_SPACE_ID) continue;\n\t\tconst head = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\t\tif (head !== null) headRefsBySpace.set(spaceId, head);\n\t}\n\treturn {\n\t\tspaceDirsOnDisk,\n\t\theadRefsBySpace\n\t};\n}\n//#endregion\n//#region src/plan-all-spaces.ts\n/**\n* Iterate the per-space planner across a set of loaded contract spaces\n* and return a deterministic shape regardless of declaration order.\n*\n* Behaviour:\n*\n* - The output is sorted alphabetically by `spaceId`. Two callers\n* passing the same set of inputs in different orders observe\n* byte-identical outputs.\n* - The per-space planner (`planSpace`) is called exactly once per\n* input, in alphabetical-by-spaceId order. Its return value is\n* attached to the corresponding output entry verbatim.\n* - Duplicate `spaceId`s in the input array throw\n* `MIGRATION.DUPLICATE_SPACE_ID` before any `planSpace` call runs,\n* keeping the planner pure when the input is malformed.\n*\n* The signature is generic over `TContract` and `TPackage` because the\n* shape is framework-neutral (SQL family today, Mongo family\n* eventually). Callers wire in whatever contract value and migration\n* package shape their family already speaks.\n*\n* Synchronous: the underlying per-space planner (target's\n* `MigrationPlanner.plan(...)`) is synchronous; callers that need to\n* resolve async I/O (e.g. reading on-disk `contract.json` from disk)\n* resolve it before calling `planAllSpaces` and pass the materialised\n* inputs through.\n*/\nfunction planAllSpaces(inputs, planSpace) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (const input of inputs) {\n\t\tif (seen.has(input.spaceId)) throw errorDuplicateSpaceId(input.spaceId);\n\t\tseen.add(input.spaceId);\n\t}\n\treturn [...inputs].sort((a, b) => {\n\t\tif (a.spaceId < b.spaceId) return -1;\n\t\tif (a.spaceId > b.spaceId) return 1;\n\t\treturn 0;\n\t}).map((input) => ({\n\t\tspaceId: input.spaceId,\n\t\tmigrationPackages: planSpace(input)\n\t}));\n}\n//#endregion\nexport { APP_SPACE_ID, RESERVED_SPACE_SUBDIR_NAMES, SPACE_REFS_DIRNAME, assertDescriptorSelfConsistency, assertValidSpaceId, computeExtensionSpaceApplyPath, contractSpaceFromJson, emitContractSpaceArtifacts, gatherDiskContractSpaceState, isValidSpaceId, listContractSpaceDirectories, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory, verifyContractSpaces };\n\n//# sourceMappingURL=spaces.mjs.map"],"mappings":"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"}