🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/errors

Package Overview
Dependencies
Maintainers
4
Versions
533
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/errors - npm Package Compare versions

Comparing version
0.15.0
to
0.16.0-dev.1
+283
dist/control-ai0hrdZ4.mjs
import { ifDefined } from "@prisma-next/utils/defined";
//#region src/control.ts
/**
* Structured CLI error that contains all information needed for error envelopes.
* Call sites throw these errors with full context.
*
* A `CliStructuredError` is a `StructuredError` (see
* `@prisma-next/utils/structured-error`): `code` is a dotted
* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's
* category — there is no separate `domain` field. See
* [ADR 239](../../../../../docs/architecture%20docs/adrs/ADR%20239%20-%20Errors%20are%20structural%20envelopes%20with%20dotted%20namespace%20codes.md)
* for the namespace taxonomy.
*/
var CliStructuredError = class extends Error {
code;
severity;
constructor(code, summary, options) {
super(summary);
this.name = "CliStructuredError";
this.code = code;
this.severity = options?.severity ?? "error";
const fix = options?.fix === options?.why ? void 0 : options?.fix;
const where = options?.where ? {
...ifDefined("path", options.where.path),
...ifDefined("line", options.where.line)
} : void 0;
Object.assign(this, {
...ifDefined("why", options?.why),
...ifDefined("fix", fix),
...ifDefined("where", where),
...ifDefined("meta", options?.meta),
...ifDefined("docsUrl", options?.docsUrl)
});
}
/**
* Converts this error to a CLI error envelope for output formatting.
*/
toEnvelope() {
return {
ok: false,
code: this.code,
severity: this.severity,
summary: this.message,
...ifDefined("why", this.why),
...ifDefined("fix", this.fix),
...ifDefined("where", this.where),
...ifDefined("meta", this.meta),
...ifDefined("docsUrl", this.docsUrl)
};
}
/**
* Type guard to check if an error is a CliStructuredError.
* Uses duck-typing to work across module boundaries where instanceof may fail.
*/
static is(error) {
if (!(error instanceof Error)) return false;
const candidate = error;
return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && typeof candidate.toEnvelope === "function";
}
};
/**
* Config file not found or missing.
*/
function errorConfigFileNotFound(configPath, options) {
return new CliStructuredError("CONFIG.FILE_NOT_FOUND", "Config file not found", {
...options?.why ? { why: options.why } : { why: "Config file not found" },
fix: "Run 'prisma-next init' to create a config file",
docsUrl: "https://prisma-next.dev/docs/cli/config",
...configPath ? { where: { path: configPath } } : {}
});
}
/**
* Contract configuration missing from config.
*/
function errorContractConfigMissing(options) {
return new CliStructuredError("CONFIG.CONTRACT_MISSING", "Contract configuration missing", {
why: options?.why ?? "The contract configuration is required for emit",
fix: "Add contract configuration to your prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/contract-emit"
});
}
/**
* Contract validation failed.
*/
function errorContractValidationFailed(reason, options) {
return new CliStructuredError("CONTRACT.VALIDATION_FAILED", "Contract validation failed", {
why: reason,
fix: "Re-run `prisma-next contract emit`, or fix the contract file and try again",
docsUrl: "https://prisma-next.dev/docs/contracts",
...options?.where ? { where: options.where } : {}
});
}
/**
* File not found.
*/
function errorFileNotFound(filePath, options) {
return new CliStructuredError("CLI.FILE_NOT_FOUND", "File not found", {
why: options?.why ?? `File not found: ${filePath}`,
fix: options?.fix ?? "Check that the file path is correct",
where: { path: filePath },
...options?.docsUrl ? { docsUrl: options.docsUrl } : {}
});
}
/**
* Database connection is required but not provided.
*/
function errorDatabaseConnectionRequired(options) {
const runHint = options?.retryCommand ? `Run \`${options.retryCommand}\`` : options?.commandName ? `Run \`prisma-next ${options.commandName} --db <url>\`` : "Provide `--db <url>`";
return new CliStructuredError("CONFIG.DB_CONNECTION_REQUIRED", "Database connection is required", {
why: options?.why ?? "Database connection is required for this command",
fix: `${runHint}, or set \`db: { connection: "postgres://…" }\` in prisma-next.config.ts`,
...options?.missingFlags !== void 0 ? { meta: { missingFlags: [...options.missingFlags] } } : {}
});
}
/**
* Query runner factory is required but not provided in config.
*/
function errorQueryRunnerFactoryRequired(options) {
return new CliStructuredError("CONFIG.QUERY_RUNNER_FACTORY_REQUIRED", "Query runner factory is required", {
why: options?.why ?? "Config.db.queryRunnerFactory is required for db verify",
fix: "Add db.queryRunnerFactory to prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
});
}
/**
* Family verify.readMarker is required but not provided.
*/
function errorFamilyReadMarkerSqlRequired(options) {
return new CliStructuredError("CONFIG.FAMILY_READ_MARKER_REQUIRED", "Family readMarker() is required", {
why: options?.why ?? "Family verify.readMarker is required for db verify",
fix: "Ensure family.verify.readMarker() is exported by your family package",
docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
});
}
/**
* JSON output format not supported.
*/
function errorJsonFormatNotSupported(options) {
return new CliStructuredError("CLI.JSON_FORMAT_UNSUPPORTED", "Unsupported JSON format", {
why: `The ${options.command} command does not support --json ${options.format}`,
fix: `Use --json ${options.supportedFormats.join(" or ")}, or omit --json for human output`,
meta: {
command: options.command,
format: options.format,
supportedFormats: options.supportedFormats
}
});
}
/**
* Driver is required for DB-connected commands but not provided.
*/
function errorDriverRequired(options) {
return new CliStructuredError("CONFIG.DRIVER_REQUIRED", "Driver is required for DB-connected commands", {
why: options?.why ?? "Config.driver is required for DB-connected commands",
fix: "Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)",
docsUrl: "https://prisma-next.dev/docs/cli/config"
});
}
/**
* Contract requires extension packs that are not provided by config descriptors.
*/
function errorContractMissingExtensionPacks(options) {
const missing = [...options.missingExtensionPacks].sort();
return new CliStructuredError("CONFIG.MISSING_EXTENSION_PACKS", "Missing extension packs in config", {
why: missing.length === 1 ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.` : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(", ")}, but CLI config does not provide matching descriptors.`,
fix: "Add the missing extension descriptors to `extensions` in prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/config",
meta: {
missingExtensionPacks: missing,
providedComponentIds: [...options.providedComponentIds].sort()
}
});
}
/**
* Migration planning failed due to conflicts.
*/
function errorMigrationPlanningFailed(options) {
const conflictSummaries = options.conflicts.map((c) => c.summary);
const computedWhy = options.why ?? conflictSummaries.join("\n");
const conflictFixes = options.conflicts.map((c) => c.why).filter((why) => typeof why === "string");
return new CliStructuredError("MIGRATION.PLANNING_FAILED", "Migration planning failed", {
why: computedWhy,
fix: conflictFixes.length > 0 ? conflictFixes.join("\n") : "Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty",
meta: { conflicts: options.conflicts },
docsUrl: "https://prisma-next.dev/docs/cli/db-init"
});
}
/**
* Target does not support migrations (missing createPlanner/createRunner).
*/
function errorTargetMigrationNotSupported(options) {
return new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", "Target does not support migrations", {
why: options?.why ?? "The configured target does not provide migration planner/runner",
fix: "Select a target that provides migrations (it must export `target.migrations` for db init)",
docsUrl: "https://prisma-next.dev/docs/cli/db-init"
});
}
/**
* The migration-file CLI received `--config` without a path argument (either
* a bare trailing `--config`, or `--config` followed by another flag like
* `--config --dry-run`). Surfacing this as a structured error fails fast
* rather than silently consuming the next flag as the config path or
* falling back to default discovery against the wrong project.
*/
function errorMigrationCliInvalidConfigArg(options) {
return new CliStructuredError("CLI.CONFIG_ARG_MISSING_PATH", "--config flag requires a path argument", {
why: options?.nextToken !== void 0 ? `\`--config\` was followed by another flag (\`${options.nextToken}\`) instead of a path argument.` : "`--config` was passed without a following path argument.",
fix: "Pass a config path: `--config <path>` or `--config=<path>`.",
meta: options?.nextToken !== void 0 ? { nextToken: options.nextToken } : {}
});
}
/**
* The migration-file CLI received a flag it does not recognise. Surfaced as a
* structured error so consumers can render their own "did you mean"
* suggestions from `meta.knownFlags` rather than parsing the message.
*
* Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:
* pass the offending token as `flag` and the option declarations as
* `knownFlags`.
*/
function errorMigrationCliUnknownFlag(options) {
const knownList = options.knownFlags.join(", ");
return new CliStructuredError("CLI.UNKNOWN_FLAG", "Unknown migration CLI flag", {
why: `Unknown flag \`${options.flag}\`.`,
fix: `Known flags: ${knownList}. Run with \`--help\` to see the full list.`,
meta: {
flag: options.flag,
knownFlags: options.knownFlags
}
});
}
/**
* The main CLI received an unsupported `--format` value.
*/
function errorInvalidOutputFormat(value) {
return new CliStructuredError("CLI.INVALID_OUTPUT_FORMAT", `Invalid --format value "${value}". Allowed values: pretty, json.`, { meta: {
value,
allowed: ["pretty", "json"]
} });
}
/**
* The main CLI received mutually exclusive output format flags
* (`--format pretty` together with `--json`).
*/
function errorOutputFormatMutex() {
return new CliStructuredError("CLI.OUTPUT_FORMAT_CONFLICT", "Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.");
}
/**
* Config validation error (missing required fields).
*/
function errorConfigValidation(field, options) {
return new CliStructuredError("CONFIG.VALIDATION_FAILED", "Config validation error", {
why: options?.why ?? `Config must have a "${field}" field`,
fix: "Check your prisma-next.config.ts and ensure all required fields are provided",
docsUrl: "https://prisma-next.dev/docs/cli/config"
});
}
/**
* An enum declares a codecId that no component in the contract's pack stack provides,
* so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`
* and PSL interpretation) when the codec lookup built from the contract's packs has no
* descriptor for the codecId.
*/
function errorEnumCodecNotInPackStack(options) {
return new CliStructuredError("CONTRACT.ENUM_CODEC_NOT_IN_PACK_STACK", `Enum codec "${options.codecId}" is not part of the contract's pack stack`, {
why: `An enum uses codec "${options.codecId}", but no family, target, or extension pack in the contract provides it.`,
fix: "Use a codec provided by the contract's target/extension packs, or add the pack that supplies this codec.",
meta: { codecId: options.codecId }
});
}
/**
* Generic unexpected error.
*/
function errorUnexpected(message, options) {
return new CliStructuredError("CLI.UNEXPECTED", "Unexpected error", {
why: options?.why ?? message,
fix: options?.fix ?? "Check the error message and try again"
});
}
//#endregion
export { errorOutputFormatMutex as _, errorContractMissingExtensionPacks as a, errorUnexpected as b, errorDriverRequired as c, errorFileNotFound as d, errorInvalidOutputFormat as f, errorMigrationPlanningFailed as g, errorMigrationCliUnknownFlag as h, errorContractConfigMissing as i, errorEnumCodecNotInPackStack as l, errorMigrationCliInvalidConfigArg as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorJsonFormatNotSupported as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFamilyReadMarkerSqlRequired as u, errorQueryRunnerFactoryRequired as v, errorTargetMigrationNotSupported as y };
//# sourceMappingURL=control-ai0hrdZ4.mjs.map
{"version":3,"file":"control-ai0hrdZ4.mjs","names":[],"sources":["../src/control.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport type { StructuredError } from '@prisma-next/utils/structured-error';\n\n/**\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 severity: 'error' | 'warn' | 'info';\n readonly summary: string;\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/**\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 * Structured CLI error that contains all information needed for error envelopes.\n * Call sites throw these errors with full context.\n *\n * A `CliStructuredError` is a `StructuredError` (see\n * `@prisma-next/utils/structured-error`): `code` is a dotted\n * `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's\n * category — there is no separate `domain` field. See\n * [ADR 239](../../../../../docs/architecture%20docs/adrs/ADR%20239%20-%20Errors%20are%20structural%20envelopes%20with%20dotted%20namespace%20codes.md)\n * for the namespace taxonomy.\n */\nexport class CliStructuredError extends Error implements StructuredError {\n readonly code: `${string}.${string}`;\n readonly severity: 'error' | 'warn' | 'info';\n declare readonly why?: string;\n declare readonly fix?: string;\n declare readonly where?: { readonly path?: string; readonly line?: number };\n declare readonly meta?: Record<string, unknown>;\n declare readonly docsUrl?: string;\n\n constructor(\n code: `${string}.${string}`,\n summary: string,\n options?: {\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.severity = options?.severity ?? 'error';\n const fix = options?.fix === options?.why ? undefined : options?.fix;\n const where = options?.where\n ? { ...ifDefined('path', options.where.path), ...ifDefined('line', options.where.line) }\n : undefined;\n Object.assign(this, {\n ...ifDefined('why', options?.why),\n ...ifDefined('fix', fix),\n ...ifDefined('where', where),\n ...ifDefined('meta', options?.meta),\n ...ifDefined('docsUrl', options?.docsUrl),\n });\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: this.code,\n severity: this.severity,\n summary: this.message,\n ...ifDefined('why', this.why),\n ...ifDefined('fix', this.fix),\n ...ifDefined('where', this.where),\n ...ifDefined('meta', this.meta),\n ...ifDefined('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 typeof candidate.toEnvelope === 'function'\n );\n }\n}\n\n// ============================================================================\n// Config Errors\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('CONFIG.FILE_NOT_FOUND', 'Config file not found', {\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('CONFIG.CONTRACT_MISSING', 'Contract configuration missing', {\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('CONTRACT.VALIDATION_FAILED', 'Contract validation failed', {\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('CLI.FILE_NOT_FOUND', 'File not found', {\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 readonly missingFlags?: readonly 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(\n 'CONFIG.DB_CONNECTION_REQUIRED',\n 'Database connection is required',\n {\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 ...(options?.missingFlags !== undefined\n ? { meta: { missingFlags: [...options.missingFlags] } }\n : {}),\n },\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(\n 'CONFIG.QUERY_RUNNER_FACTORY_REQUIRED',\n 'Query runner factory is required',\n {\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/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError(\n 'CONFIG.FAMILY_READ_MARKER_REQUIRED',\n 'Family readMarker() is required',\n {\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/**\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('CLI.JSON_FORMAT_UNSUPPORTED', 'Unsupported JSON format', {\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(\n 'CONFIG.DRIVER_REQUIRED',\n 'Driver is required for DB-connected commands',\n {\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/**\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(\n 'CONFIG.MISSING_EXTENSION_PACKS',\n 'Missing extension packs in config',\n {\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/**\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('MIGRATION.PLANNING_FAILED', 'Migration planning failed', {\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(\n 'MIGRATION.TARGET_UNSUPPORTED',\n 'Target does not support migrations',\n {\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/**\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(\n 'CLI.CONFIG_ARG_MISSING_PATH',\n '--config flag requires a path argument',\n {\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/**\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('CLI.UNKNOWN_FLAG', 'Unknown migration CLI flag', {\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 'CLI.INVALID_OUTPUT_FORMAT',\n `Invalid --format value \"${value}\". Allowed values: pretty, json.`,\n {\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 'CLI.OUTPUT_FORMAT_CONFLICT',\n 'Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.',\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('CONFIG.VALIDATION_FAILED', 'Config validation error', {\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 * An enum declares a codecId that no component in the contract's pack stack provides,\n * so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`\n * and PSL interpretation) when the codec lookup built from the contract's packs has no\n * descriptor for the codecId.\n */\nexport function errorEnumCodecNotInPackStack(options: {\n readonly codecId: string;\n}): CliStructuredError {\n return new CliStructuredError(\n 'CONTRACT.ENUM_CODEC_NOT_IN_PACK_STACK',\n `Enum codec \"${options.codecId}\" is not part of the contract's pack stack`,\n {\n why: `An enum uses codec \"${options.codecId}\", but no family, target, or extension pack in the contract provides it.`,\n fix: \"Use a codec provided by the contract's target/extension packs, or add the pack that supplies this codec.\",\n meta: { codecId: options.codecId },\n },\n );\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('CLI.UNEXPECTED', 'Unexpected error', {\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,IAAa,qBAAb,cAAwC,MAAiC;CACvE;CACA;CAOA,YACE,MACA,SACA,SAQA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS,YAAY;EACrC,MAAM,MAAM,SAAS,QAAQ,SAAS,MAAM,KAAA,IAAY,SAAS;EACjE,MAAM,QAAQ,SAAS,QACnB;GAAE,GAAG,UAAU,QAAQ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S,cAAc,KAAA,IAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;CAC/E,CACF;AACF;;;;;;;;;;AAWA,SAAgB,6BAA6B,SAGtB;CACrB,MAAM,YAAY,QAAQ,WAAW,KAAK,IAAI;CAC9C,OAAO,IAAI,mBAAmB,oBAAoB,8BAA8B;EAC9E,KAAK,kBAAkB,QAAQ,KAAK;EACpC,KAAK,gBAAgB,UAAU;EAC/B,MAAM;GAAE,MAAM,QAAQ;GAAM,YAAY,QAAQ;EAAW;CAC7D,CAAC;AACH;;;;AAKA,SAAgB,yBAAyB,OAAmC;CAC1E,OAAO,IAAI,mBACT,6BACA,2BAA2B,MAAM,mCACjC,EACE,MAAM;EAAE;EAAO,SAAS,CAAC,UAAU,MAAM;CAAW,EACtD,CACF;AACF;;;;;AAMA,SAAgB,yBAA6C;CAC3D,OAAO,IAAI,mBACT,8BACA,qGACF;AACF;;;;AAKA,SAAgB,sBACd,OACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,4BAA4B,2BAA2B;EACnF,KAAK,SAAS,OAAO,uBAAuB,MAAM;EAClD,KAAK;EACL,SAAS;CACX,CAAC;AACH;;;;;;;AAYA,SAAgB,6BAA6B,SAEtB;CACrB,OAAO,IAAI,mBACT,yCACA,eAAe,QAAQ,QAAQ,6CAC/B;EACE,KAAK,uBAAuB,QAAQ,QAAQ;EAC5C,KAAK;EACL,MAAM,EAAE,SAAS,QAAQ,QAAQ;CACnC,CACF;AACF;;;;AAKA,SAAgB,gBACd,SACA,SAIoB;CACpB,OAAO,IAAI,mBAAmB,kBAAkB,oBAAoB;EAClE,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;CACvB,CAAC;AACH"}
import { StructuredError } from "@prisma-next/utils/structured-error";
//#region src/control.d.ts
/**
* CLI error envelope for output formatting.
* This is the serialized form of a CliStructuredError.
*/
interface CliErrorEnvelope {
readonly ok: false;
readonly code: string;
readonly severity: 'error' | 'warn' | 'info';
readonly summary: string;
readonly why?: string;
readonly fix?: string;
readonly where?: {
readonly path?: string;
readonly line?: number;
};
readonly meta?: Record<string, unknown>;
readonly docsUrl?: string;
}
/**
* Minimal conflict data structure expected by CLI output.
*/
interface CliErrorConflict {
readonly kind: string;
readonly summary: string;
readonly why?: string;
}
/**
* Structured CLI error that contains all information needed for error envelopes.
* Call sites throw these errors with full context.
*
* A `CliStructuredError` is a `StructuredError` (see
* `@prisma-next/utils/structured-error`): `code` is a dotted
* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's
* category — there is no separate `domain` field. See
* [ADR 239](../../../../../docs/architecture%20docs/adrs/ADR%20239%20-%20Errors%20are%20structural%20envelopes%20with%20dotted%20namespace%20codes.md)
* for the namespace taxonomy.
*/
declare class CliStructuredError extends Error implements StructuredError {
readonly code: `${string}.${string}`;
readonly severity: 'error' | 'warn' | 'info';
readonly why?: string;
readonly fix?: string;
readonly where?: {
readonly path?: string;
readonly line?: number;
};
readonly meta?: Record<string, unknown>;
readonly docsUrl?: string;
constructor(code: `${string}.${string}`, summary: string, options?: {
readonly severity?: 'error' | 'warn' | 'info';
readonly why?: string;
readonly fix?: string;
readonly where?: {
readonly path?: string;
readonly line?: number;
};
readonly meta?: Record<string, unknown>;
readonly docsUrl?: string;
});
/**
* Converts this error to a CLI error envelope for output formatting.
*/
toEnvelope(): CliErrorEnvelope;
/**
* Type guard to check if an error is a CliStructuredError.
* Uses duck-typing to work across module boundaries where instanceof may fail.
*/
static is(error: unknown): error is CliStructuredError;
}
/**
* Config file not found or missing.
*/
declare function errorConfigFileNotFound(configPath?: string, options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract configuration missing from config.
*/
declare function errorContractConfigMissing(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract validation failed.
*/
declare function errorContractValidationFailed(reason: string, options?: {
readonly where?: {
readonly path?: string;
readonly line?: number;
};
}): CliStructuredError;
/**
* File not found.
*/
declare function errorFileNotFound(filePath: string, options?: {
readonly why?: string;
readonly fix?: string;
readonly docsUrl?: string;
}): CliStructuredError;
/**
* Database connection is required but not provided.
*/
declare function errorDatabaseConnectionRequired(options?: {
readonly why?: string;
readonly commandName?: string;
readonly retryCommand?: string;
readonly missingFlags?: readonly string[];
}): CliStructuredError;
/**
* Query runner factory is required but not provided in config.
*/
declare function errorQueryRunnerFactoryRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Family verify.readMarker is required but not provided.
*/
declare function errorFamilyReadMarkerSqlRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* JSON output format not supported.
*/
declare function errorJsonFormatNotSupported(options: {
readonly command: string;
readonly format: string;
readonly supportedFormats: readonly string[];
}): CliStructuredError;
/**
* Driver is required for DB-connected commands but not provided.
*/
declare function errorDriverRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract requires extension packs that are not provided by config descriptors.
*/
declare function errorContractMissingExtensionPacks(options: {
readonly missingExtensionPacks: readonly string[];
readonly providedComponentIds: readonly string[];
}): CliStructuredError;
/**
* Migration planning failed due to conflicts.
*/
declare function errorMigrationPlanningFailed(options: {
readonly conflicts: readonly CliErrorConflict[];
readonly why?: string;
}): CliStructuredError;
/**
* Target does not support migrations (missing createPlanner/createRunner).
*/
declare function errorTargetMigrationNotSupported(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* The migration-file CLI received `--config` without a path argument (either
* a bare trailing `--config`, or `--config` followed by another flag like
* `--config --dry-run`). Surfacing this as a structured error fails fast
* rather than silently consuming the next flag as the config path or
* falling back to default discovery against the wrong project.
*/
declare function errorMigrationCliInvalidConfigArg(options?: {
readonly nextToken?: string;
}): CliStructuredError;
/**
* The migration-file CLI received a flag it does not recognise. Surfaced as a
* structured error so consumers can render their own "did you mean"
* suggestions from `meta.knownFlags` rather than parsing the message.
*
* Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:
* pass the offending token as `flag` and the option declarations as
* `knownFlags`.
*/
declare function errorMigrationCliUnknownFlag(options: {
readonly flag: string;
readonly knownFlags: readonly string[];
}): CliStructuredError;
/**
* The main CLI received an unsupported `--format` value.
*/
declare function errorInvalidOutputFormat(value: string): CliStructuredError;
/**
* The main CLI received mutually exclusive output format flags
* (`--format pretty` together with `--json`).
*/
declare function errorOutputFormatMutex(): CliStructuredError;
/**
* Config validation error (missing required fields).
*/
declare function errorConfigValidation(field: string, options?: {
readonly why?: string;
}): CliStructuredError;
/**
* An enum declares a codecId that no component in the contract's pack stack provides,
* so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`
* and PSL interpretation) when the codec lookup built from the contract's packs has no
* descriptor for the codecId.
*/
declare function errorEnumCodecNotInPackStack(options: {
readonly codecId: string;
}): CliStructuredError;
/**
* Generic unexpected error.
*/
declare function errorUnexpected(message: string, options?: {
readonly why?: string;
readonly fix?: string;
}): CliStructuredError;
//#endregion
export { errorUnexpected as S, errorMigrationCliUnknownFlag as _, errorConfigValidation as a, errorQueryRunnerFactoryRequired as b, errorContractValidationFailed as c, errorEnumCodecNotInPackStack as d, errorFamilyReadMarkerSqlRequired as f, errorMigrationCliInvalidConfigArg as g, errorJsonFormatNotSupported as h, errorConfigFileNotFound as i, errorDatabaseConnectionRequired as l, errorInvalidOutputFormat as m, CliErrorEnvelope as n, errorContractConfigMissing as o, errorFileNotFound as p, CliStructuredError as r, errorContractMissingExtensionPacks as s, CliErrorConflict as t, errorDriverRequired as u, errorMigrationPlanningFailed as v, errorTargetMigrationNotSupported as x, errorOutputFormatMutex as y };
//# sourceMappingURL=control-BPZvmSyz.d.mts.map
{"version":3,"file":"control-BPZvmSyz.d.mts","names":[],"sources":["../src/control.ts"],"mappings":";;;;;;UAOiB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;aAAmB;aAAwB;;WAC3C,OAAO;WACP;;;;;UAMM;WACN;WACA;WACA;;;;;;;;;;;;;cAcE,2BAA2B,iBAAiB;WAC9C;WACA;WACQ;WACA;WACA;aAAmB;aAAwB;;WAC3C,OAAO;WACP;cAGf,6BACA,iBACA;aACW;aACA;aACA;aACA;eAAmB;eAAwB;;aAC3C,OAAO;aACP;;;;;EAuBb,cAAc;;;;;SAkBP,GAAG,iBAAiB,SAAS;;;;;iBAoBtB,wBACd,qBACA;WACW;IAEV;;;;iBAYa,2BAA2B;WAChC;IACP;;;;iBAWY,8BACd,gBACA;WACW;aAAmB;aAAwB;;IAErD;;;;iBAYa,kBACd,kBACA;WACW;WACA;WACA;IAEV;;;;iBAYa,gCAAgC;WACrC;WACA;WACA;WACA;IACP;;;;iBAsBY,gCAAgC;WACrC;IACP;;;;iBAeY,iCAAiC;WACtC;IACP;;;;iBAeY,4BAA4B;WACjC;WACA;WACA;IACP;;;;iBAeY,oBAAoB;WAAqB;IAAiB;;;;iBAe1D,mCAAmC;WACxC;WACA;IACP;;;;iBAuBY,6BAA6B;WAClC,oBAAoB;WACpB;IACP;;;;iBAuBY,iCAAiC;WACtC;IACP;;;;;;;;iBAmBY,kCAAkC;WACvC;IACP;;;;;;;;;;iBAyBY,6BAA6B;WAClC;WACA;IACP;;;;iBAYY,yBAAyB,gBAAgB;;;;;iBAczC,0BAA0B;;;;iBAU1B,sBACd,eACA;WACW;IAEV;;;;;;;iBAkBa,6BAA6B;WAClC;IACP;;;;iBAeY,gBACd,iBACA;WACW;WACA;IAEV"}
+1
-1

@@ -1,2 +0,2 @@

import { S as errorUnexpected, _ as errorMigrationCliUnknownFlag, a as errorConfigValidation, b as errorQueryRunnerFactoryRequired, c as errorContractValidationFailed, d as errorEnumCodecNotInPackStack, f as errorFamilyReadMarkerSqlRequired, g as errorMigrationCliInvalidConfigArg, h as errorJsonFormatNotSupported, i as errorConfigFileNotFound, l as errorDatabaseConnectionRequired, m as errorInvalidOutputFormat, n as CliErrorEnvelope, o as errorContractConfigMissing, p as errorFileNotFound, r as CliStructuredError, s as errorContractMissingExtensionPacks, t as CliErrorConflict, u as errorDriverRequired, v as errorMigrationPlanningFailed, x as errorTargetMigrationNotSupported, y as errorOutputFormatMutex } from "./control-B20v3PXT.mjs";
import { S as errorUnexpected, _ as errorMigrationCliUnknownFlag, a as errorConfigValidation, b as errorQueryRunnerFactoryRequired, c as errorContractValidationFailed, d as errorEnumCodecNotInPackStack, f as errorFamilyReadMarkerSqlRequired, g as errorMigrationCliInvalidConfigArg, h as errorJsonFormatNotSupported, i as errorConfigFileNotFound, l as errorDatabaseConnectionRequired, m as errorInvalidOutputFormat, n as CliErrorEnvelope, o as errorContractConfigMissing, p as errorFileNotFound, r as CliStructuredError, s as errorContractMissingExtensionPacks, t as CliErrorConflict, u as errorDriverRequired, v as errorMigrationPlanningFailed, x as errorTargetMigrationNotSupported, y as errorOutputFormatMutex } from "./control-BPZvmSyz.mjs";
export { type CliErrorConflict, type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorEnumCodecNotInPackStack, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorInvalidOutputFormat, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorOutputFormatMutex, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };

@@ -1,2 +0,2 @@

import { _ as errorOutputFormatMutex, a as errorContractMissingExtensionPacks, b as errorUnexpected, c as errorDriverRequired, d as errorFileNotFound, f as errorInvalidOutputFormat, g as errorMigrationPlanningFailed, h as errorMigrationCliUnknownFlag, i as errorContractConfigMissing, l as errorEnumCodecNotInPackStack, m as errorMigrationCliInvalidConfigArg, n as errorConfigFileNotFound, o as errorContractValidationFailed, p as errorJsonFormatNotSupported, r as errorConfigValidation, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFamilyReadMarkerSqlRequired, v as errorQueryRunnerFactoryRequired, y as errorTargetMigrationNotSupported } from "./control-BVMQqofj.mjs";
import { _ as errorOutputFormatMutex, a as errorContractMissingExtensionPacks, b as errorUnexpected, c as errorDriverRequired, d as errorFileNotFound, f as errorInvalidOutputFormat, g as errorMigrationPlanningFailed, h as errorMigrationCliUnknownFlag, i as errorContractConfigMissing, l as errorEnumCodecNotInPackStack, m as errorMigrationCliInvalidConfigArg, n as errorConfigFileNotFound, o as errorContractValidationFailed, p as errorJsonFormatNotSupported, r as errorConfigValidation, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFamilyReadMarkerSqlRequired, v as errorQueryRunnerFactoryRequired, y as errorTargetMigrationNotSupported } from "./control-ai0hrdZ4.mjs";
export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorEnumCodecNotInPackStack, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorInvalidOutputFormat, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag, errorMigrationPlanningFailed, errorOutputFormatMutex, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };

@@ -1,4 +0,3 @@

import { r as CliStructuredError } from "./control-B20v3PXT.mjs";
import { r as CliStructuredError } from "./control-BPZvmSyz.mjs";
import { SchemaDiffIssue, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
//#region src/execution.d.ts

@@ -79,3 +78,3 @@ /**

/** Error code for destructive changes that require explicit confirmation. */
declare const ERROR_CODE_DESTRUCTIVE_CHANGES = "3030";
declare const ERROR_CODE_DESTRUCTIVE_CHANGES = "MIGRATION.DESTRUCTIVE_CHANGES";
/**

@@ -82,0 +81,0 @@ * Destructive operations require explicit confirmation via -y/--yes.

@@ -1,1 +0,1 @@

{"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution.ts"],"mappings":";;;;;;AAcA;iBAAgB,kBAAA,CAAmB,OAAA;EAAA,SAAqB,GAAA;AAAA,IAAiB,kBAAkB;;;;iBAW3E,iBAAA,CAAkB,OAAA;EAAA,SACvB,GAAA;EAAA,SACA,QAAA;EAAA,SACA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,YAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA,GAAO,MAAA;AAAA,IAEjB,kBAAkB"}
{"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution.ts"],"mappings":";;;;;;iBAcgB,mBAAmB;WAAqB;IAAiB;;;;iBAUzD,kBAAkB;WACvB;WACA;WACA;IACP;;;;iBAkBY,oBACd,kBACA,gBACA;WACW;IAEV;;;;iBAaa,sBAAsB;WAC3B;WACA;WACA;IACP;;;;iBAeY,sBAAsB;WAC3B;WACA;WACA;IACP;iBA4CY,uBACd,cACA;WAAoB;WAAwB;;iBA0BxB,4BAA4B,GAChD,iBAAiB,QAAQ,IACzB;WAAoB;WAAwB;IAC3C,QAAQ;iBAQK,qBAAqB,GACnC,cACA,QAAQ,mBAAmB,GAC3B;WAAoB;WAAwB;IAC3C;;;;;iBAYa,oBAAoB;WACzB;WACA;IACP;;;;;iBAWY,8BAA8B;WACnC;WACA,oBAAoB;WACpB,kBAAkB;IACzB;;;;iBAcY,kBACd,iBACA;WACW;WACA;WACA,OAAO;IAEjB;;cASU;;;;iBAKG,wBACd,iBACA;WACW;WACA;WACA,OAAO;IAEjB;;;;iBAWa,aACd,iBACA;WACW;WACA;WACA,OAAO;IAEjB"}

@@ -1,2 +0,2 @@

import { t as CliStructuredError } from "./control-BVMQqofj.mjs";
import { t as CliStructuredError } from "./control-ai0hrdZ4.mjs";
import { ifDefined } from "@prisma-next/utils/defined";

@@ -8,4 +8,3 @@ //#region src/execution.ts

function errorMarkerMissing(options) {
return new CliStructuredError("3001", "Database not signed", {
domain: "RUN",
return new CliStructuredError("CONTRACT.MARKER_MISSING", "Database not signed", {
why: options?.why ?? "No database signature (marker) found",

@@ -19,4 +18,3 @@ fix: "Run `prisma-next db sign --db <url>` to sign the database"

function errorHashMismatch(options) {
return new CliStructuredError("3002", "Hash mismatch", {
domain: "RUN",
return new CliStructuredError("CONTRACT.MARKER_MISMATCH", "Hash mismatch", {
why: options?.why ?? "Contract hash does not match database marker",

@@ -34,4 +32,3 @@ fix: "Migrate database or re-sign if intentional",

function errorTargetMismatch(expected, actual, options) {
return new CliStructuredError("3003", "Target mismatch", {
domain: "RUN",
return new CliStructuredError("CONTRACT.TARGET_MISMATCH", "Target mismatch", {
why: options?.why ?? `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,

@@ -49,4 +46,3 @@ fix: "Align contract target and config target",

function errorMarkerRowCorrupt(options) {
return new CliStructuredError("3005", "Marker row is corrupt or incompatible", {
domain: "RUN",
return new CliStructuredError("CONTRACT.MARKER_ROW_CORRUPT", "Marker row is corrupt or incompatible", {
why: options.why,

@@ -61,4 +57,3 @@ 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.`,

function errorMarkerReadFailed(options) {
return new CliStructuredError("3006", "Database error while reading contract marker", {
domain: "RUN",
return new CliStructuredError("CONTRACT.MARKER_READ_FAILED", "Database error while reading contract marker", {
why: options.why,

@@ -80,6 +75,3 @@ fix: `Could not read marker at ${options.markerLocation} for space "${options.space}". Verify read permissions, connectivity, and locks, then retry.`,

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.",
meta: {
code: "RUNNER_FAILED",
runnerErrorCode: "LEGACY_MARKER_SHAPE"
}
meta: { runnerErrorCode: "MIGRATION.LEGACY_MARKER_SHAPE" }
});

@@ -124,4 +116,3 @@ }

function errorMarkerRequired(options) {
return new CliStructuredError("3010", "Database must be signed first", {
domain: "RUN",
return new CliStructuredError("CONTRACT.MARKER_REQUIRED", "Database must be signed first", {
why: options?.why ?? "No database signature (marker) found",

@@ -136,4 +127,3 @@ fix: options?.fix ?? "Run `prisma-next db init` first to sign the database"

function errorSchemaVerificationFailed(options) {
return new CliStructuredError("3004", options.summary, {
domain: "RUN",
return new CliStructuredError("CONTRACT.SCHEMA_VERIFICATION_FAILED", options.summary, {
why: "Database schema does not satisfy the contract",

@@ -151,4 +141,3 @@ fix: "Run `prisma-next db update` to reconcile, or adjust your contract to match the database",

function errorRunnerFailed(summary, options) {
return new CliStructuredError("3020", summary, {
domain: "RUN",
return new CliStructuredError("MIGRATION.RUNNER_FAILED", summary, {
why: options?.why ?? "Migration runner failed",

@@ -160,3 +149,3 @@ fix: options?.fix ?? "Inspect the reported conflict and reconcile schema drift",

/** Error code for destructive changes that require explicit confirmation. */
const ERROR_CODE_DESTRUCTIVE_CHANGES = "3030";
const ERROR_CODE_DESTRUCTIVE_CHANGES = "MIGRATION.DESTRUCTIVE_CHANGES";
/**

@@ -167,3 +156,2 @@ * Destructive operations require explicit confirmation via -y/--yes.

return new CliStructuredError(ERROR_CODE_DESTRUCTIVE_CHANGES, summary, {
domain: "RUN",
why: options?.why ?? "Planned operations include destructive changes that require confirmation",

@@ -178,4 +166,3 @@ fix: options?.fix ?? "Re-run with `-y` to apply, or use `--dry-run` to preview first",

function errorRuntime(summary, options) {
return new CliStructuredError("3000", summary, {
domain: "RUN",
return new CliStructuredError("CONTRACT.VERIFY_FAILED", summary, {
...options?.why ? { why: options.why } : { why: "Verification failed" },

@@ -182,0 +169,0 @@ ...options?.fix ? { fix: options.fix } : { fix: "Check contract and database state" },

@@ -1,1 +0,1 @@

{"version":3,"file":"execution.mjs","names":[],"sources":["../src/execution.ts"],"sourcesContent":["import type {\n SchemaDiffIssue,\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 result is preserved in `meta.verificationResult`.\n */\nexport function errorSchemaVerificationFailed(options: {\n readonly summary: string;\n readonly verificationResult: VerifyDatabaseSchemaResult;\n readonly issues?: readonly SchemaDiffIssue[];\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;CACP,CAAC;AACH;;;;AAKA,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,QAAQ;GAC1C,GAAG,UAAU,UAAU,SAAS,MAAM;EACxC,EACF,IACA,CAAC;CACP,CAAC;AACH;;;;AAKA,SAAgB,oBACd,UACA,QACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,mBAAmB;EACvD,QAAQ;EACR,KACE,SAAS,OACT,2DAA2D,SAAS,YAAY,OAAO;EACzF,KAAK;EACL,MAAM;GAAE;GAAU;EAAO;CAC3B,CAAC;AACH;;;;AAKA,SAAgB,sBAAsB,SAIf;CACrB,OAAO,IAAI,mBAAmB,QAAQ,yCAAyC;EAC7E,QAAQ;EACR,KAAK,QAAQ;EACb,KAAK,OAAO,QAAQ,eAAe,kBAAkB,QAAQ,MAAM;EACnE,MAAM,EAAE,OAAO,QAAQ,MAAM;CAC/B,CAAC;AACH;;;;AAKA,SAAgB,sBAAsB,SAIf;CACrB,OAAO,IAAI,mBAAmB,QAAQ,gDAAgD;EACpF,QAAQ;EACR,KAAK,QAAQ;EACb,KAAK,4BAA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,OAAO,IAAI,mBAAmB,QAAQ,iCAAiC;EACrE,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;CACvB,CAAC;AACH;;;;;AAMA,SAAgB,8BAA8B,SAIvB;CACrB,OAAO,IAAI,mBAAmB,QAAQ,QAAQ,SAAS;EACrD,QAAQ;EACR,KAAK;EACL,KAAK;EACL,MAAM;GACJ,oBAAoB,QAAQ;GAC5B,GAAG,UAAU,UAAU,QAAQ,MAAM;EACvC;CACF,CAAC;AACH;;;;AAKA,SAAgB,kBACd,SACA,SAKoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,SAAS;EAC7C,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;EACrB,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;CAChD,CAAC;AACH;;AAGA,MAAa,iCAAiC;;;;AAK9C,SAAgB,wBACd,SACA,SAKoB;CACpB,OAAO,IAAI,mBAAmB,gCAAgC,SAAS;EACrE,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;EACrB,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;CAChD,CAAC;AACH;;;;AAKA,SAAgB,aACd,SACA,SAKoB;CACpB,OAAO,IAAI,mBAAmB,QAAQ,SAAS;EAC7C,QAAQ;EACR,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,sBAAsB;EACvE,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,oCAAoC;EACrF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;CAChD,CAAC;AACH"}
{"version":3,"file":"execution.mjs","names":[],"sources":["../src/execution.ts"],"sourcesContent":["import type {\n SchemaDiffIssue,\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 (CONTRACT.*, MIGRATION.*)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('CONTRACT.MARKER_MISSING', 'Database not signed', {\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('CONTRACT.MARKER_MISMATCH', 'Hash mismatch', {\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('CONTRACT.TARGET_MISMATCH', 'Target mismatch', {\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(\n 'CONTRACT.MARKER_ROW_CORRUPT',\n 'Marker row is corrupt or incompatible',\n {\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/**\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(\n 'CONTRACT.MARKER_READ_FAILED',\n 'Database error while reading contract marker',\n {\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}\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: { runnerErrorCode: 'MIGRATION.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('CONTRACT.MARKER_REQUIRED', 'Database must be signed first', {\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 result is preserved in `meta.verificationResult`.\n */\nexport function errorSchemaVerificationFailed(options: {\n readonly summary: string;\n readonly verificationResult: VerifyDatabaseSchemaResult;\n readonly issues?: readonly SchemaDiffIssue[];\n}): CliStructuredError {\n return new CliStructuredError('CONTRACT.SCHEMA_VERIFICATION_FAILED', options.summary, {\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('MIGRATION.RUNNER_FAILED', summary, {\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 = 'MIGRATION.DESTRUCTIVE_CHANGES';\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 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('CONTRACT.VERIFY_FAILED', summary, {\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,2BAA2B,uBAAuB;EAC9E,KAAK,SAAS,OAAO;EACrB,KAAK;CACP,CAAC;AACH;;;;AAKA,SAAgB,kBAAkB,SAIX;CACrB,OAAO,IAAI,mBAAmB,4BAA4B,iBAAiB;EACzE,KAAK,SAAS,OAAO;EACrB,KAAK;EACL,GAAI,SAAS,aAAa,KAAA,KAAa,SAAS,WAAW,KAAA,IACvD,EACE,MAAM;GACJ,GAAG,UAAU,YAAY,SAAS,QAAQ;GAC1C,GAAG,UAAU,UAAU,SAAS,MAAM;EACxC,EACF,IACA,CAAC;CACP,CAAC;AACH;;;;AAKA,SAAgB,oBACd,UACA,QACA,SAGoB;CACpB,OAAO,IAAI,mBAAmB,4BAA4B,mBAAmB;EAC3E,KACE,SAAS,OACT,2DAA2D,SAAS,YAAY,OAAO;EACzF,KAAK;EACL,MAAM;GAAE;GAAU;EAAO;CAC3B,CAAC;AACH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AoC;EACrF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;CAChD,CAAC;AACH"}

@@ -1,3 +0,2 @@

import { r as CliStructuredError } from "./control-B20v3PXT.mjs";
import { r as CliStructuredError } from "./control-BPZvmSyz.mjs";
//#region src/migration.d.ts

@@ -15,3 +14,3 @@ /**

* emit a real query and the author is expected to fill one in. Always throws
* a structured migration error (`PN-MIG-2001`).
* a structured migration error (`MIGRATION.UNFILLED_PLACEHOLDER`).
*

@@ -31,5 +30,5 @@ * The return type `never` makes it assignable to any expected return type, so

*
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
* Distinct from `errorHashMismatch` (`CONTRACT.MARKER_MISMATCH`) which
* rejects a plan at runtime execution; this is an authoring-time rejection
* so it lives in the `MIG` namespace.
* so it lives in the `MIGRATION` namespace.
*/

@@ -36,0 +35,0 @@ declare function errorDataTransformContractMismatch(options: {

@@ -1,1 +0,1 @@

{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/migration.ts"],"mappings":";;;;;AAkBA;;;;AAA0E;iBAA1D,wBAAA,CAAyB,IAAA,WAAe,kBAAkB;;;;AAkBlC;AAgBxC;;;;;iBAhBgB,WAAA,CAAY,IAAY;;;;;AAoBlB;AAkBtB;;;;AAA0E;AAkB1E;;iBAxCgB,kCAAA,CAAmC,OAAA;EAAA,SACxC,iBAAA;EAAA,SACA,QAAA;EAAA,SACA,MAAA;AAAA,IACP,kBAAkB;;AAuCD;AAuBrB;;;iBA5CgB,yBAAA,CAA0B,GAAA,WAAc,kBAAkB;;;;;;AA+CpD;AAgBtB;;;iBA7CgB,kCAAA,CACd,GAAA,UACA,uBAAA,YACC,kBAAkB;;;;;AA6CA;;;;iBAtBL,4BAAA,CAA6B,OAAA;EAAA,SAClC,iBAAA;EAAA,SACA,cAAA;AAAA,IACP,kBAAkB;;;;;iBAgBN,0BAAA,CACd,GAAA,UACA,sBAAA,YACC,kBAAkB"}
{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/migration.ts"],"mappings":";;;;;;;;;iBAgBgB,yBAAyB,eAAe;;;;;;;;;;iBAqBxC,YAAY;;;;;;;;;;;;;iBAgBZ,mCAAmC;WACxC;WACA;WACA;IACP;;;;;;iBAqBY,0BAA0B,cAAc;;;;;;;;;;iBAiBxC,mCACd,aACA,mCACC;;;;;;;;;iBA0Ba,6BAA6B;WAClC;WACA;IACP;;;;;iBAmBY,2BACd,aACA,kCACC"}

@@ -1,2 +0,2 @@

import { t as CliStructuredError } from "./control-BVMQqofj.mjs";
import { t as CliStructuredError } from "./control-ai0hrdZ4.mjs";
//#region src/migration.ts

@@ -11,4 +11,3 @@ /**

function errorUnfilledPlaceholder(slot) {
return new CliStructuredError("2001", "Unfilled migration placeholder", {
domain: "MIG",
return new CliStructuredError("MIGRATION.UNFILLED_PLACEHOLDER", "Unfilled migration placeholder", {
why: `The migration contains a placeholder that has not been filled in: ${slot}`,

@@ -22,3 +21,3 @@ fix: "Open migration.ts and replace the `placeholder(...)` call with your actual query.",

* emit a real query and the author is expected to fill one in. Always throws
* a structured migration error (`PN-MIG-2001`).
* a structured migration error (`MIGRATION.UNFILLED_PLACEHOLDER`).
*

@@ -40,9 +39,8 @@ * The return type `never` makes it assignable to any expected return type, so

*
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
* Distinct from `errorHashMismatch` (`CONTRACT.MARKER_MISMATCH`) which
* rejects a plan at runtime execution; this is an authoring-time rejection
* so it lives in the `MIG` namespace.
* so it lives in the `MIGRATION` namespace.
*/
function errorDataTransformContractMismatch(options) {
return new CliStructuredError("2005", "dataTransform query plan built against wrong contract", {
domain: "MIG",
return new CliStructuredError("MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH", "dataTransform query plan built against wrong contract", {
why: `Data transform "${options.dataTransformName}" produced a query plan whose storage hash (${options.actual}) does not match the migration's contract (${options.expected}). The query builder was configured with a different contract than the one passed to dataTransform(endContract, ...).`,

@@ -63,4 +61,3 @@ fix: "Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.",

function errorMigrationFileMissing(dir) {
return new CliStructuredError("2002", "migration.ts not found", {
domain: "MIG",
return new CliStructuredError("MIGRATION.FILE_MISSING", "migration.ts not found", {
why: `No migration.ts file was found at "${dir}"`,

@@ -81,4 +78,3 @@ fix: "Scaffold one with `prisma-next migration new` or `prisma-next migration plan`.",

function errorMigrationInvalidDefaultExport(dir, actualExportDescription) {
return new CliStructuredError("2003", "migration.ts default export is not a valid migration", {
domain: "MIG",
return new CliStructuredError("MIGRATION.INVALID_DEFAULT_EXPORT", "migration.ts default export is not a valid migration", {
why: actualExportDescription !== void 0 ? `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object; got ${actualExportDescription}` : `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object.`,

@@ -101,4 +97,3 @@ fix: "Use `export default class extends Migration { ... }` or `export default () => ({ targetId, destination, operations })`.",

function errorMigrationTargetMismatch(options) {
return new CliStructuredError("2006", "Migration target does not match config target", {
domain: "MIG",
return new CliStructuredError("MIGRATION.TARGET_MISMATCH", "Migration target does not match config target", {
why: `This migration is for target "${options.migrationTargetId}" but the loaded prisma-next.config.ts declares target "${options.configTargetId}". The migration script can only be run against a config that targets the same database.`,

@@ -117,4 +112,3 @@ fix: "Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.",

function errorMigrationPlanNotArray(dir, actualValueDescription) {
return new CliStructuredError("2004", "Migration.operations must be an array of operations", {
domain: "MIG",
return new CliStructuredError("MIGRATION.PLAN_NOT_ARRAY", "Migration.operations must be an array of operations", {
why: actualValueDescription !== void 0 ? `Migration.operations for migration.ts at "${dir}" was ${actualValueDescription}; an array of operations is required.` : `Migration.operations for migration.ts at "${dir}" is not an array of operations.`,

@@ -121,0 +115,0 @@ fix: "Ensure your `operations` getter returns an array of operations; see the data-migrations authoring guide.",

@@ -1,1 +0,1 @@

{"version":3,"file":"migration.mjs","names":[],"sources":["../src/migration.ts"],"sourcesContent":["import { CliStructuredError } from './control';\n\n// ============================================================================\n// Migration Errors (PN-MIG-2000-2999)\n//\n// Errors raised by the migration subsystem (authoring, planning, emit).\n// Domain `MIG` distinguishes these from generic application runtime errors\n// (`RUN`) and from CLI argument/config errors (`CLI`). See\n// `docs/CLI Style Guide.md` for the canonical domain taxonomy.\n// ============================================================================\n\n/**\n * A scaffolded migration contains a placeholder slot that was never filled in.\n *\n * Thrown at emit time (when `check.source()` or `run()` is invoked) via the\n * `placeholder(...)` utility. The `slot` identifies the exact location the\n * author still needs to edit, e.g. `\"backfill-product-status:check.source\"`.\n */\nexport function errorUnfilledPlaceholder(slot: string): CliStructuredError {\n return new CliStructuredError('2001', 'Unfilled migration placeholder', {\n domain: 'MIG',\n why: `The migration contains a placeholder that has not been filled in: ${slot}`,\n fix: 'Open migration.ts and replace the `placeholder(...)` call with your actual query.',\n meta: { slot },\n });\n}\n\n/**\n * Scaffolded `migration.ts` files call this wherever the scaffolder couldn't\n * emit a real query and the author is expected to fill one in. Always throws\n * a structured migration error (`PN-MIG-2001`).\n *\n * The return type `never` makes it assignable to any expected return type, so\n * a scaffolded `() => placeholder('...')` satisfies signatures like\n * `() => MongoQueryPlan` without polluting them with a sentinel union arm.\n */\nexport function placeholder(slot: string): never {\n throw errorUnfilledPlaceholder(slot);\n}\n\n/**\n * A `dataTransform(endContract, …)` factory was handed a `SqlQueryPlan` whose\n * `meta.storageHash` does not match the `endContract.storage.storageHash` it\n * was configured with. This almost always means the user's query-builder\n * (`sql({ context: createExecutionContext({ contract: endContract, … }) })`)\n * was instantiated from a different contract reference than the one passed\n * to `dataTransform(endContract, …)`.\n *\n * Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which\n * rejects a plan at runtime execution; this is an authoring-time rejection\n * so it lives in the `MIG` namespace.\n */\nexport function errorDataTransformContractMismatch(options: {\n readonly dataTransformName: string;\n readonly expected: string;\n readonly actual: string;\n}): CliStructuredError {\n return new CliStructuredError('2005', 'dataTransform query plan built against wrong contract', {\n domain: 'MIG',\n why: `Data transform \"${options.dataTransformName}\" produced a query plan whose storage hash (${options.actual}) does not match the migration's contract (${options.expected}). The query builder was configured with a different contract than the one passed to dataTransform(endContract, ...).`,\n fix: 'Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.',\n meta: {\n dataTransformName: options.dataTransformName,\n expected: options.expected,\n actual: options.actual,\n },\n });\n}\n\n/**\n * `migration.ts` was expected at the given package directory but could not be\n * located. Thrown when consumers attempt to read a migration package that is\n * missing its source file.\n */\nexport function errorMigrationFileMissing(dir: string): CliStructuredError {\n return new CliStructuredError('2002', 'migration.ts not found', {\n domain: 'MIG',\n why: `No migration.ts file was found at \"${dir}\"`,\n fix: 'Scaffold one with `prisma-next migration new` or `prisma-next migration plan`.',\n meta: { dir },\n });\n}\n\n/**\n * The `migration.ts` at the given package directory does not default-export a\n * valid migration shape. Two shapes are accepted: a `Migration` subclass, or a\n * factory function returning a `MigrationPlan`-shaped object (with at least\n * an `operations` array, plus `targetId` and `destination`). Thrown when the\n * default export is missing, is not a constructor/function, does not extend\n * `Migration`, or (for factory functions) returns a value that is not\n * `MigrationPlan`-shaped.\n */\nexport function errorMigrationInvalidDefaultExport(\n dir: string,\n actualExportDescription?: string,\n): CliStructuredError {\n return new CliStructuredError('2003', 'migration.ts default export is not a valid migration', {\n domain: 'MIG',\n why:\n actualExportDescription !== undefined\n ? `migration.ts at \"${dir}\" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object; got ${actualExportDescription}`\n : `migration.ts at \"${dir}\" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object.`,\n fix: 'Use `export default class extends Migration { ... }` or `export default () => ({ targetId, destination, operations })`.',\n meta: {\n dir,\n ...(actualExportDescription !== undefined ? { actualExport: actualExportDescription } : {}),\n },\n });\n}\n\n/**\n * The migration class declares one `targetId` but the loaded\n * `prisma-next.config.ts` declares another. Thrown by `MigrationCLI.run`\n * when a migration script is invoked against a config whose target\n * descriptor disagrees with the migration's own `targetId`. Distinct from generic\n * config-validation errors because the mismatch is between two valid\n * artifacts (the script and the config), not a malformed input.\n */\nexport function errorMigrationTargetMismatch(options: {\n readonly migrationTargetId: string;\n readonly configTargetId: string;\n}): CliStructuredError {\n return new CliStructuredError('2006', 'Migration target does not match config target', {\n domain: 'MIG',\n why: `This migration is for target \"${options.migrationTargetId}\" but the loaded prisma-next.config.ts declares target \"${options.configTargetId}\". The migration script can only be run against a config that targets the same database.`,\n fix: \"Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.\",\n meta: {\n migrationTargetId: options.migrationTargetId,\n configTargetId: options.configTargetId,\n },\n });\n}\n\n/**\n * A `Migration.operations` getter returned a value that is not an array. Used\n * by emit capabilities after instantiating the authored migration.\n */\nexport function errorMigrationPlanNotArray(\n dir: string,\n actualValueDescription?: string,\n): CliStructuredError {\n return new CliStructuredError('2004', 'Migration.operations must be an array of operations', {\n domain: 'MIG',\n why:\n actualValueDescription !== undefined\n ? `Migration.operations for migration.ts at \"${dir}\" was ${actualValueDescription}; an array of operations is required.`\n : `Migration.operations for migration.ts at \"${dir}\" is not an array of operations.`,\n fix: 'Ensure your `operations` getter returns an array of operations; see the data-migrations authoring guide.',\n meta: {\n dir,\n ...(actualValueDescription !== undefined ? { actualValue: actualValueDescription } : {}),\n },\n });\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,yBAAyB,MAAkC;CACzE,OAAO,IAAI,mBAAmB,QAAQ,kCAAkC;EACtE,QAAQ;EACR,KAAK,qEAAqE;EAC1E,KAAK;EACL,MAAM,EAAE,KAAK;CACf,CAAC;AACH;;;;;;;;;;AAWA,SAAgB,YAAY,MAAqB;CAC/C,MAAM,yBAAyB,IAAI;AACrC;;;;;;;;;;;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AI,CAAC;EACxF;CACF,CAAC;AACH"}
{"version":3,"file":"migration.mjs","names":[],"sources":["../src/migration.ts"],"sourcesContent":["import { CliStructuredError } from './control';\n\n// ============================================================================\n// Migration Errors (MIGRATION.*)\n//\n// Errors raised by the migration subsystem (authoring, planning, emit). See\n// ADR 239 for the namespace taxonomy.\n// ============================================================================\n\n/**\n * A scaffolded migration contains a placeholder slot that was never filled in.\n *\n * Thrown at emit time (when `check.source()` or `run()` is invoked) via the\n * `placeholder(...)` utility. The `slot` identifies the exact location the\n * author still needs to edit, e.g. `\"backfill-product-status:check.source\"`.\n */\nexport function errorUnfilledPlaceholder(slot: string): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.UNFILLED_PLACEHOLDER',\n 'Unfilled migration placeholder',\n {\n why: `The migration contains a placeholder that has not been filled in: ${slot}`,\n fix: 'Open migration.ts and replace the `placeholder(...)` call with your actual query.',\n meta: { slot },\n },\n );\n}\n\n/**\n * Scaffolded `migration.ts` files call this wherever the scaffolder couldn't\n * emit a real query and the author is expected to fill one in. Always throws\n * a structured migration error (`MIGRATION.UNFILLED_PLACEHOLDER`).\n *\n * The return type `never` makes it assignable to any expected return type, so\n * a scaffolded `() => placeholder('...')` satisfies signatures like\n * `() => MongoQueryPlan` without polluting them with a sentinel union arm.\n */\nexport function placeholder(slot: string): never {\n throw errorUnfilledPlaceholder(slot);\n}\n\n/**\n * A `dataTransform(endContract, …)` factory was handed a `SqlQueryPlan` whose\n * `meta.storageHash` does not match the `endContract.storage.storageHash` it\n * was configured with. This almost always means the user's query-builder\n * (`sql({ context: createExecutionContext({ contract: endContract, … }) })`)\n * was instantiated from a different contract reference than the one passed\n * to `dataTransform(endContract, …)`.\n *\n * Distinct from `errorHashMismatch` (`CONTRACT.MARKER_MISMATCH`) which\n * rejects a plan at runtime execution; this is an authoring-time rejection\n * so it lives in the `MIGRATION` namespace.\n */\nexport function errorDataTransformContractMismatch(options: {\n readonly dataTransformName: string;\n readonly expected: string;\n readonly actual: string;\n}): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH',\n 'dataTransform query plan built against wrong contract',\n {\n why: `Data transform \"${options.dataTransformName}\" produced a query plan whose storage hash (${options.actual}) does not match the migration's contract (${options.expected}). The query builder was configured with a different contract than the one passed to dataTransform(endContract, ...).`,\n fix: 'Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.',\n meta: {\n dataTransformName: options.dataTransformName,\n expected: options.expected,\n actual: options.actual,\n },\n },\n );\n}\n\n/**\n * `migration.ts` was expected at the given package directory but could not be\n * located. Thrown when consumers attempt to read a migration package that is\n * missing its source file.\n */\nexport function errorMigrationFileMissing(dir: string): CliStructuredError {\n return new CliStructuredError('MIGRATION.FILE_MISSING', 'migration.ts not found', {\n why: `No migration.ts file was found at \"${dir}\"`,\n fix: 'Scaffold one with `prisma-next migration new` or `prisma-next migration plan`.',\n meta: { dir },\n });\n}\n\n/**\n * The `migration.ts` at the given package directory does not default-export a\n * valid migration shape. Two shapes are accepted: a `Migration` subclass, or a\n * factory function returning a `MigrationPlan`-shaped object (with at least\n * an `operations` array, plus `targetId` and `destination`). Thrown when the\n * default export is missing, is not a constructor/function, does not extend\n * `Migration`, or (for factory functions) returns a value that is not\n * `MigrationPlan`-shaped.\n */\nexport function errorMigrationInvalidDefaultExport(\n dir: string,\n actualExportDescription?: string,\n): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.INVALID_DEFAULT_EXPORT',\n 'migration.ts default export is not a valid migration',\n {\n why:\n actualExportDescription !== undefined\n ? `migration.ts at \"${dir}\" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object; got ${actualExportDescription}`\n : `migration.ts at \"${dir}\" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object.`,\n fix: 'Use `export default class extends Migration { ... }` or `export default () => ({ targetId, destination, operations })`.',\n meta: {\n dir,\n ...(actualExportDescription !== undefined ? { actualExport: actualExportDescription } : {}),\n },\n },\n );\n}\n\n/**\n * The migration class declares one `targetId` but the loaded\n * `prisma-next.config.ts` declares another. Thrown by `MigrationCLI.run`\n * when a migration script is invoked against a config whose target\n * descriptor disagrees with the migration's own `targetId`. Distinct from generic\n * config-validation errors because the mismatch is between two valid\n * artifacts (the script and the config), not a malformed input.\n */\nexport function errorMigrationTargetMismatch(options: {\n readonly migrationTargetId: string;\n readonly configTargetId: string;\n}): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.TARGET_MISMATCH',\n 'Migration target does not match config target',\n {\n why: `This migration is for target \"${options.migrationTargetId}\" but the loaded prisma-next.config.ts declares target \"${options.configTargetId}\". The migration script can only be run against a config that targets the same database.`,\n fix: \"Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.\",\n meta: {\n migrationTargetId: options.migrationTargetId,\n configTargetId: options.configTargetId,\n },\n },\n );\n}\n\n/**\n * A `Migration.operations` getter returned a value that is not an array. Used\n * by emit capabilities after instantiating the authored migration.\n */\nexport function errorMigrationPlanNotArray(\n dir: string,\n actualValueDescription?: string,\n): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.PLAN_NOT_ARRAY',\n 'Migration.operations must be an array of operations',\n {\n why:\n actualValueDescription !== undefined\n ? `Migration.operations for migration.ts at \"${dir}\" was ${actualValueDescription}; an array of operations is required.`\n : `Migration.operations for migration.ts at \"${dir}\" is not an array of operations.`,\n fix: 'Ensure your `operations` getter returns an array of operations; see the data-migrations authoring guide.',\n meta: {\n dir,\n ...(actualValueDescription !== undefined ? { actualValue: actualValueDescription } : {}),\n },\n },\n );\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,yBAAyB,MAAkC;CACzE,OAAO,IAAI,mBACT,kCACA,kCACA;EACE,KAAK,qEAAqE;EAC1E,KAAK;EACL,MAAM,EAAE,KAAK;CACf,CACF;AACF;;;;;;;;;;AAWA,SAAgB,YAAY,MAAqB;CAC/C,MAAM,yBAAy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"0.16.0-dev.1",
"license": "Apache-2.0",

@@ -9,9 +9,9 @@ "type": "module",

"dependencies": {
"@prisma-next/framework-components": "0.15.0",
"@prisma-next/utils": "0.15.0"
"@prisma-next/framework-components": "0.16.0-dev.1",
"@prisma-next/utils": "0.16.0-dev.1"
},
"devDependencies": {
"@prisma-next/tsconfig": "0.15.0",
"@prisma-next/tsdown": "0.15.0",
"tsdown": "0.22.3",
"@prisma-next/tsconfig": "0.16.0-dev.1",
"@prisma-next/tsdown": "0.16.0-dev.1",
"tsdown": "0.22.8",
"typescript": "5.9.3",

@@ -18,0 +18,0 @@ "vitest": "4.1.10"

@@ -0,1 +1,4 @@

import { ifDefined } from '@prisma-next/utils/defined';
import type { StructuredError } from '@prisma-next/utils/structured-error';
/**

@@ -8,15 +11,9 @@ * CLI error envelope for output formatting.

readonly code: string;
readonly domain: string;
readonly severity: 'error' | 'warn' | 'info';
readonly summary: string;
readonly why: string | undefined;
readonly fix: string | undefined;
readonly where:
| {
readonly path: string | undefined;
readonly line: number | undefined;
}
| undefined;
readonly meta: Record<string, unknown> | undefined;
readonly docsUrl: string | undefined;
readonly why?: string;
readonly fix?: string;
readonly where?: { readonly path?: string; readonly line?: number };
readonly meta?: Record<string, unknown>;
readonly docsUrl?: string;
}

@@ -34,45 +31,25 @@

/**
* Domain prefix for structured CLI error codes.
*
* The full envelope code is rendered as `PN-<domain>-<code>` (see
* `CliStructuredError.toEnvelope`). The supported domains follow the
* taxonomy documented in `docs/CLI Style Guide.md`:
*
* - `CLI` — CLI command processing (config, validation, planning)
* - `MIG` — Migration subsystem (authoring, planning conflicts, runner)
* - `RUN` — Application runtime (query execution, streaming)
* - `CON` — Contract subsystem (validation, normalization)
* - `SCHEMA` — Schema subsystem
*
* Sub-clustering within a domain is conveyed by the numeric code range; see
* the per-domain source files for reserved ranges.
*/
const CLI_ERROR_DOMAINS = ['CLI', 'RUN', 'MIG', 'CON', 'SCHEMA'] as const;
export type CliErrorDomain = (typeof CLI_ERROR_DOMAINS)[number];
/**
* Structured CLI error that contains all information needed for error envelopes.
* Call sites throw these errors with full context.
*
* A `CliStructuredError` is a `StructuredError` (see
* `@prisma-next/utils/structured-error`): `code` is a dotted
* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's
* category — there is no separate `domain` field. See
* [ADR 239](../../../../../docs/architecture%20docs/adrs/ADR%20239%20-%20Errors%20are%20structural%20envelopes%20with%20dotted%20namespace%20codes.md)
* for the namespace taxonomy.
*/
export class CliStructuredError extends Error {
readonly code: string;
readonly domain: CliErrorDomain;
export class CliStructuredError extends Error implements StructuredError {
readonly code: `${string}.${string}`;
readonly severity: 'error' | 'warn' | 'info';
readonly why: string | undefined;
readonly fix: string | undefined;
readonly where:
| {
readonly path: string | undefined;
readonly line: number | undefined;
}
| undefined;
readonly meta: Record<string, unknown> | undefined;
readonly docsUrl: string | undefined;
declare readonly why?: string;
declare readonly fix?: string;
declare readonly where?: { readonly path?: string; readonly line?: number };
declare readonly meta?: Record<string, unknown>;
declare readonly docsUrl?: string;
constructor(
code: string,
code: `${string}.${string}`,
summary: string,
options?: {
readonly domain?: CliErrorDomain;
readonly severity?: 'error' | 'warn' | 'info';

@@ -89,14 +66,14 @@ readonly why?: string;

this.code = code;
this.domain = options?.domain ?? 'CLI';
this.severity = options?.severity ?? 'error';
this.why = options?.why;
this.fix = options?.fix === options?.why ? undefined : options?.fix;
this.where = options?.where
? {
path: options.where.path,
line: options.where.line,
}
const fix = options?.fix === options?.why ? undefined : options?.fix;
const where = options?.where
? { ...ifDefined('path', options.where.path), ...ifDefined('line', options.where.line) }
: undefined;
this.meta = options?.meta;
this.docsUrl = options?.docsUrl;
Object.assign(this, {
...ifDefined('why', options?.why),
...ifDefined('fix', fix),
...ifDefined('where', where),
...ifDefined('meta', options?.meta),
...ifDefined('docsUrl', options?.docsUrl),
});
}

@@ -110,11 +87,10 @@

ok: false as const,
code: `PN-${this.domain}-${this.code}`,
domain: this.domain,
code: this.code,
severity: this.severity,
summary: this.message,
why: this.why,
fix: this.fix,
where: this.where,
meta: this.meta,
docsUrl: this.docsUrl,
...ifDefined('why', this.why),
...ifDefined('fix', this.fix),
...ifDefined('where', this.where),
...ifDefined('meta', this.meta),
...ifDefined('docsUrl', this.docsUrl),
};

@@ -135,3 +111,2 @@ }

typeof candidate.code === 'string' &&
isCliErrorDomain(candidate.domain) &&
typeof candidate.toEnvelope === 'function'

@@ -142,30 +117,6 @@ );

const CLI_ERROR_DOMAIN_SET: ReadonlySet<CliErrorDomain> = new Set(CLI_ERROR_DOMAINS);
function isCliErrorDomain(value: unknown): value is CliErrorDomain {
return typeof value === 'string' && CLI_ERROR_DOMAIN_SET.has(value as CliErrorDomain);
}
// ============================================================================
// Numeric range conventions for `PN-CLI-NNNN`
// Config Errors
// ============================================================================
//
// Sub-clustering inside the `CLI` domain uses the numeric prefix:
//
// - `4xxx` — generic / cross-command CLI errors authored here (config
// missing, file not found, contract validation, etc.).
// - `5xxx` — command-specific CLI errors authored alongside the command
// itself (e.g. `init` errors live in
// `packages/1-framework/3-tooling/cli/src/commands/init/errors.ts`).
// The 5xxx range avoids collisions with the shared 4xxx pool while
// still belonging to the `CLI` domain — consumers branch on the full
// `PN-CLI-5007` form, so the prefix is purely an authoring guide.
//
// See [`docs/CLI Style Guide.md` § Errors](../../../../../docs/CLI%20Style%20Guide.md#errors)
// and the per-command error file for the live reservation list.
// ============================================================================
// Config Errors (PN-CLI-4001-4007)
// ============================================================================
/**

@@ -180,4 +131,3 @@ * Config file not found or missing.

): CliStructuredError {
return new CliStructuredError('4001', 'Config file not found', {
domain: 'CLI',
return new CliStructuredError('CONFIG.FILE_NOT_FOUND', 'Config file not found', {
...(options?.why ? { why: options.why } : { why: 'Config file not found' }),

@@ -196,4 +146,3 @@ fix: "Run 'prisma-next init' to create a config file",

}): CliStructuredError {
return new CliStructuredError('4002', 'Contract configuration missing', {
domain: 'CLI',
return new CliStructuredError('CONFIG.CONTRACT_MISSING', 'Contract configuration missing', {
why: options?.why ?? 'The contract configuration is required for emit',

@@ -214,4 +163,3 @@ fix: 'Add contract configuration to your prisma-next.config.ts',

): CliStructuredError {
return new CliStructuredError('4003', 'Contract validation failed', {
domain: 'CLI',
return new CliStructuredError('CONTRACT.VALIDATION_FAILED', 'Contract validation failed', {
why: reason,

@@ -235,4 +183,3 @@ fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',

): CliStructuredError {
return new CliStructuredError('4004', 'File not found', {
domain: 'CLI',
return new CliStructuredError('CLI.FILE_NOT_FOUND', 'File not found', {
why: options?.why ?? `File not found: ${filePath}`,

@@ -259,10 +206,13 @@ fix: options?.fix ?? 'Check that the file path is correct',

: 'Provide `--db <url>`';
return new CliStructuredError('4005', 'Database connection is required', {
domain: 'CLI',
why: options?.why ?? 'Database connection is required for this command',
fix: `${runHint}, or set \`db: { connection: "postgres://…" }\` in prisma-next.config.ts`,
...(options?.missingFlags !== undefined
? { meta: { missingFlags: [...options.missingFlags] } }
: {}),
});
return new CliStructuredError(
'CONFIG.DB_CONNECTION_REQUIRED',
'Database connection is required',
{
why: options?.why ?? 'Database connection is required for this command',
fix: `${runHint}, or set \`db: { connection: "postgres://…" }\` in prisma-next.config.ts`,
...(options?.missingFlags !== undefined
? { meta: { missingFlags: [...options.missingFlags] } }
: {}),
},
);
}

@@ -276,8 +226,11 @@

}): CliStructuredError {
return new CliStructuredError('4006', 'Query runner factory is required', {
domain: 'CLI',
why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',
fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',
docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',
});
return new CliStructuredError(
'CONFIG.QUERY_RUNNER_FACTORY_REQUIRED',
'Query runner factory is required',
{
why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',
fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',
docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',
},
);
}

@@ -291,8 +244,11 @@

}): CliStructuredError {
return new CliStructuredError('4007', 'Family readMarker() is required', {
domain: 'CLI',
why: options?.why ?? 'Family verify.readMarker is required for db verify',
fix: 'Ensure family.verify.readMarker() is exported by your family package',
docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',
});
return new CliStructuredError(
'CONFIG.FAMILY_READ_MARKER_REQUIRED',
'Family readMarker() is required',
{
why: options?.why ?? 'Family verify.readMarker is required for db verify',
fix: 'Ensure family.verify.readMarker() is exported by your family package',
docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',
},
);
}

@@ -308,4 +264,3 @@

}): CliStructuredError {
return new CliStructuredError('4008', 'Unsupported JSON format', {
domain: 'CLI',
return new CliStructuredError('CLI.JSON_FORMAT_UNSUPPORTED', 'Unsupported JSON format', {
why: `The ${options.command} command does not support --json ${options.format}`,

@@ -325,8 +280,11 @@ fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,

export function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {
return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {
domain: 'CLI',
why: options?.why ?? 'Config.driver is required for DB-connected commands',
fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',
docsUrl: 'https://prisma-next.dev/docs/cli/config',
});
return new CliStructuredError(
'CONFIG.DRIVER_REQUIRED',
'Driver is required for DB-connected commands',
{
why: options?.why ?? 'Config.driver is required for DB-connected commands',
fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',
docsUrl: 'https://prisma-next.dev/docs/cli/config',
},
);
}

@@ -342,15 +300,18 @@

const missing = [...options.missingExtensionPacks].sort();
return new CliStructuredError('4011', 'Missing extension packs in config', {
domain: 'CLI',
why:
missing.length === 1
? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`
: `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,
fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',
docsUrl: 'https://prisma-next.dev/docs/cli/config',
meta: {
missingExtensionPacks: missing,
providedComponentIds: [...options.providedComponentIds].sort(),
return new CliStructuredError(
'CONFIG.MISSING_EXTENSION_PACKS',
'Missing extension packs in config',
{
why:
missing.length === 1
? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`
: `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,
fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',
docsUrl: 'https://prisma-next.dev/docs/cli/config',
meta: {
missingExtensionPacks: missing,
providedComponentIds: [...options.providedComponentIds].sort(),
},
},
});
);
}

@@ -376,4 +337,3 @@

return new CliStructuredError('4020', 'Migration planning failed', {
domain: 'CLI',
return new CliStructuredError('MIGRATION.PLANNING_FAILED', 'Migration planning failed', {
why: computedWhy,

@@ -392,8 +352,11 @@ fix: computedFix,

}): CliStructuredError {
return new CliStructuredError('4021', 'Target does not support migrations', {
domain: 'CLI',
why: options?.why ?? 'The configured target does not provide migration planner/runner',
fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',
docsUrl: 'https://prisma-next.dev/docs/cli/db-init',
});
return new CliStructuredError(
'MIGRATION.TARGET_UNSUPPORTED',
'Target does not support migrations',
{
why: options?.why ?? 'The configured target does not provide migration planner/runner',
fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',
docsUrl: 'https://prisma-next.dev/docs/cli/db-init',
},
);
}

@@ -415,8 +378,11 @@

: '`--config` was passed without a following path argument.';
return new CliStructuredError('4012', '--config flag requires a path argument', {
domain: 'CLI',
why,
fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',
meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},
});
return new CliStructuredError(
'CLI.CONFIG_ARG_MISSING_PATH',
'--config flag requires a path argument',
{
why,
fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',
meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},
},
);
}

@@ -438,4 +404,3 @@

const knownList = options.knownFlags.join(', ');
return new CliStructuredError('4013', 'Unknown migration CLI flag', {
domain: 'CLI',
return new CliStructuredError('CLI.UNKNOWN_FLAG', 'Unknown migration CLI flag', {
why: `Unknown flag \`${options.flag}\`.`,

@@ -452,6 +417,5 @@ fix: `Known flags: ${knownList}. Run with \`--help\` to see the full list.`,

return new CliStructuredError(
'4014',
'CLI.INVALID_OUTPUT_FORMAT',
`Invalid --format value "${value}". Allowed values: pretty, json.`,
{
domain: 'CLI',
meta: { value, allowed: ['pretty', 'json'] as const },

@@ -468,5 +432,4 @@ },

return new CliStructuredError(
'4015',
'CLI.OUTPUT_FORMAT_CONFLICT',
'Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.',
{ domain: 'CLI' },
);

@@ -484,4 +447,3 @@ }

): CliStructuredError {
return new CliStructuredError('4009', 'Config validation error', {
domain: 'CLI',
return new CliStructuredError('CONFIG.VALIDATION_FAILED', 'Config validation error', {
why: options?.why ?? `Config must have a "${field}" field`,

@@ -507,6 +469,5 @@ fix: 'Check your prisma-next.config.ts and ensure all required fields are provided',

return new CliStructuredError(
'4016',
'CONTRACT.ENUM_CODEC_NOT_IN_PACK_STACK',
`Enum codec "${options.codecId}" is not part of the contract's pack stack`,
{
domain: 'CON',
why: `An enum uses codec "${options.codecId}", but no family, target, or extension pack in the contract provides it.`,

@@ -529,4 +490,3 @@ fix: "Use a codec provided by the contract's target/extension packs, or add the pack that supplies this codec.",

): CliStructuredError {
return new CliStructuredError('4999', 'Unexpected error', {
domain: 'CLI',
return new CliStructuredError('CLI.UNEXPECTED', 'Unexpected error', {
why: options?.why ?? message,

@@ -533,0 +493,0 @@ fix: options?.fix ?? 'Check the error message and try again',

@@ -9,3 +9,3 @@ import type {

// ============================================================================
// Runtime Errors (PN-RUN-3000-3030)
// Runtime Errors (CONTRACT.*, MIGRATION.*)
// ============================================================================

@@ -17,4 +17,3 @@

export function errorMarkerMissing(options?: { readonly why?: string }): CliStructuredError {
return new CliStructuredError('3001', 'Database not signed', {
domain: 'RUN',
return new CliStructuredError('CONTRACT.MARKER_MISSING', 'Database not signed', {
why: options?.why ?? 'No database signature (marker) found',

@@ -33,4 +32,3 @@ fix: 'Run `prisma-next db sign --db <url>` to sign the database',

}): CliStructuredError {
return new CliStructuredError('3002', 'Hash mismatch', {
domain: 'RUN',
return new CliStructuredError('CONTRACT.MARKER_MISMATCH', 'Hash mismatch', {
why: options?.why ?? 'Contract hash does not match database marker',

@@ -59,4 +57,3 @@ fix: 'Migrate database or re-sign if intentional',

): CliStructuredError {
return new CliStructuredError('3003', 'Target mismatch', {
domain: 'RUN',
return new CliStructuredError('CONTRACT.TARGET_MISMATCH', 'Target mismatch', {
why:

@@ -78,8 +75,11 @@ options?.why ??

}): CliStructuredError {
return new CliStructuredError('3005', 'Marker row is corrupt or incompatible', {
domain: 'RUN',
why: options.why,
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.`,
meta: { space: options.space },
});
return new CliStructuredError(
'CONTRACT.MARKER_ROW_CORRUPT',
'Marker row is corrupt or incompatible',
{
why: options.why,
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.`,
meta: { space: options.space },
},
);
}

@@ -95,8 +95,11 @@

}): CliStructuredError {
return new CliStructuredError('3006', 'Database error while reading contract marker', {
domain: 'RUN',
why: options.why,
fix: `Could not read marker at ${options.markerLocation} for space "${options.space}". Verify read permissions, connectivity, and locks, then retry.`,
meta: { space: options.space },
});
return new CliStructuredError(
'CONTRACT.MARKER_READ_FAILED',
'Database error while reading contract marker',
{
why: options.why,
fix: `Could not read marker at ${options.markerLocation} for space "${options.space}". Verify read permissions, connectivity, and locks, then retry.`,
meta: { space: options.space },
},
);
}

@@ -131,3 +134,3 @@

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.',
meta: { code: 'RUNNER_FAILED', runnerErrorCode: 'LEGACY_MARKER_SHAPE' },
meta: { runnerErrorCode: 'MIGRATION.LEGACY_MARKER_SHAPE' },
},

@@ -196,4 +199,3 @@ );

}): CliStructuredError {
return new CliStructuredError('3010', 'Database must be signed first', {
domain: 'RUN',
return new CliStructuredError('CONTRACT.MARKER_REQUIRED', 'Database must be signed first', {
why: options?.why ?? 'No database signature (marker) found',

@@ -213,4 +215,3 @@ fix: options?.fix ?? 'Run `prisma-next db init` first to sign the database',

}): CliStructuredError {
return new CliStructuredError('3004', options.summary, {
domain: 'RUN',
return new CliStructuredError('CONTRACT.SCHEMA_VERIFICATION_FAILED', options.summary, {
why: 'Database schema does not satisfy the contract',

@@ -236,4 +237,3 @@ fix: 'Run `prisma-next db update` to reconcile, or adjust your contract to match the database',

): CliStructuredError {
return new CliStructuredError('3020', summary, {
domain: 'RUN',
return new CliStructuredError('MIGRATION.RUNNER_FAILED', summary, {
why: options?.why ?? 'Migration runner failed',

@@ -246,3 +246,3 @@ fix: options?.fix ?? 'Inspect the reported conflict and reconcile schema drift',

/** Error code for destructive changes that require explicit confirmation. */
export const ERROR_CODE_DESTRUCTIVE_CHANGES = '3030';
export const ERROR_CODE_DESTRUCTIVE_CHANGES = 'MIGRATION.DESTRUCTIVE_CHANGES';

@@ -261,3 +261,2 @@ /**

return new CliStructuredError(ERROR_CODE_DESTRUCTIVE_CHANGES, summary, {
domain: 'RUN',
why: options?.why ?? 'Planned operations include destructive changes that require confirmation',

@@ -280,4 +279,3 @@ fix: options?.fix ?? 'Re-run with `-y` to apply, or use `--dry-run` to preview first',

): CliStructuredError {
return new CliStructuredError('3000', summary, {
domain: 'RUN',
return new CliStructuredError('CONTRACT.VERIFY_FAILED', summary, {
...(options?.why ? { why: options.why } : { why: 'Verification failed' }),

@@ -284,0 +282,0 @@ ...(options?.fix ? { fix: options.fix } : { fix: 'Check contract and database state' }),

import { CliStructuredError } from './control';
// ============================================================================
// Migration Errors (PN-MIG-2000-2999)
// Migration Errors (MIGRATION.*)
//
// Errors raised by the migration subsystem (authoring, planning, emit).
// Domain `MIG` distinguishes these from generic application runtime errors
// (`RUN`) and from CLI argument/config errors (`CLI`). See
// `docs/CLI Style Guide.md` for the canonical domain taxonomy.
// Errors raised by the migration subsystem (authoring, planning, emit). See
// ADR 239 for the namespace taxonomy.
// ============================================================================

@@ -20,8 +18,11 @@

export function errorUnfilledPlaceholder(slot: string): CliStructuredError {
return new CliStructuredError('2001', 'Unfilled migration placeholder', {
domain: 'MIG',
why: `The migration contains a placeholder that has not been filled in: ${slot}`,
fix: 'Open migration.ts and replace the `placeholder(...)` call with your actual query.',
meta: { slot },
});
return new CliStructuredError(
'MIGRATION.UNFILLED_PLACEHOLDER',
'Unfilled migration placeholder',
{
why: `The migration contains a placeholder that has not been filled in: ${slot}`,
fix: 'Open migration.ts and replace the `placeholder(...)` call with your actual query.',
meta: { slot },
},
);
}

@@ -32,3 +33,3 @@

* emit a real query and the author is expected to fill one in. Always throws
* a structured migration error (`PN-MIG-2001`).
* a structured migration error (`MIGRATION.UNFILLED_PLACEHOLDER`).
*

@@ -51,5 +52,5 @@ * The return type `never` makes it assignable to any expected return type, so

*
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
* Distinct from `errorHashMismatch` (`CONTRACT.MARKER_MISMATCH`) which
* rejects a plan at runtime execution; this is an authoring-time rejection
* so it lives in the `MIG` namespace.
* so it lives in the `MIGRATION` namespace.
*/

@@ -61,12 +62,15 @@ export function errorDataTransformContractMismatch(options: {

}): CliStructuredError {
return new CliStructuredError('2005', 'dataTransform query plan built against wrong contract', {
domain: 'MIG',
why: `Data transform "${options.dataTransformName}" produced a query plan whose storage hash (${options.actual}) does not match the migration's contract (${options.expected}). The query builder was configured with a different contract than the one passed to dataTransform(endContract, ...).`,
fix: 'Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.',
meta: {
dataTransformName: options.dataTransformName,
expected: options.expected,
actual: options.actual,
return new CliStructuredError(
'MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH',
'dataTransform query plan built against wrong contract',
{
why: `Data transform "${options.dataTransformName}" produced a query plan whose storage hash (${options.actual}) does not match the migration's contract (${options.expected}). The query builder was configured with a different contract than the one passed to dataTransform(endContract, ...).`,
fix: 'Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.',
meta: {
dataTransformName: options.dataTransformName,
expected: options.expected,
actual: options.actual,
},
},
});
);
}

@@ -80,4 +84,3 @@

export function errorMigrationFileMissing(dir: string): CliStructuredError {
return new CliStructuredError('2002', 'migration.ts not found', {
domain: 'MIG',
return new CliStructuredError('MIGRATION.FILE_MISSING', 'migration.ts not found', {
why: `No migration.ts file was found at "${dir}"`,

@@ -102,14 +105,17 @@ fix: 'Scaffold one with `prisma-next migration new` or `prisma-next migration plan`.',

): CliStructuredError {
return new CliStructuredError('2003', 'migration.ts default export is not a valid migration', {
domain: 'MIG',
why:
actualExportDescription !== undefined
? `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object; got ${actualExportDescription}`
: `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object.`,
fix: 'Use `export default class extends Migration { ... }` or `export default () => ({ targetId, destination, operations })`.',
meta: {
dir,
...(actualExportDescription !== undefined ? { actualExport: actualExportDescription } : {}),
return new CliStructuredError(
'MIGRATION.INVALID_DEFAULT_EXPORT',
'migration.ts default export is not a valid migration',
{
why:
actualExportDescription !== undefined
? `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object; got ${actualExportDescription}`
: `migration.ts at "${dir}" must default-export a Migration subclass or a factory function returning a MigrationPlan-shaped object.`,
fix: 'Use `export default class extends Migration { ... }` or `export default () => ({ targetId, destination, operations })`.',
meta: {
dir,
...(actualExportDescription !== undefined ? { actualExport: actualExportDescription } : {}),
},
},
});
);
}

@@ -129,11 +135,14 @@

}): CliStructuredError {
return new CliStructuredError('2006', 'Migration target does not match config target', {
domain: 'MIG',
why: `This migration is for target "${options.migrationTargetId}" but the loaded prisma-next.config.ts declares target "${options.configTargetId}". The migration script can only be run against a config that targets the same database.`,
fix: "Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.",
meta: {
migrationTargetId: options.migrationTargetId,
configTargetId: options.configTargetId,
return new CliStructuredError(
'MIGRATION.TARGET_MISMATCH',
'Migration target does not match config target',
{
why: `This migration is for target "${options.migrationTargetId}" but the loaded prisma-next.config.ts declares target "${options.configTargetId}". The migration script can only be run against a config that targets the same database.`,
fix: "Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.",
meta: {
migrationTargetId: options.migrationTargetId,
configTargetId: options.configTargetId,
},
},
});
);
}

@@ -149,14 +158,17 @@

): CliStructuredError {
return new CliStructuredError('2004', 'Migration.operations must be an array of operations', {
domain: 'MIG',
why:
actualValueDescription !== undefined
? `Migration.operations for migration.ts at "${dir}" was ${actualValueDescription}; an array of operations is required.`
: `Migration.operations for migration.ts at "${dir}" is not an array of operations.`,
fix: 'Ensure your `operations` getter returns an array of operations; see the data-migrations authoring guide.',
meta: {
dir,
...(actualValueDescription !== undefined ? { actualValue: actualValueDescription } : {}),
return new CliStructuredError(
'MIGRATION.PLAN_NOT_ARRAY',
'Migration.operations must be an array of operations',
{
why:
actualValueDescription !== undefined
? `Migration.operations for migration.ts at "${dir}" was ${actualValueDescription}; an array of operations is required.`
: `Migration.operations for migration.ts at "${dir}" is not an array of operations.`,
fix: 'Ensure your `operations` getter returns an array of operations; see the data-migrations authoring guide.',
meta: {
dir,
...(actualValueDescription !== undefined ? { actualValue: actualValueDescription } : {}),
},
},
});
);
}
//#region src/control.d.ts
/**
* CLI error envelope for output formatting.
* This is the serialized form of a CliStructuredError.
*/
interface CliErrorEnvelope {
readonly ok: false;
readonly code: string;
readonly domain: string;
readonly severity: 'error' | 'warn' | 'info';
readonly summary: string;
readonly why: string | undefined;
readonly fix: string | undefined;
readonly where: {
readonly path: string | undefined;
readonly line: number | undefined;
} | undefined;
readonly meta: Record<string, unknown> | undefined;
readonly docsUrl: string | undefined;
}
/**
* Minimal conflict data structure expected by CLI output.
*/
interface CliErrorConflict {
readonly kind: string;
readonly summary: string;
readonly why?: string;
}
/**
* Domain prefix for structured CLI error codes.
*
* The full envelope code is rendered as `PN-<domain>-<code>` (see
* `CliStructuredError.toEnvelope`). The supported domains follow the
* taxonomy documented in `docs/CLI Style Guide.md`:
*
* - `CLI` — CLI command processing (config, validation, planning)
* - `MIG` — Migration subsystem (authoring, planning conflicts, runner)
* - `RUN` — Application runtime (query execution, streaming)
* - `CON` — Contract subsystem (validation, normalization)
* - `SCHEMA` — Schema subsystem
*
* Sub-clustering within a domain is conveyed by the numeric code range; see
* the per-domain source files for reserved ranges.
*/
declare const CLI_ERROR_DOMAINS: readonly ["CLI", "RUN", "MIG", "CON", "SCHEMA"];
type CliErrorDomain = (typeof CLI_ERROR_DOMAINS)[number];
/**
* Structured CLI error that contains all information needed for error envelopes.
* Call sites throw these errors with full context.
*/
declare class CliStructuredError extends Error {
readonly code: string;
readonly domain: CliErrorDomain;
readonly severity: 'error' | 'warn' | 'info';
readonly why: string | undefined;
readonly fix: string | undefined;
readonly where: {
readonly path: string | undefined;
readonly line: number | undefined;
} | undefined;
readonly meta: Record<string, unknown> | undefined;
readonly docsUrl: string | undefined;
constructor(code: string, summary: string, options?: {
readonly domain?: CliErrorDomain;
readonly severity?: 'error' | 'warn' | 'info';
readonly why?: string;
readonly fix?: string;
readonly where?: {
readonly path?: string;
readonly line?: number;
};
readonly meta?: Record<string, unknown>;
readonly docsUrl?: string;
});
/**
* Converts this error to a CLI error envelope for output formatting.
*/
toEnvelope(): CliErrorEnvelope;
/**
* Type guard to check if an error is a CliStructuredError.
* Uses duck-typing to work across module boundaries where instanceof may fail.
*/
static is(error: unknown): error is CliStructuredError;
}
/**
* Config file not found or missing.
*/
declare function errorConfigFileNotFound(configPath?: string, options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract configuration missing from config.
*/
declare function errorContractConfigMissing(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract validation failed.
*/
declare function errorContractValidationFailed(reason: string, options?: {
readonly where?: {
readonly path?: string;
readonly line?: number;
};
}): CliStructuredError;
/**
* File not found.
*/
declare function errorFileNotFound(filePath: string, options?: {
readonly why?: string;
readonly fix?: string;
readonly docsUrl?: string;
}): CliStructuredError;
/**
* Database connection is required but not provided.
*/
declare function errorDatabaseConnectionRequired(options?: {
readonly why?: string;
readonly commandName?: string;
readonly retryCommand?: string;
readonly missingFlags?: readonly string[];
}): CliStructuredError;
/**
* Query runner factory is required but not provided in config.
*/
declare function errorQueryRunnerFactoryRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Family verify.readMarker is required but not provided.
*/
declare function errorFamilyReadMarkerSqlRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* JSON output format not supported.
*/
declare function errorJsonFormatNotSupported(options: {
readonly command: string;
readonly format: string;
readonly supportedFormats: readonly string[];
}): CliStructuredError;
/**
* Driver is required for DB-connected commands but not provided.
*/
declare function errorDriverRequired(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* Contract requires extension packs that are not provided by config descriptors.
*/
declare function errorContractMissingExtensionPacks(options: {
readonly missingExtensionPacks: readonly string[];
readonly providedComponentIds: readonly string[];
}): CliStructuredError;
/**
* Migration planning failed due to conflicts.
*/
declare function errorMigrationPlanningFailed(options: {
readonly conflicts: readonly CliErrorConflict[];
readonly why?: string;
}): CliStructuredError;
/**
* Target does not support migrations (missing createPlanner/createRunner).
*/
declare function errorTargetMigrationNotSupported(options?: {
readonly why?: string;
}): CliStructuredError;
/**
* The migration-file CLI received `--config` without a path argument (either
* a bare trailing `--config`, or `--config` followed by another flag like
* `--config --dry-run`). Surfacing this as a structured error fails fast
* rather than silently consuming the next flag as the config path or
* falling back to default discovery against the wrong project.
*/
declare function errorMigrationCliInvalidConfigArg(options?: {
readonly nextToken?: string;
}): CliStructuredError;
/**
* The migration-file CLI received a flag it does not recognise. Surfaced as a
* structured error so consumers can render their own "did you mean"
* suggestions from `meta.knownFlags` rather than parsing the message.
*
* Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:
* pass the offending token as `flag` and the option declarations as
* `knownFlags`.
*/
declare function errorMigrationCliUnknownFlag(options: {
readonly flag: string;
readonly knownFlags: readonly string[];
}): CliStructuredError;
/**
* The main CLI received an unsupported `--format` value.
*/
declare function errorInvalidOutputFormat(value: string): CliStructuredError;
/**
* The main CLI received mutually exclusive output format flags
* (`--format pretty` together with `--json`).
*/
declare function errorOutputFormatMutex(): CliStructuredError;
/**
* Config validation error (missing required fields).
*/
declare function errorConfigValidation(field: string, options?: {
readonly why?: string;
}): CliStructuredError;
/**
* An enum declares a codecId that no component in the contract's pack stack provides,
* so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`
* and PSL interpretation) when the codec lookup built from the contract's packs has no
* descriptor for the codecId.
*/
declare function errorEnumCodecNotInPackStack(options: {
readonly codecId: string;
}): CliStructuredError;
/**
* Generic unexpected error.
*/
declare function errorUnexpected(message: string, options?: {
readonly why?: string;
readonly fix?: string;
}): CliStructuredError;
//#endregion
export { errorUnexpected as S, errorMigrationCliUnknownFlag as _, errorConfigValidation as a, errorQueryRunnerFactoryRequired as b, errorContractValidationFailed as c, errorEnumCodecNotInPackStack as d, errorFamilyReadMarkerSqlRequired as f, errorMigrationCliInvalidConfigArg as g, errorJsonFormatNotSupported as h, errorConfigFileNotFound as i, errorDatabaseConnectionRequired as l, errorInvalidOutputFormat as m, CliErrorEnvelope as n, errorContractConfigMissing as o, errorFileNotFound as p, CliStructuredError as r, errorContractMissingExtensionPacks as s, CliErrorConflict as t, errorDriverRequired as u, errorMigrationPlanningFailed as v, errorTargetMigrationNotSupported as x, errorOutputFormatMutex as y };
//# sourceMappingURL=control-B20v3PXT.d.mts.map
{"version":3,"file":"control-B20v3PXT.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,MAAM;EAAA,SACZ,OAAA;AAAA;AAAO;AAMlB;;AANkB,UAMD,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;AAAA;;AAAG;AACb;;;;AAkBwE;AAEzE;;;;AAAsD;AAMtD;;;;cARM,iBAAA;AAAA,KAEM,cAAA,WAAyB,iBAAiB;;;;;cAMzC,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,IAAc,gBAAA;EAvBD;;;;EAAA,OA0CN,EAAA,CAAG,KAAA,YAAiB,KAAA,IAAS,kBAAA;AAAA;;;;iBA6CtB,uBAAA,CACd,UAAA,WACA,OAAA;EAAA,SACW,GAAA;AAAA,IAEV,kBAAkB;;;;iBAaL,0BAAA,CAA2B,OAAA;EAAA,SAChC,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BAAA,CAAyB,KAAA,WAAgB,kBAAkB;;;;;iBAe3D,sBAAA,IAA0B,kBAAkB;;AAjGtC;AAwBtB;iBAoFgB,qBAAA,CACd,KAAA,UACA,OAAA;EAAA,SACW,GAAA;AAAA,IAEV,kBAAkB;;;;;AAvFC;AAgBtB;iBA0FgB,4BAAA,CAA6B,OAAA;EAAA,SAClC,OAAA;AAAA,IACP,kBAAkB;;;;iBAgBN,eAAA,CACd,OAAA,UACA,OAAA;EAAA,SACW,GAAA;EAAA,SACA,GAAA;AAAA,IAEV,kBAAkB"}
//#region src/control.ts
/**
* Domain prefix for structured CLI error codes.
*
* The full envelope code is rendered as `PN-<domain>-<code>` (see
* `CliStructuredError.toEnvelope`). The supported domains follow the
* taxonomy documented in `docs/CLI Style Guide.md`:
*
* - `CLI` — CLI command processing (config, validation, planning)
* - `MIG` — Migration subsystem (authoring, planning conflicts, runner)
* - `RUN` — Application runtime (query execution, streaming)
* - `CON` — Contract subsystem (validation, normalization)
* - `SCHEMA` — Schema subsystem
*
* Sub-clustering within a domain is conveyed by the numeric code range; see
* the per-domain source files for reserved ranges.
*/
const CLI_ERROR_DOMAINS = [
"CLI",
"RUN",
"MIG",
"CON",
"SCHEMA"
];
/**
* Structured CLI error that contains all information needed for error envelopes.
* Call sites throw these errors with full context.
*/
var CliStructuredError = class extends Error {
code;
domain;
severity;
why;
fix;
where;
meta;
docsUrl;
constructor(code, summary, options) {
super(summary);
this.name = "CliStructuredError";
this.code = code;
this.domain = options?.domain ?? "CLI";
this.severity = options?.severity ?? "error";
this.why = options?.why;
this.fix = options?.fix === options?.why ? void 0 : options?.fix;
this.where = options?.where ? {
path: options.where.path,
line: options.where.line
} : void 0;
this.meta = options?.meta;
this.docsUrl = options?.docsUrl;
}
/**
* Converts this error to a CLI error envelope for output formatting.
*/
toEnvelope() {
return {
ok: false,
code: `PN-${this.domain}-${this.code}`,
domain: this.domain,
severity: this.severity,
summary: this.message,
why: this.why,
fix: this.fix,
where: this.where,
meta: this.meta,
docsUrl: this.docsUrl
};
}
/**
* Type guard to check if an error is a CliStructuredError.
* Uses duck-typing to work across module boundaries where instanceof may fail.
*/
static is(error) {
if (!(error instanceof Error)) return false;
const candidate = error;
return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && isCliErrorDomain(candidate.domain) && typeof candidate.toEnvelope === "function";
}
};
const CLI_ERROR_DOMAIN_SET = new Set(CLI_ERROR_DOMAINS);
function isCliErrorDomain(value) {
return typeof value === "string" && CLI_ERROR_DOMAIN_SET.has(value);
}
/**
* Config file not found or missing.
*/
function errorConfigFileNotFound(configPath, options) {
return new CliStructuredError("4001", "Config file not found", {
domain: "CLI",
...options?.why ? { why: options.why } : { why: "Config file not found" },
fix: "Run 'prisma-next init' to create a config file",
docsUrl: "https://prisma-next.dev/docs/cli/config",
...configPath ? { where: { path: configPath } } : {}
});
}
/**
* Contract configuration missing from config.
*/
function errorContractConfigMissing(options) {
return new CliStructuredError("4002", "Contract configuration missing", {
domain: "CLI",
why: options?.why ?? "The contract configuration is required for emit",
fix: "Add contract configuration to your prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/contract-emit"
});
}
/**
* Contract validation failed.
*/
function errorContractValidationFailed(reason, options) {
return new CliStructuredError("4003", "Contract validation failed", {
domain: "CLI",
why: reason,
fix: "Re-run `prisma-next contract emit`, or fix the contract file and try again",
docsUrl: "https://prisma-next.dev/docs/contracts",
...options?.where ? { where: options.where } : {}
});
}
/**
* File not found.
*/
function errorFileNotFound(filePath, options) {
return new CliStructuredError("4004", "File not found", {
domain: "CLI",
why: options?.why ?? `File not found: ${filePath}`,
fix: options?.fix ?? "Check that the file path is correct",
where: { path: filePath },
...options?.docsUrl ? { docsUrl: options.docsUrl } : {}
});
}
/**
* Database connection is required but not provided.
*/
function errorDatabaseConnectionRequired(options) {
const runHint = options?.retryCommand ? `Run \`${options.retryCommand}\`` : options?.commandName ? `Run \`prisma-next ${options.commandName} --db <url>\`` : "Provide `--db <url>`";
return new CliStructuredError("4005", "Database connection is required", {
domain: "CLI",
why: options?.why ?? "Database connection is required for this command",
fix: `${runHint}, or set \`db: { connection: "postgres://…" }\` in prisma-next.config.ts`,
...options?.missingFlags !== void 0 ? { meta: { missingFlags: [...options.missingFlags] } } : {}
});
}
/**
* Query runner factory is required but not provided in config.
*/
function errorQueryRunnerFactoryRequired(options) {
return new CliStructuredError("4006", "Query runner factory is required", {
domain: "CLI",
why: options?.why ?? "Config.db.queryRunnerFactory is required for db verify",
fix: "Add db.queryRunnerFactory to prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
});
}
/**
* Family verify.readMarker is required but not provided.
*/
function errorFamilyReadMarkerSqlRequired(options) {
return new CliStructuredError("4007", "Family readMarker() is required", {
domain: "CLI",
why: options?.why ?? "Family verify.readMarker is required for db verify",
fix: "Ensure family.verify.readMarker() is exported by your family package",
docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
});
}
/**
* JSON output format not supported.
*/
function errorJsonFormatNotSupported(options) {
return new CliStructuredError("4008", "Unsupported JSON format", {
domain: "CLI",
why: `The ${options.command} command does not support --json ${options.format}`,
fix: `Use --json ${options.supportedFormats.join(" or ")}, or omit --json for human output`,
meta: {
command: options.command,
format: options.format,
supportedFormats: options.supportedFormats
}
});
}
/**
* Driver is required for DB-connected commands but not provided.
*/
function errorDriverRequired(options) {
return new CliStructuredError("4010", "Driver is required for DB-connected commands", {
domain: "CLI",
why: options?.why ?? "Config.driver is required for DB-connected commands",
fix: "Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)",
docsUrl: "https://prisma-next.dev/docs/cli/config"
});
}
/**
* Contract requires extension packs that are not provided by config descriptors.
*/
function errorContractMissingExtensionPacks(options) {
const missing = [...options.missingExtensionPacks].sort();
return new CliStructuredError("4011", "Missing extension packs in config", {
domain: "CLI",
why: missing.length === 1 ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.` : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(", ")}, but CLI config does not provide matching descriptors.`,
fix: "Add the missing extension descriptors to `extensions` in prisma-next.config.ts",
docsUrl: "https://prisma-next.dev/docs/cli/config",
meta: {
missingExtensionPacks: missing,
providedComponentIds: [...options.providedComponentIds].sort()
}
});
}
/**
* Migration planning failed due to conflicts.
*/
function errorMigrationPlanningFailed(options) {
const conflictSummaries = options.conflicts.map((c) => c.summary);
const computedWhy = options.why ?? conflictSummaries.join("\n");
const conflictFixes = options.conflicts.map((c) => c.why).filter((why) => typeof why === "string");
return new CliStructuredError("4020", "Migration planning failed", {
domain: "CLI",
why: computedWhy,
fix: conflictFixes.length > 0 ? conflictFixes.join("\n") : "Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty",
meta: { conflicts: options.conflicts },
docsUrl: "https://prisma-next.dev/docs/cli/db-init"
});
}
/**
* Target does not support migrations (missing createPlanner/createRunner).
*/
function errorTargetMigrationNotSupported(options) {
return new CliStructuredError("4021", "Target does not support migrations", {
domain: "CLI",
why: options?.why ?? "The configured target does not provide migration planner/runner",
fix: "Select a target that provides migrations (it must export `target.migrations` for db init)",
docsUrl: "https://prisma-next.dev/docs/cli/db-init"
});
}
/**
* The migration-file CLI received `--config` without a path argument (either
* a bare trailing `--config`, or `--config` followed by another flag like
* `--config --dry-run`). Surfacing this as a structured error fails fast
* rather than silently consuming the next flag as the config path or
* falling back to default discovery against the wrong project.
*/
function errorMigrationCliInvalidConfigArg(options) {
return new CliStructuredError("4012", "--config flag requires a path argument", {
domain: "CLI",
why: options?.nextToken !== void 0 ? `\`--config\` was followed by another flag (\`${options.nextToken}\`) instead of a path argument.` : "`--config` was passed without a following path argument.",
fix: "Pass a config path: `--config <path>` or `--config=<path>`.",
meta: options?.nextToken !== void 0 ? { nextToken: options.nextToken } : {}
});
}
/**
* The migration-file CLI received a flag it does not recognise. Surfaced as a
* structured error so consumers can render their own "did you mean"
* suggestions from `meta.knownFlags` rather than parsing the message.
*
* Designed to wrap clipanion's `UnknownSyntaxError` at the parser boundary:
* pass the offending token as `flag` and the option declarations as
* `knownFlags`.
*/
function errorMigrationCliUnknownFlag(options) {
const knownList = options.knownFlags.join(", ");
return new CliStructuredError("4013", "Unknown migration CLI flag", {
domain: "CLI",
why: `Unknown flag \`${options.flag}\`.`,
fix: `Known flags: ${knownList}. Run with \`--help\` to see the full list.`,
meta: {
flag: options.flag,
knownFlags: options.knownFlags
}
});
}
/**
* The main CLI received an unsupported `--format` value.
*/
function errorInvalidOutputFormat(value) {
return new CliStructuredError("4014", `Invalid --format value "${value}". Allowed values: pretty, json.`, {
domain: "CLI",
meta: {
value,
allowed: ["pretty", "json"]
}
});
}
/**
* The main CLI received mutually exclusive output format flags
* (`--format pretty` together with `--json`).
*/
function errorOutputFormatMutex() {
return new CliStructuredError("4015", "Cannot use --format pretty together with --json. Use --format json or --json alone for JSON output.", { domain: "CLI" });
}
/**
* Config validation error (missing required fields).
*/
function errorConfigValidation(field, options) {
return new CliStructuredError("4009", "Config validation error", {
domain: "CLI",
why: options?.why ?? `Config must have a "${field}" field`,
fix: "Check your prisma-next.config.ts and ensure all required fields are provided",
docsUrl: "https://prisma-next.dev/docs/cli/config"
});
}
/**
* An enum declares a codecId that no component in the contract's pack stack provides,
* so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`
* and PSL interpretation) when the codec lookup built from the contract's packs has no
* descriptor for the codecId.
*/
function errorEnumCodecNotInPackStack(options) {
return new CliStructuredError("4016", `Enum codec "${options.codecId}" is not part of the contract's pack stack`, {
domain: "CON",
why: `An enum uses codec "${options.codecId}", but no family, target, or extension pack in the contract provides it.`,
fix: "Use a codec provided by the contract's target/extension packs, or add the pack that supplies this codec.",
meta: { codecId: options.codecId }
});
}
/**
* Generic unexpected error.
*/
function errorUnexpected(message, options) {
return new CliStructuredError("4999", "Unexpected error", {
domain: "CLI",
why: options?.why ?? message,
fix: options?.fix ?? "Check the error message and try again"
});
}
//#endregion
export { errorOutputFormatMutex as _, errorContractMissingExtensionPacks as a, errorUnexpected as b, errorDriverRequired as c, errorFileNotFound as d, errorInvalidOutputFormat as f, errorMigrationPlanningFailed as g, errorMigrationCliUnknownFlag as h, errorContractConfigMissing as i, errorEnumCodecNotInPackStack as l, errorMigrationCliInvalidConfigArg as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorJsonFormatNotSupported as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFamilyReadMarkerSqlRequired as u, errorQueryRunnerFactoryRequired as v, errorTargetMigrationNotSupported as y };
//# sourceMappingURL=control-BVMQqofj.mjs.map
{"version":3,"file":"control-BVMQqofj.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 readonly missingFlags?: readonly 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 ...(options?.missingFlags !== undefined\n ? { meta: { missingFlags: [...options.missingFlags] } }\n : {}),\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 * An enum declares a codecId that no component in the contract's pack stack provides,\n * so its member values cannot be encoded. Thrown by both authoring paths (TS `defineContract`\n * and PSL interpretation) when the codec lookup built from the contract's packs has no\n * descriptor for the codecId.\n */\nexport function errorEnumCodecNotInPackStack(options: {\n readonly codecId: string;\n}): CliStructuredError {\n return new CliStructuredError(\n '4016',\n `Enum codec \"${options.codecId}\" is not part of the contract's pack stack`,\n {\n domain: 'CON',\n why: `An enum uses codec \"${options.codecId}\", but no family, target, or extension pack in the contract provides it.`,\n fix: \"Use a codec provided by the contract's target/extension packs, or add the pack that supplies this codec.\",\n meta: { codecId: options.codecId },\n },\n );\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;AAAQ;;;;;AAQ/D,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CACA;CACA;CACA;CACA;CACA;CAMA;CACA;CAEA,YACE,MACA,SACA,SASA;EACA,MAAM,OAAO;EACb,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;EACtB,IACA,KAAA;EACJ,KAAK,OAAO,SAAS;EACrB,KAAK,UAAU,SAAS;CAC1B;;;;CAKA,aAA+B;EAC7B,OAAO;GACL,IAAI;GACJ,MAAM,MAAM,KAAK,OAAO,GAAG,KAAK;GAChC,QAAQ,KAAK;GACb,UAAU,KAAK;GACf,SAAS,KAAK;GACd,KAAK,KAAK;GACV,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,SAAS,KAAK;EAChB;CACF;;;;;CAMA,OAAO,GAAG,OAA6C;EACrD,IAAI,EAAE,iBAAiB,QACrB,OA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