@prisma/orm-toolchain 0.17.0-dev.5 → 0.17.0-dev.7

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 (83) hide show
  1. package/dist/bin__prisma-next.mjs +21 -21
  2. package/dist/bin__prisma-next.mjs.map +1 -1
  3. package/dist/cli.mjs +2 -2
  4. package/dist/cli__commands__contract-emit.mjs +1 -1
  5. package/dist/cli__commands__contract-infer.mjs +1 -1
  6. package/dist/cli__commands__db-init.mjs +1 -1
  7. package/dist/cli__commands__db-schema.mjs +1 -1
  8. package/dist/cli__commands__db-sign.mjs +1 -1
  9. package/dist/cli__commands__db-update.mjs +1 -1
  10. package/dist/cli__commands__db-verify.mjs +1 -1
  11. package/dist/cli__commands__migrate.mjs +1 -1
  12. package/dist/cli__commands__migration-check.mjs +1 -1
  13. package/dist/cli__commands__migration-graph.mjs +1 -1
  14. package/dist/cli__commands__migration-list.mjs +1 -1
  15. package/dist/cli__commands__migration-log.mjs +1 -1
  16. package/dist/cli__commands__migration-new.mjs +1 -1
  17. package/dist/cli__commands__migration-plan.mjs +1 -1
  18. package/dist/cli__commands__migration-show.mjs +1 -1
  19. package/dist/cli__commands__migration-status.mjs +1 -1
  20. package/dist/cli__commands__ref.mjs +1 -1
  21. package/dist/cli__control-api.mjs +2 -2
  22. package/dist/cli__migration-cli.mjs +1 -1
  23. package/dist/{client-75qrAPqf-DRg33_uJ.mjs → client-75qrAPqf-7l0C0H_b.mjs} +2 -2
  24. package/dist/{client-75qrAPqf-DRg33_uJ.mjs.map → client-75qrAPqf-7l0C0H_b.mjs.map} +1 -1
  25. package/dist/config-loader.mjs +1 -1
  26. package/dist/{contract-emit-0hSjbuxp-D2wIkKg5.mjs → contract-emit-0hSjbuxp-BJLC-VgC.mjs} +4 -4
  27. package/dist/{contract-emit-0hSjbuxp-D2wIkKg5.mjs.map → contract-emit-0hSjbuxp-BJLC-VgC.mjs.map} +1 -1
  28. package/dist/{contract-emit-B6odMoem-BqLV218x.mjs → contract-emit-B6odMoem-C87PBvmo.mjs} +3 -3
  29. package/dist/{contract-emit-B6odMoem-BqLV218x.mjs.map → contract-emit-B6odMoem-C87PBvmo.mjs.map} +1 -1
  30. package/dist/{contract-infer-BnkqpftN-CWEXM1_m.mjs → contract-infer-BnkqpftN-DwBzasOu.mjs} +2 -2
  31. package/dist/{contract-infer-BnkqpftN-CWEXM1_m.mjs.map → contract-infer-BnkqpftN-DwBzasOu.mjs.map} +1 -1
  32. package/dist/{db-init-CNV8ATc2.mjs → db-init-bd0_x2Q8.mjs} +2 -2
  33. package/dist/{db-init-CNV8ATc2.mjs.map → db-init-bd0_x2Q8.mjs.map} +1 -1
  34. package/dist/{db-schema-CJzVfw2K.mjs → db-schema-CwgAWTqG.mjs} +2 -2
  35. package/dist/{db-schema-CJzVfw2K.mjs.map → db-schema-CwgAWTqG.mjs.map} +1 -1
  36. package/dist/{db-sign-gLmoexj3.mjs → db-sign-vqiYfpjI.mjs} +3 -3
  37. package/dist/{db-sign-gLmoexj3.mjs.map → db-sign-vqiYfpjI.mjs.map} +1 -1
  38. package/dist/{db-update-C24M1jin.mjs → db-update-Br0diOCo.mjs} +2 -2
  39. package/dist/{db-update-C24M1jin.mjs.map → db-update-Br0diOCo.mjs.map} +1 -1
  40. package/dist/{db-verify-CKPsRFrj-1sjfQjHX.mjs → db-verify-CKPsRFrj-T7nSt7yT.mjs} +3 -3
  41. package/dist/{db-verify-CKPsRFrj-1sjfQjHX.mjs.map → db-verify-CKPsRFrj-T7nSt7yT.mjs.map} +1 -1
  42. package/dist/{domain-type-generation-DAn9y5d2-BgoT5uKI.mjs → domain-type-generation-bpSO3Y0L-Cdauqrnc.mjs} +16 -16
  43. package/dist/domain-type-generation-bpSO3Y0L-Cdauqrnc.mjs.map +1 -0
  44. package/dist/emitter.mjs +2 -2
  45. package/dist/emitter__domain-type-generation.mjs +1 -1
  46. package/dist/{exports-BGMKuMBH-C1_tsw6T.mjs → exports-BCLg4CiV-okAfZydo.mjs} +6 -4
  47. package/dist/exports-BCLg4CiV-okAfZydo.mjs.map +1 -0
  48. package/dist/{exports-DPBVzFXj.mjs → exports-BnihzVhw.mjs} +2 -2
  49. package/dist/{exports-DPBVzFXj.mjs.map → exports-BnihzVhw.mjs.map} +1 -1
  50. package/dist/{exports-BTEdvV8H.mjs → exports-CDX9kZuw.mjs} +2 -2
  51. package/dist/{exports-BTEdvV8H.mjs.map → exports-CDX9kZuw.mjs.map} +1 -1
  52. package/dist/{format-ByDm2goZ-CDNjRRyB.mjs → format-ByDm2goZ-BIRlFoo6.mjs} +2 -2
  53. package/dist/{format-ByDm2goZ-CDNjRRyB.mjs.map → format-ByDm2goZ-BIRlFoo6.mjs.map} +1 -1
  54. package/dist/{init-BGm77aWc-BuTXxJgQ.mjs → init-BGm77aWc-jHVUn63W.mjs} +2 -2
  55. package/dist/{init-BGm77aWc-BuTXxJgQ.mjs.map → init-BGm77aWc-jHVUn63W.mjs.map} +1 -1
  56. package/dist/{inspect-live-schema-CnwYTRZ0-Bdvwf7Dl.mjs → inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs} +3 -3
  57. package/dist/{inspect-live-schema-CnwYTRZ0-Bdvwf7Dl.mjs.map → inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs.map} +1 -1
  58. package/dist/{migrate-BnHRdrqX.mjs → migrate-BdVFDKF2.mjs} +4 -4
  59. package/dist/{migrate-BnHRdrqX.mjs.map → migrate-BdVFDKF2.mjs.map} +1 -1
  60. package/dist/{migration-check-DcwUnadt-DfjO4JKT.mjs → migration-check-DcwUnadt-jamDqOmM.mjs} +2 -2
  61. package/dist/{migration-check-DcwUnadt-DfjO4JKT.mjs.map → migration-check-DcwUnadt-jamDqOmM.mjs.map} +1 -1
  62. package/dist/{migration-command-scaffold-BCuoeAki-BMi1GAv-.mjs → migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs} +3 -3
  63. package/dist/{migration-command-scaffold-BCuoeAki-BMi1GAv-.mjs.map → migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs.map} +1 -1
  64. package/dist/{migration-graph-Bjy-ZHY3.mjs → migration-graph-vmgkL3k4.mjs} +3 -3
  65. package/dist/{migration-graph-Bjy-ZHY3.mjs.map → migration-graph-vmgkL3k4.mjs.map} +1 -1
  66. package/dist/{migration-list-BFBeo1_X-DwyOI0w9.mjs → migration-list-BFBeo1_X-ckYMhETH.mjs} +2 -2
  67. package/dist/{migration-list-BFBeo1_X-DwyOI0w9.mjs.map → migration-list-BFBeo1_X-ckYMhETH.mjs.map} +1 -1
  68. package/dist/{migration-log-CS5IWcNq-CjmDyvwG.mjs → migration-log-CS5IWcNq-DI7FTHCA.mjs} +3 -3
  69. package/dist/{migration-log-CS5IWcNq-CjmDyvwG.mjs.map → migration-log-CS5IWcNq-DI7FTHCA.mjs.map} +1 -1
  70. package/dist/{migration-new-CCEfD9oh.mjs → migration-new-GmW2anVb.mjs} +3 -3
  71. package/dist/{migration-new-CCEfD9oh.mjs.map → migration-new-GmW2anVb.mjs.map} +1 -1
  72. package/dist/{migration-plan-q_L84PN1-BFb6Si_L.mjs → migration-plan-q_L84PN1-ClkGgtVz.mjs} +3 -3
  73. package/dist/{migration-plan-q_L84PN1-BFb6Si_L.mjs.map → migration-plan-q_L84PN1-ClkGgtVz.mjs.map} +1 -1
  74. package/dist/{migration-show-PTC1gUjq.mjs → migration-show--pW4XhKs.mjs} +3 -3
  75. package/dist/{migration-show-PTC1gUjq.mjs.map → migration-show--pW4XhKs.mjs.map} +1 -1
  76. package/dist/{migration-status-CE7cQLDq-BNFyJssP.mjs → migration-status-CE7cQLDq-P1x1-BsZ.mjs} +4 -4
  77. package/dist/{migration-status-CE7cQLDq-BNFyJssP.mjs.map → migration-status-CE7cQLDq-P1x1-BsZ.mjs.map} +1 -1
  78. package/dist/{ref-tjLWCeGO.mjs → ref-sHE8zOcm.mjs} +2 -2
  79. package/dist/{ref-tjLWCeGO.mjs.map → ref-sHE8zOcm.mjs.map} +1 -1
  80. package/dist/vite-plugin-contract-emit.mjs +3 -3
  81. package/package.json +12 -12
  82. package/dist/domain-type-generation-DAn9y5d2-BgoT5uKI.mjs.map +0 -1
  83. package/dist/exports-BGMKuMBH-C1_tsw6T.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"migration-plan-q_L84PN1-BFb6Si_L.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-plan-q_L84PN1.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, Q as errorPlanForgotTheFlag, W as errorFileNotFound, X as errorMigrationPlanningFailed, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, it as errorSnapshotMissing, l as setCommandDescriptions, lt as mapMigrationToolsError, o as resolveContractPath, ot as errorTargetMigrationNotSupported, r as getTargetMigrations, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"./command-helpers-CAoXqAY9.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"./framework-components-CjshQKHA.mjs\";\nimport { t as createProjectSpecifierResolver } from \"./project-import-root-CpwLCDLY.mjs\";\nimport { c as toExtensionInputs, i as loadContractSpaceAggregateForCli, t as buildContractSpaceAggregate } from \"./contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { t as mapContractAtError } from \"./contract-at-errors-BX7w-p19.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack, hasOperationPreview } from \"@internal/framework-components/control\";\nimport { emitContractSpaceArtifacts, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory } from \"@internal/migration-tools/spaces\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { assertHashIsGraphNode, findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { snapshotsImportPathFrom, writeContractSnapshot } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\nimport { computeMigrationHash } from \"@internal/migration-tools/hash\";\nimport { formatMigrationDirName, materialiseExtensionMigrationPackageIfMissing, writeMigrationPackage } from \"@internal/migration-tools/io\";\nimport { writeMigrationTs } from \"@internal/migration-tools/migration-ts\";\nimport { deriveProvidedInvariants } from \"@internal/migration-tools/invariants\";\n//#region src/utils/contract-space-seed-phase.ts\n/**\n* Phase-1 of the two-phase `migration plan` pipeline (sub-spec § 4).\n*\n* For every extension that exposes a `contractSpace`:\n*\n* 1. Read the on-disk head ref (returns `null` on first emit).\n* 2. Write the head contract into the migrations-root snapshot store\n* (write-if-absent, keyed by hash) and unconditionally re-emit\n* `refs/head.json`, via {@link emitContractSpaceArtifacts}. The\n* framework owns `refs/head.json`; re-emit is the contract for that\n* file. The snapshot itself is only written once per distinct hash.\n* 3. Materialise any descriptor-shipped migration packages not yet on\n* disk via {@link materialiseExtensionMigrationPackageIfMissing}.\n* Existing packages are left untouched (by-existence skip).\n*\n* The return value lets the caller render a per-space status line and\n* lets the phase-2 aggregate loader run on a now-consistent disk state\n* (every loaded extension is guaranteed to have its head ref pinned\n* to the descriptor's hash and to ship every package the descriptor\n* declares).\n*\n* Output ordering is deterministic and alphabetical by spaceId (via\n* {@link planAllSpaces}, which also detects duplicate spaceIds). This\n* matches the canonical sort order used by every other aggregate\n* surface (`migrate`, `migration status`, the runner).\n*/\nasync function runContractSpaceSeedPhase(inputs) {\n\tconst planned = planAllSpaces(inputs.extensions.filter((pack) => pack.contractSpace !== void 0).map((pack) => ({\n\t\tspaceId: pack.id,\n\t\tpriorContract: null,\n\t\tnewContract: pack.contractSpace.contractJson,\n\t\t__pack: pack.contractSpace\n\t})), (input) => input.__pack.migrations);\n\tconst descriptorBySpace = /* @__PURE__ */ new Map();\n\tfor (const pack of inputs.extensions) if (pack.contractSpace !== void 0) descriptorBySpace.set(pack.id, pack.contractSpace);\n\tconst seeded = [];\n\tfor (const space of planned) {\n\t\tconst descriptor = descriptorBySpace.get(space.spaceId);\n\t\tif (descriptor === void 0) continue;\n\t\tconst priorHash = (await readContractSpaceHeadRef(inputs.migrationsDir, space.spaceId))?.hash ?? null;\n\t\tawait emitContractSpaceArtifacts(inputs.migrationsDir, space.spaceId, {\n\t\t\tcontract: descriptor.contractJson,\n\t\t\tcontractDts: buildPlaceholderContractDts(space.spaceId),\n\t\t\theadRef: {\n\t\t\t\thash: descriptor.headRef.hash,\n\t\t\t\tinvariants: descriptor.headRef.invariants\n\t\t\t}\n\t\t});\n\t\tconst spaceDir = spaceMigrationDirectory(inputs.migrationsDir, space.spaceId);\n\t\tconst newMigrationDirs = [];\n\t\tfor (const pkg of space.migrationPackages) {\n\t\t\tconst { written } = await materialiseExtensionMigrationPackageIfMissing(spaceDir, pkg);\n\t\t\tif (written) newMigrationDirs.push(pkg.dirName);\n\t\t}\n\t\tconst action = priorHash !== descriptor.headRef.hash || newMigrationDirs.length > 0 ? \"updated\" : \"unchanged\";\n\t\tseeded.push({\n\t\t\tspaceId: space.spaceId,\n\t\t\taction,\n\t\t\tpriorHash,\n\t\t\tnewHash: descriptor.headRef.hash,\n\t\t\tnewMigrationDirs\n\t\t});\n\t}\n\treturn { seeded };\n}\n/**\n* Placeholder `.d.ts` content for an extension space's on-disk mirror.\n*\n* Rendering a fully-typed `.d.ts` for an extension contract requires\n* the SQL-family renderer with the codec / typemap registry threaded\n* through; until that integration ships, the on-disk `.d.ts` is a\n* stub `export {};` module that documents how consumers should\n* validate the sibling `contract.json`. The stub typechecks on its\n* own and does not need any TypeScript suppressions.\n*/\nfunction buildPlaceholderContractDts(spaceId) {\n\treturn [\n\t\t\"/**\",\n\t\t` * Placeholder \\`.d.ts\\` for extension space \"${spaceId}\".`,\n\t\t\" *\",\n\t\t\" * The framework re-emits this file on every `migration plan` run\",\n\t\t\" * alongside `contract.json` and `refs/head.json`. A typed `.d.ts`\",\n\t\t\" * rendering pass for extension contracts is tracked separately;\",\n\t\t\" * until that ships, consumers should import `contract.json`\",\n\t\t\" * and pass it through the target descriptor’s `contractSerializer`.\",\n\t\t\" */\",\n\t\t\"export {};\",\n\t\t\"\"\n\t].join(\"\\n\");\n}\n//#endregion\n//#region src/utils/plan-resolution.ts\nconst FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;\nfunction looksLikeFullHash(input) {\n\treturn FULL_HASH_PATTERN.test(input);\n}\nfunction graphIsEmpty(space) {\n\treturn space.packages.length === 0;\n}\nfunction getReachableRefs(refs, graph) {\n\treturn Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{\n\t\tname,\n\t\thash: entry.hash\n\t}] : []).sort((a, b) => a.name.localeCompare(b.name));\n}\nfunction assertFromIsGraphNode(fromHash, graph, refs, graphTipHash) {\n\ttry {\n\t\tassertHashIsGraphNode(fromHash, graph);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.HASH_NOT_IN_GRAPH\") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), graphTipHash);\n\t\tthrow error;\n\t}\n}\nasync function resolveContractRef(parsed, space, options) {\n\tconst { hash, provenance } = parsed;\n\tconst refName = provenance.kind === \"ref\" ? provenance.refName : void 0;\n\ttry {\n\t\tconst at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);\n\t\tif (at.provenance === \"ref\") return ok({\n\t\t\tkind: \"ref\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t\treturn ok({\n\t\t\tkind: \"graph-node\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t} catch (error) {\n\t\treturn mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);\n\t}\n}\nasync function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {\n\tconst resolution = await resolveContractRef(parsed, input.space, {\n\t\t...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},\n\t\tartifactRole: \"from\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tif (resolution.value.kind === \"graph-node\") return ok({\n\t\tkind: \"graph-node\",\n\t\tfromHash: resolution.value.hash,\n\t\tfromContract: resolution.value.contract\n\t});\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\tif (graphIsEmpty(input.space)) return ok({\n\t\tkind: \"auto-baseline\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n\tconst graph = input.space.graph();\n\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\ttry {\n\t\tassertFromIsGraphNode(hash, graph, refs, graphTip);\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\treturn ok({\n\t\tkind: \"ref\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n}\nasync function resolveFromForPlan(input) {\n\tconst { optionsFrom, space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tif (optionsFrom === void 0) {\n\t\tconst dbRef = refs[\"db\"];\n\t\tif (!dbRef) return ok({\n\t\t\tkind: \"greenfield\",\n\t\t\tfromHash: null,\n\t\t\tfromContract: null\n\t\t});\n\t\treturn resolveFromPolicy({\n\t\t\thash: dbRef.hash,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"ref\",\n\t\t\t\trefName: \"db\"\n\t\t\t}\n\t\t}, input, refs);\n\t}\n\tconst refResult = parseContractRef(optionsFrom, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) {\n\t\tif (looksLikeFullHash(optionsFrom)) {\n\t\t\tconst empty = graphIsEmpty(space);\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\tif (empty) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));\n\t\t\treturn notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph), graphTip));\n\t\t}\n\t\treturn notOk(mapRefResolutionError(refResult.failure));\n\t}\n\treturn resolveFromPolicy(refResult.value, input, refs, optionsFrom);\n}\nasync function resolveToForPlan(optionsTo, input) {\n\tconst { space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tconst refResult = parseContractRef(optionsTo, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\tconst resolution = await resolveContractRef(refResult.value, space, {\n\t\texplicitLabel: optionsTo,\n\t\tartifactRole: \"to\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\treturn ok({\n\t\thash,\n\t\tcontract,\n\t\tcontractJson,\n\t\tcontractDts\n\t});\n}\n//#endregion\n//#region src/commands/migration-plan.ts\nasync function runPlannerLeg(planner, migrations, frameworkComponents, contract, fromContract, spaceId, ownership, snapshotsImportPath, resolveImportSpecifier) {\n\tconst fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);\n\tconst plannerResult = planner.plan({\n\t\tcontract,\n\t\tschema: fromSchema,\n\t\tpolicy: { allowedOperationClasses: [\n\t\t\t\"additive\",\n\t\t\t\"widening\",\n\t\t\t\"destructive\",\n\t\t\t\"data\"\n\t\t] },\n\t\tfromContract,\n\t\tframeworkComponents,\n\t\tspaceId,\n\t\townership,\n\t\tsnapshotsImportPath\n\t});\n\tif (plannerResult.kind === \"failure\") return notOk(errorMigrationPlanningFailed({ conflicts: plannerResult.conflicts }));\n\tlet plannedOps = [];\n\tlet hasPlaceholders = false;\n\ttry {\n\t\tplannedOps = await Promise.all(plannerResult.plan.operations);\n\t\tif (plannedOps.length === 0) return notOk(errorMigrationPlanningFailed({ conflicts: [{\n\t\t\tkind: \"unsupportedChange\",\n\t\t\tsummary: \"Contract changed but planner produced no operations. This indicates unsupported or ignored changes.\"\n\t\t}] }));\n\t} catch (e) {\n\t\tif (CliStructuredError.is(e) && e.code === \"MIGRATION.UNFILLED_PLACEHOLDER\") hasPlaceholders = true;\n\t\telse throw e;\n\t}\n\treturn ok({\n\t\tplannedOps,\n\t\tmigrationTsContent: plannerResult.plan.renderTypeScript(resolveImportSpecifier),\n\t\thasPlaceholders\n\t});\n}\nasync function writePlannedMigrationPackage(packageDir, fromHash, toHash, createdAt, leg) {\n\tconst opsForWrite = leg.hasPlaceholders ? [] : leg.plannedOps;\n\tconst metadataWithInvariants = {\n\t\tfrom: fromHash,\n\t\tto: toHash,\n\t\tprovidedInvariants: deriveProvidedInvariants(opsForWrite),\n\t\tcreatedAt: createdAt.toISOString()\n\t};\n\tawait writeMigrationPackage(packageDir, {\n\t\t...metadataWithInvariants,\n\t\tmigrationHash: computeMigrationHash(metadataWithInvariants, opsForWrite)\n\t}, opsForWrite);\n\tawait writeMigrationTs(packageDir, leg.migrationTsContent);\n}\nasync function executeMigrationPlanCommand(options, flags, ui, startTime) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [\n\t\t\t{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: configPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"contract\",\n\t\t\t\tvalue: contractPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"migrations\",\n\t\t\t\tvalue: appMigrationsRelative\n\t\t\t}\n\t\t];\n\t\tif (options.from) details.push({\n\t\t\tlabel: \"from\",\n\t\t\tvalue: options.from\n\t\t});\n\t\tif (options.to) details.push({\n\t\t\tlabel: \"to\",\n\t\t\tvalue: options.to\n\t\t});\n\t\tif (options.name) details.push({\n\t\t\tlabel: \"name\",\n\t\t\tvalue: options.name\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration plan\",\n\t\t\tdescription: \"Plan a migration from contract changes\",\n\t\t\turl: \"https://pris.ly/migration-plan\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t}));\n\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}\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tconst controlAdapter = config.adapter.create(stack);\n\tlet toContract;\n\ttry {\n\t\ttoContract = familyInstance.deserializeContract(JSON.parse(contractJsonContent));\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst rawStorageHash = toContract.storage?.storageHash;\n\tif (typeof rawStorageHash !== \"string\") return notOk(errorContractValidationFailed(\"Contract is missing storageHash\", { where: { path: contractPathAbsolute } }));\n\tlet toStorageHash = rawStorageHash;\n\tlet toArtifacts = null;\n\tlet fromContract = null;\n\tlet fromHash = null;\n\tlet snapshotStartContract = null;\n\tlet isAutoBaseline = false;\n\tconst tolerantAggregateResult = await loadContractSpaceAggregateForCli({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!tolerantAggregateResult.ok) return notOk(tolerantAggregateResult.failure);\n\tconst resolutionSpace = tolerantAggregateResult.value.app;\n\tconst resolutionResult = await resolveFromForPlan({\n\t\toptionsFrom: options.from,\n\t\tspace: resolutionSpace\n\t});\n\tif (!resolutionResult.ok) return notOk(resolutionResult.failure);\n\tswitch (resolutionResult.value.kind) {\n\t\tcase \"greenfield\": break;\n\t\tcase \"graph-node\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tbreak;\n\t\tcase \"ref\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tbreak;\n\t\tcase \"auto-baseline\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tisAutoBaseline = true;\n\t\t\tbreak;\n\t}\n\tif (options.to !== void 0) {\n\t\tconst toResolution = await resolveToForPlan(options.to, { space: resolutionSpace });\n\t\tif (!toResolution.ok) return notOk(toResolution.failure);\n\t\ttoContract = toResolution.value.contract;\n\t\ttoStorageHash = toResolution.value.hash;\n\t\ttoArtifacts = {\n\t\t\tcontractJson: toResolution.value.contractJson,\n\t\t\tcontractDts: toResolution.value.contractDts\n\t\t};\n\t}\n\tconst resolveImportSpecifier = createProjectSpecifierResolver(options.config);\n\tconst seedResult = await runContractSpaceSeedPhase({\n\t\tmigrationsDir,\n\t\textensions: toExtensionInputs(config.extensions ?? [])\n\t});\n\tif (!flags.json && !flags.quiet) {\n\t\tfor (const record of seedResult.seeded) if (record.action === \"updated\") {\n\t\t\tconst pkgSuffix = record.newMigrationDirs.length > 0 ? `; ${record.newMigrationDirs.length} new migration package(s) materialised` : \"\";\n\t\t\tui.step(`Updated ${record.spaceId} to ${record.newHash}${pkgSuffix}`);\n\t\t}\n\t}\n\tconst emittedExtensionDirs = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({\n\t\tspaceId: r.spaceId,\n\t\tdirName\n\t})));\n\tif (fromHash === toStorageHash && !isAutoBaseline) return ok({\n\t\tok: true,\n\t\tnoOp: true,\n\t\tfrom: fromHash,\n\t\tto: toStorageHash,\n\t\toperations: [],\n\t\temittedExtensionDirs,\n\t\tsummary: \"No changes detected between contracts\",\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n\tconst migrations = getTargetMigrations(config.target);\n\tif (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.id}\" does not support migrations` }));\n\tconst aggregateResult = await buildContractSpaceAggregate({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!aggregateResult.ok) return notOk(aggregateResult.failure);\n\tconst aggregate = aggregateResult.value;\n\tconst frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [\n\t\tconfig.target,\n\t\tconfig.adapter,\n\t\t...config.extensions ?? []\n\t]);\n\tasync function writeDestinationSnapshot(destHash) {\n\t\tif (toArtifacts !== null) {\n\t\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\t\tcontractJson: toArtifacts.contractJson,\n\t\t\t\tcontractDts: toArtifacts.contractDts\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);\n\t\tconst [contractJsonRaw, contractDts] = await Promise.all([readFile(destinationArtifacts.jsonPath, \"utf-8\"), readFile(destinationArtifacts.dtsPath, \"utf-8\")]);\n\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\tcontractJson: JSON.parse(contractJsonRaw),\n\t\t\tcontractDts\n\t\t});\n\t}\n\ttry {\n\t\tconst planner = migrations.createPlanner(controlAdapter);\n\t\tif (isAutoBaseline && fromHash !== null && fromContract !== null && snapshotStartContract !== null) {\n\t\t\tconst baselineTimestamp = /* @__PURE__ */ new Date();\n\t\t\tconst deltaTimestamp = new Date(baselineTimestamp.getTime() + 6e4);\n\t\t\tconst baselineDirName = formatMigrationDirName(baselineTimestamp, \"baseline\");\n\t\t\tconst deltaDirName = formatMigrationDirName(deltaTimestamp, options.name ?? \"migration\");\n\t\t\tconst baselinePackageDir = join(appMigrationsDir, baselineDirName);\n\t\t\tconst deltaPackageDir = join(appMigrationsDir, deltaDirName);\n\t\t\tconst baselineLeg = await runPlannerLeg(planner, migrations, frameworkComponents, fromContract, null, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(baselinePackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!baselineLeg.ok) return notOk(baselineLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(baselinePackageDir, null, fromHash, baselineTimestamp, baselineLeg.value);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tif (fromHash === toStorageHash) {\n\t\t\t\tconst baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;\n\t\t\t\tif (baselineLeg.value.hasPlaceholders) {\n\t\t\t\t\tconst baselineDir = relative(process.cwd(), baselinePackageDir);\n\t\t\t\t\treturn ok({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tnoOp: false,\n\t\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\t\tdir: baselineDir,\n\t\t\t\t\t\tbaselineDir,\n\t\t\t\t\t\toperations: [],\n\t\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t\tpendingPlaceholders: true,\n\t\t\t\t\t\tsummary: \"Planned baseline with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(baselineOps) : void 0;\n\t\t\t\treturn ok({\n\t\t\t\t\tok: true,\n\t\t\t\t\tnoOp: false,\n\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\t\toperations: baselineOps.map((op) => ({\n\t\t\t\t\t\tid: op.id,\n\t\t\t\t\t\tlabel: op.label,\n\t\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t\t})),\n\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\t\tsummary: buildAutoBaselinePlanSummary(0, emittedExtensionDirs.length),\n\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(deltaPackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(deltaPackageDir, fromHash, toStorageHash, deltaTimestamp, deltaLeg.value);\n\t\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tconst deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;\n\t\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: [],\n\t\t\t\temittedExtensionDirs,\n\t\t\t\tpendingPlaceholders: true,\n\t\t\t\tsummary: \"Planned baseline + migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(deltaOps) : void 0;\n\t\t\treturn ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: deltaOps.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\temittedExtensionDirs,\n\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\tsummary: buildAutoBaselinePlanSummary(deltaOps.length, emittedExtensionDirs.length),\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t}\n\t\tconst timestamp = /* @__PURE__ */ new Date();\n\t\tconst packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? \"migration\"));\n\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(packageDir, migrationsDir), resolveImportSpecifier);\n\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\tawait writePlannedMigrationPackage(packageDir, fromHash, toStorageHash, timestamp, deltaLeg.value);\n\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\tif (snapshotStartContract !== null) await writeContractSnapshot(migrationsDir, snapshotStartContract.fromHash, {\n\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t});\n\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: [],\n\t\t\temittedExtensionDirs,\n\t\t\tpendingPlaceholders: true,\n\t\t\tsummary: \"Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t\tconst plannedOps = deltaLeg.value.plannedOps;\n\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(plannedOps) : void 0;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: plannedOps.map((op) => ({\n\t\t\t\tid: op.id,\n\t\t\t\tlabel: op.label,\n\t\t\t\toperationClass: op.operationClass\n\t\t\t})),\n\t\t\temittedExtensionDirs,\n\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\tsummary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),\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 (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\treturn notOk(errorUnexpected(message, { why: `Unexpected error during migration plan: ${message}` }));\n\t}\n}\nfunction createMigrationPlanCommand() {\n\tconst command = new Command(\"plan\");\n\tsetCommandDescriptions(command, \"Plan a migration from contract changes\", \"Compares the emitted contract against the latest on-disk migration state and\\nproduces a new migration package with the required operations. No database\\nconnection is needed — this is a fully offline operation.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration plan\",\n\t\t\"prisma-next migration plan --name add-users-table\",\n\t\t\"prisma-next migration plan --to <migration-dir>^ --name rollback\"\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--name <slug>\", \"Name slug for the migration directory\", \"migration\").option(\"--from <contract>\", \"Starting contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--to <contract>\", \"Destination contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path); defaults to the emitted contract\").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 executeMigrationPlanCommand(options, flags, ui, startTime), flags, ui, (planResult) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(planResult, null, 2));\n\t\t\telse if (!flags.quiet) ui.log(formatMigrationPlanOutput(planResult, flags));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n/**\n* Compose the success-line summary so the cross-space side effect\n* (extension-space migration packages materialised on disk during\n* this `plan` run) is visible in the top line — not just in the\n* step log above it.\n*\n* Example outputs:\n* - `Planned 3 operation(s)` (app-space-only project)\n* - `Planned 3 operation(s); materialised 1 extension-space migration` (one extension)\n* - `Planned 3 operation(s); materialised 2 extension-space migrations` (two extensions)\n*\n* Locks AC3 at the summary-line level: a reader of the success line\n* can tell that something happened beyond the app space.\n*/\nfunction buildPlanSummary(plannedOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned ${plannedOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction buildAutoBaselinePlanSummary(deltaOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned baseline + ${deltaOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction formatMigrationPlanOutput(result, flags) {\n\tconst lines = [];\n\tconst useColor = flags.color !== false;\n\tconst green_ = useColor ? (s) => `\\x1b[32m${s}\\x1b[0m` : (s) => s;\n\tconst yellow_ = useColor ? (s) => `\\x1b[33m${s}\\x1b[0m` : (s) => s;\n\tconst dim_ = useColor ? (s) => `\\x1b[2m${s}\\x1b[0m` : (s) => s;\n\tfunction appendEmittedExtensions() {\n\t\tif (result.emittedExtensionDirs.length === 0) return;\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(\"Emitted extension migrations:\"));\n\t\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(` ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\t\tlines.push(\"\");\n\t\tlines.push(`Next: review the extension migrations above, then run ${green_(\"prisma-next migrate\")}.`);\n\t}\n\tif (result.noOp) {\n\t\tlines.push(`${green_(\"✔\")} No changes detected`);\n\t\tlines.push(dim_(` from: ${result.from}`));\n\t\tlines.push(dim_(` to: ${result.to}`));\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tif (result.pendingPlaceholders) {\n\t\tlines.push(`${yellow_(\"⚠\")} ${result.summary}`);\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`from: ${result.from}`));\n\t\tlines.push(dim_(`to: ${result.to}`));\n\t\tif (result.dir) lines.push(dim_(`dir: ${result.dir}`));\n\t\tlines.push(\"\");\n\t\tlines.push(\"Open migration.ts and replace each `placeholder(...)` call with your actual query.\");\n\t\tlines.push(`Then run: ${green_(`node ${result.dir ?? \"<dir>\"}/migration.ts`)}`);\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tlines.push(`${green_(\"✔\")} ${result.summary}`);\n\tlines.push(\"\");\n\tif (result.operations.length > 0) {\n\t\tlines.push(dim_(\"│\"));\n\t\tfor (let i = 0; i < result.operations.length; i++) {\n\t\t\tconst op = result.operations[i];\n\t\t\tconst treeChar = i === result.operations.length - 1 ? \"└\" : \"├\";\n\t\t\tconst destructiveMarker = op.operationClass === \"destructive\" ? ` ${yellow_(\"(destructive)\")}` : \"\";\n\t\t\tlines.push(`${dim_(treeChar)}─ ${op.label}${destructiveMarker}`);\n\t\t}\n\t\tif (result.operations.some((op) => op.operationClass === \"destructive\")) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(`${yellow_(\"⚠\")} This migration contains destructive operations that may cause data loss.`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\tlines.push(dim_(`from: ${result.from}`));\n\tlines.push(dim_(`to: ${result.to}`));\n\tif (result.baselineDir) lines.push(dim_(`Baseline → ${result.baselineDir}`));\n\tif (result.dir) lines.push(dim_(`App space → ${result.dir}`));\n\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(`Extension space ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\tlines.push(\"\");\n\tconst reviewTarget = result.baselineDir !== void 0 && result.dir !== void 0 ? `${result.baselineDir} and ${result.dir}` : result.baselineDir ?? result.dir ?? \"<dir>\";\n\tlines.push(`Next: review ${green_(reviewTarget)} if needed, then run ${green_(\"prisma-next migrate\")}.`);\n\tif (result.preview && result.preview.statements.length > 0) {\n\t\tconst allSql = result.preview.statements.every((s) => s.language === \"sql\");\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(allSql ? \"DDL preview\" : \"Operation preview\"));\n\t\tlines.push(\"\");\n\t\tfor (const statement of result.preview.statements) {\n\t\t\tconst trimmed = statement.text.trim();\n\t\t\tif (!trimmed) continue;\n\t\t\tconst line = statement.language === \"sql\" && !trimmed.endsWith(\";\") ? `${trimmed};` : trimmed;\n\t\t\tlines.push(line);\n\t\t}\n\t}\n\tif (flags.verbose && result.timings) {\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`Total time: ${result.timings.total}ms`));\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Resolve a migration package by **target contract hash** (`metadata.to`)\n* using exact match or prefix match.\n*\n* Note: matches `metadata.to` (the contract hash this migration produces),\n* not `metadata.migrationHash` (the package's content-addressed identity).\n* Tries exact match first, then prefix match. Returns the matched package on\n* success, or a discriminated failure indicating whether the prefix was\n* ambiguous or simply not found.\n*\n* @internal Exported for testing only.\n*/\nfunction resolveBundleByPrefix(bundles, needle) {\n\tconst exact = bundles.find((p) => p.metadata.to === needle);\n\tif (exact) return ok(exact);\n\tconst candidates = bundles.filter((p) => p.metadata.to.startsWith(needle));\n\tif (candidates.length === 1) return ok(candidates[0]);\n\tif (candidates.length > 1) return notOk({\n\t\treason: \"ambiguous\",\n\t\tcount: candidates.length\n\t});\n\treturn notOk({ reason: \"not-found\" });\n}\n//#endregion\nexport { formatMigrationPlanOutput as n, resolveBundleByPrefix as r, createMigrationPlanCommand as t };\n\n//# sourceMappingURL=migration-plan-q_L84PN1.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,eAAe,0BAA0B,QAAQ;CAChD,MAAM,UAAU,cAAc,OAAO,WAAW,QAAQ,SAAS,KAAK,kBAAkB,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU;EAC9G,SAAS,KAAK;EACd,eAAe;EACf,aAAa,KAAK,cAAc;EAChC,QAAQ,KAAK;CACd,EAAE,IAAI,UAAU,MAAM,OAAO,UAAU;CACvC,MAAM,oCAAoC,IAAI,IAAI;CAClD,KAAK,MAAM,QAAQ,OAAO,YAAY,IAAI,KAAK,kBAAkB,KAAK,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AAG,KAAK;CAC1B,MAAM,aAAa,QAAQ,QAAQ,MAAM,EAAE,SAAS,GAAG,WAAW,MAAM,CAAC;CACzE,IAAI,WAAW,WAAW,GAAG,OAAO,GAAG,WAAW,EAAE;CACpD,IAAI,WAAW,SAAS,GAAG,OAAO,MAAM;EACvC,QAAQ;EACR,OAAO,WAAW;CACnB,CAAC;CACD,OAAO,MAAM,EAAE,QAAQ,YAAY,CAAC;AACrC"}
1
+ {"version":3,"file":"migration-plan-q_L84PN1-ClkGgtVz.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-plan-q_L84PN1.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, Q as errorPlanForgotTheFlag, W as errorFileNotFound, X as errorMigrationPlanningFailed, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, it as errorSnapshotMissing, l as setCommandDescriptions, lt as mapMigrationToolsError, o as resolveContractPath, ot as errorTargetMigrationNotSupported, r as getTargetMigrations, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"./command-helpers-CAoXqAY9.mjs\";\nimport { t as assertFrameworkComponentsCompatible } from \"./framework-components-CjshQKHA.mjs\";\nimport { t as createProjectSpecifierResolver } from \"./project-import-root-CpwLCDLY.mjs\";\nimport { c as toExtensionInputs, i as loadContractSpaceAggregateForCli, t as buildContractSpaceAggregate } from \"./contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { t as mapContractAtError } from \"./contract-at-errors-BX7w-p19.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join, relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { createControlStack, hasOperationPreview } from \"@internal/framework-components/control\";\nimport { emitContractSpaceArtifacts, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory } from \"@internal/migration-tools/spaces\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { assertHashIsGraphNode, findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { snapshotsImportPathFrom, writeContractSnapshot } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\nimport { computeMigrationHash } from \"@internal/migration-tools/hash\";\nimport { formatMigrationDirName, materialiseExtensionMigrationPackageIfMissing, writeMigrationPackage } from \"@internal/migration-tools/io\";\nimport { writeMigrationTs } from \"@internal/migration-tools/migration-ts\";\nimport { deriveProvidedInvariants } from \"@internal/migration-tools/invariants\";\n//#region src/utils/contract-space-seed-phase.ts\n/**\n* Phase-1 of the two-phase `migration plan` pipeline (sub-spec § 4).\n*\n* For every extension that exposes a `contractSpace`:\n*\n* 1. Read the on-disk head ref (returns `null` on first emit).\n* 2. Write the head contract into the migrations-root snapshot store\n* (write-if-absent, keyed by hash) and unconditionally re-emit\n* `refs/head.json`, via {@link emitContractSpaceArtifacts}. The\n* framework owns `refs/head.json`; re-emit is the contract for that\n* file. The snapshot itself is only written once per distinct hash.\n* 3. Materialise any descriptor-shipped migration packages not yet on\n* disk via {@link materialiseExtensionMigrationPackageIfMissing}.\n* Existing packages are left untouched (by-existence skip).\n*\n* The return value lets the caller render a per-space status line and\n* lets the phase-2 aggregate loader run on a now-consistent disk state\n* (every loaded extension is guaranteed to have its head ref pinned\n* to the descriptor's hash and to ship every package the descriptor\n* declares).\n*\n* Output ordering is deterministic and alphabetical by spaceId (via\n* {@link planAllSpaces}, which also detects duplicate spaceIds). This\n* matches the canonical sort order used by every other aggregate\n* surface (`migrate`, `migration status`, the runner).\n*/\nasync function runContractSpaceSeedPhase(inputs) {\n\tconst planned = planAllSpaces(inputs.extensions.filter((pack) => pack.contractSpace !== void 0).map((pack) => ({\n\t\tspaceId: pack.id,\n\t\tpriorContract: null,\n\t\tnewContract: pack.contractSpace.contractJson,\n\t\t__pack: pack.contractSpace\n\t})), (input) => input.__pack.migrations);\n\tconst descriptorBySpace = /* @__PURE__ */ new Map();\n\tfor (const pack of inputs.extensions) if (pack.contractSpace !== void 0) descriptorBySpace.set(pack.id, pack.contractSpace);\n\tconst seeded = [];\n\tfor (const space of planned) {\n\t\tconst descriptor = descriptorBySpace.get(space.spaceId);\n\t\tif (descriptor === void 0) continue;\n\t\tconst priorHash = (await readContractSpaceHeadRef(inputs.migrationsDir, space.spaceId))?.hash ?? null;\n\t\tawait emitContractSpaceArtifacts(inputs.migrationsDir, space.spaceId, {\n\t\t\tcontract: descriptor.contractJson,\n\t\t\tcontractDts: buildPlaceholderContractDts(space.spaceId),\n\t\t\theadRef: {\n\t\t\t\thash: descriptor.headRef.hash,\n\t\t\t\tinvariants: descriptor.headRef.invariants\n\t\t\t}\n\t\t});\n\t\tconst spaceDir = spaceMigrationDirectory(inputs.migrationsDir, space.spaceId);\n\t\tconst newMigrationDirs = [];\n\t\tfor (const pkg of space.migrationPackages) {\n\t\t\tconst { written } = await materialiseExtensionMigrationPackageIfMissing(spaceDir, pkg);\n\t\t\tif (written) newMigrationDirs.push(pkg.dirName);\n\t\t}\n\t\tconst action = priorHash !== descriptor.headRef.hash || newMigrationDirs.length > 0 ? \"updated\" : \"unchanged\";\n\t\tseeded.push({\n\t\t\tspaceId: space.spaceId,\n\t\t\taction,\n\t\t\tpriorHash,\n\t\t\tnewHash: descriptor.headRef.hash,\n\t\t\tnewMigrationDirs\n\t\t});\n\t}\n\treturn { seeded };\n}\n/**\n* Placeholder `.d.ts` content for an extension space's on-disk mirror.\n*\n* Rendering a fully-typed `.d.ts` for an extension contract requires\n* the SQL-family renderer with the codec / typemap registry threaded\n* through; until that integration ships, the on-disk `.d.ts` is a\n* stub `export {};` module that documents how consumers should\n* validate the sibling `contract.json`. The stub typechecks on its\n* own and does not need any TypeScript suppressions.\n*/\nfunction buildPlaceholderContractDts(spaceId) {\n\treturn [\n\t\t\"/**\",\n\t\t` * Placeholder \\`.d.ts\\` for extension space \"${spaceId}\".`,\n\t\t\" *\",\n\t\t\" * The framework re-emits this file on every `migration plan` run\",\n\t\t\" * alongside `contract.json` and `refs/head.json`. A typed `.d.ts`\",\n\t\t\" * rendering pass for extension contracts is tracked separately;\",\n\t\t\" * until that ships, consumers should import `contract.json`\",\n\t\t\" * and pass it through the target descriptor’s `contractSerializer`.\",\n\t\t\" */\",\n\t\t\"export {};\",\n\t\t\"\"\n\t].join(\"\\n\");\n}\n//#endregion\n//#region src/utils/plan-resolution.ts\nconst FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;\nfunction looksLikeFullHash(input) {\n\treturn FULL_HASH_PATTERN.test(input);\n}\nfunction graphIsEmpty(space) {\n\treturn space.packages.length === 0;\n}\nfunction getReachableRefs(refs, graph) {\n\treturn Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{\n\t\tname,\n\t\thash: entry.hash\n\t}] : []).sort((a, b) => a.name.localeCompare(b.name));\n}\nfunction assertFromIsGraphNode(fromHash, graph, refs, graphTipHash) {\n\ttry {\n\t\tassertHashIsGraphNode(fromHash, graph);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.HASH_NOT_IN_GRAPH\") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), graphTipHash);\n\t\tthrow error;\n\t}\n}\nasync function resolveContractRef(parsed, space, options) {\n\tconst { hash, provenance } = parsed;\n\tconst refName = provenance.kind === \"ref\" ? provenance.refName : void 0;\n\ttry {\n\t\tconst at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);\n\t\tif (at.provenance === \"ref\") return ok({\n\t\t\tkind: \"ref\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t\treturn ok({\n\t\t\tkind: \"graph-node\",\n\t\t\thash: at.hash,\n\t\t\tcontract: at.contract,\n\t\t\tcontractJson: at.contractJson,\n\t\t\tcontractDts: at.contractDts\n\t\t});\n\t} catch (error) {\n\t\treturn mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);\n\t}\n}\nasync function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {\n\tconst resolution = await resolveContractRef(parsed, input.space, {\n\t\t...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},\n\t\tartifactRole: \"from\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tif (resolution.value.kind === \"graph-node\") return ok({\n\t\tkind: \"graph-node\",\n\t\tfromHash: resolution.value.hash,\n\t\tfromContract: resolution.value.contract\n\t});\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\tif (graphIsEmpty(input.space)) return ok({\n\t\tkind: \"auto-baseline\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n\tconst graph = input.space.graph();\n\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\ttry {\n\t\tassertFromIsGraphNode(hash, graph, refs, graphTip);\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\treturn ok({\n\t\tkind: \"ref\",\n\t\tfromHash: hash,\n\t\tfromContract: contract,\n\t\tcontractDts,\n\t\tcontractJson\n\t});\n}\nasync function resolveFromForPlan(input) {\n\tconst { optionsFrom, space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tif (optionsFrom === void 0) {\n\t\tconst dbRef = refs[\"db\"];\n\t\tif (!dbRef) return ok({\n\t\t\tkind: \"greenfield\",\n\t\t\tfromHash: null,\n\t\t\tfromContract: null\n\t\t});\n\t\treturn resolveFromPolicy({\n\t\t\thash: dbRef.hash,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"ref\",\n\t\t\t\trefName: \"db\"\n\t\t\t}\n\t\t}, input, refs);\n\t}\n\tconst refResult = parseContractRef(optionsFrom, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) {\n\t\tif (looksLikeFullHash(optionsFrom)) {\n\t\t\tconst empty = graphIsEmpty(space);\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\tif (empty) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));\n\t\t\treturn notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph), graphTip));\n\t\t}\n\t\treturn notOk(mapRefResolutionError(refResult.failure));\n\t}\n\treturn resolveFromPolicy(refResult.value, input, refs, optionsFrom);\n}\nasync function resolveToForPlan(optionsTo, input) {\n\tconst { space } = input;\n\tconst graph = space.graph();\n\tconst refs = space.refs;\n\tconst refResult = parseContractRef(optionsTo, {\n\t\tgraph,\n\t\trefs\n\t});\n\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\tconst resolution = await resolveContractRef(refResult.value, space, {\n\t\texplicitLabel: optionsTo,\n\t\tartifactRole: \"to\"\n\t});\n\tif (!resolution.ok) return resolution;\n\tconst { hash, contract, contractJson, contractDts } = resolution.value;\n\treturn ok({\n\t\thash,\n\t\tcontract,\n\t\tcontractJson,\n\t\tcontractDts\n\t});\n}\n//#endregion\n//#region src/commands/migration-plan.ts\nasync function runPlannerLeg(planner, migrations, frameworkComponents, contract, fromContract, spaceId, ownership, snapshotsImportPath, resolveImportSpecifier) {\n\tconst fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);\n\tconst plannerResult = planner.plan({\n\t\tcontract,\n\t\tschema: fromSchema,\n\t\tpolicy: { allowedOperationClasses: [\n\t\t\t\"additive\",\n\t\t\t\"widening\",\n\t\t\t\"destructive\",\n\t\t\t\"data\"\n\t\t] },\n\t\tfromContract,\n\t\tframeworkComponents,\n\t\tspaceId,\n\t\townership,\n\t\tsnapshotsImportPath\n\t});\n\tif (plannerResult.kind === \"failure\") return notOk(errorMigrationPlanningFailed({ conflicts: plannerResult.conflicts }));\n\tlet plannedOps = [];\n\tlet hasPlaceholders = false;\n\ttry {\n\t\tplannedOps = await Promise.all(plannerResult.plan.operations);\n\t\tif (plannedOps.length === 0) return notOk(errorMigrationPlanningFailed({ conflicts: [{\n\t\t\tkind: \"unsupportedChange\",\n\t\t\tsummary: \"Contract changed but planner produced no operations. This indicates unsupported or ignored changes.\"\n\t\t}] }));\n\t} catch (e) {\n\t\tif (CliStructuredError.is(e) && e.code === \"MIGRATION.UNFILLED_PLACEHOLDER\") hasPlaceholders = true;\n\t\telse throw e;\n\t}\n\treturn ok({\n\t\tplannedOps,\n\t\tmigrationTsContent: plannerResult.plan.renderTypeScript(resolveImportSpecifier),\n\t\thasPlaceholders\n\t});\n}\nasync function writePlannedMigrationPackage(packageDir, fromHash, toHash, createdAt, leg) {\n\tconst opsForWrite = leg.hasPlaceholders ? [] : leg.plannedOps;\n\tconst metadataWithInvariants = {\n\t\tfrom: fromHash,\n\t\tto: toHash,\n\t\tprovidedInvariants: deriveProvidedInvariants(opsForWrite),\n\t\tcreatedAt: createdAt.toISOString()\n\t};\n\tawait writeMigrationPackage(packageDir, {\n\t\t...metadataWithInvariants,\n\t\tmigrationHash: computeMigrationHash(metadataWithInvariants, opsForWrite)\n\t}, opsForWrite);\n\tawait writeMigrationTs(packageDir, leg.migrationTsContent);\n}\nasync function executeMigrationPlanCommand(options, flags, ui, startTime) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [\n\t\t\t{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: configPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"contract\",\n\t\t\t\tvalue: contractPath\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"migrations\",\n\t\t\t\tvalue: appMigrationsRelative\n\t\t\t}\n\t\t];\n\t\tif (options.from) details.push({\n\t\t\tlabel: \"from\",\n\t\t\tvalue: options.from\n\t\t});\n\t\tif (options.to) details.push({\n\t\t\tlabel: \"to\",\n\t\t\tvalue: options.to\n\t\t});\n\t\tif (options.name) details.push({\n\t\t\tlabel: \"name\",\n\t\t\tvalue: options.name\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration plan\",\n\t\t\tdescription: \"Plan a migration from contract changes\",\n\t\t\turl: \"https://pris.ly/migration-plan\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t}));\n\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}\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tconst controlAdapter = config.adapter.create(stack);\n\tlet toContract;\n\ttry {\n\t\ttoContract = familyInstance.deserializeContract(JSON.parse(contractJsonContent));\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst rawStorageHash = toContract.storage?.storageHash;\n\tif (typeof rawStorageHash !== \"string\") return notOk(errorContractValidationFailed(\"Contract is missing storageHash\", { where: { path: contractPathAbsolute } }));\n\tlet toStorageHash = rawStorageHash;\n\tlet toArtifacts = null;\n\tlet fromContract = null;\n\tlet fromHash = null;\n\tlet snapshotStartContract = null;\n\tlet isAutoBaseline = false;\n\tconst tolerantAggregateResult = await loadContractSpaceAggregateForCli({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!tolerantAggregateResult.ok) return notOk(tolerantAggregateResult.failure);\n\tconst resolutionSpace = tolerantAggregateResult.value.app;\n\tconst resolutionResult = await resolveFromForPlan({\n\t\toptionsFrom: options.from,\n\t\tspace: resolutionSpace\n\t});\n\tif (!resolutionResult.ok) return notOk(resolutionResult.failure);\n\tswitch (resolutionResult.value.kind) {\n\t\tcase \"greenfield\": break;\n\t\tcase \"graph-node\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tbreak;\n\t\tcase \"ref\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tbreak;\n\t\tcase \"auto-baseline\":\n\t\t\tfromHash = resolutionResult.value.fromHash;\n\t\t\tfromContract = resolutionResult.value.fromContract;\n\t\t\tsnapshotStartContract = {\n\t\t\t\tfromHash: resolutionResult.value.fromHash,\n\t\t\t\tcontractJson: resolutionResult.value.contractJson,\n\t\t\t\tcontractDts: resolutionResult.value.contractDts\n\t\t\t};\n\t\t\tisAutoBaseline = true;\n\t\t\tbreak;\n\t}\n\tif (options.to !== void 0) {\n\t\tconst toResolution = await resolveToForPlan(options.to, { space: resolutionSpace });\n\t\tif (!toResolution.ok) return notOk(toResolution.failure);\n\t\ttoContract = toResolution.value.contract;\n\t\ttoStorageHash = toResolution.value.hash;\n\t\ttoArtifacts = {\n\t\t\tcontractJson: toResolution.value.contractJson,\n\t\t\tcontractDts: toResolution.value.contractDts\n\t\t};\n\t}\n\tconst resolveImportSpecifier = createProjectSpecifierResolver(options.config);\n\tconst seedResult = await runContractSpaceSeedPhase({\n\t\tmigrationsDir,\n\t\textensions: toExtensionInputs(config.extensions ?? [])\n\t});\n\tif (!flags.json && !flags.quiet) {\n\t\tfor (const record of seedResult.seeded) if (record.action === \"updated\") {\n\t\t\tconst pkgSuffix = record.newMigrationDirs.length > 0 ? `; ${record.newMigrationDirs.length} new migration package(s) materialised` : \"\";\n\t\t\tui.step(`Updated ${record.spaceId} to ${record.newHash}${pkgSuffix}`);\n\t\t}\n\t}\n\tconst emittedExtensionDirs = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({\n\t\tspaceId: r.spaceId,\n\t\tdirName\n\t})));\n\tif (fromHash === toStorageHash && !isAutoBaseline) return ok({\n\t\tok: true,\n\t\tnoOp: true,\n\t\tfrom: fromHash,\n\t\tto: toStorageHash,\n\t\toperations: [],\n\t\temittedExtensionDirs,\n\t\tsummary: \"No changes detected between contracts\",\n\t\ttimings: { total: Date.now() - startTime }\n\t});\n\tconst migrations = getTargetMigrations(config.target);\n\tif (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target \"${config.target.id}\" does not support migrations` }));\n\tconst aggregateResult = await buildContractSpaceAggregate({\n\t\ttargetId: config.target.targetId,\n\t\tmigrationsDir,\n\t\tappContract: toContract,\n\t\textensions: config.extensions ?? [],\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tif (!aggregateResult.ok) return notOk(aggregateResult.failure);\n\tconst aggregate = aggregateResult.value;\n\tconst frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [\n\t\tconfig.target,\n\t\tconfig.adapter,\n\t\t...config.extensions ?? []\n\t]);\n\tasync function writeDestinationSnapshot(destHash) {\n\t\tif (toArtifacts !== null) {\n\t\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\t\tcontractJson: toArtifacts.contractJson,\n\t\t\t\tcontractDts: toArtifacts.contractDts\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);\n\t\tconst [contractJsonRaw, contractDts] = await Promise.all([readFile(destinationArtifacts.jsonPath, \"utf-8\"), readFile(destinationArtifacts.dtsPath, \"utf-8\")]);\n\t\tawait writeContractSnapshot(migrationsDir, destHash, {\n\t\t\tcontractJson: JSON.parse(contractJsonRaw),\n\t\t\tcontractDts\n\t\t});\n\t}\n\ttry {\n\t\tconst planner = migrations.createPlanner(controlAdapter);\n\t\tif (isAutoBaseline && fromHash !== null && fromContract !== null && snapshotStartContract !== null) {\n\t\t\tconst baselineTimestamp = /* @__PURE__ */ new Date();\n\t\t\tconst deltaTimestamp = new Date(baselineTimestamp.getTime() + 6e4);\n\t\t\tconst baselineDirName = formatMigrationDirName(baselineTimestamp, \"baseline\");\n\t\t\tconst deltaDirName = formatMigrationDirName(deltaTimestamp, options.name ?? \"migration\");\n\t\t\tconst baselinePackageDir = join(appMigrationsDir, baselineDirName);\n\t\t\tconst deltaPackageDir = join(appMigrationsDir, deltaDirName);\n\t\t\tconst baselineLeg = await runPlannerLeg(planner, migrations, frameworkComponents, fromContract, null, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(baselinePackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!baselineLeg.ok) return notOk(baselineLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(baselinePackageDir, null, fromHash, baselineTimestamp, baselineLeg.value);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tif (fromHash === toStorageHash) {\n\t\t\t\tconst baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;\n\t\t\t\tif (baselineLeg.value.hasPlaceholders) {\n\t\t\t\t\tconst baselineDir = relative(process.cwd(), baselinePackageDir);\n\t\t\t\t\treturn ok({\n\t\t\t\t\t\tok: true,\n\t\t\t\t\t\tnoOp: false,\n\t\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\t\tdir: baselineDir,\n\t\t\t\t\t\tbaselineDir,\n\t\t\t\t\t\toperations: [],\n\t\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t\tpendingPlaceholders: true,\n\t\t\t\t\t\tsummary: \"Planned baseline with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(baselineOps) : void 0;\n\t\t\t\treturn ok({\n\t\t\t\t\tok: true,\n\t\t\t\t\tnoOp: false,\n\t\t\t\t\tfrom: fromHash,\n\t\t\t\t\tto: toStorageHash,\n\t\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\t\toperations: baselineOps.map((op) => ({\n\t\t\t\t\t\tid: op.id,\n\t\t\t\t\t\tlabel: op.label,\n\t\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t\t})),\n\t\t\t\t\temittedExtensionDirs,\n\t\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\t\tsummary: buildAutoBaselinePlanSummary(0, emittedExtensionDirs.length),\n\t\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(deltaPackageDir, migrationsDir), resolveImportSpecifier);\n\t\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\t\tawait writePlannedMigrationPackage(deltaPackageDir, fromHash, toStorageHash, deltaTimestamp, deltaLeg.value);\n\t\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\t\tawait writeContractSnapshot(migrationsDir, fromHash, {\n\t\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t\t});\n\t\t\tconst deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;\n\t\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: [],\n\t\t\t\temittedExtensionDirs,\n\t\t\t\tpendingPlaceholders: true,\n\t\t\t\tsummary: \"Planned baseline + migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(deltaOps) : void 0;\n\t\t\treturn ok({\n\t\t\t\tok: true,\n\t\t\t\tnoOp: false,\n\t\t\t\tfrom: fromHash,\n\t\t\t\tto: toStorageHash,\n\t\t\t\tdir: relative(process.cwd(), deltaPackageDir),\n\t\t\t\tbaselineDir: relative(process.cwd(), baselinePackageDir),\n\t\t\t\toperations: deltaOps.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\temittedExtensionDirs,\n\t\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\t\tsummary: buildAutoBaselinePlanSummary(deltaOps.length, emittedExtensionDirs.length),\n\t\t\t\ttimings: { total: Date.now() - startTime }\n\t\t\t});\n\t\t}\n\t\tconst timestamp = /* @__PURE__ */ new Date();\n\t\tconst packageDir = join(appMigrationsDir, formatMigrationDirName(timestamp, options.name ?? \"migration\"));\n\t\tconst deltaLeg = await runPlannerLeg(planner, migrations, frameworkComponents, aggregate.app.contract(), fromContract, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(packageDir, migrationsDir), resolveImportSpecifier);\n\t\tif (!deltaLeg.ok) return notOk(deltaLeg.failure);\n\t\tawait writePlannedMigrationPackage(packageDir, fromHash, toStorageHash, timestamp, deltaLeg.value);\n\t\tawait writeDestinationSnapshot(toStorageHash);\n\t\tif (snapshotStartContract !== null) await writeContractSnapshot(migrationsDir, snapshotStartContract.fromHash, {\n\t\t\tcontractJson: snapshotStartContract.contractJson,\n\t\t\tcontractDts: snapshotStartContract.contractDts\n\t\t});\n\t\tif (deltaLeg.value.hasPlaceholders) return ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: [],\n\t\t\temittedExtensionDirs,\n\t\t\tpendingPlaceholders: true,\n\t\t\tsummary: \"Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit\",\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t\tconst plannedOps = deltaLeg.value.plannedOps;\n\t\tconst preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(plannedOps) : void 0;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tnoOp: false,\n\t\t\tfrom: fromHash,\n\t\t\tto: toStorageHash,\n\t\t\tdir: relative(process.cwd(), packageDir),\n\t\t\toperations: plannedOps.map((op) => ({\n\t\t\t\tid: op.id,\n\t\t\t\tlabel: op.label,\n\t\t\t\toperationClass: op.operationClass\n\t\t\t})),\n\t\t\temittedExtensionDirs,\n\t\t\t...preview !== void 0 ? { preview } : {},\n\t\t\tsummary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),\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 (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\treturn notOk(errorUnexpected(message, { why: `Unexpected error during migration plan: ${message}` }));\n\t}\n}\nfunction createMigrationPlanCommand() {\n\tconst command = new Command(\"plan\");\n\tsetCommandDescriptions(command, \"Plan a migration from contract changes\", \"Compares the emitted contract against the latest on-disk migration state and\\nproduces a new migration package with the required operations. No database\\nconnection is needed — this is a fully offline operation.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration plan\",\n\t\t\"prisma-next migration plan --name add-users-table\",\n\t\t\"prisma-next migration plan --to <migration-dir>^ --name rollback\"\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--name <slug>\", \"Name slug for the migration directory\", \"migration\").option(\"--from <contract>\", \"Starting contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--to <contract>\", \"Destination contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path); defaults to the emitted contract\").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 executeMigrationPlanCommand(options, flags, ui, startTime), flags, ui, (planResult) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(planResult, null, 2));\n\t\t\telse if (!flags.quiet) ui.log(formatMigrationPlanOutput(planResult, flags));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n/**\n* Compose the success-line summary so the cross-space side effect\n* (extension-space migration packages materialised on disk during\n* this `plan` run) is visible in the top line — not just in the\n* step log above it.\n*\n* Example outputs:\n* - `Planned 3 operation(s)` (app-space-only project)\n* - `Planned 3 operation(s); materialised 1 extension-space migration` (one extension)\n* - `Planned 3 operation(s); materialised 2 extension-space migrations` (two extensions)\n*\n* Locks AC3 at the summary-line level: a reader of the success line\n* can tell that something happened beyond the app space.\n*/\nfunction buildPlanSummary(plannedOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned ${plannedOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction buildAutoBaselinePlanSummary(deltaOpsCount, emittedExtensionDirsCount) {\n\tconst base = `Planned baseline + ${deltaOpsCount} operation(s)`;\n\tif (emittedExtensionDirsCount === 0) return base;\n\treturn `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? \"extension-space migration\" : \"extension-space migrations\"}`;\n}\nfunction formatMigrationPlanOutput(result, flags) {\n\tconst lines = [];\n\tconst useColor = flags.color !== false;\n\tconst green_ = useColor ? (s) => `\\x1b[32m${s}\\x1b[0m` : (s) => s;\n\tconst yellow_ = useColor ? (s) => `\\x1b[33m${s}\\x1b[0m` : (s) => s;\n\tconst dim_ = useColor ? (s) => `\\x1b[2m${s}\\x1b[0m` : (s) => s;\n\tfunction appendEmittedExtensions() {\n\t\tif (result.emittedExtensionDirs.length === 0) return;\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(\"Emitted extension migrations:\"));\n\t\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(` ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\t\tlines.push(\"\");\n\t\tlines.push(`Next: review the extension migrations above, then run ${green_(\"prisma-next migrate\")}.`);\n\t}\n\tif (result.noOp) {\n\t\tlines.push(`${green_(\"✔\")} No changes detected`);\n\t\tlines.push(dim_(` from: ${result.from}`));\n\t\tlines.push(dim_(` to: ${result.to}`));\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tif (result.pendingPlaceholders) {\n\t\tlines.push(`${yellow_(\"⚠\")} ${result.summary}`);\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`from: ${result.from}`));\n\t\tlines.push(dim_(`to: ${result.to}`));\n\t\tif (result.dir) lines.push(dim_(`dir: ${result.dir}`));\n\t\tlines.push(\"\");\n\t\tlines.push(\"Open migration.ts and replace each `placeholder(...)` call with your actual query.\");\n\t\tlines.push(`Then run: ${green_(`node ${result.dir ?? \"<dir>\"}/migration.ts`)}`);\n\t\tappendEmittedExtensions();\n\t\treturn lines.join(\"\\n\");\n\t}\n\tlines.push(`${green_(\"✔\")} ${result.summary}`);\n\tlines.push(\"\");\n\tif (result.operations.length > 0) {\n\t\tlines.push(dim_(\"│\"));\n\t\tfor (let i = 0; i < result.operations.length; i++) {\n\t\t\tconst op = result.operations[i];\n\t\t\tconst treeChar = i === result.operations.length - 1 ? \"└\" : \"├\";\n\t\t\tconst destructiveMarker = op.operationClass === \"destructive\" ? ` ${yellow_(\"(destructive)\")}` : \"\";\n\t\t\tlines.push(`${dim_(treeChar)}─ ${op.label}${destructiveMarker}`);\n\t\t}\n\t\tif (result.operations.some((op) => op.operationClass === \"destructive\")) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(`${yellow_(\"⚠\")} This migration contains destructive operations that may cause data loss.`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\tlines.push(dim_(`from: ${result.from}`));\n\tlines.push(dim_(`to: ${result.to}`));\n\tif (result.baselineDir) lines.push(dim_(`Baseline → ${result.baselineDir}`));\n\tif (result.dir) lines.push(dim_(`App space → ${result.dir}`));\n\tfor (const entry of result.emittedExtensionDirs) lines.push(dim_(`Extension space ${entry.spaceId} → migrations/${entry.spaceId}/${entry.dirName}`));\n\tlines.push(\"\");\n\tconst reviewTarget = result.baselineDir !== void 0 && result.dir !== void 0 ? `${result.baselineDir} and ${result.dir}` : result.baselineDir ?? result.dir ?? \"<dir>\";\n\tlines.push(`Next: review ${green_(reviewTarget)} if needed, then run ${green_(\"prisma-next migrate\")}.`);\n\tif (result.preview && result.preview.statements.length > 0) {\n\t\tconst allSql = result.preview.statements.every((s) => s.language === \"sql\");\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(allSql ? \"DDL preview\" : \"Operation preview\"));\n\t\tlines.push(\"\");\n\t\tfor (const statement of result.preview.statements) {\n\t\t\tconst trimmed = statement.text.trim();\n\t\t\tif (!trimmed) continue;\n\t\t\tconst line = statement.language === \"sql\" && !trimmed.endsWith(\";\") ? `${trimmed};` : trimmed;\n\t\t\tlines.push(line);\n\t\t}\n\t}\n\tif (flags.verbose && result.timings) {\n\t\tlines.push(\"\");\n\t\tlines.push(dim_(`Total time: ${result.timings.total}ms`));\n\t}\n\treturn lines.join(\"\\n\");\n}\n/**\n* Resolve a migration package by **target contract hash** (`metadata.to`)\n* using exact match or prefix match.\n*\n* Note: matches `metadata.to` (the contract hash this migration produces),\n* not `metadata.migrationHash` (the package's content-addressed identity).\n* Tries exact match first, then prefix match. Returns the matched package on\n* success, or a discriminated failure indicating whether the prefix was\n* ambiguous or simply not found.\n*\n* @internal Exported for testing only.\n*/\nfunction resolveBundleByPrefix(bundles, needle) {\n\tconst exact = bundles.find((p) => p.metadata.to === needle);\n\tif (exact) return ok(exact);\n\tconst candidates = bundles.filter((p) => p.metadata.to.startsWith(needle));\n\tif (candidates.length === 1) return ok(candidates[0]);\n\tif (candidates.length > 1) return notOk({\n\t\treason: \"ambiguous\",\n\t\tcount: candidates.length\n\t});\n\treturn notOk({ reason: \"not-found\" });\n}\n//#endregion\nexport { formatMigrationPlanOutput as n, resolveBundleByPrefix as r, createMigrationPlanCommand as t };\n\n//# sourceMappingURL=migration-plan-q_L84PN1.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,eAAe,0BAA0B,QAAQ;CAChD,MAAM,UAAU,cAAc,OAAO,WAAW,QAAQ,SAAS,KAAK,kBAAkB,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU;EAC9G,SAAS,KAAK;EACd,eAAe;EACf,aAAa,KAAK,cAAc;EAChC,QAAQ,KAAK;CACd,EAAE,IAAI,UAAU,MAAM,OAAO,UAA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,QAAQ;CAC/C,MAAM,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,OAAO,MAAM;CAC1D,IAAI,OAAO,OAAO,GAAG,KAAK;CAC1B,MAAM,aAAa,QAAQ,QAAQ,MAAM,EAAE,SAAS,GAAG,WAAW,MAAM,CAAC;CACzE,IAAI,WAAW,WAAW,GAAG,OAAO,GAAG,WAAW,EAAE;CACpD,IAAI,WAAW,SAAS,GAAG,OAAO,MAAM;EACvC,QAAQ;EACR,OAAO,WAAW;CACnB,CAAC;CACD,OAAO,MAAM,EAAE,QAAQ,YAAY,CAAC;AACrC"}
@@ -1,7 +1,7 @@
1
1
  import { H as formatMigrationShowOutput, N as errorUnexpected, O as errorRuntime$1, Q as mapRefResolutionError, W as formatStyledHeader, at as resolveMigrationPaths, ct as setCommandExamples, d as errorContractValidationFailed, h as errorFileNotFound, it as resolveContractPath, lt as setCommandSeeAlso, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
2
- import { r as loadConfig } from "./exports-BTEdvV8H.mjs";
2
+ import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
3
3
  import { s as loadContractSpaceAggregate } from "./aggregate-B4mhR4Sk.mjs";
4
- import { t as createControlClient } from "./client-75qrAPqf-DRg33_uJ.mjs";
4
+ import { t as createControlClient } from "./client-75qrAPqf-7l0C0H_b.mjs";
5
5
  import { r as parseMigrationRef } from "./ref-resolution-BjJBWPjX.mjs";
6
6
  import { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from "./migration-path-target-D3Sj55PI-BICblCuk.mjs";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -168,4 +168,4 @@ function createMigrationShowCommand() {
168
168
  //#endregion
169
169
  export { createMigrationShowCommand as t };
170
170
 
171
- //# sourceMappingURL=migration-show-PTC1gUjq.mjs.map
171
+ //# sourceMappingURL=migration-show--pW4XhKs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-show-PTC1gUjq.mjs","names":["errorRuntime"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-show.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, E as formatMigrationShowOutput, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, o as resolveContractPath, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { t as createControlClient } from \"../client-75qrAPqf.mjs\";\nimport { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from \"../migration-path-target-D3Sj55PI.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { APP_SPACE_ID, createControlStack } from \"@internal/framework-components/control\";\nimport { castAs } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { parseMigrationRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/migration-show.ts\nfunction pkgToPresent(spaceId, pkg, client) {\n\tconst ops = castAs(pkg.ops);\n\tconst rawPreview = client.toOperationPreview(ops) ?? { statements: [] };\n\treturn {\n\t\tspace: spaceId,\n\t\tname: pkg.dirName,\n\t\tfromContract: pkg.metadata.from,\n\t\ttoContract: pkg.metadata.to,\n\t\thash: pkg.metadata.migrationHash,\n\t\tcreatedAt: pkg.metadata.createdAt,\n\t\toperations: ops.map((op) => ({\n\t\t\tid: op.id,\n\t\t\tlabel: op.label,\n\t\t\toperationClass: op.operationClass\n\t\t})),\n\t\tpreview: { statements: [...rawPreview.statements] }\n\t};\n}\nasync function executeMigrationShowCommand(target, options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration show\",\n\t\t\tdescription: \"Display migration package contents\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"contract\",\n\t\t\t\t\tvalue: contractPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: appMigrationsRelative\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"target\",\n\t\t\t\t\tvalue: target\n\t\t\t\t}\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\t...ifDefined(\"driver\", config.driver),\n\t\textensions: config.extensions ?? []\n\t});\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}`\n\t\t}));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: \"Failed to read contract file\" }));\n\t}\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tlet appContract;\n\ttry {\n\t\tappContract = familyInstance.deserializeContract(castAs(JSON.parse(contractJsonContent)));\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst aggregate = await loadContractSpaceAggregate({\n\t\tmigrationsDir,\n\t\tappContract,\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tconst packages = aggregate.app.packages;\n\tconst graph = aggregate.app.graph();\n\tconst refs = aggregate.app.refs;\n\tlet appPkg;\n\tif (looksLikePath(target)) {\n\t\tconst resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n\t\tif (!resolved.ok) return resolved;\n\t\tconst matched = findPackageByDirPath(packages, resolved.value);\n\t\tif (!matched) return notOk(errorRuntime(\"Migration package not found\", {\n\t\t\twhy: `No loaded migration package at ${relative(process.cwd(), resolved.value)}`,\n\t\t\tfix: \"Pass a directory name, hash prefix, or path to an on-disk app-space migration package.\"\n\t\t}));\n\t\tappPkg = matched;\n\t} else {\n\t\tif (packages.length === 0) return notOk(errorRuntime(\"No migrations found\", {\n\t\t\twhy: `No migration packages found in ${appMigrationsRelative}`,\n\t\t\tfix: \"Run `prisma-next migration plan` to create a migration first.\"\n\t\t}));\n\t\tconst migResult = parseMigrationRef(target, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!migResult.ok) return notOk(mapRefResolutionError(migResult.failure));\n\t\tconst matchedPkg = packages.find((p) => p.metadata.migrationHash === migResult.value.migrationHash);\n\t\tif (!matchedPkg) return notOk(errorRuntime(\"Migration package not found\", {\n\t\t\twhy: `Resolved migration \"${migResult.value.dirName}\" but the package was not loaded`,\n\t\t\tfix: \"The migrations directory may be corrupted. Inspect the migration.json files.\"\n\t\t}));\n\t\tappPkg = matchedPkg;\n\t}\n\tconst migration = pkgToPresent(APP_SPACE_ID, appPkg, client);\n\treturn ok({\n\t\tok: true,\n\t\tsummary: `Migration ${migration.name} in ${migration.space}: ${migration.operations.length} operation(s)`,\n\t\tmigration\n\t});\n}\nfunction createMigrationShowCommand() {\n\tconst command = new Command(\"show\");\n\tsetCommandDescriptions(command, \"Display migration package contents\", \"Shows the operations, statement preview, and metadata for one app-space migration.\\nAccepts a directory path, directory name, or hash prefix.\\nOffline — does not consult the database.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration show 20260101_100000_add_user\",\n\t\t\"prisma-next migration show a1b2c3\",\n\t\t\"prisma-next migration show 20260101_100000_add_user --json\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).argument(\"<target>\", \"Migration reference: directory name, hash/prefix, ref, or path\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (target, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeMigrationShowCommand(target, options, flags, ui), flags, ui, (showResult) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(showResult, null, 2));\n\t\t\telse if (!flags.quiet) ui.log(formatMigrationShowOutput(showResult, flags));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationShowCommand };\n\n//# sourceMappingURL=migration-show.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,aAAa,SAAS,KAAK,QAAQ;CAC3C,MAAM,MAAM,OAAO,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,mBAAmB,GAAG,KAAK,EAAE,YAAY,CAAC,EAAE;CACtE,OAAO;EACN,OAAO;EACP,MAAM,IAA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,YAAY,OAAO,MAAMA,eAAa,+BAA+B;GACzE,KAAK,uBAAuB,UAAU,MAAM,QAAQ;GACpD,KAAK;EACN,CAAC,CAAC;EACF,SAAS;CACV;CACA,MAAM,YAAY,aAAa,cAAc,QAAQ,MAAM;CAC3D,OAAO,GAAG;EACT,IAAI;EACJ,SAAS,aAAa,UAAU,KAAK,MAAM,UAAU,MAAM,IAAI,UAAU,WAAW,OAAO;EAC3F;CACD,CAAC;AACF;AACA,SAAS,6BAA6B;CACrC,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,uBAAuB,SAAS,sCAAsC,yLAAyL;CAC/P,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,kBAAkB,SAAS;EAC1B;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,SAAS,YAAY,gEAAgE,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY;EAC7M,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,4BAA4B,QAAQ,SAAS,OAAO,EAAE,GAAG,OAAO,KAAK,eAAe;GACvH,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,OAAO,GAAG,IAAI,0BAA0B,YAAY,KAAK,CAAC;EAC3E,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"migration-show--pW4XhKs.mjs","names":["errorRuntime"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-show.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, E as formatMigrationShowOutput, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, o as resolveContractPath, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { t as createControlClient } from \"../client-75qrAPqf.mjs\";\nimport { n as looksLikePath, r as resolveAppTargetPath, t as findPackageByDirPath } from \"../migration-path-target-D3Sj55PI.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { APP_SPACE_ID, createControlStack } from \"@internal/framework-components/control\";\nimport { castAs } from \"@internal/utils/casts\";\nimport { loadContractSpaceAggregate } from \"@internal/migration-tools/aggregate\";\nimport { parseMigrationRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/migration-show.ts\nfunction pkgToPresent(spaceId, pkg, client) {\n\tconst ops = castAs(pkg.ops);\n\tconst rawPreview = client.toOperationPreview(ops) ?? { statements: [] };\n\treturn {\n\t\tspace: spaceId,\n\t\tname: pkg.dirName,\n\t\tfromContract: pkg.metadata.from,\n\t\ttoContract: pkg.metadata.to,\n\t\thash: pkg.metadata.migrationHash,\n\t\tcreatedAt: pkg.metadata.createdAt,\n\t\toperations: ops.map((op) => ({\n\t\t\tid: op.id,\n\t\t\tlabel: op.label,\n\t\t\toperationClass: op.operationClass\n\t\t})),\n\t\tpreview: { statements: [...rawPreview.statements] }\n\t};\n}\nasync function executeMigrationShowCommand(target, options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(options.config, config);\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration show\",\n\t\t\tdescription: \"Display migration package contents\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"contract\",\n\t\t\t\t\tvalue: contractPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: appMigrationsRelative\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"target\",\n\t\t\t\t\tvalue: target\n\t\t\t\t}\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\t...ifDefined(\"driver\", config.driver),\n\t\textensions: config.extensions ?? []\n\t});\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}`\n\t\t}));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: \"Failed to read contract file\" }));\n\t}\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tlet appContract;\n\ttry {\n\t\tappContract = familyInstance.deserializeContract(castAs(JSON.parse(contractJsonContent)));\n\t} catch (error) {\n\t\treturn notOk(errorContractValidationFailed(`Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst aggregate = await loadContractSpaceAggregate({\n\t\tmigrationsDir,\n\t\tappContract,\n\t\tdeserializeContract: (json) => familyInstance.deserializeContract(json)\n\t});\n\tconst packages = aggregate.app.packages;\n\tconst graph = aggregate.app.graph();\n\tconst refs = aggregate.app.refs;\n\tlet appPkg;\n\tif (looksLikePath(target)) {\n\t\tconst resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n\t\tif (!resolved.ok) return resolved;\n\t\tconst matched = findPackageByDirPath(packages, resolved.value);\n\t\tif (!matched) return notOk(errorRuntime(\"Migration package not found\", {\n\t\t\twhy: `No loaded migration package at ${relative(process.cwd(), resolved.value)}`,\n\t\t\tfix: \"Pass a directory name, hash prefix, or path to an on-disk app-space migration package.\"\n\t\t}));\n\t\tappPkg = matched;\n\t} else {\n\t\tif (packages.length === 0) return notOk(errorRuntime(\"No migrations found\", {\n\t\t\twhy: `No migration packages found in ${appMigrationsRelative}`,\n\t\t\tfix: \"Run `prisma-next migration plan` to create a migration first.\"\n\t\t}));\n\t\tconst migResult = parseMigrationRef(target, {\n\t\t\tgraph,\n\t\t\trefs\n\t\t});\n\t\tif (!migResult.ok) return notOk(mapRefResolutionError(migResult.failure));\n\t\tconst matchedPkg = packages.find((p) => p.metadata.migrationHash === migResult.value.migrationHash);\n\t\tif (!matchedPkg) return notOk(errorRuntime(\"Migration package not found\", {\n\t\t\twhy: `Resolved migration \"${migResult.value.dirName}\" but the package was not loaded`,\n\t\t\tfix: \"The migrations directory may be corrupted. Inspect the migration.json files.\"\n\t\t}));\n\t\tappPkg = matchedPkg;\n\t}\n\tconst migration = pkgToPresent(APP_SPACE_ID, appPkg, client);\n\treturn ok({\n\t\tok: true,\n\t\tsummary: `Migration ${migration.name} in ${migration.space}: ${migration.operations.length} operation(s)`,\n\t\tmigration\n\t});\n}\nfunction createMigrationShowCommand() {\n\tconst command = new Command(\"show\");\n\tsetCommandDescriptions(command, \"Display migration package contents\", \"Shows the operations, statement preview, and metadata for one app-space migration.\\nAccepts a directory path, directory name, or hash prefix.\\nOffline — does not consult the database.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration show 20260101_100000_add_user\",\n\t\t\"prisma-next migration show a1b2c3\",\n\t\t\"prisma-next migration show 20260101_100000_add_user --json\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).argument(\"<target>\", \"Migration reference: directory name, hash/prefix, ref, or path\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (target, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeMigrationShowCommand(target, options, flags, ui), flags, ui, (showResult) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(showResult, null, 2));\n\t\t\telse if (!flags.quiet) ui.log(formatMigrationShowOutput(showResult, flags));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationShowCommand };\n\n//# sourceMappingURL=migration-show.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,aAAa,SAAS,KAAK,QAAQ;CAC3C,MAAM,MAAM,OAAO,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,mBAAmB,GAAG,KAAK,EAAE,YAAY,CAAC,EAAE;CACtE,OAAO;EACN,OAAO;EACP,MAAM,IAAI;EACV,cAAc,IAAI,SAAS;EAC3B,YAAY,IAAI,SAAS;EACzB,MAAM,IAAI,SAAS;EACnB,WAAW,IAAI,SAAS;EACxB,YAAY,IAAI,KAAK,QAAQ;GAC5B,IAAI,GAAG;GACP,OAAO,GAAG;GACV,gBAAgB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G;EACT,IAAI;EACJ,SAAS,aAAa,UAAU,KAAK,MAAM,UAAU,MAAM,IAAI,UAAU,WAAW,OAAO;EAC3F;CACD,CAAC;AACF;AACA,SAAS,6BAA6B;CACrC,MAAM,UAAU,IAAI,QAAQ,MAAM;CAClC,uBAAuB,SAAS,sCAAsC,yLAAyL;CAC/P,mBAAmB,SAAS;EAC3B;EACA;EACA;CACD,CAAC;CACD,kBAAkB,SAAS;EAC1B;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;EACA;GACC,MAAM;GACN,UAAU;EACX;CACD,CAAC;CACD,iBAAiB,OAAO,CAAC,CAAC,SAAS,YAAY,gEAAgE,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY;EAC7M,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,WAAW,aAAa,MAAM,4BAA4B,QAAQ,SAAS,OAAO,EAAE,GAAG,OAAO,KAAK,eAAe;GACvH,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,OAAO,GAAG,IAAI,0BAA0B,YAAY,KAAK,CAAC;EAC3E,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -2,13 +2,13 @@ import { O as errorNoInvariantPath, P as errorUnknownInvariant, t as MigrationTo
2
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
3
3
  import { a as findPath, o as findPathWithDecision } from "./migration-graph-CBf9ORe7-B4xAF8GN.mjs";
4
4
  import { $ as maskConnectionUrl, N as errorUnexpected, Q as mapRefResolutionError, W as formatStyledHeader, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, dt as toStructuralEdge, i as collectDeclaredInvariants, lt as setCommandSeeAlso, nt as readContractEnvelope, o as createTerminalUI, q as handleResult, r as addGlobalOptions, rt as requireLiveDatabase, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
5
- import { r as loadConfig } from "./exports-BTEdvV8H.mjs";
5
+ import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
6
6
  import { i as readRefs } from "./refs-BDbB9BRB-D6Za3Q49.mjs";
7
7
  import { n as buildReadAggregate, o as refusePackageCorruptionOnAggregate, r as loadContractRawSafely } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
8
- import { t as createControlClient } from "./client-75qrAPqf-DRg33_uJ.mjs";
8
+ import { t as createControlClient } from "./client-75qrAPqf-7l0C0H_b.mjs";
9
9
  import { n as parseContractRef } from "./ref-resolution-BjJBWPjX.mjs";
10
10
  import { _ as renderMigrationGraphSpaceTree, a as computeGlobalMaxDirNameWidth, f as indentMigrationGraphTreeBlock, g as renderMigrationGraphLegend, o as computeGlobalMaxEdgeTreePrefixWidth } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
11
- import { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from "./migration-list-BFBeo1_X-DwyOI0w9.mjs";
11
+ import { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from "./migration-list-BFBeo1_X-ckYMhETH.mjs";
12
12
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
13
13
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
14
14
  import { dim, yellow } from "colorette";
@@ -441,4 +441,4 @@ function createMigrationStatusCommand() {
441
441
  //#endregion
442
442
  export { formatStatusHumanOutput as a, executeMigrationStatusCommand as i, buildStatusHeadline as n, formatStatusSummary as o, createMigrationStatusCommand as r, buildNoPathSummary as t };
443
443
 
444
- //# sourceMappingURL=migration-status-CE7cQLDq-BNFyJssP.mjs.map
444
+ //# sourceMappingURL=migration-status-CE7cQLDq-P1x1-BsZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-status-CE7cQLDq-BNFyJssP.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-status-CE7cQLDq.mjs"],"sourcesContent":["import { A as formatStyledHeader, F as CliStructuredError, _ as createTerminalUI, a as readContractEnvelope, ct as errorUnexpected, d as setCommandSeeAlso, dt as requireLiveDatabase, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, lt as mapMigrationToolsError, n as collectDeclaredInvariants, p as toStructuralEdge, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"./command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate, o as refusePackageCorruptionOnAggregate, r as loadContractRawSafely } from \"./contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { t as createControlClient } from \"./client-75qrAPqf.mjs\";\nimport { a as renderMigrationGraphLegend, f as indentMigrationGraphTreeBlock, l as computeGlobalMaxDirNameWidth, p as renderMigrationGraphSpaceTree, u as computeGlobalMaxEdgeTreePrefixWidth } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from \"./migration-list-BFBeo1_X.mjs\";\nimport \"./schemas-KhXMzNA_.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { dim, yellow } from \"colorette\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError, errorNoInvariantPath, errorUnknownInvariant } from \"@internal/migration-tools/errors\";\nimport { findPath, findPathWithDecision } from \"@internal/migration-tools/migration-graph\";\nimport { readRefs } from \"@internal/migration-tools/refs\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/migration-status-overlay.ts\nfunction deriveStatusEdgeAnnotations(input) {\n\tconst annotations = /* @__PURE__ */ new Map();\n\tif (input.showAppliedOverlay) {\n\t\tfor (const edge of input.graph.migrationByHash.values()) if (input.appliedMigrationHashes.has(edge.migrationHash)) annotations.set(edge.migrationHash, { status: \"applied\" });\n\t}\n\tif (!input.graph.nodes.has(input.originHash)) return annotations;\n\tconst pendingPath = findPath(input.graph, input.originHash, input.targetHash);\n\tif (!pendingPath) return annotations;\n\tfor (const edge of pendingPath) {\n\t\tif (input.appliedMigrationHashes.has(edge.migrationHash)) continue;\n\t\tif (annotations.get(edge.migrationHash)?.status === \"applied\") continue;\n\t\tannotations.set(edge.migrationHash, { status: \"pending\" });\n\t}\n\treturn annotations;\n}\nfunction appliedHashesFromLedger(ledgerEntries) {\n\treturn new Set(ledgerEntries.map((entry) => entry.migrationHash));\n}\nfunction statusForMigrationHash(migrationHash, annotations) {\n\treturn annotations.get(migrationHash)?.status ?? null;\n}\n//#endregion\n//#region src/commands/migration-status.ts\nfunction shortDisplayHash(hash) {\n\treturn hash.slice(0, 12);\n}\nfunction resolveTarget(contractHash, activeRefHash) {\n\treturn activeRefHash ?? contractHash;\n}\nfunction buildStatusMigrations(listMigrations, annotations) {\n\treturn listMigrations.map((migration) => ({\n\t\t...migration,\n\t\tstatus: statusForMigrationHash(migration.hash, annotations)\n\t}));\n}\nfunction renderSpaceTree(args) {\n\tconst graph = args.space.graph();\n\tif (graph.nodes.size === 0) return \"\";\n\treturn renderMigrationGraphSpaceTree({\n\t\tgraph,\n\t\tmigrations: args.migrations,\n\t\tliveContractHash: args.liveContractHash,\n\t\trefsByHash: listRefsByContractHash(args.space),\n\t\tstatusOverlayByHash: args.statusOverlay,\n\t\tcolorize: args.colorize,\n\t\tglyphMode: args.glyphMode,\n\t\tisAppSpace: args.isAppSpace,\n\t\t...args.showDbMarker && args.markerHash !== void 0 ? { dbHash: args.markerHash } : {},\n\t\t...args.globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth: args.globalMaxEdgeTreePrefixWidth } : {},\n\t\t...args.globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth: args.globalMaxDirNameWidth } : {}\n\t});\n}\nfunction countPending(migrations) {\n\treturn migrations.filter((m) => m.status === \"pending\").length;\n}\nfunction buildNoPathSummary(args) {\n\tconst markerPart = args.markerHash !== void 0 ? `the database state (${shortDisplayHash(args.markerHash)})` : \"the database state\";\n\tconst targetShort = shortDisplayHash(args.targetHash);\n\tif (!args.explicitTarget) return `No migration path from ${markerPart} to the application's contract (${targetShort}). Run \\`prisma-next migration plan --name <name>\\` to author one.`;\n\treturn `No migration path from ${markerPart} to ${args.refName !== void 0 ? `the target (${targetShort} via \\`${args.refName}\\`)` : `the target (${targetShort})`}. Run \\`prisma-next migration plan --name <name>\\` to author one, or pass \\`--to <contract>\\` to pick a reachable target.`;\n}\nfunction buildStatusHeadline(args) {\n\tif (args.markerDiverged && args.markerHash !== void 0) return `Database marker ${shortDisplayHash(args.markerHash)} is not in the on-disk migration graph`;\n\tif (args.pendingCount === 0) return \"Up to date\";\n\treturn `${args.pendingCount} pending — run \\`prisma-next migrate --to ${shortDisplayHash(args.targetHash)}\\``;\n}\nfunction formatStatusSummary(result, colorize) {\n\tconst c = (fn, s) => colorize ? fn(s) : s;\n\tconst lines = [];\n\tconst pendingTotal = result.spaces.reduce((sum, space) => sum + countPending(space.migrations), 0);\n\tif (result.diagnostics.some((d) => d.code === \"MIGRATION.MARKER_NOT_IN_HISTORY\") || pendingTotal > 0) lines.push(c(yellow, result.summary));\n\telse lines.push(result.summary);\n\tconst missingInvariantsDiagnostic = result.diagnostics.find((d) => d.code === \"MIGRATION.MISSING_INVARIANTS\");\n\tif (missingInvariantsDiagnostic !== void 0) lines.push(c(dim, missingInvariantsDiagnostic.message));\n\treturn lines.join(\"\\n\");\n}\nfunction formatStatusHumanOutput(result, colorize) {\n\tconst sections = [];\n\tfor (const section of result.treeSections) {\n\t\tif (section.showHeading) sections.push(`${section.space}:`);\n\t\tif (section.tree.length > 0) sections.push(section.tree);\n\t\telse sections.push(\"(no migrations)\");\n\t\tsections.push(\"\");\n\t}\n\tsections.push(formatStatusSummary(result, colorize));\n\treturn sections.join(\"\\n\").trimEnd();\n}\nasync function readMarkersAndLedgers(args) {\n\tconst markersBySpace = /* @__PURE__ */ new Map();\n\tconst all = await args.client.readAllMarkers();\n\tfor (const [spaceId, marker] of all) markersBySpace.set(spaceId, marker);\n\tconst ledgersBySpace = /* @__PURE__ */ new Map();\n\tfor (const spaceId of args.spaceIds) ledgersBySpace.set(spaceId, await args.client.readLedger(spaceId));\n\treturn {\n\t\tmarkersBySpace,\n\t\tledgersBySpace\n\t};\n}\nasync function executeMigrationStatusCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(options.config, config);\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tconst hasDriver = !!config.driver;\n\tconst usingFromOverride = options.from !== void 0;\n\tif (!usingFromOverride) {\n\t\tconst missingDb = requireLiveDatabase({\n\t\t\tdbConnection,\n\t\t\thasDriver,\n\t\t\twhy: \"migration status needs a database connection to read the marker and ledger (or pass --from for offline path preview)\",\n\t\t\tretryCommand: \"prisma-next migration status --from <contract>\"\n\t\t});\n\t\tif (missingDb) return notOk(missingDb);\n\t}\n\tlet allRefs = {};\n\ttry {\n\t\tallRefs = await readRefs(refsDir);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));\n\t\tthrow error;\n\t}\n\tconst diagnostics = [];\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch (error) {\n\t\tdiagnostics.push({\n\t\t\tcode: \"CONTRACT.UNREADABLE\",\n\t\t\tseverity: \"warn\",\n\t\t\tmessage: `Could not read contract: ${error instanceof Error ? error.message : \"unknown error\"}`,\n\t\t\thints: [\"Run 'prisma-next contract emit' to generate a valid contract\"]\n\t\t});\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return notOk(loaded.failure);\n\tconst { aggregate } = loaded.value;\n\tif (await loadContractRawSafely(config) !== null) {\n\t\tconst corruptionFailure = refusePackageCorruptionOnAggregate(aggregate);\n\t\tif (corruptionFailure) return notOk(corruptionFailure);\n\t}\n\tconst appGraph = aggregate.app.graph();\n\tlet activeRefHash;\n\tlet activeRefName;\n\tlet activeRefEntry;\n\tlet fromOverrideHash;\n\tif (options.to) {\n\t\tconst refResult = parseContractRef(options.to, {\n\t\t\tgraph: appGraph,\n\t\t\trefs: allRefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tactiveRefHash = refResult.value.hash;\n\t\tif (refResult.value.provenance.kind === \"ref\") {\n\t\t\tactiveRefName = refResult.value.provenance.refName;\n\t\t\tactiveRefEntry = allRefs[activeRefName];\n\t\t}\n\t}\n\tif (options.from) {\n\t\tconst fromResult = parseContractRef(options.from, {\n\t\t\tgraph: appGraph,\n\t\t\trefs: allRefs\n\t\t});\n\t\tif (!fromResult.ok) return notOk(mapRefResolutionError(fromResult.failure));\n\t\tfromOverrideHash = fromResult.value.hash;\n\t}\n\tconst requiredInvariants = [...activeRefEntry?.invariants ?? []].sort();\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: \"migrations\",\n\t\t\tvalue: migrationsRelative\n\t\t}];\n\t\tif (dbConnection && hasDriver) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(String(dbConnection))\n\t\t});\n\t\tif (activeRefName) details.push({\n\t\t\tlabel: \"ref\",\n\t\t\tvalue: activeRefName\n\t\t});\n\t\tif (options.from) details.push({\n\t\t\tlabel: \"from\",\n\t\t\tvalue: options.from\n\t\t});\n\t\tif (options.space) details.push({\n\t\t\tlabel: \"space\",\n\t\t\tvalue: options.space\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration status\",\n\t\t\tdescription: \"Show migration history and applied status\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\tconst scopedSpaces = listResult.value.spaces;\n\tconst showSpaceHeadings = scopedSpaces.length > 1;\n\tlet markersBySpace = /* @__PURE__ */ new Map();\n\tlet ledgersBySpace = /* @__PURE__ */ new Map();\n\tlet connected = false;\n\tif (dbConnection && hasDriver && !usingFromOverride) {\n\t\tconst client = createControlClient({\n\t\t\tfamily: config.family,\n\t\t\ttarget: config.target,\n\t\t\tadapter: config.adapter,\n\t\t\tdriver: config.driver,\n\t\t\textensions: config.extensions ?? []\n\t\t});\n\t\ttry {\n\t\t\tawait client.connect(dbConnection);\n\t\t\tconnected = true;\n\t\t\tconst read = await readMarkersAndLedgers({\n\t\t\t\tclient,\n\t\t\t\tspaceIds: scopedSpaces.map((s) => s.space)\n\t\t\t});\n\t\t\tmarkersBySpace = new Map(read.markersBySpace);\n\t\t\tledgersBySpace = new Map(read.ledgersBySpace);\n\t\t} catch (error) {\n\t\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read database state: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t} finally {\n\t\t\tawait client.close();\n\t\t}\n\t}\n\tif (activeRefEntry && activeRefEntry.invariants.length > 0 && connected) {\n\t\tconst declared = collectDeclaredInvariants(appGraph);\n\t\tconst markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n\t\tconst known = new Set(declared);\n\t\tfor (const id of markerInvariants) known.add(id);\n\t\tconst unknown = activeRefEntry.invariants.filter((id) => !known.has(id));\n\t\tif (unknown.length > 0) return notOk(mapMigrationToolsError(errorUnknownInvariant({\n\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\tunknown,\n\t\t\tdeclared: [...declared].sort()\n\t\t})));\n\t}\n\tconst showAppliedOverlay = connected && !usingFromOverride;\n\tconst showDbMarker = connected && !usingFromOverride;\n\tconst glyphMode = ui.resolveGlyphMode(options.ascii === true);\n\tconst colorize = flags.color !== false;\n\tconst statusSpaces = [];\n\tconst treeSections = [];\n\tlet markerDiverged = false;\n\tlet markerCannotReachTarget = false;\n\tlet headlineTargetHash = activeRefHash ?? contractHash;\n\tlet totalPending = 0;\n\tconst globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({\n\t\tgraph: aggregate.space(spaceEntry.space).graph(),\n\t\tliveContractHash: contractHash\n\t})) : [];\n\tconst globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;\n\tconst globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;\n\tfor (const spaceEntry of scopedSpaces) {\n\t\tconst space = aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst spaceContractHash = space.contract().storage.storageHash;\n\t\tconst targetHash = resolveTarget(spaceContractHash, activeRefHash);\n\t\tif (spaceEntry.space === aggregate.app.spaceId) headlineTargetHash = targetHash;\n\t\tconst markerRecord = markersBySpace.get(spaceEntry.space);\n\t\tconst markerHash = usingFromOverride ? fromOverrideHash : markerRecord?.storageHash ?? void 0;\n\t\tconst originHash = markerHash ?? EMPTY_CONTRACT_HASH;\n\t\tconst markerInGraph = markerHash === void 0 || graph.nodes.has(markerHash) || markerHash === spaceContractHash;\n\t\tif (connected && !usingFromOverride && markerInGraph && originHash !== targetHash && findPath(graph, originHash, targetHash) === null) markerCannotReachTarget = true;\n\t\tif (connected && !usingFromOverride && markerHash !== void 0 && !markerInGraph) {\n\t\t\tmarkerDiverged = true;\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"MIGRATION.MARKER_NOT_IN_HISTORY\",\n\t\t\t\tseverity: \"warn\",\n\t\t\t\tmessage: \"Database was updated outside the migration system (marker does not match any migration)\",\n\t\t\t\thints: [\"Run 'prisma-next db sign' to overwrite the marker if the database already matches the contract\", \"Run 'prisma-next db update' to push the current contract to the database\"]\n\t\t\t});\n\t\t}\n\t\tconst ledger = ledgersBySpace.get(spaceEntry.space) ?? [];\n\t\tconst annotations = deriveStatusEdgeAnnotations({\n\t\t\tgraph,\n\t\t\ttargetHash,\n\t\t\toriginHash,\n\t\t\tappliedMigrationHashes: showAppliedOverlay ? appliedHashesFromLedger(ledger) : /* @__PURE__ */ new Set(),\n\t\t\tshowAppliedOverlay\n\t\t});\n\t\tconst isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n\t\tconst tree = renderSpaceTree({\n\t\t\tspace,\n\t\t\tliveContractHash: contractHash,\n\t\t\tmigrations: spaceEntry.migrations,\n\t\t\tmarkerHash,\n\t\t\tshowDbMarker,\n\t\t\tstatusOverlay: annotations,\n\t\t\tcolorize,\n\t\t\tglyphMode,\n\t\t\tisAppSpace,\n\t\t\t...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},\n\t\t\t...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}\n\t\t});\n\t\tconst migrations = buildStatusMigrations(spaceEntry.migrations, annotations);\n\t\tconst pending = countPending(migrations);\n\t\ttotalPending += pending;\n\t\tstatusSpaces.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\tcurrentContract: markerHash ?? null,\n\t\t\ttargetContract: targetHash,\n\t\t\tmigrations: [...migrations]\n\t\t});\n\t\tconst displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, \" \") : tree;\n\t\ttreeSections.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\ttree: displayTree,\n\t\t\tshowHeading: showSpaceHeadings\n\t\t});\n\t}\n\tif (connected && requiredInvariants.length > 0) {\n\t\tconst markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n\t\tconst markerSet = new Set(markerInvariants);\n\t\tconst missing = requiredInvariants.filter((id) => !markerSet.has(id));\n\t\tif (missing.length > 0) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"MIGRATION.MISSING_INVARIANTS\",\n\t\t\t\t...ifDefined(\"ref\", activeRefName),\n\t\t\t\tinvariants: missing,\n\t\t\t\tmessage: `missing invariant(s): ${missing.join(\", \")}`\n\t\t\t});\n\t\t\tif (activeRefHash !== void 0) {\n\t\t\t\tconst outcome = findPathWithDecision(appGraph, markersBySpace.get(aggregate.app.spaceId)?.storageHash ?? EMPTY_CONTRACT_HASH, activeRefHash, {\n\t\t\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\t\t\trequired: new Set(missing)\n\t\t\t\t});\n\t\t\t\tif (outcome.kind === \"unsatisfiable\") return notOk(mapMigrationToolsError(errorNoInvariantPath({\n\t\t\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\t\t\trequired: [...missing].sort(),\n\t\t\t\t\tmissing: outcome.missing,\n\t\t\t\t\tstructuralPath: outcome.structuralPath.map(toStructuralEdge)\n\t\t\t\t})));\n\t\t\t}\n\t\t}\n\t}\n\tconst appMarkerHash = markersBySpace.get(aggregate.app.spaceId)?.storageHash;\n\tconst summary = markerCannotReachTarget ? buildNoPathSummary({\n\t\tmarkerHash: appMarkerHash,\n\t\ttargetHash: headlineTargetHash,\n\t\texplicitTarget: options.to !== void 0,\n\t\trefName: activeRefName\n\t}) : buildStatusHeadline({\n\t\tpendingCount: totalPending,\n\t\ttargetHash: headlineTargetHash,\n\t\tmarkerDiverged,\n\t\tmarkerHash: appMarkerHash\n\t});\n\tif (scopedSpaces.every((s) => s.migrations.length === 0)) return ok({\n\t\tok: true,\n\t\tspaces: statusSpaces,\n\t\tsummary: \"No migrations found\",\n\t\tdiagnostics,\n\t\ttreeSections\n\t});\n\treturn ok({\n\t\tok: true,\n\t\tspaces: statusSpaces,\n\t\tsummary,\n\t\tdiagnostics,\n\t\ttreeSections\n\t});\n}\nfunction createMigrationStatusCommand() {\n\tconst command = new Command(\"status\");\n\tsetCommandDescriptions(command, \"Show migration path and pending status\", \"Shows which migrations are pending between the database marker and\\nthe target contract. Requires a database connection.\\nPass --from for an offline path preview without a database.\\nUse `migration graph` for topology, `migration log` for history,\\nand `migration list` for on-disk enumeration.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration status --db $DATABASE_URL\",\n\t\t\"prisma-next migration status --to production --db $DATABASE_URL\",\n\t\t\"prisma-next migration status --from abc123 --to production\",\n\t\t\"prisma-next migration status --from abc123 --to production --json\",\n\t\t\"prisma-next migration status --ascii --from abc123 --to production\",\n\t\t\"prisma-next migration status --legend --from abc123 --to production\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--from <contract>\", \"Origin contract reference; same grammar as --to. Supplying --from switches to offline path computation.\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationStatusCommand(options, flags, ui), flags, ui, (statusResult) => {\n\t\t\tif (flags.json) {\n\t\t\t\tconst jsonResult = {\n\t\t\t\t\tok: true,\n\t\t\t\t\tspaces: [...statusResult.spaces],\n\t\t\t\t\tsummary: statusResult.summary,\n\t\t\t\t\tdiagnostics: [...statusResult.diagnostics]\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(jsonResult, null, 2));\n\t\t\t} else if (!flags.quiet) ui.output(formatStatusHumanOutput(statusResult, flags.color !== false));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { formatStatusHumanOutput as a, executeMigrationStatusCommand as i, buildStatusHeadline as n, formatStatusSummary as o, createMigrationStatusCommand as r, buildNoPathSummary as t };\n\n//# sourceMappingURL=migration-status-CE7cQLDq.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAS,4BAA4B,OAAO;CAC3C,MAAM,8BAA8B,IAAI,IAAI;CAC5C,IAAI,MAAM,oBACJ;OAAA,MAAM,QAAQ,MAAM,MAAM,gBAAgB,OAAO,GAAG,IAAI,MAAM,uBAAuB,IAAI,KAAK,aAAa,GAAG,YAAY,IAAI,KAAK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C,CAAC,OAAO,gBAAgB,0CAA0C,CAAC,CAAC,OAAO,mBAAmB,2FAA2F,CAAC,CAAC,OAAO,qBAAqB,yGAAyG,CAAC,CAAC,OAAO,YAAY,iDAAiD,CAAC,CAAC,OAAO,WAAW,kCAAkC,CAAC,CAAC,OAAO,OAAO,YAAY;EAC9lB,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,MAAM,mBAAmB,sBAAsB,SAAS,KAAK;EAC7D,IAAI,CAAC,iBAAiB,IAAI,QAAQ,KAAK,aAAa,kBAAkB,OAAO,EAAE,CAAC;EAChF,MAAM,WAAW,aAAa,MAAM,8BAA8B,SAAS,OAAO,EAAE,GAAG,OAAO,KAAK,iBAAiB;GACnH,IAAI,MAAM,MAAM;IACf,MAAM,aAAa;KAClB,IAAI;KACJ,QAAQ,CAAC,GAAG,aAAa,MAAM;KAC/B,SAAS,aAAa;KACtB,aAAa,CAAC,GAAG,aAAa,WAAW;IAC1C;IACA,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;GAC9C,OAAO,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,wBAAwB,cAAc,MAAM,UAAU,KAAK,CAAC;EAChG,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"migration-status-CE7cQLDq-P1x1-BsZ.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-status-CE7cQLDq.mjs"],"sourcesContent":["import { A as formatStyledHeader, F as CliStructuredError, _ as createTerminalUI, a as readContractEnvelope, ct as errorUnexpected, d as setCommandSeeAlso, dt as requireLiveDatabase, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, lt as mapMigrationToolsError, n as collectDeclaredInvariants, p as toStructuralEdge, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as mapRefResolutionError, y as handleResult } from \"./command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate, o as refusePackageCorruptionOnAggregate, r as loadContractRawSafely } from \"./contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { t as createControlClient } from \"./client-75qrAPqf.mjs\";\nimport { a as renderMigrationGraphLegend, f as indentMigrationGraphTreeBlock, l as computeGlobalMaxDirNameWidth, p as renderMigrationGraphSpaceTree, u as computeGlobalMaxEdgeTreePrefixWidth } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from \"./migration-list-BFBeo1_X.mjs\";\nimport \"./schemas-KhXMzNA_.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { dim, yellow } from \"colorette\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError, errorNoInvariantPath, errorUnknownInvariant } from \"@internal/migration-tools/errors\";\nimport { findPath, findPathWithDecision } from \"@internal/migration-tools/migration-graph\";\nimport { readRefs } from \"@internal/migration-tools/refs\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/migration-status-overlay.ts\nfunction deriveStatusEdgeAnnotations(input) {\n\tconst annotations = /* @__PURE__ */ new Map();\n\tif (input.showAppliedOverlay) {\n\t\tfor (const edge of input.graph.migrationByHash.values()) if (input.appliedMigrationHashes.has(edge.migrationHash)) annotations.set(edge.migrationHash, { status: \"applied\" });\n\t}\n\tif (!input.graph.nodes.has(input.originHash)) return annotations;\n\tconst pendingPath = findPath(input.graph, input.originHash, input.targetHash);\n\tif (!pendingPath) return annotations;\n\tfor (const edge of pendingPath) {\n\t\tif (input.appliedMigrationHashes.has(edge.migrationHash)) continue;\n\t\tif (annotations.get(edge.migrationHash)?.status === \"applied\") continue;\n\t\tannotations.set(edge.migrationHash, { status: \"pending\" });\n\t}\n\treturn annotations;\n}\nfunction appliedHashesFromLedger(ledgerEntries) {\n\treturn new Set(ledgerEntries.map((entry) => entry.migrationHash));\n}\nfunction statusForMigrationHash(migrationHash, annotations) {\n\treturn annotations.get(migrationHash)?.status ?? null;\n}\n//#endregion\n//#region src/commands/migration-status.ts\nfunction shortDisplayHash(hash) {\n\treturn hash.slice(0, 12);\n}\nfunction resolveTarget(contractHash, activeRefHash) {\n\treturn activeRefHash ?? contractHash;\n}\nfunction buildStatusMigrations(listMigrations, annotations) {\n\treturn listMigrations.map((migration) => ({\n\t\t...migration,\n\t\tstatus: statusForMigrationHash(migration.hash, annotations)\n\t}));\n}\nfunction renderSpaceTree(args) {\n\tconst graph = args.space.graph();\n\tif (graph.nodes.size === 0) return \"\";\n\treturn renderMigrationGraphSpaceTree({\n\t\tgraph,\n\t\tmigrations: args.migrations,\n\t\tliveContractHash: args.liveContractHash,\n\t\trefsByHash: listRefsByContractHash(args.space),\n\t\tstatusOverlayByHash: args.statusOverlay,\n\t\tcolorize: args.colorize,\n\t\tglyphMode: args.glyphMode,\n\t\tisAppSpace: args.isAppSpace,\n\t\t...args.showDbMarker && args.markerHash !== void 0 ? { dbHash: args.markerHash } : {},\n\t\t...args.globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth: args.globalMaxEdgeTreePrefixWidth } : {},\n\t\t...args.globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth: args.globalMaxDirNameWidth } : {}\n\t});\n}\nfunction countPending(migrations) {\n\treturn migrations.filter((m) => m.status === \"pending\").length;\n}\nfunction buildNoPathSummary(args) {\n\tconst markerPart = args.markerHash !== void 0 ? `the database state (${shortDisplayHash(args.markerHash)})` : \"the database state\";\n\tconst targetShort = shortDisplayHash(args.targetHash);\n\tif (!args.explicitTarget) return `No migration path from ${markerPart} to the application's contract (${targetShort}). Run \\`prisma-next migration plan --name <name>\\` to author one.`;\n\treturn `No migration path from ${markerPart} to ${args.refName !== void 0 ? `the target (${targetShort} via \\`${args.refName}\\`)` : `the target (${targetShort})`}. Run \\`prisma-next migration plan --name <name>\\` to author one, or pass \\`--to <contract>\\` to pick a reachable target.`;\n}\nfunction buildStatusHeadline(args) {\n\tif (args.markerDiverged && args.markerHash !== void 0) return `Database marker ${shortDisplayHash(args.markerHash)} is not in the on-disk migration graph`;\n\tif (args.pendingCount === 0) return \"Up to date\";\n\treturn `${args.pendingCount} pending — run \\`prisma-next migrate --to ${shortDisplayHash(args.targetHash)}\\``;\n}\nfunction formatStatusSummary(result, colorize) {\n\tconst c = (fn, s) => colorize ? fn(s) : s;\n\tconst lines = [];\n\tconst pendingTotal = result.spaces.reduce((sum, space) => sum + countPending(space.migrations), 0);\n\tif (result.diagnostics.some((d) => d.code === \"MIGRATION.MARKER_NOT_IN_HISTORY\") || pendingTotal > 0) lines.push(c(yellow, result.summary));\n\telse lines.push(result.summary);\n\tconst missingInvariantsDiagnostic = result.diagnostics.find((d) => d.code === \"MIGRATION.MISSING_INVARIANTS\");\n\tif (missingInvariantsDiagnostic !== void 0) lines.push(c(dim, missingInvariantsDiagnostic.message));\n\treturn lines.join(\"\\n\");\n}\nfunction formatStatusHumanOutput(result, colorize) {\n\tconst sections = [];\n\tfor (const section of result.treeSections) {\n\t\tif (section.showHeading) sections.push(`${section.space}:`);\n\t\tif (section.tree.length > 0) sections.push(section.tree);\n\t\telse sections.push(\"(no migrations)\");\n\t\tsections.push(\"\");\n\t}\n\tsections.push(formatStatusSummary(result, colorize));\n\treturn sections.join(\"\\n\").trimEnd();\n}\nasync function readMarkersAndLedgers(args) {\n\tconst markersBySpace = /* @__PURE__ */ new Map();\n\tconst all = await args.client.readAllMarkers();\n\tfor (const [spaceId, marker] of all) markersBySpace.set(spaceId, marker);\n\tconst ledgersBySpace = /* @__PURE__ */ new Map();\n\tfor (const spaceId of args.spaceIds) ledgersBySpace.set(spaceId, await args.client.readLedger(spaceId));\n\treturn {\n\t\tmarkersBySpace,\n\t\tledgersBySpace\n\t};\n}\nasync function executeMigrationStatusCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(options.config, config);\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tconst hasDriver = !!config.driver;\n\tconst usingFromOverride = options.from !== void 0;\n\tif (!usingFromOverride) {\n\t\tconst missingDb = requireLiveDatabase({\n\t\t\tdbConnection,\n\t\t\thasDriver,\n\t\t\twhy: \"migration status needs a database connection to read the marker and ledger (or pass --from for offline path preview)\",\n\t\t\tretryCommand: \"prisma-next migration status --from <contract>\"\n\t\t});\n\t\tif (missingDb) return notOk(missingDb);\n\t}\n\tlet allRefs = {};\n\ttry {\n\t\tallRefs = await readRefs(refsDir);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));\n\t\tthrow error;\n\t}\n\tconst diagnostics = [];\n\tlet contractHash = EMPTY_CONTRACT_HASH;\n\ttry {\n\t\tcontractHash = (await readContractEnvelope(config)).storageHash;\n\t} catch (error) {\n\t\tdiagnostics.push({\n\t\t\tcode: \"CONTRACT.UNREADABLE\",\n\t\t\tseverity: \"warn\",\n\t\t\tmessage: `Could not read contract: ${error instanceof Error ? error.message : \"unknown error\"}`,\n\t\t\thints: [\"Run 'prisma-next contract emit' to generate a valid contract\"]\n\t\t});\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return notOk(loaded.failure);\n\tconst { aggregate } = loaded.value;\n\tif (await loadContractRawSafely(config) !== null) {\n\t\tconst corruptionFailure = refusePackageCorruptionOnAggregate(aggregate);\n\t\tif (corruptionFailure) return notOk(corruptionFailure);\n\t}\n\tconst appGraph = aggregate.app.graph();\n\tlet activeRefHash;\n\tlet activeRefName;\n\tlet activeRefEntry;\n\tlet fromOverrideHash;\n\tif (options.to) {\n\t\tconst refResult = parseContractRef(options.to, {\n\t\t\tgraph: appGraph,\n\t\t\trefs: allRefs\n\t\t});\n\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\tactiveRefHash = refResult.value.hash;\n\t\tif (refResult.value.provenance.kind === \"ref\") {\n\t\t\tactiveRefName = refResult.value.provenance.refName;\n\t\t\tactiveRefEntry = allRefs[activeRefName];\n\t\t}\n\t}\n\tif (options.from) {\n\t\tconst fromResult = parseContractRef(options.from, {\n\t\t\tgraph: appGraph,\n\t\t\trefs: allRefs\n\t\t});\n\t\tif (!fromResult.ok) return notOk(mapRefResolutionError(fromResult.failure));\n\t\tfromOverrideHash = fromResult.value.hash;\n\t}\n\tconst requiredInvariants = [...activeRefEntry?.invariants ?? []].sort();\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: \"migrations\",\n\t\t\tvalue: migrationsRelative\n\t\t}];\n\t\tif (dbConnection && hasDriver) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(String(dbConnection))\n\t\t});\n\t\tif (activeRefName) details.push({\n\t\t\tlabel: \"ref\",\n\t\t\tvalue: activeRefName\n\t\t});\n\t\tif (options.from) details.push({\n\t\t\tlabel: \"from\",\n\t\t\tvalue: options.from\n\t\t});\n\t\tif (options.space) details.push({\n\t\t\tlabel: \"space\",\n\t\t\tvalue: options.space\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration status\",\n\t\t\tdescription: \"Show migration history and applied status\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\tconst scopedSpaces = listResult.value.spaces;\n\tconst showSpaceHeadings = scopedSpaces.length > 1;\n\tlet markersBySpace = /* @__PURE__ */ new Map();\n\tlet ledgersBySpace = /* @__PURE__ */ new Map();\n\tlet connected = false;\n\tif (dbConnection && hasDriver && !usingFromOverride) {\n\t\tconst client = createControlClient({\n\t\t\tfamily: config.family,\n\t\t\ttarget: config.target,\n\t\t\tadapter: config.adapter,\n\t\t\tdriver: config.driver,\n\t\t\textensions: config.extensions ?? []\n\t\t});\n\t\ttry {\n\t\t\tawait client.connect(dbConnection);\n\t\t\tconnected = true;\n\t\t\tconst read = await readMarkersAndLedgers({\n\t\t\t\tclient,\n\t\t\t\tspaceIds: scopedSpaces.map((s) => s.space)\n\t\t\t});\n\t\t\tmarkersBySpace = new Map(read.markersBySpace);\n\t\t\tledgersBySpace = new Map(read.ledgersBySpace);\n\t\t} catch (error) {\n\t\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read database state: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t} finally {\n\t\t\tawait client.close();\n\t\t}\n\t}\n\tif (activeRefEntry && activeRefEntry.invariants.length > 0 && connected) {\n\t\tconst declared = collectDeclaredInvariants(appGraph);\n\t\tconst markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n\t\tconst known = new Set(declared);\n\t\tfor (const id of markerInvariants) known.add(id);\n\t\tconst unknown = activeRefEntry.invariants.filter((id) => !known.has(id));\n\t\tif (unknown.length > 0) return notOk(mapMigrationToolsError(errorUnknownInvariant({\n\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\tunknown,\n\t\t\tdeclared: [...declared].sort()\n\t\t})));\n\t}\n\tconst showAppliedOverlay = connected && !usingFromOverride;\n\tconst showDbMarker = connected && !usingFromOverride;\n\tconst glyphMode = ui.resolveGlyphMode(options.ascii === true);\n\tconst colorize = flags.color !== false;\n\tconst statusSpaces = [];\n\tconst treeSections = [];\n\tlet markerDiverged = false;\n\tlet markerCannotReachTarget = false;\n\tlet headlineTargetHash = activeRefHash ?? contractHash;\n\tlet totalPending = 0;\n\tconst globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({\n\t\tgraph: aggregate.space(spaceEntry.space).graph(),\n\t\tliveContractHash: contractHash\n\t})) : [];\n\tconst globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;\n\tconst globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;\n\tfor (const spaceEntry of scopedSpaces) {\n\t\tconst space = aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst spaceContractHash = space.contract().storage.storageHash;\n\t\tconst targetHash = resolveTarget(spaceContractHash, activeRefHash);\n\t\tif (spaceEntry.space === aggregate.app.spaceId) headlineTargetHash = targetHash;\n\t\tconst markerRecord = markersBySpace.get(spaceEntry.space);\n\t\tconst markerHash = usingFromOverride ? fromOverrideHash : markerRecord?.storageHash ?? void 0;\n\t\tconst originHash = markerHash ?? EMPTY_CONTRACT_HASH;\n\t\tconst markerInGraph = markerHash === void 0 || graph.nodes.has(markerHash) || markerHash === spaceContractHash;\n\t\tif (connected && !usingFromOverride && markerInGraph && originHash !== targetHash && findPath(graph, originHash, targetHash) === null) markerCannotReachTarget = true;\n\t\tif (connected && !usingFromOverride && markerHash !== void 0 && !markerInGraph) {\n\t\t\tmarkerDiverged = true;\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"MIGRATION.MARKER_NOT_IN_HISTORY\",\n\t\t\t\tseverity: \"warn\",\n\t\t\t\tmessage: \"Database was updated outside the migration system (marker does not match any migration)\",\n\t\t\t\thints: [\"Run 'prisma-next db sign' to overwrite the marker if the database already matches the contract\", \"Run 'prisma-next db update' to push the current contract to the database\"]\n\t\t\t});\n\t\t}\n\t\tconst ledger = ledgersBySpace.get(spaceEntry.space) ?? [];\n\t\tconst annotations = deriveStatusEdgeAnnotations({\n\t\t\tgraph,\n\t\t\ttargetHash,\n\t\t\toriginHash,\n\t\t\tappliedMigrationHashes: showAppliedOverlay ? appliedHashesFromLedger(ledger) : /* @__PURE__ */ new Set(),\n\t\t\tshowAppliedOverlay\n\t\t});\n\t\tconst isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n\t\tconst tree = renderSpaceTree({\n\t\t\tspace,\n\t\t\tliveContractHash: contractHash,\n\t\t\tmigrations: spaceEntry.migrations,\n\t\t\tmarkerHash,\n\t\t\tshowDbMarker,\n\t\t\tstatusOverlay: annotations,\n\t\t\tcolorize,\n\t\t\tglyphMode,\n\t\t\tisAppSpace,\n\t\t\t...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},\n\t\t\t...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}\n\t\t});\n\t\tconst migrations = buildStatusMigrations(spaceEntry.migrations, annotations);\n\t\tconst pending = countPending(migrations);\n\t\ttotalPending += pending;\n\t\tstatusSpaces.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\tcurrentContract: markerHash ?? null,\n\t\t\ttargetContract: targetHash,\n\t\t\tmigrations: [...migrations]\n\t\t});\n\t\tconst displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, \" \") : tree;\n\t\ttreeSections.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\ttree: displayTree,\n\t\t\tshowHeading: showSpaceHeadings\n\t\t});\n\t}\n\tif (connected && requiredInvariants.length > 0) {\n\t\tconst markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n\t\tconst markerSet = new Set(markerInvariants);\n\t\tconst missing = requiredInvariants.filter((id) => !markerSet.has(id));\n\t\tif (missing.length > 0) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"MIGRATION.MISSING_INVARIANTS\",\n\t\t\t\t...ifDefined(\"ref\", activeRefName),\n\t\t\t\tinvariants: missing,\n\t\t\t\tmessage: `missing invariant(s): ${missing.join(\", \")}`\n\t\t\t});\n\t\t\tif (activeRefHash !== void 0) {\n\t\t\t\tconst outcome = findPathWithDecision(appGraph, markersBySpace.get(aggregate.app.spaceId)?.storageHash ?? EMPTY_CONTRACT_HASH, activeRefHash, {\n\t\t\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\t\t\trequired: new Set(missing)\n\t\t\t\t});\n\t\t\t\tif (outcome.kind === \"unsatisfiable\") return notOk(mapMigrationToolsError(errorNoInvariantPath({\n\t\t\t\t\t...ifDefined(\"refName\", activeRefName),\n\t\t\t\t\trequired: [...missing].sort(),\n\t\t\t\t\tmissing: outcome.missing,\n\t\t\t\t\tstructuralPath: outcome.structuralPath.map(toStructuralEdge)\n\t\t\t\t})));\n\t\t\t}\n\t\t}\n\t}\n\tconst appMarkerHash = markersBySpace.get(aggregate.app.spaceId)?.storageHash;\n\tconst summary = markerCannotReachTarget ? buildNoPathSummary({\n\t\tmarkerHash: appMarkerHash,\n\t\ttargetHash: headlineTargetHash,\n\t\texplicitTarget: options.to !== void 0,\n\t\trefName: activeRefName\n\t}) : buildStatusHeadline({\n\t\tpendingCount: totalPending,\n\t\ttargetHash: headlineTargetHash,\n\t\tmarkerDiverged,\n\t\tmarkerHash: appMarkerHash\n\t});\n\tif (scopedSpaces.every((s) => s.migrations.length === 0)) return ok({\n\t\tok: true,\n\t\tspaces: statusSpaces,\n\t\tsummary: \"No migrations found\",\n\t\tdiagnostics,\n\t\ttreeSections\n\t});\n\treturn ok({\n\t\tok: true,\n\t\tspaces: statusSpaces,\n\t\tsummary,\n\t\tdiagnostics,\n\t\ttreeSections\n\t});\n}\nfunction createMigrationStatusCommand() {\n\tconst command = new Command(\"status\");\n\tsetCommandDescriptions(command, \"Show migration path and pending status\", \"Shows which migrations are pending between the database marker and\\nthe target contract. Requires a database connection.\\nPass --from for an offline path preview without a database.\\nUse `migration graph` for topology, `migration log` for history,\\nand `migration list` for on-disk enumeration.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration status --db $DATABASE_URL\",\n\t\t\"prisma-next migration status --to production --db $DATABASE_URL\",\n\t\t\"prisma-next migration status --from abc123 --to production\",\n\t\t\"prisma-next migration status --from abc123 --to production --json\",\n\t\t\"prisma-next migration status --ascii --from abc123 --to production\",\n\t\t\"prisma-next migration status --legend --from abc123 --to production\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--from <contract>\", \"Origin contract reference; same grammar as --to. Supplying --from switches to offline path computation.\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationStatusCommand(options, flags, ui), flags, ui, (statusResult) => {\n\t\t\tif (flags.json) {\n\t\t\t\tconst jsonResult = {\n\t\t\t\t\tok: true,\n\t\t\t\t\tspaces: [...statusResult.spaces],\n\t\t\t\t\tsummary: statusResult.summary,\n\t\t\t\t\tdiagnostics: [...statusResult.diagnostics]\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(jsonResult, null, 2));\n\t\t\t} else if (!flags.quiet) ui.output(formatStatusHumanOutput(statusResult, flags.color !== false));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { formatStatusHumanOutput as a, executeMigrationStatusCommand as i, buildStatusHeadline as n, formatStatusSummary as o, createMigrationStatusCommand as r, buildNoPathSummary as t };\n\n//# sourceMappingURL=migration-status-CE7cQLDq.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAS,4BAA4B,OAAO;CAC3C,MAAM,8BAA8B,IAAI,IAAI;CAC5C,IAAI,MAAM,oBACJ;OAAA,MAAM,QAAQ,MAAM,MAAM,gBAAgB,OAAO,GAAG,IAAI,MAAM,uBAAuB,IAAI,KAAK,aAAa,GAAG,YAAY,IAAI,KAAK,eAAe,EAAE,QAAQ,UAAU,CAAC;CAAA;CAE7K,IAAI,CAAC,MAAM,MAAM,MAAM,IAAI,MAAM,UAAU,GAAG,OAAO;CACrD,MAAM,cAAc,SAAS,MAAM,OAAO,MAAM,YAAY,MAAM,UAAU;CAC5E,IAAI,CAAC,aAAa,OAAO;CACzB,KAAK,MAAM,QAAQ,aAAa;EAC/B,IAAI,MAAM,uBAAuB,IAAI,KAAK,aAAa,GAAG;EAC1D,IAAI,YAAY,IAAI,KAAK,aAAa,CAAC,EAAE,WAAW,WAAW;EAC/D,YAAY,IAAI,KAAK,eAAe,EAAE,QAAQ,UAAU,CAAC;CAC1D;CACA,OAAO;AACR;AACA,SAAS,wBAAwB,eAAe;CAC/C,OAAO,IAAI,IAAI,cAAc,KAAK,UAAU,MAAM,aAAa,CAAC;AACjE;AACA,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AI;KACJ,QAAQ,CAAC,GAAG,aAAa,MAAM;KAC/B,SAAS,aAAa;KACtB,aAAa,CAAC,GAAG,aAAa,WAAW;IAC1C;IACA,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;GAC9C,OAAO,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,wBAAwB,cAAc,MAAM,UAAU,KAAK,CAAC;EAChG,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
@@ -3,7 +3,7 @@ import { r as readContractSnapshotJson, t as contractSnapshotDir } from "./contr
3
3
  import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
4
4
  import { r as findLatestMigration } from "./migration-graph-CBf9ORe7-B4xAF8GN.mjs";
5
5
  import { E as errorRefSetHashNotInGraph, N as errorUnexpected, O as errorRuntime$1, P as formatCommandHelp, Q as mapRefResolutionError, T as errorRefSetEmptySentinel, Z as mapMigrationToolsError, at as resolveMigrationPaths, et as parseGlobalFlags, h as errorFileNotFound, o as createTerminalUI, q as handleResult, r as addGlobalOptions, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, w as errorRefSetBundleNotFound } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
6
- import { r as loadConfig } from "./exports-BTEdvV8H.mjs";
6
+ import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
7
7
  import { n as isGraphNode } from "./graph-membership-DW6nnbyQ-Bp2KcVwR.mjs";
8
8
  import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, u as validateRefValue } from "./refs-BDbB9BRB-D6Za3Q49.mjs";
9
9
  import { n as buildReadAggregate } from "./contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs";
@@ -168,4 +168,4 @@ function createRefCommand() {
168
168
  //#endregion
169
169
  export { executeRefSetCommand as i, executeRefDeleteCommand as n, executeRefListCommand as r, createRefCommand as t };
170
170
 
171
- //# sourceMappingURL=ref-tjLWCeGO.mjs.map
171
+ //# sourceMappingURL=ref-sHE8zOcm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref-tjLWCeGO.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/ref.mjs"],"sourcesContent":["import { $ as errorRefSetBundleNotFound, F as CliStructuredError, O as formatCommandHelp, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, et as errorRefSetEmptySentinel, g as parseGlobalFlagsOrExit, h as parseGlobalFlags, l as setCommandDescriptions, lt as mapMigrationToolsError, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorRefSetHashNotInGraph, ut as mapRefResolutionError, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { deleteRef, readRefs, validateRefName, validateRefValue, writeRef } from \"@internal/migration-tools/refs\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/ref.ts\nfunction mapError(error) {\n\tif (MigrationToolsError.is(error)) return mapMigrationToolsError(error);\n\treturn errorUnexpected(error instanceof Error ? error.message : String(error));\n}\nfunction cliErrorInvalidRefName(name) {\n\treturn errorRuntime(`Invalid ref name \"${name}\"`, {\n\t\twhy: `Ref name \"${name}\" does not match the required format`,\n\t\tfix: \"Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments\"\n\t});\n}\nasync function executeRefSetCommand(name, contractInput, options) {\n\tif (!validateRefName(name)) return notOk(cliErrorInvalidRefName(name));\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\t\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tlet resolvedHash;\n\t\tif (validateRefValue(contractInput)) resolvedHash = contractInput;\n\t\telse {\n\t\t\tconst refResult = parseContractRef(contractInput, {\n\t\t\t\tgraph,\n\t\t\t\trefs\n\t\t\t});\n\t\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\t\tresolvedHash = refResult.value.hash;\n\t\t}\n\t\tif (resolvedHash === EMPTY_CONTRACT_HASH) return notOk(errorRefSetEmptySentinel(resolvedHash));\n\t\tif (!isGraphNode(resolvedHash, graph)) {\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\treturn notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort(), graphTip));\n\t\t}\n\t\tif (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));\n\t\tconst contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), \"contract.json\");\n\t\ttry {\n\t\t\tawait readContractSnapshotJson(migrationsDir, resolvedHash);\n\t\t} catch (readError) {\n\t\t\tif (MigrationToolsError.is(readError) && readError.code === \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\") return notOk(errorFileNotFound(contractJsonPath, {\n\t\t\t\twhy: `Migration bundle for hash ${resolvedHash} is missing its contract snapshot at ${contractJsonPath}`,\n\t\t\t\tfix: \"Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot.\"\n\t\t\t}));\n\t\t\tthrow readError;\n\t\t}\n\t\tawait writeRef(refsDir, name, {\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefDeleteCommand(name, options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\tawait deleteRef(refsDir, name);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\tdeleted: true\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefListCommand(options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\trefs: await readRefs(refsDir)\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nfunction createRefSetCommand() {\n\tconst command = new Command(\"set\");\n\tsetCommandDescriptions(command, \"Set a ref to a contract reference\", \"Sets a named ref to point to a resolved contract reference (hash, alias, or path) in migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name (e.g., staging, production)\").argument(\"<contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, hash, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefSetCommand(name, hash, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Set ref \"${value.ref}\" → ${value.hash}`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefDeleteCommand() {\n\tconst command = new Command(\"delete\");\n\tsetCommandDescriptions(command, \"Delete a ref\", \"Removes a named ref from migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name to delete\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefDeleteCommand(name, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Deleted ref \"${value.ref}\"`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List all refs\", \"Lists all named refs from migrations/refs/.\");\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefListCommand(options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) {\n\t\t\t\tconst entries = Object.entries(value.refs);\n\t\t\t\tif (entries.length === 0) ui.output(\"No refs defined\");\n\t\t\t\telse for (const [refName, entry] of entries) {\n\t\t\t\t\tconst invariantsSuffix = entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(\", \")}]` : \"\";\n\t\t\t\t\tui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefCommand() {\n\tconst command = new Command(\"ref\");\n\tsetCommandDescriptions(command, \"Manage contract refs\", \"Manage named refs in migrations/refs/. Refs map logical environment\\nnames (e.g., staging, production) to contract hashes.\");\n\taddGlobalOptions(command).configureHelp({\n\t\tformatHelp: (cmd) => formatCommandHelp({\n\t\t\tcommand: cmd,\n\t\t\tflags: parseGlobalFlags({})\n\t\t}),\n\t\tsubcommandDescription: () => \"\"\n\t});\n\tcommand.addCommand(createRefSetCommand());\n\tcommand.addCommand(createRefDeleteCommand());\n\tcommand.addCommand(createRefListCommand());\n\treturn command;\n}\n//#endregion\nexport { createRefCommand, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand };\n\n//# sourceMappingURL=ref.mjs.map"],"mappings":";;;;;;;;;;;;;;AAaA,SAAS,SAAS,OAAO;CACxB,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,uBAAuB,KAAK;CACtE,OAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAC9E;AACA,SAAS,uBAAuB,MAAM;CACrC,OAAOA,eAAa,qBAAqB,KAAK,IAAI;EACjD,KAAK,aAAa,KAAK;EACvB,KAAK;CACN,CAAC;AACF;AACA,eAAe,qBAAqB,MAAM,eAAe,SAAS;CACjE,IAAI,CAAC,gBAAgB,IAAI,GAAG,OAAO,MAAM,uBAAuB,IAAI,CAAC;CACrE,IAAI;EACH,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;EAC9C,MAAM,EAAE,eAAe,YAAY,sBAAsB,QAAQ,QAAQ,MAAM;EAC/E,MAAM,SAAS,MAAM,mBAAmB,QAAQ,EAAE,cAAc,CAAC;EACjE,IAAI,CAAC,OAAO,IAAI,OAAO,MAAM,OAAO,OAAO;EAC3C,MAAM,QAAQ,OAAO,MAAM,UAAU,IAAI,MAAM;EAC/C,MAAM,UAAU,OAAO,MAAM,UAAU,IAAI;EAC3C,MAAM,OAAO,OAAO,MAAM,UAAU,IAAI;EACxC,IAAI;EACJ,IAAI,iBAAiB,aAAa,GAAG,eAAe;OAC/C;GACJ,MAAM,YAAY,iBAAiB,eAAe;IACjD;IACA;GACD,CAAC;GACD,IAAI,CAAC,UAAU,IAAI,OAAO,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CAAC,cAAc;EACvC,aAAa,QAAQ,kBAAkB;GACtC,SAAS;GACT,OAAO,iBAAiB,CAAC,CAAC;EAC3B,CAAC;EACD,6BAA6B;CAC9B,CAAC;CACD,QAAQ,WAAW,oBAAoB,CAAC;CACxC,QAAQ,WAAW,uBAAuB,CAAC;CAC3C,QAAQ,WAAW,qBAAqB,CAAC;CACzC,OAAO;AACR"}
1
+ {"version":3,"file":"ref-sHE8zOcm.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/ref.mjs"],"sourcesContent":["import { $ as errorRefSetBundleNotFound, F as CliStructuredError, O as formatCommandHelp, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, et as errorRefSetEmptySentinel, g as parseGlobalFlagsOrExit, h as parseGlobalFlags, l as setCommandDescriptions, lt as mapMigrationToolsError, rt as errorRuntime, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorRefSetHashNotInGraph, ut as mapRefResolutionError, y as handleResult } from \"../command-helpers-CAoXqAY9.mjs\";\nimport { n as buildReadAggregate } from \"../contract-space-aggregate-loader-CFH-336b.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { join } from \"pathe\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { MigrationToolsError } from \"@internal/migration-tools/errors\";\nimport { findLatestMigration, isGraphNode } from \"@internal/migration-tools/migration-graph\";\nimport { contractSnapshotDir, readContractSnapshotJson } from \"@internal/migration-tools/contract-snapshot-store\";\nimport { deleteRef, readRefs, validateRefName, validateRefValue, writeRef } from \"@internal/migration-tools/refs\";\nimport { parseContractRef } from \"@internal/migration-tools/ref-resolution\";\n//#region src/commands/ref.ts\nfunction mapError(error) {\n\tif (MigrationToolsError.is(error)) return mapMigrationToolsError(error);\n\treturn errorUnexpected(error instanceof Error ? error.message : String(error));\n}\nfunction cliErrorInvalidRefName(name) {\n\treturn errorRuntime(`Invalid ref name \"${name}\"`, {\n\t\twhy: `Ref name \"${name}\" does not match the required format`,\n\t\tfix: \"Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments\"\n\t});\n}\nasync function executeRefSetCommand(name, contractInput, options) {\n\tif (!validateRefName(name)) return notOk(cliErrorInvalidRefName(name));\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\t\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\t\tif (!loaded.ok) return notOk(loaded.failure);\n\t\tconst graph = loaded.value.aggregate.app.graph();\n\t\tconst bundles = loaded.value.aggregate.app.packages;\n\t\tconst refs = loaded.value.aggregate.app.refs;\n\t\tlet resolvedHash;\n\t\tif (validateRefValue(contractInput)) resolvedHash = contractInput;\n\t\telse {\n\t\t\tconst refResult = parseContractRef(contractInput, {\n\t\t\t\tgraph,\n\t\t\t\trefs\n\t\t\t});\n\t\t\tif (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));\n\t\t\tresolvedHash = refResult.value.hash;\n\t\t}\n\t\tif (resolvedHash === EMPTY_CONTRACT_HASH) return notOk(errorRefSetEmptySentinel(resolvedHash));\n\t\tif (!isGraphNode(resolvedHash, graph)) {\n\t\t\tconst graphTip = findLatestMigration(graph)?.to ?? null;\n\t\t\treturn notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort(), graphTip));\n\t\t}\n\t\tif (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));\n\t\tconst contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), \"contract.json\");\n\t\ttry {\n\t\t\tawait readContractSnapshotJson(migrationsDir, resolvedHash);\n\t\t} catch (readError) {\n\t\t\tif (MigrationToolsError.is(readError) && readError.code === \"MIGRATION.CONTRACT_SNAPSHOT_MISSING\") return notOk(errorFileNotFound(contractJsonPath, {\n\t\t\t\twhy: `Migration bundle for hash ${resolvedHash} is missing its contract snapshot at ${contractJsonPath}`,\n\t\t\t\tfix: \"Restore migrations/snapshots/ from version control, or re-run the command that produced this migration to regenerate its snapshot.\"\n\t\t\t}));\n\t\t\tthrow readError;\n\t\t}\n\t\tawait writeRef(refsDir, name, {\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\thash: resolvedHash,\n\t\t\tinvariants: []\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefDeleteCommand(name, options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\tawait deleteRef(refsDir, name);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tref: name,\n\t\t\tdeleted: true\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nasync function executeRefListCommand(options) {\n\ttry {\n\t\tconst config = await loadConfig(options.config);\n\t\tconst { refsDir } = resolveMigrationPaths(options.config, config);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\trefs: await readRefs(refsDir)\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(mapError(error));\n\t}\n}\nfunction createRefSetCommand() {\n\tconst command = new Command(\"set\");\n\tsetCommandDescriptions(command, \"Set a ref to a contract reference\", \"Sets a named ref to point to a resolved contract reference (hash, alias, or path) in migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name (e.g., staging, production)\").argument(\"<contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, hash, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefSetCommand(name, hash, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Set ref \"${value.ref}\" → ${value.hash}`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefDeleteCommand() {\n\tconst command = new Command(\"delete\");\n\tsetCommandDescriptions(command, \"Delete a ref\", \"Removes a named ref from migrations/refs/.\");\n\taddGlobalOptions(command).argument(\"<name>\", \"Ref name to delete\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (name, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefDeleteCommand(name, options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) ui.output(`Deleted ref \"${value.ref}\"`);\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List all refs\", \"Lists all named refs from migrations/refs/.\");\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeRefListCommand(options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value));\n\t\t\telse if (!flags.quiet) {\n\t\t\t\tconst entries = Object.entries(value.refs);\n\t\t\t\tif (entries.length === 0) ui.output(\"No refs defined\");\n\t\t\t\telse for (const [refName, entry] of entries) {\n\t\t\t\t\tconst invariantsSuffix = entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(\", \")}]` : \"\";\n\t\t\t\t\tui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\nfunction createRefCommand() {\n\tconst command = new Command(\"ref\");\n\tsetCommandDescriptions(command, \"Manage contract refs\", \"Manage named refs in migrations/refs/. Refs map logical environment\\nnames (e.g., staging, production) to contract hashes.\");\n\taddGlobalOptions(command).configureHelp({\n\t\tformatHelp: (cmd) => formatCommandHelp({\n\t\t\tcommand: cmd,\n\t\t\tflags: parseGlobalFlags({})\n\t\t}),\n\t\tsubcommandDescription: () => \"\"\n\t});\n\tcommand.addCommand(createRefSetCommand());\n\tcommand.addCommand(createRefDeleteCommand());\n\tcommand.addCommand(createRefListCommand());\n\treturn command;\n}\n//#endregion\nexport { createRefCommand, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand };\n\n//# sourceMappingURL=ref.mjs.map"],"mappings":";;;;;;;;;;;;;;AAaA,SAAS,SAAS,OAAO;CACxB,IAAI,oBAAoB,GAAG,KAAK,GAAG,OAAO,uBAAuB,KAAK;CACtE,OAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAC9E;AACA,SAAS,uBAAuB,MAAM;CACrC,OAAOA,eAAa,qBAAqB,KAAK,IAAI;EACjD,KAAK,aAAa,KAAK;EACvB,KAAK;CACN,CAAC;AACF;AACA,eAAe,qBAAqB,MAAM,eAAe,SAAS;CACjE,IAAI,CAAC,gBAAgB,IAAI,GAAG,OAAO,MAAM,uBAAuB,IAAI,CAAC;CACrE,IAAI;EACH,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;EAC9C,MAAM,EAAE,eAAe,YAAY,sBAAsB,QAAQ,QAAQ,MAAM;EAC/E,MAAM,SAAS,MAAM,mBAAmB,QAAQ,EAAE,cAAc,CAAC;EACjE,IAAI,CAAC,OAAO,IAAI,OAAO,MAAM,OAAO,OAAO;EAC3C,MAAM,QAAQ,OAAO,MAAM,UAAU,IAAI,MAAM;EAC/C,MAAM,UAAU,OAAO,MAAM,UAAU,IA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