@prisma/orm-toolchain 0.16.0

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-DcwUnadt-B6Qoh0ot.mjs +597 -0
  191. package/dist/migration-check-DcwUnadt-B6Qoh0ot.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-CE7cQLDq-B1jDVmqG.mjs +444 -0
  217. package/dist/migration-status-CE7cQLDq-B1jDVmqG.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-CfGSxH5b-BSjB3nZS.d.mts +192 -0
  292. package/dist/schemas-CfGSxH5b-BSjB3nZS.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 +122 -0
@@ -0,0 +1,114 @@
1
+ # Welcome to Prisma Next!
2
+
3
+ Prisma Next lets you query your database in simple, easy-to-read TypeScript. Define what your data looks like, and Prisma Next gives you a fully typed client — with autocomplete for every collection, field, and relation.
4
+
5
+ This project is set up for MongoDB. Prisma Next also supports other databases.
6
+
7
+ {{requirements}}
8
+
9
+ ## Your data contract
10
+
11
+ Your data contract is the heart of your application. It lives at [`{{schemaPath}}`]({{schemaPath}}) and describes your models:
12
+
13
+ {{schemaSample}}
14
+
15
+ Every model you define in your contract can be queried from your app. Your editor will autocomplete the query methods and show you what type each field is:
16
+
17
+ ```typescript
18
+ import { db } from '{{dbImportPath}}';
19
+
20
+ const user = await db.orm.users
21
+ .where({ email: 'alice@example.com' })
22
+ .first();
23
+
24
+ // Your editor will show the type of user as
25
+ // { _id: ObjectId; email: string; username: string | null; name: string | null; posts: Post[] } | null
26
+ ```
27
+
28
+ `db` connects to MongoDB lazily on the first query, so there is no manual `connect(...)` step in your application code. Call `await db.close()` if you need to release the underlying connection (typically only in tests or short-lived scripts). After `close()` the client is single-shot — any further query, `connect()`, or `runtime()` call rejects with `"Mongo client is closed"`. Construct a new `mongo({...})` if you need to use it again.
29
+
30
+ Your contract has two companion files in the same directory:
31
+
32
+ - **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
33
+ - **`contract.d.ts`** — this powers autocomplete and type checking in your editor
34
+
35
+ Commit both files to git. When you change your contract, run `{{pkgRun}} contract emit` to update them.
36
+
37
+ If you use a framework like Next.js or Vite, the Prisma Next plugin will do this for you automatically.
38
+
39
+ ## Configuration
40
+
41
+ [`prisma-next.config.ts`](prisma-next.config.ts) tells the CLI where your contract lives and how to connect to your database. It loads environment variables from `.env` automatically:
42
+
43
+ ```typescript
44
+ import 'dotenv/config';
45
+ import { defineConfig } from '{{configEntrypoint}}';
46
+
47
+ export default defineConfig({
48
+ contract: './{{schemaPath}}',
49
+ db: {
50
+ connection: process.env['DATABASE_URL']!,
51
+ },
52
+ });
53
+ ```
54
+
55
+ Notice the `DATABASE_URL` above? It's defined in your [`.env`](./.env) file:
56
+
57
+ ```env
58
+ DATABASE_URL="mongodb://localhost:27017/mydb"
59
+ ```
60
+
61
+ You can customize how your environment variables are loaded by changing or removing the `import 'dotenv/config'` line.
62
+
63
+ ## Quick reference
64
+
65
+ ### Commands
66
+
67
+ ```bash
68
+ {{pkgRun}} contract emit # Update contract.json and contract.d.ts
69
+ {{pkgRun}} db init # Create collections in the database
70
+ {{pkgRun}} migration status # Show migration status
71
+ ```
72
+
73
+ ### Files
74
+
75
+ | File | Purpose |
76
+ |---|---|
77
+ | [`{{schemaPath}}`]({{schemaPath}}) | Your data contract — define your models here |
78
+ | [`prisma-next.config.ts`](prisma-next.config.ts) | CLI configuration |
79
+ | [`{{schemaDir}}/db.ts`]({{schemaDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
80
+ | `{{schemaDir}}/contract.json` | Compiled contract (generated) |
81
+ | `{{schemaDir}}/contract.d.ts` | Contract types (generated) |
82
+
83
+ ### Workflow
84
+
85
+ 1. Edit [`{{schemaPath}}`]({{schemaPath}}) to add or change models.
86
+ 2. Run `{{pkgRun}} contract emit` to regenerate the contract.
87
+ 3. Query your models — your IDE will autocomplete everything.
88
+
89
+ ## Transactions and change streams (Mongo)
90
+
91
+ Multi-document transactions and change streams require MongoDB to run as a **replica set** — even single-node setups for development. A standalone `mongod` will reject `withTransaction()` at runtime. For local development you have a few options:
92
+
93
+ - **Docker Compose:** start `mongo` with `--replSet rs0` and run `rs.initiate()` once.
94
+ - **`mongodb-memory-server`:** use `MongoMemoryReplSet` instead of `MongoMemoryServer` in tests.
95
+ - **MongoDB Atlas:** every Atlas cluster is already a replica set.
96
+
97
+ The transaction API (`db.transaction(...)`) is on the roadmap and tracked under [TML-2313](https://linear.app/prisma-company/issue/TML-2313/mongo-dev-replica-set-story-is-missing-transactions-change-streams). Prisma Next's Mongo facade does not expose it yet — until that ticket lands, drive transactions yourself with a raw `MongoClient` using the escape hatch in the next section.
98
+
99
+ ## Escape hatches
100
+
101
+ The ORM covers the common cases. For the rest, two escape hatches are designed in:
102
+
103
+ - **Typed raw aggregations — `db.query`.** The facade exposes `db.query`, a typed builder for aggregation pipelines that runs through the same runtime + middleware + codec stack as `db.orm`. Reach for it when the ORM can't express a `$lookup`/`$facet`/`$graphLookup`/window-function pipeline.
104
+ - **Direct `mongodb` driver control — `mongoClient` binding.** Construct your own `MongoClient` and pass it to `mongo({ mongoClient, dbName, contractJson })`. Your code keeps the `MongoClient` reference and uses it directly (transactions, change streams, sessions, anything Prisma Next doesn't surface yet); the same `db` object continues to give you the typed ORM.
105
+
106
+ `db.runtime()` is **not** the escape hatch — it returns the internal executor (`MongoRuntime`), not a `mongodb` `MongoClient` or `Db`. Use `db.query` for raw aggregations and the `mongoClient` binding for direct driver control.
107
+
108
+ ## Monorepo notes (pnpm workspaces)
109
+
110
+ If this project lives inside a pnpm workspace, a few things are worth knowing:
111
+
112
+ - **Catalogs.** When the workspace's `pnpm-workspace.yaml` defines a `catalogs` entry for `prisma-next` or `{{pkg}}`, pnpm uses the catalog version everywhere — `init` does too. If you wanted the published `latest` instead, update or remove the catalog entry, then re-run `pnpm install`.
113
+ - **`pnpm dlx`.** `pnpm dlx prisma-next@latest init …` works in any directory. Inside a workspace, pnpm still resolves dependencies through the workspace's catalog/overrides rather than the registry; expect the installed Prisma Next packages to reflect the workspace's catalog rather than `latest`.
114
+ - **`pnpm` → `npm` fallback.** If `pnpm` ever fails to install Prisma Next with a `workspace:*` or `catalog:` resolution error (a leak in a published artefact), `init` falls back to `npm install` and surfaces a warning. Once the offending package republishes a clean version you can switch back with `pnpm install`.
@@ -0,0 +1,93 @@
1
+ # Welcome to Prisma Next!
2
+
3
+ Prisma Next lets you query your database in simple, easy-to-read TypeScript. Define what your data looks like, and Prisma Next gives you a fully typed client — with autocomplete for every table, column, and relation.
4
+
5
+ This project is set up for PostgreSQL. Prisma Next also supports other databases.
6
+
7
+ {{requirements}}
8
+
9
+ ## Your data contract
10
+
11
+ Your data contract is the heart of your application. It lives at [`{{schemaPath}}`]({{schemaPath}}) and describes your models:
12
+
13
+ {{schemaSample}}
14
+
15
+ Every model you define in your contract can be queried from your app. Your editor will autocomplete the query methods and show you what type each model field is:
16
+
17
+ ```typescript
18
+ import { db } from '{{dbImportPath}}';
19
+
20
+ const user = await db.orm.User
21
+ .where({ email: 'alice@example.com' })
22
+ .first();
23
+
24
+ // Your editor will show the type of user as
25
+ // { id: number; email: string; username: string | null; name: string | null; createdAt: Date; posts: Post[] } | null
26
+ ```
27
+
28
+ Your contract has two companion files in the same directory:
29
+
30
+ - **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
31
+ - **`contract.d.ts`** — this powers autocomplete and type checking in your editor
32
+
33
+ Commit both files to git. When you change your contract, run `{{pkgRun}} contract emit` to update them.
34
+
35
+ If you use a framework like Next.js or Vite, the Prisma Next plugin will do this for you automatically.
36
+
37
+ ## Configuration
38
+
39
+ [`prisma-next.config.ts`](prisma-next.config.ts) tells the CLI where your contract lives and how to connect to your database. It loads environment variables from `.env` automatically:
40
+
41
+ ```typescript
42
+ import 'dotenv/config';
43
+ import { defineConfig } from '{{configEntrypoint}}';
44
+
45
+ export default defineConfig({
46
+ contract: './{{schemaPath}}',
47
+ db: {
48
+ connection: process.env['DATABASE_URL']!,
49
+ },
50
+ });
51
+ ```
52
+
53
+ Notice the `DATABASE_URL` above? It's defined in your [`.env`](./.env) file:
54
+
55
+ ```env
56
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
57
+ ```
58
+
59
+ You can customize how your environment variables are loaded by changing or removing the `import 'dotenv/config'` line.
60
+
61
+ ## Quick reference
62
+
63
+ ### Commands
64
+
65
+ ```bash
66
+ {{pkgRun}} contract emit # Update contract.json and contract.d.ts
67
+ {{pkgRun}} db init # Create tables in the database
68
+ {{pkgRun}} migration status # Show migration status
69
+ ```
70
+
71
+ ### Files
72
+
73
+ | File | Purpose |
74
+ |---|---|
75
+ | [`{{schemaPath}}`]({{schemaPath}}) | Your data contract — define your models here |
76
+ | [`prisma-next.config.ts`](prisma-next.config.ts) | CLI configuration |
77
+ | [`{{schemaDir}}/db.ts`]({{schemaDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
78
+ | `{{schemaDir}}/contract.json` | Compiled contract (generated) |
79
+ | `{{schemaDir}}/contract.d.ts` | Contract types (generated) |
80
+
81
+ ### Workflow
82
+
83
+ 1. Edit [`{{schemaPath}}`]({{schemaPath}}) to add or change models.
84
+ 2. Run `{{pkgRun}} contract emit` to regenerate the contract.
85
+ 3. Query your models — your IDE will autocomplete everything.
86
+
87
+ ## Monorepo notes (pnpm workspaces)
88
+
89
+ If this project lives inside a pnpm workspace, a few things are worth knowing:
90
+
91
+ - **Catalogs.** When the workspace's `pnpm-workspace.yaml` defines a `catalogs` entry for `prisma-next` or `{{pkg}}`, pnpm uses the catalog version everywhere — `init` does too. If you wanted the published `latest` instead, update or remove the catalog entry, then re-run `pnpm install`.
92
+ - **`pnpm dlx`.** `pnpm dlx prisma-next@latest init …` works in any directory. Inside a workspace, pnpm still resolves dependencies through the workspace's catalog/overrides rather than the registry; expect the installed Prisma Next packages to reflect the workspace's catalog rather than `latest`.
93
+ - **`pnpm` → `npm` fallback.** If `pnpm` ever fails to install Prisma Next with a `workspace:*` or `catalog:` resolution error (a leak in a published artefact), `init` falls back to `npm install` and surfaces a warning. Once the offending package republishes a clean version you can switch back with `pnpm install`.
@@ -0,0 +1,35 @@
1
+ # {{projectName}}
2
+
3
+ Generated by `prisma-next init` with the Minimal template.
4
+
5
+ ## First run
6
+
7
+ 1. `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
8
+ 2. `{{runDev}}` — runs `src/index.ts`, which writes one row and reads it back.
9
+
10
+ ## Available scripts
11
+
12
+ - `{{runDev}}` — run the Prisma Next sample script
13
+
14
+ ### Database and migrations
15
+
16
+ - `{{runContractEmit}}` — emit contract artifacts after contract changes
17
+ - `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
18
+ - `{{runDbDown}}` — stop the local MongoDB process (data preserved)
19
+ - `{{runDbReset}}` — stop and wipe `.mongo-data/` for a clean slate
20
+ - `{{runMigrationPlan}}` — create a MongoDB migration plan
21
+ - `{{runMigrate}}` — apply the planned MongoDB migration
22
+ - `{{runDbSeed}}` — insert sample users manually
23
+
24
+ ## Prisma Next
25
+
26
+ Prisma Next setup is scaffolded in:
27
+
28
+ - `{{contractPath}}`
29
+ - `prisma-next.config.ts`
30
+ - `prisma/db.ts`
31
+ - `src/lib/prisma.ts`
32
+
33
+ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma/tree/main/skills.
34
+
35
+ Node-based Prisma Next projects expect Node.js 24 LTS or newer.
@@ -0,0 +1,34 @@
1
+ # {{projectName}}
2
+
3
+ Generated by `prisma-next init` with the Minimal template.
4
+
5
+ ## First run
6
+
7
+ 1. `{{runDbInit}}` — applies your contract to the database (creates tables, signs the marker).
8
+ 2. `{{runDev}}` — runs `src/index.ts`, which writes one row and reads it back.
9
+
10
+ ## Available scripts
11
+
12
+ - `{{runDev}}` — run the Prisma Next sample script
13
+
14
+ ### Database and migrations
15
+
16
+ - `{{runContractEmit}}` — emit contract artifacts after contract changes
17
+ - `{{runDbInit}}` — initialize database state manually
18
+ - `{{runDbUpdate}}` — update database state manually
19
+ - `{{runMigrationPlan}}` — create a migration plan
20
+ - `{{runMigrate}}` — apply a planned migration
21
+ - `{{runDbSeed}}` — insert sample users manually (run after `db:init`)
22
+
23
+ ## Prisma Next
24
+
25
+ Prisma Next setup is scaffolded in:
26
+
27
+ - `{{contractPath}}`
28
+ - `prisma-next.config.ts`
29
+ - `prisma/db.ts`
30
+ - `src/lib/prisma.ts`
31
+
32
+ For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma/tree/main/skills.
33
+
34
+ Node-based Prisma Next projects expect Node.js 24 LTS or newer.
@@ -0,0 +1,171 @@
1
+ import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
+ import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
3
+ import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
4
+ import { r as findLatestMigration } from "./migration-graph-CBf9ORe7-B4xAF8GN.mjs";
5
+ import { E as errorRefSetHashNotInGraph, N as errorUnexpected, O as errorRuntime$1, P as formatCommandHelp, Q as mapRefResolutionError, T as errorRefSetEmptySentinel, Z as mapMigrationToolsError, at as resolveMigrationPaths, et as parseGlobalFlags, h as errorFileNotFound, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, w as errorRefSetBundleNotFound } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
6
+ import { r as loadConfig } from "./exports-Dl2aGAk7.mjs";
7
+ import { n as isGraphNode } from "./graph-membership-DW6nnbyQ-Bp2KcVwR.mjs";
8
+ import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, u as validateRefValue } from "./refs-BDbB9BRB-D6Za3Q49.mjs";
9
+ import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
10
+ import { n as parseContractRef } from "./ref-resolution-BjJBWPjX.mjs";
11
+ import { notOk, ok } from "@prisma/orm-framework/utils/result";
12
+ import { join } from "pathe";
13
+ import { Command } from "commander";
14
+ //#region ../../../1-framework/3-tooling/cli/dist/commands/ref.mjs
15
+ function mapError(error) {
16
+ if (MigrationToolsError.is(error)) return mapMigrationToolsError(error);
17
+ return errorUnexpected(error instanceof Error ? error.message : String(error));
18
+ }
19
+ function cliErrorInvalidRefName(name) {
20
+ return errorRuntime$1(`Invalid ref name "${name}"`, {
21
+ why: `Ref name "${name}" does not match the required format`,
22
+ fix: "Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments"
23
+ });
24
+ }
25
+ async function executeRefSetCommand(name, contractInput, options) {
26
+ if (!validateRefName(name)) return notOk(cliErrorInvalidRefName(name));
27
+ try {
28
+ const config = await loadConfig(options.config);
29
+ const { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);
30
+ const loaded = await buildReadAggregate(config, { migrationsDir });
31
+ if (!loaded.ok) return notOk(loaded.failure);
32
+ const graph = loaded.value.aggregate.app.graph();
33
+ const bundles = loaded.value.aggregate.app.packages;
34
+ const refs = loaded.value.aggregate.app.refs;
35
+ let resolvedHash;
36
+ if (validateRefValue(contractInput)) resolvedHash = contractInput;
37
+ else {
38
+ const refResult = parseContractRef(contractInput, {
39
+ graph,
40
+ refs
41
+ });
42
+ if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
43
+ resolvedHash = refResult.value.hash;
44
+ }
45
+ if (resolvedHash === "empty") return notOk(errorRefSetEmptySentinel(resolvedHash));
46
+ if (!isGraphNode(resolvedHash, graph)) {
47
+ const graphTip = findLatestMigration(graph)?.to ?? null;
48
+ return notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort(), graphTip));
49
+ }
50
+ if (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));
51
+ const contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), "contract.json");
52
+ try {
53
+ await readContractSnapshotJson(migrationsDir, resolvedHash);
54
+ } catch (readError) {
55
+ if (MigrationToolsError.is(readError) && readError.code === "MIGRATION.CONTRACT_SNAPSHOT_MISSING") return notOk(errorFileNotFound(contractJsonPath, {
56
+ why: `Migration bundle for hash ${resolvedHash} is missing its contract snapshot at ${contractJsonPath}`,
57
+ fix: "Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot."
58
+ }));
59
+ throw readError;
60
+ }
61
+ await writeRef(refsDir, name, {
62
+ hash: resolvedHash,
63
+ invariants: []
64
+ });
65
+ return ok({
66
+ ok: true,
67
+ ref: name,
68
+ hash: resolvedHash,
69
+ invariants: []
70
+ });
71
+ } catch (error) {
72
+ if (error instanceof CliStructuredError$1) return notOk(error);
73
+ return notOk(mapError(error));
74
+ }
75
+ }
76
+ async function executeRefDeleteCommand(name, options) {
77
+ try {
78
+ const config = await loadConfig(options.config);
79
+ const { refsDir } = resolveMigrationPaths(options.config, config);
80
+ await deleteRef(refsDir, name);
81
+ return ok({
82
+ ok: true,
83
+ ref: name,
84
+ deleted: true
85
+ });
86
+ } catch (error) {
87
+ if (error instanceof CliStructuredError$1) return notOk(error);
88
+ return notOk(mapError(error));
89
+ }
90
+ }
91
+ async function executeRefListCommand(options) {
92
+ try {
93
+ const config = await loadConfig(options.config);
94
+ const { refsDir } = resolveMigrationPaths(options.config, config);
95
+ return ok({
96
+ ok: true,
97
+ refs: await readRefs(refsDir)
98
+ });
99
+ } catch (error) {
100
+ if (error instanceof CliStructuredError$1) return notOk(error);
101
+ return notOk(mapError(error));
102
+ }
103
+ }
104
+ function createRefSetCommand() {
105
+ const command = new Command("set");
106
+ setCommandDescriptions(command, "Set a ref to a contract reference", "Sets a named ref to point to a resolved contract reference (hash, alias, or path) in migrations/refs/.");
107
+ addGlobalOptions(command).argument("<name>", "Ref name (e.g., staging, production)").argument("<contract>", "Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)").option("--config <path>", "Path to prisma-next.config.ts").action(async (name, hash, options) => {
108
+ const flags = parseGlobalFlagsOrExit(options);
109
+ const ui = createTerminalUI(flags);
110
+ const exitCode = handleResult(await executeRefSetCommand(name, hash, options), flags, ui, (value) => {
111
+ if (flags.json) ui.output(JSON.stringify(value));
112
+ else if (!flags.quiet) ui.output(`Set ref "${value.ref}" → ${value.hash}`);
113
+ });
114
+ process.exit(exitCode);
115
+ });
116
+ return command;
117
+ }
118
+ function createRefDeleteCommand() {
119
+ const command = new Command("delete");
120
+ setCommandDescriptions(command, "Delete a ref", "Removes a named ref from migrations/refs/.");
121
+ addGlobalOptions(command).argument("<name>", "Ref name to delete").option("--config <path>", "Path to prisma-next.config.ts").action(async (name, options) => {
122
+ const flags = parseGlobalFlagsOrExit(options);
123
+ const ui = createTerminalUI(flags);
124
+ const exitCode = handleResult(await executeRefDeleteCommand(name, options), flags, ui, (value) => {
125
+ if (flags.json) ui.output(JSON.stringify(value));
126
+ else if (!flags.quiet) ui.output(`Deleted ref "${value.ref}"`);
127
+ });
128
+ process.exit(exitCode);
129
+ });
130
+ return command;
131
+ }
132
+ function createRefListCommand() {
133
+ const command = new Command("list");
134
+ setCommandDescriptions(command, "List all refs", "Lists all named refs from migrations/refs/.");
135
+ addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
136
+ const flags = parseGlobalFlagsOrExit(options);
137
+ const ui = createTerminalUI(flags);
138
+ const exitCode = handleResult(await executeRefListCommand(options), flags, ui, (value) => {
139
+ if (flags.json) ui.output(JSON.stringify(value));
140
+ else if (!flags.quiet) {
141
+ const entries = Object.entries(value.refs);
142
+ if (entries.length === 0) ui.output("No refs defined");
143
+ else for (const [refName, entry] of entries) {
144
+ const invariantsSuffix = entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(", ")}]` : "";
145
+ ui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);
146
+ }
147
+ }
148
+ });
149
+ process.exit(exitCode);
150
+ });
151
+ return command;
152
+ }
153
+ function createRefCommand() {
154
+ const command = new Command("ref");
155
+ setCommandDescriptions(command, "Manage contract refs", "Manage named refs in migrations/refs/. Refs map logical environment\nnames (e.g., staging, production) to contract hashes.");
156
+ addGlobalOptions(command).configureHelp({
157
+ formatHelp: (cmd) => formatCommandHelp({
158
+ command: cmd,
159
+ flags: parseGlobalFlags({})
160
+ }),
161
+ subcommandDescription: () => ""
162
+ });
163
+ command.addCommand(createRefSetCommand());
164
+ command.addCommand(createRefDeleteCommand());
165
+ command.addCommand(createRefListCommand());
166
+ return command;
167
+ }
168
+ //#endregion
169
+ export { executeRefSetCommand as i, executeRefDeleteCommand as n, executeRefListCommand as r, createRefCommand as t };
170
+
171
+ //# sourceMappingURL=ref-B6cTthTi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-B6cTthTi.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/ref.mjs"],"sourcesContent":["import { $ as errorRefSetBundleNotFound, F as CliStructuredError, O as formatCommandHelp, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, et as errorRefSetEmptySentinel, g as parseGlobalFlagsOrExit, h as parseGlobalFlags, l as setCommandDescriptions, lt as mapMigrationToolsError, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorRefSetHashNotInGraph, ut as mapRefResolutionError, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { deleteRef, readRefs, validateRefName, validateRefValue, writeRef } from \"@internal/migration-tools/refs\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/ref.ts\nfunction mapError(error) {\n\tif (MigrationToolsError.is(error)) return mapMigrationToolsError(error);\n\treturn errorUnexpected(error instanceof Error ? error.message : String(error));\n}\nfunction cliErrorInvalidRefName(name) {\n\treturn errorRuntime(`Invalid ref name \"${name}\"`, {\n\t\twhy: `Ref name \"${name}\" does not match the required format`,\n\t\tfix: \"Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments\"\n\t});\n}\nasync function executeRefSetCommand(name, contractInput, options) {\n\tif (!validateRefName(name)) return notOk(cliErrorInvalidRefName(name));\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\t\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tlet resolvedHash;\n\t\tif (validateRefValue(contractInput)) resolvedHash = contractInput;\n\t\telse {\n\t\t\tconst refResult = parseContractRef(contractInput, {\n\t\t\t\tgraph,\n\t\t\t\trefs\n\t\t\t});\n\t\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\t\tresolvedHash = refResult.value.hash;\n\t\t}\n\t\tif (resolvedHash === EMPTY_CONTRACT_HASH) return notOk(errorRefSetEmptySentinel(resolvedHash));\n\t\tif (!isGraphNode(resolvedHash, graph)) {\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\treturn notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort(), graphTip));\n\t\t}\n\t\tif (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));\n\t\tconst contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), \"contract.json\");\n\t\ttry {\n\t\t\tawait readContractSnapshotJson(migrationsDir, resolvedHash);\n\t\t} catch (readError) {\n\t\t\tif (MigrationToolsError.is(readError) && readError.code === \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\") return notOk(errorFileNotFound(contractJsonPath, {\n\t\t\t\twhy: `Migration bundle for hash ${resolvedHash} is missing its contract snapshot at ${contractJsonPath}`,\n\t\t\t\tfix: \"Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot.\"\n\t\t\t}));\n\t\t\tthrow readError;\n\t\t}\n\t\tawait writeRef(refsDir, name, {\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefDeleteCommand(name, options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\tawait deleteRef(refsDir, name);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\tdeleted: true\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefListCommand(options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\trefs: await readRefs(refsDir)\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nfunction createRefSetCommand() {\n\tconst command = new Command(\"set\");\n\tsetCommandDescriptions(command, \"Set a ref to a contract reference\", \"Sets a named ref to point to a resolved contract reference (hash, alias, or path) in migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name (e.g., staging, production)\").argument(\"<contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, hash, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefSetCommand(name, hash, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Set ref \"${value.ref}\" → ${value.hash}`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefDeleteCommand() {\n\tconst command = new Command(\"delete\");\n\tsetCommandDescriptions(command, \"Delete a ref\", \"Removes a named ref from migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name to delete\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefDeleteCommand(name, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Deleted ref \"${value.ref}\"`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List all refs\", \"Lists all named refs from migrations/refs/.\");\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefListCommand(options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) {\n\t\t\t\tconst entries = Object.entries(value.refs);\n\t\t\t\tif (entries.length === 0) ui.output(\"No refs defined\");\n\t\t\t\telse for (const [refName, entry] of entries) {\n\t\t\t\t\tconst invariantsSuffix = entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(\", \")}]` : \"\";\n\t\t\t\t\tui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefCommand() {\n\tconst command = new Command(\"ref\");\n\tsetCommandDescriptions(command, \"Manage contract refs\", \"Manage named refs in migrations/refs/. Refs map logical environment\\nnames (e.g., staging, production) to contract hashes.\");\n\taddGlobalOptions(command).configureHelp({\n\t\tformatHelp: (cmd) => formatCommandHelp({\n\t\t\tcommand: cmd,\n\t\t\tflags: parseGlobalFlags({})\n\t\t}),\n\t\tsubcommandDescription: () => \"\"\n\t});\n\tcommand.addCommand(createRefSetCommand());\n\tcommand.addCommand(createRefDeleteCommand());\n\tcommand.addCommand(createRefListCommand());\n\treturn command;\n}\n//#endregion\nexport { createRefCommand, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand };\n\n//# sourceMappingURL=ref.mjs.map"],"mappings":"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"}
@@ -0,0 +1,57 @@
1
+ import { b as errorInvalidRefName } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
+ import { o as writeContractSnapshot } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
3
+ import { d as writeRef, l as validateRefName } from "./refs-BDbB9BRB-D6Za3Q49.mjs";
4
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
+ import { readFile } from "node:fs/promises";
6
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-advancement-CSPMoQs3.mjs
7
+ function computeRefAdvancementName(options) {
8
+ if (options.advanceRef !== void 0) return options.advanceRef;
9
+ if (options.db === void 0) return "db";
10
+ return null;
11
+ }
12
+ async function readContractIR(contractJson, contractJsonPath) {
13
+ return {
14
+ contract: contractJson,
15
+ contractDts: await readFile(contractJsonPath.replace(/\.json$/i, ".d.ts"), "utf-8")
16
+ };
17
+ }
18
+ async function executeRefAdvancement(refsDir, migrationsDir, name, hash, contractIR) {
19
+ if (!validateRefName(name)) throw errorInvalidRefName(name);
20
+ await writeContractSnapshot(migrationsDir, hash, {
21
+ contractJson: contractIR.contract,
22
+ contractDts: contractIR.contractDts
23
+ });
24
+ await writeRef(refsDir, name, {
25
+ hash,
26
+ invariants: []
27
+ });
28
+ return {
29
+ name,
30
+ hash
31
+ };
32
+ }
33
+ async function buildRefAdvancementFields(options) {
34
+ const name = computeRefAdvancementName({
35
+ ...ifDefined("advanceRef", options.advanceRef),
36
+ ...ifDefined("db", options.db)
37
+ });
38
+ if (name === null) return {
39
+ advancedRef: null,
40
+ plannedAdvanceRef: null
41
+ };
42
+ if (options.mode === "plan") return {
43
+ advancedRef: null,
44
+ plannedAdvanceRef: {
45
+ name,
46
+ hash: options.hash
47
+ }
48
+ };
49
+ return {
50
+ advancedRef: await executeRefAdvancement(options.refsDir, options.migrationsDir, name, options.hash, options.contractIR),
51
+ plannedAdvanceRef: null
52
+ };
53
+ }
54
+ //#endregion
55
+ export { readContractIR as i, computeRefAdvancementName as n, executeRefAdvancement as r, buildRefAdvancementFields as t };
56
+
57
+ //# sourceMappingURL=ref-advancement-CSPMoQs3-fEipZrdu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-advancement-CSPMoQs3-fEipZrdu.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/ref-advancement-CSPMoQs3.mjs"],"sourcesContent":["import { ifDefined } from \"@internal/utils/defined\";\nimport { readFile } from \"node:fs/promises\";\nimport { errorInvalidRefName } from \"@internal/migration-tools/errors\";\nimport { writeContractSnapshot } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { validateRefName, writeRef } from \"@internal/migration-tools/refs\";\n//#region src/utils/ref-advancement.ts\nfunction computeRefAdvancementName(options) {\n\tif (options.advanceRef !== void 0) return options.advanceRef;\n\tif (options.db === void 0) return \"db\";\n\treturn null;\n}\nasync function readContractIR(contractJson, contractJsonPath) {\n\treturn {\n\t\tcontract: contractJson,\n\t\tcontractDts: await readFile(contractJsonPath.replace(/\\.json$/i, \".d.ts\"), \"utf-8\")\n\t};\n}\nasync function executeRefAdvancement(refsDir, migrationsDir, name, hash, contractIR) {\n\tif (!validateRefName(name)) throw errorInvalidRefName(name);\n\tawait writeContractSnapshot(migrationsDir, hash, {\n\t\tcontractJson: contractIR.contract,\n\t\tcontractDts: contractIR.contractDts\n\t});\n\tawait writeRef(refsDir, name, {\n\t\thash,\n\t\tinvariants: []\n\t});\n\treturn {\n\t\tname,\n\t\thash\n\t};\n}\nasync function buildRefAdvancementFields(options) {\n\tconst name = computeRefAdvancementName({\n\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t...ifDefined(\"db\", options.db)\n\t});\n\tif (name === null) return {\n\t\tadvancedRef: null,\n\t\tplannedAdvanceRef: null\n\t};\n\tif (options.mode === \"plan\") return {\n\t\tadvancedRef: null,\n\t\tplannedAdvanceRef: {\n\t\t\tname,\n\t\t\thash: options.hash\n\t\t}\n\t};\n\treturn {\n\t\tadvancedRef: await executeRefAdvancement(options.refsDir, options.migrationsDir, name, options.hash, options.contractIR),\n\t\tplannedAdvanceRef: null\n\t};\n}\n//#endregion\nexport { readContractIR as i, computeRefAdvancementName as n, executeRefAdvancement as r, buildRefAdvancementFields as t };\n\n//# sourceMappingURL=ref-advancement-CSPMoQs3.mjs.map"],"mappings":";;;;;;AAMA,SAAS,0BAA0B,SAAS;CAC3C,IAAI,QAAQ,eAAe,KAAK,GAAG,OAAO,QAAQ;CAClD,IAAI,QAAQ,OAAO,KAAK,GAAG,OAAO;CAClC,OAAO;AACR;AACA,eAAe,eAAe,cAAc,kBAAkB;CAC7D,OAAO;EACN,UAAU;EACV,aAAa,MAAM,SAAS,iBAAiB,QAAQ,YAAY,OAAO,GAAG,OAAO;CACnF;AACD;AACA,eAAe,sBAAsB,SAAS,eAAe,MAAM,MAAM,YAAY;CACpF,IAAI,CAAC,gBAAgB,IAAI,GAAG,MAAM,oBAAoB,IAAI;CAC1D,MAAM,sBAAsB,eAAe,MAAM;EAChD,cAAc,WAAW;EACzB,aAAa,WAAW;CACzB,CAAC;CACD,MAAM,SAAS,SAAS,MAAM;EAC7B;EACA,YAAY,CAAC;CACd,CAAC;CACD,OAAO;EACN;EACA;CACD;AACD;AACA,eAAe,0BAA0B,SAAS;CACjD,MAAM,OAAO,0BAA0B;EACtC,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,MAAM,QAAQ,EAAE;CAC9B,CAAC;CACD,IAAI,SAAS,MAAM,OAAO;EACzB,aAAa;EACb,mBAAmB;CACpB;CACA,IAAI,QAAQ,SAAS,QAAQ,OAAO;EACnC,aAAa;EACb,mBAAmB;GAClB;GACA,MAAM,QAAQ;EACf;CACD;CACA,OAAO;EACN,aAAa,MAAM,sBAAsB,QAAQ,SAAS,QAAQ,eAAe,MAAM,QAAQ,MAAM,QAAQ,UAAU;EACvH,mBAAmB;CACpB;AACD"}