@prisma/orm-toolchain 8.0.0-rc.1-dev.21 → 8.0.0-rc.1-dev.23

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 (167) 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-D7Qznyrm-BzYooF6H.mjs → caught-errors-D7Qznyrm-DaZubR00.mjs} +2 -2
  4. package/dist/{caught-errors-D7Qznyrm-BzYooF6H.mjs.map → caught-errors-D7Qznyrm-DaZubR00.mjs.map} +1 -1
  5. package/dist/{cli-errors-CDr3WcJP-NFry5GHb.d.mts → cli-errors-BKPhkBSf-Ca-ymb6S.d.mts} +3 -3
  6. package/dist/{cli-errors-CDr3WcJP-NFry5GHb.d.mts.map → cli-errors-BKPhkBSf-Ca-ymb6S.d.mts.map} +1 -1
  7. package/dist/cli-telemetry.mjs +6 -5
  8. package/dist/cli-telemetry.mjs.map +1 -1
  9. package/dist/cli.mjs +2 -2
  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 +5 -5
  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 +66 -0
  39. package/dist/cli__control-api__testing.d.mts.map +1 -0
  40. package/dist/cli__control-api__testing.mjs +255 -0
  41. package/dist/cli__control-api__testing.mjs.map +1 -0
  42. package/dist/cli__migration-cli.mjs +13 -4
  43. package/dist/cli__migration-cli.mjs.map +1 -1
  44. package/dist/{client-Y6qbDk7X-BzKLmBZo.mjs → client-BNAEJZ76-ld7eOxpZ.mjs} +5 -5
  45. package/dist/{client-Y6qbDk7X-BzKLmBZo.mjs.map → client-BNAEJZ76-ld7eOxpZ.mjs.map} +1 -1
  46. package/dist/{command-helpers-C4WpR-QE-DE494TSG.mjs → command-helpers-C4WpR-QE-DNllqff1.mjs} +3 -3
  47. package/dist/{command-helpers-C4WpR-QE-DE494TSG.mjs.map → command-helpers-C4WpR-QE-DNllqff1.mjs.map} +1 -1
  48. package/dist/config-loader.d.mts +2 -2
  49. package/dist/config-loader.mjs +2 -2
  50. package/dist/{contract-at-errors-Dv1mxKYO-C29YB4RC.mjs → contract-at-errors-Dv1mxKYO-D4xfRBW5.mjs} +2 -2
  51. package/dist/{contract-at-errors-Dv1mxKYO-C29YB4RC.mjs.map → contract-at-errors-Dv1mxKYO-D4xfRBW5.mjs.map} +1 -1
  52. package/dist/{contract-emit-D8IXP9Qp-Df6NwXn8.mjs → contract-emit-DFu7h-Zl-7DBgYNv7.mjs} +9 -13
  53. package/dist/contract-emit-DFu7h-Zl-7DBgYNv7.mjs.map +1 -0
  54. package/dist/{contract-emit-CTm2zfuG-7PV9SBY6.mjs → contract-emit-DT0JKUZT-BYE7WZPc.mjs} +17 -9
  55. package/dist/contract-emit-DT0JKUZT-BYE7WZPc.mjs.map +1 -0
  56. package/dist/{contract-infer-BwT7ngoo-Dx6aAwIN.mjs → contract-infer-C_b7E71m-D2UO-X-k.mjs} +4 -4
  57. package/dist/{contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map → contract-infer-C_b7E71m-D2UO-X-k.mjs.map} +1 -1
  58. package/dist/{contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs → contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs} +3 -3
  59. package/dist/{contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map → contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs.map} +1 -1
  60. package/dist/{contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs → contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs} +2 -2
  61. package/dist/{contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map → contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs.map} +1 -1
  62. package/dist/{db-init-CBj_EWg3.mjs → db-init-Cqjw5Flp.mjs} +3 -3
  63. package/dist/{db-init-CBj_EWg3.mjs.map → db-init-Cqjw5Flp.mjs.map} +1 -1
  64. package/dist/{db-schema-BWpeh0Q_.mjs → db-schema-CRGCFKlH.mjs} +4 -4
  65. package/dist/{db-schema-BWpeh0Q_.mjs.map → db-schema-CRGCFKlH.mjs.map} +1 -1
  66. package/dist/{db-sign-DCb_DKtv.mjs → db-sign-BPQduGHb.mjs} +18 -7
  67. package/dist/db-sign-BPQduGHb.mjs.map +1 -0
  68. package/dist/{db-update-WX0KitcX.mjs → db-update-DuEk-ra5.mjs} +4 -4
  69. package/dist/{db-update-WX0KitcX.mjs.map → db-update-DuEk-ra5.mjs.map} +1 -1
  70. package/dist/{db-verify-B8ax2Y_x-Bp4s5Ra6.mjs → db-verify-DPH4lonK-pteoYVnK.mjs} +26 -11
  71. package/dist/db-verify-DPH4lonK-pteoYVnK.mjs.map +1 -0
  72. package/dist/exports-BN0vFTxG.mjs.map +1 -1
  73. package/dist/{exports-BnihzVhw.mjs → exports-DAA3XD4a.mjs} +15 -3
  74. package/dist/exports-DAA3XD4a.mjs.map +1 -0
  75. package/dist/exports-DVoyX2LM.mjs +173 -0
  76. package/dist/exports-DVoyX2LM.mjs.map +1 -0
  77. package/dist/{format-Bw3LVJ1v-BJ6lVFMA.mjs → format-DyVeO1z5-D1lnTJaz.mjs} +7 -11
  78. package/dist/format-DyVeO1z5-D1lnTJaz.mjs.map +1 -0
  79. package/dist/{framework-components-3DdB31mk-BHyX-OlJ.mjs → framework-components-ioeTnj2Z-yyQtaVWk.mjs} +7 -5
  80. package/dist/framework-components-ioeTnj2Z-yyQtaVWk.mjs.map +1 -0
  81. package/dist/index-Deu3DQZI.d.mts +47 -0
  82. package/dist/index-Deu3DQZI.d.mts.map +1 -0
  83. package/dist/{init-CPB89WK2-DPZRZ9Ee.mjs → init-BwYYd10C-CJq9i42m.mjs} +4 -4
  84. package/dist/{init-CPB89WK2-DPZRZ9Ee.mjs.map → init-BwYYd10C-CJq9i42m.mjs.map} +1 -1
  85. package/dist/{inspect-live-schema-Da76TWOs-CAFqkhGb.mjs → inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs} +15 -12
  86. package/dist/inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs.map +1 -0
  87. package/dist/{invariants-BzYfO9IL-BXTvx0z9.mjs → invariants-BzYfO9IL-BPDPDIr0.mjs} +2 -2
  88. package/dist/{invariants-BzYfO9IL-BXTvx0z9.mjs.map → invariants-BzYfO9IL-BPDPDIr0.mjs.map} +1 -1
  89. package/dist/{legend-5iwwlLU2-CB8bdQKJ.mjs → legend-5iwwlLU2-Bit8enjF.mjs} +2 -2
  90. package/dist/{legend-5iwwlLU2-CB8bdQKJ.mjs.map → legend-5iwwlLU2-Bit8enjF.mjs.map} +1 -1
  91. package/dist/{migrate-B-NAuO90.mjs → migrate-Bfsw18KQ.mjs} +23 -12
  92. package/dist/migrate-Bfsw18KQ.mjs.map +1 -0
  93. package/dist/{migrate-show-B2LkXkoB-D1ZNl84C.mjs → migrate-show-CO5OiR3J-DE4NIjvW.mjs} +18 -7
  94. package/dist/migrate-show-CO5OiR3J-DE4NIjvW.mjs.map +1 -0
  95. package/dist/{migrate-show-60NNqVia-oGqMaVA9.d.mts → migrate-show-Cu3k9mZm-B-nCgvK1.d.mts} +3 -3
  96. package/dist/{migrate-show-60NNqVia-oGqMaVA9.d.mts.map → migrate-show-Cu3k9mZm-B-nCgvK1.d.mts.map} +1 -1
  97. package/dist/{migration-check-BDjtAn7x-B0nEBR0k.mjs → migration-check-BfOnfgyY-DII6Ty5m.mjs} +19 -7
  98. package/dist/migration-check-BfOnfgyY-DII6Ty5m.mjs.map +1 -0
  99. package/dist/{migration-check-DONPyXff-CGTUpLv-.mjs → migration-check-DONPyXff-KpD0q3Zh.mjs} +4 -4
  100. package/dist/{migration-check-DONPyXff-CGTUpLv-.mjs.map → migration-check-DONPyXff-KpD0q3Zh.mjs.map} +1 -1
  101. package/dist/{migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs → migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs} +24 -7
  102. package/dist/migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs.map +1 -0
  103. package/dist/{migration-graph-Dn469b0l.mjs → migration-graph-BHiSuhBR.mjs} +17 -8
  104. package/dist/migration-graph-BHiSuhBR.mjs.map +1 -0
  105. package/dist/{migration-graph-HKch1Xk4-DyWhXtjZ.mjs → migration-graph-HKch1Xk4-DD-3zdSg.mjs} +2 -2
  106. package/dist/{migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map → migration-graph-HKch1Xk4-DD-3zdSg.mjs.map} +1 -1
  107. package/dist/{migration-list-jk4iCtmO.mjs → migration-list-BkTNEeOK.mjs} +16 -7
  108. package/dist/migration-list-BkTNEeOK.mjs.map +1 -0
  109. package/dist/{migration-list-C9OPCMt--C28yBgVr.mjs → migration-list-C9OPCMt--BBm2c7tN.mjs} +2 -2
  110. package/dist/{migration-list-C9OPCMt--C28yBgVr.mjs.map → migration-list-C9OPCMt--BBm2c7tN.mjs.map} +1 -1
  111. package/dist/{migration-log-DQzUBrm8-D3m9wcuf.mjs → migration-log-CqrwQXER-cqf2INDN.mjs} +17 -7
  112. package/dist/migration-log-CqrwQXER-cqf2INDN.mjs.map +1 -0
  113. package/dist/{migration-new-g98oB3nC-BcrkxAAt.mjs → migration-new-Cjhe_MIE-CIovsuXK.mjs} +17 -8
  114. package/dist/migration-new-Cjhe_MIE-CIovsuXK.mjs.map +1 -0
  115. package/dist/{migration-new-BkSY6m0t.mjs → migration-new-NuMfcbH8.mjs} +3 -3
  116. package/dist/{migration-new-BkSY6m0t.mjs.map → migration-new-NuMfcbH8.mjs.map} +1 -1
  117. package/dist/{migration-path-target-BPYp3LNc-DsDdLU0J.mjs → migration-path-target-BPYp3LNc-DjdEIQsZ.mjs} +2 -2
  118. package/dist/{migration-path-target-BPYp3LNc-DsDdLU0J.mjs.map → migration-path-target-BPYp3LNc-DjdEIQsZ.mjs.map} +1 -1
  119. package/dist/{migration-plan-CjIYMJZy.mjs → migration-plan-D81XmVwy.mjs} +3 -3
  120. package/dist/{migration-plan-CjIYMJZy.mjs.map → migration-plan-D81XmVwy.mjs.map} +1 -1
  121. package/dist/{migration-plan-CwuZLXVE-DAJ-JUQT.mjs → migration-plan-DE7-vtqT-jgtSH4Lw.mjs} +18 -9
  122. package/dist/migration-plan-DE7-vtqT-jgtSH4Lw.mjs.map +1 -0
  123. package/dist/{migration-plan-BsOYRogP-CC1UFAbu.d.mts → migration-plan-DvBJhxXg-B5aHAOtu.d.mts} +3 -3
  124. package/dist/{migration-plan-BsOYRogP-CC1UFAbu.d.mts.map → migration-plan-DvBJhxXg-B5aHAOtu.d.mts.map} +1 -1
  125. package/dist/{migration-show-CW6EKtfw.mjs → migration-show-DEsLJ6-a.mjs} +18 -8
  126. package/dist/migration-show-DEsLJ6-a.mjs.map +1 -0
  127. package/dist/{migration-status-DSQcBhiN.mjs → migration-status-DfLM3VqL.mjs} +21 -10
  128. package/dist/migration-status-DfLM3VqL.mjs.map +1 -0
  129. package/dist/{project-import-root-C_bd0ooL-WkbJLnAA.mjs → project-import-root-C_bd0ooL-CusfluWF.mjs} +2 -2
  130. package/dist/{project-import-root-C_bd0ooL-WkbJLnAA.mjs.map → project-import-root-C_bd0ooL-CusfluWF.mjs.map} +1 -1
  131. package/dist/{ref-DSAZime8.mjs → ref-D6JzE8nq.mjs} +3 -3
  132. package/dist/{ref-DSAZime8.mjs.map → ref-D6JzE8nq.mjs.map} +1 -1
  133. package/dist/{ref-eJjxzYTh-CNiyDL4p.mjs → ref-DrAvdDhN-q1ccuI03.mjs} +21 -10
  134. package/dist/ref-DrAvdDhN-q1ccuI03.mjs.map +1 -0
  135. package/dist/{ref-resolution-_S4xTT2L-BE5zgO2W.mjs → ref-resolution-_S4xTT2L-JfNjZU9d.mjs} +2 -2
  136. package/dist/{ref-resolution-_S4xTT2L-BE5zgO2W.mjs.map → ref-resolution-_S4xTT2L-JfNjZU9d.mjs.map} +1 -1
  137. package/dist/{telemetry-DVBHDQd6-Ckn5oClN.mjs → telemetry-DVBHDQd6-CWNTFnMO.mjs} +2 -2
  138. package/dist/{telemetry-DVBHDQd6-Ckn5oClN.mjs.map → telemetry-DVBHDQd6-CWNTFnMO.mjs.map} +1 -1
  139. package/dist/{verify-C6L_hiJU-B4V3bqvG.mjs → verify-C6L_hiJU-MX67LFfI.mjs} +2 -2
  140. package/dist/{verify-C6L_hiJU-B4V3bqvG.mjs.map → verify-C6L_hiJU-MX67LFfI.mjs.map} +1 -1
  141. package/dist/vite-plugin-contract-emit.mjs +5 -3
  142. package/dist/vite-plugin-contract-emit.mjs.map +1 -1
  143. package/package.json +13 -12
  144. package/dist/contract-emit-CTm2zfuG-7PV9SBY6.mjs.map +0 -1
  145. package/dist/contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map +0 -1
  146. package/dist/db-sign-DCb_DKtv.mjs.map +0 -1
  147. package/dist/db-verify-B8ax2Y_x-Bp4s5Ra6.mjs.map +0 -1
  148. package/dist/exports-BnihzVhw.mjs.map +0 -1
  149. package/dist/exports-CDX9kZuw.mjs +0 -119
  150. package/dist/exports-CDX9kZuw.mjs.map +0 -1
  151. package/dist/format-Bw3LVJ1v-BJ6lVFMA.mjs.map +0 -1
  152. package/dist/framework-components-3DdB31mk-BHyX-OlJ.mjs.map +0 -1
  153. package/dist/index-Df9igRvP.d.mts +0 -18
  154. package/dist/index-Df9igRvP.d.mts.map +0 -1
  155. package/dist/inspect-live-schema-Da76TWOs-CAFqkhGb.mjs.map +0 -1
  156. package/dist/migrate-B-NAuO90.mjs.map +0 -1
  157. package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs.map +0 -1
  158. package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs.map +0 -1
  159. package/dist/migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map +0 -1
  160. package/dist/migration-graph-Dn469b0l.mjs.map +0 -1
  161. package/dist/migration-list-jk4iCtmO.mjs.map +0 -1
  162. package/dist/migration-log-DQzUBrm8-D3m9wcuf.mjs.map +0 -1
  163. package/dist/migration-new-g98oB3nC-BcrkxAAt.mjs.map +0 -1
  164. package/dist/migration-plan-CwuZLXVE-DAJ-JUQT.mjs.map +0 -1
  165. package/dist/migration-show-CW6EKtfw.mjs.map +0 -1
  166. package/dist/migration-status-DSQcBhiN.mjs.map +0 -1
  167. package/dist/ref-eJjxzYTh-CNiyDL4p.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"contract-at-errors-Dv1mxKYO-C29YB4RC.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-at-errors-Dv1mxKYO.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, F as CliStructuredError, W as errorFileNotFound, ct as errorUnexpected, it as errorSnapshotMissing } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { notOk } from \"@internal/utils/result\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/control-api/operations/contract-at-errors.ts\nfunction mapContractAtError(error, options) {\n\tif (MigrationToolsError.is(error)) switch (error.code) {\n\t\tcase \"MIGRATION.REF_NOT_RESOLVABLE\": return notOk(errorSnapshotMissing(typeof error.meta?.[\"refName\"] === \"string\" ? error.meta[\"refName\"] : typeof error.meta?.[\"identifier\"] === \"string\" ? error.meta[\"identifier\"] : \"unknown\", { cause: error }));\n\t\tcase \"MIGRATION.CONTRACT_DESERIALIZATION_FAILED\": {\n\t\t\tconst filePath = typeof error.meta?.[\"filePath\"] === \"string\" ? error.meta[\"filePath\"] : \"unknown\";\n\t\t\treturn notOk(errorContractValidationFailed(`Predecessor contract at ${filePath} failed to deserialize: ${typeof error.meta?.[\"message\"] === \"string\" ? error.meta[\"message\"] : error.message}`, {\n\t\t\t\twhere: { path: filePath },\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tcase \"MIGRATION.INVALID_JSON\": {\n\t\t\tconst filePath = typeof error.meta?.[\"filePath\"] === \"string\" ? error.meta[\"filePath\"] : \"unknown\";\n\t\t\tconst message = typeof error.meta?.[\"parseError\"] === \"string\" ? error.meta[\"parseError\"] : error.message;\n\t\t\treturn notOk(errorContractValidationFailed((options?.artifactRole ?? \"from\") === \"to\" ? `Target contract at ${filePath} failed to deserialize: ${message}` : `Predecessor contract at ${filePath} failed to deserialize: ${message}`, {\n\t\t\t\twhere: { path: filePath },\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tcase \"MIGRATION.BUNDLE_NOT_FOUND_FOR_GRAPH_NODE\": return notOk(errorUnexpected(error.message, {\n\t\t\twhy: error.why,\n\t\t\tfix: error.fix,\n\t\t\tcause: error\n\t\t}));\n\t\tcase \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\": {\n\t\t\tconst expectedPath = typeof error.meta?.[\"expectedPath\"] === \"string\" ? error.meta[\"expectedPath\"] : \"migrations/snapshots/\";\n\t\t\treturn notOk(errorFileNotFound(expectedPath, {\n\t\t\t\twhy: (options?.artifactRole ?? \"from\") === \"to\" ? `Target migration is missing its contract snapshot at ${expectedPath}` : `Predecessor migration is missing its contract snapshot at ${expectedPath}`,\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\tcause: error\n\t\t\t}));\n\t\t}\n\t\tdefault: return notOk(error);\n\t}\n\tif (CliStructuredError.is(error)) return notOk(error);\n\tthrow error;\n}\n//#endregion\nexport { mapContractAtError as t };\n\n//# sourceMappingURL=contract-at-errors-Dv1mxKYO.mjs.map"],"mappings":";;;;AAIA,SAAS,mBAAmB,OAAO,SAAS;CAC3C,IAAI,oBAAoB,GAAG,KAAK,GAAG,QAAQ,MAAM,MAAd;EAClC,KAAK,gCAAgC,OAAO,MAAM,qBAAqB,OAAO,MAAM,OAAO,eAAe,WAAW,MAAM,KAAK,aAAa,OAAO,MAAM,OAAO,kBAAkB,WAAW,MAAM,KAAK,gBAAgB,WAAW,EAAE,OAAO,MAAM,CAAC,CAAC;EACrP,KAAK,6CAA6C;GACjD,MAAM,WAAW,OAAO,MAAM,OAAO,gBAAgB,WAAW,MAAM,KAAK,cAAc;GACzF,OAAO,MAAM,8BAA8B,2BAA2B,SAAS,0BAA0B,OAAO,MAAM,OAAO,eAAe,WAAW,MAAM,KAAK,aAAa,MAAM,WAAW;IAC/L,OAAO,EAAE,MAAM,SAAS;IACxB,OAAO;GACR,CAAC,CAAC;EACH;EACA,KAAK,0BAA0B;GAC9B,MAAM,WAAW,OAAO,MAAM,OAAO,gBAAgB,WAAW,MAAM,KAAK,cAAc;GACzF,MAAM,UAAU,OAAO,MAAM,OAAO,kBAAkB,WAAW,MAAM,KAAK,gBAAgB,MAAM;GAClG,OAAO,MAAM,+BAA+B,SAAS,gBAAgB,YAAY,OAAO,sBAAsB,SAAS,0BAA0B,YAAY,2BAA2B,SAAS,0BAA0B,WAAW;IACrO,OAAO,EAAE,MAAM,SAAS;IACxB,OAAO;GACR,CAAC,CAAC;EACH;EACA,KAAK,6CAA6C,OAAO,MAAM,gBAAgB,MAAM,SAAS;GAC7F,KAAK,MAAM;GACX,KAAK,MAAM;GACX,OAAO;EACR,CAAC,CAAC;EACF,KAAK,uCAAuC;GAC3C,MAAM,eAAe,OAAO,MAAM,OAAO,oBAAoB,WAAW,MAAM,KAAK,kBAAkB;GACrG,OAAO,MAAM,kBAAkB,cAAc;IAC5C,MAAM,SAAS,gBAAgB,YAAY,OAAO,wDAAwD,iBAAiB,6DAA6D;IACxL,KAAK;IACL,OAAO;GACR,CAAC,CAAC;EACH;EACA,SAAS,OAAO,MAAM,KAAK;CAC5B;CACA,IAAIA,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;CACpD,MAAM;AACP"}
1
+ {"version":3,"file":"contract-at-errors-Dv1mxKYO-D4xfRBW5.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-at-errors-Dv1mxKYO.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, F as CliStructuredError, W as errorFileNotFound, ct as errorUnexpected, it as errorSnapshotMissing } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { notOk } from \"@internal/utils/result\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/control-api/operations/contract-at-errors.ts\nfunction mapContractAtError(error, options) {\n\tif (MigrationToolsError.is(error)) switch (error.code) {\n\t\tcase \"MIGRATION.REF_NOT_RESOLVABLE\": return notOk(errorSnapshotMissing(typeof error.meta?.[\"refName\"] === \"string\" ? error.meta[\"refName\"] : typeof error.meta?.[\"identifier\"] === \"string\" ? error.meta[\"identifier\"] : \"unknown\", { cause: error }));\n\t\tcase \"MIGRATION.CONTRACT_DESERIALIZATION_FAILED\": {\n\t\t\tconst filePath = typeof error.meta?.[\"filePath\"] === \"string\" ? error.meta[\"filePath\"] : \"unknown\";\n\t\t\treturn notOk(errorContractValidationFailed(`Predecessor contract at ${filePath} failed to deserialize: ${typeof error.meta?.[\"message\"] === \"string\" ? error.meta[\"message\"] : error.message}`, {\n\t\t\t\twhere: { path: filePath },\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tcase \"MIGRATION.INVALID_JSON\": {\n\t\t\tconst filePath = typeof error.meta?.[\"filePath\"] === \"string\" ? error.meta[\"filePath\"] : \"unknown\";\n\t\t\tconst message = typeof error.meta?.[\"parseError\"] === \"string\" ? error.meta[\"parseError\"] : error.message;\n\t\t\treturn notOk(errorContractValidationFailed((options?.artifactRole ?? \"from\") === \"to\" ? `Target contract at ${filePath} failed to deserialize: ${message}` : `Predecessor contract at ${filePath} failed to deserialize: ${message}`, {\n\t\t\t\twhere: { path: filePath },\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tcase \"MIGRATION.BUNDLE_NOT_FOUND_FOR_GRAPH_NODE\": return notOk(errorUnexpected(error.message, {\n\t\t\twhy: error.why,\n\t\t\tfix: error.fix,\n\t\t\tcause: error\n\t\t}));\n\t\tcase \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\": {\n\t\t\tconst expectedPath = typeof error.meta?.[\"expectedPath\"] === \"string\" ? error.meta[\"expectedPath\"] : \"migrations/snapshots/\";\n\t\t\treturn notOk(errorFileNotFound(expectedPath, {\n\t\t\t\twhy: (options?.artifactRole ?? \"from\") === \"to\" ? `Target migration is missing its contract snapshot at ${expectedPath}` : `Predecessor migration is missing its contract snapshot at ${expectedPath}`,\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\tcause: error\n\t\t\t}));\n\t\t}\n\t\tdefault: return notOk(error);\n\t}\n\tif (CliStructuredError.is(error)) return notOk(error);\n\tthrow error;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AY,OAAO,wDAAwD,iBAAiB,6DAA6D;IACxL,KAAK;IACL,OAAO;GACR,CAAC,CAAC;EACH;EACA,SAAS,OAAO,MAAM,KAAK;CAC5B;CACA,IAAIA,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;CACpD,MAAM;AACP"}
@@ -1,14 +1,14 @@
1
- import { r as executeContractEmit } from "./contract-emit-CTm2zfuG-7PV9SBY6.mjs";
2
- import { G as formatSuccessMessage, N as errorUnexpected$1, W as formatStyledHeader, X as isVerbose, et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
1
+ import { r as executeContractEmit } from "./contract-emit-DT0JKUZT-BYE7WZPc.mjs";
2
+ import { G as formatSuccessMessage, N as errorUnexpected, W as formatStyledHeader, X as isVerbose, et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
3
3
  import { r as getEmittedArtifactPaths } from "./exports-BCLg4CiV-okAfZydo.mjs";
4
- import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
4
+ import { a as loadConfigForSections } from "./exports-DVoyX2LM.mjs";
5
5
  import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
6
6
  import { errorContractConfigMissing } from "@prisma/orm-framework/errors/control";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
9
9
  import { dirname, join, relative, resolve } from "pathe";
10
10
  import { Command } from "commander";
11
- //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-D8IXP9Qp.mjs
11
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-DFu7h-Zl.mjs
12
12
  /**
13
13
  * Formats human-readable output for contract emit.
14
14
  */
@@ -48,13 +48,9 @@ function formatEmitJson(result) {
48
48
  */
49
49
  async function resolveHeaderPaths(configOption, outputPath) {
50
50
  const displayConfigPath = configOption ? relative(process.cwd(), resolve(configOption)) : "prisma-next.config.ts";
51
- let config;
52
- try {
53
- config = await loadConfig(configOption);
54
- } catch (error) {
55
- if (error instanceof CliStructuredError$1) return notOk(error);
56
- return notOk(errorUnexpected$1(error instanceof Error ? error.message : String(error), { why: "Failed to load config" }));
57
- }
51
+ const configResult = await loadConfigForSections(configOption, ["contract"]);
52
+ if (!configResult.ok) return configResult;
53
+ const config = configResult.value;
58
54
  const effectiveJsonPath = outputPath !== void 0 ? join(outputPath, "contract.json") : config.contract?.output;
59
55
  if (!effectiveJsonPath) return notOk(errorContractConfigMissing({ why: "Config.contract.output is required for emit. Define it in your config: contract: { source: ..., output: ... }" }));
60
56
  try {
@@ -107,7 +103,7 @@ async function executeContractEmitCommand(options, flags, ui, startTime) {
107
103
  });
108
104
  } catch (error) {
109
105
  if (CliStructuredError$1.is(error)) return notOk(error);
110
- return notOk(errorUnexpected$1("Unexpected error during contract emit", { why: error instanceof Error ? error.message : String(error) }));
106
+ return notOk(errorUnexpected("Unexpected error during contract emit", { why: error instanceof Error ? error.message : String(error) }));
111
107
  }
112
108
  if (result.validationWarning) ui.warn(result.validationWarning);
113
109
  return ok({
@@ -145,4 +141,4 @@ function createContractEmitCommand() {
145
141
  //#endregion
146
142
  export { createContractEmitCommand as t };
147
143
 
148
- //# sourceMappingURL=contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map
144
+ //# sourceMappingURL=contract-emit-DFu7h-Zl-7DBgYNv7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-emit-DFu7h-Zl-7DBgYNv7.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-emit-DFu7h-Zl.mjs"],"sourcesContent":["import { n as executeContractEmit } from \"./contract-emit-DT0JKUZT.mjs\";\nimport { A as formatStyledHeader, F as CliStructuredError$1, P as isVerbose, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, j as formatSuccessMessage, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { errorContractConfigMissing } from \"@internal/errors/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { dirname, join, relative, resolve } from \"pathe\";\n//#region src/utils/formatters/emit.ts\n/**\n* Formats human-readable output for contract emit.\n*/\nfunction formatEmitOutput(result, flags) {\n\tif (flags.quiet) return \"\";\n\tconst lines = [];\n\tconst jsonPath = relative(process.cwd(), result.files.json);\n\tconst dtsPath = relative(process.cwd(), result.files.dts);\n\tlines.push(`✔ Emitted contract.json → ${jsonPath}`);\n\tlines.push(`✔ Emitted contract.d.ts → ${dtsPath}`);\n\tlines.push(` storageHash: ${result.storageHash}`);\n\tif (result.executionHash) lines.push(` executionHash: ${result.executionHash}`);\n\tif (result.profileHash) lines.push(` profileHash: ${result.profileHash}`);\n\tif (isVerbose(flags, 1)) lines.push(` Total time: ${result.timings.total}ms`);\n\treturn lines.join(\"\\n\");\n}\n/**\n* Formats JSON output for contract emit.\n*/\nfunction formatEmitJson(result) {\n\tconst output = {\n\t\tok: true,\n\t\tstorageHash: result.storageHash,\n\t\t...ifDefined(\"executionHash\", result.executionHash),\n\t\t...result.profileHash ? { profileHash: result.profileHash } : {},\n\t\toutDir: result.outDir,\n\t\tfiles: result.files,\n\t\ttimings: result.timings\n\t};\n\treturn JSON.stringify(output, null, 2);\n}\n//#endregion\n//#region src/commands/contract-emit.ts\n/**\n* Pre-load the config just to compute display paths for the styled header. The\n* actual emit work goes through `executeContractEmit`, which loads the config\n* itself; the redundant load here is bounded and lets the header render before\n* the emit spans start.\n*/\nasync function resolveHeaderPaths(configOption, outputPath) {\n\tconst displayConfigPath = configOption ? relative(process.cwd(), resolve(configOption)) : \"prisma-next.config.ts\";\n\tconst configResult = await loadConfigForSections(configOption, [\"contract\"]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst effectiveJsonPath = outputPath !== void 0 ? join(outputPath, \"contract.json\") : config.contract?.output;\n\tif (!effectiveJsonPath) return notOk(errorContractConfigMissing({ why: \"Config.contract.output is required for emit. Define it in your config: contract: { source: ..., output: ... }\" }));\n\ttry {\n\t\tconst { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = getEmittedArtifactPaths(effectiveJsonPath);\n\t\treturn ok({\n\t\t\tdisplayConfigPath,\n\t\t\toutputJsonPath,\n\t\t\toutputDtsPath\n\t\t});\n\t} catch (error) {\n\t\treturn notOk(errorContractConfigMissing({ why: error instanceof Error ? error.message : String(error) }));\n\t}\n}\nasync function executeContractEmitCommand(options, flags, ui, startTime) {\n\tconst outputPath = options.outputPath !== void 0 ? resolve(options.outputPath) : void 0;\n\tconst headerPathsResult = await resolveHeaderPaths(options.config, outputPath);\n\tif (!headerPathsResult.ok) return headerPathsResult;\n\tconst { displayConfigPath, outputJsonPath, outputDtsPath } = headerPathsResult.value;\n\tif (!flags.json && !flags.quiet) ui.stderr(formatStyledHeader({\n\t\tcommand: \"contract emit\",\n\t\tdescription: \"Emit your contract artifacts\",\n\t\turl: \"https://pris.ly/contract-emit\",\n\t\tdetails: [\n\t\t\t{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: displayConfigPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"contract\",\n\t\t\t\tvalue: relative(process.cwd(), outputJsonPath)\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"types\",\n\t\t\t\tvalue: relative(process.cwd(), outputDtsPath)\n\t\t\t}\n\t\t],\n\t\tflags\n\t}));\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\tconst configPath = options.config ? resolve(options.config) : \"prisma-next.config.ts\";\n\tlet result;\n\ttry {\n\t\tresult = await executeContractEmit({\n\t\t\tconfigPath,\n\t\t\tonProgress,\n\t\t\t...ifDefined(\"outputPath\", outputPath)\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError$1.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(\"Unexpected error during contract emit\", { why: error instanceof Error ? error.message : String(error) }));\n\t}\n\tif (result.validationWarning) ui.warn(result.validationWarning);\n\treturn ok({\n\t\tstorageHash: result.storageHash,\n\t\t...ifDefined(\"executionHash\", result.executionHash),\n\t\tprofileHash: result.profileHash,\n\t\toutDir: dirname(result.files.json),\n\t\tfiles: result.files,\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n}\nfunction createContractEmitCommand() {\n\tconst command = new Command(\"emit\");\n\tsetCommandDescriptions(command, \"Emit your contract artifacts\", \"Reads your contract source (TypeScript or Prisma schema) and emits contract.json and\\ncontract.d.ts. The contract.json contains the canonical contract structure, and\\ncontract.d.ts provides TypeScript types for type-safe query building.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next contract emit\",\n\t\t\"prisma-next contract emit --config ./custom-config.ts\",\n\t\t\"prisma-next contract emit --output-path ./generated\"\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--output-path <dir>\", \"Directory to write contract.json and contract.d.ts into\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeContractEmitCommand(options, flags, ui, Date.now()), flags, ui, (emitResult) => {\n\t\t\tif (flags.json) ui.output(formatEmitJson(emitResult));\n\t\t\telse {\n\t\t\t\tconst output = formatEmitOutput(emitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t\tif (!flags.quiet) ui.success(formatSuccessMessage(flags));\n\t\t\t}\n\t\t});\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AAM,gBAAgB,yCAAyC,EAAE,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,CAAC,CAAC;CACvI;CACA,IAAI,OAAO,mBAAmB,GAAG,KAAK,OAAO,iBAAiB;CAC9D,OAAO,GAAG;EACT,aAAa,OAAO;EACpB,GAAG,UAAU,iBAAiB,OAAO,aAAa;EAClD,aAAa,OAAO;EACpB,QAAQ,QAAQ,OAAO,MAAM,IAAI;EACjC,OAAO,OAAO;EACd,SAAS,EAAE,OAAO,KAAK,IAAI,IAAI,UAAU;CAC1C,CAAC;AACF;AACA,SAAS,4BAA4B;CACpC,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,uBAAuB,SAAS,gCAAgC,8OAA8O;CAC9S,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,uBAAuB,yDAAyD,CAAC,CAAC,OAAO,OAAO,YAAY;EACvM,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,2BAA2B,SAAS,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG,OAAO,KAAK,eAAe;GAC1H,IAAI,MAAM,MAAM,GAAG,OAAO,eAAe,UAAU,CAAC;QAC/C;IACJ,MAAM,SAAS,iBAAiB,YAAY,KAAK;IACjD,IAAI,QAAQ,GAAG,IAAI,MAAM;IACzB,IAAI,CAAC,MAAM,OAAO,GAAG,QAAQ,qBAAqB,KAAK,CAAC;GACzD;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,9 +1,9 @@
1
- import { O as errorRuntime$1, u as errorContractConfigMissing$1 } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-3DdB31mk-BHyX-OlJ.mjs";
3
- import { t as createProjectSpecifierResolver } from "./project-import-root-C_bd0ooL-WkbJLnAA.mjs";
1
+ import { O as errorRuntime$1, u as errorContractConfigMissing$1 } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-ioeTnj2Z-yyQtaVWk.mjs";
3
+ import { t as createProjectSpecifierResolver } from "./project-import-root-C_bd0ooL-CusfluWF.mjs";
4
4
  import { t as enrichContract } from "./contract-enrichment-DrMvvY2A-DxNGeF4d.mjs";
5
5
  import { r as getEmittedArtifactPaths, t as emit } from "./exports-BCLg4CiV-okAfZydo.mjs";
6
- import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
6
+ import { a as loadConfigForSections } from "./exports-DVoyX2LM.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
9
9
  import { basename, dirname, join } from "pathe";
@@ -22,8 +22,8 @@ var __exportAll$1 = (all, no_symbols) => {
22
22
  return target;
23
23
  };
24
24
  //#endregion
25
- //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-CTm2zfuG.mjs
26
- var contract_emit_CTm2zfuG_exports = /* @__PURE__ */ __exportAll$1({
25
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-DT0JKUZT.mjs
26
+ var contract_emit_DT0JKUZT_exports = /* @__PURE__ */ __exportAll$1({
27
27
  n: () => executeContractEmit,
28
28
  r: () => disposeEmitQueue,
29
29
  t: () => contract_emit_exports
@@ -267,7 +267,15 @@ function validateProviderResult(providerResult) {
267
267
  async function executeContractEmit(options) {
268
268
  const { configPath, outputPath, signal = new AbortController().signal, onProgress } = options;
269
269
  const unlessAborted = abortable(signal);
270
- const config = await unlessAborted(loadConfig(configPath));
270
+ const configResult = await unlessAborted(loadConfigForSections(configPath, [
271
+ "contract",
272
+ "family",
273
+ "target",
274
+ "adapter",
275
+ "extensions"
276
+ ]));
277
+ if (!configResult.ok) throw configResult.failure;
278
+ const config = configResult.value;
271
279
  if (!config.contract) throw errorContractConfigMissing$1({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
272
280
  const contractConfig = config.contract;
273
281
  const effectiveOutput = outputPath !== void 0 ? join(outputPath, "contract.json") : contractConfig.output;
@@ -355,6 +363,6 @@ async function executeContractEmit(options) {
355
363
  });
356
364
  }
357
365
  //#endregion
358
- export { disposeEmitQueue as n, executeContractEmit as r, contract_emit_CTm2zfuG_exports as t };
366
+ export { disposeEmitQueue as n, executeContractEmit as r, contract_emit_DT0JKUZT_exports as t };
359
367
 
360
- //# sourceMappingURL=contract-emit-CTm2zfuG-7PV9SBY6.mjs.map
368
+ //# sourceMappingURL=contract-emit-DT0JKUZT-BYE7WZPc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-emit-DT0JKUZT-BYE7WZPc.mjs","names":["errorRuntime","errorContractConfigMissing"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-emit-DT0JKUZT.mjs"],"sourcesContent":["import { rt as errorRuntime, z as errorContractConfigMissing } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"./framework-components-ioeTnj2Z.mjs\";\nimport { t as createProjectSpecifierResolver } from \"./project-import-root-C_bd0ooL.mjs\";\nimport { t as enrichContract } from \"./contract-enrichment-DrMvvY2A.mjs\";\nimport { createRequire } from \"node:module\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { emit, getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { basename, dirname, join } from \"pathe\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { abortable } from \"@internal/utils/abortable\";\n//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\n//#region src/utils/emit-queue.ts\n/**\n* Per-output FIFO queue for `executeContractEmit`.\n*\n* Ensures that at most one emit (load → resolve source → emit bytes → publish)\n* runs per output JSON path at a time. Concurrent calls for the same path\n* line up behind the in-flight one and run in submission order; the user-visible\n* outcome is \"last submission wins on disk\" without any supersession bookkeeping.\n*\n* Long-lived hosts (Vite dev server, watch CLIs) must call `disposeEmitQueue`\n* when they stop publishing to a path, otherwise the module-global `Map`\n* accumulates one entry per unique output path for the lifetime of the process.\n*/\nconst emitQueues = /* @__PURE__ */ new Map();\nfunction queueEmitByOutput(outputJsonPath, action) {\n\tconst next = (emitQueues.get(outputJsonPath) ?? Promise.resolve()).then(action, action);\n\temitQueues.set(outputJsonPath, next);\n\treturn next;\n}\nfunction disposeEmitQueue(outputJsonPath) {\n\temitQueues.delete(outputJsonPath);\n}\n//#endregion\n//#region src/utils/publish-contract-artifact-pair.ts\nfunction isRecord$1(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction createTempArtifactPath(path, publicationToken, phase) {\n\treturn join(dirname(path), `.${basename(path)}.${process.pid}.${publicationToken}.${phase}.tmp`);\n}\nasync function readExistingArtifact(path) {\n\ttry {\n\t\treturn { content: await readFile(path, \"utf-8\") };\n\t} catch (error) {\n\t\tif (isRecord$1(error) && error[\"code\"] === \"ENOENT\") return \"remove\";\n\t\tthrow error;\n\t}\n}\nasync function restoreArtifact(path, previous, publicationToken) {\n\tif (previous === \"remove\") {\n\t\tawait rm(path, { force: true });\n\t\treturn;\n\t}\n\tconst restorePath = createTempArtifactPath(path, publicationToken, \"rollback\");\n\tawait writeFile(restorePath, previous.content, \"utf-8\");\n\ttry {\n\t\tawait rename(restorePath, path);\n\t} finally {\n\t\tawait rm(restorePath, { force: true });\n\t}\n}\nfunction withRollbackFailureCause(error, rollbackFailures) {\n\tconst rollbackCause = new AggregateError(rollbackFailures, \"Failed to restore published artifacts\");\n\tif (error instanceof Error) {\n\t\tObject.defineProperty(error, \"cause\", {\n\t\t\tvalue: rollbackCause,\n\t\t\tconfigurable: true,\n\t\t\twritable: true\n\t\t});\n\t\treturn error;\n\t}\n\treturn new Error(String(error), { cause: rollbackCause });\n}\nasync function publishPairWithRollback(entries, publicationToken) {\n\tconst replaced = [];\n\ttry {\n\t\tfor (const entry of entries) {\n\t\t\tawait rename(entry.tempPath, entry.outputPath);\n\t\t\treplaced.push(entry);\n\t\t}\n\t} catch (error) {\n\t\tconst rollbackFailures = (await Promise.allSettled(replaced.map((entry) => restoreArtifact(entry.outputPath, entry.previous, publicationToken)))).flatMap((result) => result.status === \"rejected\" ? [result.reason] : []);\n\t\tif (rollbackFailures.length > 0) throw withRollbackFailureCause(error, rollbackFailures);\n\t\tthrow error;\n\t}\n}\nasync function publishContractArtifactPair({ outputJsonPath, outputDtsPath, contractJson, contractDts, publicationToken, beforePublish }) {\n\tconst tempJsonPath = createTempArtifactPath(outputJsonPath, publicationToken, \"next\");\n\tconst tempDtsPath = createTempArtifactPath(outputDtsPath, publicationToken, \"next\");\n\ttry {\n\t\tawait writeFile(tempJsonPath, contractJson, \"utf-8\");\n\t\tawait writeFile(tempDtsPath, contractDts, \"utf-8\");\n\t\tif (await beforePublish?.() === false) return false;\n\t\tconst previousJson = await readExistingArtifact(outputJsonPath);\n\t\tawait publishPairWithRollback([{\n\t\t\ttempPath: tempDtsPath,\n\t\t\toutputPath: outputDtsPath,\n\t\t\tprevious: await readExistingArtifact(outputDtsPath)\n\t\t}, {\n\t\t\ttempPath: tempJsonPath,\n\t\t\toutputPath: outputJsonPath,\n\t\t\tprevious: previousJson\n\t\t}], publicationToken);\n\t\treturn true;\n\t} finally {\n\t\tawait Promise.allSettled([rm(tempJsonPath, { force: true }), rm(tempDtsPath, { force: true })]);\n\t}\n}\n//#endregion\n//#region src/utils/validate-contract-deps.ts\nconst IMPORT_PATTERN = /import\\s+type\\s+.*?\\s+from\\s+['\"](@[^/]+\\/[^/'\"]+)/g;\nfunction extractPackageSpecifiers(dtsContent) {\n\tconst packages = /* @__PURE__ */ new Set();\n\tfor (const match of dtsContent.matchAll(IMPORT_PATTERN)) {\n\t\tconst pkg = match[1];\n\t\tif (pkg) packages.add(pkg);\n\t}\n\treturn [...packages];\n}\nfunction validateContractDeps(dtsContent, projectRoot) {\n\tconst packages = extractPackageSpecifiers(dtsContent);\n\tconst resolve = createRequire(`${projectRoot}/package.json`);\n\tconst missing = [];\n\tfor (const pkg of packages) try {\n\t\tresolve.resolve(`${pkg}/package.json`);\n\t} catch {\n\t\tmissing.push(pkg);\n\t}\n\tif (missing.length === 0) return { missing };\n\treturn {\n\t\tmissing,\n\t\twarning: [\n\t\t\t\"contract.d.ts imports types from packages that are not installed:\",\n\t\t\tmissing.map((p) => ` - ${p}`).join(\"\\n\"),\n\t\t\t\"\",\n\t\t\t\"Install them with your package manager:\",\n\t\t\t...missing.map((p) => ` ${p}`)\n\t\t].join(\"\\n\")\n\t};\n}\n//#endregion\n//#region src/control-api/operations/contract-emit.ts\nvar contract_emit_exports = /* @__PURE__ */ __exportAll({ executeContractEmit: () => executeContractEmit });\nconst EMIT_ACTION = \"emit\";\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction startSpan(onProgress, spanId, label) {\n\tonProgress?.({\n\t\taction: EMIT_ACTION,\n\t\tkind: \"spanStart\",\n\t\tspanId,\n\t\tlabel\n\t});\n}\nfunction endSpan(onProgress, spanId, outcome) {\n\tonProgress?.({\n\t\taction: EMIT_ACTION,\n\t\tkind: \"spanEnd\",\n\t\tspanId,\n\t\toutcome\n\t});\n}\nfunction failedToResolveContractSource(why, fix, meta, cause) {\n\treturn errorRuntime(\"CONTRACT.SOURCE_LOAD_FAILED\", \"Failed to resolve contract source\", {\n\t\twhy,\n\t\tfix,\n\t\t...ifDefined(\"meta\", meta),\n\t\t...ifDefined(\"cause\", cause)\n\t});\n}\nfunction diagnosticLocationSuffix(diagnostic) {\n\tconst sourceId = typeof diagnostic[\"sourceId\"] === \"string\" ? diagnostic[\"sourceId\"] : void 0;\n\tconst span = isRecord(diagnostic[\"span\"]) ? diagnostic[\"span\"] : void 0;\n\tconst start = span && isRecord(span[\"start\"]) ? span[\"start\"] : void 0;\n\tconst line = start && typeof start[\"line\"] === \"number\" ? start[\"line\"] : void 0;\n\tconst column = start && typeof start[\"column\"] === \"number\" ? start[\"column\"] : void 0;\n\tif (sourceId && line !== void 0 && column !== void 0) return ` (${sourceId}:${line}:${column})`;\n\tif (sourceId) return ` (${sourceId})`;\n\treturn \"\";\n}\nfunction mapDiagnosticsToIssues(diagnostics) {\n\tconst issues = [];\n\tfor (const raw of diagnostics) {\n\t\tif (!isRecord(raw)) continue;\n\t\tconst code = typeof raw[\"code\"] === \"string\" ? raw[\"code\"] : \"diagnostic\";\n\t\tconst message = typeof raw[\"message\"] === \"string\" ? raw[\"message\"] : \"\";\n\t\tissues.push({\n\t\t\tkind: code,\n\t\t\tmessage: `${message}${diagnosticLocationSuffix(raw)}`\n\t\t});\n\t}\n\treturn issues;\n}\nfunction validateProviderResult(providerResult) {\n\tif (!isRecord(providerResult) || typeof providerResult[\"ok\"] !== \"boolean\") return {\n\t\tok: false,\n\t\terror: failedToResolveContractSource(\"Contract source provider returned malformed result shape.\", \"Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).\")\n\t};\n\tif (providerResult[\"ok\"]) {\n\t\tif (!(\"value\" in providerResult)) return {\n\t\t\tok: false,\n\t\t\terror: failedToResolveContractSource(\"Contract source provider returned malformed success result: missing value.\", \"Ensure contract.source.load success payload is ok(Contract).\")\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: providerResult[\"value\"]\n\t\t};\n\t}\n\tconst failure = providerResult[\"failure\"];\n\tif (!isRecord(failure) || typeof failure[\"summary\"] !== \"string\" || !Array.isArray(failure[\"diagnostics\"])) return {\n\t\tok: false,\n\t\terror: failedToResolveContractSource(\"Contract source provider returned malformed failure result: expected summary and diagnostics.\", \"Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).\")\n\t};\n\treturn {\n\t\tok: false,\n\t\terror: failedToResolveContractSource(String(failure[\"summary\"]), \"Fix contract source diagnostics and return ok(Contract).\", {\n\t\t\tdiagnostics: failure[\"diagnostics\"],\n\t\t\tissues: mapDiagnosticsToIssues(failure[\"diagnostics\"]),\n\t\t\t...ifDefined(\"providerMeta\", failure[\"meta\"])\n\t\t})\n\t};\n}\n/**\n* Canonical contract emit operation.\n*\n* This is the SINGLE publication path used by both the CLI command\n* (`prisma-next contract emit`) and the Vite plugin\n* (`@internal/vite-plugin-contract-emit`). New callers must go through this\n* function rather than re-implementing load → emit → publish.\n*\n* The whole flow (load config → resolve source → emit bytes → atomic publish)\n* is serialized per output JSON path via `queueEmitByOutput`. Concurrent calls\n* for the same output line up FIFO; the user-visible outcome is \"last\n* submission wins on disk\" without any supersession bookkeeping. Within a\n* single emit, `publishContractArtifactPair` stages temp files, renames\n* `contract.d.ts` before `contract.json`, and attempts to restore the previous\n* pair if either rename fails — so type-only consumers never observe a\n* mismatched pair.\n*\n* @throws {CliStructuredError} on config/source/validation problems\n* @throws {DOMException} `AbortError` if cancelled via `signal`\n*/\nasync function executeContractEmit(options) {\n\tconst { configPath, outputPath, signal = new AbortController().signal, onProgress } = options;\n\tconst unlessAborted = abortable(signal);\n\tconst configResult = await unlessAborted(loadConfigForSections(configPath, [\n\t\t\"contract\",\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"extensions\"\n\t]));\n\tif (!configResult.ok) throw configResult.failure;\n\tconst config = configResult.value;\n\tif (!config.contract) throw errorContractConfigMissing({ why: \"Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }\" });\n\tconst contractConfig = config.contract;\n\tconst effectiveOutput = outputPath !== void 0 ? join(outputPath, \"contract.json\") : contractConfig.output;\n\tif (!effectiveOutput) throw errorContractConfigMissing({ why: \"Contract config must have output path. This should not happen if defineConfig() was used.\" });\n\tif (typeof contractConfig.source?.load !== \"function\") throw errorContractConfigMissing({ why: \"Contract config must include a valid source provider object\" });\n\tlet outputPaths;\n\ttry {\n\t\toutputPaths = getEmittedArtifactPaths(effectiveOutput);\n\t} catch (error) {\n\t\tthrow errorContractConfigMissing({ why: error instanceof Error ? error.message : String(error) });\n\t}\n\tconst { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;\n\treturn queueEmitByOutput(outputJsonPath, async () => {\n\t\tconst stack = createControlStack(config);\n\t\tconst sourceContext = {\n\t\t\tcomposedExtensions: stack.extensions.map((p) => p.id),\n\t\t\tcomposedExtensionContracts: stack.extensionContracts,\n\t\t\tauthoringContributions: stack.authoringContributions,\n\t\t\tcodecLookup: stack.codecLookup,\n\t\t\tcontrolMutationDefaults: stack.controlMutationDefaults,\n\t\t\tresolvedInputs: contractConfig.source.inputs ?? [],\n\t\t\tcapabilities: stack.capabilities\n\t\t};\n\t\tstartSpan(onProgress, \"resolveSource\", \"Resolving contract source...\");\n\t\tlet providerResult;\n\t\ttry {\n\t\t\tproviderResult = await unlessAborted(contractConfig.source.load(sourceContext));\n\t\t} catch (error) {\n\t\t\tendSpan(onProgress, \"resolveSource\", \"error\");\n\t\t\tif (signal.aborted || isRecord(error) && error[\"name\"] === \"AbortError\") throw error;\n\t\t\tthrow failedToResolveContractSource(error instanceof Error ? error.message : String(error), \"Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.\", void 0, error);\n\t\t}\n\t\tconst validatedContract = validateProviderResult(providerResult);\n\t\tif (!validatedContract.ok) {\n\t\t\tendSpan(onProgress, \"resolveSource\", \"error\");\n\t\t\tthrow validatedContract.error;\n\t\t}\n\t\tendSpan(onProgress, \"resolveSource\", \"ok\");\n\t\tstartSpan(onProgress, \"emit\", \"Emitting contract...\");\n\t\tlet emitResult;\n\t\ttry {\n\t\t\tconst familyInstance = config.family.create(stack);\n\t\t\tconst rawComponents = [\n\t\t\t\tconfig.target,\n\t\t\t\tconfig.adapter,\n\t\t\t\t...config.extensions ?? []\n\t\t\t];\n\t\t\tconst frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);\n\t\t\tconst enrichedIR = enrichContract(validatedContract.value, frameworkComponents);\n\t\t\tconst rawContractJson = config.target.contractSerializer.serializeContract(enrichedIR);\n\t\t\tconst deserializedContract = familyInstance.deserializeContract(rawContractJson);\n\t\t\tconst { contractSerializer } = config.target;\n\t\t\tconst serializeContract = (c) => contractSerializer.serializeContract(c);\n\t\t\temitResult = await unlessAborted(emit(deserializedContract, stack, config.family.emission, {\n\t\t\t\toutputJsonPath,\n\t\t\t\tserializeContract,\n\t\t\t\tresolveImportSpecifier: createProjectSpecifierResolver(configPath),\n\t\t\t\t...ifDefined(\"shouldPreserveEmpty\", contractSerializer.shouldPreserveEmpty),\n\t\t\t\t...ifDefined(\"sortStorage\", contractSerializer.sortStorage)\n\t\t\t}));\n\t\t} catch (error) {\n\t\t\tendSpan(onProgress, \"emit\", \"error\");\n\t\t\tthrow error;\n\t\t}\n\t\tendSpan(onProgress, \"emit\", \"ok\");\n\t\tawait unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));\n\t\tawait publishContractArtifactPair({\n\t\t\toutputJsonPath,\n\t\t\toutputDtsPath,\n\t\t\tcontractJson: emitResult.contractJson,\n\t\t\tcontractDts: emitResult.contractDts,\n\t\t\tpublicationToken: String(process.hrtime.bigint())\n\t\t});\n\t\tconst validationWarning = validateContractDeps(emitResult.contractDts, dirname(outputDtsPath)).warning;\n\t\treturn {\n\t\t\tstorageHash: emitResult.storageHash,\n\t\t\t...ifDefined(\"executionHash\", emitResult.executionHash),\n\t\t\tprofileHash: emitResult.profileHash,\n\t\t\tfiles: {\n\t\t\t\tjson: outputJsonPath,\n\t\t\t\tdts: outputDtsPath\n\t\t\t},\n\t\t\t...ifDefined(\"validationWarning\", validationWarning)\n\t\t};\n\t});\n}\n//#endregion\nexport { executeContractEmit as n, disposeEmitQueue as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AC7H,MAAM,aAAa,eAAe,kBAAkB,OAAO,mBAAmB;GAC9E,MAAM,kBAAkB,OAAO,OAAO,mBAAmB,kBAAkB,UAAU;GACrF,MAAM,uBAAuB,eAAe,oBAAoB,eAAe;GAC/E,MAAM,EAAE,uBAAuB,OAAO;GACtC,MAAM,qBAAqB,MAAM,mBAAmB,kBAAkB,CAAC;GACvE,aAAa,MAAM,cAAc,KAAK,sBAAsB,OAAO,OAAO,OAAO,UAAU;IAC1F;IACA;IACA,wBAAwB,+BAA+B,UAAU;IACjE,GAAG,UAAU,uBAAuB,mBAAmB,mBAAmB;IAC1E,GAAG,UAAU,eAAe,mBAAmB,WAAW;GAC3D,CAAC,CAAC;EACH,SAAS,OAAO;GACf,QAAQ,YAAY,QAAQ,OAAO;GACnC,MAAM;EACP;EACA,QAAQ,YAAY,QAAQ,IAAI;EAChC,MAAM,cAAc,MAAM,QAAQ,cAAc,GAAG,EAAE,WAAW,KAAK,CAAC,CAAC;EACvE,MAAM,4BAA4B;GACjC;GACA;GACA,cAAc,WAAW;GACzB,aAAa,WAAW;GACxB,kBAAkB,OAAO,QAAQ,OAAO,OAAO,CAAC;EACjD,CAAC;EACD,MAAM,oBAAoB,qBAAqB,WAAW,aAAa,QAAQ,aAAa,CAAC,CAAC,CAAC;EAC/F,OAAO;GACN,aAAa,WAAW;GACxB,GAAG,UAAU,iBAAiB,WAAW,aAAa;GACtD,aAAa,WAAW;GACxB,OAAO;IACN,MAAM;IACN,KAAK;GACN;GACA,GAAG,UAAU,qBAAqB,iBAAiB;EACpD;CACD,CAAC;AACF"}
@@ -1,12 +1,12 @@
1
- import { et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
2
- import { t as inspectLiveSchema } from "./inspect-live-schema-Da76TWOs-CAFqkhGb.mjs";
1
+ import { et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
2
+ import { t as inspectLiveSchema } from "./inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs";
3
3
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
4
4
  import { dirname, relative, resolve } from "pathe";
5
5
  import { errorRuntime } from "@prisma/orm-framework/errors/execution";
6
6
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
7
7
  import { Command } from "commander";
8
8
  import { printPsl } from "@prisma/orm-framework/psl-printer";
9
- //#region ../../../1-framework/3-tooling/cli/dist/contract-infer-BwT7ngoo.mjs
9
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-infer-C_b7E71m.mjs
10
10
  /**
11
11
  * Resolves the output path for the inferred PSL contract.
12
12
  *
@@ -70,4 +70,4 @@ function createContractInferCommand() {
70
70
  //#endregion
71
71
  export { createContractInferCommand as t };
72
72
 
73
- //# sourceMappingURL=contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map
73
+ //# sourceMappingURL=contract-infer-C_b7E71m-D2UO-X-k.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-infer-BwT7ngoo-Dx6aAwIN.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-infer-BwT7ngoo.mjs"],"sourcesContent":["import { _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as inspectLiveSchema } from \"./inspect-live-schema-Da76TWOs.mjs\";\nimport { Command } from \"commander\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { dirname, relative, resolve } from \"pathe\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { printPsl } from \"@internal/psl-printer\";\n//#region src/commands/contract-infer-paths.ts\n/**\n* Resolves the output path for the inferred PSL contract.\n*\n* Priority:\n* 1. --output <path> flag (resolved relative to cwd)\n* 2. contract.prisma next to config.contract.output\n* 3. Canonical default: contract.prisma in the config directory\n*/\nfunction resolveContractInferOutputPath(options, contractOutput) {\n\tconst configDir = options.config ? dirname(resolve(process.cwd(), options.config)) : process.cwd();\n\tif (options.output) return resolve(process.cwd(), options.output);\n\tif (contractOutput) return resolve(dirname(resolve(configDir, contractOutput)), \"contract.prisma\");\n\treturn resolve(configDir, \"contract.prisma\");\n}\n//#endregion\n//#region src/commands/contract-infer.ts\nasync function executeContractInferCommand(options, flags, ui, startTime) {\n\tconst inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {\n\t\tcommandName: \"contract infer\",\n\t\tdescription: \"Infer a PSL contract from the live database schema\",\n\t\turl: \"https://pris.ly/contract-infer\"\n\t});\n\tif (!inspectResult.ok) return inspectResult;\n\tconst { config, target, meta, pslContractAst, pslBlockDescriptors } = inspectResult.value;\n\tif (!pslContractAst) return notOk(errorRuntime(\"CONTRACT.INFER_UNSUPPORTED\", \"contract infer is not supported for this family\", {\n\t\twhy: \"The configured family does not implement the PslContractInferCapable capability, so an inferred PSL contract cannot be produced from the live database schema.\",\n\t\tfix: \"Use a family that supports contract inference (e.g. SQL/Postgres).\"\n\t}));\n\tconst outputPath = resolveContractInferOutputPath(options, config.contract?.output);\n\tconst pslContent = printPsl(pslContractAst, { pslBlockDescriptors });\n\tif (existsSync(outputPath) && !flags.json && !flags.quiet) ui.stderr(`\\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);\n\tmkdirSync(dirname(outputPath), { recursive: true });\n\twriteFileSync(outputPath, pslContent, \"utf-8\");\n\tconst pslPath = relative(process.cwd(), outputPath);\n\tif (!flags.json && !flags.quiet) ui.stderr(`\\u2714 Contract written to ${pslPath}`);\n\treturn ok({\n\t\tok: true,\n\t\tsummary: \"Contract inferred successfully\",\n\t\ttarget,\n\t\tpsl: { path: pslPath },\n\t\tmeta,\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n}\nfunction createContractInferCommand() {\n\tconst command = new Command(\"infer\");\n\tsetCommandDescriptions(command, \"Infer a PSL contract from the live database schema\", \"Reads the live database schema and writes an inferred PSL contract to disk.\\nThis command stops at `contract.prisma`; follow it with `contract emit` and\\n`db sign` as separate steps.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next contract infer --db $DATABASE_URL\",\n\t\t\"prisma-next contract infer --db $DATABASE_URL --output ./src/prisma/contract.prisma\",\n\t\t\"prisma-next contract infer --db $DATABASE_URL --json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--output <path>\", \"Write the inferred PSL contract to the specified path\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeContractInferCommand(options, flags, ui, Date.now()), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value, null, 2));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createContractInferCommand as t };\n\n//# sourceMappingURL=contract-infer-BwT7ngoo.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,+BAA+B,SAAS,gBAAgB;CAChE,MAAM,YAAY,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,IAAI,GAAG,QAAQ,MAAM,CAAC,IAAI,QAAQ,IAAI;CACjG,IAAI,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,IAAI,GAAG,QAAQ,MAAM;CAChE,IAAI,gBAAgB,OAAO,QAAQ,QAAQ,QAAQ,WAAW,cAAc,CAAC,GAAG,iBAAiB;CACjG,OAAO,QAAQ,WAAW,iBAAiB;AAC5C;AAGA,eAAe,4BAA4B,SAAS,OAAO,IAAI,WAAW;CACzE,MAAM,gBAAgB,MAAM,kBAAkB,SAAS,OAAO,IAAI,WAAW;EAC5E,aAAa;EACb,aAAa;EACb,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AI,CAAC,GAAG,OAAO,KAAK,UAAU;GACtH,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;EACzD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"contract-infer-C_b7E71m-D2UO-X-k.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-infer-C_b7E71m.mjs"],"sourcesContent":["import { _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as inspectLiveSchema } from \"./inspect-live-schema-CXH4ZGHT.mjs\";\nimport { Command } from \"commander\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { dirname, relative, resolve } from \"pathe\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { printPsl } from \"@internal/psl-printer\";\n//#region src/commands/contract-infer-paths.ts\n/**\n* Resolves the output path for the inferred PSL contract.\n*\n* Priority:\n* 1. --output <path> flag (resolved relative to cwd)\n* 2. contract.prisma next to config.contract.output\n* 3. Canonical default: contract.prisma in the config directory\n*/\nfunction resolveContractInferOutputPath(options, contractOutput) {\n\tconst configDir = options.config ? dirname(resolve(process.cwd(), options.config)) : process.cwd();\n\tif (options.output) return resolve(process.cwd(), options.output);\n\tif (contractOutput) return resolve(dirname(resolve(configDir, contractOutput)), \"contract.prisma\");\n\treturn resolve(configDir, \"contract.prisma\");\n}\n//#endregion\n//#region src/commands/contract-infer.ts\nasync function executeContractInferCommand(options, flags, ui, startTime) {\n\tconst inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {\n\t\tcommandName: \"contract infer\",\n\t\tdescription: \"Infer a PSL contract from the live database schema\",\n\t\turl: \"https://pris.ly/contract-infer\"\n\t});\n\tif (!inspectResult.ok) return inspectResult;\n\tconst { config, target, meta, pslContractAst, pslBlockDescriptors } = inspectResult.value;\n\tif (!pslContractAst) return notOk(errorRuntime(\"CONTRACT.INFER_UNSUPPORTED\", \"contract infer is not supported for this family\", {\n\t\twhy: \"The configured family does not implement the PslContractInferCapable capability, so an inferred PSL contract cannot be produced from the live database schema.\",\n\t\tfix: \"Use a family that supports contract inference (e.g. SQL/Postgres).\"\n\t}));\n\tconst outputPath = resolveContractInferOutputPath(options, config.contract?.output);\n\tconst pslContent = printPsl(pslContractAst, { pslBlockDescriptors });\n\tif (existsSync(outputPath) && !flags.json && !flags.quiet) ui.stderr(`\\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);\n\tmkdirSync(dirname(outputPath), { recursive: true });\n\twriteFileSync(outputPath, pslContent, \"utf-8\");\n\tconst pslPath = relative(process.cwd(), outputPath);\n\tif (!flags.json && !flags.quiet) ui.stderr(`\\u2714 Contract written to ${pslPath}`);\n\treturn ok({\n\t\tok: true,\n\t\tsummary: \"Contract inferred successfully\",\n\t\ttarget,\n\t\tpsl: { path: pslPath },\n\t\tmeta,\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n}\nfunction createContractInferCommand() {\n\tconst command = new Command(\"infer\");\n\tsetCommandDescriptions(command, \"Infer a PSL contract from the live database schema\", \"Reads the live database schema and writes an inferred PSL contract to disk.\\nThis command stops at `contract.prisma`; follow it with `contract emit` and\\n`db sign` as separate steps.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next contract infer --db $DATABASE_URL\",\n\t\t\"prisma-next contract infer --db $DATABASE_URL --output ./src/prisma/contract.prisma\",\n\t\t\"prisma-next contract infer --db $DATABASE_URL --json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--output <path>\", \"Write the inferred PSL contract to the specified path\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeContractInferCommand(options, flags, ui, Date.now()), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value, null, 2));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createContractInferCommand as t };\n\n//# sourceMappingURL=contract-infer-C_b7E71m.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,+BAA+B,SAAS,gBAAgB;CAChE,MAAM,YAAY,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,IAAI,GAAG,QAAQ,MAAM,CAAC,IAAI,QAAQ,IAAI;CACjG,IAAI,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,IAAI,GAAG,QAAQ,MAAM;CAChE,IAAI,gBAAgB,OAAO,QAAQ,QAAQ,QAAQ,WAAW,cAAc,CAAC,GAAG,iBAAiB;CACjG,OAAO,QAAQ,WAAW,iBAAiB;AAC5C;AAGA,eAAe,4BAA4B,SAAS,OAAO,IAAI,WAAW;CACzE,MAAM,gBAAgB,MAAM,kBAAkB,SAAS,OAAO,IAAI,WAAW;EAC5E,aAAa;EACb,aAAa;EACb,KAAK;CACN,CAAC;CACD,IAAI,CAAC,cAAc,IAAI,OAAO;CAC9B,MAAM,EAAE,QAAQ,QAAQ,MAAM,gBAAgB,wBAAwB,cAAc;CACpF,IAAI,CAAC,gBAAgB,OAAO,MAAM,aAAa,8BAA8B,mDAAmD;EAC/H,KAAK;EACL,KAAK;CACN,CAAC,CAAC;CACF,MAAM,aAAa,+BAA+B,SAAS,OAAO,UAAU,MAAM;CAClF,MAAM,aAAa,SAAS,gBAAgB,EAAE,oBAAoB,CAAC;CACnE,IAAI,WAAW,UAAU,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO,GAAG,OAAO,qCAAqC,SAAS,QAAQ,IAAI,GAAG,UAAU,GAAG;CAC/I,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAClD,cAAc,YAAY,YAAY,OAAO;CAC7C,MAAM,UAAU,SAAS,QAAQ,IAAI,GAAG,UAAU;CAClD,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO,GAAG,OAAO,8BAA8B,SAAS;CAClF,OAAO,GAAG;EACT,IAAI;EACJ,SAAS;EACT;EACA,KAAK,EAAE,MAAM,QAAQ;EACrB;EACA,SAAS,EAAE,OAAO,KAAK,IAAI,IAAI,UAAU;CAC1C,CAAC;AACF;AACA,SAAS,6BAA6B;CACrC,MAAM,UAAU,IAAI,QAAQ,OAAO;CACnC,uBAAuB,SAAS,sDAAsD,wLAAwL;CAC9Q,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,mBAAmB,uDAAuD,CAAC,CAAC,OAAO,OAAO,YAAY;EACpP,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,4BAA4B,SAAS,OAAO,IAAI,KAAK,IAAI,CAAC,GAAG,OAAO,KAAK,UAAU;GACtH,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;EACzD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,7 +1,7 @@
1
1
  import { i as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-Co-8oaiB-CB-6Uqki.mjs";
2
2
  import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs";
3
- import { N as errorUnexpected, O as errorRuntime$1, Z as mapRefResolutionError, h as errorFileNotFound, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
4
- import { r as buildReadAggregate } from "./contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs";
3
+ import { N as errorUnexpected, O as errorRuntime$1, Z as mapRefResolutionError, h as errorFileNotFound, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
4
+ import { r as buildReadAggregate } from "./contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs";
5
5
  import { n as parseContractRef } from "./ref-resolution-Ct2GMcNB.mjs";
6
6
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
7
7
  import { join } from "pathe";
@@ -79,4 +79,4 @@ async function resolveContractRefToSnapshot(options) {
79
79
  //#endregion
80
80
  export { resolveContractRefToSnapshot as t };
81
81
 
82
- //# sourceMappingURL=contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map
82
+ //# sourceMappingURL=contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-SATuw0JW.mjs"],"sourcesContent":["import { F as CliStructuredError, W as errorFileNotFound, ct as errorUnexpected, lt as mapRefResolutionError, rt as errorRuntime } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { r as buildReadAggregate } from \"./contract-space-aggregate-loader-C5r12INu.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { MigrationToolsError, errorContractDeserializationFailed } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/control-api/operations/contract-snapshot-resolution.ts\n/**\n* Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.\n*/\nfunction isEnoent(error) {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\nasync function resolveContractRefToSnapshot(options) {\n\ttry {\n\t\tconst loaded = await buildReadAggregate(options.config, { migrationsDir: options.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\tconst refResult = parseContractRef(options.refInput, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tconst targetHash = refResult.value.hash;\n\t\tif (bundles.find((p) => p.metadata.to === targetHash)) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash)),\n\t\t\tcontractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), \"contract.json\"),\n\t\t\tsource: \"snapshot\"\n\t\t});\n\t\tif (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.missingBundleFlag} \"${options.refInput}\" (resolved hash: ${targetHash})`, {\n\t\t\twhy: `The ref resolved successfully but no on-disk migration package has a destination (\\`to\\`) hash matching ${targetHash}.`,\n\t\t\tfix: \"Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations.\"\n\t\t}));\n\t\tlet defaultRaw;\n\t\ttry {\n\t\t\tdefaultRaw = await readFile(options.contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (isEnoent(error)) return notOk(errorFileNotFound(options.contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${options.contractPathAbsolute}`,\n\t\t\t\tfix: \"Run `prisma-next contract emit` first to generate the contract\",\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), {\n\t\t\t\twhy: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = castAs(JSON.parse(defaultRaw));\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractDeserializationFailed(options.contractPathAbsolute, error instanceof Error ? error.message : String(error), { cause: error }));\n\t\t}\n\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return notOk(errorContractDeserializationFailed(options.contractPathAbsolute, `expected a JSON object, got ${parsed === null ? \"null\" : Array.isArray(parsed) ? \"an array\" : `a ${typeof parsed}`}`));\n\t\tconst defaultContract = blindCast(parsed);\n\t\tconst storage = defaultContract[\"storage\"];\n\t\tif ((storage !== null && typeof storage === \"object\" ? blindCast(storage)[\"storageHash\"] : void 0) === targetHash) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: defaultContract,\n\t\t\tcontractJsonPath: options.contractPathAbsolute,\n\t\t\tsource: \"emitted\"\n\t\t});\n\t\treturn notOk(errorRuntime(\"MIGRATION.SNAPSHOT_MISSING\", `No contract file found for hash \"${targetHash}\"`, {\n\t\t\twhy: `Resolved contract reference \"${options.refInput}\" to hash \"${targetHash}\" but no migration produces that hash and the emitted contract does not match.`,\n\t\t\tfix: \"Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json.\"\n\t\t}));\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { resolveContractRefToSnapshot as t };\n\n//# sourceMappingURL=contract-snapshot-resolution-SATuw0JW.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,SAAS,OAAO;CACxB,OAAO,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS;AACpE;AACA,eAAe,6BAA6B,SAAS;CACpD,IAAI;EACH,MAAM,SAAS,MAAM,mBAAmB,QAAQ,QAAQ,EAAE,eAAe,QAAQ,cAAc,CAAC;EAChG,IAAI,CAAC,OAAO,IAAI,OAAO,MAAM,OAAO,OAAO;EAC3C,M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AAK,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC;EACxJ;EACA,IAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,+BAA+B,WAAW,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI,aAAa,KAAK,OAAO,UAAU,CAAC;EAChR,MAAM,kBAAkB,UAAU,MAAM;EACxC,MAAM,UAAU,gBAAgB;EAChC,KAAK,YAAY,QAAQ,OAAO,YAAY,WAAW,UAAU,OAAO,CAAC,CAAC,iBAAiB,KAAK,OAAO,YAAY,OAAO,GAAG;GAC5H,MAAM;GACN,cAAc;GACd,kBAAkB,QAAQ;GAC1B,QAAQ;EACT,CAAC;EACD,OAAO,MAAMA,eAAa,8BAA8B,oCAAoC,WAAW,IAAI;GAC1G,KAAK,gCAAgC,QAAQ,SAAS,aAAa,WAAW;GAC9E,KAAK;EACN,CAAC,CAAC;CACH,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,IAAIC,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
1
+ {"version":3,"file":"contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-snapshot-resolution-SATuw0JW.mjs"],"sourcesContent":["import { F as CliStructuredError, W as errorFileNotFound, ct as errorUnexpected, lt as mapRefResolutionError, rt as errorRuntime } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { r as buildReadAggregate } from \"./contract-space-aggregate-loader-C5r12INu.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { MigrationToolsError, errorContractDeserializationFailed } from \"@internal/migration-tools/errors\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/control-api/operations/contract-snapshot-resolution.ts\n/**\n* Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.\n*/\nfunction isEnoent(error) {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\nasync function resolveContractRefToSnapshot(options) {\n\ttry {\n\t\tconst loaded = await buildReadAggregate(options.config, { migrationsDir: options.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\tconst refResult = parseContractRef(options.refInput, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tconst targetHash = refResult.value.hash;\n\t\tif (bundles.find((p) => p.metadata.to === targetHash)) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash)),\n\t\t\tcontractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), \"contract.json\"),\n\t\t\tsource: \"snapshot\"\n\t\t});\n\t\tif (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.missingBundleFlag} \"${options.refInput}\" (resolved hash: ${targetHash})`, {\n\t\t\twhy: `The ref resolved successfully but no on-disk migration package has a destination (\\`to\\`) hash matching ${targetHash}.`,\n\t\t\tfix: \"Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations.\"\n\t\t}));\n\t\tlet defaultRaw;\n\t\ttry {\n\t\t\tdefaultRaw = await readFile(options.contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (isEnoent(error)) return notOk(errorFileNotFound(options.contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${options.contractPathAbsolute}`,\n\t\t\t\tfix: \"Run `prisma-next contract emit` first to generate the contract\",\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), {\n\t\t\t\twhy: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tcause: error\n\t\t\t}));\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = castAs(JSON.parse(defaultRaw));\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractDeserializationFailed(options.contractPathAbsolute, error instanceof Error ? error.message : String(error), { cause: error }));\n\t\t}\n\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return notOk(errorContractDeserializationFailed(options.contractPathAbsolute, `expected a JSON object, got ${parsed === null ? \"null\" : Array.isArray(parsed) ? \"an array\" : `a ${typeof parsed}`}`));\n\t\tconst defaultContract = blindCast(parsed);\n\t\tconst storage = defaultContract[\"storage\"];\n\t\tif ((storage !== null && typeof storage === \"object\" ? blindCast(storage)[\"storageHash\"] : void 0) === targetHash) return ok({\n\t\t\thash: targetHash,\n\t\t\tcontractJson: defaultContract,\n\t\t\tcontractJsonPath: options.contractPathAbsolute,\n\t\t\tsource: \"emitted\"\n\t\t});\n\t\treturn notOk(errorRuntime(\"MIGRATION.SNAPSHOT_MISSING\", `No contract file found for hash \"${targetHash}\"`, {\n\t\t\twhy: `Resolved contract reference \"${options.refInput}\" to hash \"${targetHash}\" but no migration produces that hash and the emitted contract does not match.`,\n\t\t\tfix: \"Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json.\"\n\t\t}));\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { resolveContractRefToSnapshot as t };\n\n//# sourceMappingURL=contract-snapshot-resolution-SATuw0JW.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,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ACpF,KAAK,iCAAiC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC3F,OAAO;GACR,CAAC,CAAC;EACH;EACA,IAAI;EACJ,IAAI;GACH,SAAS,OAAO,KAAK,MAAM,UAAU,CAAC;EACvC,SAAS,OAAO;GACf,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC;EACxJ;EACA,IAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG,OAAO,MAAM,mCAAmC,QAAQ,sBAAsB,+BAA+B,WAAW,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI,aAAa,KAAK,OAAO,UAAU,CAAC;EAChR,MAAM,kBAAkB,UAAU,MAAM;EACxC,MAAM,UAAU,gBAAgB;EAChC,KAAK,YAAY,QAAQ,OAAO,YAAY,WAAW,UAAU,OAAO,CAAC,CAAC,iBAAiB,KAAK,OAAO,YAAY,OAAO,GAAG;GAC5H,MAAM;GACN,cAAc;GACd,kBAAkB,QAAQ;GAC1B,QAAQ;EACT,CAAC;EACD,OAAO,MAAMA,eAAa,8BAA8B,oCAAoC,WAAW,IAAI;GAC1G,KAAK,gCAAgC,QAAQ,SAAS,aAAa,WAAW;GAC9E,KAAK;EACN,CAAC,CAAC;CACH,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,IAAIC,qBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { t as MigrationToolsError } from "./errors-Co-8oaiB-CB-6Uqki.mjs";
2
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
3
- import { N as errorUnexpected, rt as resolveContractPath, t as CliStructuredError$1, tt as readContractEnvelope } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
3
+ import { N as errorUnexpected, rt as resolveContractPath, t as CliStructuredError$1, tt as readContractEnvelope } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
4
4
  import { s as loadContractSpaceAggregate } from "./aggregate-D53gnb7v.mjs";
5
5
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
6
6
  import { readFile } from "node:fs/promises";
@@ -299,4 +299,4 @@ async function buildReadAggregate(config, options) {
299
299
  //#endregion
300
300
  export { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };
301
301
 
302
- //# sourceMappingURL=contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map
302
+ //# sourceMappingURL=contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-C5r12INu.mjs"],"sourcesContent":["import { F as CliStructuredError, a as readContractEnvelope, ct as errorUnexpected, o as resolveContractPath } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-C5r12INu.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,kBAAkB,YAAY;CACtC,OAAO,WAAW,KAAK,QAAQ;EAC9B,MAAM,OAAO;EACb,IAAI,KAAK,kBAAkB,KAAK,GAAG,OAAO;GACzC,IAAI,KAAK;GACT,UAAU,KAAK;EAChB;EACA,OAAO;GACN,IAAI,KAAK;GACT,UAAU,KAAK;GACf,eAAe;IACd,cAAc,KAAK,cAAc;IACjC,SAAS,KAAK,cAAc;IAC5B,YAAY,KAAK,cAAc,cAAc,CAAC;GAC/C;EACD;CACD,CAAC;AACF;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,4BAA4B,YAAY;CAChD,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,OAAO,YAAY;EAC7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC7C,MAAM,aAAa,OAAO,yBAAyB,KAAK,eAAe;EACvE,IAAI,eAAe,KAAK,GAAG;EAC3B,IAAI,WAAW,cAAc,WAAW,UAAU,KAAK,GAAG;EAC1D,MAAM,OAAO;EACb,QAAQ,KAAK;GACZ,IAAI,KAAK;GACT,UAAU,KAAK;EAChB,CAAC;CACF;CACA,OAAO;AACR;AAGA,MAAM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AAsB,QAAQ;CAC5C,IAAI;EACH,MAAM,MAAM,MAAM,SAAS,oBAAoB,MAAM,GAAG,OAAO;EAC/D,OAAO,KAAK,MAAM,GAAG;CACtB,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;;;AASA,eAAe,mBAAmB,QAAQ,SAAS;CAClD,IAAI,eAAe;CACnB,IAAI;EACH,gBAAgB,MAAM,qBAAqB,MAAM,EAAA,CAAG;CACrD,QAAQ,CAAC;CACT,IAAI;EACH,MAAM,0BAA0B,MAAM,sBAAsB,MAAM;EAClE,MAAM,QAAQ,mBAAmB,MAAM;EACvC,MAAM,iBAAiB,OAAO,OAAO,OAAO,KAAK;EACjD,MAAM,uBAAuB,SAAS,eAAe,oBAAoB,IAAI;EAC7E,IAAI,qBAAqB,+BAA+B;GACvD;GACA,UAAU,OAAO,OAAO;GACxB,cAAc,OAAO,OAAO;EAC7B,CAAC;EACD,IAAI,4BAA4B,MAAM,IAAI;GACzC,qBAAqB,oBAAoB,uBAAuB;EACjE,QAAQ,CAAC;EACT,MAAM,SAAS,MAAM,iCAAiC;GACrD,UAAU,OAAO,OAAO;GACxB,eAAe,QAAQ;GACvB,aAAa;GACb,YAAY,OAAO,cAAc,CAAC;GAClC;EACD,CAAC;EACD,IAAI,CAAC,OAAO,IAAI,OAAO;EACvB,OAAO,GAAG;GACT,WAAW,OAAO;GAClB;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
1
+ {"version":3,"file":"contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-C5r12INu.mjs"],"sourcesContent":["import { F as CliStructuredError, a as readContractEnvelope, ct as errorUnexpected, o as resolveContractPath } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\n//#region src/utils/extension-pack-inputs.ts\n/**\n* Project the CLI's `Config.extensions` array into the canonical\n* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n* structural cast in the CLI lives inside this function.\n*/\nfunction toExtensionInputs(extensions) {\n\treturn extensions.map((raw) => {\n\t\tconst pack = raw;\n\t\tif (pack.contractSpace === void 0) return {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t};\n\t\treturn {\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId,\n\t\t\tcontractSpace: {\n\t\t\t\tcontractJson: pack.contractSpace.contractJson,\n\t\t\t\theadRef: pack.contractSpace.headRef,\n\t\t\t\tmigrations: pack.contractSpace.migrations ?? []\n\t\t\t}\n\t\t};\n\t});\n}\n/**\n* Minimal aggregate-loader projection that extracts `id` + `targetId`\n* from raw extension pack descriptors **without invoking any\n* `contractSpace` accessor**. Inspects the own-property descriptor so\n* that getter-backed `contractSpace` declarations are detected but\n* never called.\n*\n* Inclusion semantics match {@link toDeclaredExtensions}: a data\n* property whose value is explicitly `undefined` is treated as \"no\n* contract-space declaration\" and skipped, mirroring the\n* `pack.contractSpace === undefined` check used on canonicalised\n* inputs. Prototype-chain `contractSpace` properties (no own\n* descriptor) are also skipped.\n*\n* This variant must be used by `buildContractSpaceAggregate` so that\n* the aggregate path (including `db verify`) never reads\n* `contractSpace.contractJson` from extension descriptors — the loader\n* always reads the contract from on-disk artefacts instead.\n*/\nfunction toDeclaredExtensionsFromRaw(extensions) {\n\tconst entries = [];\n\tfor (const raw of extensions) {\n\t\tif (typeof raw !== \"object\" || raw === null) continue;\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(raw, \"contractSpace\");\n\t\tif (descriptor === void 0) continue;\n\t\tif (\"value\" in descriptor && descriptor.value === void 0) continue;\n\t\tconst pack = raw;\n\t\tentries.push({\n\t\t\tid: pack.id,\n\t\t\ttargetId: pack.targetId\n\t\t});\n\t}\n\treturn entries;\n}\n//#endregion\n//#region src/control-api/operations/contract-space-aggregate-loader.ts\nconst CONTRACT_SPACES_DOCS_URL = \"https://pris.ly/contract-spaces\";\nfunction contractSpaceViolationError(summary, options) {\n\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", summary, {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\tmeta: { violations: options.violations }\n\t});\n}\n/**\n* Build the `MIGRATION.CONTRACT_SPACE_VIOLATION` structured-error envelope for a contract-space\n* target mismatch. Shared between the declared-extension precheck (the\n* descriptor's configured target disagrees with the project target) and\n* the on-disk-contract check surfaced by `checkIntegrity`.\n*/\nfunction targetMismatchError(spaceId, expected, actual) {\n\treturn contractSpaceViolationError(`Contract-space target mismatch for \"${spaceId}\"`, {\n\t\twhy: `Space \"${spaceId}\" targets \"${actual}\" but the project's adapter targets \"${expected}\".`,\n\t\tfix: \"Update the extension descriptor to target the configured database, or change the project adapter.\",\n\t\tviolations: [{\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId,\n\t\t\texpected,\n\t\t\tactual\n\t\t}]\n\t});\n}\n/**\n* Human-readable detail for an integrity violation, used as the `why`\n* of the `integrityFailure` envelope. Mirrors the messages the prior\n* throw-on-load loader produced so downstream consumers see the same\n* text for the same on-disk state.\n*/\nfunction describeIntegrityViolation(violation) {\n\tswitch (violation.kind) {\n\t\tcase \"hashMismatch\": return `Migration \"${violation.dirName}\" stored hash \"${violation.stored}\" does not match computed hash \"${violation.computed}\".`;\n\t\tcase \"providedInvariantsMismatch\": return `Migration \"${violation.dirName}\" providedInvariants in migration.json disagrees with ops.json.`;\n\t\tcase \"packageUnloadable\": return `Migration \"${violation.dirName}\" could not be loaded: ${violation.detail}`;\n\t\tcase \"sameSourceAndTarget\": return `Migration \"${violation.dirName}\" has source equal to target (${violation.hash}) with no data invariant — a true no-op self-edge.`;\n\t\tcase \"headRefMissing\": return `Head ref \\`refs/head.json\\` is missing for contract space \"${violation.spaceId}\".`;\n\t\tcase \"headRefNotInGraph\": return `Head ref ${violation.hash} for contract space \"${violation.spaceId}\" is not present in the migration graph.`;\n\t\tcase \"refUnreadable\": return `Ref \"${violation.refName}\" for contract space \"${violation.spaceId}\" is unreadable: ${violation.detail}`;\n\t\tcase \"duplicateMigrationHash\": return `Multiple migrations in space \"${violation.spaceId}\" share migrationHash \"${violation.migrationHash}\" (${violation.dirNames.join(\", \")}).`;\n\t\tdefault: {\n\t\t\tconst spaceId = \"spaceId\" in violation ? violation.spaceId : \"*\";\n\t\t\treturn `Integrity violation \"${violation.kind}\" for contract space \"${spaceId}\".`;\n\t\t}\n\t}\n}\n/**\n* Map the integrity violations `checkIntegrity` reports into a single\n* CLI structured-error envelope, preserving the error codes the prior\n* throw-on-load loader emitted: `MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION`\n* (layout drift, bundled) and `MIGRATION.CONTRACT_SPACE_VIOLATION` (target /\n* disjointness / contract-validation / structural integrity). Returns\n* `null` when there is nothing to refuse on.\n*\n* Precedence reproduces the prior loader's first-failure ordering:\n* layout drift first (every offence bundled into one envelope), then\n* target mismatch, then disjointness, then a contract-validation\n* failure, then any remaining structural integrity violation.\n*/\nfunction mapIntegrityViolations(violations) {\n\tif (violations.length === 0) return null;\n\tconst layout = violations.filter((v) => v.kind === \"orphanSpaceDir\" || v.kind === \"declaredButUnmigrated\");\n\tif (layout.length > 0) {\n\t\tconst lines = layout.map((v) => `- [${v.kind}] ${v.spaceId}`);\n\t\treturn new CliStructuredError(\"MIGRATION.CONTRACT_SPACE_LAYOUT_VIOLATION\", layout.length === 1 ? \"Contract-space layout violation detected\" : `Contract-space layout violations detected (${layout.length})`, {\n\t\t\twhy: `The on-disk \\`migrations/\\` directory and your \\`extensions\\` declaration are not in agreement.\\n${lines.join(\"\\n\")}`,\n\t\t\tfix: \"Declare the extension in `extensions` and re-emit its contract-space artefacts, or remove the orphan `migrations/<space>` directory.\",\n\t\t\tdocsUrl: CONTRACT_SPACES_DOCS_URL,\n\t\t\tmeta: { violations: layout }\n\t\t});\n\t}\n\tconst targetMismatch = violations.find((v) => v.kind === \"targetMismatch\");\n\tif (targetMismatch && targetMismatch.kind === \"targetMismatch\") return targetMismatchError(targetMismatch.spaceId, targetMismatch.expected, targetMismatch.actual);\n\tconst disjointness = violations.find((v) => v.kind === \"disjointness\");\n\tif (disjointness && disjointness.kind === \"disjointness\") return contractSpaceViolationError(`Contract-space disjointness violation: storage element \"${disjointness.element}\" claimed by multiple spaces`, {\n\t\twhy: `Spaces ${disjointness.claimedBy.map((s) => `\"${s}\"`).join(\", \")} all claim the storage element \"${disjointness.element}\". Each storage element must be owned by exactly one contract space.`,\n\t\tfix: \"Update the conflicting contracts so each storage element is claimed by exactly one space.\",\n\t\tviolations: [disjointness]\n\t});\n\tconst contractUnreadable = violations.find((v) => v.kind === \"contractUnreadable\");\n\tif (contractUnreadable && contractUnreadable.kind === \"contractUnreadable\") return contractSpaceViolationError(`Contract-space contract validation failed for \"${contractUnreadable.spaceId}\"`, {\n\t\twhy: contractUnreadable.detail,\n\t\tfix: \"Re-emit the extension contract with `prisma-next contract emit`, or fix the extension pack descriptor producing the invalid contract.\",\n\t\tviolations: [contractUnreadable]\n\t});\n\tconst structural = violations[0];\n\treturn contractSpaceViolationError(`Contract-space integrity failure for \"${\"spaceId\" in structural ? structural.spaceId : \"*\"}\"`, {\n\t\twhy: describeIntegrityViolation(structural),\n\t\tfix: \"Re-emit the affected migration package(s) or restore the on-disk `migrations/` directory from version control.\",\n\t\tviolations: [structural]\n\t});\n}\nfunction declaredExtensionsFromInputs(extensions) {\n\treturn toDeclaredExtensionsFromRaw(extensions);\n}\n/**\n* Reject extension descriptors whose configured target disagrees with\n* the project target before any on-disk read.\n*/\nfunction refuseDeclaredExtensionTargetMismatch(inputs) {\n\tfor (const declared of declaredExtensionsFromInputs(inputs.extensions)) if (declared.targetId !== inputs.targetId) return targetMismatchError(declared.id, inputs.targetId, declared.targetId);\n\treturn null;\n}\n/**\n* Load the tolerant {@link ContractSpaceAggregate} once at the CLI\n* surface. Construction never throws on disk content; callers query\n* {@link ContractSpaceAggregate.app} / extension facets instead of\n* re-reading `migrations/`.\n*/\nasync function loadContractSpaceAggregateForCli(inputs) {\n\tconst targetFailure = refuseDeclaredExtensionTargetMismatch(inputs);\n\tif (targetFailure) return notOk(targetFailure);\n\treturn ok(await loadContractSpaceAggregate({\n\t\tmigrationsDir: inputs.migrationsDir,\n\t\tdeserializeContract: inputs.deserializeContract,\n\t\tappContract: inputs.appContract\n\t}));\n}\n/**\n* Run `checkIntegrity` on a loaded aggregate and map violations into\n* the contract-space refusal envelope, or return `null` when the model\n* is acceptable for the requested check scope.\n*/\nfunction refuseContractSpaceIntegrity(aggregate, options) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity(options));\n}\nconst PACKAGE_CORRUPTION_KINDS = /* @__PURE__ */ new Set([\n\t\"hashMismatch\",\n\t\"providedInvariantsMismatch\",\n\t\"packageUnloadable\"\n]);\n/**\n* Reader-subset integrity refusal for `migration status`: package\n* corruptions only (`hashMismatch`, `providedInvariantsMismatch`,\n* `packageUnloadable`).\n*/\nfunction refusePackageCorruptionOnAggregate(aggregate) {\n\treturn mapIntegrityViolations(aggregate.checkIntegrity().filter((v) => PACKAGE_CORRUPTION_KINDS.has(v.kind)));\n}\n/**\n* Construct the tolerant {@link ContractSpaceAggregate} at the CLI\n* surface and apply the explicit integrity refusal.\n*\n* App-space migration packages are read from `migrations/<app>/` by the\n* loader itself; callers no longer thread them through.\n*/\nasync function buildContractSpaceAggregate(inputs) {\n\tconst declaredExtensions = declaredExtensionsFromInputs(inputs.extensions);\n\tconst loaded = await loadContractSpaceAggregateForCli(inputs);\n\tif (!loaded.ok) return loaded;\n\tconst failure = refuseContractSpaceIntegrity(loaded.value, {\n\t\tdeclaredExtensions,\n\t\tcheckContracts: true\n\t});\n\tif (failure) return notOk(failure);\n\treturn ok(loaded.value);\n}\n/**\n* Build a minimal app {@link Contract} carrying only the project's\n* contract-identity (`storage.storageHash` + `target` / `targetFamily`)\n* when the real `contract.json` is absent or undeserializable.\n*\n* `loadContractSpaceAggregate` requires an `appContract` to synthesise the\n* app space's head ref from its storage hash. Read commands query only that\n* hash and the target — never `models` — so an empty-`models` stand-in is\n* sufficient for them. It is *not* a valid contract for any consumer that\n* reads schema, which is why this is confined to the read-aggregate path.\n*/\nfunction appContractStandInFromIdentity(args) {\n\treturn blindCast({\n\t\tstorage: { storageHash: args.contractHash },\n\t\tschemaVersion: \"0.0.0\",\n\t\ttarget: args.targetId,\n\t\ttargetFamily: args.targetFamily,\n\t\tmodels: {},\n\t\tprofileHash: EMPTY_CONTRACT_HASH\n\t});\n}\nasync function loadContractRawSafely(config) {\n\ttry {\n\t\tconst raw = await readFile(resolveContractPath(config), \"utf-8\");\n\t\treturn JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Tolerant {@link ContractSpaceAggregate} assembly for read-only CLI\n* commands. No integrity gate — callers query `aggregate.app` (or other\n* facets) without re-reading `migrations/`. When `contract.json` is absent\n* or undeserializable, the app contract falls back to an identity-only\n* stand-in ({@link appContractStandInFromIdentity}), so these commands\n* load without requiring a readable contract.\n*/\nasync function buildReadAggregate(config, options) {\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch {}\n\ttry {\n\t\tconst contractRawForAggregate = await loadContractRawSafely(config);\n\t\tconst stack = createControlStack(config);\n\t\tconst familyInstance = config.family.create(stack);\n\t\tconst deserializeContract = (json) => familyInstance.deserializeContract(json);\n\t\tlet appContractForLoad = appContractStandInFromIdentity({\n\t\t\tcontractHash,\n\t\t\ttargetId: config.target.id,\n\t\t\ttargetFamily: config.target.familyId\n\t\t});\n\t\tif (contractRawForAggregate !== null) try {\n\t\t\tappContractForLoad = deserializeContract(contractRawForAggregate);\n\t\t} catch {}\n\t\tconst loaded = await loadContractSpaceAggregateForCli({\n\t\t\ttargetId: config.target.id,\n\t\t\tmigrationsDir: options.migrationsDir,\n\t\t\tappContract: appContractForLoad,\n\t\t\textensions: config.extensions ?? [],\n\t\t\tdeserializeContract\n\t\t});\n\t\tif (!loaded.ok) return loaded;\n\t\treturn ok({\n\t\t\taggregate: loaded.value,\n\t\t\tcontractHash\n\t\t});\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n}\n//#endregion\nexport { loadContractSpaceAggregateForCli as a, refuseDeclaredExtensionTargetMismatch as c, toExtensionInputs as d, loadContractRawSafely as i, refusePackageCorruptionOnAggregate as l, buildContractSpaceAggregate as n, mapIntegrityViolations as o, buildReadAggregate as r, refuseContractSpaceIntegrity as s, appContractStandInFromIdentity as t, toDeclaredExtensionsFromRaw as u };\n\n//# sourceMappingURL=contract-space-aggregate-loader-C5r12INu.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,kBAAkB,YAAY;CACtC,OAAO,WAAW,KAAK,QAAQ;EAC9B,MAAM,OAAO;EACb,IAAI,KAAK,kBAAkB,KAAK,GAAG,OAAO;GACzC,IAAI,KAAK;GACT,UAAU,KAAK;EAChB;EACA,OAAO;GACN,IAAI,KAAK;GACT,UAAU,KAAK;GACf,eAAe;IACd,cAAc,KAAK,cAAc;IACjC,SAAS,KAAK,cAAc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IAAI,CAAC,OAAO,IAAI,OAAO;EACvB,OAAO,GAAG;GACT,WAAW,OAAO;GAClB;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACrD,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
@@ -1,6 +1,6 @@
1
- import { B as formatMigrationJson, D as errorRunnerFailed, N as errorUnexpected, O as errorRuntime$1, V as formatMigrationPlanOutput, at as sanitizeErrorMessage, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, st as setCommandExamples, t as CliStructuredError$1, x as errorMigrationPlanningFailed, z as formatMigrationApplyOutput } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
1
+ import { B as formatMigrationJson, D as errorRunnerFailed, N as errorUnexpected, O as errorRuntime$1, V as formatMigrationPlanOutput, at as sanitizeErrorMessage, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, st as setCommandExamples, t as CliStructuredError$1, x as errorMigrationPlanningFailed, z as formatMigrationApplyOutput } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
2
2
  import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-BZQtedYC.mjs";
3
- import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs";
3
+ import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs";
4
4
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
5
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
6
6
  import { assertNever } from "@prisma/orm-framework/utils/internal-error";
@@ -136,4 +136,4 @@ function createDbInitCommand() {
136
136
  //#endregion
137
137
  export { createDbInitCommand as t };
138
138
 
139
- //# sourceMappingURL=db-init-CBj_EWg3.mjs.map
139
+ //# sourceMappingURL=db-init-Cqjw5Flp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-init-CBj_EWg3.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-init.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, C as formatMigrationApplyOutput, F as CliStructuredError, T as formatMigrationPlanOutput, X as errorMigrationPlanningFailed, _ as createTerminalUI, c as sanitizeErrorMessage, ct as errorUnexpected, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, nt as errorRunnerFailed, rt as errorRuntime, s as resolveMigrationPaths, u as setCommandExamples, w as formatMigrationJson, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { o as resolveRefAdvancementFields } from \"../ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"../migration-command-scaffold-BPqXPCFV.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Maps a DbInitFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") {\n\t\tconst mismatchParts = [];\n\t\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) mismatchParts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\t\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) mismatchParts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\t\treturn errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(\" and \")}.` : \"\"}`, {\n\t\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t\t}\n\t\t});\n\t}\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst 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.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand };\n\n//# sourceMappingURL=db-init.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,iBAAiB,SAAS;CAClC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,oCAAoC;EACxD,MAAM,gBAAgB,CAAC;EACvB,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,cAAc,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;EAClQ,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,cAAc,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;EAClQ,OAAOA,eAAa,oCAAoC,+DAA+D,cAAc,SAAS,IAAI,gBAAgB,cAAc,KAAK,OAAO,EAAE,KAAK,MAAM;GACxM,KAAK;GACL,KAAK;GACL,MAAM;IACL,GAAG,UAAU,qBAAqB,QAAQ,QAAQ,WAAW;IAC7D,GAAG,UAAU,0BAA0B,QAAQ,aAAa,WAAW;IACvE,GAAG,UAAU,qBAAqB,QAAQ,QAAQ,WAAW;IAC7D,GAAG,UAAU,0BAA0B,QAAQ,aAAa,WAAW;GACxE;EACD,CAAC;CACF;CACA,IAAI,QAAQ,SAAS,iBAAiB;EACrC,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OAAO,MAAM;CACpB;AACD;AACA,SAAS,sBAAsB;CAC9B,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,uBAAuB,SAAS,kEAAkE,qYAAqY;CACve,mBAAmB,SAAS,CAAC,0CAA0C,kDAAkD,CAAC;CAC1H,2BAA2B,OAAO;CAClC,QAAQ,OAAO,wBAAwB,kDAAkD;CACzF,QAAQ,OAAO,OAAO,YAAY;EACjC,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,YAAY,KAAK,IAAI;EAC3B,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,qBAAqB,SAAS,OAAO,IAAI,SAAS,GAAG,OAAO,KAAK,iBAAiB;GACrH,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,YAAY,CAAC;QACtD;IACJ,MAAM,SAAS,aAAa,SAAS,SAAS,0BAA0B,cAAc,KAAK,IAAI,2BAA2B,cAAc,KAAK;IAC7I,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"db-init-Cqjw5Flp.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-init.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, C as formatMigrationApplyOutput, F as CliStructuredError, T as formatMigrationPlanOutput, X as errorMigrationPlanningFailed, _ as createTerminalUI, c as sanitizeErrorMessage, ct as errorUnexpected, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, nt as errorRunnerFailed, rt as errorRuntime, s as resolveMigrationPaths, u as setCommandExamples, w as formatMigrationJson, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { o as resolveRefAdvancementFields } from \"../ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"../migration-command-scaffold-CGcbYM2B.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-init.ts\n/**\n* Maps a DbInitFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbInitFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"MIGRATION.MARKER_ORIGIN_MISMATCH\") {\n\t\tconst mismatchParts = [];\n\t\tif (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) mismatchParts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);\n\t\tif (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) mismatchParts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);\n\t\treturn errorRuntime(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(\" and \")}.` : \"\"}`, {\n\t\t\twhy: \"Database has an existing signature (marker) that does not match the target contract\",\n\t\t\tfix: \"If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow\",\n\t\t\tmeta: {\n\t\t\t\t...ifDefined(\"markerStorageHash\", failure.marker?.storageHash),\n\t\t\t\t...ifDefined(\"destinationStorageHash\", failure.destination?.storageHash),\n\t\t\t\t...ifDefined(\"markerProfileHash\", failure.marker?.profileHash),\n\t\t\t\t...ifDefined(\"destinationProfileHash\", failure.destination?.profileHash)\n\t\t\t}\n\t\t});\n\t}\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst 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.\" : \"Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `prisma-next db init`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\t...ifDefined(\"meta\", failure.meta),\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db init command and returns a structured Result.\n*/\nasync function executeDbInitCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db init\",\n\t\tdescription: \"Bootstrap a database to match the current contract\",\n\t\turl: \"https://pris.ly/db-init\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, contractJson, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbInit({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbInitFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractPathAbsolute,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...result.value.execution ? { execution: {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} } : {},\n\t\t\t...result.value.marker ? { marker: {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} } : {},\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db init: ${safeMessage}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbInitCommand() {\n\tconst command = new Command(\"init\");\n\tsetCommandDescriptions(command, \"Bootstrap a database to match the current contract and sign it\", \"Initializes a database to match your emitted contract using additive-only operations.\\nCreates any missing tables, columns, indexes, and constraints defined in your contract.\\nLeaves existing compatible structures in place, surfaces conflicts when destructive changes\\nwould be required, and signs the database to track contract state. Use --dry-run to\\npreview changes without applying.\");\n\tsetCommandExamples(command, [\"prisma-next db init --db $DATABASE_URL\", \"prisma-next db init --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeDbInitCommand(options, flags, ui, startTime), flags, ui, (dbInitResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbInitResult));\n\t\t\telse {\n\t\t\t\tconst output = dbInitResult.mode === \"plan\" ? formatMigrationPlanOutput(dbInitResult, flags) : formatMigrationApplyOutput(dbInitResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbInitCommand };\n\n//# sourceMappingURL=db-init.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,iBAAiB,SAAS;CAClC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,oCAAoC;EACxD,MAAM,gBAAgB,CAAC;EACvB,IAAI,QAAQ,QAAQ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ,QAAQ,eAAe,QAAQ,aAAa,aAAa,cAAc,KAAK,wBAAwB,QAAQ,OAAO,YAAY,iBAAiB,QAAQ,YAAY,YAAY,EAAE;EAClQ,IAAI,QAAQ,QAAQ,gBAAgB,Q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
- import { et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
2
- import { t as inspectLiveSchema } from "./inspect-live-schema-Da76TWOs-CAFqkhGb.mjs";
3
- import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-C6L_hiJU-B4V3bqvG.mjs";
1
+ import { et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
2
+ import { t as inspectLiveSchema } from "./inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs";
3
+ import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-C6L_hiJU-MX67LFfI.mjs";
4
4
  import { Command } from "commander";
5
5
  //#region ../../../1-framework/3-tooling/cli/dist/commands/db-schema.mjs
6
6
  function toIntrospectSchemaResult(result) {
@@ -44,4 +44,4 @@ function createDbSchemaCommand() {
44
44
  //#endregion
45
45
  export { createDbSchemaCommand as t };
46
46
 
47
- //# sourceMappingURL=db-schema-BWpeh0Q_.mjs.map
47
+ //# sourceMappingURL=db-schema-CRGCFKlH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-schema-BWpeh0Q_.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-schema.mjs"],"sourcesContent":["import { _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { t as inspectLiveSchema } from \"../inspect-live-schema-Da76TWOs.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"../verify-C6L_hiJU.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/db-schema.ts\nfunction toIntrospectSchemaResult(result) {\n\treturn {\n\t\tok: true,\n\t\tsummary: \"Schema read successfully\",\n\t\ttarget: result.target,\n\t\tschema: result.schema,\n\t\tmeta: result.meta,\n\t\ttimings: result.timings\n\t};\n}\nfunction createDbSchemaCommand() {\n\tconst command = new Command(\"schema\");\n\tsetCommandDescriptions(command, \"Inspect the live database schema\", \"Reads the live database schema and prints it as a tree by default or as JSON with\\n--json. This command is always read-only and never writes files. To save machine-\\nreadable output, use shell redirection, for example `prisma-next db schema --json > schema.json`.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db schema --db $DATABASE_URL\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json > schema.json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").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 inspectLiveSchema(options, flags, ui, Date.now(), {\n\t\t\tcommandName: \"db schema\",\n\t\t\tdescription: \"Inspect the live database schema\",\n\t\t\turl: \"https://pris.ly/db-schema\"\n\t\t}), flags, ui, (value) => {\n\t\t\tconst introspectResult = toIntrospectSchemaResult(value);\n\t\t\tif (flags.json) {\n\t\t\t\tui.output(formatIntrospectJson(introspectResult));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst output = formatIntrospectOutput(introspectResult, value.schemaView, flags);\n\t\t\tif (output) ui.log(output);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSchemaCommand };\n\n//# sourceMappingURL=db-schema.mjs.map"],"mappings":";;;;;AAKA,SAAS,yBAAyB,QAAQ;CACzC,OAAO;EACN,IAAI;EACJ,SAAS;EACT,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;CACjB;AACD;AACA,SAAS,wBAAwB;CAChC,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBAAuB,SAAS,oCAAoC,yQAAyQ;CAC7U,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACjK,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,kBAAkB,SAAS,OAAO,IAAI,KAAK,IAAI,GAAG;GACrF,aAAa;GACb,aAAa;GACb,KAAK;EACN,CAAC,GAAG,OAAO,KAAK,UAAU;GACzB,MAAM,mBAAmB,yBAAyB,KAAK;GACvD,IAAI,MAAM,MAAM;IACf,GAAG,OAAO,qBAAqB,gBAAgB,CAAC;IAChD;GACD;GACA,MAAM,SAAS,uBAAuB,kBAAkB,MAAM,YAAY,KAAK;GAC/E,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"db-schema-CRGCFKlH.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-schema.mjs"],"sourcesContent":["import { _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { t as inspectLiveSchema } from \"../inspect-live-schema-CXH4ZGHT.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"../verify-C6L_hiJU.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/db-schema.ts\nfunction toIntrospectSchemaResult(result) {\n\treturn {\n\t\tok: true,\n\t\tsummary: \"Schema read successfully\",\n\t\ttarget: result.target,\n\t\tschema: result.schema,\n\t\tmeta: result.meta,\n\t\ttimings: result.timings\n\t};\n}\nfunction createDbSchemaCommand() {\n\tconst command = new Command(\"schema\");\n\tsetCommandDescriptions(command, \"Inspect the live database schema\", \"Reads the live database schema and prints it as a tree by default or as JSON with\\n--json. This command is always read-only and never writes files. To save machine-\\nreadable output, use shell redirection, for example `prisma-next db schema --json > schema.json`.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db schema --db $DATABASE_URL\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json\",\n\t\t\"prisma-next db schema --db $DATABASE_URL --json > schema.json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").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 inspectLiveSchema(options, flags, ui, Date.now(), {\n\t\t\tcommandName: \"db schema\",\n\t\t\tdescription: \"Inspect the live database schema\",\n\t\t\turl: \"https://pris.ly/db-schema\"\n\t\t}), flags, ui, (value) => {\n\t\t\tconst introspectResult = toIntrospectSchemaResult(value);\n\t\t\tif (flags.json) {\n\t\t\t\tui.output(formatIntrospectJson(introspectResult));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst output = formatIntrospectOutput(introspectResult, value.schemaView, flags);\n\t\t\tif (output) ui.log(output);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSchemaCommand };\n\n//# sourceMappingURL=db-schema.mjs.map"],"mappings":";;;;;AAKA,SAAS,yBAAyB,QAAQ;CACzC,OAAO;EACN,IAAI;EACJ,SAAS;EACT,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;CACjB;AACD;AACA,SAAS,wBAAwB;CAChC,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBAAuB,SAAS,oCAAoC,yQAAyQ;CAC7U,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,OAAO,cAAc,4BAA4B,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACjK,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,kBAAkB,SAAS,OAAO,IAAI,KAAK,IAAI,GAAG;GACrF,aAAa;GACb,aAAa;GACb,KAAK;EACN,CAAC,GAAG,OAAO,KAAK,UAAU;GACzB,MAAM,mBAAmB,yBAAyB,KAAK;GACvD,IAAI,MAAM,MAAM;IACf,GAAG,OAAO,qBAAqB,gBAAgB,CAAC;IAChD;GACD;GACA,MAAM,SAAS,uBAAuB,kBAAkB,MAAM,YAAY,KAAK;GAC/E,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}