prisma-next 0.12.0-dev.27 → 0.12.0-dev.29

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 (97) hide show
  1. package/dist/cli.mjs +12 -12
  2. package/dist/{client-V7BkIQrQ.mjs → client-xeWpMlq1.mjs} +22 -11
  3. package/dist/client-xeWpMlq1.mjs.map +1 -0
  4. package/dist/{command-helpers-DlrUCI7s.mjs → command-helpers-DK_5ItoJ.mjs} +253 -2
  5. package/dist/command-helpers-DK_5ItoJ.mjs.map +1 -0
  6. package/dist/commands/contract-emit.mjs +1 -1
  7. package/dist/commands/contract-infer.mjs +1 -1
  8. package/dist/commands/db-init.mjs +4 -5
  9. package/dist/commands/db-init.mjs.map +1 -1
  10. package/dist/commands/db-schema.mjs +3 -3
  11. package/dist/commands/db-sign.mjs +4 -4
  12. package/dist/commands/db-update.d.mts.map +1 -1
  13. package/dist/commands/db-update.mjs +10 -7
  14. package/dist/commands/db-update.mjs.map +1 -1
  15. package/dist/commands/db-verify.mjs +1 -1
  16. package/dist/commands/migrate.d.mts +1 -1
  17. package/dist/commands/migrate.mjs +5 -6
  18. package/dist/commands/migrate.mjs.map +1 -1
  19. package/dist/commands/migration-check.mjs +1 -1
  20. package/dist/commands/migration-graph.d.mts +12 -15
  21. package/dist/commands/migration-graph.d.mts.map +1 -1
  22. package/dist/commands/migration-graph.mjs +84 -51
  23. package/dist/commands/migration-graph.mjs.map +1 -1
  24. package/dist/commands/migration-list.d.mts +14 -5
  25. package/dist/commands/migration-list.d.mts.map +1 -1
  26. package/dist/commands/migration-list.mjs +1 -187
  27. package/dist/commands/migration-log.d.mts +2 -2
  28. package/dist/commands/migration-log.mjs +1 -1
  29. package/dist/commands/migration-new.mjs +3 -3
  30. package/dist/commands/migration-plan.mjs +1 -1
  31. package/dist/commands/migration-show.d.mts +1 -1
  32. package/dist/commands/migration-show.mjs +3 -4
  33. package/dist/commands/migration-show.mjs.map +1 -1
  34. package/dist/commands/migration-status.d.mts +21 -3
  35. package/dist/commands/migration-status.d.mts.map +1 -1
  36. package/dist/commands/migration-status.mjs +2 -3
  37. package/dist/commands/ref.d.mts +1 -1
  38. package/dist/commands/ref.mjs +3 -3
  39. package/dist/commands/telemetry/index.mjs +1 -1
  40. package/dist/{contract-at-errors-DlZHXSkI.mjs → contract-at-errors-DG3kjgoz.mjs} +2 -2
  41. package/dist/{contract-at-errors-DlZHXSkI.mjs.map → contract-at-errors-DG3kjgoz.mjs.map} +1 -1
  42. package/dist/{contract-emit-S53EyBRV.mjs → contract-emit-BO0l6fnT.mjs} +3 -3
  43. package/dist/{contract-emit-S53EyBRV.mjs.map → contract-emit-BO0l6fnT.mjs.map} +1 -1
  44. package/dist/{contract-emit-CaKp92-Q.mjs → contract-emit-C0Bs0VRj.mjs} +3 -3
  45. package/dist/{contract-emit-CaKp92-Q.mjs.map → contract-emit-C0Bs0VRj.mjs.map} +1 -1
  46. package/dist/{contract-infer-Cebb-_Qx.mjs → contract-infer-2wtPflGH.mjs} +3 -3
  47. package/dist/{contract-infer-Cebb-_Qx.mjs.map → contract-infer-2wtPflGH.mjs.map} +1 -1
  48. package/dist/{contract-space-aggregate-loader-Dvl1SJ4C.mjs → contract-space-aggregate-loader-Dbr3-jHF.mjs} +3 -3
  49. package/dist/{contract-space-aggregate-loader-Dvl1SJ4C.mjs.map → contract-space-aggregate-loader-Dbr3-jHF.mjs.map} +1 -1
  50. package/dist/{db-verify-B1OoWEWn.mjs → db-verify-CxHiSiTG.mjs} +4 -4
  51. package/dist/{db-verify-B1OoWEWn.mjs.map → db-verify-CxHiSiTG.mjs.map} +1 -1
  52. package/dist/exports/control-api.d.mts +1 -1
  53. package/dist/exports/control-api.mjs +2 -2
  54. package/dist/exports/index.mjs +1 -1
  55. package/dist/{framework-components-DCAT1uUC.mjs → framework-components-CxOVKAAh.mjs} +2 -2
  56. package/dist/{framework-components-DCAT1uUC.mjs.map → framework-components-CxOVKAAh.mjs.map} +1 -1
  57. package/dist/{init-Kf3T4A4W.mjs → init-R272pxux.mjs} +3 -3
  58. package/dist/{init-Kf3T4A4W.mjs.map → init-R272pxux.mjs.map} +1 -1
  59. package/dist/{inspect-live-schema-DTqflZ8X.mjs → inspect-live-schema-RekOwfi5.mjs} +3 -3
  60. package/dist/{inspect-live-schema-DTqflZ8X.mjs.map → inspect-live-schema-RekOwfi5.mjs.map} +1 -1
  61. package/dist/{migration-check-Ccyd0QKb.mjs → migration-check-Dc0cOhKH.mjs} +2 -2
  62. package/dist/{migration-check-Ccyd0QKb.mjs.map → migration-check-Dc0cOhKH.mjs.map} +1 -1
  63. package/dist/{migration-command-scaffold-DI7_SFL0.mjs → migration-command-scaffold-ApB3NxWY.mjs} +3 -3
  64. package/dist/{migration-command-scaffold-DI7_SFL0.mjs.map → migration-command-scaffold-ApB3NxWY.mjs.map} +1 -1
  65. package/dist/{migration-graph-tree-render-DyDBuJEX.mjs → migration-graph-space-render-dmLLWift.mjs} +389 -210
  66. package/dist/migration-graph-space-render-dmLLWift.mjs.map +1 -0
  67. package/dist/migration-list-C5sXrl0U.mjs +228 -0
  68. package/dist/migration-list-C5sXrl0U.mjs.map +1 -0
  69. package/dist/{migration-list-types-DV9PBc7Z.d.mts → migration-list-types-DS63IdFd.d.mts} +1 -1
  70. package/dist/{migration-list-types-DV9PBc7Z.d.mts.map → migration-list-types-DS63IdFd.d.mts.map} +1 -1
  71. package/dist/{migration-log-Des4seHP.mjs → migration-log-DD_vCbYW.mjs} +4 -4
  72. package/dist/{migration-log-Des4seHP.mjs.map → migration-log-DD_vCbYW.mjs.map} +1 -1
  73. package/dist/{migration-plan-DxDTBzGS.mjs → migration-plan-CeTjQOIG.mjs} +5 -5
  74. package/dist/{migration-plan-DxDTBzGS.mjs.map → migration-plan-CeTjQOIG.mjs.map} +1 -1
  75. package/dist/{migration-status-CCwqA-vi.mjs → migration-status-qV8ctwPy.mjs} +61 -45
  76. package/dist/migration-status-qV8ctwPy.mjs.map +1 -0
  77. package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-V1o-9LVK.mjs} +1 -1
  78. package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-V1o-9LVK.mjs.map} +1 -1
  79. package/dist/{telemetry-LFFQmqHd.mjs → telemetry-S-NGi9U6.mjs} +2 -2
  80. package/dist/{telemetry-LFFQmqHd.mjs.map → telemetry-S-NGi9U6.mjs.map} +1 -1
  81. package/dist/{terminal-ui-C3xGyxW-.d.mts → terminal-ui-5Y6mrg93.d.mts} +1 -1
  82. package/dist/{terminal-ui-C3xGyxW-.d.mts.map → terminal-ui-5Y6mrg93.d.mts.map} +1 -1
  83. package/dist/{types-BdS8PoKM.d.mts → types-Mh7mdPHM.d.mts} +5 -1
  84. package/dist/types-Mh7mdPHM.d.mts.map +1 -0
  85. package/dist/{verify-C0TARc6h.mjs → verify-BdI-BgYi.mjs} +2 -2
  86. package/dist/{verify-C0TARc6h.mjs.map → verify-BdI-BgYi.mjs.map} +1 -1
  87. package/package.json +11 -11
  88. package/dist/client-V7BkIQrQ.mjs.map +0 -1
  89. package/dist/command-helpers-DlrUCI7s.mjs.map +0 -1
  90. package/dist/commands/migration-list.mjs.map +0 -1
  91. package/dist/migration-graph-tree-render-DyDBuJEX.mjs.map +0 -1
  92. package/dist/migration-status-CCwqA-vi.mjs.map +0 -1
  93. package/dist/migration-types-CAQ-0TEE.d.mts +0 -15
  94. package/dist/migration-types-CAQ-0TEE.d.mts.map +0 -1
  95. package/dist/migrations-B3H6RTXb.mjs +0 -228
  96. package/dist/migrations-B3H6RTXb.mjs.map +0 -1
  97. package/dist/types-BdS8PoKM.d.mts.map +0 -1
@@ -1,36 +1,51 @@
1
1
  import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
2
- import { T as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from "../command-helpers-DlrUCI7s.mjs";
3
- import { n as buildReadAggregate } from "../contract-space-aggregate-loader-Dvl1SJ4C.mjs";
4
- import { c as buildMigrationGraphLayout, n as renderMigrationGraphTree, s as buildMigrationGraphRows, t as renderMigrationGraphLegend } from "../migration-graph-tree-render-DyDBuJEX.mjs";
2
+ import { A as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from "../command-helpers-DK_5ItoJ.mjs";
3
+ import { n as buildReadAggregate } from "../contract-space-aggregate-loader-Dbr3-jHF.mjs";
4
+ import { a as renderMigrationGraphLegend, i as renderMigrationGraphSpaceTree, n as computeGlobalMaxEdgeTreePrefixWidth, r as indentMigrationGraphTreeBlock, t as computeGlobalMaxDirNameWidth } from "../migration-graph-space-render-dmLLWift.mjs";
5
+ import { c as validateLegendOptions, i as migrationSpaceListEntriesFromAggregate, o as runMigrationList, r as listRefsByContractHash, s as shouldShowLegend } from "../migration-list-C5sXrl0U.mjs";
5
6
  import { Command } from "commander";
7
+ import { ifDefined } from "@prisma-next/utils/defined";
6
8
  import { ok } from "@prisma-next/utils/result";
7
9
  //#region src/commands/migration-graph.ts
8
- /**
9
- * The legend is decoration printed alongside the command header on stderr, so
10
- * it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,
11
- * `--quiet`) exactly as the header is.
12
- */
13
- function migrationGraphShowsLegend(options, flags) {
14
- return options.legend === true && options.dot !== true && flags.json !== true && flags.quiet !== true;
10
+ function computeGraphSummary(graph) {
11
+ return `${graph.nodes.size} node(s), ${graph.migrationByHash.size} edge(s)`;
12
+ }
13
+ function formatMigrationGraphHumanOutput(result) {
14
+ const sections = [];
15
+ for (const section of result.treeSections) {
16
+ if (section.showHeading) sections.push(`${section.spaceId}:`);
17
+ if (section.tree.length > 0) sections.push(section.tree);
18
+ else sections.push("(no migrations)");
19
+ sections.push("");
20
+ }
21
+ sections.push(result.summary);
22
+ return sections.join("\n").trimEnd();
15
23
  }
16
24
  async function executeMigrationGraphCommand(options, flags, ui) {
17
25
  const config = await loadConfig(options.config);
18
- const { configPath, appMigrationsRelative, migrationsDir } = resolveMigrationPaths(options.config, config);
26
+ const { configPath, migrationsRelative, migrationsDir } = resolveMigrationPaths(options.config, config);
19
27
  if (!flags.json && !flags.quiet) {
20
28
  const header = formatStyledHeader({
21
29
  command: "migration graph",
22
30
  description: "Show the migration graph topology",
23
- details: [{
24
- label: "config",
25
- value: configPath
26
- }, {
27
- label: "migrations",
28
- value: appMigrationsRelative
29
- }],
31
+ details: [
32
+ {
33
+ label: "config",
34
+ value: configPath
35
+ },
36
+ {
37
+ label: "migrations",
38
+ value: migrationsRelative
39
+ },
40
+ ...options.space !== void 0 ? [{
41
+ label: "space",
42
+ value: options.space
43
+ }] : []
44
+ ],
30
45
  flags
31
46
  });
32
47
  ui.stderr(header);
33
- if (migrationGraphShowsLegend(options, flags)) {
48
+ if (shouldShowLegend(options, flags)) {
34
49
  ui.stderr(renderMigrationGraphLegend({
35
50
  colorize: flags.color !== false,
36
51
  glyphMode: ui.resolveGlyphMode(options.ascii === true)
@@ -40,18 +55,50 @@ async function executeMigrationGraphCommand(options, flags, ui) {
40
55
  }
41
56
  const loaded = await buildReadAggregate(config, { migrationsDir });
42
57
  if (!loaded.ok) return loaded;
43
- const { aggregate, contractHash } = loaded.value;
44
- const graph = aggregate.app.graph();
58
+ const { aggregate, contractHash: liveContractHash } = loaded.value;
59
+ const appGraph = aggregate.app.graph();
60
+ const listResult = runMigrationList({
61
+ spaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),
62
+ ...ifDefined("spaceFilter", options.space)
63
+ });
64
+ if (!listResult.ok) return listResult;
65
+ const scopedSpaces = listResult.value.spaces;
66
+ const showSpaceHeadings = scopedSpaces.length > 1;
67
+ const glyphMode = ui.resolveGlyphMode(options.ascii === true);
68
+ const colorize = flags.color !== false;
69
+ const globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({
70
+ graph: aggregate.space(spaceEntry.spaceId).graph(),
71
+ liveContractHash
72
+ })) : [];
73
+ const globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;
74
+ const globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;
75
+ const treeSections = [];
76
+ for (const spaceEntry of scopedSpaces) {
77
+ const member = aggregate.space(spaceEntry.spaceId);
78
+ if (member === void 0) continue;
79
+ const graph = member.graph();
80
+ const tree = spaceEntry.migrations.length === 0 ? "" : renderMigrationGraphSpaceTree({
81
+ graph,
82
+ migrations: spaceEntry.migrations,
83
+ liveContractHash,
84
+ glyphMode,
85
+ colorize,
86
+ refsByHash: listRefsByContractHash(member),
87
+ ...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},
88
+ ...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}
89
+ });
90
+ const displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, " ") : tree;
91
+ treeSections.push({
92
+ spaceId: spaceEntry.spaceId,
93
+ tree: displayTree,
94
+ showHeading: showSpaceHeadings
95
+ });
96
+ }
45
97
  return ok({
46
98
  ok: true,
47
- graph,
48
- contractHash,
49
- refs: Object.entries(aggregate.app.refs).map(([name, entry]) => ({
50
- name,
51
- hash: entry.hash,
52
- active: false
53
- })),
54
- summary: `${graph.nodes.size} node(s), ${graph.migrationByHash.size} edge(s)`
99
+ graph: appGraph,
100
+ treeSections,
101
+ summary: computeGraphSummary(appGraph)
55
102
  });
56
103
  }
57
104
  function createMigrationGraphCommand() {
@@ -62,7 +109,8 @@ function createMigrationGraphCommand() {
62
109
  "prisma-next migration graph --json",
63
110
  "prisma-next migration graph --dot",
64
111
  "prisma-next migration graph --ascii",
65
- "prisma-next migration graph --legend"
112
+ "prisma-next migration graph --legend",
113
+ "prisma-next migration graph --space app"
66
114
  ]);
67
115
  setCommandSeeAlso(command, [
68
116
  {
@@ -82,9 +130,11 @@ function createMigrationGraphCommand() {
82
130
  oneLiner: "Display migration package contents"
83
131
  }
84
132
  ]);
85
- addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--dot", "Output in Graphviz DOT format").option("--ascii", "Use ASCII glyphs (pipe-friendly)").option("--legend", "Print a key for the tree glyphs and lane colors").action(async (options) => {
133
+ addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").option("--dot", "Output in Graphviz DOT format").option("--ascii", "Use ASCII glyphs (pipe-friendly)").option("--legend", "Print a key for the tree glyphs and lane colors").action(async (options) => {
86
134
  const flags = parseGlobalFlagsOrExit(options);
87
135
  const ui = createTerminalUI(flags);
136
+ const legendValidation = validateLegendOptions(options, flags);
137
+ if (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));
88
138
  const exitCode = handleResult(await executeMigrationGraphCommand(options, flags, ui), flags, ui, (graphResult) => {
89
139
  if (options.dot) {
90
140
  const lines = ["digraph migrations {"];
@@ -107,32 +157,15 @@ function createMigrationGraphCommand() {
107
157
  ok: true,
108
158
  nodes,
109
159
  edges,
110
- summary: graphResult.summary
160
+ summary: `${graphResult.graph.nodes.size} node(s), ${graphResult.graph.migrationByHash.size} edge(s)`
111
161
  }, null, 2));
112
- } else if (!flags.quiet) {
113
- const refsByHash = /* @__PURE__ */ new Map();
114
- for (const ref of graphResult.refs) {
115
- const existing = refsByHash.get(ref.hash);
116
- refsByHash.set(ref.hash, existing ? [...existing, ref.name] : [ref.name]);
117
- }
118
- const layout = buildMigrationGraphLayout(buildMigrationGraphRows(graphResult.graph, { ...graphResult.contractHash !== null ? { contractHash: graphResult.contractHash } : {} }));
119
- const activeRef = graphResult.refs.find((ref) => ref.active);
120
- const treeOutput = renderMigrationGraphTree(layout, {
121
- refsByHash,
122
- ...graphResult.contractHash !== null ? { contractHash: graphResult.contractHash } : {},
123
- ...activeRef !== void 0 ? { activeRefName: activeRef.name } : {},
124
- colorize: flags.color !== false,
125
- glyphMode: ui.resolveGlyphMode(options.ascii === true)
126
- });
127
- ui.output(treeOutput);
128
- ui.output(`\n${graphResult.summary}`);
129
- }
162
+ } else if (!flags.quiet) ui.output(formatMigrationGraphHumanOutput(graphResult));
130
163
  });
131
164
  process.exit(exitCode);
132
165
  });
133
166
  return command;
134
167
  }
135
168
  //#endregion
136
- export { createMigrationGraphCommand, executeMigrationGraphCommand, migrationGraphShowsLegend };
169
+ export { createMigrationGraphCommand, executeMigrationGraphCommand, formatMigrationGraphHumanOutput };
137
170
 
138
171
  //# sourceMappingURL=migration-graph.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-graph.mjs","names":[],"sources":["../../src/commands/migration-graph.ts"],"sourcesContent":["import type { MigrationGraph } from '@prisma-next/migration-tools/graph';\nimport { ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport type { CliStructuredError } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n} from '../utils/command-helpers';\nimport { buildReadAggregate } from '../utils/contract-space-aggregate-loader';\nimport { buildMigrationGraphLayout } from '../utils/formatters/migration-graph-layout';\nimport { buildMigrationGraphRows } from '../utils/formatters/migration-graph-rows';\nimport {\n renderMigrationGraphLegend,\n renderMigrationGraphTree,\n} from '../utils/formatters/migration-graph-tree-render';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport type { StatusRef } from '../utils/migration-types';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationGraphOptions extends CommonCommandOptions {\n readonly config?: string;\n readonly dot?: boolean;\n readonly ascii?: boolean;\n readonly legend?: boolean;\n}\n\n/**\n * The legend is decoration printed alongside the command header on stderr, so\n * it is suppressed for the machine-readable / silent paths (`--json`, `--dot`,\n * `--quiet`) exactly as the header is.\n */\nexport function migrationGraphShowsLegend(\n options: { readonly legend?: boolean; readonly dot?: boolean },\n flags: GlobalFlags,\n): boolean {\n return (\n options.legend === true && options.dot !== true && flags.json !== true && flags.quiet !== true\n );\n}\n\nexport interface MigrationGraphResult {\n readonly ok: true;\n readonly graph: MigrationGraph;\n readonly contractHash: string | null;\n readonly refs: readonly StatusRef[];\n readonly summary: string;\n}\n\nexport async function executeMigrationGraphCommand(\n options: MigrationGraphOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationGraphResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, appMigrationsRelative, migrationsDir } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration graph',\n description: 'Show the migration graph topology',\n details: [\n { label: 'config', value: configPath },\n { label: 'migrations', value: appMigrationsRelative },\n ],\n flags,\n });\n ui.stderr(header);\n if (migrationGraphShowsLegend(options, flags)) {\n ui.stderr(\n renderMigrationGraphLegend({\n colorize: flags.color !== false,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n }),\n );\n ui.stderr('');\n }\n }\n\n const loaded = await buildReadAggregate(config, { migrationsDir });\n if (!loaded.ok) {\n return loaded;\n }\n\n const { aggregate, contractHash } = loaded.value;\n const graph = aggregate.app.graph();\n const refs: readonly StatusRef[] = Object.entries(aggregate.app.refs).map(([name, entry]) => ({\n name,\n hash: entry.hash,\n active: false,\n }));\n\n return ok({\n ok: true,\n graph,\n contractHash,\n refs,\n summary: `${graph.nodes.size} node(s), ${graph.migrationByHash.size} edge(s)`,\n });\n}\n\nexport function createMigrationGraphCommand(): Command {\n const command = new Command('graph');\n setCommandDescriptions(\n command,\n 'Show the migration graph topology',\n 'Renders the migration graph topology. Offline — does not consult\\n' +\n 'the database. --ascii swaps box-drawing for pipe-friendly ASCII glyphs.\\n' +\n 'Use --json for machine-readable output, or --dot for Graphviz DOT\\n' +\n 'format.',\n );\n setCommandExamples(command, [\n 'prisma-next migration graph',\n 'prisma-next migration graph --json',\n 'prisma-next migration graph --dot',\n 'prisma-next migration graph --ascii',\n 'prisma-next migration graph --legend',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration status', oneLiner: 'Show migration path and pending status' },\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration list', oneLiner: 'List on-disk migrations' },\n { verb: 'migration show', oneLiner: 'Display migration package contents' },\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--dot', 'Output in Graphviz DOT format')\n .option('--ascii', 'Use ASCII glyphs (pipe-friendly)')\n .option('--legend', 'Print a key for the tree glyphs and lane colors')\n .action(async (options: MigrationGraphOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n const result = await executeMigrationGraphCommand(options, flags, ui);\n const exitCode = handleResult(result, flags, ui, (graphResult) => {\n if (options.dot) {\n const lines = ['digraph migrations {'];\n for (const edge of graphResult.graph.migrationByHash.values()) {\n const from = edge.from.slice(0, 12);\n const to = edge.to.slice(0, 12);\n lines.push(` \"${from}\" -> \"${to}\" [label=\"${edge.dirName}\"];`);\n }\n lines.push('}');\n ui.output(lines.join('\\n'));\n } else if (flags.json) {\n const nodes = [...graphResult.graph.nodes];\n const edges = [...graphResult.graph.migrationByHash.values()].map((e) => ({\n dirName: e.dirName,\n from: e.from,\n to: e.to,\n migrationHash: e.migrationHash,\n }));\n ui.output(\n JSON.stringify({ ok: true, nodes, edges, summary: graphResult.summary }, null, 2),\n );\n } else if (!flags.quiet) {\n const refsByHash = new Map<string, string[]>();\n for (const ref of graphResult.refs) {\n const existing = refsByHash.get(ref.hash);\n refsByHash.set(ref.hash, existing ? [...existing, ref.name] : [ref.name]);\n }\n const rowModel = buildMigrationGraphRows(graphResult.graph, {\n ...(graphResult.contractHash !== null\n ? { contractHash: graphResult.contractHash }\n : {}),\n });\n const layout = buildMigrationGraphLayout(rowModel);\n const activeRef = graphResult.refs.find((ref) => ref.active);\n const treeOutput = renderMigrationGraphTree(layout, {\n refsByHash,\n ...(graphResult.contractHash !== null\n ? { contractHash: graphResult.contractHash }\n : {}),\n ...(activeRef !== undefined ? { activeRefName: activeRef.name } : {}),\n colorize: flags.color !== false,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n });\n ui.output(treeOutput);\n ui.output(`\\n${graphResult.summary}`);\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAgB,0BACd,SACA,OACS;CACT,OACE,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,SAAS,QAAQ,MAAM,UAAU;AAE9F;AAUA,eAAsB,6BACpB,SACA,OACA,IAC2D;CAC3D,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,YAAY,uBAAuB,kBAAkB,sBAC3D,QAAQ,QACR,MACF;CAEA,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAC/B,MAAM,SAAS,mBAAmB;GAChC,SAAS;GACT,aAAa;GACb,SAAS,CACP;IAAE,OAAO;IAAU,OAAO;GAAW,GACrC;IAAE,OAAO;IAAc,OAAO;GAAsB,CACtD;GACA;EACF,CAAC;EACD,GAAG,OAAO,MAAM;EAChB,IAAI,0BAA0B,SAAS,KAAK,GAAG;GAC7C,GAAG,OACD,2BAA2B;IACzB,UAAU,MAAM,UAAU;IAC1B,WAAW,GAAG,iBAAiB,QAAQ,UAAU,IAAI;GACvD,CAAC,CACH;GACA,GAAG,OAAO,EAAE;EACd;CACF;CAEA,MAAM,SAAS,MAAM,mBAAmB,QAAQ,EAAE,cAAc,CAAC;CACj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Q,KAAK,QAAQ;CACvB,CAAC;CACH,OAAO;AACT"}
1
+ {"version":3,"file":"migration-graph.mjs","names":[],"sources":["../../src/commands/migration-graph.ts"],"sourcesContent":["import type { MigrationGraph } from '@prisma-next/migration-tools/graph';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport type { CliStructuredError } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n} from '../utils/command-helpers';\nimport { buildReadAggregate } from '../utils/contract-space-aggregate-loader';\nimport {\n computeGlobalMaxDirNameWidth,\n computeGlobalMaxEdgeTreePrefixWidth,\n indentMigrationGraphTreeBlock,\n renderMigrationGraphSpaceTree,\n} from '../utils/formatters/migration-graph-space-render';\nimport { renderMigrationGraphLegend } from '../utils/formatters/migration-graph-tree-render';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { shouldShowLegend, validateLegendOptions } from '../utils/legend';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\nimport {\n listRefsByContractHash,\n migrationSpaceListEntriesFromAggregate,\n runMigrationList,\n} from './migration-list';\n\ninterface MigrationGraphOptions extends CommonCommandOptions {\n readonly config?: string;\n readonly dot?: boolean;\n readonly space?: string;\n readonly ascii?: boolean;\n readonly legend?: boolean;\n}\n\nexport interface MigrationGraphTreeSection {\n readonly spaceId: string;\n readonly tree: string;\n readonly showHeading: boolean;\n}\n\nexport interface MigrationGraphResult {\n readonly ok: true;\n /** App-space graph for `--json` / `--dot` (unchanged machine output). */\n readonly graph: MigrationGraph;\n readonly treeSections: readonly MigrationGraphTreeSection[];\n readonly summary: string;\n}\n\nfunction computeGraphSummary(graph: MigrationGraph): string {\n return `${graph.nodes.size} node(s), ${graph.migrationByHash.size} edge(s)`;\n}\n\nexport function formatMigrationGraphHumanOutput(result: MigrationGraphResult): string {\n const sections: string[] = [];\n for (const section of result.treeSections) {\n if (section.showHeading) {\n sections.push(`${section.spaceId}:`);\n }\n if (section.tree.length > 0) {\n sections.push(section.tree);\n } else {\n sections.push('(no migrations)');\n }\n sections.push('');\n }\n sections.push(result.summary);\n return sections.join('\\n').trimEnd();\n}\n\nexport async function executeMigrationGraphCommand(\n options: MigrationGraphOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationGraphResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsRelative, migrationsDir } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration graph',\n description: 'Show the migration graph topology',\n details: [\n { label: 'config', value: configPath },\n { label: 'migrations', value: migrationsRelative },\n ...(options.space !== undefined ? [{ label: 'space', value: options.space }] : []),\n ],\n flags,\n });\n ui.stderr(header);\n if (shouldShowLegend(options, flags)) {\n ui.stderr(\n renderMigrationGraphLegend({\n colorize: flags.color !== false,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n }),\n );\n ui.stderr('');\n }\n }\n\n const loaded = await buildReadAggregate(config, { migrationsDir });\n if (!loaded.ok) {\n return loaded;\n }\n\n const { aggregate, contractHash: liveContractHash } = loaded.value;\n const appGraph = aggregate.app.graph();\n\n const listSpaces = await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir);\n const listResult = runMigrationList({\n spaces: listSpaces,\n ...ifDefined('spaceFilter', options.space),\n });\n if (!listResult.ok) {\n return listResult;\n }\n\n const scopedSpaces = listResult.value.spaces;\n const showSpaceHeadings = scopedSpaces.length > 1;\n const glyphMode = ui.resolveGlyphMode(options.ascii === true);\n const colorize = flags.color !== false;\n\n const globalLayoutInputs = showSpaceHeadings\n ? scopedSpaces\n .filter((spaceEntry) => spaceEntry.migrations.length > 0)\n .map((spaceEntry) => ({\n graph: aggregate.space(spaceEntry.spaceId)!.graph(),\n liveContractHash,\n }))\n : [];\n const globalMaxEdgeTreePrefixWidth =\n globalLayoutInputs.length > 0\n ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs)\n : undefined;\n const globalMaxDirNameWidth =\n globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : undefined;\n\n const treeSections: MigrationGraphTreeSection[] = [];\n for (const spaceEntry of scopedSpaces) {\n const member = aggregate.space(spaceEntry.spaceId);\n if (member === undefined) {\n continue;\n }\n const graph = member.graph();\n const tree =\n spaceEntry.migrations.length === 0\n ? ''\n : renderMigrationGraphSpaceTree({\n graph,\n migrations: spaceEntry.migrations,\n liveContractHash,\n glyphMode,\n colorize,\n refsByHash: listRefsByContractHash(member),\n ...(globalMaxEdgeTreePrefixWidth !== undefined ? { globalMaxEdgeTreePrefixWidth } : {}),\n ...(globalMaxDirNameWidth !== undefined ? { globalMaxDirNameWidth } : {}),\n });\n const displayTree =\n showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, ' ') : tree;\n treeSections.push({\n spaceId: spaceEntry.spaceId,\n tree: displayTree,\n showHeading: showSpaceHeadings,\n });\n }\n\n return ok({\n ok: true,\n graph: appGraph,\n treeSections,\n summary: computeGraphSummary(appGraph),\n });\n}\n\nexport function createMigrationGraphCommand(): Command {\n const command = new Command('graph');\n setCommandDescriptions(\n command,\n 'Show the migration graph topology',\n 'Renders the migration graph topology. Offline — does not consult\\n' +\n 'the database. --ascii swaps box-drawing for pipe-friendly ASCII glyphs.\\n' +\n 'Use --json for machine-readable output, or --dot for Graphviz DOT\\n' +\n 'format.',\n );\n setCommandExamples(command, [\n 'prisma-next migration graph',\n 'prisma-next migration graph --json',\n 'prisma-next migration graph --dot',\n 'prisma-next migration graph --ascii',\n 'prisma-next migration graph --legend',\n 'prisma-next migration graph --space app',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration status', oneLiner: 'Show migration path and pending status' },\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration list', oneLiner: 'List on-disk migrations' },\n { verb: 'migration show', oneLiner: 'Display migration package contents' },\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--space <id>', 'Narrow output to a single contract space')\n .option('--dot', 'Output in Graphviz DOT format')\n .option('--ascii', 'Use ASCII glyphs (pipe-friendly)')\n .option('--legend', 'Print a key for the tree glyphs and lane colors')\n .action(async (options: MigrationGraphOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n const legendValidation = validateLegendOptions(options, flags);\n if (!legendValidation.ok) {\n process.exit(handleResult(legendValidation, flags, ui));\n }\n const result = await executeMigrationGraphCommand(options, flags, ui);\n const exitCode = handleResult(result, flags, ui, (graphResult) => {\n if (options.dot) {\n const lines = ['digraph migrations {'];\n for (const edge of graphResult.graph.migrationByHash.values()) {\n const from = edge.from.slice(0, 12);\n const to = edge.to.slice(0, 12);\n lines.push(` \"${from}\" -> \"${to}\" [label=\"${edge.dirName}\"];`);\n }\n lines.push('}');\n ui.output(lines.join('\\n'));\n } else if (flags.json) {\n const nodes = [...graphResult.graph.nodes];\n const edges = [...graphResult.graph.migrationByHash.values()].map((e) => ({\n dirName: e.dirName,\n from: e.from,\n to: e.to,\n migrationHash: e.migrationHash,\n }));\n ui.output(\n JSON.stringify(\n {\n ok: true,\n nodes,\n edges,\n summary: `${graphResult.graph.nodes.size} node(s), ${graphResult.graph.migrationByHash.size} edge(s)`,\n },\n null,\n 2,\n ),\n );\n } else if (!flags.quiet) {\n ui.output(formatMigrationGraphHumanOutput(graphResult));\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n"],"mappings":";;;;;;;;;AAuDA,SAAS,oBAAoB,OAA+B;CAC1D,OAAO,GAAG,MAAM,MAAM,KAAK,YAAY,MAAM,gBAAgB,KAAK;AACpE;AAEA,SAAg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AgB,OAAO,CAAC,EAAE,KAAK,OAAO;KACxE,SAAS,EAAE;KACX,MAAM,EAAE;KACR,IAAI,EAAE;KACN,eAAe,EAAE;IACnB,EAAE;IACF,GAAG,OACD,KAAK,UACH;KACE,IAAI;KACJ;KACA;KACA,SAAS,GAAG,YAAY,MAAM,MAAM,KAAK,YAAY,YAAY,MAAM,gBAAgB,KAAK;IAC9F,GACA,MACA,CACF,CACF;GACF,OAAO,IAAI,CAAC,MAAM,OAChB,GAAG,OAAO,gCAAgC,WAAW,CAAC;EAE1D,CAAC;EACD,QAAQ,KAAK,QAAQ;CACvB,CAAC;CACH,OAAO;AACT"}
@@ -1,10 +1,11 @@
1
- import { N as CliStructuredError } from "../types-BdS8PoKM.mjs";
1
+ import { N as CliStructuredError } from "../types-Mh7mdPHM.mjs";
2
2
  import { n as GlobalFlags, t as CommonCommandOptions } from "../global-flags-DG4uY5tV.mjs";
3
- import { n as GlyphMode, t as TerminalUI } from "../terminal-ui-C3xGyxW-.mjs";
4
- import { n as MigrationListResult, r as MigrationSpaceListEntry } from "../migration-list-types-DV9PBc7Z.mjs";
3
+ import { n as GlyphMode, t as TerminalUI } from "../terminal-ui-5Y6mrg93.mjs";
4
+ import { n as MigrationListResult, r as MigrationSpaceListEntry } from "../migration-list-types-DS63IdFd.mjs";
5
5
  import { Command } from "commander";
6
6
  import { Result } from "@prisma-next/utils/result";
7
7
  import { ContractSpaceAggregate, ContractSpaceMember } from "@prisma-next/migration-tools/aggregate";
8
+ import { MigrationGraph } from "@prisma-next/migration-tools/graph";
8
9
 
9
10
  //#region src/commands/migration-list.d.ts
10
11
  /**
@@ -29,10 +30,18 @@ interface MigrationListOptions extends CommonCommandOptions {
29
30
  readonly config?: string;
30
31
  readonly space?: string;
31
32
  readonly ascii?: boolean;
33
+ readonly legend?: boolean;
34
+ }
35
+ interface MigrationListExecuteResult {
36
+ readonly list: MigrationListResult;
37
+ readonly liveContractHash: string;
38
+ readonly aggregate: ContractSpaceAggregate;
32
39
  }
33
40
  interface MigrationListHumanRenderOptions {
34
41
  readonly glyphMode: GlyphMode;
35
42
  readonly useColor: boolean;
43
+ readonly liveContractHash: string;
44
+ readonly graphForSpace: (spaceId: string) => MigrationGraph | undefined;
36
45
  }
37
46
  declare function renderMigrationListHumanOutput(result: MigrationListResult, options: MigrationListHumanRenderOptions): string;
38
47
  /**
@@ -62,8 +71,8 @@ declare function runMigrationList(inputs: RunMigrationListInputs): Result<Migrat
62
71
  * stderr (interactive mode only), and delegates to {@link runMigrationList}.
63
72
  * Kept intentionally thin so the unit-testable surface lives in the core.
64
73
  */
65
- declare function executeMigrationListCommand(options: MigrationListOptions, flags: GlobalFlags, ui: TerminalUI): Promise<Result<MigrationListResult, CliStructuredError>>;
74
+ declare function executeMigrationListCommand(options: MigrationListOptions, flags: GlobalFlags, ui: TerminalUI): Promise<Result<MigrationListExecuteResult, CliStructuredError>>;
66
75
  declare function createMigrationListCommand(): Command;
67
76
  //#endregion
68
- export { MigrationListHumanRenderOptions, RunMigrationListInputs, createMigrationListCommand, executeMigrationListCommand, listRefsByContractHash, migrationSpaceListEntriesFromAggregate, renderMigrationListHumanOutput, runMigrationList };
77
+ export { MigrationListExecuteResult, MigrationListHumanRenderOptions, RunMigrationListInputs, createMigrationListCommand, executeMigrationListCommand, listRefsByContractHash, migrationSpaceListEntriesFromAggregate, renderMigrationListHumanOutput, runMigrationList };
69
78
  //# sourceMappingURL=migration-list.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-list.d.mts","names":[],"sources":["../../src/commands/migration-list.ts"],"mappings":";;;;;;;;;AAgEA;;;;;;;;AAAA,iBAAgB,sBAAA,CACd,MAAA,EAAQ,mBAAA,GACP,WAAW;AA4Bd;;;;;;;;AAAA,iBAAsB,sCAAA,CACpB,SAAA,EAAW,sBAAA,EACX,oBAAA,WACC,OAAA,UAAiB,uBAAA;AAAA,UA6BV,oBAAA,SAA6B,oBAAoB;EAAA,SAChD,MAAA;EAAA,SACA,KAAA;EAAA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+B;;;;;;;;;UAkBzB,sBAAA;EAAA,SACN,MAAA,WAAiB,uBAAuB;EAAA,SACxC,WAAA;AAAA;;;;;;;;;;iBAoBK,gBAAA,CACd,MAAA,EAAQ,sBAAA,GACP,MAAA,CAAO,mBAAA,EAAqB,kBAAA;AA/C8B;AAG7D;;;;AAH6D,iBA4EvC,2BAAA,CACpB,OAAA,EAAS,oBAAA,EACT,KAAA,EAAO,WAAA,EACP,EAAA,EAAI,UAAA,GACH,OAAA,CAAQ,MAAA,CAAO,0BAAA,EAA4B,kBAAA;AAAA,iBAiD9B,0BAAA,CAAA,GAA8B,OAAO"}
@@ -1,188 +1,2 @@
1
- import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
2
- import { B as errorInvalidSpaceId, Q as errorSpaceNotFound, T as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from "../command-helpers-DlrUCI7s.mjs";
3
- import { n as buildReadAggregate } from "../contract-space-aggregate-loader-Dvl1SJ4C.mjs";
4
- import { a as renderMigrationListWithStyle, r as createAnsiMigrationListStyler } from "../migration-graph-tree-render-DyDBuJEX.mjs";
5
- import { Command } from "commander";
6
- import { ifDefined } from "@prisma-next/utils/defined";
7
- import { notOk, ok } from "@prisma-next/utils/result";
8
- import { APP_SPACE_ID, RESERVED_SPACE_SUBDIR_NAMES, isValidSpaceId, listContractSpaceDirectories } from "@prisma-next/migration-tools/spaces";
9
- import { HEAD_REF_NAME, refsByContractHash } from "@prisma-next/migration-tools/refs";
10
- //#region src/commands/migration-list.ts
11
- function compareSpaceIds(a, b) {
12
- if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;
13
- if (b === APP_SPACE_ID) return 1;
14
- if (a < b) return -1;
15
- if (a > b) return 1;
16
- return 0;
17
- }
18
- function compareDirNamesDescending(a, b) {
19
- if (a.dirName < b.dirName) return 1;
20
- if (a.dirName > b.dirName) return -1;
21
- return 0;
22
- }
23
- /**
24
- * Ref names decorating a space's destination contract hashes. The
25
- * tolerant `member.refs` deliberately omits the structural `head.json`;
26
- * for extension spaces the old enumerator surfaced it as a `head`
27
- * decoration on the tip migration, so fold `member.headRef` back in to
28
- * keep that output. The app space synthesises its head, so it carries
29
- * no on-disk `head` ref to restore.
30
- */
31
- function listRefsByContractHash(member) {
32
- const byHash = new Map(refsByContractHash(member.refs));
33
- if (member.spaceId !== APP_SPACE_ID && member.headRef !== null) {
34
- const hash = member.headRef.hash;
35
- const bucket = byHash.get(hash) ?? [];
36
- if (!bucket.includes(HEAD_REF_NAME)) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());
37
- }
38
- return byHash;
39
- }
40
- async function orderedOnDiskSpaceIds(projectMigrationsDir) {
41
- return (await listContractSpaceDirectories(projectMigrationsDir)).filter((name) => !RESERVED_SPACE_SUBDIR_NAMES.has(name)).filter(isValidSpaceId).sort(compareSpaceIds);
42
- }
43
- /**
44
- * Project the loaded {@link ContractSpaceAggregate} into the render-ready
45
- * {@link MigrationSpaceListEntry} rows `migration list` displays.
46
- *
47
- * Space membership matches the on-disk contract-space directories (not the
48
- * aggregate's always-present synthesized app member when `migrations/app/`
49
- * is absent); package and ref data come from `aggregate.space(id)`.
50
- */
51
- async function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {
52
- const spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);
53
- const spaces = [];
54
- for (const spaceId of spaceIds) {
55
- const member = aggregate.space(spaceId);
56
- if (member === void 0) continue;
57
- const refsByHash = listRefsByContractHash(member);
58
- const migrations = member.packages.map((pkg) => ({
59
- dirName: pkg.dirName,
60
- from: pkg.metadata.from,
61
- to: pkg.metadata.to,
62
- migrationHash: pkg.metadata.migrationHash,
63
- operationCount: pkg.ops.length,
64
- createdAt: pkg.metadata.createdAt,
65
- refs: refsByHash.get(pkg.metadata.to) ?? [],
66
- providedInvariants: pkg.metadata.providedInvariants
67
- })).sort(compareDirNamesDescending);
68
- spaces.push({
69
- spaceId,
70
- migrations
71
- });
72
- }
73
- return spaces;
74
- }
75
- function renderMigrationListHumanOutput(result, options) {
76
- return renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, { colorize: options.useColor });
77
- }
78
- function computeSummary(spaces) {
79
- const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);
80
- if (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;
81
- return `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;
82
- }
83
- /**
84
- * Policy core of `migration list`: validates `--space`, narrows the
85
- * pre-enumerated spaces, and assembles a {@link MigrationListResult}.
86
- *
87
- * - `migrations/` missing or contains no valid space directories →
88
- * caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.
89
- * - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.
90
- * - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.
91
- */
92
- function runMigrationList(inputs) {
93
- const { spaces, spaceFilter } = inputs;
94
- if (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));
95
- if (spaceFilter !== void 0 && !spaces.some((s) => s.spaceId === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()));
96
- const scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;
97
- const resultSpaces = scopedSpaces.length === 0 ? [{
98
- spaceId: APP_SPACE_ID,
99
- migrations: []
100
- }] : scopedSpaces;
101
- return ok({
102
- ok: true,
103
- spaces: resultSpaces,
104
- summary: computeSummary(resultSpaces)
105
- });
106
- }
107
- /**
108
- * CLI shell: loads config, resolves paths, prints the styled header on
109
- * stderr (interactive mode only), and delegates to {@link runMigrationList}.
110
- * Kept intentionally thin so the unit-testable surface lives in the core.
111
- */
112
- async function executeMigrationListCommand(options, flags, ui) {
113
- const config = await loadConfig(options.config);
114
- const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);
115
- if (!flags.json && !flags.quiet) {
116
- const header = formatStyledHeader({
117
- command: "migration list",
118
- description: "List on-disk migrations per contract space",
119
- details: [
120
- {
121
- label: "config",
122
- value: configPath
123
- },
124
- {
125
- label: "migrations",
126
- value: migrationsRelative
127
- },
128
- ...options.space !== void 0 ? [{
129
- label: "space",
130
- value: options.space
131
- }] : []
132
- ],
133
- flags
134
- });
135
- ui.stderr(header);
136
- }
137
- const loaded = await buildReadAggregate(config, { migrationsDir });
138
- if (!loaded.ok) return notOk(loaded.failure);
139
- return runMigrationList({
140
- spaces: await migrationSpaceListEntriesFromAggregate(loaded.value.aggregate, migrationsDir),
141
- ...ifDefined("spaceFilter", options.space)
142
- });
143
- }
144
- function createMigrationListCommand() {
145
- const command = new Command("list");
146
- setCommandDescriptions(command, "List on-disk migrations per contract space", "Enumerates every on-disk migration under migrations/<space>/ for every\ncontract space found on disk. Offline — does not consult the database.\nHuman output draws the shared migration graph tree with operation counts,\ninvariants on each migration row, and refs on destination contract nodes.\nPass --space <id> to narrow to one contract space. --ascii forces ASCII\ntree glyphs (orthogonal to --no-color).");
147
- setCommandExamples(command, [
148
- "prisma-next migration list",
149
- "prisma-next migration list --space app",
150
- "prisma-next migration list --ascii",
151
- "prisma-next migration list --json"
152
- ]);
153
- setCommandSeeAlso(command, [
154
- {
155
- verb: "migration status",
156
- oneLiner: "Show migration path and pending status"
157
- },
158
- {
159
- verb: "migration log",
160
- oneLiner: "Show executed migration history"
161
- },
162
- {
163
- verb: "migration graph",
164
- oneLiner: "Show the migration graph topology"
165
- },
166
- {
167
- verb: "migration show",
168
- oneLiner: "Display migration package contents"
169
- }
170
- ]);
171
- addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").option("--ascii", "Use ASCII kind glyphs (pipe-friendly)").action(async (options) => {
172
- const flags = parseGlobalFlagsOrExit(options);
173
- const ui = createTerminalUI(flags);
174
- const exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, (listResult) => {
175
- if (flags.json) ui.output(JSON.stringify(listResult, null, 2));
176
- else if (!flags.quiet) ui.output(renderMigrationListHumanOutput(listResult, {
177
- glyphMode: ui.resolveGlyphMode(options.ascii === true),
178
- useColor: ui.useColor
179
- }));
180
- });
181
- process.exit(exitCode);
182
- });
183
- return command;
184
- }
185
- //#endregion
1
+ import { a as renderMigrationListHumanOutput, i as migrationSpaceListEntriesFromAggregate, n as executeMigrationListCommand, o as runMigrationList, r as listRefsByContractHash, t as createMigrationListCommand } from "../migration-list-C5sXrl0U.mjs";
186
2
  export { createMigrationListCommand, executeMigrationListCommand, listRefsByContractHash, migrationSpaceListEntriesFromAggregate, renderMigrationListHumanOutput, runMigrationList };
187
-
188
- //# sourceMappingURL=migration-list.mjs.map
@@ -1,6 +1,6 @@
1
- import { N as CliStructuredError } from "../types-BdS8PoKM.mjs";
1
+ import { N as CliStructuredError } from "../types-Mh7mdPHM.mjs";
2
2
  import { n as GlobalFlags, t as CommonCommandOptions } from "../global-flags-DG4uY5tV.mjs";
3
- import { t as TerminalUI } from "../terminal-ui-C3xGyxW-.mjs";
3
+ import { t as TerminalUI } from "../terminal-ui-5Y6mrg93.mjs";
4
4
  import { Command } from "commander";
5
5
  import { Result } from "@prisma-next/utils/result";
6
6
  import { LedgerEntryRecord } from "@prisma-next/contract/types";
@@ -1,2 +1,2 @@
1
- import { n as executeMigrationLogCommand, t as createMigrationLogCommand } from "../migration-log-Des4seHP.mjs";
1
+ import { n as executeMigrationLogCommand, t as createMigrationLogCommand } from "../migration-log-DD_vCbYW.mjs";
2
2
  export { createMigrationLogCommand, executeMigrationLogCommand };
@@ -1,7 +1,7 @@
1
1
  import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
2
- import { $ as errorTargetMigrationNotSupported, A as CliStructuredError, R as errorFileNotFound, T as formatStyledHeader, X as errorRuntime, _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, o as resolveContractPath, r as getTargetMigrations, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorUnexpected, u as setCommandExamples, y as handleResult } from "../command-helpers-DlrUCI7s.mjs";
3
- import { t as assertFrameworkComponentsCompatible } from "../framework-components-DCAT1uUC.mjs";
4
- import { o as refusePackageCorruptionOnAggregate } from "../contract-space-aggregate-loader-Dvl1SJ4C.mjs";
2
+ import { A as formatStyledHeader, F as CliStructuredError, U as errorFileNotFound, _ as createTerminalUI, at as errorTargetMigrationNotSupported, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, nt as errorRuntime, o as resolveContractPath, r as getTargetMigrations, s as resolveMigrationPaths, st as errorUnexpected, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from "../command-helpers-DK_5ItoJ.mjs";
3
+ import { t as assertFrameworkComponentsCompatible } from "../framework-components-CxOVKAAh.mjs";
4
+ import { o as refusePackageCorruptionOnAggregate } from "../contract-space-aggregate-loader-Dbr3-jHF.mjs";
5
5
  import { Command } from "commander";
6
6
  import { getEmittedArtifactPaths } from "@prisma-next/emitter";
7
7
  import { notOk, ok } from "@prisma-next/utils/result";
@@ -1,2 +1,2 @@
1
- import { n as formatMigrationPlanOutput, r as resolveBundleByPrefix, t as createMigrationPlanCommand } from "../migration-plan-DxDTBzGS.mjs";
1
+ import { n as formatMigrationPlanOutput, r as resolveBundleByPrefix, t as createMigrationPlanCommand } from "../migration-plan-CeTjQOIG.mjs";
2
2
  export { createMigrationPlanCommand, formatMigrationPlanOutput, resolveBundleByPrefix };
@@ -1,4 +1,4 @@
1
- import { N as CliStructuredError } from "../types-BdS8PoKM.mjs";
1
+ import { N as CliStructuredError } from "../types-Mh7mdPHM.mjs";
2
2
  import { Command } from "commander";
3
3
  import { Result } from "@prisma-next/utils/result";
4
4
  import { OperationPreview } from "@prisma-next/framework-components/control";
@@ -1,15 +1,14 @@
1
1
  import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
2
- import { P as errorContractValidationFailed, R as errorFileNotFound, T as formatStyledHeader, X as errorRuntime, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, o as resolveContractPath, rt as mapRefResolutionError, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorUnexpected, u as setCommandExamples, y as handleResult } from "../command-helpers-DlrUCI7s.mjs";
3
- import { t as createControlClient } from "../client-V7BkIQrQ.mjs";
4
- import { a as formatMigrationShowOutput } from "../migrations-B3H6RTXb.mjs";
2
+ import { A as formatStyledHeader, E as formatMigrationShowOutput, U as errorFileNotFound, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, lt as mapRefResolutionError, nt as errorRuntime, o as resolveContractPath, s as resolveMigrationPaths, st as errorUnexpected, t as addGlobalOptions, u as setCommandExamples, y as handleResult, z as errorContractValidationFailed } from "../command-helpers-DK_5ItoJ.mjs";
3
+ import { t as createControlClient } from "../client-xeWpMlq1.mjs";
5
4
  import { Command } from "commander";
6
5
  import { ifDefined } from "@prisma-next/utils/defined";
7
6
  import { notOk, ok } from "@prisma-next/utils/result";
8
7
  import { isAbsolute, relative, resolve } from "pathe";
9
8
  import { readFile } from "node:fs/promises";
10
9
  import { APP_SPACE_ID, createControlStack } from "@prisma-next/framework-components/control";
11
- import { loadContractSpaceAggregate } from "@prisma-next/migration-tools/aggregate";
12
10
  import { castAs } from "@prisma-next/utils/casts";
11
+ import { loadContractSpaceAggregate } from "@prisma-next/migration-tools/aggregate";
13
12
  import { parseMigrationRef } from "@prisma-next/migration-tools/ref-resolution";
14
13
  //#region src/commands/migration-show.ts
15
14
  function looksLikePath(target) {
@@ -1 +1 @@
1
- {"version":3,"file":"migration-show.mjs","names":[],"sources":["../../src/commands/migration-show.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Contract } from '@prisma-next/contract/types';\nimport {\n APP_SPACE_ID,\n createControlStack,\n type MigrationPlanOperation,\n type OperationPreview,\n} from '@prisma-next/framework-components/control';\nimport { loadContractSpaceAggregate } from '@prisma-next/migration-tools/aggregate';\nimport type { OnDiskMigrationPackage } from '@prisma-next/migration-tools/package';\nimport { parseMigrationRef } from '@prisma-next/migration-tools/ref-resolution';\nimport { castAs } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { isAbsolute, relative, resolve } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport {\n type CliStructuredError,\n errorContractValidationFailed,\n errorFileNotFound,\n errorRuntime,\n errorUnexpected,\n mapRefResolutionError,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveContractPath,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n} from '../utils/command-helpers';\nimport { formatMigrationShowOutput } from '../utils/formatters/migrations';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationShowOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport interface MigrationShowPresent {\n readonly spaceId: string;\n readonly dirName: string;\n readonly dirPath: string;\n readonly from: string | null;\n readonly to: string;\n readonly migrationHash: string;\n readonly createdAt: string;\n readonly operations: readonly {\n readonly id: string;\n readonly label: string;\n readonly operationClass: string;\n }[];\n readonly preview: OperationPreview;\n readonly summary: string;\n}\n\nexport interface MigrationShowResult {\n readonly ok: true;\n readonly migration: MigrationShowPresent;\n}\n\nfunction looksLikePath(target: string): boolean {\n return target.includes('/') || target.includes('\\\\');\n}\n\nexport function resolveAppTargetPath(\n target: string,\n appMigrationsDir: string,\n appMigrationsRelative: string,\n): Result<string, CliStructuredError> {\n const targetPath = resolve(target);\n const relativeToApp = relative(appMigrationsDir, targetPath);\n const isOutsideAppDir =\n relativeToApp === '' ||\n relativeToApp === '.' ||\n relativeToApp.startsWith('..') ||\n isAbsolute(relativeToApp);\n if (isOutsideAppDir) {\n return notOk(\n errorRuntime('Target must point to an app-space migration', {\n why: `Expected a path under ${appMigrationsRelative}, got ${target}`,\n fix: 'Pass an app-space migration directory or use a hash prefix.',\n }),\n );\n }\n return ok(targetPath);\n}\n\nfunction pkgToPresent(\n spaceId: string,\n pkg: OnDiskMigrationPackage,\n client: ReturnType<typeof createControlClient>,\n): MigrationShowPresent {\n const ops = castAs<readonly MigrationPlanOperation[]>(pkg.ops);\n const preview: OperationPreview = client.toOperationPreview(ops) ?? { statements: [] };\n return {\n spaceId,\n dirName: pkg.dirName,\n dirPath: relative(process.cwd(), pkg.dirPath),\n from: pkg.metadata.from,\n to: pkg.metadata.to,\n migrationHash: pkg.metadata.migrationHash,\n createdAt: pkg.metadata.createdAt,\n operations: ops.map((op) => ({\n id: op.id,\n label: op.label,\n operationClass: op.operationClass,\n })),\n preview,\n summary: `${ops.length} operation(s)`,\n };\n}\n\nfunction findPackageByDirPath(\n packages: readonly OnDiskMigrationPackage[],\n resolvedDirPath: string,\n): OnDiskMigrationPackage | undefined {\n const normalized = resolve(resolvedDirPath);\n return packages.find((p) => resolve(p.dirPath) === normalized);\n}\n\nasync function executeMigrationShowCommand(\n target: string,\n options: MigrationShowOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationShowResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } =\n resolveMigrationPaths(options.config, config);\n\n const contractPathAbsolute = resolveContractPath(config);\n const contractPath = relative(process.cwd(), contractPathAbsolute);\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration show',\n description: 'Display migration package contents',\n details: [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n { label: 'migrations', value: appMigrationsRelative },\n { label: 'target', value: target },\n ],\n flags,\n });\n ui.stderr(header);\n }\n\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n ...ifDefined('driver', config.driver),\n extensionPacks: config.extensionPacks ?? [],\n });\n\n let contractJsonContent: string;\n try {\n contractJsonContent = await readFile(contractPathAbsolute, 'utf-8');\n } catch (error) {\n if (error instanceof Error && (error as NodeJS.ErrnoException).code === 'ENOENT') {\n return notOk(\n errorFileNotFound(contractPathAbsolute, {\n why: `Contract file not found at ${contractPathAbsolute}`,\n fix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}`,\n }),\n );\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: 'Failed to read contract file',\n }),\n );\n }\n\n const stack = createControlStack(config);\n const familyInstance = config.family.create(stack);\n\n let appContract: Contract;\n try {\n appContract = familyInstance.deserializeContract(\n castAs<unknown>(JSON.parse(contractJsonContent)),\n );\n } catch (error) {\n return notOk(\n errorContractValidationFailed(\n `Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`,\n { where: { path: contractPathAbsolute } },\n ),\n );\n }\n\n const aggregate = await loadContractSpaceAggregate({\n migrationsDir,\n appContract,\n deserializeContract: (json: unknown) => familyInstance.deserializeContract(json),\n });\n\n const packages = aggregate.app.packages;\n const graph = aggregate.app.graph();\n const refs = aggregate.app.refs;\n\n let appPkg: OnDiskMigrationPackage;\n if (looksLikePath(target)) {\n const resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n if (!resolved.ok) return resolved;\n const matched = findPackageByDirPath(packages, resolved.value);\n if (!matched) {\n return notOk(\n errorRuntime('Migration package not found', {\n why: `No loaded migration package at ${relative(process.cwd(), resolved.value)}`,\n fix: 'Pass a directory name, hash prefix, or path to an on-disk app-space migration package.',\n }),\n );\n }\n appPkg = matched;\n } else {\n if (packages.length === 0) {\n return notOk(\n errorRuntime('No migrations found', {\n why: `No migration packages found in ${appMigrationsRelative}`,\n fix: 'Run `prisma-next migration plan` to create a migration first.',\n }),\n );\n }\n const migResult = parseMigrationRef(target, { graph, refs });\n if (!migResult.ok) {\n return notOk(mapRefResolutionError(migResult.failure));\n }\n const matchedPkg = packages.find(\n (p) => p.metadata.migrationHash === migResult.value.migrationHash,\n );\n if (!matchedPkg) {\n return notOk(\n errorRuntime('Migration package not found', {\n why: `Resolved migration \"${migResult.value.dirName}\" but the package was not loaded`,\n fix: 'The migrations directory may be corrupted. Inspect the migration.json files.',\n }),\n );\n }\n appPkg = matchedPkg;\n }\n\n return ok({\n ok: true,\n migration: pkgToPresent(APP_SPACE_ID, appPkg, client),\n });\n}\n\nexport function createMigrationShowCommand(): Command {\n const command = new Command('show');\n setCommandDescriptions(\n command,\n 'Display migration package contents',\n 'Shows the operations, statement preview, and metadata for one app-space migration.\\n' +\n 'Accepts a directory path, directory name, or hash prefix.',\n );\n setCommandExamples(command, [\n 'prisma-next migration show 20260101_100000_add_user',\n 'prisma-next migration show sha256:a1b2c3',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration status', oneLiner: 'Show migration path and pending status' },\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration list', oneLiner: 'List on-disk migrations' },\n { verb: 'migration graph', oneLiner: 'Show the migration graph topology' },\n ]);\n addGlobalOptions(command)\n .argument('<target>', 'Migration reference: directory name, hash/prefix, or path')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (target: string, options: MigrationShowOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n\n const ui = createTerminalUI(flags);\n\n const result = await executeMigrationShowCommand(target, options, flags, ui);\n\n const exitCode = handleResult(result, flags, ui, (showResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(showResult, null, 2));\n } else if (!flags.quiet) {\n ui.log(formatMigrationShowOutput(showResult, flags));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"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AU;EAA0B;EAC9D;GAAE,MAAM;GAAmB,UAAU;EAAoC;CAC3E,CAAC;CACD,iBAAiB,OAAO,EACrB,SAAS,YAAY,2DAA2D,EAChF,OAAO,mBAAmB,+BAA+B,EACzD,OAAO,OAAO,QAAgB,YAAkC;EAC/D,MAAM,QAAQ,uBAAuB,OAAO;EAE5C,MAAM,KAAK,iBAAiB,KAAK;EAIjC,MAAM,WAAW,aAAa,MAFT,4BAA4B,QAAQ,SAAS,OAAO,EAAE,GAErC,OAAO,KAAK,eAAe;GAC/D,IAAI,MAAM,MACR,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,OAChB,GAAG,IAAI,0BAA0B,YAAY,KAAK,CAAC;EAEvD,CAAC;EAED,QAAQ,KAAK,QAAQ;CACvB,CAAC;CAEH,OAAO;AACT"}
1
+ {"version":3,"file":"migration-show.mjs","names":[],"sources":["../../src/commands/migration-show.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Contract } from '@prisma-next/contract/types';\nimport {\n APP_SPACE_ID,\n createControlStack,\n type MigrationPlanOperation,\n type OperationPreview,\n} from '@prisma-next/framework-components/control';\nimport { loadContractSpaceAggregate } from '@prisma-next/migration-tools/aggregate';\nimport type { OnDiskMigrationPackage } from '@prisma-next/migration-tools/package';\nimport { parseMigrationRef } from '@prisma-next/migration-tools/ref-resolution';\nimport { castAs } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { isAbsolute, relative, resolve } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport {\n type CliStructuredError,\n errorContractValidationFailed,\n errorFileNotFound,\n errorRuntime,\n errorUnexpected,\n mapRefResolutionError,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveContractPath,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n} from '../utils/command-helpers';\nimport { formatMigrationShowOutput } from '../utils/formatters/migrations';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationShowOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport interface MigrationShowPresent {\n readonly spaceId: string;\n readonly dirName: string;\n readonly dirPath: string;\n readonly from: string | null;\n readonly to: string;\n readonly migrationHash: string;\n readonly createdAt: string;\n readonly operations: readonly {\n readonly id: string;\n readonly label: string;\n readonly operationClass: string;\n }[];\n readonly preview: OperationPreview;\n readonly summary: string;\n}\n\nexport interface MigrationShowResult {\n readonly ok: true;\n readonly migration: MigrationShowPresent;\n}\n\nfunction looksLikePath(target: string): boolean {\n return target.includes('/') || target.includes('\\\\');\n}\n\nexport function resolveAppTargetPath(\n target: string,\n appMigrationsDir: string,\n appMigrationsRelative: string,\n): Result<string, CliStructuredError> {\n const targetPath = resolve(target);\n const relativeToApp = relative(appMigrationsDir, targetPath);\n const isOutsideAppDir =\n relativeToApp === '' ||\n relativeToApp === '.' ||\n relativeToApp.startsWith('..') ||\n isAbsolute(relativeToApp);\n if (isOutsideAppDir) {\n return notOk(\n errorRuntime('Target must point to an app-space migration', {\n why: `Expected a path under ${appMigrationsRelative}, got ${target}`,\n fix: 'Pass an app-space migration directory or use a hash prefix.',\n }),\n );\n }\n return ok(targetPath);\n}\n\nfunction pkgToPresent(\n spaceId: string,\n pkg: OnDiskMigrationPackage,\n client: ReturnType<typeof createControlClient>,\n): MigrationShowPresent {\n const ops = castAs<readonly MigrationPlanOperation[]>(pkg.ops);\n const preview: OperationPreview = client.toOperationPreview(ops) ?? { statements: [] };\n return {\n spaceId,\n dirName: pkg.dirName,\n dirPath: relative(process.cwd(), pkg.dirPath),\n from: pkg.metadata.from,\n to: pkg.metadata.to,\n migrationHash: pkg.metadata.migrationHash,\n createdAt: pkg.metadata.createdAt,\n operations: ops.map((op) => ({\n id: op.id,\n label: op.label,\n operationClass: op.operationClass,\n })),\n preview,\n summary: `${ops.length} operation(s)`,\n };\n}\n\nfunction findPackageByDirPath(\n packages: readonly OnDiskMigrationPackage[],\n resolvedDirPath: string,\n): OnDiskMigrationPackage | undefined {\n const normalized = resolve(resolvedDirPath);\n return packages.find((p) => resolve(p.dirPath) === normalized);\n}\n\nasync function executeMigrationShowCommand(\n target: string,\n options: MigrationShowOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationShowResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } =\n resolveMigrationPaths(options.config, config);\n\n const contractPathAbsolute = resolveContractPath(config);\n const contractPath = relative(process.cwd(), contractPathAbsolute);\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration show',\n description: 'Display migration package contents',\n details: [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n { label: 'migrations', value: appMigrationsRelative },\n { label: 'target', value: target },\n ],\n flags,\n });\n ui.stderr(header);\n }\n\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n ...ifDefined('driver', config.driver),\n extensionPacks: config.extensionPacks ?? [],\n });\n\n let contractJsonContent: string;\n try {\n contractJsonContent = await readFile(contractPathAbsolute, 'utf-8');\n } catch (error) {\n if (error instanceof Error && (error as NodeJS.ErrnoException).code === 'ENOENT') {\n return notOk(\n errorFileNotFound(contractPathAbsolute, {\n why: `Contract file not found at ${contractPathAbsolute}`,\n fix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}`,\n }),\n );\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: 'Failed to read contract file',\n }),\n );\n }\n\n const stack = createControlStack(config);\n const familyInstance = config.family.create(stack);\n\n let appContract: Contract;\n try {\n appContract = familyInstance.deserializeContract(\n castAs<unknown>(JSON.parse(contractJsonContent)),\n );\n } catch (error) {\n return notOk(\n errorContractValidationFailed(\n `Contract at ${contractPathAbsolute} failed to deserialize: ${error instanceof Error ? error.message : String(error)}`,\n { where: { path: contractPathAbsolute } },\n ),\n );\n }\n\n const aggregate = await loadContractSpaceAggregate({\n migrationsDir,\n appContract,\n deserializeContract: (json: unknown) => familyInstance.deserializeContract(json),\n });\n\n const packages = aggregate.app.packages;\n const graph = aggregate.app.graph();\n const refs = aggregate.app.refs;\n\n let appPkg: OnDiskMigrationPackage;\n if (looksLikePath(target)) {\n const resolved = resolveAppTargetPath(target, appMigrationsDir, appMigrationsRelative);\n if (!resolved.ok) return resolved;\n const matched = findPackageByDirPath(packages, resolved.value);\n if (!matched) {\n return notOk(\n errorRuntime('Migration package not found', {\n why: `No loaded migration package at ${relative(process.cwd(), resolved.value)}`,\n fix: 'Pass a directory name, hash prefix, or path to an on-disk app-space migration package.',\n }),\n );\n }\n appPkg = matched;\n } else {\n if (packages.length === 0) {\n return notOk(\n errorRuntime('No migrations found', {\n why: `No migration packages found in ${appMigrationsRelative}`,\n fix: 'Run `prisma-next migration plan` to create a migration first.',\n }),\n );\n }\n const migResult = parseMigrationRef(target, { graph, refs });\n if (!migResult.ok) {\n return notOk(mapRefResolutionError(migResult.failure));\n }\n const matchedPkg = packages.find(\n (p) => p.metadata.migrationHash === migResult.value.migrationHash,\n );\n if (!matchedPkg) {\n return notOk(\n errorRuntime('Migration package not found', {\n why: `Resolved migration \"${migResult.value.dirName}\" but the package was not loaded`,\n fix: 'The migrations directory may be corrupted. Inspect the migration.json files.',\n }),\n );\n }\n appPkg = matchedPkg;\n }\n\n return ok({\n ok: true,\n migration: pkgToPresent(APP_SPACE_ID, appPkg, client),\n });\n}\n\nexport function createMigrationShowCommand(): Command {\n const command = new Command('show');\n setCommandDescriptions(\n command,\n 'Display migration package contents',\n 'Shows the operations, statement preview, and metadata for one app-space migration.\\n' +\n 'Accepts a directory path, directory name, or hash prefix.',\n );\n setCommandExamples(command, [\n 'prisma-next migration show 20260101_100000_add_user',\n 'prisma-next migration show sha256:a1b2c3',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration status', oneLiner: 'Show migration path and pending status' },\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration list', oneLiner: 'List on-disk migrations' },\n { verb: 'migration graph', oneLiner: 'Show the migration graph topology' },\n ]);\n addGlobalOptions(command)\n .argument('<target>', 'Migration reference: directory name, hash/prefix, or path')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (target: string, options: MigrationShowOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n\n const ui = createTerminalUI(flags);\n\n const result = await executeMigrationShowCommand(target, options, flags, ui);\n\n const exitCode = handleResult(result, flags, ui, (showResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(showResult, null, 2));\n } else if (!flags.quiet) {\n ui.log(formatMigrationShowOutput(showResult, flags));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;AAmEA,SAAS,cAAc,QAAyB;CAC9C,OAAO,OAAO,SAAS,GAAG,KAAK,OAAO,SAAS,IAAI;AACrD;AAEA,SAAgB,qBACd,QACA,kBACA,uBACoC;CACpC,MAAM,aAAa,QAAQ,MAAM;CACjC,MAAM,gBAAgB,SAAS,kBAAkB,UAAU;CAM3D,IAJE,kBAAkB,MAClB,kBAAkB,OAClB,cAAc,WAAW,IAAI,KAC7B,WAAW,aAAa,GAExB,OAAO,MACL,aAAa,+CAA+C;EAC1D,KAAK,yBAAyB,sBAAsB,QAAQ;EAC5D,KAAK;CACP,CAAC,CACH;CAEF,OAAO,GAAG,UAAU;AACtB;AAEA,SAAS,aACP,SACA,KACA,QACsB;CACtB,MAAM,MAAM,OAA0C,IAAI,GAAG;CAC7D,MAAM,UAA4B,OAAO,mBAAmB,GAAG,KAAK,EAAE,YAAY,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