prisma-next 0.11.0-dev.69 → 0.11.0-dev.70

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 (39) hide show
  1. package/dist/cli.mjs +5 -5
  2. package/dist/commands/migrate.d.mts +1 -1
  3. package/dist/commands/migration-graph.d.mts +6 -4
  4. package/dist/commands/migration-graph.d.mts.map +1 -1
  5. package/dist/commands/migration-graph.mjs +1 -121
  6. package/dist/commands/migration-list.d.mts +4 -3
  7. package/dist/commands/migration-list.d.mts.map +1 -1
  8. package/dist/commands/migration-list.mjs +1 -1
  9. package/dist/commands/migration-log.d.mts +3 -3
  10. package/dist/commands/migration-plan.d.mts +1 -1
  11. package/dist/commands/migration-plan.mjs +1 -1
  12. package/dist/commands/migration-show.d.mts +1 -1
  13. package/dist/commands/migration-status.d.mts +1 -1
  14. package/dist/commands/ref.d.mts +1 -1
  15. package/dist/exports/control-api.d.mts +1 -1
  16. package/dist/exports/init-output.mjs +1 -1
  17. package/dist/{global-flags-2SPgqWma.d.mts → global-flags-DG4uY5tV.d.mts} +1 -1
  18. package/dist/{global-flags-2SPgqWma.d.mts.map → global-flags-DG4uY5tV.d.mts.map} +1 -1
  19. package/dist/{init-BQNpPozW.mjs → init-DE-phHWK.mjs} +2 -2
  20. package/dist/{init-BQNpPozW.mjs.map → init-DE-phHWK.mjs.map} +1 -1
  21. package/dist/migration-graph-kPluRdF2.mjs +1232 -0
  22. package/dist/migration-graph-kPluRdF2.mjs.map +1 -0
  23. package/dist/{migration-list-A3bJ4j5e.mjs → migration-list-CE35R5Ag.mjs} +2 -277
  24. package/dist/migration-list-CE35R5Ag.mjs.map +1 -0
  25. package/dist/migration-list-styler-DeAwACt3.mjs +402 -0
  26. package/dist/migration-list-styler-DeAwACt3.mjs.map +1 -0
  27. package/dist/{migration-plan-ZZm8C0s-.mjs → migration-plan-DHLa2Khm.mjs} +1 -1
  28. package/dist/{migration-plan-ZZm8C0s-.mjs.map → migration-plan-DHLa2Khm.mjs.map} +1 -1
  29. package/dist/{migration-types-q64xAI_J.d.mts → migration-types-CAQ-0TEE.d.mts} +1 -1
  30. package/dist/{migration-types-q64xAI_J.d.mts.map → migration-types-CAQ-0TEE.d.mts.map} +1 -1
  31. package/dist/{output-DEg3SSnJ.mjs → output-CF_hqzI-.mjs} +1 -1
  32. package/dist/{output-DEg3SSnJ.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
  33. package/dist/{terminal-ui-sLZt2cxc.d.mts → terminal-ui-BbtqsQYY.d.mts} +1 -1
  34. package/dist/{terminal-ui-sLZt2cxc.d.mts.map → terminal-ui-BbtqsQYY.d.mts.map} +1 -1
  35. package/dist/{types-BNqTw3ek.d.mts → types-Ci7TndCS.d.mts} +1 -1
  36. package/dist/{types-BNqTw3ek.d.mts.map → types-Ci7TndCS.d.mts.map} +1 -1
  37. package/package.json +11 -11
  38. package/dist/commands/migration-graph.mjs.map +0 -1
  39. package/dist/migration-list-A3bJ4j5e.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration-list-A3bJ4j5e.mjs","names":["canonicalFrom"],"sources":["../src/utils/formatters/migration-list-data-column.ts","../src/utils/formatters/migration-list-graph-topology.ts","../src/utils/formatters/migration-list-graph-layout.ts","../src/utils/formatters/migration-list-graph-render.ts","../src/utils/formatters/migration-list-render.ts","../src/utils/formatters/migration-list-styler.ts","../src/commands/migration-list.ts"],"sourcesContent":["import type { GlyphMode } from '../glyph-mode';\nimport type { MigrationEdgeKind } from './migration-list-graph-topology';\nimport type { MigrationListStyler } from './migration-list-render';\nimport type { MigrationListEntry } from './migration-list-types';\n\nexport const MIGRATION_LIST_HASH_WIDTH = 7;\nexport const MIGRATION_LIST_EMPTY_SOURCE = '∅';\nexport const MIGRATION_LIST_ASCII_EMPTY_SOURCE = '-';\nexport const MIGRATION_LIST_FORWARD_EDGE_GLYPH = '→';\nexport const MIGRATION_LIST_ASCII_FORWARD_EDGE_GLYPH = '->';\nexport const MIGRATION_LIST_DECORATION_PREFIX = ' ';\n\nexport const MIGRATION_LIST_UNICODE_KIND_GLYPH: Record<MigrationEdgeKind, string> = {\n forward: '*',\n rollback: '↩',\n self: '⟲',\n};\n\nexport const MIGRATION_LIST_ASCII_KIND_GLYPH: Record<MigrationEdgeKind, string> = {\n forward: '*',\n rollback: '<',\n self: '~',\n};\n\nexport function migrationListKindGlyph(glyphMode: GlyphMode, edgeKind: MigrationEdgeKind): string {\n return glyphMode === 'ascii'\n ? MIGRATION_LIST_ASCII_KIND_GLYPH[edgeKind]\n : MIGRATION_LIST_UNICODE_KIND_GLYPH[edgeKind];\n}\n\nexport function migrationListForwardArrow(glyphMode: GlyphMode): string {\n return glyphMode === 'ascii'\n ? MIGRATION_LIST_ASCII_FORWARD_EDGE_GLYPH\n : MIGRATION_LIST_FORWARD_EDGE_GLYPH;\n}\n\nexport function migrationListEmptySource(glyphMode: GlyphMode): string {\n return glyphMode === 'ascii' ? MIGRATION_LIST_ASCII_EMPTY_SOURCE : MIGRATION_LIST_EMPTY_SOURCE;\n}\n\nexport function abbreviateContractHash(hash: string): string {\n const stripped = hash.startsWith('sha256:') ? hash.slice(7) : hash;\n return stripped.slice(0, MIGRATION_LIST_HASH_WIDTH);\n}\n\nexport function computeMigrationDirNameWidth(migrations: readonly MigrationListEntry[]): number {\n if (migrations.length === 0) return 0;\n return Math.max(...migrations.map((entry) => entry.dirName.length)) + 2;\n}\n\nfunction formatSourceColumn(\n from: string | null,\n style: MigrationListStyler,\n emptySource: string,\n): string {\n if (from === null) {\n return style.glyph(emptySource) + ' '.repeat(MIGRATION_LIST_HASH_WIDTH - emptySource.length);\n }\n return style.sourceHash(abbreviateContractHash(from));\n}\n\nexport function formatDecorations(\n providedInvariants: readonly string[],\n refs: readonly string[],\n style: MigrationListStyler,\n): string {\n const blocks: string[] = [];\n if (providedInvariants.length > 0) {\n blocks.push(style.invariants(providedInvariants));\n }\n if (refs.length > 0) {\n blocks.push(style.refs(refs));\n }\n if (blocks.length === 0) return '';\n return `${MIGRATION_LIST_DECORATION_PREFIX}${blocks.join(' ')}`;\n}\n\nexport interface MigrationDataColumnOptions {\n readonly dirNameWidth: number;\n readonly edgeKind: MigrationEdgeKind;\n readonly style: MigrationListStyler;\n readonly forwardArrow?: string;\n readonly emptySource?: string;\n}\n\nexport function formatMigrationDataColumn(\n migration: MigrationListEntry,\n options: MigrationDataColumnOptions,\n): string {\n const {\n dirNameWidth,\n edgeKind,\n style,\n forwardArrow = MIGRATION_LIST_FORWARD_EDGE_GLYPH,\n emptySource = MIGRATION_LIST_EMPTY_SOURCE,\n } = options;\n const dirNamePadding = ' '.repeat(Math.max(0, dirNameWidth - migration.dirName.length));\n const dirName = `${style.dirName(migration.dirName)}${dirNamePadding}`;\n const decorations = formatDecorations(migration.providedInvariants, migration.refs, style);\n\n if (edgeKind === 'self') {\n const contractHash = migration.from ?? migration.to;\n const hash = style.sourceHash(abbreviateContractHash(contractHash));\n return `${dirName}${hash}${decorations}`;\n }\n\n const source = formatSourceColumn(migration.from, style, emptySource);\n const arrow = style.glyph(forwardArrow);\n const dest = style.destHash(abbreviateContractHash(migration.to));\n return `${dirName}${source} ${arrow} ${dest}${decorations}`;\n}\n\nexport function formatNodeLineDataColumn(contractHash: string, style: MigrationListStyler): string {\n return style.sourceHash(abbreviateContractHash(contractHash));\n}\n","import { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport type { MigrationListEntry } from './migration-list-types';\n\nexport type MigrationEdgeKind = 'forward' | 'rollback' | 'self';\n\nexport interface MigrationListGraphTopology {\n readonly kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>;\n readonly forwardInDegree: ReadonlyMap<string, number>;\n readonly forwardOutDegree: ReadonlyMap<string, number>;\n}\n\ninterface NonSelfEdge {\n readonly entry: MigrationListEntry;\n readonly from: string;\n readonly to: string;\n}\n\nfunction canonicalFrom(from: string | null): string {\n return from ?? EMPTY_CONTRACT_HASH;\n}\n\nfunction compareDirNameDesc(a: MigrationListEntry, b: MigrationListEntry): number {\n return b.dirName.localeCompare(a.dirName);\n}\n\nfunction bumpDegree(map: Map<string, number>, key: string): void {\n map.set(key, (map.get(key) ?? 0) + 1);\n}\n\nexport function classifyMigrationListGraphTopology(\n entries: readonly MigrationListEntry[],\n): MigrationListGraphTopology {\n const nodes = new Set<string>();\n const kindByMigrationHash = new Map<string, MigrationEdgeKind>();\n const outgoingByFrom = new Map<string, NonSelfEdge[]>();\n\n for (const entry of entries) {\n const from = canonicalFrom(entry.from);\n const to = entry.to;\n nodes.add(from);\n nodes.add(to);\n\n if (from === to) {\n kindByMigrationHash.set(entry.migrationHash, 'self');\n continue;\n }\n\n const bucket = outgoingByFrom.get(from);\n const edge: NonSelfEdge = { entry, from, to };\n if (bucket) bucket.push(edge);\n else outgoingByFrom.set(from, [edge]);\n }\n\n for (const bucket of outgoingByFrom.values()) {\n bucket.sort((a, b) => compareDirNameDesc(a.entry, b.entry));\n }\n\n const nonSelfInDegree = new Map<string, number>();\n for (const node of nodes) {\n nonSelfInDegree.set(node, 0);\n }\n for (const bucket of outgoingByFrom.values()) {\n for (const edge of bucket) {\n bumpDegree(nonSelfInDegree, edge.to);\n }\n }\n\n const dfsRoots: string[] = [];\n for (const node of nodes) {\n if ((nonSelfInDegree.get(node) ?? 0) === 0) {\n dfsRoots.push(node);\n }\n }\n dfsRoots.sort((a, b) => {\n if (a === EMPTY_CONTRACT_HASH) return -1;\n if (b === EMPTY_CONTRACT_HASH) return 1;\n return a.localeCompare(b);\n });\n if (dfsRoots.length === 0) {\n dfsRoots.push(...[...nodes].sort((a, b) => a.localeCompare(b)));\n }\n\n const WHITE = 0;\n const GRAY = 1;\n const BLACK = 2;\n const color = new Map<string, number>();\n for (const node of nodes) {\n color.set(node, WHITE);\n }\n\n interface Frame {\n node: string;\n outgoing: readonly NonSelfEdge[];\n index: number;\n }\n const stack: Frame[] = [];\n\n function pushFrame(node: string): void {\n color.set(node, GRAY);\n stack.push({ node, outgoing: outgoingByFrom.get(node) ?? [], index: 0 });\n }\n\n function runDfsFrom(root: string): void {\n if (color.get(root) !== WHITE) return;\n pushFrame(root);\n\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame === undefined) break;\n if (frame.index >= frame.outgoing.length) {\n color.set(frame.node, BLACK);\n stack.pop();\n continue;\n }\n\n const edge = frame.outgoing[frame.index];\n frame.index += 1;\n if (edge === undefined) continue;\n\n const v = edge.to;\n const vColor = color.get(v);\n if (vColor === GRAY) {\n kindByMigrationHash.set(edge.entry.migrationHash, 'rollback');\n } else {\n kindByMigrationHash.set(edge.entry.migrationHash, 'forward');\n if (vColor === WHITE) {\n pushFrame(v);\n }\n }\n }\n }\n\n for (const root of dfsRoots) {\n runDfsFrom(root);\n }\n const remainingWhite = [...nodes].filter((node) => color.get(node) === WHITE);\n remainingWhite.sort((a, b) => a.localeCompare(b));\n for (const root of remainingWhite) {\n runDfsFrom(root);\n }\n\n const forwardInDegree = new Map<string, number>();\n const forwardOutDegree = new Map<string, number>();\n\n for (const entry of entries) {\n if (kindByMigrationHash.get(entry.migrationHash) !== 'forward') continue;\n const from = canonicalFrom(entry.from);\n const to = entry.to;\n bumpDegree(forwardOutDegree, from);\n bumpDegree(forwardInDegree, to);\n }\n\n return {\n kindByMigrationHash,\n forwardInDegree,\n forwardOutDegree,\n };\n}\n","import { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport {\n classifyMigrationListGraphTopology,\n type MigrationEdgeKind,\n type MigrationListGraphTopology,\n} from './migration-list-graph-topology';\nimport type { MigrationListEntry } from './migration-list-types';\n\nexport type ConnectorKind = 'fanBelow' | 'joinAbove';\n\nexport interface MigrationLayoutRow {\n readonly kind: 'migration';\n readonly entry: MigrationListEntry;\n readonly edgeKind: MigrationEdgeKind;\n readonly laneIndex: number;\n readonly passThroughLanes: readonly number[];\n readonly woven: boolean;\n}\n\nexport interface NodeLineLayoutRow {\n readonly kind: 'nodeLine';\n readonly contractHash: string;\n readonly laneIndex: number;\n}\n\nexport interface ConnectorLayoutRow {\n readonly kind: 'connector';\n readonly connectorKind: ConnectorKind;\n readonly contractHash: string;\n readonly startLane: number;\n readonly endLane: number;\n readonly branchCount: number;\n}\n\nexport type LayoutRow = MigrationLayoutRow | NodeLineLayoutRow | ConnectorLayoutRow;\n\nexport interface MigrationListGraphLayout {\n readonly rows: readonly LayoutRow[];\n}\n\ninterface LaneState {\n want: string;\n active: boolean;\n}\n\nfunction canonicalFrom(from: string | null): string {\n return from ?? EMPTY_CONTRACT_HASH;\n}\n\nfunction forwardInDegree(topology: MigrationListGraphTopology, hash: string): number {\n return topology.forwardInDegree.get(hash) ?? 0;\n}\n\nfunction forwardOutDegree(topology: MigrationListGraphTopology, hash: string): number {\n return topology.forwardOutDegree.get(hash) ?? 0;\n}\n\nfunction buildForwardProducersByTo(\n entries: readonly MigrationListEntry[],\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n): Map<string, MigrationListEntry[]> {\n const byTo = new Map<string, MigrationListEntry[]>();\n for (const entry of entries) {\n if (kindByMigrationHash.get(entry.migrationHash) !== 'forward') continue;\n const bucket = byTo.get(entry.to);\n if (bucket) bucket.push(entry);\n else byTo.set(entry.to, [entry]);\n }\n return byTo;\n}\n\nfunction countForwardProducersTo(\n forwardProducersByTo: Map<string, MigrationListEntry[]>,\n contract: string,\n): number {\n return forwardProducersByTo.get(contract)?.length ?? 0;\n}\n\nfunction hasLaterForwardDepartingFrom(\n entries: readonly MigrationListEntry[],\n startIndex: number,\n contract: string,\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n): boolean {\n for (let index = startIndex + 1; index < entries.length; index++) {\n const later = entries[index];\n if (later === undefined) continue;\n if (kindByMigrationHash.get(later.migrationHash) !== 'forward') continue;\n if (canonicalFrom(later.from) === contract) return true;\n }\n return false;\n}\n\nexport function computeMigrationListGraphLayout(\n entries: readonly MigrationListEntry[],\n topology: MigrationListGraphTopology = classifyMigrationListGraphTopology(entries),\n): MigrationListGraphLayout {\n const { kindByMigrationHash } = topology;\n const forwardProducersByTo = buildForwardProducersByTo(entries, kindByMigrationHash);\n const convergencesEmitted = new Set<string>();\n const producerLaneByHash = new Map<string, number>();\n const lanes: LaneState[] = [];\n const rows: LayoutRow[] = [];\n\n function emitNodeLine(contractHash: string): void {\n rows.push({ kind: 'nodeLine', contractHash, laneIndex: 0 });\n }\n\n function emitConnector(\n connectorKind: ConnectorKind,\n contractHash: string,\n startLane: number,\n endLane: number,\n branchCount: number,\n ): void {\n rows.push({\n kind: 'connector',\n connectorKind,\n contractHash,\n startLane,\n endLane,\n branchCount,\n });\n }\n\n function activeLaneIndices(): number[] {\n const indices: number[] = [];\n for (let index = 0; index < lanes.length; index++) {\n if (lanes[index]?.active) indices.push(index);\n }\n return indices;\n }\n\n function lanesWanting(contract: string): number[] {\n const indices: number[] = [];\n for (let index = 0; index < lanes.length; index++) {\n const lane = lanes[index];\n if (lane?.active && lane.want === contract) indices.push(index);\n }\n return indices;\n }\n\n function ensureLane(index: number): void {\n while (lanes.length <= index) {\n lanes.push({ want: '', active: false });\n }\n }\n\n function openLaneAtRight(want: string): number {\n const index = lanes.length;\n lanes.push({ want, active: true });\n return index;\n }\n\n function closeLane(index: number): void {\n ensureLane(index);\n const lane = lanes[index];\n if (lane) lane.active = false;\n }\n\n function emitJoinAbove(contractHash: string, laneIndices: readonly number[]): void {\n if (laneIndices.length < 2) return;\n const startLane = Math.min(...laneIndices);\n const endLane = Math.max(...laneIndices);\n emitConnector('joinAbove', contractHash, startLane, endLane, laneIndices.length);\n for (const index of laneIndices) {\n if (index !== startLane) closeLane(index);\n }\n }\n\n function emitConvergencePreamble(contract: string): void {\n if (convergencesEmitted.has(contract)) return;\n if (forwardInDegree(topology, contract) < 2) return;\n\n const consumersWanting = lanesWanting(contract);\n if (forwardOutDegree(topology, contract) >= 2 && consumersWanting.length >= 2) {\n emitJoinAbove(contract, consumersWanting);\n }\n\n emitNodeLine(contract);\n const producers = forwardProducersByTo.get(contract) ?? [];\n if (producers.length >= 2) {\n emitConnector('fanBelow', contract, 0, producers.length - 1, producers.length);\n }\n\n for (const [producerIndex, producer] of producers.entries()) {\n ensureLane(producerIndex);\n lanes[producerIndex] = { want: canonicalFrom(producer.from), active: true };\n producerLaneByHash.set(producer.migrationHash, producerIndex);\n }\n\n convergencesEmitted.add(contract);\n }\n\n function placeWoven(\n entry: MigrationListEntry,\n edgeKind: MigrationEdgeKind,\n laneIndex: number,\n ): void {\n const passThroughLanes = activeLaneIndices().filter((index) => index !== laneIndex);\n rows.push({\n kind: 'migration',\n entry,\n edgeKind,\n laneIndex,\n passThroughLanes,\n woven: true,\n });\n ensureLane(laneIndex);\n lanes[laneIndex] = { want: canonicalFrom(entry.from), active: true };\n }\n\n function placeUnwoven(entry: MigrationListEntry, edgeKind: MigrationEdgeKind): void {\n const passThroughLanes = activeLaneIndices();\n const laneIndex = passThroughLanes.length === 0 ? 0 : Math.max(...passThroughLanes) + 1;\n rows.push({\n kind: 'migration',\n entry,\n edgeKind,\n laneIndex,\n passThroughLanes,\n woven: false,\n });\n }\n\n for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {\n const entry = entries[entryIndex]!;\n const edgeKind = kindByMigrationHash.get(entry.migrationHash) ?? 'forward';\n const to = entry.to;\n\n if (edgeKind !== 'forward') {\n placeUnwoven(entry, edgeKind);\n continue;\n }\n\n if (forwardInDegree(topology, to) >= 2 && !convergencesEmitted.has(to)) {\n emitConvergencePreamble(to);\n }\n\n const presetLane = producerLaneByHash.get(entry.migrationHash);\n const wantingTo = lanesWanting(to);\n\n if (wantingTo.length >= 2 && countForwardProducersTo(forwardProducersByTo, to) === 1) {\n emitJoinAbove(to, wantingTo);\n }\n\n if (presetLane !== undefined) {\n placeWoven(entry, edgeKind, presetLane);\n continue;\n }\n\n const firstWanting = wantingTo[0];\n if (firstWanting !== undefined) {\n placeWoven(entry, edgeKind, firstWanting);\n continue;\n }\n\n if (hasLaterForwardDepartingFrom(entries, entryIndex, to, kindByMigrationHash)) {\n placeUnwoven(entry, edgeKind);\n continue;\n }\n\n const tipLaneIndex = openLaneAtRight(canonicalFrom(entry.from));\n placeWoven(entry, edgeKind, tipLaneIndex);\n }\n\n return { rows };\n}\n","import type { GlyphMode } from '../glyph-mode';\nimport {\n abbreviateContractHash,\n computeMigrationDirNameWidth,\n formatMigrationDataColumn,\n formatNodeLineDataColumn,\n MIGRATION_LIST_ASCII_KIND_GLYPH,\n MIGRATION_LIST_UNICODE_KIND_GLYPH,\n migrationListEmptySource,\n migrationListForwardArrow,\n} from './migration-list-data-column';\nimport type {\n ConnectorLayoutRow,\n LayoutRow,\n MigrationLayoutRow,\n MigrationListGraphLayout,\n NodeLineLayoutRow,\n} from './migration-list-graph-layout';\nimport { computeMigrationListGraphLayout } from './migration-list-graph-layout';\nimport type { MigrationListGraphTopology } from './migration-list-graph-topology';\nimport type { MigrationListStyler } from './migration-list-render';\nimport type { MigrationListEntry, MigrationListResult } from './migration-list-types';\n\nexport type { GlyphMode } from '../glyph-mode';\n\ninterface GlyphPalette {\n readonly lane: string;\n readonly node: string;\n readonly forwardArrow: string;\n readonly emptySource: string;\n readonly kind: typeof MIGRATION_LIST_UNICODE_KIND_GLYPH;\n readonly fanBelow: (branchCount: number) => string;\n readonly joinAbove: (branchCount: number) => string;\n}\n\nconst UNICODE_PALETTE: GlyphPalette = {\n lane: '│',\n node: 'o',\n forwardArrow: migrationListForwardArrow('unicode'),\n emptySource: migrationListEmptySource('unicode'),\n kind: MIGRATION_LIST_UNICODE_KIND_GLYPH,\n fanBelow: (branchCount) => (branchCount === 2 ? '├─┐' : '├─┬─┐'),\n joinAbove: (branchCount) => (branchCount === 2 ? '├─┘' : '└─┴─┘'),\n};\n\nconst ASCII_PALETTE: GlyphPalette = {\n lane: '|',\n node: 'o',\n forwardArrow: migrationListForwardArrow('ascii'),\n emptySource: migrationListEmptySource('ascii'),\n kind: MIGRATION_LIST_ASCII_KIND_GLYPH,\n fanBelow: (branchCount) => (branchCount === 2 ? '+-\\\\' : '+-|-\\\\'),\n joinAbove: (branchCount) => (branchCount === 2 ? '+-/' : '/-+-/'),\n};\n\nfunction paletteFor(mode: GlyphMode): GlyphPalette {\n return mode === 'ascii' ? ASCII_PALETTE : UNICODE_PALETTE;\n}\n\nfunction migrationEntries(layout: MigrationListGraphLayout): MigrationListEntry[] {\n const entries: MigrationListEntry[] = [];\n for (const row of layout.rows) {\n if (row.kind === 'migration') entries.push(row.entry);\n }\n return entries;\n}\n\nfunction layoutMaxLaneIndex(layout: MigrationListGraphLayout): number {\n let max = 0;\n for (const row of layout.rows) {\n if (row.kind === 'migration') {\n max = Math.max(max, row.laneIndex, ...row.passThroughLanes);\n } else if (row.kind === 'connector') {\n max = Math.max(max, row.endLane);\n } else {\n max = Math.max(max, row.laneIndex);\n }\n }\n return max;\n}\n\nfunction laneCell(glyph: string): string {\n return `${glyph} `;\n}\n\nfunction emptyLaneCell(): string {\n return ' ';\n}\n\nfunction renderMigrationGutter(\n row: MigrationLayoutRow,\n maxLane: number,\n palette: GlyphPalette,\n style: MigrationListStyler,\n): string {\n const cells: string[] = [];\n for (let lane = 0; lane <= maxLane; lane++) {\n if (lane === row.laneIndex) {\n cells.push(laneCell(style.kind(palette.kind[row.edgeKind])));\n } else if (row.passThroughLanes.includes(lane)) {\n cells.push(laneCell(style.lane(palette.lane)));\n } else {\n cells.push(emptyLaneCell());\n }\n }\n return cells.join('');\n}\n\nfunction renderNodeLineGutter(\n row: NodeLineLayoutRow,\n openLanes: ReadonlySet<number>,\n maxLane: number,\n palette: GlyphPalette,\n style: MigrationListStyler,\n): string {\n const cells: string[] = [];\n for (let lane = 0; lane <= maxLane; lane++) {\n if (lane === row.laneIndex) {\n cells.push(laneCell(palette.node));\n } else if (openLanes.has(lane)) {\n cells.push(laneCell(style.lane(palette.lane)));\n } else {\n cells.push(emptyLaneCell());\n }\n }\n return cells.join('');\n}\n\nfunction renderConnectorGutter(\n row: ConnectorLayoutRow,\n openLanes: ReadonlySet<number>,\n maxLane: number,\n palette: GlyphPalette,\n style: MigrationListStyler,\n): string {\n const spanLaneCount = row.endLane - row.startLane + 1;\n const spanWidth = spanLaneCount * 2;\n let spanGlyph = (\n row.connectorKind === 'fanBelow'\n ? palette.fanBelow(row.branchCount)\n : palette.joinAbove(row.branchCount)\n )\n .padEnd(spanWidth, ' ')\n .slice(0, spanWidth);\n\n const hasOutsideOpen = [...openLanes].some((lane) => lane < row.startLane || lane > row.endLane);\n if (!hasOutsideOpen && spanGlyph.endsWith(' ')) {\n spanGlyph = spanGlyph.slice(0, -1);\n }\n\n let gutter = '';\n for (let lane = 0; lane < row.startLane; lane++) {\n gutter += openLanes.has(lane) ? laneCell(style.lane(palette.lane)) : emptyLaneCell();\n }\n gutter += style.lane(spanGlyph);\n for (let lane = row.endLane + 1; lane <= maxLane; lane++) {\n gutter += openLanes.has(lane) ? laneCell(style.lane(palette.lane)) : emptyLaneCell();\n }\n return gutter;\n}\n\nfunction advanceOpenLanes(row: LayoutRow, openLanes: ReadonlySet<number>): ReadonlySet<number> {\n if (row.kind === 'migration') {\n return new Set([row.laneIndex, ...row.passThroughLanes]);\n }\n if (row.kind === 'connector') {\n if (row.connectorKind === 'fanBelow') {\n const next = new Set(openLanes);\n for (let lane = row.startLane; lane <= row.endLane; lane++) {\n next.add(lane);\n }\n return next;\n }\n const next = new Set(openLanes);\n for (let lane = row.startLane + 1; lane <= row.endLane; lane++) {\n next.delete(lane);\n }\n return next;\n }\n return openLanes;\n}\n\nexport function renderMigrationListGraphWithStyle(\n layout: MigrationListGraphLayout,\n style: MigrationListStyler,\n glyphMode: GlyphMode,\n): string {\n const palette = paletteFor(glyphMode);\n const migrations = migrationEntries(layout);\n const layoutMaxLane = layoutMaxLaneIndex(layout);\n const dirNameWidth = computeMigrationDirNameWidth(migrations);\n const gutterMaxLane = layoutMaxLane;\n const blockDataStart = (layoutMaxLane + 1) * 2;\n // Migration and node-line gutters always occupy a fixed, ANSI-free visible\n // width of two columns per lane. Padding is computed from this width rather\n // than the rendered string length so dimmed lanes (which carry zero-width\n // SGR bytes) stay column-aligned with the data that follows.\n const gutterVisibleWidth = (gutterMaxLane + 1) * 2;\n const lines: string[] = [];\n let openLanes: ReadonlySet<number> = new Set();\n\n function padToDataColumn(gutter: string, dataStart: number): string {\n return gutter + ' '.repeat(Math.max(0, dataStart - gutterVisibleWidth));\n }\n\n for (const row of layout.rows) {\n if (row.kind === 'migration') {\n const gutter = renderMigrationGutter(row, gutterMaxLane, palette, style);\n const data = formatMigrationDataColumn(row.entry, {\n dirNameWidth,\n edgeKind: row.edgeKind,\n style,\n forwardArrow: palette.forwardArrow,\n emptySource: palette.emptySource,\n });\n lines.push(`${padToDataColumn(gutter, blockDataStart)}${data}`);\n } else if (row.kind === 'nodeLine') {\n const gutter = renderNodeLineGutter(row, openLanes, gutterMaxLane, palette, style);\n const data = formatNodeLineDataColumn(row.contractHash, style);\n lines.push(`${padToDataColumn(gutter, blockDataStart)}${data}`);\n } else {\n lines.push(renderConnectorGutter(row, openLanes, gutterMaxLane, palette, style));\n }\n openLanes = advanceOpenLanes(row, openLanes);\n }\n\n return lines.map((line) => line.trimEnd()).join('\\n');\n}\n\nexport function renderMigrationListGraph(\n layout: MigrationListGraphLayout,\n style: MigrationListStyler,\n glyphMode: GlyphMode,\n): string {\n return renderMigrationListGraphWithStyle(layout, style, glyphMode);\n}\n\nexport function formatGraphNodeLineHash(contractHash: string, style: MigrationListStyler): string {\n return style.sourceHash(abbreviateContractHash(contractHash));\n}\n\nfunction formatGraphEmptyStateLine(spaceId: string, style: MigrationListStyler): string {\n return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);\n}\n\nfunction renderGraphSpaceBlock(\n spaceId: string,\n migrations: readonly MigrationListEntry[],\n multiSpace: boolean,\n style: MigrationListStyler,\n glyphMode: GlyphMode,\n topology: MigrationListGraphTopology,\n): readonly string[] {\n if (migrations.length === 0) {\n const emptyLine = formatGraphEmptyStateLine(spaceId, style);\n if (!multiSpace) {\n return [emptyLine];\n }\n return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];\n }\n\n const layout = computeMigrationListGraphLayout(migrations, topology);\n const graphBody = renderMigrationListGraphWithStyle(layout, style, glyphMode);\n const rows = graphBody.split('\\n');\n if (!multiSpace) {\n return rows;\n }\n return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];\n}\n\nexport function renderMigrationListGraphResult(\n result: MigrationListResult,\n style: MigrationListStyler,\n glyphMode: GlyphMode,\n topologyBySpaceId: ReadonlyMap<string, MigrationListGraphTopology>,\n): string {\n const multiSpace = result.spaces.length > 1;\n const lines: string[] = [];\n\n for (let index = 0; index < result.spaces.length; index++) {\n const space = result.spaces[index]!;\n if (index > 0) {\n lines.push('');\n }\n const topology = topologyBySpaceId.get(space.spaceId);\n if (topology === undefined) {\n throw new Error(`missing topology for space ${space.spaceId}`);\n }\n lines.push(\n ...renderGraphSpaceBlock(\n space.spaceId,\n space.migrations,\n multiSpace,\n style,\n glyphMode,\n topology,\n ),\n );\n }\n\n const totalMigrations = result.spaces.reduce(\n (count, space) => count + space.migrations.length,\n 0,\n );\n if (totalMigrations > 0) {\n lines.push('');\n lines.push(style.summary(result.summary));\n }\n\n return lines.join('\\n');\n}\n","import type { GlyphMode } from '../glyph-mode';\nimport {\n computeMigrationDirNameWidth,\n formatMigrationDataColumn,\n migrationListEmptySource,\n migrationListForwardArrow,\n migrationListKindGlyph,\n} from './migration-list-data-column';\nimport {\n classifyMigrationListGraphTopology,\n type MigrationEdgeKind,\n type MigrationListGraphTopology,\n} from './migration-list-graph-topology';\nimport type { MigrationListEntry, MigrationListResult } from './migration-list-types';\n\nexport type { GlyphMode } from '../glyph-mode';\nexport type { MigrationEdgeKind } from './migration-list-graph-topology';\nexport type {\n MigrationListEntry,\n MigrationListResult,\n MigrationSpaceListEntry,\n} from './migration-list-types';\n\n/**\n * Semantic styler for `migration list` output tokens. Token-typed so\n * the renderer composes presentation-neutral fragments and the styler\n * decides how each token kind is decorated (ANSI codes, plain text,\n * etc.). The renderer pads with raw spaces *outside* styled tokens so\n * visible column widths stay stable regardless of what the styler\n * emits — adding ANSI escape sequences never disturbs alignment.\n *\n * `invariants` and `refs` receive the underlying string arrays rather\n * than a pre-joined string so per-element styling (e.g. distinguishing\n * the live-DB `db` marker from user-named refs) is possible without\n * having to re-parse a joined block.\n */\nexport interface MigrationListStyler {\n kind(text: string): string;\n dirName(text: string): string;\n sourceHash(text: string): string;\n destHash(text: string): string;\n glyph(text: string): string;\n lane(text: string): string;\n invariants(ids: readonly string[]): string;\n refs(names: readonly string[]): string;\n spaceHeading(text: string): string;\n summary(text: string): string;\n emptyState(text: string): string;\n}\n\nexport const IDENTITY_MIGRATION_LIST_STYLER: MigrationListStyler = {\n kind: (text) => text,\n dirName: (text) => text,\n sourceHash: (text) => text,\n destHash: (text) => text,\n glyph: (text) => text,\n lane: (text) => text,\n invariants: (ids) => `{${ids.join(', ')}}`,\n refs: (names) => `(${names.join(', ')})`,\n spaceHeading: (text) => text,\n summary: (text) => text,\n emptyState: (text) => text,\n};\n\nfunction resolveEdgeKind(\n migrationHash: string,\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n): MigrationEdgeKind {\n return kindByMigrationHash.get(migrationHash) ?? 'forward';\n}\n\nfunction formatMigrationRow(\n migration: MigrationListEntry,\n dirNameWidth: number,\n edgeKind: MigrationEdgeKind,\n glyphMode: GlyphMode,\n style: MigrationListStyler,\n): string {\n const kindColumn = `${style.kind(migrationListKindGlyph(glyphMode, edgeKind))} `;\n const data = formatMigrationDataColumn(migration, {\n dirNameWidth,\n edgeKind,\n style,\n forwardArrow: migrationListForwardArrow(glyphMode),\n emptySource: migrationListEmptySource(glyphMode),\n });\n return `${kindColumn}${data}`;\n}\n\nfunction formatEmptyStateLine(spaceId: string, style: MigrationListStyler): string {\n return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);\n}\n\nfunction renderSpaceBlock(\n spaceId: string,\n migrations: readonly MigrationListEntry[],\n multiSpace: boolean,\n glyphMode: GlyphMode,\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n style: MigrationListStyler,\n): readonly string[] {\n if (migrations.length === 0) {\n const emptyLine = formatEmptyStateLine(spaceId, style);\n if (!multiSpace) {\n return [emptyLine];\n }\n return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];\n }\n\n const dirNameWidth = computeMigrationDirNameWidth(migrations);\n const rows = migrations.map((entry) =>\n formatMigrationRow(\n entry,\n dirNameWidth,\n resolveEdgeKind(entry.migrationHash, kindByMigrationHash),\n glyphMode,\n style,\n ),\n );\n if (!multiSpace) {\n return rows;\n }\n return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];\n}\n\nexport function buildMigrationListTopologyBySpace(\n result: MigrationListResult,\n): ReadonlyMap<string, MigrationListGraphTopology> {\n const topologyBySpaceId = new Map<string, MigrationListGraphTopology>();\n for (const space of result.spaces) {\n topologyBySpaceId.set(space.spaceId, classifyMigrationListGraphTopology(space.migrations));\n }\n return topologyBySpaceId;\n}\n\n/**\n * Compose the styled `migration list` output. The renderer is\n * presentation-neutral — every token passes through `style` before\n * landing in the output, so the same composition serves the pure-text\n * path ({@link renderMigrationList} via\n * {@link IDENTITY_MIGRATION_LIST_STYLER}) and the ANSI-styled CLI path\n * (via the ANSI styler the CLI shell wires up).\n */\nexport function renderMigrationListWithStyle(\n result: MigrationListResult,\n style: MigrationListStyler,\n glyphMode: GlyphMode = 'unicode',\n topologyBySpaceId: ReadonlyMap<\n string,\n MigrationListGraphTopology\n > = buildMigrationListTopologyBySpace(result),\n): string {\n const multiSpace = result.spaces.length > 1;\n const lines: string[] = [];\n\n for (let index = 0; index < result.spaces.length; index++) {\n const space = result.spaces[index]!;\n if (index > 0) {\n lines.push('');\n }\n const topology = topologyBySpaceId.get(space.spaceId);\n const kindByMigrationHash =\n topology?.kindByMigrationHash ??\n classifyMigrationListGraphTopology(space.migrations).kindByMigrationHash;\n lines.push(\n ...renderSpaceBlock(\n space.spaceId,\n space.migrations,\n multiSpace,\n glyphMode,\n kindByMigrationHash,\n style,\n ),\n );\n }\n\n const totalMigrations = result.spaces.reduce(\n (count, space) => count + space.migrations.length,\n 0,\n );\n if (totalMigrations > 0) {\n lines.push('');\n lines.push(style.summary(result.summary));\n }\n\n return lines.join('\\n');\n}\n\nexport function renderMigrationList(result: MigrationListResult): string {\n return renderMigrationListWithStyle(result, IDENTITY_MIGRATION_LIST_STYLER);\n}\n","import { bold, cyan, cyanBright, dim, green, greenBright, yellow } from 'colorette';\nimport { IDENTITY_MIGRATION_LIST_STYLER, type MigrationListStyler } from './migration-list-render';\n\n/**\n * The reserved ref name for the live-database marker. Treated as a\n * structurally distinct token from user-named refs so the styler can\n * make it visually pop in `(refs)` decorations.\n */\nconst DB_REF_NAME = 'db';\n\nfunction styleRefName(name: string): string {\n return name === DB_REF_NAME ? bold(greenBright(name)) : green(name);\n}\n\n/**\n * Build a {@link MigrationListStyler} that decorates `migration list`\n * tokens with ANSI SGR codes. When `useColor` is `false` (non-TTY,\n * `--no-color`, `NO_COLOR=1`, piped output) the function returns the\n * shared identity styler so callers get plain text with zero ANSI\n * bytes — pipe-friendly by construction.\n *\n * Palette:\n *\n * - `dirName`: bold\n * - `sourceHash`: dim cyan\n * - `destHash`: bright cyan\n * - `kind` (`*` / `↩` / `⟲`): bright — the signal; lanes and arrows dim\n * - `glyph` (`→` / `⟲` / `∅`): dim\n * - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim\n * - `invariants` (`{...}`): yellow\n * - `refs` (`(...)`): green; the live-DB `db` marker inside is green-bold\n * - `spaceHeading` (`<spaceId>:`): bold\n * - `summary`: dim\n * - `emptyState`: dim\n */\nexport function createAnsiMigrationListStyler(opts: {\n readonly useColor: boolean;\n}): MigrationListStyler {\n if (!opts.useColor) {\n return IDENTITY_MIGRATION_LIST_STYLER;\n }\n return {\n // Kind glyphs stay bright in both flat and graph views; lanes carry the dim gutter.\n kind: (text) => text,\n dirName: (text) => bold(text),\n sourceHash: (text) => dim(cyan(text)),\n destHash: (text) => cyanBright(text),\n glyph: (text) => dim(text),\n lane: (text) => dim(text),\n invariants: (ids) => yellow(`{${ids.join(', ')}}`),\n refs: (names) => {\n const open = green('(');\n const close = green(')');\n const separator = green(', ');\n return open + names.map(styleRefName).join(separator) + close;\n },\n spaceHeading: (text) => bold(text),\n summary: (text) => dim(text),\n emptyState: (text) => dim(text),\n };\n}\n","import type {\n ContractSpaceAggregate,\n ContractSpaceMember,\n} from '@prisma-next/migration-tools/aggregate';\nimport { HEAD_REF_NAME, refsByContractHash } from '@prisma-next/migration-tools/refs';\nimport {\n APP_SPACE_ID,\n isValidSpaceId,\n listContractSpaceDirectories,\n RESERVED_SPACE_SUBDIR_NAMES,\n} from '@prisma-next/migration-tools/spaces';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport {\n type CliStructuredError,\n errorInvalidSpaceId,\n errorSpaceNotFound,\n} 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 type GlyphMode,\n renderMigrationListGraphResult,\n} from '../utils/formatters/migration-list-graph-render';\nimport {\n buildMigrationListTopologyBySpace,\n renderMigrationListWithStyle,\n} from '../utils/formatters/migration-list-render';\nimport { createAnsiMigrationListStyler } from '../utils/formatters/migration-list-styler';\nimport type {\n MigrationListEntry,\n MigrationListResult,\n MigrationSpaceListEntry,\n} from '../utils/formatters/migration-list-types';\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\nfunction compareSpaceIds(a: string, b: string): number {\n if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;\n if (b === APP_SPACE_ID) return 1;\n if (a < b) return -1;\n if (a > b) return 1;\n return 0;\n}\n\nfunction compareDirNamesDescending(a: MigrationListEntry, b: MigrationListEntry): number {\n if (a.dirName < b.dirName) return 1;\n if (a.dirName > b.dirName) return -1;\n return 0;\n}\n\n/**\n * Ref names decorating a space's destination contract hashes. The\n * tolerant `member.refs` deliberately omits the structural `head.json`;\n * for extension spaces the old enumerator surfaced it as a `head`\n * decoration on the tip migration, so fold `member.headRef` back in to\n * keep that output. The app space synthesises its head, so it carries\n * no on-disk `head` ref to restore.\n */\nfunction listRefsByContractHash(\n member: ContractSpaceMember,\n): ReadonlyMap<string, readonly string[]> {\n const byHash = new Map(refsByContractHash(member.refs));\n if (member.spaceId !== APP_SPACE_ID && member.headRef !== null) {\n const hash = member.headRef.hash;\n const bucket = byHash.get(hash) ?? [];\n if (!bucket.includes(HEAD_REF_NAME)) {\n byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());\n }\n }\n return byHash;\n}\n\nasync function orderedOnDiskSpaceIds(projectMigrationsDir: string): Promise<readonly string[]> {\n const candidateDirs = await listContractSpaceDirectories(projectMigrationsDir);\n return candidateDirs\n .filter((name) => !RESERVED_SPACE_SUBDIR_NAMES.has(name))\n .filter(isValidSpaceId)\n .sort(compareSpaceIds);\n}\n\n/**\n * Project the loaded {@link ContractSpaceAggregate} into the render-ready\n * {@link MigrationSpaceListEntry} rows `migration list` displays.\n *\n * Space membership matches the on-disk contract-space directories (not the\n * aggregate's always-present synthesized app member when `migrations/app/`\n * is absent); package and ref data come from `aggregate.space(id)`.\n */\nexport async function migrationSpaceListEntriesFromAggregate(\n aggregate: ContractSpaceAggregate,\n projectMigrationsDir: string,\n): Promise<readonly MigrationSpaceListEntry[]> {\n const spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);\n const spaces: MigrationSpaceListEntry[] = [];\n\n for (const spaceId of spaceIds) {\n const member = aggregate.space(spaceId);\n if (member === undefined) {\n continue;\n }\n const refsByHash = listRefsByContractHash(member);\n const migrations: MigrationListEntry[] = member.packages\n .map((pkg) => ({\n dirName: pkg.dirName,\n from: pkg.metadata.from,\n to: pkg.metadata.to,\n migrationHash: pkg.metadata.migrationHash,\n operationCount: pkg.ops.length,\n createdAt: pkg.metadata.createdAt,\n refs: refsByHash.get(pkg.metadata.to) ?? [],\n providedInvariants: pkg.metadata.providedInvariants,\n }))\n .sort(compareDirNamesDescending);\n\n spaces.push({ spaceId, migrations });\n }\n\n return spaces;\n}\n\ninterface MigrationListOptions extends CommonCommandOptions {\n readonly config?: string;\n readonly space?: string;\n readonly graph?: boolean;\n readonly ascii?: boolean;\n}\n\nexport interface MigrationListHumanRenderOptions {\n readonly graph: boolean;\n readonly glyphMode: GlyphMode;\n readonly useColor: boolean;\n}\n\nexport function renderMigrationListHumanOutput(\n result: MigrationListResult,\n options: MigrationListHumanRenderOptions,\n): string {\n const styler = createAnsiMigrationListStyler({ useColor: options.useColor });\n const topologyBySpaceId = buildMigrationListTopologyBySpace(result);\n if (options.graph) {\n return renderMigrationListGraphResult(result, styler, options.glyphMode, topologyBySpaceId);\n }\n return renderMigrationListWithStyle(result, styler, options.glyphMode, topologyBySpaceId);\n}\n\n/**\n * Inputs for {@link runMigrationList} — the policy core of `migration list`\n * that tests exercise directly.\n *\n * The core does not call `loadConfig`, parse CLI flags, render a styled\n * header, or write to any stream. Enumeration is supplied by the caller\n * (the CLI shell builds it from {@link migrationSpaceListEntriesFromAggregate}).\n */\nexport interface RunMigrationListInputs {\n readonly spaces: readonly MigrationSpaceListEntry[];\n readonly spaceFilter?: string;\n}\n\nfunction computeSummary(spaces: readonly MigrationSpaceListEntry[]): string {\n const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);\n if (spaces.length <= 1) {\n return `${totalMigrations} migration(s) on disk`;\n }\n return `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;\n}\n\n/**\n * Policy core of `migration list`: validates `--space`, narrows the\n * pre-enumerated spaces, and assembles a {@link MigrationListResult}.\n *\n * - `migrations/` missing or contains no valid space directories →\n * caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.\n * - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.\n * - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.\n */\nexport function runMigrationList(\n inputs: RunMigrationListInputs,\n): Result<MigrationListResult, CliStructuredError> {\n const { spaces, spaceFilter } = inputs;\n\n if (spaceFilter !== undefined && !isValidSpaceId(spaceFilter)) {\n return notOk(errorInvalidSpaceId(spaceFilter));\n }\n\n if (spaceFilter !== undefined && !spaces.some((s) => s.spaceId === spaceFilter)) {\n return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()));\n }\n\n const scopedSpaces =\n spaceFilter !== undefined ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\n const resultSpaces: readonly MigrationSpaceListEntry[] =\n scopedSpaces.length === 0 ? [{ spaceId: APP_SPACE_ID, migrations: [] }] : scopedSpaces;\n\n return ok({\n ok: true,\n spaces: resultSpaces,\n summary: computeSummary(resultSpaces),\n });\n}\n\n/**\n * CLI shell: loads config, resolves paths, prints the styled header on\n * stderr (interactive mode only), and delegates to {@link runMigrationList}.\n * Kept intentionally thin so the unit-testable surface lives in the core.\n */\nexport async function executeMigrationListCommand(\n options: MigrationListOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationListResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration list',\n description: 'List on-disk migrations, latest first, per contract space',\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 }\n\n const loaded = await buildReadAggregate(config, { migrationsDir });\n if (!loaded.ok) {\n return notOk(loaded.failure);\n }\n\n const spaces = await migrationSpaceListEntriesFromAggregate(\n loaded.value.aggregate,\n migrationsDir,\n );\n\n return runMigrationList({\n spaces,\n ...ifDefined('spaceFilter', options.space),\n });\n}\n\nexport function createMigrationListCommand(): Command {\n const command = new Command('list');\n setCommandDescriptions(\n command,\n 'List on-disk migrations, latest first, per contract space',\n 'Enumerates every on-disk migration under migrations/<space>/ for every\\n' +\n 'contract space found on disk, latest first. Offline — does not consult\\n' +\n 'the database. Each row leads with a kind glyph (* forward, ↩ rollback,\\n' +\n '⟲ self), then dirName, then source → destination contract hashes\\n' +\n '(7-char git-style). Self-edges show a single hash. Invariants render as\\n' +\n '{...}; refs on the destination as (production, db). Pass --space <id>\\n' +\n 'to narrow to one contract space. --graph draws the forward spine with\\n' +\n 'lane gutters; --ascii forces ASCII glyphs (orthogonal to --no-color).',\n );\n setCommandExamples(command, [\n 'prisma-next migration list',\n 'prisma-next migration list --graph',\n 'prisma-next migration list --space app',\n 'prisma-next migration list --graph --ascii',\n 'prisma-next migration list --json',\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 graph', oneLiner: 'Show the migration graph topology' },\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('--graph', 'Draw migration relationships as an annotated tree')\n .option('--ascii', 'Use ASCII glyphs for --graph (pipe-friendly)')\n .action(async (options: MigrationListOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n const result = await executeMigrationListCommand(options, flags, ui);\n const exitCode = handleResult(result, flags, ui, (listResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(listResult, null, 2));\n } else if (!flags.quiet) {\n ui.output(\n renderMigrationListHumanOutput(listResult, {\n graph: options.graph === true,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n useColor: ui.useColor,\n }),\n );\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAa,oCAAuE;CAClF,SAAS;CACT,UAAU;CACV,MAAM;AACR;AAEA,MAAa,kCAAqE;CAChF,SAAS;CACT,UAAU;CACV,MAAM;AACR;AAEA,SAAgB,uBAAuB,WAAsB,UAAqC;CAChG,OAAO,cAAc,UACjB,gCAAgC,YAChC,kCAAkC;AACxC;AAEA,SAAgB,0BAA0B,WAA8B;CACtE,OAAO,cAAc,UAAA,OAAA;AAGvB;AAEA,SAAgB,yBAAyB,WAA8B;CACrE,OAAO,cAAc,UAAA,MAAA;AACvB;AAEA,SAAgB,uBAAuB,MAAsB;CAE3D,QADiB,KAAK,WAAW,SAAS,IAAI,KAAK,MAAM,CAAC,IAAI,MAC9C,MAAM,GAAA,CAA4B;AACpD;AAEA,SAAgB,6BAA6B,YAAmD;CAC9F,IAAI,WAAW,WAAW,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,GAAG,WAAW,KAAK,UAAU,MAAM,QAAQ,MAAM,CAAC,IAAI;AACxE;AAEA,SAAS,mBACP,MACA,OACA,aACQ;CACR,IAAI,SAAS,MACX,OAAO,MAAM,MAAM,WAAW,IAAI,IAAI,OAAA,IAAmC,YAAY,MAAM;CAE7F,OAAO,MAAM,WAAW,uBAAuB,IAAI,CAAC;AACtD;AAEA,SAAgB,kBACd,oBACA,MACA,OACQ;CACR,MAAM,SAAmB,CAAC;CAC1B,IAAI,mBAAmB,SAAS,GAC9B,OAAO,KAAK,MAAM,WAAW,kBAAkB,CAAC;CAElD,IAAI,KAAK,SAAS,GAChB,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC;CAE9B,IAAI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