@prisma-next/errors 0.10.0-dev.9 → 0.11.0

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.
@@ -266,6 +266,25 @@ function errorMigrationCliUnknownFlag(options) {
266
266
  });
267
267
  }
268
268
  /**
269
+ * The main CLI received an unsupported `--format` value.
270
+ */
271
+ function errorInvalidOutputFormat(value) {
272
+ return new CliStructuredError("4014", `Invalid --format value "${value}". Allowed values: pretty, json.`, {
273
+ domain: "CLI",
274
+ meta: {
275
+ value,
276
+ allowed: ["pretty", "json"]
277
+ }
278
+ });
279
+ }
280
+ /**
281
+ * The main CLI received mutually exclusive output format flags
282
+ * (`--format pretty` together with `--json`).
283
+ */
284
+ function errorOutputFormatMutex() {
285
+ return new CliStructuredError("4015", "Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.", { domain: "CLI" });
286
+ }
287
+ /**
269
288
  * Config validation error (missing required fields).
270
289
  */
271
290
  function errorConfigValidation(field, options) {
@@ -287,6 +306,6 @@ function errorUnexpected(message, options) {
287
306
  });
288
307
  }
289
308
  //#endregion
290
- export { errorUnexpected as _, errorContractMissingExtensionPacks as a, errorDriverRequired as c, errorJsonFormatNotSupported as d, errorMigrationCliInvalidConfigArg as f, errorTargetMigrationNotSupported as g, errorQueryRunnerFactoryRequired as h, errorContractConfigMissing as i, errorFamilyReadMarkerSqlRequired as l, errorMigrationPlanningFailed as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorMigrationCliUnknownFlag as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFileNotFound as u };
309
+ export { errorQueryRunnerFactoryRequired as _, errorContractMissingExtensionPacks as a, errorDriverRequired as c, errorInvalidOutputFormat as d, errorJsonFormatNotSupported as f, errorOutputFormatMutex as g, errorMigrationPlanningFailed as h, errorContractConfigMissing as i, errorFamilyReadMarkerSqlRequired as l, errorMigrationCliUnknownFlag as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorMigrationCliInvalidConfigArg as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFileNotFound as u, errorTargetMigrationNotSupported as v, errorUnexpected as y };
291
310
 
292
- //# sourceMappingURL=control-B61eSDwG.mjs.map
311
+ //# sourceMappingURL=control-DOc6vx43.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-B61eSDwG.mjs","names":[],"sources":["../src/control.ts"],"sourcesContent":["/**\n * CLI error envelope for output formatting.\n * This is the serialized form of a CliStructuredError.\n */\nexport interface CliErrorEnvelope {\n readonly ok: false;\n readonly code: string;\n readonly domain: string;\n readonly severity: 'error' | 'warn' | 'info';\n readonly summary: string;\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n}\n\n/**\n * Minimal conflict data structure expected by CLI output.\n */\nexport interface CliErrorConflict {\n readonly kind: string;\n readonly summary: string;\n readonly why?: string;\n}\n\n/**\n * Domain prefix for structured CLI error codes.\n *\n * The full envelope code is rendered as `PN-<domain>-<code>` (see\n * `CliStructuredError.toEnvelope`). The supported domains follow the\n * taxonomy documented in `docs/CLI Style Guide.md`:\n *\n * - `CLI` — CLI command processing (config, validation, planning)\n * - `MIG` — Migration subsystem (authoring, planning conflicts, runner)\n * - `RUN` — Application runtime (query execution, streaming)\n * - `CON` — Contract subsystem (validation, normalization)\n * - `SCHEMA` — Schema subsystem\n *\n * Sub-clustering within a domain is conveyed by the numeric code range; see\n * the per-domain source files for reserved ranges.\n */\nconst CLI_ERROR_DOMAINS = ['CLI', 'RUN', 'MIG', 'CON', 'SCHEMA'] as const;\n\nexport type CliErrorDomain = (typeof CLI_ERROR_DOMAINS)[number];\n\n/**\n * Structured CLI error that contains all information needed for error envelopes.\n * Call sites throw these errors with full context.\n */\nexport class CliStructuredError extends Error {\n readonly code: string;\n readonly domain: CliErrorDomain;\n readonly severity: 'error' | 'warn' | 'info';\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n\n constructor(\n code: string,\n summary: string,\n options?: {\n readonly domain?: CliErrorDomain;\n readonly severity?: 'error' | 'warn' | 'info';\n readonly why?: string;\n readonly fix?: string;\n readonly where?: { readonly path?: string; readonly line?: number };\n readonly meta?: Record<string, unknown>;\n readonly docsUrl?: string;\n },\n ) {\n super(summary);\n this.name = 'CliStructuredError';\n this.code = code;\n this.domain = options?.domain ?? 'CLI';\n this.severity = options?.severity ?? 'error';\n this.why = options?.why;\n this.fix = options?.fix === options?.why ? undefined : options?.fix;\n this.where = options?.where\n ? {\n path: options.where.path,\n line: options.where.line,\n }\n : undefined;\n this.meta = options?.meta;\n this.docsUrl = options?.docsUrl;\n }\n\n /**\n * Converts this error to a CLI error envelope for output formatting.\n */\n toEnvelope(): CliErrorEnvelope {\n return {\n ok: false as const,\n code: `PN-${this.domain}-${this.code}`,\n domain: this.domain,\n severity: this.severity,\n summary: this.message,\n why: this.why,\n fix: this.fix,\n where: this.where,\n meta: this.meta,\n docsUrl: this.docsUrl,\n };\n }\n\n /**\n * Type guard to check if an error is a CliStructuredError.\n * Uses duck-typing to work across module boundaries where instanceof may fail.\n */\n static is(error: unknown): error is CliStructuredError {\n if (!(error instanceof Error)) {\n return false;\n }\n const candidate = error as CliStructuredError;\n return (\n candidate.name === 'CliStructuredError' &&\n typeof candidate.code === 'string' &&\n isCliErrorDomain(candidate.domain) &&\n typeof candidate.toEnvelope === 'function'\n );\n }\n}\n\nconst CLI_ERROR_DOMAIN_SET: ReadonlySet<CliErrorDomain> = new Set(CLI_ERROR_DOMAINS);\n\nfunction isCliErrorDomain(value: unknown): value is CliErrorDomain {\n return typeof value === 'string' && CLI_ERROR_DOMAIN_SET.has(value as CliErrorDomain);\n}\n\n// ============================================================================\n// Numeric range conventions for `PN-CLI-NNNN`\n// ============================================================================\n//\n// Sub-clustering inside the `CLI` domain uses the numeric prefix:\n//\n// - `4xxx` — generic / cross-command CLI errors authored here (config\n// missing, file not found, contract validation, etc.).\n// - `5xxx` — command-specific CLI errors authored alongside the command\n// itself (e.g. `init` errors live in\n// `packages/1-framework/3-tooling/cli/src/commands/init/errors.ts`).\n// The 5xxx range avoids collisions with the shared 4xxx pool while\n// still belonging to the `CLI` domain — consumers branch on the full\n// `PN-CLI-5007` form, so the prefix is purely an authoring guide.\n//\n// See [`docs/CLI Style Guide.md` § Errors](../../../../../docs/CLI%20Style%20Guide.md#errors)\n// and the per-command error file for the live reservation list.\n\n// ============================================================================\n// Config Errors (PN-CLI-4001-4007)\n// ============================================================================\n\n/**\n * Config file not found or missing.\n */\nexport function errorConfigFileNotFound(\n configPath?: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n ...(options?.why ? { why: options.why } : { why: 'Config file not found' }),\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n ...(configPath ? { where: { path: configPath } } : {}),\n });\n}\n\n/**\n * Contract configuration missing from config.\n */\nexport function errorContractConfigMissing(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4002', 'Contract configuration missing', {\n domain: 'CLI',\n why: options?.why ?? 'The contract configuration is required for emit',\n fix: 'Add contract configuration to your prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',\n });\n}\n\n/**\n * Contract validation failed.\n */\nexport function errorContractValidationFailed(\n reason: string,\n options?: {\n readonly where?: { readonly path?: string; readonly line?: number };\n },\n): CliStructuredError {\n return new CliStructuredError('4003', 'Contract validation failed', {\n domain: 'CLI',\n why: reason,\n fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',\n docsUrl: 'https://prisma-next.dev/docs/contracts',\n ...(options?.where ? { where: options.where } : {}),\n });\n}\n\n/**\n * File not found.\n */\nexport function errorFileNotFound(\n filePath: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly docsUrl?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: options?.fix ?? 'Check that the file path is correct',\n where: { path: filePath },\n ...(options?.docsUrl ? { docsUrl: options.docsUrl } : {}),\n });\n}\n\n/**\n * Database connection is required but not provided.\n */\nexport function errorDatabaseConnectionRequired(options?: {\n readonly why?: string;\n readonly commandName?: string;\n readonly retryCommand?: string;\n}): CliStructuredError {\n const runHint = options?.retryCommand\n ? `Run \\`${options.retryCommand}\\``\n : options?.commandName\n ? `Run \\`prisma-next ${options.commandName} --db <url>\\``\n : 'Provide `--db <url>`';\n return new CliStructuredError('4005', 'Database connection is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database connection is required for this command',\n fix: `${runHint}, or set \\`db: { connection: \"postgres://…\" }\\` in prisma-next.config.ts`,\n });\n}\n\n/**\n * Query runner factory is required but not provided in config.\n */\nexport function errorQueryRunnerFactoryRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4006', 'Query runner factory is required', {\n domain: 'CLI',\n why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',\n fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4007', 'Family readMarker() is required', {\n domain: 'CLI',\n why: options?.why ?? 'Family verify.readMarker is required for db verify',\n fix: 'Ensure family.verify.readMarker() is exported by your family package',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * JSON output format not supported.\n */\nexport function errorJsonFormatNotSupported(options: {\n readonly command: string;\n readonly format: string;\n readonly supportedFormats: readonly string[];\n}): CliStructuredError {\n return new CliStructuredError('4008', 'Unsupported JSON format', {\n domain: 'CLI',\n why: `The ${options.command} command does not support --json ${options.format}`,\n fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,\n meta: {\n command: options.command,\n format: options.format,\n supportedFormats: options.supportedFormats,\n },\n });\n}\n\n/**\n * Driver is required for DB-connected commands but not provided.\n */\nexport function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {\n domain: 'CLI',\n why: options?.why ?? 'Config.driver is required for DB-connected commands',\n fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n/**\n * Contract requires extension packs that are not provided by config descriptors.\n */\nexport function errorContractMissingExtensionPacks(options: {\n readonly missingExtensionPacks: readonly string[];\n readonly providedComponentIds: readonly string[];\n}): CliStructuredError {\n const missing = [...options.missingExtensionPacks].sort();\n return new CliStructuredError('4011', 'Missing extension packs in config', {\n domain: 'CLI',\n why:\n missing.length === 1\n ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`\n : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,\n fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n meta: {\n missingExtensionPacks: missing,\n providedComponentIds: [...options.providedComponentIds].sort(),\n },\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly CliErrorConflict[];\n readonly why?: string;\n}): CliStructuredError {\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n const conflictFixes = options.conflicts\n .map((c) => c.why)\n .filter((why): why is string => typeof why === 'string');\n const computedFix =\n conflictFixes.length > 0\n ? conflictFixes.join('\\n')\n : 'Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty';\n\n return new CliStructuredError('4020', 'Migration planning failed', {\n domain: 'CLI',\n why: computedWhy,\n fix: computedFix,\n meta: { conflicts: options.conflicts },\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Target does not support migrations (missing createPlanner/createRunner).\n */\nexport function errorTargetMigrationNotSupported(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4021', 'Target does not support migrations', {\n domain: 'CLI',\n why: options?.why ?? 'The configured target does not provide migration planner/runner',\n fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * The migration-file CLI received `--config` without a path argument (either\n * a bare trailing `--config`, or `--config` followed by another flag like\n * `--config --dry-run`). Surfacing this as a structured error fails fast\n * rather than silently consuming the next flag as the config path or\n * falling back to default discovery against the wrong project.\n */\nexport function errorMigrationCliInvalidConfigArg(options?: {\n readonly nextToken?: string;\n}): CliStructuredError {\n const why =\n options?.nextToken !== undefined\n ? `\\`--config\\` was followed by another flag (\\`${options.nextToken}\\`) instead of a path argument.`\n : '`--config` was passed without a following path argument.';\n return new CliStructuredError('4012', '--config flag requires a path argument', {\n domain: 'CLI',\n why,\n fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',\n meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},\n });\n}\n\n/**\n * The migration-file CLI received a flag it does not recognise. Surfaced as a\n * structured error so consumers can render their own \"did you mean\"\n * suggestions from `meta.knownFlags` rather than parsing the message.\n *\n * Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:\n * pass the offending token as `flag` and the option declarations as\n * `knownFlags`.\n */\nexport function errorMigrationCliUnknownFlag(options: {\n readonly flag: string;\n readonly knownFlags: readonly string[];\n}): CliStructuredError {\n const knownList = options.knownFlags.join(', ');\n return new CliStructuredError('4013', 'Unknown migration CLI flag', {\n domain: 'CLI',\n why: `Unknown flag \\`${options.flag}\\`.`,\n fix: `Known flags: ${knownList}. Run with \\`--help\\` to see the full list.`,\n meta: { flag: options.flag, knownFlags: options.knownFlags },\n });\n}\n\n/**\n * Config validation error (missing required fields).\n */\nexport function errorConfigValidation(\n field: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4009', 'Config validation error', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: 'Check your prisma-next.config.ts and ensure all required fields are provided',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Generic Error\n// ============================================================================\n\n/**\n * Generic unexpected error.\n */\nexport function errorUnexpected(\n message: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4999', 'Unexpected error', {\n domain: 'CLI',\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,MAAM,oBAAoB;CAAC;CAAO;CAAO;CAAO;CAAO;CAAS;;;;;AAQhE,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CACA;CACA;CACA;CACA;CACA;CAMA;CACA;CAEA,YACE,MACA,SACA,SASA;EACA,MAAM,QAAQ;EACd,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS,UAAU;EACjC,KAAK,WAAW,SAAS,YAAY;EACrC,KAAK,MAAM,SAAS;EACpB,KAAK,MAAM,SAAS,QAAQ,SAAS,MAAM,KAAA,IAAY,SAAS;EAChE,KAAK,QAAQ,SAAS,QAClB;GACE,MAAM,QAAQ,MAAM;GACpB,MAAM,QAAQ,MAAM;GACrB,GACD,KAAA;EACJ,KAAK,OAAO,SAAS;EACrB,KAAK,UAAU,SAAS;;;;;CAM1B,aAA+B;EAC7B,OAAO;GACL,IAAI;GACJ,MAAM,MAAM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,kBAAkB,QAAQ,KAAK;EACpC,KAAK,gBAAgB,UAAU;EAC/B,MAAM;GAAE,MAAM,QAAQ;GAAM,YAAY,QAAQ;GAAY;EAC7D,CAAC;;;;;AAMJ,SAAgB,sBACd,OACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,2BAA2B;EAC/D,QAAQ;EACR,KAAK,SAAS,OAAO,uBAAuB,MAAM;EAClD,KAAK;EACL,SAAS;EACV,CAAC;;;;;AAUJ,SAAgB,gBACd,SACA,SAIoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,oBAAoB;EACxD,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;EACtB,CAAC"}
1
+ {"version":3,"file":"control-DOc6vx43.mjs","names":[],"sources":["../src/control.ts"],"sourcesContent":["/**\n * CLI error envelope for output formatting.\n * This is the serialized form of a CliStructuredError.\n */\nexport interface CliErrorEnvelope {\n readonly ok: false;\n readonly code: string;\n readonly domain: string;\n readonly severity: 'error' | 'warn' | 'info';\n readonly summary: string;\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n}\n\n/**\n * Minimal conflict data structure expected by CLI output.\n */\nexport interface CliErrorConflict {\n readonly kind: string;\n readonly summary: string;\n readonly why?: string;\n}\n\n/**\n * Domain prefix for structured CLI error codes.\n *\n * The full envelope code is rendered as `PN-<domain>-<code>` (see\n * `CliStructuredError.toEnvelope`). The supported domains follow the\n * taxonomy documented in `docs/CLI Style Guide.md`:\n *\n * - `CLI` — CLI command processing (config, validation, planning)\n * - `MIG` — Migration subsystem (authoring, planning conflicts, runner)\n * - `RUN` — Application runtime (query execution, streaming)\n * - `CON` — Contract subsystem (validation, normalization)\n * - `SCHEMA` — Schema subsystem\n *\n * Sub-clustering within a domain is conveyed by the numeric code range; see\n * the per-domain source files for reserved ranges.\n */\nconst CLI_ERROR_DOMAINS = ['CLI', 'RUN', 'MIG', 'CON', 'SCHEMA'] as const;\n\nexport type CliErrorDomain = (typeof CLI_ERROR_DOMAINS)[number];\n\n/**\n * Structured CLI error that contains all information needed for error envelopes.\n * Call sites throw these errors with full context.\n */\nexport class CliStructuredError extends Error {\n readonly code: string;\n readonly domain: CliErrorDomain;\n readonly severity: 'error' | 'warn' | 'info';\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n\n constructor(\n code: string,\n summary: string,\n options?: {\n readonly domain?: CliErrorDomain;\n readonly severity?: 'error' | 'warn' | 'info';\n readonly why?: string;\n readonly fix?: string;\n readonly where?: { readonly path?: string; readonly line?: number };\n readonly meta?: Record<string, unknown>;\n readonly docsUrl?: string;\n },\n ) {\n super(summary);\n this.name = 'CliStructuredError';\n this.code = code;\n this.domain = options?.domain ?? 'CLI';\n this.severity = options?.severity ?? 'error';\n this.why = options?.why;\n this.fix = options?.fix === options?.why ? undefined : options?.fix;\n this.where = options?.where\n ? {\n path: options.where.path,\n line: options.where.line,\n }\n : undefined;\n this.meta = options?.meta;\n this.docsUrl = options?.docsUrl;\n }\n\n /**\n * Converts this error to a CLI error envelope for output formatting.\n */\n toEnvelope(): CliErrorEnvelope {\n return {\n ok: false as const,\n code: `PN-${this.domain}-${this.code}`,\n domain: this.domain,\n severity: this.severity,\n summary: this.message,\n why: this.why,\n fix: this.fix,\n where: this.where,\n meta: this.meta,\n docsUrl: this.docsUrl,\n };\n }\n\n /**\n * Type guard to check if an error is a CliStructuredError.\n * Uses duck-typing to work across module boundaries where instanceof may fail.\n */\n static is(error: unknown): error is CliStructuredError {\n if (!(error instanceof Error)) {\n return false;\n }\n const candidate = error as CliStructuredError;\n return (\n candidate.name === 'CliStructuredError' &&\n typeof candidate.code === 'string' &&\n isCliErrorDomain(candidate.domain) &&\n typeof candidate.toEnvelope === 'function'\n );\n }\n}\n\nconst CLI_ERROR_DOMAIN_SET: ReadonlySet<CliErrorDomain> = new Set(CLI_ERROR_DOMAINS);\n\nfunction isCliErrorDomain(value: unknown): value is CliErrorDomain {\n return typeof value === 'string' && CLI_ERROR_DOMAIN_SET.has(value as CliErrorDomain);\n}\n\n// ============================================================================\n// Numeric range conventions for `PN-CLI-NNNN`\n// ============================================================================\n//\n// Sub-clustering inside the `CLI` domain uses the numeric prefix:\n//\n// - `4xxx` — generic / cross-command CLI errors authored here (config\n// missing, file not found, contract validation, etc.).\n// - `5xxx` — command-specific CLI errors authored alongside the command\n// itself (e.g. `init` errors live in\n// `packages/1-framework/3-tooling/cli/src/commands/init/errors.ts`).\n// The 5xxx range avoids collisions with the shared 4xxx pool while\n// still belonging to the `CLI` domain — consumers branch on the full\n// `PN-CLI-5007` form, so the prefix is purely an authoring guide.\n//\n// See [`docs/CLI Style Guide.md` § Errors](../../../../../docs/CLI%20Style%20Guide.md#errors)\n// and the per-command error file for the live reservation list.\n\n// ============================================================================\n// Config Errors (PN-CLI-4001-4007)\n// ============================================================================\n\n/**\n * Config file not found or missing.\n */\nexport function errorConfigFileNotFound(\n configPath?: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n ...(options?.why ? { why: options.why } : { why: 'Config file not found' }),\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n ...(configPath ? { where: { path: configPath } } : {}),\n });\n}\n\n/**\n * Contract configuration missing from config.\n */\nexport function errorContractConfigMissing(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4002', 'Contract configuration missing', {\n domain: 'CLI',\n why: options?.why ?? 'The contract configuration is required for emit',\n fix: 'Add contract configuration to your prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',\n });\n}\n\n/**\n * Contract validation failed.\n */\nexport function errorContractValidationFailed(\n reason: string,\n options?: {\n readonly where?: { readonly path?: string; readonly line?: number };\n },\n): CliStructuredError {\n return new CliStructuredError('4003', 'Contract validation failed', {\n domain: 'CLI',\n why: reason,\n fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',\n docsUrl: 'https://prisma-next.dev/docs/contracts',\n ...(options?.where ? { where: options.where } : {}),\n });\n}\n\n/**\n * File not found.\n */\nexport function errorFileNotFound(\n filePath: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly docsUrl?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: options?.fix ?? 'Check that the file path is correct',\n where: { path: filePath },\n ...(options?.docsUrl ? { docsUrl: options.docsUrl } : {}),\n });\n}\n\n/**\n * Database connection is required but not provided.\n */\nexport function errorDatabaseConnectionRequired(options?: {\n readonly why?: string;\n readonly commandName?: string;\n readonly retryCommand?: string;\n}): CliStructuredError {\n const runHint = options?.retryCommand\n ? `Run \\`${options.retryCommand}\\``\n : options?.commandName\n ? `Run \\`prisma-next ${options.commandName} --db <url>\\``\n : 'Provide `--db <url>`';\n return new CliStructuredError('4005', 'Database connection is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database connection is required for this command',\n fix: `${runHint}, or set \\`db: { connection: \"postgres://…\" }\\` in prisma-next.config.ts`,\n });\n}\n\n/**\n * Query runner factory is required but not provided in config.\n */\nexport function errorQueryRunnerFactoryRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4006', 'Query runner factory is required', {\n domain: 'CLI',\n why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',\n fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4007', 'Family readMarker() is required', {\n domain: 'CLI',\n why: options?.why ?? 'Family verify.readMarker is required for db verify',\n fix: 'Ensure family.verify.readMarker() is exported by your family package',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * JSON output format not supported.\n */\nexport function errorJsonFormatNotSupported(options: {\n readonly command: string;\n readonly format: string;\n readonly supportedFormats: readonly string[];\n}): CliStructuredError {\n return new CliStructuredError('4008', 'Unsupported JSON format', {\n domain: 'CLI',\n why: `The ${options.command} command does not support --json ${options.format}`,\n fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,\n meta: {\n command: options.command,\n format: options.format,\n supportedFormats: options.supportedFormats,\n },\n });\n}\n\n/**\n * Driver is required for DB-connected commands but not provided.\n */\nexport function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {\n domain: 'CLI',\n why: options?.why ?? 'Config.driver is required for DB-connected commands',\n fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n/**\n * Contract requires extension packs that are not provided by config descriptors.\n */\nexport function errorContractMissingExtensionPacks(options: {\n readonly missingExtensionPacks: readonly string[];\n readonly providedComponentIds: readonly string[];\n}): CliStructuredError {\n const missing = [...options.missingExtensionPacks].sort();\n return new CliStructuredError('4011', 'Missing extension packs in config', {\n domain: 'CLI',\n why:\n missing.length === 1\n ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`\n : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,\n fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n meta: {\n missingExtensionPacks: missing,\n providedComponentIds: [...options.providedComponentIds].sort(),\n },\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly CliErrorConflict[];\n readonly why?: string;\n}): CliStructuredError {\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n const conflictFixes = options.conflicts\n .map((c) => c.why)\n .filter((why): why is string => typeof why === 'string');\n const computedFix =\n conflictFixes.length > 0\n ? conflictFixes.join('\\n')\n : 'Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty';\n\n return new CliStructuredError('4020', 'Migration planning failed', {\n domain: 'CLI',\n why: computedWhy,\n fix: computedFix,\n meta: { conflicts: options.conflicts },\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Target does not support migrations (missing createPlanner/createRunner).\n */\nexport function errorTargetMigrationNotSupported(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4021', 'Target does not support migrations', {\n domain: 'CLI',\n why: options?.why ?? 'The configured target does not provide migration planner/runner',\n fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * The migration-file CLI received `--config` without a path argument (either\n * a bare trailing `--config`, or `--config` followed by another flag like\n * `--config --dry-run`). Surfacing this as a structured error fails fast\n * rather than silently consuming the next flag as the config path or\n * falling back to default discovery against the wrong project.\n */\nexport function errorMigrationCliInvalidConfigArg(options?: {\n readonly nextToken?: string;\n}): CliStructuredError {\n const why =\n options?.nextToken !== undefined\n ? `\\`--config\\` was followed by another flag (\\`${options.nextToken}\\`) instead of a path argument.`\n : '`--config` was passed without a following path argument.';\n return new CliStructuredError('4012', '--config flag requires a path argument', {\n domain: 'CLI',\n why,\n fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',\n meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},\n });\n}\n\n/**\n * The migration-file CLI received a flag it does not recognise. Surfaced as a\n * structured error so consumers can render their own \"did you mean\"\n * suggestions from `meta.knownFlags` rather than parsing the message.\n *\n * Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:\n * pass the offending token as `flag` and the option declarations as\n * `knownFlags`.\n */\nexport function errorMigrationCliUnknownFlag(options: {\n readonly flag: string;\n readonly knownFlags: readonly string[];\n}): CliStructuredError {\n const knownList = options.knownFlags.join(', ');\n return new CliStructuredError('4013', 'Unknown migration CLI flag', {\n domain: 'CLI',\n why: `Unknown flag \\`${options.flag}\\`.`,\n fix: `Known flags: ${knownList}. Run with \\`--help\\` to see the full list.`,\n meta: { flag: options.flag, knownFlags: options.knownFlags },\n });\n}\n\n/**\n * The main CLI received an unsupported `--format` value.\n */\nexport function errorInvalidOutputFormat(value: string): CliStructuredError {\n return new CliStructuredError(\n '4014',\n `Invalid --format value \"${value}\". Allowed values: pretty, json.`,\n {\n domain: 'CLI',\n meta: { value, allowed: ['pretty', 'json'] as const },\n },\n );\n}\n\n/**\n * The main CLI received mutually exclusive output format flags\n * (`--format pretty` together with `--json`).\n */\nexport function errorOutputFormatMutex(): CliStructuredError {\n return new CliStructuredError(\n '4015',\n 'Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.',\n { domain: 'CLI' },\n );\n}\n\n/**\n * Config validation error (missing required fields).\n */\nexport function errorConfigValidation(\n field: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4009', 'Config validation error', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: 'Check your prisma-next.config.ts and ensure all required fields are provided',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Generic Error\n// ============================================================================\n\n/**\n * Generic unexpected error.\n */\nexport function errorUnexpected(\n message: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4999', 'Unexpected error', {\n domain: 'CLI',\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mapp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AS,OAAO;EACrB,KAAK,SAAS,OAAO;EACtB,CAAC"}
@@ -188,6 +188,15 @@ declare function errorMigrationCliUnknownFlag(options: {
188
188
  readonly flag: string;
189
189
  readonly knownFlags: readonly string[];
190
190
  }): CliStructuredError;
191
+ /**
192
+ * The main CLI received an unsupported `--format` value.
193
+ */
194
+ declare function errorInvalidOutputFormat(value: string): CliStructuredError;
195
+ /**
196
+ * The main CLI received mutually exclusive output format flags
197
+ * (`--format pretty` together with `--json`).
198
+ */
199
+ declare function errorOutputFormatMutex(): CliStructuredError;
191
200
  /**
192
201
  * Config validation error (missing required fields).
193
202
  */
@@ -202,5 +211,5 @@ declare function errorUnexpected(message: string, options?: {
202
211
  readonly fix?: string;
203
212
  }): CliStructuredError;
204
213
  //#endregion
205
- export { errorQueryRunnerFactoryRequired as _, errorConfigValidation as a, errorContractValidationFailed as c, errorFamilyReadMarkerSqlRequired as d, errorFileNotFound as f, errorMigrationPlanningFailed as g, errorMigrationCliUnknownFlag as h, errorConfigFileNotFound as i, errorDatabaseConnectionRequired as l, errorMigrationCliInvalidConfigArg as m, CliErrorEnvelope as n, errorContractConfigMissing as o, errorJsonFormatNotSupported as p, CliStructuredError as r, errorContractMissingExtensionPacks as s, CliErrorConflict as t, errorDriverRequired as u, errorTargetMigrationNotSupported as v, errorUnexpected as y };
206
- //# sourceMappingURL=control-BtdiadMy.d.mts.map
214
+ export { errorMigrationPlanningFailed as _, errorConfigValidation as a, errorTargetMigrationNotSupported as b, errorContractValidationFailed as c, errorFamilyReadMarkerSqlRequired as d, errorFileNotFound as f, errorMigrationCliUnknownFlag as g, errorMigrationCliInvalidConfigArg as h, errorConfigFileNotFound as i, errorDatabaseConnectionRequired as l, errorJsonFormatNotSupported as m, CliErrorEnvelope as n, errorContractConfigMissing as o, errorInvalidOutputFormat as p, CliStructuredError as r, errorContractMissingExtensionPacks as s, CliErrorConflict as t, errorDriverRequired as u, errorOutputFormatMutex as v, errorUnexpected as x, errorQueryRunnerFactoryRequired as y };
215
+ //# sourceMappingURL=control-_u-dzLnw.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-BtdiadMy.d.mts","names":[],"sources":["../src/control.ts"],"mappings":";;AAIA;;;UAAiB,gBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,KAAA;IAAA,SAEM,IAAA;IAAA,SACA,IAAA;EAAA;EAAA,SAGN,IAAA,EAAM,MAAA;EAAA,SACN,OAAA;AAAA;;AAMX;;UAAiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;AAAA;;;AACV;;;;;AAoBD;;;;;AAMA;;;;cARM,iBAAA;AAAA,KAEM,cAAA,WAAyB,iBAAA;;;;;cAMxB,kBAAA,SAA2B,KAAA;EAAA,SAC7B,IAAA;EAAA,SACA,MAAA,EAAQ,cAAA;EAAA,SACR,QAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,KAAA;IAAA,SAEM,IAAA;IAAA,SACA,IAAA;EAAA;EAAA,SAGN,IAAA,EAAM,MAAA;EAAA,SACN,OAAA;cAGP,IAAA,UACA,OAAA,UACA,OAAA;IAAA,SACW,MAAA,GAAS,cAAA;IAAA,SACT,QAAA;IAAA,SACA,GAAA;IAAA,SACA,GAAA;IAAA,SACA,KAAA;MAAA,SAAmB,IAAA;MAAA,SAAwB,IAAA;IAAA;IAAA,SAC3C,IAAA,GAAO,MAAA;IAAA,SACP,OAAA;EAAA;EAFmB;;;EAyBhC,UAAA,CAAA,GAAc,gBAAA;EAvBD;;;;EAAA,OA0CN,EAAA,CAAG,KAAA,YAAiB,KAAA,IAAS,kBAAA;AAAA;;;;iBA6CtB,uBAAA,CACd,UAAA,WACA,OAAA;EAAA,SACW,GAAA;AAAA,IAEV,kBAAA;;;;iBAaa,0BAAA,CAA2B,OAAA;EAAA,SACh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,sBAAA,CAAA,GAA0B,kBAAA;;;AAzE1C;iBAoFgB,qBAAA,CACd,KAAA,UACA,OAAA;EAAA,SACW,GAAA;AAAA,IAEV,kBAAA;;;;iBAgBa,eAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;AAAA,IAEV,kBAAA"}
@@ -1,2 +1,2 @@
1
- import { _ as errorQueryRunnerFactoryRequired, a as errorConfigValidation, c as errorContractValidationFailed, d as errorFamilyReadMarkerSqlRequired, f as errorFileNotFound, g as errorMigrationPlanningFailed, h as errorMigrationCliUnknownFlag, i as errorConfigFileNotFound, l as errorDatabaseConnectionRequired, m as errorMigrationCliInvalidConfigArg, n as CliErrorEnvelope, o as errorContractConfigMissing, p as errorJsonFormatNotSupported, r as CliStructuredError, s as errorContractMissingExtensionPacks, t as CliErrorConflict, u as errorDriverRequired, v as errorTargetMigrationNotSupported, y as errorUnexpected } from "./control-BtdiadMy.mjs";
2
- export { type CliErrorConflict, type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
1
+ import { _ as errorMigrationPlanningFailed, a as errorConfigValidation, b as errorTargetMigrationNotSupported, c as errorContractValidationFailed, d as errorFamilyReadMarkerSqlRequired, f as errorFileNotFound, g as errorMigrationCliUnknownFlag, h as errorMigrationCliInvalidConfigArg, i as errorConfigFileNotFound, l as errorDatabaseConnectionRequired, m as errorJsonFormatNotSupported, n as CliErrorEnvelope, o as errorContractConfigMissing, p as errorInvalidOutputFormat, r as CliStructuredError, s as errorContractMissingExtensionPacks, t as CliErrorConflict, u as errorDriverRequired, v as errorOutputFormatMutex, x as errorUnexpected, y as errorQueryRunnerFactoryRequired } from "./control-_u-dzLnw.mjs";
2
+ export { type CliErrorConflict, type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorInvalidOutputFormat, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorOutputFormatMutex, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
package/dist/control.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as errorUnexpected, a as errorContractMissingExtensionPacks, c as errorDriverRequired, d as errorJsonFormatNotSupported, f as errorMigrationCliInvalidConfigArg, g as errorTargetMigrationNotSupported, h as errorQueryRunnerFactoryRequired, i as errorContractConfigMissing, l as errorFamilyReadMarkerSqlRequired, m as errorMigrationPlanningFailed, n as errorConfigFileNotFound, o as errorContractValidationFailed, p as errorMigrationCliUnknownFlag, r as errorConfigValidation, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFileNotFound } from "./control-B61eSDwG.mjs";
2
- export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
1
+ import { _ as errorQueryRunnerFactoryRequired, a as errorContractMissingExtensionPacks, c as errorDriverRequired, d as errorInvalidOutputFormat, f as errorJsonFormatNotSupported, g as errorOutputFormatMutex, h as errorMigrationPlanningFailed, i as errorContractConfigMissing, l as errorFamilyReadMarkerSqlRequired, m as errorMigrationCliUnknownFlag, n as errorConfigFileNotFound, o as errorContractValidationFailed, p as errorMigrationCliInvalidConfigArg, r as errorConfigValidation, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFileNotFound, v as errorTargetMigrationNotSupported, y as errorUnexpected } from "./control-DOc6vx43.mjs";
2
+ export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorInvalidOutputFormat, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorOutputFormatMutex, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
@@ -1,4 +1,4 @@
1
- import { r as CliStructuredError } from "./control-BtdiadMy.mjs";
1
+ import { r as CliStructuredError } from "./control-_u-dzLnw.mjs";
2
2
  import { SchemaIssue, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
3
3
 
4
4
  //#region src/execution.d.ts
@@ -22,6 +22,34 @@ declare function errorHashMismatch(options?: {
22
22
  declare function errorTargetMismatch(expected: string, actual: string, options?: {
23
23
  readonly why?: string;
24
24
  }): CliStructuredError;
25
+ /**
26
+ * Marker row exists but column values fail schema validation.
27
+ */
28
+ declare function errorMarkerRowCorrupt(options: {
29
+ readonly why: string;
30
+ readonly space: string;
31
+ readonly markerLocation: string;
32
+ }): CliStructuredError;
33
+ /**
34
+ * Driver-level failure while reading the contract marker table.
35
+ */
36
+ declare function errorMarkerReadFailed(options: {
37
+ readonly why: string;
38
+ readonly space: string;
39
+ readonly markerLocation: string;
40
+ }): CliStructuredError;
41
+ declare function rethrowMarkerReadError(err: unknown, context: {
42
+ readonly space: string;
43
+ readonly markerLocation: string;
44
+ }): never;
45
+ declare function withMarkerReadErrorHandling<T>(operation: () => Promise<T>, context: {
46
+ readonly space: string;
47
+ readonly markerLocation: string;
48
+ }): Promise<T>;
49
+ declare function parseMarkerRowSafely<T>(row: unknown, parse: (value: unknown) => T, context: {
50
+ readonly space: string;
51
+ readonly markerLocation: string;
52
+ }): T;
25
53
  /**
26
54
  * Database marker is required but not found.
27
55
  * Used by commands that require a pre-existing marker as a precondition.
@@ -66,5 +94,5 @@ declare function errorRuntime(summary: string, options?: {
66
94
  readonly meta?: Record<string, unknown>;
67
95
  }): CliStructuredError;
68
96
  //#endregion
69
- export { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorMarkerRequired, errorRunnerFailed, errorRuntime, errorSchemaVerificationFailed, errorTargetMismatch };
97
+ export { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorMarkerReadFailed, errorMarkerRequired, errorMarkerRowCorrupt, errorRunnerFailed, errorRuntime, errorSchemaVerificationFailed, errorTargetMismatch, parseMarkerRowSafely, rethrowMarkerReadError, withMarkerReadErrorHandling };
70
98
  //# sourceMappingURL=execution.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution.ts"],"mappings":";;;;;;AAcA;iBAAgB,kBAAA,CAAmB,OAAA;EAAA,SAAqB,GAAA;AAAA,IAAiB,kBAAA;;;;iBAWzD,iBAAA,CAAkB,OAAA;EAAA,SACvB,GAAA;EAAA,SACA,QAAA;EAAA,SACA,MAAA;AAAA,IACP,kBAAA;;;;iBAmBY,mBAAA,CACd,QAAA,UACA,MAAA,UACA,OAAA;EAAA,SACW,GAAA;AAAA,IAEV,kBAAA;;;AANH;;iBAqBgB,mBAAA,CAAoB,OAAA;EAAA,SACzB,GAAA;EAAA,SACA,GAAA;AAAA,IACP,kBAAA;;;;;iBAYY,6BAAA,CAA8B,OAAA;EAAA,SACnC,OAAA;EAAA,SACA,kBAAA,EAAoB,0BAAA;EAAA,SACpB,MAAA,YAAkB,WAAA;AAAA,IACzB,kBAAA;;;;iBAeY,iBAAA,C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A,SAAoB,KAAA;EAAA,SAAwB,cAAA;AAAA,IAC3C,CAAA;;;;;iBAYa,mBAAA,CAAoB,OAAA;EAAA,SACzB,GAAA;EAAA,SACA,GAAA;AAAA,IACP,kBAAA;;;;;iBAYY,6BAAA,CAA8B,OAAA;EAAA,SACnC,OAAA;EAAA,SACA,kBAAA,EAAoB,0BAAA;EAAA,SACpB,MAAA,YAAkB,WAAA;AAAA,IACzB,kBAAA;AA9CJ;;;AAAA,iBA6DgB,iBAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA,GAAO,MAAA;AAAA,IAEjB,kBAAA;;cAUU,8BAAA;;;;iBAKG,uBAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA,GAAO,MAAA;AAAA,IAEjB,kBAAA;;;AA/EH;iBA2FgB,YAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA,GAAO,MAAA;AAAA,IAEjB,kBAAA"}
@@ -1,4 +1,4 @@
1
- import { t as CliStructuredError } from "./control-B61eSDwG.mjs";
1
+ import { t as CliStructuredError } from "./control-DOc6vx43.mjs";
2
2
  import { ifDefined } from "@prisma-next/utils/defined";
3
3
  //#region src/execution.ts
4
4
  /**
@@ -40,6 +40,77 @@ function errorTargetMismatch(expected, actual, options) {
40
40
  });
41
41
  }
42
42
  /**
43
+ * Marker row exists but column values fail schema validation.
44
+ */
45
+ function errorMarkerRowCorrupt(options) {
46
+ return new CliStructuredError("3005", "Marker row is corrupt or incompatible", {
47
+ domain: "RUN",
48
+ why: options.why,
49
+ fix: `The ${options.markerLocation} row for space "${options.space}" contains invalid data. Delete the row, then run \`prisma-next db sign --db <url>\` to write a fresh marker.`,
50
+ meta: { space: options.space }
51
+ });
52
+ }
53
+ /**
54
+ * Driver-level failure while reading the contract marker table.
55
+ */
56
+ function errorMarkerReadFailed(options) {
57
+ return new CliStructuredError("3006", "Database error while reading contract marker", {
58
+ domain: "RUN",
59
+ why: options.why,
60
+ fix: `Could not read marker at ${options.markerLocation} for space "${options.space}". Verify read permissions, connectivity, and locks, then retry.`,
61
+ meta: { space: options.space }
62
+ });
63
+ }
64
+ function isMarkerRowParseError(err) {
65
+ return err instanceof Error && (err.message.startsWith("Invalid contract marker row:") || err.message.startsWith("Invalid marker doc on"));
66
+ }
67
+ function isLegacyMarkerShapeReadError(message) {
68
+ const normalized = message.toLowerCase();
69
+ return normalized.includes("column \"space\" does not exist") || normalized.includes("no such column: space");
70
+ }
71
+ function errorLegacyMarkerShape(options) {
72
+ return errorRunnerFailed(`Legacy marker-table shape detected on ${options.markerLocation} (no \`space\` column). Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop \`${options.markerLocation}\` and re-run \`prisma-next db init\` to reinitialise from a clean baseline.`, {
73
+ why: options.why,
74
+ fix: "Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.",
75
+ meta: {
76
+ code: "RUNNER_FAILED",
77
+ runnerErrorCode: "LEGACY_MARKER_SHAPE"
78
+ }
79
+ });
80
+ }
81
+ function rethrowMarkerReadError(err, context) {
82
+ if (CliStructuredError.is(err)) throw err;
83
+ if (isMarkerRowParseError(err)) throw errorMarkerRowCorrupt({
84
+ why: err.message,
85
+ space: context.space,
86
+ markerLocation: context.markerLocation
87
+ });
88
+ const message = err instanceof Error ? err.message : String(err);
89
+ if (isLegacyMarkerShapeReadError(message)) throw errorLegacyMarkerShape({
90
+ why: message,
91
+ markerLocation: context.markerLocation
92
+ });
93
+ throw errorMarkerReadFailed({
94
+ why: message,
95
+ space: context.space,
96
+ markerLocation: context.markerLocation
97
+ });
98
+ }
99
+ async function withMarkerReadErrorHandling(operation, context) {
100
+ try {
101
+ return await operation();
102
+ } catch (err) {
103
+ rethrowMarkerReadError(err, context);
104
+ }
105
+ }
106
+ function parseMarkerRowSafely(row, parse, context) {
107
+ try {
108
+ return parse(row);
109
+ } catch (err) {
110
+ rethrowMarkerReadError(err, context);
111
+ }
112
+ }
113
+ /**
43
114
  * Database marker is required but not found.
44
115
  * Used by commands that require a pre-existing marker as a precondition.
45
116
  */
@@ -101,6 +172,6 @@ function errorRuntime(summary, options) {
101
172
  });
102
173
  }
103
174
  //#endregion
104
- export { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorMarkerRequired, errorRunnerFailed, errorRuntime, errorSchemaVerificationFailed, errorTargetMismatch };
175
+ export { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorMarkerReadFailed, errorMarkerRequired, errorMarkerRowCorrupt, errorRunnerFailed, errorRuntime, errorSchemaVerificationFailed, errorTargetMismatch, parseMarkerRowSafely, rethrowMarkerReadError, withMarkerReadErrorHandling };
105
176
 
106
177
  //# sourceMappingURL=execution.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution.mjs","names":[],"sources":["../src/execution.ts"],"sourcesContent":["import type {\n SchemaIssue,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { CliStructuredError } from './control';\n\n// ============================================================================\n// Runtime Errors (PN-RUN-3000-3030)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('3001', 'Database not signed', {\n domain: 'RUN',\n why: options?.why ?? 'No database signature (marker) found',\n fix: 'Run `prisma-next db sign --db <url>` to sign the database',\n });\n}\n\n/**\n * Contract hash does not match database marker.\n */\nexport function errorHashMismatch(options?: {\n readonly why?: string;\n readonly expected?: string;\n readonly actual?: string;\n}): CliStructuredError {\n return new CliStructuredError('3002', 'Hash mismatch', {\n domain: 'RUN',\n why: options?.why ?? 'Contract hash does not match database marker',\n fix: 'Migrate database or re-sign if intentional',\n ...(options?.expected !== undefined || options?.actual !== undefined\n ? {\n meta: {\n ...ifDefined('expected', options?.expected),\n ...ifDefined('actual', options?.actual),\n },\n }\n : {}),\n });\n}\n\n/**\n * Contract target does not match config target.\n */\nexport function errorTargetMismatch(\n expected: string,\n actual: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('3003', 'Target mismatch', {\n domain: 'RUN',\n why:\n options?.why ??\n `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,\n fix: 'Align contract target and config target',\n meta: { expected, actual },\n });\n}\n\n/**\n * Database marker is required but not found.\n * Used by commands that require a pre-existing marker as a precondition.\n */\nexport function errorMarkerRequired(options?: {\n readonly why?: string;\n readonly fix?: string;\n}): CliStructuredError {\n return new CliStructuredError('3010', 'Database must be signed first', {\n domain: 'RUN',\n why: options?.why ?? 'No database signature (marker) found',\n fix: options?.fix ?? 'Run `prisma-next db init` first to sign the database',\n });\n}\n\n/**\n * Schema verification found mismatches between the database and the contract.\n * The full verification tree is preserved in `meta.verificationResult`.\n */\nexport function errorSchemaVerificationFailed(options: {\n readonly summary: string;\n readonly verificationResult: VerifyDatabaseSchemaResult;\n readonly issues?: readonly SchemaIssue[];\n}): CliStructuredError {\n return new CliStructuredError('3004', options.summary, {\n domain: 'RUN',\n why: 'Database schema does not satisfy the contract',\n fix: 'Run `prisma-next db update` to reconcile, or adjust your contract to match the database',\n meta: {\n verificationResult: options.verificationResult,\n ...ifDefined('issues', options.issues),\n },\n });\n}\n\n/**\n * Migration runner failed during execution.\n */\nexport function errorRunnerFailed(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError('3020', summary, {\n domain: 'RUN',\n why: options?.why ?? 'Migration runner failed',\n fix: options?.fix ?? 'Inspect the reported conflict and reconcile schema drift',\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n\n/** Error code for destructive changes that require explicit confirmation. */\nexport const ERROR_CODE_DESTRUCTIVE_CHANGES = '3030';\n\n/**\n * Destructive operations require explicit confirmation via -y/--yes.\n */\nexport function errorDestructiveChanges(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError(ERROR_CODE_DESTRUCTIVE_CHANGES, summary, {\n domain: 'RUN',\n why: options?.why ?? 'Planned operations include destructive changes that require confirmation',\n fix: options?.fix ?? 'Re-run with `-y` to apply, or use `--dry-run` to preview first',\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n\n/**\n * Generic runtime error.\n */\nexport function errorRuntime(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError('3000', summary, {\n domain: 'RUN',\n ...(options?.why ? { why: options.why } : { why: 'Verification failed' }),\n ...(options?.fix ? { fix: options.fix } : { fix: 'Check contract and database state' }),\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,SAAyD;CAC1F,OAAO,IAAI,mBAAmB,QAAQ,uBAAuB;EAC3D,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACN,CAAC;;;;;AAMJ,SAAgB,kBAAkB,SAIX;CACrB,OAAO,IAAI,mBAAmB,QAAQ,iBAAiB;EACrD,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACL,GAAI,SAAS,aAAa,KAAA,KAAa,SAAS,WAAW,KAAA,IACvD,EACE,MAAM;GACJ,GAAG,UAAU,YAAY,SAAS,SAAS;GAC3C,GAAG,UAAU,UAAU,SAAS,OAAO;GACxC,EACF,GACD,EAAE;EACP,CAAC;;;;;AAMJ,SAAgB,oBACd,UACA,QACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,mBAAmB;EACvD,QAAQ;EACR,K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ution.mjs","names":[],"sources":["../src/execution.ts"],"sourcesContent":["import type {\n SchemaIssue,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { CliStructuredError } from './control';\n\n// ============================================================================\n// Runtime Errors (PN-RUN-3000-3030)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('3001', 'Database not signed', {\n domain: 'RUN',\n why: options?.why ?? 'No database signature (marker) found',\n fix: 'Run `prisma-next db sign --db <url>` to sign the database',\n });\n}\n\n/**\n * Contract hash does not match database marker.\n */\nexport function errorHashMismatch(options?: {\n readonly why?: string;\n readonly expected?: string;\n readonly actual?: string;\n}): CliStructuredError {\n return new CliStructuredError('3002', 'Hash mismatch', {\n domain: 'RUN',\n why: options?.why ?? 'Contract hash does not match database marker',\n fix: 'Migrate database or re-sign if intentional',\n ...(options?.expected !== undefined || options?.actual !== undefined\n ? {\n meta: {\n ...ifDefined('expected', options?.expected),\n ...ifDefined('actual', options?.actual),\n },\n }\n : {}),\n });\n}\n\n/**\n * Contract target does not match config target.\n */\nexport function errorTargetMismatch(\n expected: string,\n actual: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('3003', 'Target mismatch', {\n domain: 'RUN',\n why:\n options?.why ??\n `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,\n fix: 'Align contract target and config target',\n meta: { expected, actual },\n });\n}\n\n/**\n * Marker row exists but column values fail schema validation.\n */\nexport function errorMarkerRowCorrupt(options: {\n readonly why: string;\n readonly space: string;\n readonly markerLocation: string;\n}): CliStructuredError {\n return new CliStructuredError('3005', 'Marker row is corrupt or incompatible', {\n domain: 'RUN',\n why: options.why,\n fix: `The ${options.markerLocation} row for space \"${options.space}\" contains invalid data. Delete the row, then run \\`prisma-next db sign --db <url>\\` to write a fresh marker.`,\n meta: { space: options.space },\n });\n}\n\n/**\n * Driver-level failure while reading the contract marker table.\n */\nexport function errorMarkerReadFailed(options: {\n readonly why: string;\n readonly space: string;\n readonly markerLocation: string;\n}): CliStructuredError {\n return new CliStructuredError('3006', 'Database error while reading contract marker', {\n domain: 'RUN',\n why: options.why,\n fix: `Could not read marker at ${options.markerLocation} for space \"${options.space}\". Verify read permissions, connectivity, and locks, then retry.`,\n meta: { space: options.space },\n });\n}\n\nfunction isMarkerRowParseError(err: unknown): err is Error {\n return (\n err instanceof Error &&\n (err.message.startsWith('Invalid contract marker row:') ||\n err.message.startsWith('Invalid marker doc on'))\n );\n}\n\nfunction isLegacyMarkerShapeReadError(message: string): boolean {\n const normalized = message.toLowerCase();\n return (\n normalized.includes('column \"space\" does not exist') ||\n normalized.includes('no such column: space')\n );\n}\n\nfunction errorLegacyMarkerShape(options: {\n readonly why: string;\n readonly markerLocation: string;\n}): CliStructuredError {\n return errorRunnerFailed(\n `Legacy marker-table shape detected on ${options.markerLocation} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${options.markerLocation}\\` and re-run \\`prisma-next db init\\` to reinitialise from a clean baseline.`,\n {\n why: options.why,\n fix: 'Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.',\n meta: { code: 'RUNNER_FAILED', runnerErrorCode: 'LEGACY_MARKER_SHAPE' },\n },\n );\n}\n\nexport function rethrowMarkerReadError(\n err: unknown,\n context: { readonly space: string; readonly markerLocation: string },\n): never {\n if (CliStructuredError.is(err)) {\n throw err;\n }\n if (isMarkerRowParseError(err)) {\n throw errorMarkerRowCorrupt({\n why: err.message,\n space: context.space,\n markerLocation: context.markerLocation,\n });\n }\n const message = err instanceof Error ? err.message : String(err);\n if (isLegacyMarkerShapeReadError(message)) {\n throw errorLegacyMarkerShape({\n why: message,\n markerLocation: context.markerLocation,\n });\n }\n throw errorMarkerReadFailed({\n why: message,\n space: context.space,\n markerLocation: context.markerLocation,\n });\n}\n\nexport async function withMarkerReadErrorHandling<T>(\n operation: () => Promise<T>,\n context: { readonly space: string; readonly markerLocation: string },\n): Promise<T> {\n try {\n return await operation();\n } catch (err) {\n rethrowMarkerReadError(err, context);\n }\n}\n\nexport function parseMarkerRowSafely<T>(\n row: unknown,\n parse: (value: unknown) => T,\n context: { readonly space: string; readonly markerLocation: string },\n): T {\n try {\n return parse(row);\n } catch (err) {\n rethrowMarkerReadError(err, context);\n }\n}\n\n/**\n * Database marker is required but not found.\n * Used by commands that require a pre-existing marker as a precondition.\n */\nexport function errorMarkerRequired(options?: {\n readonly why?: string;\n readonly fix?: string;\n}): CliStructuredError {\n return new CliStructuredError('3010', 'Database must be signed first', {\n domain: 'RUN',\n why: options?.why ?? 'No database signature (marker) found',\n fix: options?.fix ?? 'Run `prisma-next db init` first to sign the database',\n });\n}\n\n/**\n * Schema verification found mismatches between the database and the contract.\n * The full verification tree is preserved in `meta.verificationResult`.\n */\nexport function errorSchemaVerificationFailed(options: {\n readonly summary: string;\n readonly verificationResult: VerifyDatabaseSchemaResult;\n readonly issues?: readonly SchemaIssue[];\n}): CliStructuredError {\n return new CliStructuredError('3004', options.summary, {\n domain: 'RUN',\n why: 'Database schema does not satisfy the contract',\n fix: 'Run `prisma-next db update` to reconcile, or adjust your contract to match the database',\n meta: {\n verificationResult: options.verificationResult,\n ...ifDefined('issues', options.issues),\n },\n });\n}\n\n/**\n * Migration runner failed during execution.\n */\nexport function errorRunnerFailed(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError('3020', summary, {\n domain: 'RUN',\n why: options?.why ?? 'Migration runner failed',\n fix: options?.fix ?? 'Inspect the reported conflict and reconcile schema drift',\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n\n/** Error code for destructive changes that require explicit confirmation. */\nexport const ERROR_CODE_DESTRUCTIVE_CHANGES = '3030';\n\n/**\n * Destructive operations require explicit confirmation via -y/--yes.\n */\nexport function errorDestructiveChanges(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError(ERROR_CODE_DESTRUCTIVE_CHANGES, summary, {\n domain: 'RUN',\n why: options?.why ?? 'Planned operations include destructive changes that require confirmation',\n fix: options?.fix ?? 'Re-run with `-y` to apply, or use `--dry-run` to preview first',\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n\n/**\n * Generic runtime error.\n */\nexport function errorRuntime(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError('3000', summary, {\n domain: 'RUN',\n ...(options?.why ? { why: options.why } : { why: 'Verification failed' }),\n ...(options?.fix ? { fix: options.fix } : { fix: 'Check contract and database state' }),\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,SAAyD;CAC1F,OAAO,IAAI,mBAAmB,QAAQ,uBAAuB;EAC3D,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACN,CAAC;;;;;AAMJ,SAAgB,kBAAkB,SAIX;CACrB,OAAO,IAAI,mBAAmB,QAAQ,iBAAiB;EACrD,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACL,GAAI,SAAS,aAAa,KAAA,KAAa,SAAS,WAAW,KAAA,IACvD,EACE,MAAM;GACJ,GAAG,UAAU,YAAY,SAAS,SAAS;GAC3C,GAAG,UAAU,UAAU,SAAS,OAAO;GACxC,EACF,GACD,EAAE;EACP,CAAC;;;;;AAMJ,SAAgB,oBACd,UACA,QACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,mBAAmB;EACvD,QAAQ;EACR,KACE,SAAS,OACT,2DAA2D,SAAS,YAAY,OAAO;EACzF,KAAK;E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AAG,EAAE,KAAK,uBAAuB;EACxE,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,KAAK,GAAG,EAAE,KAAK,qCAAqC;EACtF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,MAAM,GAAG,EAAE;EAChD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as CliStructuredError } from "./control-BtdiadMy.mjs";
1
+ import { r as CliStructuredError } from "./control-_u-dzLnw.mjs";
2
2
 
3
3
  //#region src/migration.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as CliStructuredError } from "./control-B61eSDwG.mjs";
1
+ import { t as CliStructuredError } from "./control-DOc6vx43.mjs";
2
2
  //#region src/migration.ts
3
3
  /**
4
4
  * A scaffolded migration contains a placeholder slot that was never filled in.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@prisma-next/errors",
3
- "version": "0.10.0-dev.9",
3
+ "version": "0.11.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Structured error types for Prisma Next control and execution planes",
8
8
  "dependencies": {
9
- "@prisma-next/framework-components": "0.10.0-dev.9",
10
- "@prisma-next/utils": "0.10.0-dev.9"
9
+ "@prisma-next/framework-components": "0.11.0",
10
+ "@prisma-next/utils": "0.11.0"
11
11
  },
12
12
  "devDependencies": {
13
- "@prisma-next/tsconfig": "0.10.0-dev.9",
14
- "@prisma-next/tsdown": "0.10.0-dev.9",
13
+ "@prisma-next/tsconfig": "0.11.0",
14
+ "@prisma-next/tsdown": "0.11.0",
15
15
  "tsdown": "0.22.0",
16
16
  "typescript": "5.9.3",
17
17
  "vitest": "4.1.6"
package/src/control.ts CHANGED
@@ -420,6 +420,32 @@ export function errorMigrationCliUnknownFlag(options: {
420
420
  });
421
421
  }
422
422
 
423
+ /**
424
+ * The main CLI received an unsupported `--format` value.
425
+ */
426
+ export function errorInvalidOutputFormat(value: string): CliStructuredError {
427
+ return new CliStructuredError(
428
+ '4014',
429
+ `Invalid --format value "${value}". Allowed values: pretty, json.`,
430
+ {
431
+ domain: 'CLI',
432
+ meta: { value, allowed: ['pretty', 'json'] as const },
433
+ },
434
+ );
435
+ }
436
+
437
+ /**
438
+ * The main CLI received mutually exclusive output format flags
439
+ * (`--format pretty` together with `--json`).
440
+ */
441
+ export function errorOutputFormatMutex(): CliStructuredError {
442
+ return new CliStructuredError(
443
+ '4015',
444
+ 'Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.',
445
+ { domain: 'CLI' },
446
+ );
447
+ }
448
+
423
449
  /**
424
450
  * Config validation error (missing required fields).
425
451
  */
package/src/execution.ts CHANGED
@@ -63,6 +63,121 @@ export function errorTargetMismatch(
63
63
  });
64
64
  }
65
65
 
66
+ /**
67
+ * Marker row exists but column values fail schema validation.
68
+ */
69
+ export function errorMarkerRowCorrupt(options: {
70
+ readonly why: string;
71
+ readonly space: string;
72
+ readonly markerLocation: string;
73
+ }): CliStructuredError {
74
+ return new CliStructuredError('3005', 'Marker row is corrupt or incompatible', {
75
+ domain: 'RUN',
76
+ why: options.why,
77
+ fix: `The ${options.markerLocation} row for space "${options.space}" contains invalid data. Delete the row, then run \`prisma-next db sign --db <url>\` to write a fresh marker.`,
78
+ meta: { space: options.space },
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Driver-level failure while reading the contract marker table.
84
+ */
85
+ export function errorMarkerReadFailed(options: {
86
+ readonly why: string;
87
+ readonly space: string;
88
+ readonly markerLocation: string;
89
+ }): CliStructuredError {
90
+ return new CliStructuredError('3006', 'Database error while reading contract marker', {
91
+ domain: 'RUN',
92
+ why: options.why,
93
+ fix: `Could not read marker at ${options.markerLocation} for space "${options.space}". Verify read permissions, connectivity, and locks, then retry.`,
94
+ meta: { space: options.space },
95
+ });
96
+ }
97
+
98
+ function isMarkerRowParseError(err: unknown): err is Error {
99
+ return (
100
+ err instanceof Error &&
101
+ (err.message.startsWith('Invalid contract marker row:') ||
102
+ err.message.startsWith('Invalid marker doc on'))
103
+ );
104
+ }
105
+
106
+ function isLegacyMarkerShapeReadError(message: string): boolean {
107
+ const normalized = message.toLowerCase();
108
+ return (
109
+ normalized.includes('column "space" does not exist') ||
110
+ normalized.includes('no such column: space')
111
+ );
112
+ }
113
+
114
+ function errorLegacyMarkerShape(options: {
115
+ readonly why: string;
116
+ readonly markerLocation: string;
117
+ }): CliStructuredError {
118
+ return errorRunnerFailed(
119
+ `Legacy marker-table shape detected on ${options.markerLocation} (no \`space\` column). ` +
120
+ 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +
121
+ `Drop \`${options.markerLocation}\` and re-run \`prisma-next db init\` to reinitialise from a clean baseline.`,
122
+ {
123
+ why: options.why,
124
+ fix: 'Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.',
125
+ meta: { code: 'RUNNER_FAILED', runnerErrorCode: 'LEGACY_MARKER_SHAPE' },
126
+ },
127
+ );
128
+ }
129
+
130
+ export function rethrowMarkerReadError(
131
+ err: unknown,
132
+ context: { readonly space: string; readonly markerLocation: string },
133
+ ): never {
134
+ if (CliStructuredError.is(err)) {
135
+ throw err;
136
+ }
137
+ if (isMarkerRowParseError(err)) {
138
+ throw errorMarkerRowCorrupt({
139
+ why: err.message,
140
+ space: context.space,
141
+ markerLocation: context.markerLocation,
142
+ });
143
+ }
144
+ const message = err instanceof Error ? err.message : String(err);
145
+ if (isLegacyMarkerShapeReadError(message)) {
146
+ throw errorLegacyMarkerShape({
147
+ why: message,
148
+ markerLocation: context.markerLocation,
149
+ });
150
+ }
151
+ throw errorMarkerReadFailed({
152
+ why: message,
153
+ space: context.space,
154
+ markerLocation: context.markerLocation,
155
+ });
156
+ }
157
+
158
+ export async function withMarkerReadErrorHandling<T>(
159
+ operation: () => Promise<T>,
160
+ context: { readonly space: string; readonly markerLocation: string },
161
+ ): Promise<T> {
162
+ try {
163
+ return await operation();
164
+ } catch (err) {
165
+ rethrowMarkerReadError(err, context);
166
+ }
167
+ }
168
+
169
+ export function parseMarkerRowSafely<T>(
170
+ row: unknown,
171
+ parse: (value: unknown) => T,
172
+ context: { readonly space: string; readonly markerLocation: string },
173
+ ): T {
174
+ try {
175
+ return parse(row);
176
+ } catch (err) {
177
+ rethrowMarkerReadError(err, context);
178
+ }
179
+ }
180
+
66
181
  /**
67
182
  * Database marker is required but not found.
68
183
  * Used by commands that require a pre-existing marker as a precondition.
@@ -10,10 +10,12 @@ export {
10
10
  errorDriverRequired,
11
11
  errorFamilyReadMarkerSqlRequired,
12
12
  errorFileNotFound,
13
+ errorInvalidOutputFormat,
13
14
  errorJsonFormatNotSupported,
14
15
  errorMigrationCliInvalidConfigArg,
15
16
  errorMigrationCliUnknownFlag,
16
17
  errorMigrationPlanningFailed,
18
+ errorOutputFormatMutex,
17
19
  errorQueryRunnerFactoryRequired,
18
20
  errorTargetMigrationNotSupported,
19
21
  errorUnexpected,
@@ -3,9 +3,14 @@ export {
3
3
  errorDestructiveChanges,
4
4
  errorHashMismatch,
5
5
  errorMarkerMissing,
6
+ errorMarkerReadFailed,
6
7
  errorMarkerRequired,
8
+ errorMarkerRowCorrupt,
7
9
  errorRunnerFailed,
8
10
  errorRuntime,
9
11
  errorSchemaVerificationFailed,
10
12
  errorTargetMismatch,
13
+ parseMarkerRowSafely,
14
+ rethrowMarkerReadError,
15
+ withMarkerReadErrorHandling,
11
16
  } from '../execution';