@prisma-next/cli 0.16.0-dev.5 → 0.16.0-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cli.mjs +13 -13
  2. package/dist/{client-KuBQftxz.mjs → client-2kwLMBSf.mjs} +4 -4
  3. package/dist/{client-KuBQftxz.mjs.map → client-2kwLMBSf.mjs.map} +1 -1
  4. package/dist/{command-helpers-Cpq44aVa.mjs → command-helpers-CVn3U9Uz.mjs} +12 -4
  5. package/dist/command-helpers-CVn3U9Uz.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.d.mts.map +1 -1
  9. package/dist/commands/db-init.mjs +5 -4
  10. package/dist/commands/db-init.mjs.map +1 -1
  11. package/dist/commands/db-schema.mjs +3 -3
  12. package/dist/commands/db-sign.mjs +4 -4
  13. package/dist/commands/db-update.d.mts.map +1 -1
  14. package/dist/commands/db-update.mjs +6 -5
  15. package/dist/commands/db-update.mjs.map +1 -1
  16. package/dist/commands/db-verify.mjs +1 -1
  17. package/dist/commands/migrate.d.mts.map +1 -1
  18. package/dist/commands/migrate.mjs +7 -7
  19. package/dist/commands/migrate.mjs.map +1 -1
  20. package/dist/commands/migration-check.mjs +1 -1
  21. package/dist/commands/migration-graph.mjs +3 -3
  22. package/dist/commands/migration-list.mjs +1 -1
  23. package/dist/commands/migration-log.mjs +1 -1
  24. package/dist/commands/migration-new.mjs +3 -3
  25. package/dist/commands/migration-plan.mjs +1 -1
  26. package/dist/commands/migration-show.mjs +3 -3
  27. package/dist/commands/migration-status.mjs +1 -1
  28. package/dist/commands/ref.d.mts.map +1 -1
  29. package/dist/commands/ref.mjs +7 -10
  30. package/dist/commands/ref.mjs.map +1 -1
  31. package/dist/commands/telemetry/index.mjs +1 -1
  32. package/dist/{contract-at-errors-CTtzKR6q.mjs → contract-at-errors-C-l4-JEY.mjs} +5 -7
  33. package/dist/contract-at-errors-C-l4-JEY.mjs.map +1 -0
  34. package/dist/{contract-emit-CgnXSANN.mjs → contract-emit-DzOkTs11.mjs} +3 -3
  35. package/dist/{contract-emit-CgnXSANN.mjs.map → contract-emit-DzOkTs11.mjs.map} +1 -1
  36. package/dist/{contract-emit-cJQBlvGb.mjs → contract-emit-iSMJVs26.mjs} +3 -3
  37. package/dist/{contract-emit-cJQBlvGb.mjs.map → contract-emit-iSMJVs26.mjs.map} +1 -1
  38. package/dist/{contract-infer-Cg8evbeg.mjs → contract-infer-BVqworBB.mjs} +3 -3
  39. package/dist/{contract-infer-Cg8evbeg.mjs.map → contract-infer-BVqworBB.mjs.map} +1 -1
  40. package/dist/{contract-space-aggregate-loader-D_3VeHVb.mjs → contract-space-aggregate-loader-hPVymNLw.mjs} +2 -2
  41. package/dist/{contract-space-aggregate-loader-D_3VeHVb.mjs.map → contract-space-aggregate-loader-hPVymNLw.mjs.map} +1 -1
  42. package/dist/{db-verify-BEclUzki.mjs → db-verify-BpwCMyWJ.mjs} +4 -4
  43. package/dist/{db-verify-BEclUzki.mjs.map → db-verify-BpwCMyWJ.mjs.map} +1 -1
  44. package/dist/exports/control-api.mjs +2 -2
  45. package/dist/exports/index.mjs +2 -2
  46. package/dist/{format-DAUAZqPt.mjs → format-CefCDzkw.mjs} +2 -2
  47. package/dist/{format-DAUAZqPt.mjs.map → format-CefCDzkw.mjs.map} +1 -1
  48. package/dist/{framework-components-CnbUbiJw.mjs → framework-components-VMQJbAwl.mjs} +2 -2
  49. package/dist/{framework-components-CnbUbiJw.mjs.map → framework-components-VMQJbAwl.mjs.map} +1 -1
  50. package/dist/{init-CgKEi_t5.mjs → init-BSgPxVXA.mjs} +3 -3
  51. package/dist/{init-CgKEi_t5.mjs.map → init-BSgPxVXA.mjs.map} +1 -1
  52. package/dist/{inspect-live-schema-CX7EA5C3.mjs → inspect-live-schema-DxsD_a4d.mjs} +3 -3
  53. package/dist/{inspect-live-schema-CX7EA5C3.mjs.map → inspect-live-schema-DxsD_a4d.mjs.map} +1 -1
  54. package/dist/{migration-check-CcuayFB2.mjs → migration-check-Biu1YZXu.mjs} +4 -4
  55. package/dist/{migration-check-CcuayFB2.mjs.map → migration-check-Biu1YZXu.mjs.map} +1 -1
  56. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs → migration-command-scaffold-DB_i9nBC.mjs} +3 -3
  57. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs.map → migration-command-scaffold-DB_i9nBC.mjs.map} +1 -1
  58. package/dist/{migration-list-6z6vuXHa.mjs → migration-list-cnSKilYH.mjs} +3 -3
  59. package/dist/{migration-list-6z6vuXHa.mjs.map → migration-list-cnSKilYH.mjs.map} +1 -1
  60. package/dist/{migration-log-C_xam2HZ.mjs → migration-log-CEqFiez9.mjs} +3 -3
  61. package/dist/{migration-log-C_xam2HZ.mjs.map → migration-log-CEqFiez9.mjs.map} +1 -1
  62. package/dist/{migration-path-target-DpPTsRCg.mjs → migration-path-target-C0TQuV5n.mjs} +2 -2
  63. package/dist/{migration-path-target-DpPTsRCg.mjs.map → migration-path-target-C0TQuV5n.mjs.map} +1 -1
  64. package/dist/{migration-plan-DuMEUejG.mjs → migration-plan-BJHulFZC.mjs} +9 -9
  65. package/dist/migration-plan-BJHulFZC.mjs.map +1 -0
  66. package/dist/{migration-status-B61YOaMl.mjs → migration-status-Df4zK5lO.mjs} +5 -5
  67. package/dist/{migration-status-B61YOaMl.mjs.map → migration-status-Df4zK5lO.mjs.map} +1 -1
  68. package/dist/{ref-advancement-BkXlikCA.mjs → ref-advancement-BCz7X7qJ.mjs} +13 -6
  69. package/dist/ref-advancement-BCz7X7qJ.mjs.map +1 -0
  70. package/dist/{telemetry-DVr6RFnq.mjs → telemetry-BEyNMfco.mjs} +2 -2
  71. package/dist/{telemetry-DVr6RFnq.mjs.map → telemetry-BEyNMfco.mjs.map} +1 -1
  72. package/dist/{verify-CgDVZjhc.mjs → verify-C4RazDE1.mjs} +2 -2
  73. package/dist/{verify-CgDVZjhc.mjs.map → verify-C4RazDE1.mjs.map} +1 -1
  74. package/package.json +21 -21
  75. package/src/commands/db-init.ts +1 -0
  76. package/src/commands/db-update.ts +1 -0
  77. package/src/commands/migrate.ts +1 -0
  78. package/src/commands/migration-plan.ts +1 -1
  79. package/src/commands/ref.ts +5 -11
  80. package/src/utils/cli-errors.ts +13 -5
  81. package/src/utils/contract-at-errors.ts +4 -9
  82. package/src/utils/plan-resolution.ts +5 -5
  83. package/src/utils/ref-advancement.ts +22 -3
  84. package/dist/command-helpers-Cpq44aVa.mjs.map +0 -1
  85. package/dist/contract-at-errors-CTtzKR6q.mjs.map +0 -1
  86. package/dist/migration-plan-DuMEUejG.mjs.map +0 -1
  87. package/dist/ref-advancement-BkXlikCA.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"verify-CgDVZjhc.mjs","names":[],"sources":["../src/utils/formatters/verify.ts"],"sourcesContent":["import type {\n CoreSchemaView,\n ExpectationFailureReason,\n IntrospectSchemaResult,\n SchemaDiffIssue,\n SchemaTreeNode,\n SignDatabaseResult,\n VerifyDatabaseResult,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { issueOutcome } from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { bold, cyan, dim, green, magenta, red, yellow } from 'colorette';\nimport type { GlobalFlags } from '../global-flags';\nimport { createColorFormatter, formatDim, isVerbose } from './helpers';\n\n/** Human-readable label for each outcome, prefixed onto an issue's message for display. */\nconst OUTCOME_LABEL: Record<ExpectationFailureReason, string> = {\n 'not-found': 'missing',\n 'not-expected': 'extra',\n 'not-equal': 'mismatch',\n};\n\n/**\n * The issue's display text: its own path, prefixed with a human label for\n * why it's flagged. Turning the presence-derived outcome (and the path) into\n * prose is this formatter's job, not the differ's — the differ's issue is\n * data (`path` + nodes), not prose.\n */\nfunction formatIssueMessage(issue: SchemaDiffIssue): string {\n return `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join('/')}`;\n}\n\n// ============================================================================\n// Verify Output Formatters\n// ============================================================================\n\nexport interface DbVerifyCommandSuccessResult {\n readonly ok: true;\n readonly mode: 'full' | 'marker-only';\n readonly summary: string;\n readonly contract: VerifyDatabaseResult['contract'];\n readonly marker?: VerifyDatabaseResult['marker'];\n readonly target: VerifyDatabaseResult['target'];\n readonly missingCodecs?: VerifyDatabaseResult['missingCodecs'];\n readonly codecCoverageSkipped?: VerifyDatabaseResult['codecCoverageSkipped'];\n readonly schema?: {\n readonly summary: string;\n readonly strict: boolean;\n /**\n * Warn-graded finding messages (observed-policy drift). Informational —\n * present on a passing verify; the full-mode result summarizes them as a\n * flat message list.\n */\n readonly warnings?: readonly string[];\n };\n /**\n * Live element names no contract space declares. In full success this is\n * only ever non-empty in lenient mode — strict mode fails on it — and is\n * rendered informationally.\n */\n readonly unclaimed?: readonly string[];\n readonly warning?: string;\n readonly meta?:\n | (NonNullable<VerifyDatabaseResult['meta']> & {\n readonly schemaVerification: 'performed' | 'skipped';\n })\n | {\n readonly schemaVerification: 'performed' | 'skipped';\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\n/**\n * Formats human-readable output for database verify.\n */\nexport function formatVerifyOutput(\n result: DbVerifyCommandSuccessResult,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n const verificationMode =\n result.mode === 'full'\n ? `marker + schema${result.schema?.strict ? ' (strict)' : ' (tolerant)'}`\n : 'marker only (--marker-only)';\n\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n lines.push(`${formatDimText(` verification: ${verificationMode}`)}`);\n lines.push(`${formatDimText(` storageHash: ${result.contract.storageHash}`)}`);\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.schema?.warnings && result.schema.warnings.length > 0) {\n lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of result.schema.warnings) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (result.unclaimed && result.unclaimed.length > 0) {\n lines.push('');\n lines.push(formatYellow('Unclaimed elements (declared by no contract):'));\n for (const name of result.unclaimed) {\n lines.push(` ${formatYellow('⚠')} ${name}`);\n }\n }\n\n if (result.warning) {\n lines.push('');\n lines.push(`${formatYellow('⚠')} ${result.warning}`);\n }\n\n if (isVerbose(flags, 1)) {\n if (result.codecCoverageSkipped) {\n lines.push(\n `${formatDimText(' Codec coverage check skipped (helper returned no supported types)')}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database verify.\n */\nexport function formatVerifyJson(result: DbVerifyCommandSuccessResult): string {\n const output = {\n ok: result.ok,\n summary: result.summary,\n mode: result.mode,\n contract: result.contract,\n ...ifDefined('marker', result.marker),\n target: result.target,\n ...ifDefined('missingCodecs', result.missingCodecs),\n ...ifDefined('codecCoverageSkipped', result.codecCoverageSkipped),\n ...ifDefined('schema', result.schema),\n unclaimed: result.unclaimed ?? [],\n ...ifDefined('warning', result.warning),\n ...ifDefined('meta', result.meta),\n timings: result.timings,\n };\n\n return JSON.stringify(output, null, 2);\n}\n\n/**\n * Formats JSON output for database introspection.\n */\nexport function formatIntrospectJson(result: IntrospectSchemaResult<unknown>): string {\n return JSON.stringify(result, null, 2);\n}\n\n/**\n * Renders a schema tree structure from CoreSchemaView.\n * Status-glyph tree styling shared with the retired verification-tree renderer.\n */\nfunction renderSchemaTree(\n node: SchemaTreeNode,\n flags: GlobalFlags,\n options: {\n readonly isLast: boolean;\n readonly prefix: string;\n readonly useColor: boolean;\n readonly formatDimText: (text: string) => string;\n readonly isRoot?: boolean;\n },\n): string[] {\n const { isLast, prefix, useColor, formatDimText, isRoot = false } = options;\n const lines: string[] = [];\n\n // Format node label with color based on kind (matching schema-verify style)\n let formattedLabel: string = node.label;\n\n if (useColor) {\n switch (node.kind) {\n case 'root':\n formattedLabel = bold(node.label);\n break;\n case 'entity': {\n // Parse \"table tableName\" format - color \"table\" dim, tableName cyan\n const tableMatch = node.label.match(/^table\\s+(.+)$/);\n if (tableMatch?.[1]) {\n const tableName = tableMatch[1];\n formattedLabel = `${dim('table')} ${cyan(tableName)}`;\n } else {\n // Fallback: color entire label with cyan\n formattedLabel = cyan(node.label);\n }\n break;\n }\n case 'collection': {\n // \"columns\" grouping node - dim the label\n formattedLabel = dim(node.label);\n break;\n }\n case 'field': {\n // Parse column name format: \"columnName: typeDisplay (nullability)\"\n // Color code: column name (cyan), type (default), nullability (dim)\n const columnMatch = node.label.match(/^([^:]+):\\s*(.+)$/);\n if (columnMatch?.[1] && columnMatch[2]) {\n const columnName = columnMatch[1];\n const rest = columnMatch[2];\n // Parse rest: \"typeDisplay (nullability)\"\n const typeMatch = rest.match(/^([^\\s(]+)\\s*(\\([^)]+\\))$/);\n if (typeMatch?.[1] && typeMatch[2]) {\n const typeDisplay = typeMatch[1];\n const nullability = typeMatch[2];\n formattedLabel = `${cyan(columnName)}: ${typeDisplay} ${dim(nullability)}`;\n } else {\n // Fallback if format doesn't match\n formattedLabel = `${cyan(columnName)}: ${rest}`;\n }\n } else {\n formattedLabel = node.label;\n }\n break;\n }\n case 'index': {\n // Parse index/unique constraint/primary key formats\n // \"primary key: columnName\" -> dim \"primary key\", cyan columnName\n const pkMatch = node.label.match(/^primary key:\\s*(.+)$/);\n if (pkMatch?.[1]) {\n const columnNames = pkMatch[1];\n formattedLabel = `${dim('primary key')}: ${cyan(columnNames)}`;\n } else {\n // \"unique name\" -> dim \"unique\", cyan \"name\"\n const uniqueMatch = node.label.match(/^unique\\s+(.+)$/);\n if (uniqueMatch?.[1]) {\n const name = uniqueMatch[1];\n formattedLabel = `${dim('unique')} ${cyan(name)}`;\n } else {\n // \"index name\" or \"unique index name\" -> dim label prefix, cyan name\n const indexMatch = node.label.match(/^(unique\\s+)?index\\s+(.+)$/);\n if (indexMatch?.[2]) {\n const indexPrefix = indexMatch[1] ? `${dim('unique')} ` : '';\n const name = indexMatch[2];\n formattedLabel = `${indexPrefix}${dim('index')} ${cyan(name)}`;\n } else {\n formattedLabel = dim(node.label);\n }\n }\n }\n break;\n }\n case 'dependency': {\n // Parse extension message formats similar to schema-verify\n // \"extensionName extension is enabled\" -> cyan extensionName, dim rest\n const extMatch = node.label.match(/^([^\\s]+)\\s+(extension is enabled)$/);\n if (extMatch?.[1] && extMatch[2]) {\n const extName = extMatch[1];\n const rest = extMatch[2];\n formattedLabel = `${cyan(extName)} ${dim(rest)}`;\n } else {\n // Fallback: color entire label with magenta\n formattedLabel = magenta(node.label);\n }\n break;\n }\n default:\n formattedLabel = node.label;\n break;\n }\n }\n\n // Root node renders without tree characters or prefix\n if (isRoot) {\n lines.push(formattedLabel);\n } else {\n const treeChar = isLast ? '└' : '├';\n const treePrefix = `${formatDimText(treeChar)}─ `;\n lines.push(`${prefix}${treePrefix}${formattedLabel}`);\n }\n\n // Render children if present\n if (node.children && node.children.length > 0) {\n const childPrefix = isRoot ? '' : `${prefix}${isLast ? ' ' : `${formatDimText('│')} `}`;\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n if (!child) continue;\n const isLastChild = i === node.children.length - 1;\n const childLines = renderSchemaTree(child, flags, {\n isLast: isLastChild,\n prefix: childPrefix,\n useColor,\n formatDimText,\n isRoot: false,\n });\n lines.push(...childLines);\n }\n }\n\n return lines;\n}\n\n/**\n * Formats human-readable output for database introspection.\n */\nexport function formatIntrospectOutput(\n result: IntrospectSchemaResult<unknown>,\n schemaView: CoreSchemaView | undefined,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (schemaView) {\n // Render tree structure - root node is special (no tree characters)\n const treeLines = renderSchemaTree(schemaView.root, flags, {\n isLast: true,\n prefix: '',\n useColor,\n formatDimText,\n isRoot: true,\n });\n lines.push(...treeLines);\n } else {\n // Fallback: print summary when toSchemaView is not available\n lines.push(`✔ ${result.summary}`);\n if (isVerbose(flags, 1)) {\n lines.push(` Target: ${result.target.familyId}/${result.target.id}`);\n if (result.meta?.dbUrl) {\n lines.push(` Database: ${result.meta.dbUrl}`);\n }\n }\n }\n\n // Add timings in verbose mode\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats human-readable output for database schema verification.\n */\nexport function formatSchemaVerifyOutput(\n result: VerifyDatabaseSchemaResult,\n flags: GlobalFlags,\n unclaimed: readonly string[] = [],\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatRed = createColorFormatter(useColor, red);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n const issueMessages = result.schema.issues.map(formatIssueMessage);\n if (issueMessages.length > 0) {\n lines.push(formatRed('Schema issues:'));\n for (const message of issueMessages) {\n lines.push(` ${formatRed('✖')} ${message}`);\n }\n }\n\n const warningMessages = (result.schema.warnings?.issues ?? []).map(formatIssueMessage);\n if (warningMessages.length > 0) {\n if (lines.length > 0) lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of warningMessages) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (unclaimed.length > 0) {\n const strict = result.meta?.strict ?? false;\n if (lines.length > 0) lines.push('');\n lines.push(\n (strict ? formatRed : formatYellow)('Unclaimed elements (declared by no contract):'),\n );\n for (const name of unclaimed) {\n lines.push(` ${(strict ? formatRed : formatYellow)(strict ? '✖' : '⚠')} ${name}`);\n }\n }\n\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n // Blank line before summary\n if (lines.length > 0) lines.push('');\n\n // Summary line at the end: verdict with status glyph\n if (result.ok) {\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n } else {\n const codeText = result.code ? ` (${result.code})` : '';\n lines.push(`${formatRed('✖')} ${result.summary}${codeText}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database schema verification. The unclaimed-elements\n * list is a top-level field alongside the combined result, reported once for\n * the whole database.\n */\nexport function formatSchemaVerifyJson(\n result: VerifyDatabaseSchemaResult,\n unclaimed: readonly string[] = [],\n): string {\n return JSON.stringify({ ...result, unclaimed }, null, 2);\n}\n\n// ============================================================================\n// Sign Output Formatters\n// ============================================================================\n\n/**\n * Formats human-readable output for database sign.\n */\nexport function formatSignOutput(result: SignDatabaseResult, flags: GlobalFlags): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (result.ok) {\n // Main success message in white (not dimmed)\n lines.push(`${formatGreen('✔')} Database signed`);\n\n // Show from -> to hashes with clear labels\n const previousHash = result.marker.previous?.storageHash ?? 'none';\n const currentHash = result.contract.storageHash;\n\n lines.push(`${formatDimText(` from: ${previousHash}`)}`);\n lines.push(`${formatDimText(` to: ${currentHash}`)}`);\n\n if (isVerbose(flags, 1)) {\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.marker.previous?.profileHash) {\n lines.push(\n `${formatDimText(` previous profileHash: ${result.marker.previous.profileHash}`)}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database sign.\n */\nexport function formatSignJson(result: SignDatabaseResult): string {\n return JSON.stringify(result, null, 2);\n}\n"],"mappings":";;;;;;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,cAAc,2BAA2B,OAAO,OAAO,SAAS,aAAa,GAClF;GAEF,MAAM,KAAK,GAAG,cAAc,iBAAiB,OAAO,QAAQ,MAAM,GAAG,GAAG;EAC1E;CACF;CAEA,OAAO,MAAM,KAAK,IAAI;AACxB;;;;AAKA,SAAgB,eAAe,QAAoC;CACjE,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AACvC"}
1
+ {"version":3,"file":"verify-C4RazDE1.mjs","names":[],"sources":["../src/utils/formatters/verify.ts"],"sourcesContent":["import type {\n CoreSchemaView,\n ExpectationFailureReason,\n IntrospectSchemaResult,\n SchemaDiffIssue,\n SchemaTreeNode,\n SignDatabaseResult,\n VerifyDatabaseResult,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { issueOutcome } from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { bold, cyan, dim, green, magenta, red, yellow } from 'colorette';\nimport type { GlobalFlags } from '../global-flags';\nimport { createColorFormatter, formatDim, isVerbose } from './helpers';\n\n/** Human-readable label for each outcome, prefixed onto an issue's message for display. */\nconst OUTCOME_LABEL: Record<ExpectationFailureReason, string> = {\n 'not-found': 'missing',\n 'not-expected': 'extra',\n 'not-equal': 'mismatch',\n};\n\n/**\n * The issue's display text: its own path, prefixed with a human label for\n * why it's flagged. Turning the presence-derived outcome (and the path) into\n * prose is this formatter's job, not the differ's — the differ's issue is\n * data (`path` + nodes), not prose.\n */\nfunction formatIssueMessage(issue: SchemaDiffIssue): string {\n return `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join('/')}`;\n}\n\n// ============================================================================\n// Verify Output Formatters\n// ============================================================================\n\nexport interface DbVerifyCommandSuccessResult {\n readonly ok: true;\n readonly mode: 'full' | 'marker-only';\n readonly summary: string;\n readonly contract: VerifyDatabaseResult['contract'];\n readonly marker?: VerifyDatabaseResult['marker'];\n readonly target: VerifyDatabaseResult['target'];\n readonly missingCodecs?: VerifyDatabaseResult['missingCodecs'];\n readonly codecCoverageSkipped?: VerifyDatabaseResult['codecCoverageSkipped'];\n readonly schema?: {\n readonly summary: string;\n readonly strict: boolean;\n /**\n * Warn-graded finding messages (observed-policy drift). Informational —\n * present on a passing verify; the full-mode result summarizes them as a\n * flat message list.\n */\n readonly warnings?: readonly string[];\n };\n /**\n * Live element names no contract space declares. In full success this is\n * only ever non-empty in lenient mode — strict mode fails on it — and is\n * rendered informationally.\n */\n readonly unclaimed?: readonly string[];\n readonly warning?: string;\n readonly meta?:\n | (NonNullable<VerifyDatabaseResult['meta']> & {\n readonly schemaVerification: 'performed' | 'skipped';\n })\n | {\n readonly schemaVerification: 'performed' | 'skipped';\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\n/**\n * Formats human-readable output for database verify.\n */\nexport function formatVerifyOutput(\n result: DbVerifyCommandSuccessResult,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n const verificationMode =\n result.mode === 'full'\n ? `marker + schema${result.schema?.strict ? ' (strict)' : ' (tolerant)'}`\n : 'marker only (--marker-only)';\n\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n lines.push(`${formatDimText(` verification: ${verificationMode}`)}`);\n lines.push(`${formatDimText(` storageHash: ${result.contract.storageHash}`)}`);\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.schema?.warnings && result.schema.warnings.length > 0) {\n lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of result.schema.warnings) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (result.unclaimed && result.unclaimed.length > 0) {\n lines.push('');\n lines.push(formatYellow('Unclaimed elements (declared by no contract):'));\n for (const name of result.unclaimed) {\n lines.push(` ${formatYellow('⚠')} ${name}`);\n }\n }\n\n if (result.warning) {\n lines.push('');\n lines.push(`${formatYellow('⚠')} ${result.warning}`);\n }\n\n if (isVerbose(flags, 1)) {\n if (result.codecCoverageSkipped) {\n lines.push(\n `${formatDimText(' Codec coverage check skipped (helper returned no supported types)')}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database verify.\n */\nexport function formatVerifyJson(result: DbVerifyCommandSuccessResult): string {\n const output = {\n ok: result.ok,\n summary: result.summary,\n mode: result.mode,\n contract: result.contract,\n ...ifDefined('marker', result.marker),\n target: result.target,\n ...ifDefined('missingCodecs', result.missingCodecs),\n ...ifDefined('codecCoverageSkipped', result.codecCoverageSkipped),\n ...ifDefined('schema', result.schema),\n unclaimed: result.unclaimed ?? [],\n ...ifDefined('warning', result.warning),\n ...ifDefined('meta', result.meta),\n timings: result.timings,\n };\n\n return JSON.stringify(output, null, 2);\n}\n\n/**\n * Formats JSON output for database introspection.\n */\nexport function formatIntrospectJson(result: IntrospectSchemaResult<unknown>): string {\n return JSON.stringify(result, null, 2);\n}\n\n/**\n * Renders a schema tree structure from CoreSchemaView.\n * Status-glyph tree styling shared with the retired verification-tree renderer.\n */\nfunction renderSchemaTree(\n node: SchemaTreeNode,\n flags: GlobalFlags,\n options: {\n readonly isLast: boolean;\n readonly prefix: string;\n readonly useColor: boolean;\n readonly formatDimText: (text: string) => string;\n readonly isRoot?: boolean;\n },\n): string[] {\n const { isLast, prefix, useColor, formatDimText, isRoot = false } = options;\n const lines: string[] = [];\n\n // Format node label with color based on kind (matching schema-verify style)\n let formattedLabel: string = node.label;\n\n if (useColor) {\n switch (node.kind) {\n case 'root':\n formattedLabel = bold(node.label);\n break;\n case 'entity': {\n // Parse \"table tableName\" format - color \"table\" dim, tableName cyan\n const tableMatch = node.label.match(/^table\\s+(.+)$/);\n if (tableMatch?.[1]) {\n const tableName = tableMatch[1];\n formattedLabel = `${dim('table')} ${cyan(tableName)}`;\n } else {\n // Fallback: color entire label with cyan\n formattedLabel = cyan(node.label);\n }\n break;\n }\n case 'collection': {\n // \"columns\" grouping node - dim the label\n formattedLabel = dim(node.label);\n break;\n }\n case 'field': {\n // Parse column name format: \"columnName: typeDisplay (nullability)\"\n // Color code: column name (cyan), type (default), nullability (dim)\n const columnMatch = node.label.match(/^([^:]+):\\s*(.+)$/);\n if (columnMatch?.[1] && columnMatch[2]) {\n const columnName = columnMatch[1];\n const rest = columnMatch[2];\n // Parse rest: \"typeDisplay (nullability)\"\n const typeMatch = rest.match(/^([^\\s(]+)\\s*(\\([^)]+\\))$/);\n if (typeMatch?.[1] && typeMatch[2]) {\n const typeDisplay = typeMatch[1];\n const nullability = typeMatch[2];\n formattedLabel = `${cyan(columnName)}: ${typeDisplay} ${dim(nullability)}`;\n } else {\n // Fallback if format doesn't match\n formattedLabel = `${cyan(columnName)}: ${rest}`;\n }\n } else {\n formattedLabel = node.label;\n }\n break;\n }\n case 'index': {\n // Parse index/unique constraint/primary key formats\n // \"primary key: columnName\" -> dim \"primary key\", cyan columnName\n const pkMatch = node.label.match(/^primary key:\\s*(.+)$/);\n if (pkMatch?.[1]) {\n const columnNames = pkMatch[1];\n formattedLabel = `${dim('primary key')}: ${cyan(columnNames)}`;\n } else {\n // \"unique name\" -> dim \"unique\", cyan \"name\"\n const uniqueMatch = node.label.match(/^unique\\s+(.+)$/);\n if (uniqueMatch?.[1]) {\n const name = uniqueMatch[1];\n formattedLabel = `${dim('unique')} ${cyan(name)}`;\n } else {\n // \"index name\" or \"unique index name\" -> dim label prefix, cyan name\n const indexMatch = node.label.match(/^(unique\\s+)?index\\s+(.+)$/);\n if (indexMatch?.[2]) {\n const indexPrefix = indexMatch[1] ? `${dim('unique')} ` : '';\n const name = indexMatch[2];\n formattedLabel = `${indexPrefix}${dim('index')} ${cyan(name)}`;\n } else {\n formattedLabel = dim(node.label);\n }\n }\n }\n break;\n }\n case 'dependency': {\n // Parse extension message formats similar to schema-verify\n // \"extensionName extension is enabled\" -> cyan extensionName, dim rest\n const extMatch = node.label.match(/^([^\\s]+)\\s+(extension is enabled)$/);\n if (extMatch?.[1] && extMatch[2]) {\n const extName = extMatch[1];\n const rest = extMatch[2];\n formattedLabel = `${cyan(extName)} ${dim(rest)}`;\n } else {\n // Fallback: color entire label with magenta\n formattedLabel = magenta(node.label);\n }\n break;\n }\n default:\n formattedLabel = node.label;\n break;\n }\n }\n\n // Root node renders without tree characters or prefix\n if (isRoot) {\n lines.push(formattedLabel);\n } else {\n const treeChar = isLast ? '└' : '├';\n const treePrefix = `${formatDimText(treeChar)}─ `;\n lines.push(`${prefix}${treePrefix}${formattedLabel}`);\n }\n\n // Render children if present\n if (node.children && node.children.length > 0) {\n const childPrefix = isRoot ? '' : `${prefix}${isLast ? ' ' : `${formatDimText('│')} `}`;\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n if (!child) continue;\n const isLastChild = i === node.children.length - 1;\n const childLines = renderSchemaTree(child, flags, {\n isLast: isLastChild,\n prefix: childPrefix,\n useColor,\n formatDimText,\n isRoot: false,\n });\n lines.push(...childLines);\n }\n }\n\n return lines;\n}\n\n/**\n * Formats human-readable output for database introspection.\n */\nexport function formatIntrospectOutput(\n result: IntrospectSchemaResult<unknown>,\n schemaView: CoreSchemaView | undefined,\n flags: GlobalFlags,\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (schemaView) {\n // Render tree structure - root node is special (no tree characters)\n const treeLines = renderSchemaTree(schemaView.root, flags, {\n isLast: true,\n prefix: '',\n useColor,\n formatDimText,\n isRoot: true,\n });\n lines.push(...treeLines);\n } else {\n // Fallback: print summary when toSchemaView is not available\n lines.push(`✔ ${result.summary}`);\n if (isVerbose(flags, 1)) {\n lines.push(` Target: ${result.target.familyId}/${result.target.id}`);\n if (result.meta?.dbUrl) {\n lines.push(` Database: ${result.meta.dbUrl}`);\n }\n }\n }\n\n // Add timings in verbose mode\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats human-readable output for database schema verification.\n */\nexport function formatSchemaVerifyOutput(\n result: VerifyDatabaseSchemaResult,\n flags: GlobalFlags,\n unclaimed: readonly string[] = [],\n): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatRed = createColorFormatter(useColor, red);\n const formatYellow = createColorFormatter(useColor, yellow);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n const issueMessages = result.schema.issues.map(formatIssueMessage);\n if (issueMessages.length > 0) {\n lines.push(formatRed('Schema issues:'));\n for (const message of issueMessages) {\n lines.push(` ${formatRed('✖')} ${message}`);\n }\n }\n\n const warningMessages = (result.schema.warnings?.issues ?? []).map(formatIssueMessage);\n if (warningMessages.length > 0) {\n if (lines.length > 0) lines.push('');\n lines.push(formatYellow('Schema warnings:'));\n for (const message of warningMessages) {\n lines.push(` ${formatYellow('⚠')} ${message}`);\n }\n }\n\n if (unclaimed.length > 0) {\n const strict = result.meta?.strict ?? false;\n if (lines.length > 0) lines.push('');\n lines.push(\n (strict ? formatRed : formatYellow)('Unclaimed elements (declared by no contract):'),\n );\n for (const name of unclaimed) {\n lines.push(` ${(strict ? formatRed : formatYellow)(strict ? '✖' : '⚠')} ${name}`);\n }\n }\n\n if (isVerbose(flags, 1)) {\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n\n // Blank line before summary\n if (lines.length > 0) lines.push('');\n\n // Summary line at the end: verdict with status glyph\n if (result.ok) {\n lines.push(`${formatGreen('✔')} ${result.summary}`);\n } else {\n const codeText = result.code ? ` (${result.code})` : '';\n lines.push(`${formatRed('✖')} ${result.summary}${codeText}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database schema verification. The unclaimed-elements\n * list is a top-level field alongside the combined result, reported once for\n * the whole database.\n */\nexport function formatSchemaVerifyJson(\n result: VerifyDatabaseSchemaResult,\n unclaimed: readonly string[] = [],\n): string {\n return JSON.stringify({ ...result, unclaimed }, null, 2);\n}\n\n// ============================================================================\n// Sign Output Formatters\n// ============================================================================\n\n/**\n * Formats human-readable output for database sign.\n */\nexport function formatSignOutput(result: SignDatabaseResult, flags: GlobalFlags): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n const useColor = flags.color !== false;\n const formatGreen = createColorFormatter(useColor, green);\n const formatDimText = (text: string) => formatDim(useColor, text);\n\n if (result.ok) {\n // Main success message in white (not dimmed)\n lines.push(`${formatGreen('✔')} Database signed`);\n\n // Show from -> to hashes with clear labels\n const previousHash = result.marker.previous?.storageHash ?? 'none';\n const currentHash = result.contract.storageHash;\n\n lines.push(`${formatDimText(` from: ${previousHash}`)}`);\n lines.push(`${formatDimText(` to: ${currentHash}`)}`);\n\n if (isVerbose(flags, 1)) {\n if (result.contract.profileHash) {\n lines.push(`${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);\n }\n if (result.marker.previous?.profileHash) {\n lines.push(\n `${formatDimText(` previous profileHash: ${result.marker.previous.profileHash}`)}`,\n );\n }\n lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for database sign.\n */\nexport function formatSignJson(result: SignDatabaseResult): string {\n return JSON.stringify(result, null, 2);\n}\n"],"mappings":";;;;;;AAiBA,MAAM,gBAA0D;CAC9D,aAAa;CACb,gBAAgB;CAChB,aAAa;AACf;;;;;;;AAQA,SAAS,mBAAmB,OAAgC;CAC1D,OAAO,GAAG,cAAc,aAAa,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK,GAAG;AACtE;;;;AA+CA,SAAgB,mBACd,QACA,OACQ;CACR,IAAI,MAAM,OACR,OAAO;CAGT,MAAM,QAAkB,CAA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,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/cli",
3
- "version": "0.16.0-dev.5",
3
+ "version": "0.16.0-dev.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,18 +9,18 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@clack/prompts": "^1.7.0",
12
- "@prisma-next/config": "0.16.0-dev.5",
13
- "@prisma-next/config-loader": "0.16.0-dev.5",
14
- "@prisma-next/contract": "0.16.0-dev.5",
15
- "@prisma-next/emitter": "0.16.0-dev.5",
16
- "@prisma-next/errors": "0.16.0-dev.5",
17
- "@prisma-next/framework-components": "0.16.0-dev.5",
18
- "@prisma-next/language-server": "0.16.0-dev.5",
19
- "@prisma-next/migration-tools": "0.16.0-dev.5",
20
- "@prisma-next/psl-parser": "0.16.0-dev.5",
21
- "@prisma-next/psl-printer": "0.16.0-dev.5",
22
- "@prisma-next/cli-telemetry": "0.16.0-dev.5",
23
- "@prisma-next/utils": "0.16.0-dev.5",
12
+ "@prisma-next/config": "0.16.0-dev.6",
13
+ "@prisma-next/config-loader": "0.16.0-dev.6",
14
+ "@prisma-next/contract": "0.16.0-dev.6",
15
+ "@prisma-next/emitter": "0.16.0-dev.6",
16
+ "@prisma-next/errors": "0.16.0-dev.6",
17
+ "@prisma-next/framework-components": "0.16.0-dev.6",
18
+ "@prisma-next/language-server": "0.16.0-dev.6",
19
+ "@prisma-next/migration-tools": "0.16.0-dev.6",
20
+ "@prisma-next/psl-parser": "0.16.0-dev.6",
21
+ "@prisma-next/psl-printer": "0.16.0-dev.6",
22
+ "@prisma-next/cli-telemetry": "0.16.0-dev.6",
23
+ "@prisma-next/utils": "0.16.0-dev.6",
24
24
  "arktype": "^2.2.2",
25
25
  "ci-info": "^4.3.1",
26
26
  "clipanion": "4.0.0-rc.4",
@@ -36,14 +36,14 @@
36
36
  "wrap-ansi": "^10.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@prisma-next/sql-contract": "0.16.0-dev.5",
40
- "@prisma-next/sql-contract-emitter": "0.16.0-dev.5",
41
- "@prisma-next/sql-contract-ts": "0.16.0-dev.5",
42
- "@prisma-next/sql-operations": "0.16.0-dev.5",
43
- "@prisma-next/sql-runtime": "0.16.0-dev.5",
44
- "@prisma-next/test-utils": "0.16.0-dev.5",
45
- "@prisma-next/tsconfig": "0.16.0-dev.5",
46
- "@prisma-next/tsdown": "0.16.0-dev.5",
39
+ "@prisma-next/sql-contract": "0.16.0-dev.6",
40
+ "@prisma-next/sql-contract-emitter": "0.16.0-dev.6",
41
+ "@prisma-next/sql-contract-ts": "0.16.0-dev.6",
42
+ "@prisma-next/sql-operations": "0.16.0-dev.6",
43
+ "@prisma-next/sql-runtime": "0.16.0-dev.6",
44
+ "@prisma-next/test-utils": "0.16.0-dev.6",
45
+ "@prisma-next/tsconfig": "0.16.0-dev.6",
46
+ "@prisma-next/tsdown": "0.16.0-dev.6",
47
47
  "@types/node": "25.9.4",
48
48
  "tsdown": "0.22.8",
49
49
  "typescript": "5.9.3",
@@ -176,6 +176,7 @@ async function executeDbInitCommand(
176
176
  ...ifDefined('advanceRef', options.advanceRef),
177
177
  ...ifDefined('db', options.db),
178
178
  refsDir,
179
+ migrationsDir,
179
180
  contractIR,
180
181
  mode: result.value.mode,
181
182
  hash: advancementHash,
@@ -200,6 +200,7 @@ async function executeDbUpdateCommand(
200
200
  ...ifDefined('advanceRef', options.advanceRef),
201
201
  ...ifDefined('db', options.db),
202
202
  refsDir,
203
+ migrationsDir,
203
204
  contractIR,
204
205
  mode: result.value.mode,
205
206
  hash: advancementHash,
@@ -831,6 +831,7 @@ async function executeMigrateCommand(
831
831
  : await readContractIR(snapshotContractJson, contractPathAbsolute);
832
832
  advancedRef = await executeRefAdvancement(
833
833
  refsDir,
834
+ migrationsDir,
834
835
  options.advanceRef,
835
836
  value.markerHash,
836
837
  contractIR,
@@ -331,7 +331,7 @@ async function executeMigrationPlanCommand(
331
331
  fromHash = resolutionResult.value.fromHash;
332
332
  fromContract = resolutionResult.value.fromContract;
333
333
  break;
334
- case 'snapshot':
334
+ case 'ref':
335
335
  fromHash = resolutionResult.value.fromHash;
336
336
  fromContract = resolutionResult.value.fromContract;
337
337
  snapshotStartContract = {
@@ -9,11 +9,11 @@ import { findLatestMigration, isGraphNode } from '@prisma-next/migration-tools/m
9
9
  import { parseContractRef } from '@prisma-next/migration-tools/ref-resolution';
10
10
  import type { RefEntry } from '@prisma-next/migration-tools/refs';
11
11
  import {
12
- deleteRefPaired,
12
+ deleteRef,
13
13
  readRefs,
14
14
  validateRefName,
15
15
  validateRefValue,
16
- writeRefPaired,
16
+ writeRef,
17
17
  } from '@prisma-next/migration-tools/refs';
18
18
  import { notOk, ok, type Result } from '@prisma-next/utils/result';
19
19
  import { Command } from 'commander';
@@ -37,7 +37,6 @@ import {
37
37
  import { buildReadAggregate } from '../utils/contract-space-aggregate-loader';
38
38
  import { formatCommandHelp } from '../utils/formatters/help';
39
39
  import { parseGlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';
40
- import { readContractIR } from '../utils/ref-advancement';
41
40
  import { handleResult } from '../utils/result-handler';
42
41
  import { createTerminalUI } from '../utils/terminal-ui';
43
42
 
@@ -121,12 +120,8 @@ export async function executeRefSetCommand(
121
120
  contractSnapshotDir(migrationsDir, resolvedHash),
122
121
  'contract.json',
123
122
  );
124
- let contractJson: Record<string, unknown>;
125
123
  try {
126
- contractJson = (await readContractSnapshotJson(migrationsDir, resolvedHash)) as Record<
127
- string,
128
- unknown
129
- >;
124
+ await readContractSnapshotJson(migrationsDir, resolvedHash);
130
125
  } catch (readError) {
131
126
  if (
132
127
  MigrationToolsError.is(readError) &&
@@ -142,9 +137,8 @@ export async function executeRefSetCommand(
142
137
  throw readError;
143
138
  }
144
139
 
145
- const contractIR = await readContractIR(contractJson, contractJsonPath);
146
140
  const entry: RefEntry = { hash: resolvedHash, invariants: [] };
147
- await writeRefPaired(refsDir, name, entry, contractIR);
141
+ await writeRef(refsDir, name, entry);
148
142
  return ok({ ok: true as const, ref: name, hash: resolvedHash, invariants: [] });
149
143
  } catch (error) {
150
144
  if (error instanceof CliStructuredError) return notOk(error);
@@ -159,7 +153,7 @@ export async function executeRefDeleteCommand(
159
153
  try {
160
154
  const config = await loadConfig(options.config);
161
155
  const { refsDir } = resolveMigrationPaths(options.config, config);
162
- await deleteRefPaired(refsDir, name);
156
+ await deleteRef(refsDir, name);
163
157
  return ok({ ok: true as const, ref: name, deleted: true as const });
164
158
  } catch (error) {
165
159
  if (error instanceof CliStructuredError) return notOk(error);
@@ -215,22 +215,30 @@ export function errorPlanForgotTheFlag(
215
215
  });
216
216
  }
217
217
 
218
+ /**
219
+ * `viaRef: true` (the default) mirrors migration-tools' `errorRefNotResolvable`:
220
+ * a ref name with no pointer file, where the fallback hash isn't a graph
221
+ * node either — there's nothing to materialize a contract from.
222
+ * `viaRef: false` is a distinct, ref-independent case: an explicit `--from
223
+ * <hash>` that doesn't name a ref, on an empty migration graph, so there is
224
+ * no graph node and no ref to resolve a contract through.
225
+ */
218
226
  export function errorSnapshotMissing(
219
227
  identifier: string,
220
228
  options?: { readonly viaRef?: boolean },
221
229
  ): CliStructuredError {
222
230
  const viaRef = options?.viaRef !== false;
223
231
  const fix = viaRef
224
- ? `Run "prisma-next db update --advance-ref ${identifier}" to repopulate the snapshot, or "prisma-next ref delete ${identifier}" to clear the orphan pointer.`
225
- : `No contract source exists for hash "${identifier}" on an empty migration graph. Use --from with a ref name that has a paired snapshot, or run db update first.`;
232
+ ? `Create the ref with "prisma-next ref set ${identifier} <hash>" (or advance it via "prisma-next db update --advance-ref ${identifier}"), or pass a hash that is a node in the migration graph.`
233
+ : `No contract source exists for hash "${identifier}" on an empty migration graph. Use --from with a ref name (its contract resolves through the snapshot store), or run db update first.`;
226
234
  return errorRuntime(
227
235
  viaRef
228
- ? `Ref "${identifier}" has no paired contract snapshot`
236
+ ? `Ref "${identifier}" is not resolvable`
229
237
  : `No contract source for from-hash "${identifier}"`,
230
238
  {
231
239
  why: viaRef
232
- ? `Ref "${identifier}" exists but its paired snapshot files are missing.`
233
- : `Hash "${identifier}" is not a graph node and no paired ref snapshot supplies a contract.`,
240
+ ? `Ref "${identifier}" has no pointer file, and the hash being resolved is not a node in the migration graph either.`
241
+ : `Hash "${identifier}" is not a node in the migration graph (the graph is empty), and it does not name a ref either.`,
234
242
  fix,
235
243
  meta: {
236
244
  code: 'MIGRATION.SNAPSHOT_MISSING',
@@ -15,7 +15,7 @@ export function mapContractAtError(
15
15
  ): Result<never, CliStructuredError> {
16
16
  if (MigrationToolsError.is(error)) {
17
17
  switch (error.code) {
18
- case 'MIGRATION.SNAPSHOT_MISSING': {
18
+ case 'MIGRATION.REF_NOT_RESOLVABLE': {
19
19
  const refName =
20
20
  typeof error.details?.['refName'] === 'string'
21
21
  ? error.details['refName']
@@ -26,18 +26,13 @@ export function mapContractAtError(
26
26
  }
27
27
  case 'MIGRATION.CONTRACT_DESERIALIZATION_FAILED': {
28
28
  const filePath =
29
- typeof error.details?.['filePath'] === 'string'
30
- ? error.details['filePath']
31
- : 'ref-snapshot';
29
+ typeof error.details?.['filePath'] === 'string' ? error.details['filePath'] : 'unknown';
32
30
  const message =
33
31
  typeof error.details?.['message'] === 'string' ? error.details['message'] : error.message;
34
- const isRefSnapshot = filePath.endsWith('.contract.json');
35
32
  return notOk(
36
33
  errorContractValidationFailed(
37
- isRefSnapshot
38
- ? `Ref snapshot contract failed to deserialize: ${message}`
39
- : `Predecessor contract at ${filePath} failed to deserialize: ${message}`,
40
- { where: { path: isRefSnapshot ? 'ref-snapshot' : filePath } },
34
+ `Predecessor contract at ${filePath} failed to deserialize: ${message}`,
35
+ { where: { path: filePath } },
41
36
  ),
42
37
  );
43
38
  }
@@ -29,7 +29,7 @@ export type FromResolution =
29
29
  | { kind: 'greenfield'; fromHash: null; fromContract: null }
30
30
  | { kind: 'graph-node'; fromHash: string; fromContract: Contract }
31
31
  | {
32
- kind: 'snapshot';
32
+ kind: 'ref';
33
33
  fromHash: string;
34
34
  fromContract: Contract;
35
35
  contractDts: string;
@@ -81,7 +81,7 @@ export function assertFromIsGraphNode(
81
81
 
82
82
  type RefContractResolution =
83
83
  | {
84
- kind: 'snapshot';
84
+ kind: 'ref';
85
85
  hash: string;
86
86
  contract: Contract;
87
87
  contractJson: unknown;
@@ -106,9 +106,9 @@ async function resolveContractRef(
106
106
  try {
107
107
  const at = await space.contractAt(hash, refName !== undefined ? { refName } : undefined);
108
108
 
109
- if (at.provenance === 'snapshot') {
109
+ if (at.provenance === 'ref') {
110
110
  return ok({
111
- kind: 'snapshot',
111
+ kind: 'ref',
112
112
  hash: at.hash,
113
113
  contract: at.contract,
114
114
  contractJson: at.contractJson,
@@ -175,7 +175,7 @@ async function resolveFromPolicy(
175
175
  throw error;
176
176
  }
177
177
  return ok({
178
- kind: 'snapshot',
178
+ kind: 'ref',
179
179
  fromHash: hash,
180
180
  fromContract: contract,
181
181
  contractDts,
@@ -1,8 +1,14 @@
1
1
  import { readFile } from 'node:fs/promises';
2
- import type { ContractIR } from '@prisma-next/migration-tools/refs';
3
- import { writeRefPaired } from '@prisma-next/migration-tools/refs';
2
+ import { writeContractSnapshot } from '@prisma-next/migration-tools/contract-snapshot-store';
3
+ import { errorInvalidRefName } from '@prisma-next/migration-tools/errors';
4
+ import { validateRefName, writeRef } from '@prisma-next/migration-tools/refs';
4
5
  import { ifDefined } from '@prisma-next/utils/defined';
5
6
 
7
+ export interface ContractIR {
8
+ readonly contract: unknown;
9
+ readonly contractDts: string;
10
+ }
11
+
6
12
  export interface RefAdvancementFields {
7
13
  readonly advancedRef: { readonly name: string; readonly hash: string } | null;
8
14
  readonly plannedAdvanceRef: { readonly name: string; readonly hash: string } | null;
@@ -32,11 +38,22 @@ export async function readContractIR(
32
38
 
33
39
  export async function executeRefAdvancement(
34
40
  refsDir: string,
41
+ migrationsDir: string,
35
42
  name: string,
36
43
  hash: string,
37
44
  contractIR: ContractIR,
38
45
  ): Promise<{ name: string; hash: string }> {
39
- await writeRefPaired(refsDir, name, { hash, invariants: [] }, contractIR);
46
+ // Validate the ref name before writing anything: writeRef validates it too,
47
+ // but only after the store write below, which would otherwise leave a
48
+ // (harmless, but pointless) orphan store entry on an invalid name.
49
+ if (!validateRefName(name)) {
50
+ throw errorInvalidRefName(name);
51
+ }
52
+ await writeContractSnapshot(migrationsDir, hash, {
53
+ contractJson: contractIR.contract,
54
+ contractDts: contractIR.contractDts,
55
+ });
56
+ await writeRef(refsDir, name, { hash, invariants: [] });
40
57
  return { name, hash };
41
58
  }
42
59
 
@@ -44,6 +61,7 @@ export async function buildRefAdvancementFields(options: {
44
61
  readonly advanceRef?: string;
45
62
  readonly db?: string;
46
63
  readonly refsDir: string;
64
+ readonly migrationsDir: string;
47
65
  readonly contractIR: ContractIR;
48
66
  readonly mode: 'plan' | 'apply';
49
67
  readonly hash: string;
@@ -60,6 +78,7 @@ export async function buildRefAdvancementFields(options: {
60
78
  }
61
79
  const advancedRef = await executeRefAdvancement(
62
80
  options.refsDir,
81
+ options.migrationsDir,
63
82
  name,
64
83
  options.hash,
65
84
  options.contractIR,