@prisma/orm-toolchain 8.0.0-rc.1-dev.4 → 8.0.0-rc.1-dev.6

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 (170) hide show
  1. package/dist/{aggregate-B4mhR4Sk.mjs → aggregate-i-rfetSO.mjs} +8 -8
  2. package/dist/{aggregate-B4mhR4Sk.mjs.map → aggregate-i-rfetSO.mjs.map} +1 -1
  3. package/dist/bin__prisma-next.mjs +22 -22
  4. package/dist/bin__prisma-next.mjs.map +1 -1
  5. package/dist/cli.mjs +2 -2
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/cli__commands__contract-emit.mjs +1 -1
  8. package/dist/cli__commands__contract-infer.mjs +1 -1
  9. package/dist/cli__commands__db-init.mjs +1 -1
  10. package/dist/cli__commands__db-schema.mjs +1 -1
  11. package/dist/cli__commands__db-sign.mjs +1 -1
  12. package/dist/cli__commands__db-update.mjs +1 -1
  13. package/dist/cli__commands__db-verify.mjs +1 -1
  14. package/dist/cli__commands__migrate.d.mts +1 -1
  15. package/dist/cli__commands__migrate.mjs +1 -1
  16. package/dist/cli__commands__migration-check.d.mts +1 -1
  17. package/dist/cli__commands__migration-check.mjs +1 -1
  18. package/dist/cli__commands__migration-graph.d.mts +1 -1
  19. package/dist/cli__commands__migration-graph.mjs +1 -1
  20. package/dist/cli__commands__migration-list.d.mts +1 -1
  21. package/dist/cli__commands__migration-list.mjs +1 -1
  22. package/dist/cli__commands__migration-log.d.mts +1 -1
  23. package/dist/cli__commands__migration-log.mjs +1 -1
  24. package/dist/cli__commands__migration-new.mjs +1 -1
  25. package/dist/cli__commands__migration-plan.mjs +1 -1
  26. package/dist/cli__commands__migration-show.mjs +1 -1
  27. package/dist/cli__commands__migration-status.d.mts +1 -1
  28. package/dist/cli__commands__migration-status.mjs +1 -1
  29. package/dist/cli__commands__ref.d.mts +1 -1
  30. package/dist/cli__commands__ref.mjs +1 -1
  31. package/dist/cli__commands__telemetry.mjs +1 -1
  32. package/dist/cli__control-api.d.mts +1 -1
  33. package/dist/cli__control-api.mjs +2 -2
  34. package/dist/cli__migration-cli.mjs +3 -6
  35. package/dist/cli__migration-cli.mjs.map +1 -1
  36. package/dist/{client-75qrAPqf-7l0C0H_b.mjs → client-7aUYC7ci-Bh9mLxkl.mjs} +16 -12
  37. package/dist/client-7aUYC7ci-Bh9mLxkl.mjs.map +1 -0
  38. package/dist/{command-helpers-CAoXqAY9-DWUBcTXM.mjs → command-helpers-C4WpR-QE-CK2gkj6l.mjs} +30 -74
  39. package/dist/command-helpers-C4WpR-QE-CK2gkj6l.mjs.map +1 -0
  40. package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs +44 -0
  41. package/dist/contract-at-errors-YdCQ5OOk-okxG7Eaj.mjs.map +1 -0
  42. package/dist/{contract-emit-B6odMoem-C87PBvmo.mjs → contract-emit-CTm2zfuG-8mtkxW8M.mjs} +12 -11
  43. package/dist/contract-emit-CTm2zfuG-8mtkxW8M.mjs.map +1 -0
  44. package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs → contract-emit-D8IXP9Qp-CecAQio1.mjs} +4 -4
  45. package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs.map → contract-emit-D8IXP9Qp-CecAQio1.mjs.map} +1 -1
  46. package/dist/{contract-infer-BnkqpftN-DwBzasOu.mjs → contract-infer-C8-RqHeK-D_dm3onP.mjs} +5 -5
  47. package/dist/contract-infer-C8-RqHeK-D_dm3onP.mjs.map +1 -0
  48. package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs → contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs} +3 -3
  49. package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map → contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs.map} +1 -1
  50. package/dist/{contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs → contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs} +6 -6
  51. package/dist/contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs.map +1 -0
  52. package/dist/{db-init-bd0_x2Q8.mjs → db-init-CXMcvoIA.mjs} +9 -12
  53. package/dist/db-init-CXMcvoIA.mjs.map +1 -0
  54. package/dist/{db-schema-CwgAWTqG.mjs → db-schema-j8DERh4t.mjs} +4 -4
  55. package/dist/{db-schema-CwgAWTqG.mjs.map → db-schema-j8DERh4t.mjs.map} +1 -1
  56. package/dist/{db-sign-vqiYfpjI.mjs → db-sign-xV_rpoIc.mjs} +10 -10
  57. package/dist/db-sign-xV_rpoIc.mjs.map +1 -0
  58. package/dist/{db-update-Br0diOCo.mjs → db-update-DXa2DIvu.mjs} +11 -11
  59. package/dist/db-update-DXa2DIvu.mjs.map +1 -0
  60. package/dist/{db-verify-CKPsRFrj-T7nSt7yT.mjs → db-verify-YWHjuKC7-DidK1gx1.mjs} +9 -6
  61. package/dist/db-verify-YWHjuKC7-DidK1gx1.mjs.map +1 -0
  62. package/dist/{errors--qsXZUtL.d.mts → errors-AkMBj-YP.d.mts} +8 -8
  63. package/dist/errors-AkMBj-YP.d.mts.map +1 -0
  64. package/dist/{errors-IpZm1Skp-BH495dRd.mjs → errors-BwusfLIN-BXM7K-ww.mjs} +42 -51
  65. package/dist/errors-BwusfLIN-BXM7K-ww.mjs.map +1 -0
  66. package/dist/{format-ByDm2goZ-BIRlFoo6.mjs → format-Bw3LVJ1v-D10inUT9.mjs} +12 -9
  67. package/dist/format-Bw3LVJ1v-D10inUT9.mjs.map +1 -0
  68. package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs → framework-components-3DdB31mk-BPGSuOyZ.mjs} +3 -3
  69. package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs.map → framework-components-3DdB31mk-BPGSuOyZ.mjs.map} +1 -1
  70. package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs → graph-membership-h9ejuZla-ewjYM5wz.mjs} +3 -3
  71. package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs.map → graph-membership-h9ejuZla-ewjYM5wz.mjs.map} +1 -1
  72. package/dist/{init-BGm77aWc-jHVUn63W.mjs → init-CPB89WK2-Di4kgP6B.mjs} +4 -4
  73. package/dist/{init-BGm77aWc-jHVUn63W.mjs.map → init-CPB89WK2-Di4kgP6B.mjs.map} +1 -1
  74. package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs → inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs} +4 -4
  75. package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs.map → inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs.map} +1 -1
  76. package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs → invariants-CMcQxRas-CXX9uhQW.mjs} +3 -3
  77. package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs.map → invariants-CMcQxRas-CXX9uhQW.mjs.map} +1 -1
  78. package/dist/{io-C8TdyBKt-DloEBi70.mjs → io-CL3hSv42-DGZtTs89.mjs} +8 -8
  79. package/dist/{io-C8TdyBKt-DloEBi70.mjs.map → io-CL3hSv42-DGZtTs89.mjs.map} +1 -1
  80. package/dist/{migrate-BdVFDKF2.mjs → migrate-COusRrm7.mjs} +28 -22
  81. package/dist/migrate-COusRrm7.mjs.map +1 -0
  82. package/dist/{migration-check-CcG-fB8r-qpu6xdbA.mjs → migration-check-CueEJelQ-J81XR_ns.mjs} +10 -10
  83. package/dist/migration-check-CueEJelQ-J81XR_ns.mjs.map +1 -0
  84. package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs → migration-command-scaffold-DNRo4exb-9JCezdoT.mjs} +4 -4
  85. package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs.map → migration-command-scaffold-DNRo4exb-9JCezdoT.mjs.map} +1 -1
  86. package/dist/{migration-BuUmO7It.mjs → migration-diUAhNaa.mjs} +3 -3
  87. package/dist/{migration-BuUmO7It.mjs.map → migration-diUAhNaa.mjs.map} +1 -1
  88. package/dist/{migration-graph-vmgkL3k4.mjs → migration-graph-BL6vfLcE.mjs} +4 -4
  89. package/dist/{migration-graph-vmgkL3k4.mjs.map → migration-graph-BL6vfLcE.mjs.map} +1 -1
  90. package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs → migration-graph-D6bN-mX0-DwMWY8DA.mjs} +3 -3
  91. package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs.map → migration-graph-D6bN-mX0-DwMWY8DA.mjs.map} +1 -1
  92. package/dist/{migration-list-BFBeo1_X-ckYMhETH.mjs → migration-list-D2_JdzWC-MRHYYVQE.mjs} +6 -6
  93. package/dist/{migration-list-BFBeo1_X-ckYMhETH.mjs.map → migration-list-D2_JdzWC-MRHYYVQE.mjs.map} +1 -1
  94. package/dist/{migration-log-CS5IWcNq-DI7FTHCA.mjs → migration-log-BXbz6-Lj-CKHbat5f.mjs} +4 -6
  95. package/dist/migration-log-BXbz6-Lj-CKHbat5f.mjs.map +1 -0
  96. package/dist/{migration-new-GmW2anVb.mjs → migration-new-szZFsA3C.mjs} +16 -15
  97. package/dist/migration-new-szZFsA3C.mjs.map +1 -0
  98. package/dist/{migration-path-target-D3Sj55PI-BICblCuk.mjs → migration-path-target-BPYp3LNc-qRQlG_Yn.mjs} +4 -4
  99. package/dist/migration-path-target-BPYp3LNc-qRQlG_Yn.mjs.map +1 -0
  100. package/dist/{migration-plan-q_L84PN1-ClkGgtVz.mjs → migration-plan-CxXAXYc8-Dnp-v8Nl.mjs} +17 -18
  101. package/dist/migration-plan-CxXAXYc8-Dnp-v8Nl.mjs.map +1 -0
  102. package/dist/{migration-show--pW4XhKs.mjs → migration-show-BKsIh7Uz.mjs} +9 -9
  103. package/dist/migration-show-BKsIh7Uz.mjs.map +1 -0
  104. package/dist/{migration-status-CFlzlRmu-QHUxHm_l.mjs → migration-status-CNnRInne--cvmx56T.mjs} +15 -15
  105. package/dist/migration-status-CNnRInne--cvmx56T.mjs.map +1 -0
  106. package/dist/migration-tools.d.mts +2 -2
  107. package/dist/migration-tools.mjs +12 -12
  108. package/dist/migration-tools__aggregate.mjs +1 -1
  109. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  110. package/dist/migration-tools__errors.d.mts +1 -1
  111. package/dist/migration-tools__errors.mjs +1 -1
  112. package/dist/migration-tools__invariants.mjs +1 -1
  113. package/dist/migration-tools__io.mjs +1 -1
  114. package/dist/migration-tools__migration-graph.mjs +2 -2
  115. package/dist/migration-tools__migration.mjs +1 -1
  116. package/dist/migration-tools__ref-resolution.mjs +1 -1
  117. package/dist/migration-tools__refs.mjs +1 -1
  118. package/dist/migration-tools__spaces.d.mts +1 -1
  119. package/dist/migration-tools__spaces.mjs +2 -2
  120. package/dist/{project-import-root-CpwLCDLY-DkVwAnWj.mjs → project-import-root-C_bd0ooL-CLXW-gp6.mjs} +10 -8
  121. package/dist/project-import-root-C_bd0ooL-CLXW-gp6.mjs.map +1 -0
  122. package/dist/{ref-sHE8zOcm.mjs → ref-DjZ5Y8ju.mjs} +11 -11
  123. package/dist/ref-DjZ5Y8ju.mjs.map +1 -0
  124. package/dist/{ref-advancement-CSPMoQs3-fEipZrdu.mjs → ref-advancement-CSPMoQs3-CPkL3IFF.mjs} +4 -4
  125. package/dist/{ref-advancement-CSPMoQs3-fEipZrdu.mjs.map → ref-advancement-CSPMoQs3-CPkL3IFF.mjs.map} +1 -1
  126. package/dist/{ref-resolution-BjJBWPjX.mjs → ref-resolution-BsdziDFA.mjs} +2 -2
  127. package/dist/{ref-resolution-BjJBWPjX.mjs.map → ref-resolution-BsdziDFA.mjs.map} +1 -1
  128. package/dist/{refs-BDbB9BRB-D6Za3Q49.mjs → refs-DtoeUivZ-qay0UMSP.mjs} +6 -6
  129. package/dist/refs-DtoeUivZ-qay0UMSP.mjs.map +1 -0
  130. package/dist/{spaces-C27bA-xc.mjs → spaces-BNd2Tlk0.mjs} +7 -7
  131. package/dist/spaces-BNd2Tlk0.mjs.map +1 -0
  132. package/dist/{spaces-DxFj5y8l.d.mts → spaces-D5qtTlhj.d.mts} +2 -2
  133. package/dist/{spaces-DxFj5y8l.d.mts.map → spaces-D5qtTlhj.d.mts.map} +1 -1
  134. package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs → telemetry-DVBHDQd6-BEdoMii0.mjs} +3 -3
  135. package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs.map → telemetry-DVBHDQd6-BEdoMii0.mjs.map} +1 -1
  136. package/dist/{types-DZWEs4si-D8UlyJI0.d.mts → types-2n_H3DQ9-Bks8UPEO.d.mts} +8 -2
  137. package/dist/types-2n_H3DQ9-Bks8UPEO.d.mts.map +1 -0
  138. package/dist/{verify-DnVNjc5C-BGdsblBK.mjs → verify-C6L_hiJU-CN3eEe3Y.mjs} +3 -3
  139. package/dist/{verify-DnVNjc5C-BGdsblBK.mjs.map → verify-C6L_hiJU-CN3eEe3Y.mjs.map} +1 -1
  140. package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs → verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs} +4 -4
  141. package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs.map → verify-contract-spaces-Ak73-zQK-y4qVyu-y.mjs.map} +1 -1
  142. package/dist/vite-plugin-contract-emit.mjs +1 -1
  143. package/package.json +12 -12
  144. package/dist/client-75qrAPqf-7l0C0H_b.mjs.map +0 -1
  145. package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs.map +0 -1
  146. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs +0 -36
  147. package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs.map +0 -1
  148. package/dist/contract-emit-B6odMoem-C87PBvmo.mjs.map +0 -1
  149. package/dist/contract-infer-BnkqpftN-DwBzasOu.mjs.map +0 -1
  150. package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map +0 -1
  151. package/dist/db-init-bd0_x2Q8.mjs.map +0 -1
  152. package/dist/db-sign-vqiYfpjI.mjs.map +0 -1
  153. package/dist/db-update-Br0diOCo.mjs.map +0 -1
  154. package/dist/db-verify-CKPsRFrj-T7nSt7yT.mjs.map +0 -1
  155. package/dist/errors--qsXZUtL.d.mts.map +0 -1
  156. package/dist/errors-IpZm1Skp-BH495dRd.mjs.map +0 -1
  157. package/dist/format-ByDm2goZ-BIRlFoo6.mjs.map +0 -1
  158. package/dist/migrate-BdVFDKF2.mjs.map +0 -1
  159. package/dist/migration-check-CcG-fB8r-qpu6xdbA.mjs.map +0 -1
  160. package/dist/migration-log-CS5IWcNq-DI7FTHCA.mjs.map +0 -1
  161. package/dist/migration-new-GmW2anVb.mjs.map +0 -1
  162. package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs.map +0 -1
  163. package/dist/migration-plan-q_L84PN1-ClkGgtVz.mjs.map +0 -1
  164. package/dist/migration-show--pW4XhKs.mjs.map +0 -1
  165. package/dist/migration-status-CFlzlRmu-QHUxHm_l.mjs.map +0 -1
  166. package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs.map +0 -1
  167. package/dist/ref-sHE8zOcm.mjs.map +0 -1
  168. package/dist/refs-BDbB9BRB-D6Za3Q49.mjs.map +0 -1
  169. package/dist/spaces-C27bA-xc.mjs.map +0 -1
  170. package/dist/types-DZWEs4si-D8UlyJI0.d.mts.map +0 -1
@@ -1,6 +1,6 @@
1
- import { O as errorRuntime$1, u as errorContractConfigMissing$1 } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-CjshQKHA-Dlp6Leo5.mjs";
3
- import { t as createProjectSpecifierResolver } from "./project-import-root-CpwLCDLY-DkVwAnWj.mjs";
1
+ import { O as errorRuntime$1, u as errorContractConfigMissing$1 } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-3DdB31mk-BPGSuOyZ.mjs";
3
+ import { t as createProjectSpecifierResolver } from "./project-import-root-C_bd0ooL-CLXW-gp6.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
6
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
@@ -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-B6odMoem.mjs
26
- var contract_emit_B6odMoem_exports = /* @__PURE__ */ __exportAll$1({
25
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-CTm2zfuG.mjs
26
+ var contract_emit_CTm2zfuG_exports = /* @__PURE__ */ __exportAll$1({
27
27
  n: () => executeContractEmit,
28
28
  r: () => disposeEmitQueue,
29
29
  t: () => contract_emit_exports
@@ -184,11 +184,12 @@ function endSpan(onProgress, spanId, outcome) {
184
184
  outcome
185
185
  });
186
186
  }
187
- function failedToResolveContractSource(why, fix, meta) {
188
- return errorRuntime$1("Failed to resolve contract source", {
187
+ function failedToResolveContractSource(why, fix, meta, cause) {
188
+ return errorRuntime$1("CONTRACT.SOURCE_LOAD_FAILED", "Failed to resolve contract source", {
189
189
  why,
190
190
  fix,
191
- ...ifDefined("meta", meta)
191
+ ...ifDefined("meta", meta),
192
+ ...ifDefined("cause", cause)
192
193
  });
193
194
  }
194
195
  function diagnosticLocationSuffix(diagnostic) {
@@ -297,7 +298,7 @@ async function executeContractEmit(options) {
297
298
  } catch (error) {
298
299
  endSpan(onProgress, "resolveSource", "error");
299
300
  if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
300
- throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.");
301
+ throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
301
302
  }
302
303
  const validatedContract = validateProviderResult(providerResult);
303
304
  if (!validatedContract.ok) {
@@ -354,6 +355,6 @@ async function executeContractEmit(options) {
354
355
  });
355
356
  }
356
357
  //#endregion
357
- export { disposeEmitQueue as n, executeContractEmit as r, contract_emit_B6odMoem_exports as t };
358
+ export { disposeEmitQueue as n, executeContractEmit as r, contract_emit_CTm2zfuG_exports as t };
358
359
 
359
- //# sourceMappingURL=contract-emit-B6odMoem-C87PBvmo.mjs.map
360
+ //# sourceMappingURL=contract-emit-CTm2zfuG-8mtkxW8M.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-emit-CTm2zfuG-8mtkxW8M.mjs","names":["errorRuntime","errorContractConfigMissing"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-emit-CTm2zfuG.mjs"],"sourcesContent":["import { rt as errorRuntime, z as errorContractConfigMissing } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"./framework-components-3DdB31mk.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 { loadConfig } 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 config = await unlessAborted(loadConfig(configPath));\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 r, contract_emit_exports as t };\n\n//# sourceMappingURL=contract-emit-CTm2zfuG.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAI,YAAY,OAAO;AACvB,IAAI,eAAe,KAAK,eAAe;CACtC,IAAI,SAAS,CAAC;CACd,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KA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U,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,5 +1,5 @@
1
- import { r as executeContractEmit } from "./contract-emit-B6odMoem-C87PBvmo.mjs";
2
- import { G as formatSuccessMessage, N as errorUnexpected$1, W as formatStyledHeader, X as isVerbose, ct as setCommandExamples, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
1
+ import { r as executeContractEmit } from "./contract-emit-CTm2zfuG-8mtkxW8M.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-CK2gkj6l.mjs";
3
3
  import { r as getEmittedArtifactPaths } from "./exports-BCLg4CiV-okAfZydo.mjs";
4
4
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
5
5
  import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
@@ -8,7 +8,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-0hSjbuxp.mjs
11
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-emit-D8IXP9Qp.mjs
12
12
  /**
13
13
  * Formats human-readable output for contract emit.
14
14
  */
@@ -145,4 +145,4 @@ function createContractEmitCommand() {
145
145
  //#endregion
146
146
  export { createContractEmitCommand as t };
147
147
 
148
- //# sourceMappingURL=contract-emit-0hSjbuxp-BJLC-VgC.mjs.map
148
+ //# sourceMappingURL=contract-emit-D8IXP9Qp-CecAQio1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-emit-0hSjbuxp-BJLC-VgC.mjs","names":["errorUnexpected"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-emit-0hSjbuxp.mjs"],"sourcesContent":["import { n as executeContractEmit } from \"./contract-emit-B6odMoem.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-CAoXqAY9.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } 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\tlet config;\n\ttry {\n\t\tconfig = await loadConfig(configOption);\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError$1) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: \"Failed to load config\" }));\n\t}\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});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createContractEmitCommand as t };\n\n//# sourceMappingURL=contract-emit-0hSjbuxp.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,QAAQ,OAAO;CACxC,IAAI,MAAM,OAAO,OAAO;CACxB,MAAM,QAAQ,CAAC;CACf,MAAM,WAAW,SAAS,QAAQ,IAAI,GAAG,OAAO,MAAM,IAAI;CAC1D,MAAM,UAAU,SAAS,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG;CACxD,MAAM,KAAK,6BAA6B,UA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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
+ {"version":3,"file":"contract-emit-D8IXP9Qp-CecAQio1.mjs","names":["errorUnexpected"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-emit-D8IXP9Qp.mjs"],"sourcesContent":["import { n as executeContractEmit } from \"./contract-emit-CTm2zfuG.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 { loadConfig } 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\tlet config;\n\ttry {\n\t\tconfig = await loadConfig(configOption);\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError$1) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: \"Failed to load config\" }));\n\t}\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});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createContractEmitCommand as t };\n\n//# sourceMappingURL=contract-emit-D8IXP9Qp.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,Q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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,12 +1,12 @@
1
- import { ct as setCommandExamples, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
2
- import { t as inspectLiveSchema } from "./inspect-live-schema-CnwYTRZ0-P-6asJFl.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-CK2gkj6l.mjs";
2
+ import { t as inspectLiveSchema } from "./inspect-live-schema-DEYE4EHW-DmSfKdpv.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-BnkqpftN.mjs
9
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-infer-C8-RqHeK.mjs
10
10
  /**
11
11
  * Resolves the output path for the inferred PSL contract.
12
12
  *
@@ -29,7 +29,7 @@ async function executeContractInferCommand(options, flags, ui, startTime) {
29
29
  });
30
30
  if (!inspectResult.ok) return inspectResult;
31
31
  const { config, target, meta, pslContractAst, pslBlockDescriptors } = inspectResult.value;
32
- if (!pslContractAst) return notOk(errorRuntime("contract infer is not supported for this family", {
32
+ if (!pslContractAst) return notOk(errorRuntime("CONTRACT.INFER_UNSUPPORTED", "contract infer is not supported for this family", {
33
33
  why: "The configured family does not implement the PslContractInferCapable capability, so an inferred PSL contract cannot be produced from the live database schema.",
34
34
  fix: "Use a family that supports contract inference (e.g. SQL/Postgres)."
35
35
  }));
@@ -70,4 +70,4 @@ function createContractInferCommand() {
70
70
  //#endregion
71
71
  export { createContractInferCommand as t };
72
72
 
73
- //# sourceMappingURL=contract-infer-BnkqpftN-DwBzasOu.mjs.map
73
+ //# sourceMappingURL=contract-infer-C8-RqHeK-D_dm3onP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-infer-C8-RqHeK-D_dm3onP.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-infer-C8-RqHeK.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-DEYE4EHW.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-C8-RqHeK.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,+BAA+B,SAAS,gBAAgB;CAChE,M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AAS,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,11 +1,11 @@
1
- import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, o as errorContractSnapshotMissing } from "./errors-IpZm1Skp-BH495dRd.mjs";
1
+ import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, o as errorContractSnapshotMissing } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
2
  import { join, relative } from "pathe";
3
3
  import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from "@prisma/orm-framework/components/control";
5
5
  import { randomBytes } from "node:crypto";
6
6
  import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
7
7
  import { blindCast } from "@prisma/orm-framework/utils/casts";
8
- //#region ../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-sf5nP4mb.mjs
8
+ //#region ../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-DNTOE6fB.mjs
9
9
  const CONTRACT_JSON_FILE = "contract.json";
10
10
  const CONTRACT_DTS_FILE = "contract.d.ts";
11
11
  function hasErrnoCode(error, code) {
@@ -115,4 +115,4 @@ function snapshotsImportPathFrom(packageDir, migrationsDir) {
115
115
  //#endregion
116
116
  export { snapshotsImportPathFrom as a, readContractSnapshotJsonTolerant as i, readContractSnapshotDts as n, writeContractSnapshot as o, readContractSnapshotJson as r, contractSnapshotDir as t };
117
117
 
118
- //# sourceMappingURL=contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map
118
+ //# sourceMappingURL=contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-sf5nP4mb.mjs"],"sourcesContent":["import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, o as errorContractSnapshotMissing } from \"./errors-IpZm1Skp.mjs\";\nimport { join, relative } from \"pathe\";\nimport { mkdir, readFile, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from \"@internal/framework-components/control\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/contract-snapshot-store.ts\nconst CONTRACT_JSON_FILE = \"contract.json\";\nconst CONTRACT_DTS_FILE = \"contract.d.ts\";\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && blindCast(error).code === code;\n}\nasync function directoryExists(p) {\n\ttry {\n\t\treturn (await stat(p)).isDirectory();\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return false;\n\t\tthrow error;\n\t}\n}\nfunction contractSnapshotDir(migrationsDir, storageHash) {\n\treturn join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex(storageHash));\n}\nasync function writeContractSnapshot(migrationsDir, storageHash, input) {\n\tconst dir = contractSnapshotDir(migrationsDir, storageHash);\n\tconst actualStorageHash = blindCast(input.contractJson).storage?.storageHash;\n\tif (actualStorageHash !== storageHash) throw errorContractSnapshotHashMismatch(storageHash, typeof actualStorageHash === \"string\" ? actualStorageHash : String(actualStorageHash), dir);\n\tif (await directoryExists(dir)) return {\n\t\twritten: false,\n\t\tdir\n\t};\n\tconst tmpDir = join(join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME), `.tmp-${storageHashHex(storageHash)}-${Date.now()}-${randomBytes(4).toString(\"hex\")}`);\n\tawait mkdir(tmpDir, { recursive: true });\n\tconst jsonContent = `${canonicalizeJson(input.contractJson)}\\n`;\n\tconst dtsContent = input.contractDts.endsWith(\"\\n\") ? input.contractDts : `${input.contractDts}\\n`;\n\ttry {\n\t\tawait writeFile(join(tmpDir, CONTRACT_JSON_FILE), jsonContent);\n\t\tawait writeFile(join(tmpDir, CONTRACT_DTS_FILE), dtsContent);\n\t\tawait rename(tmpDir, dir);\n\t} catch (error) {\n\t\tawait rm(tmpDir, {\n\t\t\trecursive: true,\n\t\t\tforce: true\n\t\t});\n\t\tif (hasErrnoCode(error, \"EEXIST\") || hasErrnoCode(error, \"ENOTEMPTY\")) return {\n\t\t\twritten: false,\n\t\t\tdir\n\t\t};\n\t\tthrow error;\n\t}\n\treturn {\n\t\twritten: true,\n\t\tdir\n\t};\n}\nasync function readContractSnapshotJson(migrationsDir, storageHash) {\n\tconst jsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, jsonPath);\n\t\tthrow error;\n\t}\n\ttry {\n\t\treturn JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(jsonPath, e instanceof Error ? e.message : String(e));\n\t}\n}\n/**\n* Tolerant read: a missing store entry (ENOENT), an unparseable\n* `contract.json`, the JSON literal `null`, or a `storageHash` that isn't a\n* well-formed 64-hex value all resolve to `undefined` rather than\n* throwing — parity with the catch-all tolerance of the pre-store\n* `readEndContractJson` (`io.ts`), which never validated the hash it was\n* keyed by either. Any other fs error (e.g. `EACCES` on a present-but-\n* unreadable file) propagates rather than silently loading a contract-less\n* package.\n*/\nasync function readContractSnapshotJsonTolerant(migrationsDir, storageHash) {\n\tlet jsonPath;\n\ttry {\n\t\tjsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\t} catch {\n\t\treturn;\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return;\n\t\tthrow error;\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\treturn parsed === null ? void 0 : parsed;\n\t} catch {\n\t\treturn;\n\t}\n}\nasync function readContractSnapshotDts(migrationsDir, storageHash) {\n\tconst dtsPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_DTS_FILE);\n\ttry {\n\t\treturn await readFile(dtsPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, dtsPath);\n\t\tthrow error;\n\t}\n}\nfunction snapshotsImportPathFrom(packageDir, migrationsDir) {\n\treturn relative(packageDir, join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME)).split(\"\\\\\").join(\"/\");\n}\n//#endregion\nexport { snapshotsImportPathFrom as a, readContractSnapshotJsonTolerant as i, readContractSnapshotDts as n, writeContractSnapshot as o, readContractSnapshotJson as r, contractSnapshotDir as t };\n\n//# sourceMappingURL=contract-snapshot-store-sf5nP4mb.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,SAAS,aAAa,OAAO,MAAM;CAClC,OAAO,iBAAiB,SAAS,UAAU,KAAK,CAAC,CAAC,SAAS;AAC5D;AACA,eAA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../../1-framework/3-tooling/migration/dist/contract-snapshot-store-DNTOE6fB.mjs"],"sourcesContent":["import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, o as errorContractSnapshotMissing } from \"./errors-BwusfLIN.mjs\";\nimport { join, relative } from \"pathe\";\nimport { mkdir, readFile, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from \"@internal/framework-components/control\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { blindCast } from \"@internal/utils/casts\";\n//#region src/contract-snapshot-store.ts\nconst CONTRACT_JSON_FILE = \"contract.json\";\nconst CONTRACT_DTS_FILE = \"contract.d.ts\";\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && blindCast(error).code === code;\n}\nasync function directoryExists(p) {\n\ttry {\n\t\treturn (await stat(p)).isDirectory();\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return false;\n\t\tthrow error;\n\t}\n}\nfunction contractSnapshotDir(migrationsDir, storageHash) {\n\treturn join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex(storageHash));\n}\nasync function writeContractSnapshot(migrationsDir, storageHash, input) {\n\tconst dir = contractSnapshotDir(migrationsDir, storageHash);\n\tconst actualStorageHash = blindCast(input.contractJson).storage?.storageHash;\n\tif (actualStorageHash !== storageHash) throw errorContractSnapshotHashMismatch(storageHash, typeof actualStorageHash === \"string\" ? actualStorageHash : String(actualStorageHash), dir);\n\tif (await directoryExists(dir)) return {\n\t\twritten: false,\n\t\tdir\n\t};\n\tconst tmpDir = join(join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME), `.tmp-${storageHashHex(storageHash)}-${Date.now()}-${randomBytes(4).toString(\"hex\")}`);\n\tawait mkdir(tmpDir, { recursive: true });\n\tconst jsonContent = `${canonicalizeJson(input.contractJson)}\\n`;\n\tconst dtsContent = input.contractDts.endsWith(\"\\n\") ? input.contractDts : `${input.contractDts}\\n`;\n\ttry {\n\t\tawait writeFile(join(tmpDir, CONTRACT_JSON_FILE), jsonContent);\n\t\tawait writeFile(join(tmpDir, CONTRACT_DTS_FILE), dtsContent);\n\t\tawait rename(tmpDir, dir);\n\t} catch (error) {\n\t\tawait rm(tmpDir, {\n\t\t\trecursive: true,\n\t\t\tforce: true\n\t\t});\n\t\tif (hasErrnoCode(error, \"EEXIST\") || hasErrnoCode(error, \"ENOTEMPTY\")) return {\n\t\t\twritten: false,\n\t\t\tdir\n\t\t};\n\t\tthrow error;\n\t}\n\treturn {\n\t\twritten: true,\n\t\tdir\n\t};\n}\nasync function readContractSnapshotJson(migrationsDir, storageHash) {\n\tconst jsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, jsonPath);\n\t\tthrow error;\n\t}\n\ttry {\n\t\treturn JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(jsonPath, e instanceof Error ? e.message : String(e));\n\t}\n}\n/**\n* Tolerant read: a missing store entry (ENOENT), an unparseable\n* `contract.json`, the JSON literal `null`, or a `storageHash` that isn't a\n* well-formed 64-hex value all resolve to `undefined` rather than\n* throwing — parity with the catch-all tolerance of the pre-store\n* `readEndContractJson` (`io.ts`), which never validated the hash it was\n* keyed by either. Any other fs error (e.g. `EACCES` on a present-but-\n* unreadable file) propagates rather than silently loading a contract-less\n* package.\n*/\nasync function readContractSnapshotJsonTolerant(migrationsDir, storageHash) {\n\tlet jsonPath;\n\ttry {\n\t\tjsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\t} catch {\n\t\treturn;\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return;\n\t\tthrow error;\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\treturn parsed === null ? void 0 : parsed;\n\t} catch {\n\t\treturn;\n\t}\n}\nasync function readContractSnapshotDts(migrationsDir, storageHash) {\n\tconst dtsPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_DTS_FILE);\n\ttry {\n\t\treturn await readFile(dtsPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, dtsPath);\n\t\tthrow error;\n\t}\n}\nfunction snapshotsImportPathFrom(packageDir, migrationsDir) {\n\treturn relative(packageDir, join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME)).split(\"\\\\\").join(\"/\");\n}\n//#endregion\nexport { snapshotsImportPathFrom as a, readContractSnapshotJsonTolerant as i, readContractSnapshotDts as n, writeContractSnapshot as o, readContractSnapshotJson as r, contractSnapshotDir as t };\n\n//# sourceMappingURL=contract-snapshot-store-DNTOE6fB.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,SAAS,aAAa,OAAO,MAAM;CAClC,OAAO,iBAAiB,SAAS,UAAU,KAAK,CAAC,CAAC,SAAS;AAC5D;AACA,eAAe,gBAAgB,GAAG;CACjC,IAAI;EACH,QAAQ,MAAM,KAAK,CAAC,EAAA,CAAG,YAAY;CACpC,SAAS,OAAO;EACf,IAAI,aAAa,OAAO,QAAQ,GAAG,OAAO;EAC1C,MAAM;CACP;AACD;AACA,SAAS,oBAAoB,eAAe,aAAa;CACxD,OAAO,KAAK,eAAe,4BAA4B,eAAe,WAAW,CAAC;AACnF;AACA,eAAe,sBAAsB,eAAe,aAAa,OAAO;CACvE,MAAM,MAAM,oBAAoB,eAAe,WAAW;CAC1D,MAAM,oBAAoB,UAAU,MAAM,YAAY,CAAC,CAAC,SAAS;CACjE,IAAI,sBAAsB,aAAa,MAAM,kC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eAAe,iCAAiC,eAAe,aAAa;CAC3E,IAAI;CACJ,IAAI;EACH,WAAW,KAAK,oBAAoB,eAAe,WAAW,GAAG,kBAAkB;CACpF,QAAQ;EACP;CACD;CACA,IAAI;CACJ,IAAI;EACH,MAAM,MAAM,SAAS,UAAU,OAAO;CACvC,SAAS,OAAO;EACf,IAAI,aAAa,OAAO,QAAQ,GAAG;EACnC,MAAM;CACP;CACA,IAAI;EACH,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,OAAO,WAAW,OAAO,KAAK,IAAI;CACnC,QAAQ;EACP;CACD;AACD;AACA,eAAe,wBAAwB,eAAe,aAAa;CAClE,MAAM,UAAU,KAAK,oBAAoB,eAAe,WAAW,GAAG,iBAAiB;CACvF,IAAI;EACH,OAAO,MAAM,SAAS,SAAS,OAAO;CACvC,SAAS,OAAO;EACf,IAAI,aAAa,OAAO,QAAQ,GAAG,MAAM,6BAA6B,aAAa,OAAO;EAC1F,MAAM;CACP;AACD;AACA,SAAS,wBAAwB,YAAY,eAAe;CAC3D,OAAO,SAAS,YAAY,KAAK,eAAe,0BAA0B,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;AAClG"}
@@ -1,12 +1,12 @@
1
- import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
1
+ import { t as MigrationToolsError } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
3
- import { N as errorUnexpected, Z as mapMigrationToolsError, it as resolveContractPath, nt as readContractEnvelope, t as CliStructuredError$1 } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
4
- import { s as loadContractSpaceAggregate } from "./aggregate-B4mhR4Sk.mjs";
3
+ import { N as errorUnexpected, rt as resolveContractPath, t as CliStructuredError$1, tt as readContractEnvelope } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
4
+ import { s as loadContractSpaceAggregate } from "./aggregate-i-rfetSO.mjs";
5
5
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
6
6
  import { readFile } from "node:fs/promises";
7
7
  import { createControlStack } from "@prisma/orm-framework/components/control";
8
8
  import { blindCast } from "@prisma/orm-framework/utils/casts";
9
- //#region ../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-CFH-336b.mjs
9
+ //#region ../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-CziO_ZRW.mjs
10
10
  /**
11
11
  * Project the CLI's `Config.extensions` array into the canonical
12
12
  * {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`
@@ -292,11 +292,11 @@ async function buildReadAggregate(config, options) {
292
292
  contractHash
293
293
  });
294
294
  } catch (error) {
295
- if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
295
+ if (MigrationToolsError.is(error)) return notOk(error);
296
296
  return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));
297
297
  }
298
298
  }
299
299
  //#endregion
300
300
  export { refuseContractSpaceIntegrity as a, toExtensionInputs as c, loadContractSpaceAggregateForCli as i, buildReadAggregate as n, refusePackageCorruptionOnAggregate as o, loadContractRawSafely as r, toDeclaredExtensionsFromRaw as s, buildContractSpaceAggregate as t };
301
301
 
302
- //# sourceMappingURL=contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map
302
+ //# sourceMappingURL=contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/contract-space-aggregate-loader-CziO_ZRW.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/utils/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 { refuseContractSpaceIntegrity as a, toExtensionInputs as c, loadContractSpaceAggregateForCli as i, buildReadAggregate as n, refusePackageCorruptionOnAggregate as o, loadContractRawSafely as r, toDeclaredExtensionsFromRaw as s, buildContractSpaceAggregate as t };\n\n//# sourceMappingURL=contract-space-aggregate-loader-CziO_ZRW.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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,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,KAAK,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC;CAChM;AACD"}
@@ -1,7 +1,7 @@
1
- import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
- import { B as formatMigrationJson, D as errorRunnerFailed, N as errorUnexpected, O as errorRuntime$1, V as formatMigrationPlanOutput, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, d as errorContractValidationFailed, o as createTerminalUI, ot as sanitizeErrorMessage, q as handleResult, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, x as errorMigrationPlanningFailed, z as formatMigrationApplyOutput } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
3
- import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs";
4
- import { i as readContractIR, n as computeRefAdvancementName, t as buildRefAdvancementFields } from "./ref-advancement-CSPMoQs3-fEipZrdu.mjs";
1
+ import { t as MigrationToolsError } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
+ 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-CK2gkj6l.mjs";
3
+ import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-DNRo4exb-9JCezdoT.mjs";
4
+ import { i as readContractIR, n as computeRefAdvancementName, t as buildRefAdvancementFields } from "./ref-advancement-CSPMoQs3-CPkL3IFF.mjs";
5
5
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
6
6
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
7
7
  import { assertNever } from "@prisma/orm-framework/utils/internal-error";
@@ -17,11 +17,10 @@ function mapDbInitFailure(failure) {
17
17
  const mismatchParts = [];
18
18
  if (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) mismatchParts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);
19
19
  if (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) mismatchParts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);
20
- return errorRuntime$1(`Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(" and ")}.` : ""}`, {
20
+ return errorRuntime$1("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing database signature does not match plan destination.${mismatchParts.length > 0 ? ` Mismatch in ${mismatchParts.join(" and ")}.` : ""}`, {
21
21
  why: "Database has an existing signature (marker) that does not match the target contract",
22
22
  fix: "If bootstrapping, drop/reset the database then re-run `prisma-next db init`; otherwise reconcile schema/marker using your migration workflow",
23
23
  meta: {
24
- code: "MIGRATION.MARKER_ORIGIN_MISMATCH",
25
24
  ...ifDefined("markerStorageHash", failure.marker?.storageHash),
26
25
  ...ifDefined("destinationStorageHash", failure.destination?.storageHash),
27
26
  ...ifDefined("markerProfileHash", failure.marker?.profileHash),
@@ -34,10 +33,8 @@ function mapDbInitFailure(failure) {
34
33
  return errorRunnerFailed(failure.summary, {
35
34
  why: failure.why ?? "Migration runner failed",
36
35
  fix,
37
- ...failure.meta ? { meta: {
38
- code: "RUNNER_FAILED",
39
- ...failure.meta
40
- } } : { meta: { code: "RUNNER_FAILED" } }
36
+ ...ifDefined("meta", failure.meta),
37
+ ...ifDefined("cause", failure.cause)
41
38
  });
42
39
  }
43
40
  const exhaustive = failure.code;
@@ -84,7 +81,7 @@ async function executeDbInitCommand(options, flags, ui, startTime) {
84
81
  hash: advancementHash
85
82
  });
86
83
  } catch (error) {
87
- if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
84
+ if (MigrationToolsError.is(error)) return notOk(error);
88
85
  throw error;
89
86
  }
90
87
  return ok({
@@ -150,4 +147,4 @@ function createDbInitCommand() {
150
147
  //#endregion
151
148
  export { createDbInitCommand as t };
152
149
 
153
- //# sourceMappingURL=db-init-bd0_x2Q8.mjs.map
150
+ //# sourceMappingURL=db-init-CXMcvoIA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-init-CXMcvoIA.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 { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"../migration-command-scaffold-DNRo4exb.mjs\";\nimport { i as readContractIR, n as computeRefAdvancementName, t as buildRefAdvancementFields } from \"../ref-advancement-CSPMoQs3.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\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\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\tlet refAdvancementFields = {\n\t\t\tadvancedRef: null,\n\t\t\tplannedAdvanceRef: null\n\t\t};\n\t\tif (computeRefAdvancementName({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db)\n\t\t}) !== null) try {\n\t\t\tconst contractIR = await readContractIR(contractJson, contractPathAbsolute);\n\t\t\trefAdvancementFields = await buildRefAdvancementFields({\n\t\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t\t...ifDefined(\"db\", options.db),\n\t\t\t\trefsDir,\n\t\t\t\tmigrationsDir,\n\t\t\t\tcontractIR,\n\t\t\t\tmode: result.value.mode,\n\t\t\t\thash: advancementHash\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\t\tthrow error;\n\t\t}\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":";;;;;;;;;;;;;AAaA,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,YAA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I,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -1,6 +1,6 @@
1
- import { ct as setCommandExamples, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
2
- import { t as inspectLiveSchema } from "./inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs";
3
- import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-DnVNjc5C-BGdsblBK.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-CK2gkj6l.mjs";
2
+ import { t as inspectLiveSchema } from "./inspect-live-schema-DEYE4EHW-DmSfKdpv.mjs";
3
+ import { n as formatIntrospectOutput, t as formatIntrospectJson } from "./verify-C6L_hiJU-CN3eEe3Y.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-CwgAWTqG.mjs.map
47
+ //# sourceMappingURL=db-schema-j8DERh4t.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-schema-CwgAWTqG.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-CAoXqAY9.mjs\";\nimport { t as inspectLiveSchema } from \"../inspect-live-schema-CnwYTRZ0.mjs\";\nimport { n as formatIntrospectOutput, t as formatIntrospectJson } from \"../verify-DnVNjc5C.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-j8DERh4t.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-DEYE4EHW.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,12 +1,12 @@
1
- import { t as MigrationToolsError } from "./errors-IpZm1Skp-BH495dRd.mjs";
2
- import { r as readContractSnapshotJson } from "./contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs";
3
- import { $ as maskConnectionUrl, N as errorUnexpected, O as errorRuntime$1, Q as mapRefResolutionError, W as formatStyledHeader, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, d as errorContractValidationFailed, f as errorDatabaseConnectionRequired, h as errorFileNotFound, it as resolveContractPath, m as errorDriverRequired, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
1
+ import { t as MigrationToolsError } from "./errors-BwusfLIN-BXM7K-ww.mjs";
2
+ import { r as readContractSnapshotJson } from "./contract-snapshot-store-DNTOE6fB-BDpjbdCJ.mjs";
3
+ import { N as errorUnexpected, O as errorRuntime$1, Q as maskConnectionUrl, W as formatStyledHeader, Z as mapRefResolutionError, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, f as errorDatabaseConnectionRequired, h as errorFileNotFound, it as resolveMigrationPaths, m as errorDriverRequired, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-CK2gkj6l.mjs";
4
4
  import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
5
5
  import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
6
- import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
7
- import { t as createControlClient } from "./client-75qrAPqf-7l0C0H_b.mjs";
8
- import { n as parseContractRef } from "./ref-resolution-BjJBWPjX.mjs";
9
- import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-DnVNjc5C-BGdsblBK.mjs";
6
+ import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CziO_ZRW-DIoQOL0P.mjs";
7
+ import { t as createControlClient } from "./client-7aUYC7ci-Bh9mLxkl.mjs";
8
+ import { n as parseContractRef } from "./ref-resolution-BsdziDFA.mjs";
9
+ import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-C6L_hiJU-CN3eEe3Y.mjs";
10
10
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
11
11
  import { relative, resolve } from "pathe";
12
12
  import { readFile } from "node:fs/promises";
@@ -64,13 +64,13 @@ async function executeDbSignCommand(contractArg, options, flags, ui) {
64
64
  const defaultRaw = await readFile(contractPathAbsolute, "utf-8");
65
65
  const defaultContract = JSON.parse(defaultRaw);
66
66
  if (defaultContract["storage"]?.["storageHash"] === targetHash) contractJson = defaultContract;
67
- else return notOk(errorRuntime$1(`No contract file found for hash "${targetHash}"`, {
67
+ else return notOk(errorRuntime$1("MIGRATION.SNAPSHOT_MISSING", `No contract file found for hash "${targetHash}"`, {
68
68
  why: `Resolved contract reference "${effectiveContractArg}" to hash "${targetHash}" but no migration produces that hash and the emitted contract does not match.`,
69
69
  fix: "Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json."
70
70
  }));
71
71
  }
72
72
  } catch (error) {
73
- if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
73
+ if (MigrationToolsError.is(error)) return notOk(error);
74
74
  if (error instanceof CliStructuredError$1) return notOk(error);
75
75
  return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));
76
76
  }
@@ -172,4 +172,4 @@ function createDbSignCommand() {
172
172
  //#endregion
173
173
  export { createDbSignCommand as t };
174
174
 
175
- //# sourceMappingURL=db-sign-vqiYfpjI.mjs.map
175
+ //# sourceMappingURL=db-sign-xV_rpoIc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-sign-xV_rpoIc.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-sign.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, U as errorDriverRequired, V as errorDatabaseConnectionRequired, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, lt as mapRefResolutionError, o as resolveContractPath, rt as errorRuntime, s as resolveMigrationPaths, 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 { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CziO_ZRW.mjs\";\nimport { t as createControlClient } from \"../client-7aUYC7ci.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"../verify-C6L_hiJU.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config);\n\t\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tconst refResult = parseContractRef(effectiveContractArg, {\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)) contractJson = await readContractSnapshotJson(migrationsDir, targetHash);\n\t\telse {\n\t\t\tconst defaultRaw = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t\tconst defaultContract = JSON.parse(defaultRaw);\n\t\t\tif (defaultContract[\"storage\"]?.[\"storageHash\"] === targetHash) contractJson = defaultContract;\n\t\t\telse return notOk(errorRuntime(\"MIGRATION.SNAPSHOT_MISSING\", `No contract file found for hash \"${targetHash}\"`, {\n\t\t\t\twhy: `Resolved contract reference \"${effectiveContractArg}\" to hash \"${targetHash}\" but no migration produces that hash and the emitted contract does not match.`,\n\t\t\t\tfix: \"Ensure the target contract exists on disk — either as a migration endpoint or as the emitted contract.json.\"\n\t\t\t}));\n\t\t}\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(error);\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) 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\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand };\n\n//# sourceMappingURL=db-sign.mjs.map"],"mappings":";;;;;;;;;;;;;;;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