@prisma-next/cli 0.15.0-dev.9 → 0.16.0-dev.1

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 (145) hide show
  1. package/dist/cli.d.mts +1 -1
  2. package/dist/cli.mjs +13 -13
  3. package/dist/{client-BFdyYwMb.mjs → client-KuBQftxz.mjs} +67 -36
  4. package/dist/client-KuBQftxz.mjs.map +1 -0
  5. package/dist/{command-helpers-BLXps5-Y.mjs → command-helpers-Cpq44aVa.mjs} +6 -4
  6. package/dist/command-helpers-Cpq44aVa.mjs.map +1 -0
  7. package/dist/commands/contract-emit.d.mts +0 -1
  8. package/dist/commands/contract-emit.d.mts.map +1 -1
  9. package/dist/commands/contract-emit.mjs +1 -1
  10. package/dist/commands/contract-infer.d.mts +0 -1
  11. package/dist/commands/contract-infer.d.mts.map +1 -1
  12. package/dist/commands/contract-infer.mjs +1 -1
  13. package/dist/commands/db-init.d.mts +0 -1
  14. package/dist/commands/db-init.d.mts.map +1 -1
  15. package/dist/commands/db-init.mjs +6 -6
  16. package/dist/commands/db-init.mjs.map +1 -1
  17. package/dist/commands/db-schema.d.mts +0 -1
  18. package/dist/commands/db-schema.d.mts.map +1 -1
  19. package/dist/commands/db-schema.mjs +3 -3
  20. package/dist/commands/db-sign.d.mts +0 -1
  21. package/dist/commands/db-sign.d.mts.map +1 -1
  22. package/dist/commands/db-sign.mjs +4 -4
  23. package/dist/commands/db-update.d.mts +0 -1
  24. package/dist/commands/db-update.d.mts.map +1 -1
  25. package/dist/commands/db-update.mjs +5 -5
  26. package/dist/commands/db-update.mjs.map +1 -1
  27. package/dist/commands/db-verify.d.mts +0 -1
  28. package/dist/commands/db-verify.d.mts.map +1 -1
  29. package/dist/commands/db-verify.mjs +1 -1
  30. package/dist/commands/migrate.d.mts +1 -2
  31. package/dist/commands/migrate.d.mts.map +1 -1
  32. package/dist/commands/migrate.mjs +5 -5
  33. package/dist/commands/migration-check.d.mts +1 -2
  34. package/dist/commands/migration-check.d.mts.map +1 -1
  35. package/dist/commands/migration-check.mjs +1 -1
  36. package/dist/commands/migration-graph.d.mts +2 -3
  37. package/dist/commands/migration-graph.d.mts.map +1 -1
  38. package/dist/commands/migration-graph.mjs +3 -3
  39. package/dist/commands/migration-list.d.mts +2 -3
  40. package/dist/commands/migration-list.d.mts.map +1 -1
  41. package/dist/commands/migration-list.mjs +1 -1
  42. package/dist/commands/migration-log.d.mts +2 -3
  43. package/dist/commands/migration-log.d.mts.map +1 -1
  44. package/dist/commands/migration-log.mjs +1 -1
  45. package/dist/commands/migration-new.d.mts +0 -1
  46. package/dist/commands/migration-new.d.mts.map +1 -1
  47. package/dist/commands/migration-new.mjs +3 -3
  48. package/dist/commands/migration-plan.d.mts +0 -1
  49. package/dist/commands/migration-plan.d.mts.map +1 -1
  50. package/dist/commands/migration-plan.mjs +1 -1
  51. package/dist/commands/migration-show.d.mts +0 -1
  52. package/dist/commands/migration-show.d.mts.map +1 -1
  53. package/dist/commands/migration-show.mjs +3 -3
  54. package/dist/commands/migration-status.d.mts +2 -3
  55. package/dist/commands/migration-status.d.mts.map +1 -1
  56. package/dist/commands/migration-status.mjs +1 -1
  57. package/dist/commands/ref.d.mts +1 -2
  58. package/dist/commands/ref.d.mts.map +1 -1
  59. package/dist/commands/ref.mjs +2 -2
  60. package/dist/commands/telemetry/index.d.mts +0 -1
  61. package/dist/commands/telemetry/index.d.mts.map +1 -1
  62. package/dist/commands/telemetry/index.mjs +1 -1
  63. package/dist/{contract-at-errors-BWfTml7P.mjs → contract-at-errors-D9gEjYtg.mjs} +2 -2
  64. package/dist/{contract-at-errors-BWfTml7P.mjs.map → contract-at-errors-D9gEjYtg.mjs.map} +1 -1
  65. package/dist/{contract-emit-ClAoSE6t.mjs → contract-emit-CgnXSANN.mjs} +3 -3
  66. package/dist/{contract-emit-ClAoSE6t.mjs.map → contract-emit-CgnXSANN.mjs.map} +1 -1
  67. package/dist/{contract-emit-Db9tBwcF.mjs → contract-emit-cJQBlvGb.mjs} +3 -3
  68. package/dist/{contract-emit-Db9tBwcF.mjs.map → contract-emit-cJQBlvGb.mjs.map} +1 -1
  69. package/dist/{contract-infer-DIHsuFUb.mjs → contract-infer-Cg8evbeg.mjs} +3 -3
  70. package/dist/{contract-infer-DIHsuFUb.mjs.map → contract-infer-Cg8evbeg.mjs.map} +1 -1
  71. package/dist/{contract-space-aggregate-loader-BRO5pDiM.mjs → contract-space-aggregate-loader-D_3VeHVb.mjs} +14 -15
  72. package/dist/contract-space-aggregate-loader-D_3VeHVb.mjs.map +1 -0
  73. package/dist/{db-verify-C6Z2BNuC.mjs → db-verify-BEclUzki.mjs} +6 -7
  74. package/dist/db-verify-BEclUzki.mjs.map +1 -0
  75. package/dist/exports/control-api.d.mts +1 -2
  76. package/dist/exports/control-api.d.mts.map +1 -1
  77. package/dist/exports/control-api.mjs +2 -2
  78. package/dist/exports/index.d.mts +0 -1
  79. package/dist/exports/index.d.mts.map +1 -1
  80. package/dist/exports/index.mjs +2 -2
  81. package/dist/exports/init-output.d.mts +1 -0
  82. package/dist/exports/init-output.d.mts.map +1 -1
  83. package/dist/{format-CAOChHKT.mjs → format-DAUAZqPt.mjs} +2 -2
  84. package/dist/{format-CAOChHKT.mjs.map → format-DAUAZqPt.mjs.map} +1 -1
  85. package/dist/{framework-components-DoSQ6XDH.mjs → framework-components-CnbUbiJw.mjs} +2 -2
  86. package/dist/{framework-components-DoSQ6XDH.mjs.map → framework-components-CnbUbiJw.mjs.map} +1 -1
  87. package/dist/global-flags-BpoOYtNZ.d.mts.map +1 -1
  88. package/dist/{init-BeAcODLF.mjs → init-C3JhkHg-.mjs} +33 -46
  89. package/dist/init-C3JhkHg-.mjs.map +1 -0
  90. package/dist/{inspect-live-schema-CLipMm-L.mjs → inspect-live-schema-CX7EA5C3.mjs} +3 -3
  91. package/dist/{inspect-live-schema-CLipMm-L.mjs.map → inspect-live-schema-CX7EA5C3.mjs.map} +1 -1
  92. package/dist/{migration-check-Bnb8M0xV.mjs → migration-check-MHT3w7_v.mjs} +24 -24
  93. package/dist/migration-check-MHT3w7_v.mjs.map +1 -0
  94. package/dist/migration-cli.d.mts +0 -1
  95. package/dist/migration-cli.d.mts.map +1 -1
  96. package/dist/migration-cli.mjs +3 -3
  97. package/dist/migration-cli.mjs.map +1 -1
  98. package/dist/{migration-command-scaffold-CWH2o2kb.mjs → migration-command-scaffold-CRyYrHZ9.mjs} +3 -3
  99. package/dist/{migration-command-scaffold-CWH2o2kb.mjs.map → migration-command-scaffold-CRyYrHZ9.mjs.map} +1 -1
  100. package/dist/{migration-list-DoIt-BxI.mjs → migration-list-BAKujUjh.mjs} +3 -3
  101. package/dist/{migration-list-DoIt-BxI.mjs.map → migration-list-BAKujUjh.mjs.map} +1 -1
  102. package/dist/{migration-log-BLqx4ZZh.mjs → migration-log-C_xam2HZ.mjs} +3 -3
  103. package/dist/{migration-log-BLqx4ZZh.mjs.map → migration-log-C_xam2HZ.mjs.map} +1 -1
  104. package/dist/{migration-path-target-CD6weEBq.mjs → migration-path-target-DpPTsRCg.mjs} +2 -2
  105. package/dist/{migration-path-target-CD6weEBq.mjs.map → migration-path-target-DpPTsRCg.mjs.map} +1 -1
  106. package/dist/{migration-plan-B4jtO5HI.mjs → migration-plan-CreSVtWZ.mjs} +6 -6
  107. package/dist/migration-plan-CreSVtWZ.mjs.map +1 -0
  108. package/dist/{migration-status-B10JDiAZ.mjs → migration-status-YgEvXf-u.mjs} +5 -5
  109. package/dist/{migration-status-B10JDiAZ.mjs.map → migration-status-YgEvXf-u.mjs.map} +1 -1
  110. package/dist/schemas-CeGMYFYX.d.mts.map +1 -1
  111. package/dist/{telemetry-DSRq37Fo.mjs → telemetry-DVr6RFnq.mjs} +2 -2
  112. package/dist/{telemetry-DSRq37Fo.mjs.map → telemetry-DVr6RFnq.mjs.map} +1 -1
  113. package/dist/{terminal-ui-DGRNFWna.d.mts → terminal-ui-BN4QOsm5.d.mts} +1 -2
  114. package/dist/terminal-ui-BN4QOsm5.d.mts.map +1 -0
  115. package/dist/{types-DFoqNIcQ.d.mts → types-D4r_HI9-.d.mts} +8 -4
  116. package/dist/types-D4r_HI9-.d.mts.map +1 -0
  117. package/dist/{verify-DL7cUiLL.mjs → verify-CgDVZjhc.mjs} +2 -2
  118. package/dist/{verify-DL7cUiLL.mjs.map → verify-CgDVZjhc.mjs.map} +1 -1
  119. package/package.json +25 -25
  120. package/src/commands/db-init.ts +3 -3
  121. package/src/commands/db-update.ts +1 -1
  122. package/src/commands/db-verify.ts +2 -3
  123. package/src/commands/init/errors.ts +62 -58
  124. package/src/commands/init/init.ts +29 -26
  125. package/src/commands/migration-check.ts +7 -7
  126. package/src/commands/migration-plan.ts +1 -1
  127. package/src/control-api/operations/db-run.ts +4 -4
  128. package/src/control-api/operations/db-verify.ts +12 -9
  129. package/src/control-api/operations/migrate.ts +70 -26
  130. package/src/control-api/types.ts +4 -1
  131. package/src/migration-cli.ts +5 -5
  132. package/src/utils/cli-errors.ts +15 -2
  133. package/src/utils/combine-verify-results.ts +1 -1
  134. package/src/utils/contract-space-aggregate-loader.ts +12 -13
  135. package/src/utils/integrity-violation-to-check-failure.ts +14 -14
  136. package/src/utils/result-handler.ts +4 -2
  137. package/dist/client-BFdyYwMb.mjs.map +0 -1
  138. package/dist/command-helpers-BLXps5-Y.mjs.map +0 -1
  139. package/dist/contract-space-aggregate-loader-BRO5pDiM.mjs.map +0 -1
  140. package/dist/db-verify-C6Z2BNuC.mjs.map +0 -1
  141. package/dist/init-BeAcODLF.mjs.map +0 -1
  142. package/dist/migration-check-Bnb8M0xV.mjs.map +0 -1
  143. package/dist/migration-plan-B4jtO5HI.mjs.map +0 -1
  144. package/dist/terminal-ui-DGRNFWna.d.mts.map +0 -1
  145. package/dist/types-DFoqNIcQ.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"format-CAOChHKT.mjs","names":[],"sources":["../src/control-api/operations/format.ts","../src/commands/format.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { EOL } from 'node:os';\nimport { loadConfig } from '@prisma-next/config-loader';\nimport { type FormatOptions, format, PslFormatError } from '@prisma-next/psl-parser/format';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../../utils/cli-errors';\n\nexport interface FormatOperationOptions {\n readonly configPath?: string;\n readonly eol?: string;\n}\n\nexport interface FormatOperationResult {\n readonly formatted: boolean;\n readonly path?: string;\n}\n\nexport function resolveNewline(\n formatterNewline: 'LF' | 'CRLF' | undefined,\n eol: string,\n): 'LF' | 'CRLF' {\n if (formatterNewline !== undefined) {\n return formatterNewline;\n }\n return eol === '\\r\\n' ? 'CRLF' : 'LF';\n}\n\nexport async function executeFormat(\n options: FormatOperationOptions,\n): Promise<Result<FormatOperationResult, CliStructuredError>> {\n const eol = options.eol ?? EOL;\n\n let config: Awaited<ReturnType<typeof loadConfig>>;\n try {\n config = await loadConfig(options.configPath);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n const source = config.contract?.source;\n if (source?.sourceFormat !== 'psl') {\n return ok({ formatted: false });\n }\n\n const inputPath = source.inputs?.[0];\n if (inputPath === undefined) {\n return ok({ formatted: false });\n }\n\n let contents: string;\n try {\n contents = await readFile(inputPath, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to read contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} exists and is readable.`,\n }),\n );\n }\n\n const formatOptions: FormatOptions = {\n indent: config.formatter?.indent ?? 2,\n newline: resolveNewline(config.formatter?.newline, eol),\n };\n\n let formatted: string;\n try {\n formatted = format(contents, formatOptions);\n } catch (error) {\n if (error instanceof PslFormatError) {\n return notOk(\n errorRuntime('Cannot format PSL with parse errors', {\n why: error.message,\n fix: 'Fix the parse errors in your schema and try again.',\n meta: { diagnostics: error.diagnostics },\n }),\n );\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n try {\n await writeFile(inputPath, formatted, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to write formatted contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} is writable.`,\n }),\n );\n }\n\n return ok({ formatted: true, path: inputPath });\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\nimport { Command } from 'commander';\nimport { relative, resolve } from 'pathe';\nimport { executeFormat } from '../control-api/operations/format';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI } from '../utils/terminal-ui';\n\ninterface FormatCommandOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport function createFormatCommand(): Command {\n const command = new Command('format');\n setCommandDescriptions(\n command,\n 'Format your PSL contract source',\n 'Formats the Prisma schema (PSL) contract source declared in your config\\n' +\n '(contract.source.inputs[0]) in place. Only runs when contract.source.sourceFormat\\n' +\n \"is 'psl'; a TypeScript or unset source is left untouched. Indent and newline are\\n\" +\n 'read from the optional formatter config section, defaulting to two spaces and the\\n' +\n 'system newline.',\n );\n setCommandExamples(command, [\n 'prisma-next format',\n 'prisma-next format --config ./custom-config.ts',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: FormatCommandOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n\n if (!flags.json && !flags.quiet) {\n const displayConfigPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n ui.stderr(\n formatStyledHeader({\n command: 'format',\n description: 'Format your PSL contract source',\n details: [{ label: 'config', value: displayConfigPath }],\n flags,\n }),\n );\n }\n\n const result = await executeFormat({ ...ifDefined('configPath', options.config) });\n\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n return;\n }\n if (flags.quiet) {\n return;\n }\n if (value.formatted) {\n ui.success(`Formatted ${relative(process.cwd(), value.path ?? '')}`);\n } else {\n ui.info('Nothing to format (contract source is not PSL).');\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,eACd,kBACA,KACe;CACf,IAAI,qBAAqB,KAAA,GACvB,OAAO;CAET,OAAO,QAAQ,SAAS,SAAS;AACnC;AAEA,eAAsB,cACpB,SAC4D;CAC5D,MAAM,MAAM,QAAQ,OAAO;CAE3B,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,WAAW,QAAQ,UAAU;CAC9C,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAC7B,OAAO,MAAM,KAAK;EAEpB,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,CAAC;CACtF;CAEA,MAAM,SAAS,OAAO,UAAU;CAChC,IAAI,QAAQ,iBAAiB,OAC3B,OAAO,GAAG,EAAE,WAAW,MAAM,CAAC;CAGhC,MAAM,YAAY,OAAO,SAAS;CAClC,IAAI,cAAc,KAAA,GAChB,OAAO,GAAG,EAAE,WAAW,MAAM,CAAC;CAGhC,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,SAAS,WAAW,OAAO;CAC9C,SAAS,OAAO;EACd,OAAO,MACL,aAAa,uCAAuC;GAClD,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAC1D,KAAK,cAAc,UAAU;EAC/B,CAAC,CACH;CACF;CAEA,MAAM,gBAA+B;EACnC,QAAQ,OAAO,WAAW,UAAU;EACpC,SAAS,eAAe,OAAO,WAAW,SAAS,GAAG;CACxD;CAEA,IAAI;CACJ,IAAI;EACF,YAAY,OAAO,UAAU,aAAa;CAC5C,SAAS,OAAO;EACd,IAAI,iBAAiB,gBACnB,OAAO,MACL,aAAa,uCAAuC;GAClD,KAAK,MAAM;GACX,KAAK;GACL,MAAM,EAAE,aAAa,MAAM,YAAY;EACzC,CAAC,CACH;EAEF,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,CAAC;CACtF;CAEA,IAAI;EACF,MAAM,UAAU,WAAW,WAAW,OAAO;CAC/C,SAAS,OAAO;EACd,OAAO,MACL,aAAa,kDAAkD;GAC7D,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAC1D,KAAK,cAAc,UAAU;EAC/B,CAAC,CACH;CACF;CAEA,OAAO,GAAG;EAAE,WAAW;EAAM,MAAM;CAAU,CAAC;AAChD;;;AC9EA,SAAgB,sBAA+B;CAC7C,MAAM,UAAU,IAAI,QAAQ,QAAQ;CACpC,uBACE,SACA,mCACA,kVAKF;CACA,mBAAmB,SAAS,CAC1B,sBACA,gDACF,CAAC;CACD,iBAAiB,OAAO,CAAC,CACtB,OAAO,mBAAmB,+BAA+B,CAAC,CAC1D,OAAO,OAAO,YAAkC;EAC/C,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EAEjC,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;GAC/B,MAAM,oBAAoB,QAAQ,SAC9B,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAC/C;GACJ,GAAG,OACD,mBAAmB;IACjB,SAAS;IACT,aAAa;IACb,SAAS,CAAC;KAAE,OAAO;KAAU,OAAO;IAAkB,CAAC;IACvD;GACF,CAAC,CACH;EACF;EAIA,MAAM,WAAW,aAAa,MAFT,cAAc,EAAE,GAAG,UAAU,cAAc,QAAQ,MAAM,EAAE,CAAC,GAE3C,OAAO,KAAK,UAAU;GAC1D,IAAI,MAAM,MAAM;IACd,GAAG,OAAO,KAAK,UAAU,KAAK,CAAC;IAC/B;GACF;GACA,IAAI,MAAM,OACR;GAEF,IAAI,MAAM,WACR,GAAG,QAAQ,aAAa,SAAS,QAAQ,IAAI,GAAG,MAAM,QAAQ,EAAE,GAAG;QAEnE,GAAG,KAAK,iDAAiD;EAE7D,CAAC;EACD,QAAQ,KAAK,QAAQ;CACvB,CAAC;CAEH,OAAO;AACT"}
1
+ {"version":3,"file":"format-DAUAZqPt.mjs","names":[],"sources":["../src/control-api/operations/format.ts","../src/commands/format.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { EOL } from 'node:os';\nimport { loadConfig } from '@prisma-next/config-loader';\nimport { type FormatOptions, format, PslFormatError } from '@prisma-next/psl-parser/format';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../../utils/cli-errors';\n\nexport interface FormatOperationOptions {\n readonly configPath?: string;\n readonly eol?: string;\n}\n\nexport interface FormatOperationResult {\n readonly formatted: boolean;\n readonly path?: string;\n}\n\nexport function resolveNewline(\n formatterNewline: 'LF' | 'CRLF' | undefined,\n eol: string,\n): 'LF' | 'CRLF' {\n if (formatterNewline !== undefined) {\n return formatterNewline;\n }\n return eol === '\\r\\n' ? 'CRLF' : 'LF';\n}\n\nexport async function executeFormat(\n options: FormatOperationOptions,\n): Promise<Result<FormatOperationResult, CliStructuredError>> {\n const eol = options.eol ?? EOL;\n\n let config: Awaited<ReturnType<typeof loadConfig>>;\n try {\n config = await loadConfig(options.configPath);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n const source = config.contract?.source;\n if (source?.sourceFormat !== 'psl') {\n return ok({ formatted: false });\n }\n\n const inputPath = source.inputs?.[0];\n if (inputPath === undefined) {\n return ok({ formatted: false });\n }\n\n let contents: string;\n try {\n contents = await readFile(inputPath, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to read contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} exists and is readable.`,\n }),\n );\n }\n\n const formatOptions: FormatOptions = {\n indent: config.formatter?.indent ?? 2,\n newline: resolveNewline(config.formatter?.newline, eol),\n };\n\n let formatted: string;\n try {\n formatted = format(contents, formatOptions);\n } catch (error) {\n if (error instanceof PslFormatError) {\n return notOk(\n errorRuntime('Cannot format PSL with parse errors', {\n why: error.message,\n fix: 'Fix the parse errors in your schema and try again.',\n meta: { diagnostics: error.diagnostics },\n }),\n );\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n try {\n await writeFile(inputPath, formatted, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to write formatted contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} is writable.`,\n }),\n );\n }\n\n return ok({ formatted: true, path: inputPath });\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\nimport { Command } from 'commander';\nimport { relative, resolve } from 'pathe';\nimport { executeFormat } from '../control-api/operations/format';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI } from '../utils/terminal-ui';\n\ninterface FormatCommandOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport function createFormatCommand(): Command {\n const command = new Command('format');\n setCommandDescriptions(\n command,\n 'Format your PSL contract source',\n 'Formats the Prisma schema (PSL) contract source declared in your config\\n' +\n '(contract.source.inputs[0]) in place. Only runs when contract.source.sourceFormat\\n' +\n \"is 'psl'; a TypeScript or unset source is left untouched. Indent and newline are\\n\" +\n 'read from the optional formatter config section, defaulting to two spaces and the\\n' +\n 'system newline.',\n );\n setCommandExamples(command, [\n 'prisma-next format',\n 'prisma-next format --config ./custom-config.ts',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: FormatCommandOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n\n if (!flags.json && !flags.quiet) {\n const displayConfigPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n ui.stderr(\n formatStyledHeader({\n command: 'format',\n description: 'Format your PSL contract source',\n details: [{ label: 'config', value: displayConfigPath }],\n flags,\n }),\n );\n }\n\n const result = await executeFormat({ ...ifDefined('configPath', options.config) });\n\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n return;\n }\n if (flags.quiet) {\n return;\n }\n if (value.formatted) {\n ui.success(`Formatted ${relative(process.cwd(), value.path ?? '')}`);\n } else {\n ui.info('Nothing to format (contract source is not PSL).');\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { R as errorConfigValidation } from "./command-helpers-BLXps5-Y.mjs";
1
+ import { R as errorConfigValidation } from "./command-helpers-Cpq44aVa.mjs";
2
2
  import "@prisma-next/framework-components/components";
3
3
  //#region src/utils/framework-components.ts
4
4
  /**
@@ -55,4 +55,4 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
55
55
  //#endregion
56
56
  export { assertFrameworkComponentsCompatible as t };
57
57
 
58
- //# sourceMappingURL=framework-components-DoSQ6XDH.mjs.map
58
+ //# sourceMappingURL=framework-components-CnbUbiJw.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"framework-components-DoSQ6XDH.mjs","names":[],"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/framework-components/components';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { errorConfigValidation, errorContractMissingExtensionPacks } from './cli-errors';\n\n/**\n * Asserts that all framework components are compatible with the expected family and target.\n *\n * This function validates that each component in the framework components array:\n * - Has kind 'target', 'adapter', 'extension', or 'driver'\n * - Has familyId matching expectedFamilyId\n * - Has targetId matching expectedTargetId\n *\n * This validation happens at the CLI composition boundary, before passing components\n * to typed planner/runner instances. It fills the gap between runtime validation\n * (via `validateConfig()`) and compile-time type enforcement.\n *\n * @param expectedFamilyId - The expected family ID (e.g., 'sql')\n * @param expectedTargetId - The expected target ID (e.g., 'postgres')\n * @param frameworkComponents - Array of framework components to validate\n * @returns The same array typed as TargetBoundComponentDescriptor\n * @throws CliStructuredError if any component is incompatible\n *\n * @example\n * ```ts\n * const config = await loadConfig();\n * const frameworkComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n *\n * // Validate and type-narrow components before passing to planner\n * const typedComponents = assertFrameworkComponentsCompatible(\n * config.family.familyId,\n * config.target.targetId,\n * frameworkComponents\n * );\n *\n * const planner = target.migrations.createPlanner(familyInstance);\n * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });\n * ```\n */\nexport function assertFrameworkComponentsCompatible<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n expectedFamilyId: TFamilyId,\n expectedTargetId: TTargetId,\n frameworkComponents: ReadonlyArray<unknown>,\n): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>> {\n for (let i = 0; i < frameworkComponents.length; i++) {\n const component = frameworkComponents[i];\n\n // Check that component is an object\n if (typeof component !== 'object' || component === null) {\n throw errorConfigValidation('frameworkComponents[]', {\n why: `Framework component at index ${i} must be an object`,\n });\n }\n\n const record = component as Record<string, unknown>;\n\n // Check kind\n if (!Object.hasOwn(record, 'kind')) {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} must have 'kind' property`,\n });\n }\n\n const kind = record['kind'];\n if (kind !== 'target' && kind !== 'adapter' && kind !== 'extension' && kind !== 'driver') {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`,\n });\n }\n\n // Check familyId\n if (!Object.hasOwn(record, 'familyId')) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`,\n });\n }\n\n const familyId = record['familyId'];\n if (familyId !== expectedFamilyId) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`,\n });\n }\n\n // Check targetId\n if (!Object.hasOwn(record, 'targetId')) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`,\n });\n }\n\n const targetId = record['targetId'];\n if (targetId !== expectedTargetId) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`,\n });\n }\n }\n\n // Type assertion is safe because we've validated all components above\n return frameworkComponents as ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Validates that a contract is compatible with the configured target, adapter,\n * and extension packs. Throws on family/target mismatches or missing extension packs.\n *\n * This check ensures the emitted contract matches the CLI config before running\n * commands that depend on the contract (e.g., db verify, db sign).\n *\n * @param contract - The contract to validate (must include targetFamily, target, extensionPacks).\n * @param stack - The control plane stack (target, adapter, driver, extensionPacks).\n *\n * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target\n * doesn't match the configured family/target.\n * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires\n * extension packs that are not provided in the config (includes all missing packs in error.meta).\n *\n * @example\n * ```ts\n * import { assertContractRequirementsSatisfied } from './framework-components';\n *\n * const config = await loadConfig();\n * const contract = await loadContractJson(config.contract.output);\n * const stack = createControlStack({ family: config.family, target: config.target, adapter: config.adapter, ... });\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({ contract, stack });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n stack,\n}: {\n readonly contract: Pick<Contract, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly stack: ControlStack<TFamilyId, TTargetId>;\n}): void {\n const providedComponentIds = new Set<string>([\n stack.target.id,\n ...(stack.adapter ? [stack.adapter.id] : []),\n ]);\n for (const extension of stack.extensionPacks) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: stack.target.familyId,\n expectedTargetId: stack.target.targetId,\n providedComponentIds,\n });\n\n if (result.familyMismatch) {\n throw errorConfigValidation('contract.targetFamily', {\n why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`,\n });\n }\n\n if (result.targetMismatch) {\n throw errorConfigValidation('contract.target', {\n why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`,\n });\n }\n\n if (result.missingExtensionPackIds.length > 0) {\n throw errorContractMissingExtensionPacks({\n missingExtensionPacks: result.missingExtensionPackIds,\n providedComponentIds: [...providedComponentIds],\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,oCAId,kBACA,kBACA,qBACqE;CACrE,KAAK,IAAI,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;EACnD,MAAM,YAAY,oBAAoB;EAGtC,IAAI,OAAO,cAAc,YAAY,cAAc,MACjD,MAAM,sBAAsB,yBAAyB,EACnD,KAAK,gCAAgC,EAAE,oBACzC,CAAC;EAGH,MAAM,SAAS;EAGf,IAAI,CAAC,OAAO,OAAO,QAAQ,MAAM,GAC/B,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,4BACzC,CAAC;EAGH,MAAM,OAAO,OAAO;EACpB,IAAI,SAAS,YAAY,SAAS,aAAa,SAAS,eAAe,SAAS,UAC9E,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,qBAAqB,OAAO,IAAI,EAAE,2DAC3E,CAAC;EAIH,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,GACnC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,iCAChE,CAAC;EAGH,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,kBAAkB,OAAO,QAAQ,EAAE,kBAAkB,iBAAiB,GACtI,CAAC;EAIH,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,GACnC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,iCAChE,CAAC;EAGH,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,kBAAkB,OAAO,QAAQ,EAAE,kBAAkB,iBAAiB,GACtI,CAAC;CAEL;CAGA,OAAO;AACT"}
1
+ {"version":3,"file":"framework-components-CnbUbiJw.mjs","names":[],"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/framework-components/components';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { errorConfigValidation, errorContractMissingExtensionPacks } from './cli-errors';\n\n/**\n * Asserts that all framework components are compatible with the expected family and target.\n *\n * This function validates that each component in the framework components array:\n * - Has kind 'target', 'adapter', 'extension', or 'driver'\n * - Has familyId matching expectedFamilyId\n * - Has targetId matching expectedTargetId\n *\n * This validation happens at the CLI composition boundary, before passing components\n * to typed planner/runner instances. It fills the gap between runtime validation\n * (via `validateConfig()`) and compile-time type enforcement.\n *\n * @param expectedFamilyId - The expected family ID (e.g., 'sql')\n * @param expectedTargetId - The expected target ID (e.g., 'postgres')\n * @param frameworkComponents - Array of framework components to validate\n * @returns The same array typed as TargetBoundComponentDescriptor\n * @throws CliStructuredError if any component is incompatible\n *\n * @example\n * ```ts\n * const config = await loadConfig();\n * const frameworkComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n *\n * // Validate and type-narrow components before passing to planner\n * const typedComponents = assertFrameworkComponentsCompatible(\n * config.family.familyId,\n * config.target.targetId,\n * frameworkComponents\n * );\n *\n * const planner = target.migrations.createPlanner(familyInstance);\n * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });\n * ```\n */\nexport function assertFrameworkComponentsCompatible<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n expectedFamilyId: TFamilyId,\n expectedTargetId: TTargetId,\n frameworkComponents: ReadonlyArray<unknown>,\n): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>> {\n for (let i = 0; i < frameworkComponents.length; i++) {\n const component = frameworkComponents[i];\n\n // Check that component is an object\n if (typeof component !== 'object' || component === null) {\n throw errorConfigValidation('frameworkComponents[]', {\n why: `Framework component at index ${i} must be an object`,\n });\n }\n\n const record = component as Record<string, unknown>;\n\n // Check kind\n if (!Object.hasOwn(record, 'kind')) {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} must have 'kind' property`,\n });\n }\n\n const kind = record['kind'];\n if (kind !== 'target' && kind !== 'adapter' && kind !== 'extension' && kind !== 'driver') {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`,\n });\n }\n\n // Check familyId\n if (!Object.hasOwn(record, 'familyId')) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`,\n });\n }\n\n const familyId = record['familyId'];\n if (familyId !== expectedFamilyId) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`,\n });\n }\n\n // Check targetId\n if (!Object.hasOwn(record, 'targetId')) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`,\n });\n }\n\n const targetId = record['targetId'];\n if (targetId !== expectedTargetId) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`,\n });\n }\n }\n\n // Type assertion is safe because we've validated all components above\n return frameworkComponents as ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Validates that a contract is compatible with the configured target, adapter,\n * and extension packs. Throws on family/target mismatches or missing extension packs.\n *\n * This check ensures the emitted contract matches the CLI config before running\n * commands that depend on the contract (e.g., db verify, db sign).\n *\n * @param contract - The contract to validate (must include targetFamily, target, extensionPacks).\n * @param stack - The control plane stack (target, adapter, driver, extensionPacks).\n *\n * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target\n * doesn't match the configured family/target.\n * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires\n * extension packs that are not provided in the config (includes all missing packs in error.meta).\n *\n * @example\n * ```ts\n * import { assertContractRequirementsSatisfied } from './framework-components';\n *\n * const config = await loadConfig();\n * const contract = await loadContractJson(config.contract.output);\n * const stack = createControlStack({ family: config.family, target: config.target, adapter: config.adapter, ... });\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({ contract, stack });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n stack,\n}: {\n readonly contract: Pick<Contract, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly stack: ControlStack<TFamilyId, TTargetId>;\n}): void {\n const providedComponentIds = new Set<string>([\n stack.target.id,\n ...(stack.adapter ? [stack.adapter.id] : []),\n ]);\n for (const extension of stack.extensionPacks) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: stack.target.familyId,\n expectedTargetId: stack.target.targetId,\n providedComponentIds,\n });\n\n if (result.familyMismatch) {\n throw errorConfigValidation('contract.targetFamily', {\n why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`,\n });\n }\n\n if (result.targetMismatch) {\n throw errorConfigValidation('contract.target', {\n why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`,\n });\n }\n\n if (result.missingExtensionPackIds.length > 0) {\n throw errorContractMissingExtensionPacks({\n missingExtensionPacks: result.missingExtensionPackIds,\n providedComponentIds: [...providedComponentIds],\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,oCAId,kBACA,kBACA,qBACqE;CACrE,KAAK,IAAI,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;EACnD,MAAM,YAAY,oBAAoB;EAGtC,IAAI,OAAO,cAAc,YAAY,cAAc,MACjD,MAAM,sBAAsB,yBAAyB,EACnD,KAAK,gCAAgC,EAAE,oBACzC,CAAC;EAGH,MAAM,SAAS;EAGf,IAAI,CAAC,OAAO,OAAO,QAAQ,MAAM,GAC/B,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,4BACzC,CAAC;EAGH,MAAM,OAAO,OAAO;EACpB,IAAI,SAAS,YAAY,SAAS,aAAa,SAAS,eAAe,SAAS,UAC9E,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,qBAAqB,OAAO,IAAI,EAAE,2DAC3E,CAAC;EAIH,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,GACnC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,iCAChE,CAAC;EAGH,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,kBAAkB,OAAO,QAAQ,EAAE,kBAAkB,iBAAiB,GACtI,CAAC;EAIH,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,GACnC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,iCAChE,CAAC;EAGH,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,IAAI,EAAE,kBAAkB,OAAO,QAAQ,EAAE,kBAAkB,iBAAiB,GACtI,CAAC;CAEL;CAGA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"global-flags-BpoOYtNZ.d.mts","names":[],"sources":["../src/utils/global-flags.ts"],"mappings":";KAMY,YAAA;AAAA,UAEK,WAAA;EAAA,SACN,MAAA,EAAQ,YAAY;EAAA,SACpB,cAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,WAAA;EAAA,SACA,GAAA;AAAA;;;;;UAOM,oBAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,CAAA;EAAA,SACA,OAAA;EAAA,SACA,CAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,WAAA;EAAA,SACA,gBAAA;EAAA,SACA,GAAA;EAAA,SACA,CAAA;AAAA"}
1
+ {"version":3,"file":"global-flags-BpoOYtNZ.d.mts","names":[],"sources":["../src/utils/global-flags.ts"],"mappings":";KAMY;UAEK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA"}
@@ -1,4 +1,4 @@
1
- import { F as CliStructuredError, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-BLXps5-Y.mjs";
1
+ import { F as CliStructuredError, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-Cpq44aVa.mjs";
2
2
  import { a as starterSchema, c as version, i as schemaSample, n as dbFile, o as targetLabel, r as defaultSchemaPath, s as targetPackageName, t as configFile } from "./cli.mjs";
3
3
  import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-mEQ74_nd.mjs";
4
4
  import { createRequire } from "node:module";
@@ -182,8 +182,7 @@ function stripQuotes(value) {
182
182
  * the user was never given the choice — `--force` is the contract.
183
183
  */
184
184
  function errorInitReinitNeedsForce() {
185
- return new CliStructuredError("5002", "Project is already initialized", {
186
- domain: "CLI",
185
+ return new CliStructuredError("CLI.INIT_REINIT_NEEDS_FORCE", "Project is already initialized", {
187
186
  why: "A `prisma-next.config.ts` already exists in this directory. Re-running `init` would overwrite the scaffolded files; in non-interactive mode `init` will not do that without `--force`.",
188
187
  fix: "Pass `--force` to overwrite the existing scaffold, or run `init` interactively to confirm.",
189
188
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -208,8 +207,7 @@ function errorInitMissingFlags(options) {
208
207
  default: return `--${flag} <value>`;
209
208
  }
210
209
  }).join(" ");
211
- return new CliStructuredError("5003", "Missing required flags", {
212
- domain: "CLI",
210
+ return new CliStructuredError("CLI.INIT_MISSING_FLAGS", "Missing required flags", {
213
211
  why: `${options.why} Missing required flag(s): ${flagList}.`,
214
212
  fix: `Re-run with the missing flag(s) supplied, e.g. \`prisma-next init --yes ${fixList}\`. Use \`prisma-next init --help\` to see every flag.`,
215
213
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -221,8 +219,7 @@ function errorInitMissingFlags(options) {
221
219
  * allowed values in `meta` for machine-readable consumption.
222
220
  */
223
221
  function errorInitInvalidFlagValue(options) {
224
- return new CliStructuredError("5004", `Invalid value for --${options.flag}`, {
225
- domain: "CLI",
222
+ return new CliStructuredError("CLI.INIT_INVALID_FLAG_VALUE", `Invalid value for --${options.flag}`, {
226
223
  why: `\`--${options.flag} ${options.value}\` is not one of: ${options.allowed.join(", ")}.`,
227
224
  fix: `Use one of: ${options.allowed.map((v) => `--${options.flag} ${v}`).join(", ")}.`,
228
225
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -240,8 +237,7 @@ function errorInitInvalidFlagValue(options) {
240
237
  */
241
238
  function errorInitAuthoringSchemaPathMismatch(options) {
242
239
  const expectedAuthoring = options.expectedExtension === ".ts" ? "typescript" : "psl";
243
- return new CliStructuredError("5014", "Authoring and schema path do not match", {
244
- domain: "CLI",
240
+ return new CliStructuredError("CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH", "Authoring and schema path do not match", {
245
241
  why: `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
246
242
  fix: `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, or change \`--authoring\` to match the path you supplied. You can also omit \`--schema-path\` to use the default for the chosen authoring.`,
247
243
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -261,8 +257,7 @@ function errorInitAuthoringSchemaPathMismatch(options) {
261
257
  * 3 (USER_ABORTED).
262
258
  */
263
259
  function errorInitUserAborted() {
264
- return new CliStructuredError("5006", "Init cancelled", {
265
- domain: "CLI",
260
+ return new CliStructuredError("CLI.INIT_USER_ABORTED", "Init cancelled", {
266
261
  why: "The interactive prompt was cancelled before all required inputs were supplied. No files were modified.",
267
262
  fix: "Re-run `prisma-next init` and complete the prompts, or pass the required inputs as flags (see `--help`) for a non-interactive run.",
268
263
  severity: "info"
@@ -277,8 +272,7 @@ function errorInitUserAborted() {
277
272
  * mode is supposed to prevent.
278
273
  */
279
274
  function errorInitStrictProbeWithoutProbe() {
280
- return new CliStructuredError("5005", "`--strict-probe` requires `--probe-db`", {
281
- domain: "CLI",
275
+ return new CliStructuredError("CLI.INIT_STRICT_PROBE_WITHOUT_PROBE", "`--strict-probe` requires `--probe-db`", {
282
276
  why: "`--strict-probe` only changes how a *failed* probe is reported; without `--probe-db` no probe is attempted in the first place. (`init` is offline-by-default — it never opens a connection to your database without explicit consent.)",
283
277
  fix: "Add `--probe-db` to opt in to the probe, or drop `--strict-probe` if you do not need the version check.",
284
278
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -293,8 +287,7 @@ function errorInitStrictProbeWithoutProbe() {
293
287
  */
294
288
  function errorInitInstallFailed(options) {
295
289
  const trimmed = options.stderrLines.map((s) => s.trim()).filter(Boolean);
296
- return new CliStructuredError("5007", "Failed to install dependencies", {
297
- domain: "CLI",
290
+ return new CliStructuredError("CLI.INIT_INSTALL_FAILED", "Failed to install dependencies", {
298
291
  why: trimmed.length === 0 ? "The package manager exited with an error and no recoverable fallback applied." : `The package manager exited with: ${trimmed[0]}`,
299
292
  fix: `Install manually:\n ${options.addCommand}\n ${options.addDevCommand}\nThen run \`${options.emitCommand}\` to emit the contract.`,
300
293
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -316,8 +309,7 @@ function errorInitInstallFailed(options) {
316
309
  * and re-run.
317
310
  */
318
311
  function errorInitInvalidManifest(options) {
319
- return new CliStructuredError("5010", `Failed to parse ${options.path}`, {
320
- domain: "CLI",
312
+ return new CliStructuredError("CLI.INIT_INVALID_MANIFEST", `Failed to parse ${options.path}`, {
321
313
  why: `\`${options.path}\` is not valid JSON: ${options.cause}`,
322
314
  fix: `Fix the JSON syntax in \`${options.path}\` (a missing comma or unbalanced brace is the most common cause), then re-run \`prisma-next init\`.`,
323
315
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -342,8 +334,7 @@ function errorInitInvalidManifest(options) {
342
334
  * re-run.
343
335
  */
344
336
  function errorInitInvalidTsconfig(options) {
345
- return new CliStructuredError("5011", `Failed to parse ${options.path}`, {
346
- domain: "CLI",
337
+ return new CliStructuredError("CLI.INIT_INVALID_TSCONFIG", `Failed to parse ${options.path}`, {
347
338
  why: `\`${options.path}\` is not valid JSON or JSONC: ${options.cause}`,
348
339
  fix: `Fix the syntax in \`${options.path}\` and re-run \`prisma-next init\`. \`init\` accepts JSONC (comments and trailing commas) but cannot recover from unbalanced braces or missing commas.`,
349
340
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -368,8 +359,7 @@ function errorInitInvalidTsconfig(options) {
368
359
  * carries `filesWritten` so a follow-up agent can resume manually.
369
360
  */
370
361
  function errorInitProbeFailed(options) {
371
- return new CliStructuredError("5012", "Database probe failed", {
372
- domain: "CLI",
362
+ return new CliStructuredError("CLI.INIT_PROBE_FAILED", "Database probe failed", {
373
363
  why: `\`--probe-db\` could not complete and \`--strict-probe\` was set: ${options.cause}`,
374
364
  fix: "Confirm `DATABASE_URL` points at a reachable server, or drop `--strict-probe` to treat probe failures as warnings.",
375
365
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -386,8 +376,7 @@ function errorInitProbeFailed(options) {
386
376
  * `5 = EMIT_FAILED`.
387
377
  */
388
378
  function errorInitEmitFailed(options) {
389
- return new CliStructuredError("5008", "Failed to emit contract", {
390
- domain: "CLI",
379
+ return new CliStructuredError("CLI.INIT_EMIT_FAILED", "Failed to emit contract", {
391
380
  why: `\`prisma-next contract emit\` failed: ${options.cause}`,
392
381
  fix: `Inspect your contract file, fix the underlying issue, then re-run \`${options.emitCommand}\`. Pass \`-v\` for the full error envelope.`,
393
382
  docsUrl: "https://prisma-next.dev/docs/cli/contract-emit",
@@ -409,8 +398,7 @@ function errorInitEmitFailed(options) {
409
398
  * semantics. Maps to exit code `6 = SKILL_INSTALL_FAILED`.
410
399
  */
411
400
  function errorInitSkillInstallFailed(options) {
412
- return new CliStructuredError("5013", "Failed to install Prisma Next skills", {
413
- domain: "CLI",
401
+ return new CliStructuredError("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
414
402
  why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
415
403
  fix: `Either:
416
404
  - Re-run \`prisma-next init --no-skill${options.filesWritten.length > 0 ? " --force" : ""}\` to skip the skill install for this run, or\n - Fix the underlying issue (network, npm registry, \`npx skills\` on PATH) and install manually:\n ${options.skillInstallCommand}`,
@@ -1880,8 +1868,7 @@ async function runInit(baseDir, runOptions) {
1880
1868
  warnings
1881
1869
  };
1882
1870
  const validated = InitOutputSchema(output);
1883
- if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError("5009", "Init produced an invalid output document", {
1884
- domain: "CLI",
1871
+ if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError("CLI.INIT_INVALID_OUTPUT_DOCUMENT", "Init produced an invalid output document", {
1885
1872
  why: `The success document failed schema validation: ${String(validated)}`,
1886
1873
  fix: "This is a bug in prisma-next. Please report it with the full `-v` output.",
1887
1874
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -1910,10 +1897,10 @@ function emitError(ui, flags, error) {
1910
1897
  * Maps a structured init error to its documented exit code. Centralised so
1911
1898
  * the error → exit-code contract lives next to the codes themselves.
1912
1899
  *
1913
- * `5009` (and the unknown-code default branch) routes to
1914
- * `INIT_EXIT_INTERNAL_ERROR` because those represent prisma-next bugs the
1915
- * user did not cause — surfacing them as `PRECONDITION` would mislead
1916
- * automation into thinking the caller mis-invoked the CLI.
1900
+ * `CLI.INIT_INVALID_OUTPUT_DOCUMENT` (and the unknown-code default branch)
1901
+ * routes to `INIT_EXIT_INTERNAL_ERROR` because those represent prisma-next
1902
+ * bugs the user did not cause — surfacing them as `PRECONDITION` would
1903
+ * mislead automation into thinking the caller mis-invoked the CLI.
1917
1904
  *
1918
1905
  * See [exit-codes.ts](./exit-codes.ts) for the canonical list and
1919
1906
  * [Style Guide § Exit Codes](../../../../../../../docs/CLI%20Style%20Guide.md#exit-codes)
@@ -1924,19 +1911,19 @@ function emitError(ui, flags, error) {
1924
1911
  */
1925
1912
  function exitCodeForError(error) {
1926
1913
  switch (error.code) {
1927
- case "5002":
1928
- case "5003":
1929
- case "5004":
1930
- case "5005":
1931
- case "5010":
1932
- case "5011":
1933
- case "5012":
1934
- case "5014": return 2;
1935
- case "5006": return 3;
1936
- case "5007": return 4;
1937
- case "5008": return 5;
1938
- case "5009": return 1;
1939
- case "5013": return 6;
1914
+ case "CLI.INIT_REINIT_NEEDS_FORCE":
1915
+ case "CLI.INIT_MISSING_FLAGS":
1916
+ case "CLI.INIT_INVALID_FLAG_VALUE":
1917
+ case "CLI.INIT_STRICT_PROBE_WITHOUT_PROBE":
1918
+ case "CLI.INIT_INVALID_MANIFEST":
1919
+ case "CLI.INIT_INVALID_TSCONFIG":
1920
+ case "CLI.INIT_PROBE_FAILED":
1921
+ case "CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH": return 2;
1922
+ case "CLI.INIT_USER_ABORTED": return 3;
1923
+ case "CLI.INIT_INSTALL_FAILED": return 4;
1924
+ case "CLI.INIT_EMIT_FAILED": return 5;
1925
+ case "CLI.INIT_INVALID_OUTPUT_DOCUMENT": return 1;
1926
+ case "CLI.INIT_SKILL_INSTALL_FAILED": return 6;
1940
1927
  default: return 1;
1941
1928
  }
1942
1929
  }
@@ -2153,7 +2140,7 @@ async function runEmit(ctx) {
2153
2140
  const spinner = ctx.ui.spinner();
2154
2141
  spinner.start("Emitting contract...");
2155
2142
  try {
2156
- const { executeContractEmit } = await import("./contract-emit-Db9tBwcF.mjs").then((n) => n.t);
2143
+ const { executeContractEmit } = await import("./contract-emit-cJQBlvGb.mjs").then((n) => n.t);
2157
2144
  await executeContractEmit({ configPath: join(ctx.baseDir, "prisma-next.config.ts") });
2158
2145
  spinner.stop("Contract emitted");
2159
2146
  } catch (err) {
@@ -2206,4 +2193,4 @@ function sanitisePackageName(raw) {
2206
2193
  //#endregion
2207
2194
  export { runInit };
2208
2195
 
2209
- //# sourceMappingURL=init-BeAcODLF.mjs.map
2196
+ //# sourceMappingURL=init-C3JhkHg-.mjs.map