@prisma/orm-toolchain 8.0.0-rc.1-dev.36 → 8.0.0-rc.1-dev.38

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 (138) hide show
  1. package/dist/bin__prisma-next.mjs +23 -23
  2. package/dist/bin__prisma-next.mjs.map +1 -1
  3. package/dist/{caught-errors-BZ-9WASe-DH4DaDha.mjs → caught-errors-DLPzfzIW-CQ9BoXD-.mjs} +3 -3
  4. package/dist/{caught-errors-BZ-9WASe-DH4DaDha.mjs.map → caught-errors-DLPzfzIW-CQ9BoXD-.mjs.map} +1 -1
  5. package/dist/{cli-errors-C6_pH59O-CzD4SYcJ.mjs → cli-errors-BG6bItjG-DwdKIeGz.mjs} +4 -4
  6. package/dist/cli-errors-BG6bItjG-DwdKIeGz.mjs.map +1 -0
  7. package/dist/{cli-errors-f5PRtVdm-C6xVKeQn.d.mts → cli-errors-BiKBrOXc-JPxQqO58.d.mts} +48 -6
  8. package/dist/cli-errors-BiKBrOXc-JPxQqO58.d.mts.map +1 -0
  9. package/dist/cli.mjs +572 -33
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/cli__commands__contract-emit.mjs +1 -1
  12. package/dist/cli__commands__contract-infer.mjs +1 -1
  13. package/dist/cli__commands__db-init.mjs +1 -1
  14. package/dist/cli__commands__db-schema.mjs +1 -1
  15. package/dist/cli__commands__db-sign.mjs +1 -1
  16. package/dist/cli__commands__db-update.mjs +1 -1
  17. package/dist/cli__commands__db-verify.mjs +1 -1
  18. package/dist/cli__commands__migrate.d.mts +2 -2
  19. package/dist/cli__commands__migrate.mjs +1 -1
  20. package/dist/cli__commands__migration-check.mjs +1 -1
  21. package/dist/cli__commands__migration-graph.d.mts +1 -1
  22. package/dist/cli__commands__migration-graph.mjs +1 -1
  23. package/dist/cli__commands__migration-list.d.mts +1 -1
  24. package/dist/cli__commands__migration-list.mjs +1 -1
  25. package/dist/cli__commands__migration-log.d.mts +1 -1
  26. package/dist/cli__commands__migration-log.mjs +1 -1
  27. package/dist/cli__commands__migration-new.mjs +1 -1
  28. package/dist/cli__commands__migration-plan.d.mts +1 -1
  29. package/dist/cli__commands__migration-plan.mjs +1 -1
  30. package/dist/cli__commands__migration-show.mjs +1 -1
  31. package/dist/cli__commands__migration-status.d.mts +1 -1
  32. package/dist/cli__commands__migration-status.mjs +1 -1
  33. package/dist/cli__commands__ref.mjs +1 -1
  34. package/dist/cli__commands__telemetry.mjs +1 -1
  35. package/dist/cli__control-api.d.mts +11 -3
  36. package/dist/cli__control-api.d.mts.map +1 -1
  37. package/dist/cli__control-api.mjs +15 -15
  38. package/dist/cli__control-api__testing.d.mts +1 -1
  39. package/dist/{client-BqhVohc5-DFRVWFps.mjs → client-DU9qtBxW-BjVHiKzE.mjs} +57 -11
  40. package/dist/client-DU9qtBxW-BjVHiKzE.mjs.map +1 -0
  41. package/dist/{command-helpers-kD9CO1hd-BPhnkBin.mjs → command-helpers-CwLvFwMB-BWwUQhlT.mjs} +3 -3
  42. package/dist/{command-helpers-kD9CO1hd-BPhnkBin.mjs.map → command-helpers-CwLvFwMB-BWwUQhlT.mjs.map} +1 -1
  43. package/dist/{contract-at-errors-CLFX1-Gc-MNPXDx1t.mjs → contract-at-errors-Dptf8RE_-B5gr04Sc.mjs} +3 -3
  44. package/dist/{contract-at-errors-CLFX1-Gc-MNPXDx1t.mjs.map → contract-at-errors-Dptf8RE_-B5gr04Sc.mjs.map} +1 -1
  45. package/dist/{contract-emit-BlvUNMHM-BEioUVR5.mjs → contract-emit-BQFpcb2A-BwT9iVdb.mjs} +5 -5
  46. package/dist/{contract-emit-BlvUNMHM-BEioUVR5.mjs.map → contract-emit-BQFpcb2A-BwT9iVdb.mjs.map} +1 -1
  47. package/dist/contract-emit-Bzt11N4v-BQ2Pr8KG.mjs +2 -0
  48. package/dist/{contract-emit-CrYO0A8x-60BOqXFr.mjs → contract-emit-CZQZ1i4z-p9LSGmmQ.mjs} +6 -6
  49. package/dist/{contract-emit-CrYO0A8x-60BOqXFr.mjs.map → contract-emit-CZQZ1i4z-p9LSGmmQ.mjs.map} +1 -1
  50. package/dist/{contract-infer-C8kLphsm-C7-AIYMc.mjs → contract-infer-C6cYOihE-CIUCgmw0.mjs} +4 -4
  51. package/dist/{contract-infer-C8kLphsm-C7-AIYMc.mjs.map → contract-infer-C6cYOihE-CIUCgmw0.mjs.map} +1 -1
  52. package/dist/{contract-snapshot-resolution-BUUdIcgG-8mbs6-OD.mjs → contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs} +4 -4
  53. package/dist/{contract-snapshot-resolution-BUUdIcgG-8mbs6-OD.mjs.map → contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs.map} +1 -1
  54. package/dist/{contract-space-aggregate-loader-BpdB-mHG-BiU0IUeb.mjs → contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs} +4 -4
  55. package/dist/{contract-space-aggregate-loader-BpdB-mHG-BiU0IUeb.mjs.map → contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs.map} +1 -1
  56. package/dist/{db-init-CyNsXRAB-D3xWQ-vy.mjs → db-init-DypCy1e3-CBrYfhHF.mjs} +6 -6
  57. package/dist/{db-init-CyNsXRAB-D3xWQ-vy.mjs.map → db-init-DypCy1e3-CBrYfhHF.mjs.map} +1 -1
  58. package/dist/{db-init-failure-XYOVL4o7-BitY_JYn.mjs → db-init-failure-BmCcHUfc-BqDxyrJE.mjs} +3 -3
  59. package/dist/{db-init-failure-XYOVL4o7-BitY_JYn.mjs.map → db-init-failure-BmCcHUfc-BqDxyrJE.mjs.map} +1 -1
  60. package/dist/{db-schema-7zNGHgYN-BVaRHPxg.mjs → db-schema-DHfPM-5V-JeCjrQ55.mjs} +4 -4
  61. package/dist/{db-schema-7zNGHgYN-BVaRHPxg.mjs.map → db-schema-DHfPM-5V-JeCjrQ55.mjs.map} +1 -1
  62. package/dist/{db-sign-DAs6J3XG-xxP2CCnO.mjs → db-sign-DbAxRcZh-C-nT9kcG.mjs} +6 -6
  63. package/dist/{db-sign-DAs6J3XG-xxP2CCnO.mjs.map → db-sign-DbAxRcZh-C-nT9kcG.mjs.map} +1 -1
  64. package/dist/{db-update-BX1sOuQk-CpeLgPeN.mjs → db-update-J59yROwL-DCP-_z2W.mjs} +16 -7
  65. package/dist/db-update-J59yROwL-DCP-_z2W.mjs.map +1 -0
  66. package/dist/{db-verify-CN4nmxxF-DSRWae0u.mjs → db-verify-0TpDMziA-CJDKutMN.mjs} +5 -5
  67. package/dist/{db-verify-CN4nmxxF-DSRWae0u.mjs.map → db-verify-0TpDMziA-CJDKutMN.mjs.map} +1 -1
  68. package/dist/{format-DceifGAK-BJhTdkcO.mjs → format-cbJY7l6v-CjMUDTAs.mjs} +5 -5
  69. package/dist/{format-DceifGAK-BJhTdkcO.mjs.map → format-cbJY7l6v-CjMUDTAs.mjs.map} +1 -1
  70. package/dist/{framework-components-CPFWl2Ix-CrIZL3jG.mjs → framework-components-C3K7SBeC-Bj5gx85-.mjs} +3 -3
  71. package/dist/{framework-components-CPFWl2Ix-CrIZL3jG.mjs.map → framework-components-C3K7SBeC-Bj5gx85-.mjs.map} +1 -1
  72. package/dist/{init-SY01IBU--CQFYh2As.mjs → init-Bco4QkKJ-DqUZVrBU.mjs} +4 -4
  73. package/dist/{init-SY01IBU--CQFYh2As.mjs.map → init-Bco4QkKJ-DqUZVrBU.mjs.map} +1 -1
  74. package/dist/{inspect-live-schema-BaLAtOgO-Bs0gs_yP.mjs → inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs} +5 -5
  75. package/dist/{inspect-live-schema-BaLAtOgO-Bs0gs_yP.mjs.map → inspect-live-schema-Cf77j9Vd-i5fzNW4T.mjs.map} +1 -1
  76. package/dist/{invariants-1L2zfc6--BpedlAbF.mjs → invariants-1zL5-9Mc-BCeOLxd_.mjs} +4 -4
  77. package/dist/{invariants-1L2zfc6--BpedlAbF.mjs.map → invariants-1zL5-9Mc-BCeOLxd_.mjs.map} +1 -1
  78. package/dist/{legend-aXC5H1jH-Dg1yWonK.mjs → legend-BQcPKTLe-bn9e4_ZU.mjs} +3 -3
  79. package/dist/{legend-aXC5H1jH-Dg1yWonK.mjs.map → legend-BQcPKTLe-bn9e4_ZU.mjs.map} +1 -1
  80. package/dist/{migrate-DRiUHRCS-Cci6EEZv.mjs → migrate-CgSnzAUm-aGstaO5N.mjs} +12 -12
  81. package/dist/{migrate-DRiUHRCS-Cci6EEZv.mjs.map → migrate-CgSnzAUm-aGstaO5N.mjs.map} +1 -1
  82. package/dist/{migrate-failure-Bdr3AJee-C9yNeQXy.mjs → migrate-failure-CnoUcDms-taa9pfd7.mjs} +4 -4
  83. package/dist/{migrate-failure-Bdr3AJee-C9yNeQXy.mjs.map → migrate-failure-CnoUcDms-taa9pfd7.mjs.map} +1 -1
  84. package/dist/{migrate-show-DutwCc2F-BhGfH7D-.d.mts → migrate-show-Dlo-YzOk-BXo-DmwI.d.mts} +3 -3
  85. package/dist/{migrate-show-DutwCc2F-BhGfH7D-.d.mts.map → migrate-show-Dlo-YzOk-BXo-DmwI.d.mts.map} +1 -1
  86. package/dist/{migrate-show-bdXjSFgh-CQxl5yNp.mjs → migrate-show-kVUG1xdo-bVTW8tu4.mjs} +6 -6
  87. package/dist/{migrate-show-bdXjSFgh-CQxl5yNp.mjs.map → migrate-show-kVUG1xdo-bVTW8tu4.mjs.map} +1 -1
  88. package/dist/{migration-check-BHiINj74-CVazN1LV.mjs → migration-check-BVK9vfan-Dfg8lbeB.mjs} +6 -6
  89. package/dist/{migration-check-BHiINj74-CVazN1LV.mjs.map → migration-check-BVK9vfan-Dfg8lbeB.mjs.map} +1 -1
  90. package/dist/{migration-check-of-RPYRk-HuXtDO8i.mjs → migration-check-CBMoMDX2-DhSEOGNg.mjs} +6 -6
  91. package/dist/{migration-check-of-RPYRk-HuXtDO8i.mjs.map → migration-check-CBMoMDX2-DhSEOGNg.mjs.map} +1 -1
  92. package/dist/{migration-command-scaffold-zJFTGn5k-5AGczeSx.mjs → migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs} +5 -5
  93. package/dist/{migration-command-scaffold-zJFTGn5k-5AGczeSx.mjs.map → migration-command-scaffold-B1BiWKLI-Bskk5UKX.mjs.map} +1 -1
  94. package/dist/{migration-graph-DmdVVJoZ-DDBKjUMz.mjs → migration-graph-B30X5398-BH3zB9Mn.mjs} +3 -3
  95. package/dist/{migration-graph-DmdVVJoZ-DDBKjUMz.mjs.map → migration-graph-B30X5398-BH3zB9Mn.mjs.map} +1 -1
  96. package/dist/{migration-graph-D0KHjNJ--CWzX9Zzc.mjs → migration-graph-D2dbLCkl-CCHL0aDA.mjs} +8 -8
  97. package/dist/{migration-graph-D0KHjNJ--CWzX9Zzc.mjs.map → migration-graph-D2dbLCkl-CCHL0aDA.mjs.map} +1 -1
  98. package/dist/{migration-graph-sections-BWcFCOL6-_G0Wb4QR.mjs → migration-graph-sections-0lKA5l1b-CTHQquu7.mjs} +3 -3
  99. package/dist/{migration-graph-sections-BWcFCOL6-_G0Wb4QR.mjs.map → migration-graph-sections-0lKA5l1b-CTHQquu7.mjs.map} +1 -1
  100. package/dist/{migration-list-W0dqabIj-Dc2NH_LY.mjs → migration-list-BQTfSGbT-DoNqbNsu.mjs} +3 -3
  101. package/dist/{migration-list-W0dqabIj-Dc2NH_LY.mjs.map → migration-list-BQTfSGbT-DoNqbNsu.mjs.map} +1 -1
  102. package/dist/{migration-list-B0SANIeM-DiXQ9LyS.mjs → migration-list-DCx0KOFp-B3MiGnpa.mjs} +6 -6
  103. package/dist/{migration-list-B0SANIeM-DiXQ9LyS.mjs.map → migration-list-DCx0KOFp-B3MiGnpa.mjs.map} +1 -1
  104. package/dist/{migration-log-B3iiP8ns-B4tdLSye.mjs → migration-log-CJ6_9_uj-uWyc3vlC.mjs} +6 -6
  105. package/dist/{migration-log-B3iiP8ns-B4tdLSye.mjs.map → migration-log-CJ6_9_uj-uWyc3vlC.mjs.map} +1 -1
  106. package/dist/{migration-new-YSdtJTRp-Dc06LNJe.mjs → migration-new-Bp5dPKnF-D-Fb6vEp.mjs} +7 -7
  107. package/dist/{migration-new-YSdtJTRp-Dc06LNJe.mjs.map → migration-new-Bp5dPKnF-D-Fb6vEp.mjs.map} +1 -1
  108. package/dist/{migration-new-Bf5K9fNK-Cd90rYmm.mjs → migration-new-CXLgOLXz-2C5s_q7n.mjs} +4 -4
  109. package/dist/{migration-new-Bf5K9fNK-Cd90rYmm.mjs.map → migration-new-CXLgOLXz-2C5s_q7n.mjs.map} +1 -1
  110. package/dist/{migration-path-target-5r1leSW5-B0EMgvEv.mjs → migration-path-target-BNTSTPAc-D7dQ4K7x.mjs} +3 -3
  111. package/dist/{migration-path-target-5r1leSW5-B0EMgvEv.mjs.map → migration-path-target-BNTSTPAc-D7dQ4K7x.mjs.map} +1 -1
  112. package/dist/{migration-plan-oterbw8h-_GrKbsRb.mjs → migration-plan-BxfF1Hdo-BKn0xMlY.mjs} +4 -4
  113. package/dist/{migration-plan-oterbw8h-_GrKbsRb.mjs.map → migration-plan-BxfF1Hdo-BKn0xMlY.mjs.map} +1 -1
  114. package/dist/{migration-plan-CZY8HVCh-BbfQvxnb.mjs → migration-plan-C6KrFHJT-CRkTsE7L.mjs} +8 -8
  115. package/dist/{migration-plan-CZY8HVCh-BbfQvxnb.mjs.map → migration-plan-C6KrFHJT-CRkTsE7L.mjs.map} +1 -1
  116. package/dist/{migration-plan-4cnnP6yM-DXzRfi_A.d.mts → migration-plan-CharRhoN-BIB3WL65.d.mts} +3 -3
  117. package/dist/{migration-plan-4cnnP6yM-DXzRfi_A.d.mts.map → migration-plan-CharRhoN-BIB3WL65.d.mts.map} +1 -1
  118. package/dist/{migration-show-iX2cduR4-C3-FENR4.mjs → migration-show-Dhnlx_GU-DhWLLt3Z.mjs} +8 -8
  119. package/dist/{migration-show-iX2cduR4-C3-FENR4.mjs.map → migration-show-Dhnlx_GU-DhWLLt3Z.mjs.map} +1 -1
  120. package/dist/{migration-status-BZ6gOxyJ-sbhPgABr.mjs → migration-status-S88DjM8c-DLHnCKfW.mjs} +10 -10
  121. package/dist/{migration-status-BZ6gOxyJ-sbhPgABr.mjs.map → migration-status-S88DjM8c-DLHnCKfW.mjs.map} +1 -1
  122. package/dist/{project-import-root-BPuwl2j1-DTX9G73z.mjs → project-import-root-nwdoPWap--5vXe4zp.mjs} +3 -3
  123. package/dist/{project-import-root-BPuwl2j1-DTX9G73z.mjs.map → project-import-root-nwdoPWap--5vXe4zp.mjs.map} +1 -1
  124. package/dist/{ref-CVD6j3jA-BAgpZLNM.mjs → ref-C8oaaeky-ColNkWpr.mjs} +5 -5
  125. package/dist/{ref-CVD6j3jA-BAgpZLNM.mjs.map → ref-C8oaaeky-ColNkWpr.mjs.map} +1 -1
  126. package/dist/{ref-CaqNqeRF-cjWFAueu.mjs → ref-gZQjdz8I-CW6n9Fc0.mjs} +4 -4
  127. package/dist/{ref-CaqNqeRF-cjWFAueu.mjs.map → ref-gZQjdz8I-CW6n9Fc0.mjs.map} +1 -1
  128. package/dist/{ref-resolution-D4fAdXo8-Dfaky0yw.mjs → ref-resolution-DAK4OK3x-B-8ZZc0f.mjs} +3 -3
  129. package/dist/{ref-resolution-D4fAdXo8-Dfaky0yw.mjs.map → ref-resolution-DAK4OK3x-B-8ZZc0f.mjs.map} +1 -1
  130. package/dist/{telemetry-fKuZOFpu-DNUWfIHo.mjs → telemetry-DPXFYAsz-CPW2USxs.mjs} +3 -3
  131. package/dist/{telemetry-fKuZOFpu-DNUWfIHo.mjs.map → telemetry-DPXFYAsz-CPW2USxs.mjs.map} +1 -1
  132. package/dist/vite-plugin-contract-emit.mjs +1 -1
  133. package/package.json +12 -12
  134. package/dist/cli-errors-C6_pH59O-CzD4SYcJ.mjs.map +0 -1
  135. package/dist/cli-errors-f5PRtVdm-C6xVKeQn.d.mts.map +0 -1
  136. package/dist/client-BqhVohc5-DFRVWFps.mjs.map +0 -1
  137. package/dist/contract-emit-Csa6R0gt-DvxFlS0O.mjs +0 -2
  138. package/dist/db-update-BX1sOuQk-CpeLgPeN.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,47 +1,50 @@
1
1
  import { i as loadConfig } from "./exports-BZLNbtkY.mjs";
2
- import { F as requireLiveDatabase, I as runCommandAction, N as errorUnexpected, a as errorConfigValidation$1, b as errorNoMigrations, c as errorDatabaseConnectionRequired, d as errorFileNotFound, h as errorLegendHumanOnly, j as errorTargetMigrationNotSupported, s as errorContractValidationFailed, t as CliStructuredError$1$1, u as errorDriverRequired, v as errorMigrationPackageNotFound } from "./cli-errors-C6_pH59O-CzD4SYcJ.mjs";
2
+ import { I as requireLiveDatabase, L as runCommandAction, M as errorTargetMigrationNotSupported, O as errorRunnerFailed, P as errorUnexpected, a as errorConfigValidation$1, b as errorMigrationPlanningFailed, c as errorContractValidationFailed, d as errorDriverRequired, f as errorFileNotFound, g as errorLegendHumanOnly, k as errorRuntime$1, l as errorDatabaseConnectionRequired, o as errorConsentPlanMismatch, t as CliStructuredError$1$1, u as errorDestructiveChanges, x as errorNoMigrations, y as errorMigrationPackageNotFound } from "./cli-errors-BG6bItjG-DwdKIeGz.mjs";
3
3
  import { r as getEmittedArtifactPaths } from "./exports-BCLg4CiV-05kuwcb0.mjs";
4
+ import { n as executeContractEmit } from "./contract-emit-CZQZ1i4z-p9LSGmmQ.mjs";
4
5
  import { h as renderPreviewStatement, m as previewBlockHeader } from "./terminal-ui-Cqz4LVL7-B0mcVdLy.mjs";
5
6
  import { c as spaceMigrationDirectory } from "./verify-contract-spaces-DhJTb0zM-_oh6W6lp.mjs";
6
- import { S as targetSupportsMigrations, f as maskConnectionUrl, n as closeQuietly, v as sanitizeErrorMessage } from "./command-helpers-kD9CO1hd-BPhnkBin.mjs";
7
- import { t as createContractEmitCommand } from "./contract-emit-BlvUNMHM-BEioUVR5.mjs";
8
- import { n as executeFormat, t as createFormatCommand } from "./format-DceifGAK-BJhTdkcO.mjs";
9
- import { a as loadContractSpaceAggregateForCli, r as buildReadAggregate, s as refuseContractSpaceIntegrity, u as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-BpdB-mHG-BiU0IUeb.mjs";
10
- import { t as createControlClient } from "./client-BqhVohc5-DFRVWFps.mjs";
7
+ import { S as targetSupportsMigrations, f as maskConnectionUrl, n as closeQuietly, v as sanitizeErrorMessage } from "./command-helpers-CwLvFwMB-BWwUQhlT.mjs";
8
+ import { t as createContractEmitCommand } from "./contract-emit-BQFpcb2A-BwT9iVdb.mjs";
9
+ import { n as executeFormat, t as createFormatCommand } from "./format-cbJY7l6v-CjMUDTAs.mjs";
10
+ import { a as loadContractSpaceAggregateForCli, r as buildReadAggregate, s as refuseContractSpaceIntegrity, u as toDeclaredExtensionsFromRaw } from "./contract-space-aggregate-loader-CoLTf3Ce-pQDru2w0.mjs";
11
+ import { t as createControlClient } from "./client-DU9qtBxW-BjVHiKzE.mjs";
11
12
  import { a as readContractIR, o as resolveRefAdvancementFields, t as advanceRefSafely } from "./ref-advancement-DaZBzm7m-WoqnFAyr.mjs";
12
- import { t as mapDbInitFailure } from "./db-init-failure-XYOVL4o7-BitY_JYn.mjs";
13
- import { t as mapCaughtMigrationError } from "./caught-errors-BZ-9WASe-DH4DaDha.mjs";
14
- import { t as mapContractAtError } from "./contract-at-errors-CLFX1-Gc-MNPXDx1t.mjs";
15
- import { i as refuseUnknownInvariants, n as refuseMarkerOutsideGraph } from "./invariants-1L2zfc6--BpedlAbF.mjs";
16
- import { t as executeMigrateShowPlan } from "./migrate-show-bdXjSFgh-CQxl5yNp.mjs";
17
- import { n as resolveMigrationRef, t as resolveContractRef } from "./ref-resolution-D4fAdXo8-Dfaky0yw.mjs";
18
- import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList } from "./migration-list-W0dqabIj-Dc2NH_LY.mjs";
13
+ import { t as mapDbInitFailure } from "./db-init-failure-BmCcHUfc-BqDxyrJE.mjs";
14
+ import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-DvZvbNcZ-DHFCWe_k.mjs";
15
+ import { t as mapCaughtMigrationError } from "./caught-errors-DLPzfzIW-CQ9BoXD-.mjs";
16
+ import { t as mapContractAtError } from "./contract-at-errors-Dptf8RE_-B5gr04Sc.mjs";
17
+ import { i as refuseUnknownInvariants, n as refuseMarkerOutsideGraph } from "./invariants-1zL5-9Mc-BCeOLxd_.mjs";
18
+ import { t as executeMigrateShowPlan } from "./migrate-show-kVUG1xdo-bVTW8tu4.mjs";
19
+ import { n as resolveMigrationRef, t as resolveContractRef } from "./ref-resolution-DAK4OK3x-B-8ZZc0f.mjs";
20
+ import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList } from "./migration-list-BQTfSGbT-DoNqbNsu.mjs";
19
21
  import { S as toneSpans, b as renderMigrationListWithStyle, d as createToneMigrationListStyler, n as TONE_MIGRATION_GRAPH_PALETTE, v as renderMigrationGraphLegend, x as toneDrawing } from "./migration-graph-command-render-BeuEyf2B-BNH9oUB_.mjs";
20
- import { n as migrateShowRunListRows, r as renderMigrateShowGraph, t as mapMigrateFailure } from "./migrate-failure-Bdr3AJee-C9yNeQXy.mjs";
21
- import { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-5r1leSW5-B0EMgvEv.mjs";
22
- import { t as buildMigrationSpaceGraphEntries } from "./migration-graph-DmdVVJoZ-DDBKjUMz.mjs";
23
- import { n as renderMigrationGraphDot, r as renderMigrationGraphSections, t as buildMigrationGraphTreeSections } from "./migration-graph-sections-BWcFCOL6-_G0Wb4QR.mjs";
22
+ import { n as migrateShowRunListRows, r as renderMigrateShowGraph, t as mapMigrateFailure } from "./migrate-failure-CnoUcDms-taa9pfd7.mjs";
23
+ import { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-BNTSTPAc-D7dQ4K7x.mjs";
24
+ import { t as buildMigrationSpaceGraphEntries } from "./migration-graph-B30X5398-BH3zB9Mn.mjs";
25
+ import { n as renderMigrationGraphDot, r as renderMigrationGraphSections, t as buildMigrationGraphTreeSections } from "./migration-graph-sections-0lKA5l1b-CTHQquu7.mjs";
24
26
  import { a as sortLedgerEntries, i as serializeLedgerEntriesForJson, n as formatLedgerAppliedAt, o as styleHashTransition, t as MIGRATION_LOG_EMPTY_MESSAGE } from "./migration-log-table-DRiOnvzf-zTQBThqe.mjs";
25
- import { n as executeRefListCommand, r as executeRefSetCommand, t as executeRefDeleteCommand } from "./ref-CVD6j3jA-BAgpZLNM.mjs";
27
+ import { n as executeRefListCommand, r as executeRefSetCommand, t as executeRefDeleteCommand } from "./ref-C8oaaeky-ColNkWpr.mjs";
26
28
  import { CliStructuredError } from "@prisma/orm-framework/errors/control";
27
29
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
28
- import { join, normalize, relative, resolve } from "pathe";
30
+ import { basename, dirname, join, normalize, relative, resolve } from "pathe";
29
31
  import { existsSync, unlinkSync, writeFileSync } from "node:fs";
30
32
  import { DOCS_BASE, isStructuredError } from "@prisma/orm-framework/utils/structured-error";
31
33
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
32
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
33
- import { readFile } from "node:fs/promises";
34
+ import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
35
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
34
36
  import { APP_SPACE_ID, createControlStack } from "@prisma/orm-framework/components/control";
35
37
  import { collectConfigIssues } from "@prisma/orm-framework/config/config-validation";
36
38
  import { tmpdir } from "node:os";
39
+ import { printPsl } from "@prisma/orm-framework/psl-printer";
37
40
  import { defineCommand, defineCommandFamily, defineConfigSection, flag, positional } from "@prisma/cli-engine";
38
41
  import { CliStructuredError as CliStructuredError$1, notOk, ok } from "@prisma/cli-engine/protocol";
39
42
  import { pathToFileURL } from "node:url";
40
43
  import { build } from "esbuild";
41
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-h2VTJG-X.mjs
44
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-pL46nF5F.mjs
42
45
  const MISSING_CONFIG_ACTION = {
43
46
  kind: "run-command",
44
- label: "Create a configuration file",
47
+ label: "Create a config file",
45
48
  command: "prisma-next init"
46
49
  };
47
50
  function editConfigAction(field) {
@@ -261,16 +264,6 @@ function defineOrmCommand(def) {
261
264
  }
262
265
  });
263
266
  }
264
- /**
265
- * The database connection override, declared from here by every command that
266
- * accepts one so its brief and placeholder cannot drift apart. Resolution
267
- * order is the flag, then `config.db.connection`, then
268
- * `CONFIG.DB_CONNECTION_REQUIRED`.
269
- */
270
- const dbFlag = flag.string({
271
- brief: "Database connection string",
272
- placeholder: "url"
273
- });
274
267
  const OUTCOMES = {
275
268
  ok: "ok",
276
269
  skipped: "skipped",
@@ -303,6 +296,267 @@ function controlProgressReporter(report) {
303
296
  });
304
297
  };
305
298
  }
299
+ function hashRows(document) {
300
+ return {
301
+ kind: "fields",
302
+ rows: [
303
+ {
304
+ label: "storageHash",
305
+ value: [{
306
+ text: document.storageHash,
307
+ tone: "identifier"
308
+ }]
309
+ },
310
+ ...document.executionHash === void 0 ? [] : [{
311
+ label: "executionHash",
312
+ value: [{
313
+ text: document.executionHash,
314
+ tone: "identifier"
315
+ }]
316
+ }],
317
+ {
318
+ label: "profileHash",
319
+ value: [{
320
+ text: document.profileHash,
321
+ tone: "identifier"
322
+ }]
323
+ }
324
+ ]
325
+ };
326
+ }
327
+ function emitPresentations(inputs) {
328
+ const { document, cwd } = inputs;
329
+ return {
330
+ human: () => [
331
+ {
332
+ kind: "fields",
333
+ rail: true,
334
+ rows: [{
335
+ label: "contract",
336
+ value: relative(cwd, document.files.json)
337
+ }, {
338
+ label: "types",
339
+ value: relative(cwd, document.files.dts)
340
+ }]
341
+ },
342
+ {
343
+ kind: "summary",
344
+ status: "ok",
345
+ text: "Emitted contract.json and contract.d.ts"
346
+ },
347
+ hashRows(document)
348
+ ],
349
+ stdout: () => [document.files.json, document.files.dts],
350
+ json: () => document
351
+ };
352
+ }
353
+ function createContractEmitCommand$1({ executeContractEmit }) {
354
+ return defineOrmCommand({
355
+ help: {
356
+ summary: "Emit your contract artifacts",
357
+ description: "Reads your contract source (TypeScript or Prisma schema) and emits\ncontract.json and contract.d.ts. The contract.json contains the canonical\ncontract structure, and contract.d.ts provides TypeScript types for\ntype-safe query building. Offline — does not consult the database.",
358
+ examples: [
359
+ "contract emit",
360
+ "contract emit --output-path ./generated",
361
+ "contract emit --json"
362
+ ]
363
+ },
364
+ args: { flags: { outputPath: flag.string({
365
+ brief: "Directory to write contract.json and contract.d.ts into",
366
+ placeholder: "dir"
367
+ }) } },
368
+ needs: { config: ormConfigSection },
369
+ handler: async (args, ctx) => {
370
+ const startedAt = Date.now();
371
+ const outputPath = args.flags.outputPath === void 0 ? void 0 : resolve(ctx.cwd, args.flags.outputPath);
372
+ const result = await executeContractEmit({
373
+ config: ctx.config,
374
+ cwd: ctx.cwd,
375
+ onProgress: controlProgressReporter(ctx.report),
376
+ signal: ctx.signal,
377
+ ...ifDefined("outputPath", outputPath)
378
+ });
379
+ if (result.validationWarning !== void 0) ctx.report({
380
+ kind: "message",
381
+ severity: "warn",
382
+ text: result.validationWarning
383
+ });
384
+ const document = {
385
+ ok: true,
386
+ storageHash: result.storageHash,
387
+ ...ifDefined("executionHash", result.executionHash),
388
+ profileHash: result.profileHash,
389
+ outDir: dirname(result.files.json),
390
+ files: result.files,
391
+ timings: { total: Date.now() - startedAt }
392
+ };
393
+ ctx.report({
394
+ kind: "message",
395
+ severity: "verbose",
396
+ text: `Total time: ${document.timings.total}ms`
397
+ });
398
+ return ok(ctx.present({ data: document }, emitPresentations({
399
+ document,
400
+ cwd: ctx.cwd
401
+ })));
402
+ }
403
+ });
404
+ }
405
+ const contractEmitCommand = createContractEmitCommand$1({ executeContractEmit });
406
+ /**
407
+ * Writes a generated file the way `contract emit` publishes its pair: the
408
+ * bytes land in a temporary file beside the target and are renamed over it, so
409
+ * a run interrupted mid-write leaves the previous file intact rather than a
410
+ * truncated one.
411
+ */
412
+ async function publishTextArtifact(inputs) {
413
+ const directory = dirname(inputs.path);
414
+ const tempPath = join(directory, `.${basename(inputs.path)}.${process.pid}.${inputs.publicationToken}.next.tmp`);
415
+ await mkdir(directory, { recursive: true });
416
+ try {
417
+ await writeFile(tempPath, inputs.content, "utf-8");
418
+ await rename(tempPath, inputs.path);
419
+ } finally {
420
+ await rm(tempPath, { force: true });
421
+ }
422
+ }
423
+ /**
424
+ * The database connection override, declared from here by every command that
425
+ * accepts one so its brief and placeholder cannot drift apart. Resolution
426
+ * order is the flag, then `config.db.connection`, then
427
+ * `CONFIG.DB_CONNECTION_REQUIRED`.
428
+ */
429
+ const dbFlag = flag.string({
430
+ brief: "Database connection string",
431
+ placeholder: "url"
432
+ });
433
+ /** The file `contract infer` writes when nothing names another. */
434
+ const INFERRED_CONTRACT_FILENAME = "contract.prisma";
435
+ /**
436
+ * Where `contract infer` writes the PSL it inferred: `--output`, else
437
+ * `contract.prisma` beside the emitted contract, else `contract.prisma` in the
438
+ * invocation directory.
439
+ */
440
+ function inferredContractPathFor(inputs) {
441
+ if (inputs.output !== void 0) return resolve(inputs.cwd, inputs.output);
442
+ const contractOutput = inputs.config.contract?.output;
443
+ if (contractOutput !== void 0) return join(dirname(resolve(inputs.cwd, contractOutput)), INFERRED_CONTRACT_FILENAME);
444
+ return join(inputs.cwd, INFERRED_CONTRACT_FILENAME);
445
+ }
446
+ function inferPresentations(inputs) {
447
+ const { document, database } = inputs;
448
+ return {
449
+ human: () => [...database === void 0 ? [] : [{
450
+ kind: "fields",
451
+ rail: true,
452
+ rows: [{
453
+ label: "database",
454
+ value: database
455
+ }]
456
+ }], {
457
+ kind: "summary",
458
+ status: "ok",
459
+ text: [{ text: "Contract written to " }, {
460
+ text: document.psl.path,
461
+ tone: "identifier"
462
+ }]
463
+ }],
464
+ json: () => document
465
+ };
466
+ }
467
+ function createContractInferCommand({ createControlClient, printPsl }) {
468
+ return defineOrmCommand({
469
+ help: {
470
+ summary: "Infer a PSL contract from the live database schema",
471
+ description: "Reads the live database schema and writes an inferred PSL contract to\ndisk. This command stops at contract.prisma; follow it with\n`contract emit` and `db sign` as separate steps. An existing file at the\noutput path is overwritten, with a warning.",
472
+ examples: [
473
+ "contract infer --db $DATABASE_URL",
474
+ "contract infer --db $DATABASE_URL --output ./src/prisma/contract.prisma",
475
+ "contract infer --json"
476
+ ]
477
+ },
478
+ args: { flags: {
479
+ db: dbFlag,
480
+ output: flag.string({
481
+ brief: "Write the inferred PSL contract to the specified path",
482
+ placeholder: "path"
483
+ })
484
+ } },
485
+ needs: { config: ormConfigSection },
486
+ handler: async (args, ctx) => {
487
+ const startedAt = Date.now();
488
+ const dbConnection = args.flags.db ?? ctx.config.db?.connection;
489
+ if (dbConnection === void 0) return notOk(normalizeError(errorDatabaseConnectionRequired({
490
+ why: "Database connection is required for contract infer (set db.connection in prisma-next.config.ts, or pass --db <url>)",
491
+ commandName: "contract infer",
492
+ missingFlags: ["--db"]
493
+ })));
494
+ if (ctx.config.driver === void 0) return notOk(normalizeError(errorDriverRequired({ why: "Config.driver is required for contract infer" })));
495
+ const client = createControlClient({
496
+ family: ctx.config.family,
497
+ target: ctx.config.target,
498
+ adapter: ctx.config.adapter,
499
+ driver: ctx.config.driver,
500
+ extensions: ctx.config.extensions ?? []
501
+ });
502
+ let pslContent;
503
+ try {
504
+ const schema = await client.introspect({
505
+ connection: dbConnection,
506
+ onProgress: controlProgressReporter(ctx.report)
507
+ });
508
+ const pslContractAst = client.inferPslContract(schema);
509
+ if (pslContractAst === void 0) return notOk(normalizeError(errorRuntime$1("CONTRACT.INFER_UNSUPPORTED", "contract infer is not supported for this family", {
510
+ why: "The configured family does not implement the PslContractInferCapable capability, so an inferred PSL contract cannot be produced from the live database schema.",
511
+ fix: "Use a family that supports contract inference (e.g. SQL/Postgres)."
512
+ })));
513
+ pslContent = printPsl(pslContractAst, { pslBlockDescriptors: client.getPslBlockDescriptors() });
514
+ } catch (error) {
515
+ if (CliStructuredError$1$1.is(error)) return notOk(normalizeError(error));
516
+ const safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === "string" ? dbConnection : void 0);
517
+ return notOk(normalizeError(errorUnexpected(safeMessage, { why: `Unexpected error during contract infer: ${safeMessage}` })));
518
+ } finally {
519
+ await closeQuietly(client);
520
+ }
521
+ const outputPath = inferredContractPathFor({
522
+ config: ctx.config,
523
+ cwd: ctx.cwd,
524
+ output: args.flags.output
525
+ });
526
+ const displayPath = relative(ctx.cwd, outputPath);
527
+ if (existsSync(outputPath)) ctx.report({
528
+ kind: "message",
529
+ severity: "warn",
530
+ text: `Overwriting existing file: ${displayPath}`
531
+ });
532
+ await publishTextArtifact({
533
+ path: outputPath,
534
+ content: pslContent,
535
+ publicationToken: String(process.hrtime.bigint())
536
+ });
537
+ const database = typeof dbConnection === "string" ? maskConnectionUrl(dbConnection) : void 0;
538
+ const document = {
539
+ ok: true,
540
+ summary: "Contract inferred successfully",
541
+ target: {
542
+ familyId: ctx.config.family.familyId,
543
+ id: ctx.config.target.targetId
544
+ },
545
+ psl: { path: displayPath },
546
+ meta: { ...ifDefined("dbUrl", database) },
547
+ timings: { total: Date.now() - startedAt }
548
+ };
549
+ return ok(ctx.present({ data: document }, inferPresentations({
550
+ document,
551
+ database
552
+ })));
553
+ }
554
+ });
555
+ }
556
+ const contractInferCommand = createContractInferCommand({
557
+ createControlClient,
558
+ printPsl
559
+ });
306
560
  function operationNode(operation) {
307
561
  return operation.operationClass === "destructive" ? {
308
562
  label: operation.label,
@@ -384,6 +638,22 @@ function previewBlocks$1(preview) {
384
638
  lines: statements
385
639
  }];
386
640
  }
641
+ /**
642
+ * What the planner flagged without refusing to plan it. Only `db update`
643
+ * produces these — the additive-only policies cannot reach the branch.
644
+ */
645
+ function plannerWarningBlocks(result) {
646
+ const warnings = result.warnings ?? [];
647
+ if (warnings.length === 0) return [];
648
+ return [{
649
+ kind: "summary",
650
+ status: "warn",
651
+ text: "Planner warnings"
652
+ }, {
653
+ kind: "list",
654
+ items: warnings.map((warning) => warning.summary)
655
+ }];
656
+ }
387
657
  function planSummaryText(result) {
388
658
  const operations = result.plan.operations.length;
389
659
  const spaces = result.perSpace?.length ?? 0;
@@ -404,6 +674,7 @@ function planBlocks(result) {
404
674
  status: "ok",
405
675
  text: planSummaryText(result)
406
676
  },
677
+ ...plannerWarningBlocks(result),
407
678
  ...operationBlocks$1(result),
408
679
  {
409
680
  kind: "fields",
@@ -464,6 +735,7 @@ function applyBlocks(result) {
464
735
  status: "ok",
465
736
  text: applySummaryText(result)
466
737
  },
738
+ ...plannerWarningBlocks(result),
467
739
  ...operationBlocks$1(result),
468
740
  ...fallbackMarkerBlocks(result),
469
741
  ...advanced === null || advanced === void 0 ? [] : [{
@@ -904,6 +1176,270 @@ function createDbSchemaCommand(createClient) {
904
1176
  });
905
1177
  }
906
1178
  const dbSchemaCommand = createDbSchemaCommand(createControlClient);
1179
+ /**
1180
+ * A `db update` failure as the CLI's structured error.
1181
+ *
1182
+ * `DESTRUCTIVE_CHANGES` is handled by the command, which asks for consent and
1183
+ * calls again; it is mapped here for the case the control API returns it from a
1184
+ * call that already carried consent, which would otherwise degrade silently.
1185
+ *
1186
+ * The `assertNever` is deliberate: a control-API failure code this does not
1187
+ * handle must stop the command rather than degrade into a generic message.
1188
+ */
1189
+ function mapDbUpdateFailure(failure) {
1190
+ if (failure.code === "PLANNING_FAILED") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });
1191
+ if (failure.code === "RUNNER_FAILED") {
1192
+ const fix = (typeof failure.meta?.["runnerErrorCode"] === "string" ? failure.meta["runnerErrorCode"] : void 0) === "MIGRATION.LEGACY_MARKER_SHAPE" ? "Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema." : "Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`";
1193
+ return errorRunnerFailed(failure.summary, {
1194
+ why: failure.why ?? "Migration runner failed",
1195
+ fix,
1196
+ meta: {
1197
+ ...failure.meta,
1198
+ ...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}
1199
+ },
1200
+ ...ifDefined("cause", failure.cause)
1201
+ });
1202
+ }
1203
+ if (failure.code === "DESTRUCTIVE_CHANGES") return errorDestructiveChanges(failure.summary, {
1204
+ ...ifDefined("why", failure.why),
1205
+ fix: "Re-run `prisma-next db update` and type the database name when asked, or pass `--no-interactive --confirm <database>` where there is nobody to ask. Use `--dry-run` to preview the operations first.",
1206
+ ...failure.destructiveChanges ? { meta: {
1207
+ destructiveOperations: failure.destructiveChanges.destructiveOperations,
1208
+ databaseName: failure.destructiveChanges.databaseName,
1209
+ planHash: failure.destructiveChanges.planHash
1210
+ } } : {}
1211
+ });
1212
+ if (failure.code === "CONSENT_PLAN_MISMATCH") return errorConsentPlanMismatch({
1213
+ consentedPlanHash: failure.consentPlanMismatch?.consentedPlanHash ?? "",
1214
+ planHash: failure.consentPlanMismatch?.planHash ?? "",
1215
+ ...ifDefined("why", failure.why)
1216
+ });
1217
+ const exhaustive = failure.code;
1218
+ return assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);
1219
+ }
1220
+ /**
1221
+ * A token nobody can type is not consent: an empty one makes the engine's
1222
+ * type-to-confirm accept a bare Enter, and `--confirm ""` grant outright.
1223
+ */
1224
+ function errorConsentTokenUnresolved(targetId) {
1225
+ return new CliStructuredError$1("CLI.CONSENT_TOKEN_UNRESOLVED", "The database this run would change has no name to confirm.", {
1226
+ why: `The connected database reports no name, and the target id "${targetId}" yields none either, so the consent prompt has nothing to ask you to type and the destructive operations cannot be authorised.`,
1227
+ nextActions: [{
1228
+ kind: "user-choice",
1229
+ label: "Name the database in `db.connection` (or pass `--db <url>`) and run `prisma-next db update` again."
1230
+ }]
1231
+ });
1232
+ }
1233
+ /** A prompt that names nothing cannot be consented to knowingly. */
1234
+ function errorConsentOperationsMissing() {
1235
+ return new CliStructuredError$1("CLI.CONSENT_OPERATIONS_MISSING", "The plan was refused as destructive but named no operations to confirm.", {
1236
+ why: "The consent prompt has to list what is about to be destroyed, and the refusal carried no operations to list.",
1237
+ nextActions: [{
1238
+ kind: "run-command",
1239
+ label: "Preview the plan",
1240
+ command: "prisma-next db update --dry-run"
1241
+ }]
1242
+ });
1243
+ }
1244
+ /** The question the user answers before anything is dropped. */
1245
+ function destructiveConsentQuestion(operations, token) {
1246
+ const listed = operations.map((operation) => ` - ${operation.label}`).join("\n");
1247
+ return [`Apply ${operations.length} destructive operation(s) to ${token}? Data they remove cannot be recovered:`, listed].join("\n");
1248
+ }
1249
+ function updatePresentations(inputs) {
1250
+ const { document, database, dryRun } = inputs;
1251
+ return {
1252
+ human: () => [{
1253
+ kind: "fields",
1254
+ rail: true,
1255
+ rows: [
1256
+ {
1257
+ label: "contract",
1258
+ value: inputs.contractPath
1259
+ },
1260
+ ...database === void 0 ? [] : [{
1261
+ label: "database",
1262
+ value: database
1263
+ }],
1264
+ ...inputs.to === void 0 ? [] : [{
1265
+ label: "to",
1266
+ value: inputs.to
1267
+ }],
1268
+ ...dryRun ? [{
1269
+ label: "mode",
1270
+ value: "dry run"
1271
+ }] : []
1272
+ ]
1273
+ }, ...migrationResultBlocks(document)],
1274
+ json: () => document,
1275
+ next: () => migrationResultNextActions(document, "prisma-next db update")
1276
+ };
1277
+ }
1278
+ function updateDocument(inputs) {
1279
+ const { value } = inputs;
1280
+ return {
1281
+ ok: true,
1282
+ mode: value.mode,
1283
+ plan: {
1284
+ targetId: inputs.targetId,
1285
+ destination: {
1286
+ storageHash: value.destination.storageHash,
1287
+ ...ifDefined("profileHash", value.destination.profileHash)
1288
+ },
1289
+ operations: value.plan.operations.map((operation) => ({
1290
+ id: operation.id,
1291
+ label: operation.label,
1292
+ operationClass: operation.operationClass
1293
+ })),
1294
+ ...ifDefined("preview", value.plan.preview)
1295
+ },
1296
+ ...value.execution === void 0 ? {} : { execution: {
1297
+ operationsPlanned: value.execution.operationsPlanned,
1298
+ operationsExecuted: value.execution.operationsExecuted
1299
+ } },
1300
+ ...value.marker === void 0 ? {} : { marker: {
1301
+ storageHash: value.marker.storageHash,
1302
+ ...ifDefined("profileHash", value.marker.profileHash)
1303
+ } },
1304
+ ...ifDefined("perSpace", value.perSpace),
1305
+ ...ifDefined("warnings", value.warnings),
1306
+ advancedRef: inputs.advancedRef,
1307
+ plannedAdvanceRef: inputs.plannedAdvanceRef,
1308
+ summary: value.summary,
1309
+ timings: { total: Date.now() - inputs.startedAt }
1310
+ };
1311
+ }
1312
+ function createDbUpdateCommand(createClient) {
1313
+ return defineOrmCommand({
1314
+ help: {
1315
+ summary: "Update your database schema to match your contract",
1316
+ description: "Compares the database to the emitted contract and applies the changes that\nclose the gap, whether or not the database was bootstrapped with `db init`.\nAn operation that would destroy data is applied only with your consent: the\ncommand asks you to type the database name. A run with nobody to ask — a CI\njob, or `--no-interactive` — takes it from `--confirm <database>` instead.\nUse --dry-run to see the operations without applying them.",
1317
+ examples: [
1318
+ "db update",
1319
+ "db update --dry-run",
1320
+ "db update --no-interactive --confirm appdb",
1321
+ "db update --to production"
1322
+ ]
1323
+ },
1324
+ args: { flags: {
1325
+ db: dbFlag,
1326
+ dryRun: flag.boolean({ brief: "Preview the planned operations without applying them" }),
1327
+ to: flag.string({
1328
+ brief: "Contract to update to (hash, prefix, ref name, migration dir name, or ./path)",
1329
+ placeholder: "contract"
1330
+ }),
1331
+ advanceRef: flag.string({
1332
+ brief: "Advance the named ref to the post-command contract hash",
1333
+ placeholder: "name"
1334
+ })
1335
+ } },
1336
+ needs: { config: ormConfigSection },
1337
+ handler: async (args, ctx) => {
1338
+ const startedAt = Date.now();
1339
+ const prepared = await prepareMigrationRun({
1340
+ config: ctx.config,
1341
+ cwd: ctx.cwd,
1342
+ db: args.flags.db,
1343
+ commandName: "db update",
1344
+ createClient
1345
+ });
1346
+ if (!prepared.ok) return notOk(prepared.failure);
1347
+ const { client, contractPath, dbConnection, migrationsDir, refsDir } = prepared.value;
1348
+ let contractJson = prepared.value.contractJson;
1349
+ let snapshotContractPath = contractPath;
1350
+ if (args.flags.to !== void 0) {
1351
+ const resolved = await resolveContractRefToSnapshot({
1352
+ config: ctx.config,
1353
+ migrationsDir,
1354
+ refInput: args.flags.to,
1355
+ contractPathAbsolute: contractPath,
1356
+ fallbackToEmitted: false,
1357
+ missingBundleFlag: "--to"
1358
+ });
1359
+ if (!resolved.ok) return notOk(normalizeError(resolved.failure));
1360
+ contractJson = resolved.value.contractJson;
1361
+ snapshotContractPath = resolved.value.contractJsonPath;
1362
+ }
1363
+ const mode = args.flags.dryRun ? "plan" : "apply";
1364
+ let document;
1365
+ try {
1366
+ await client.connect(dbConnection);
1367
+ const update = (consent) => client.dbUpdate({
1368
+ contract: contractJson,
1369
+ mode,
1370
+ migrationsDir,
1371
+ ...consent === void 0 ? {} : { consent },
1372
+ onProgress: controlProgressReporter(ctx.report)
1373
+ });
1374
+ const reported = /* @__PURE__ */ new Set();
1375
+ const reportPlannerWarnings = (warnings) => {
1376
+ for (const warning of warnings) if (!reported.has(warning.summary)) {
1377
+ reported.add(warning.summary);
1378
+ ctx.report({
1379
+ kind: "message",
1380
+ severity: "warn",
1381
+ text: warning.summary
1382
+ });
1383
+ }
1384
+ };
1385
+ let result = await update();
1386
+ if (mode === "apply" && !result.ok && result.failure.code === "DESTRUCTIVE_CHANGES") {
1387
+ reportPlannerWarnings(result.failure.warnings ?? []);
1388
+ const refusal = result.failure.destructiveChanges;
1389
+ if (refusal === void 0 || refusal.destructiveOperations.length === 0) return notOk(normalizeError(errorConsentOperationsMissing()));
1390
+ const token = refusal.databaseName ?? "";
1391
+ if (token.trim().length === 0) return notOk(normalizeError(errorConsentTokenUnresolved(ctx.config.target.targetId)));
1392
+ if (!await ctx.prompt.consent(destructiveConsentQuestion(refusal.destructiveOperations, token), { token })) return notOk(normalizeError(mapDbUpdateFailure(result.failure)));
1393
+ result = await update({ planHash: refusal.planHash });
1394
+ }
1395
+ if (!result.ok) {
1396
+ reportPlannerWarnings(result.failure.warnings ?? []);
1397
+ return notOk(normalizeError(mapDbUpdateFailure(result.failure)));
1398
+ }
1399
+ const advancementHash = result.value.mode === "apply" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;
1400
+ const advancement = await resolveRefAdvancementFields({
1401
+ ...ifDefined("advanceRef", args.flags.advanceRef),
1402
+ ...ifDefined("db", args.flags.db),
1403
+ refsDir,
1404
+ migrationsDir,
1405
+ contractJson,
1406
+ contractJsonPath: snapshotContractPath,
1407
+ mode: result.value.mode,
1408
+ hash: advancementHash
1409
+ });
1410
+ if (!advancement.ok) return notOk(normalizeError(advancement.failure));
1411
+ document = updateDocument({
1412
+ value: result.value,
1413
+ targetId: ctx.config.target.targetId,
1414
+ advancedRef: advancement.value.advancedRef,
1415
+ plannedAdvanceRef: advancement.value.plannedAdvanceRef,
1416
+ startedAt
1417
+ });
1418
+ } catch (error) {
1419
+ if (error instanceof CliStructuredError$1) throw error;
1420
+ if (CliStructuredError$1$1.is(error)) return notOk(normalizeError(error));
1421
+ if (isStructuredError(error) && error.code === "CONTRACT.VALIDATION_FAILED") return notOk(normalizeError(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPath } })));
1422
+ const safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === "string" ? dbConnection : void 0);
1423
+ return notOk(normalizeError(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` })));
1424
+ } finally {
1425
+ await closeQuietly(client);
1426
+ }
1427
+ ctx.report({
1428
+ kind: "message",
1429
+ severity: "verbose",
1430
+ text: `Total time: ${document.timings.total}ms`
1431
+ });
1432
+ return ok(ctx.present({ data: document }, updatePresentations({
1433
+ document,
1434
+ contractPath: prepared.value.contractDisplayPath,
1435
+ database: prepared.value.database,
1436
+ to: args.flags.to,
1437
+ dryRun: args.flags.dryRun
1438
+ })));
1439
+ }
1440
+ });
1441
+ }
1442
+ const dbUpdateCommand = createDbUpdateCommand(createControlClient);
907
1443
  const NOTHING_TO_FORMAT = "Nothing to format (contract source is not PSL).";
908
1444
  function formatPresentations(document, cwd) {
909
1445
  const path = document.path;
@@ -1967,8 +2503,11 @@ const DOCS_BASE_URL = `${DOCS_BASE}/`;
1967
2503
  const ormCommandFamily = defineCommandFamily({
1968
2504
  configSection: ormConfigSection,
1969
2505
  commands: {
2506
+ "contract emit": contractEmitCommand,
2507
+ "contract infer": contractInferCommand,
1970
2508
  "db init": dbInitCommand,
1971
2509
  "db schema": dbSchemaCommand,
2510
+ "db update": dbUpdateCommand,
1972
2511
  format: formatCommand,
1973
2512
  migrate: migrateCommand,
1974
2513
  "migration graph": migrationGraphCommand,