@prisma-next/errors 0.4.1 → 0.5.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{control-M7-bPTyk.d.mts → control-Bzl70Ny9.d.mts} +12 -2
- package/dist/{control-M7-bPTyk.d.mts.map → control-Bzl70Ny9.d.mts.map} +1 -1
- package/dist/{control-CjD1SB2D.mjs → control-Ly06UGvt.mjs} +17 -2
- package/dist/{control-CjD1SB2D.mjs.map → control-Ly06UGvt.mjs.map} +1 -1
- package/dist/control.d.mts +2 -2
- package/dist/control.mjs +2 -2
- package/dist/execution.d.mts +1 -1
- package/dist/execution.mjs +1 -1
- package/dist/migration.d.mts +14 -2
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +21 -2
- package/dist/migration.mjs.map +1 -1
- package/package.json +3 -3
- package/src/control.ts +22 -0
- package/src/exports/control.ts +1 -0
- package/src/exports/migration.ts +1 -0
- package/src/migration.ts +23 -0
|
@@ -165,6 +165,16 @@ declare function errorMigrationPlanningFailed(options: {
|
|
|
165
165
|
declare function errorTargetMigrationNotSupported(options?: {
|
|
166
166
|
readonly why?: string;
|
|
167
167
|
}): CliStructuredError;
|
|
168
|
+
/**
|
|
169
|
+
* The migration-file CLI received `--config` without a path argument (either
|
|
170
|
+
* a bare trailing `--config`, or `--config` followed by another flag like
|
|
171
|
+
* `--config --dry-run`). Surfacing this as a structured error fails fast
|
|
172
|
+
* rather than silently consuming the next flag as the config path or
|
|
173
|
+
* falling back to default discovery against the wrong project.
|
|
174
|
+
*/
|
|
175
|
+
declare function errorMigrationCliInvalidConfigArg(options?: {
|
|
176
|
+
readonly nextToken?: string;
|
|
177
|
+
}): CliStructuredError;
|
|
168
178
|
/**
|
|
169
179
|
* Config validation error (missing required fields).
|
|
170
180
|
*/
|
|
@@ -179,5 +189,5 @@ declare function errorUnexpected(message: string, options?: {
|
|
|
179
189
|
readonly fix?: string;
|
|
180
190
|
}): CliStructuredError;
|
|
181
191
|
//#endregion
|
|
182
|
-
export {
|
|
183
|
-
//# sourceMappingURL=control-
|
|
192
|
+
export { errorTargetMigrationNotSupported as _, errorConfigValidation as a, errorContractValidationFailed as c, errorFamilyReadMarkerSqlRequired as d, errorFileNotFound as f, errorQueryRunnerFactoryRequired as g, errorMigrationPlanningFailed as h, errorConfigFileNotFound as i, errorDatabaseConnectionRequired as l, errorMigrationCliInvalidConfigArg as m, CliErrorEnvelope as n, errorContractConfigMissing as o, errorJsonFormatNotSupported as p, CliStructuredError as r, errorContractMissingExtensionPacks as s, CliErrorConflict as t, errorDriverRequired as u, errorUnexpected as v };
|
|
193
|
+
//# sourceMappingURL=control-Bzl70Ny9.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-
|
|
1
|
+
{"version":3,"file":"control-Bzl70Ny9.d.mts","names":[],"sources":["../src/control.ts"],"sourcesContent":[],"mappings":";;AAIA;AAqBA;AAIC;AAoBW,UA7CK,gBAAA,CA6CoB;EAMxB,SAAA,EAAA,EAAA,KAAA;EAEM,SAAA,IAAA,EAAA,MAAA;EAUF,SAAA,MAAA,EAAA,MAAA;EAOO,SAAA,QAAA,EAAA,OAAA,GAAA,MAAA,GAAA,MAAA;EAKF,SAAA,OAAA,EAAA,MAAA;EAwBN,SAAA,GAAA,EAAA,MAAA,GAAA,SAAA;EAmBsB,SAAA,GAAA,EAAA,MAAA,GAAA,SAAA;EAnEE,SAAA,KAAA,EAAA;IAAK,SAAA,IAAA,EAAA,MAAA,GAAA,SAAA;IA8F7B,SAAA,IAAA,EAAA,MAAA,GAAuB,SAKpC;EAaa,CAAA,GAAA,SAAA;EAcA,SAAA,IAAA,EAnKC,MAmKD,CAAA,MAAA,EAAA,OAA6B,CAAA,GAAA,SAK1C;EAaa,SAAA,OAAA,EAAA,MAAiB,GAAA,SAO9B;AAaH;AAoBA;AAcA;AAcA;AAoBgB,UAtQC,gBAAA,CAsQkB;EAYnB,SAAA,IAAA,EAAA,MAAA;EAuBA,SAAA,OAAA,EAAA,MAAA;EA2BA,SAAA,GAAA,CAAA,EAAA,MAAA;AAkBhB;AAkBA;AAqBA;;;;;;;;;;;;;;;cAvWM;KAEM,cAAA,WAAyB;;;;;cAMxB,kBAAA,SAA2B,KAAA;;mBAErB;;;;;;;;iBAUF;;;sBAOO;;;;;;;;oBAKF;;;;;;gBAwBN;;;;;sCAmBsB;;;;;iBA2BtB,uBAAA;;IAKb;;;;iBAaa,0BAAA;;IAEZ;;;;iBAYY,6BAAA;;;;;IAKb;;;;iBAaa,iBAAA;;;;IAOb;;;;iBAaa,+BAAA;;;;IAIZ;;;;iBAgBY,+BAAA;;IAEZ;;;;iBAYY,gCAAA;;IAEZ;;;;iBAYY,2BAAA;;;;IAIZ;;;;iBAgBY,mBAAA;;IAA0D;;;;iBAY1D,kCAAA;;;IAGZ;;;;iBAoBY,4BAAA;+BACe;;IAE3B;;;;iBAwBY,gCAAA;;IAEZ;;;;;;;;iBAgBY,iCAAA;;IAEZ;;;;iBAgBY,qBAAA;;IAKb;;;;iBAgBa,eAAA;;;IAMb"}
|
|
@@ -230,6 +230,21 @@ function errorTargetMigrationNotSupported(options) {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
+
* The migration-file CLI received `--config` without a path argument (either
|
|
234
|
+
* a bare trailing `--config`, or `--config` followed by another flag like
|
|
235
|
+
* `--config --dry-run`). Surfacing this as a structured error fails fast
|
|
236
|
+
* rather than silently consuming the next flag as the config path or
|
|
237
|
+
* falling back to default discovery against the wrong project.
|
|
238
|
+
*/
|
|
239
|
+
function errorMigrationCliInvalidConfigArg(options) {
|
|
240
|
+
return new CliStructuredError("4012", "--config flag requires a path argument", {
|
|
241
|
+
domain: "CLI",
|
|
242
|
+
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.",
|
|
243
|
+
fix: "Pass a config path: `--config <path>` or `--config=<path>`.",
|
|
244
|
+
meta: options?.nextToken !== void 0 ? { nextToken: options.nextToken } : {}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
233
248
|
* Config validation error (missing required fields).
|
|
234
249
|
*/
|
|
235
250
|
function errorConfigValidation(field, options) {
|
|
@@ -252,5 +267,5 @@ function errorUnexpected(message, options) {
|
|
|
252
267
|
}
|
|
253
268
|
|
|
254
269
|
//#endregion
|
|
255
|
-
export { errorContractMissingExtensionPacks as a, errorDriverRequired as c, errorJsonFormatNotSupported as d,
|
|
256
|
-
//# sourceMappingURL=control-
|
|
270
|
+
export { errorContractMissingExtensionPacks as a, errorDriverRequired as c, errorJsonFormatNotSupported as d, errorMigrationCliInvalidConfigArg as f, errorUnexpected as g, errorTargetMigrationNotSupported as h, errorContractConfigMissing as i, errorFamilyReadMarkerSqlRequired as l, errorQueryRunnerFactoryRequired as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorMigrationPlanningFailed as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFileNotFound as u };
|
|
271
|
+
//# sourceMappingURL=control-Ly06UGvt.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-CjD1SB2D.mjs","names":["CLI_ERROR_DOMAIN_SET: ReadonlySet<CliErrorDomain>"],"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// Config Errors (PN-CLI-4001-4007)\n// ============================================================================\n\n/**\n * Config file not found or missing.\n */\nexport function errorConfigFileNotFound(\n configPath?: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n ...(options?.why ? { why: options.why } : { why: 'Config file not found' }),\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n ...(configPath ? { where: { path: configPath } } : {}),\n });\n}\n\n/**\n * Contract configuration missing from config.\n */\nexport function errorContractConfigMissing(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4002', 'Contract configuration missing', {\n domain: 'CLI',\n why: options?.why ?? 'The contract configuration is required for emit',\n fix: 'Add contract configuration to your prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',\n });\n}\n\n/**\n * Contract validation failed.\n */\nexport function errorContractValidationFailed(\n reason: string,\n options?: {\n readonly where?: { readonly path?: string; readonly line?: number };\n },\n): CliStructuredError {\n return new CliStructuredError('4003', 'Contract validation failed', {\n domain: 'CLI',\n why: reason,\n fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',\n docsUrl: 'https://prisma-next.dev/docs/contracts',\n ...(options?.where ? { where: options.where } : {}),\n });\n}\n\n/**\n * File not found.\n */\nexport function errorFileNotFound(\n filePath: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly docsUrl?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: options?.fix ?? 'Check that the file path is correct',\n where: { path: filePath },\n ...(options?.docsUrl ? { docsUrl: options.docsUrl } : {}),\n });\n}\n\n/**\n * Database connection is required but not provided.\n */\nexport function errorDatabaseConnectionRequired(options?: {\n readonly why?: string;\n readonly commandName?: string;\n readonly retryCommand?: string;\n}): CliStructuredError {\n const runHint = options?.retryCommand\n ? `Run \\`${options.retryCommand}\\``\n : options?.commandName\n ? `Run \\`prisma-next ${options.commandName} --db <url>\\``\n : 'Provide `--db <url>`';\n return new CliStructuredError('4005', 'Database connection is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database connection is required for this command',\n fix: `${runHint}, or set \\`db: { connection: \"postgres://…\" }\\` in prisma-next.config.ts`,\n });\n}\n\n/**\n * Query runner factory is required but not provided in config.\n */\nexport function errorQueryRunnerFactoryRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4006', 'Query runner factory is required', {\n domain: 'CLI',\n why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',\n fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4007', 'Family readMarker() is required', {\n domain: 'CLI',\n why: options?.why ?? 'Family verify.readMarker is required for db verify',\n fix: 'Ensure family.verify.readMarker() is exported by your family package',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * JSON output format not supported.\n */\nexport function errorJsonFormatNotSupported(options: {\n readonly command: string;\n readonly format: string;\n readonly supportedFormats: readonly string[];\n}): CliStructuredError {\n return new CliStructuredError('4008', 'Unsupported JSON format', {\n domain: 'CLI',\n why: `The ${options.command} command does not support --json ${options.format}`,\n fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,\n meta: {\n command: options.command,\n format: options.format,\n supportedFormats: options.supportedFormats,\n },\n });\n}\n\n/**\n * Driver is required for DB-connected commands but not provided.\n */\nexport function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {\n domain: 'CLI',\n why: options?.why ?? 'Config.driver is required for DB-connected commands',\n fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n/**\n * Contract requires extension packs that are not provided by config descriptors.\n */\nexport function errorContractMissingExtensionPacks(options: {\n readonly missingExtensionPacks: readonly string[];\n readonly providedComponentIds: readonly string[];\n}): CliStructuredError {\n const missing = [...options.missingExtensionPacks].sort();\n return new CliStructuredError('4011', 'Missing extension packs in config', {\n domain: 'CLI',\n why:\n missing.length === 1\n ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`\n : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,\n fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n meta: {\n missingExtensionPacks: missing,\n providedComponentIds: [...options.providedComponentIds].sort(),\n },\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly CliErrorConflict[];\n readonly why?: string;\n}): CliStructuredError {\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n const conflictFixes = options.conflicts\n .map((c) => c.why)\n .filter((why): why is string => typeof why === 'string');\n const computedFix =\n conflictFixes.length > 0\n ? conflictFixes.join('\\n')\n : 'Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty';\n\n return new CliStructuredError('4020', 'Migration planning failed', {\n domain: 'CLI',\n why: computedWhy,\n fix: computedFix,\n meta: { conflicts: options.conflicts },\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Target does not support migrations (missing createPlanner/createRunner).\n */\nexport function errorTargetMigrationNotSupported(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4021', 'Target does not support migrations', {\n domain: 'CLI',\n why: options?.why ?? 'The configured target does not provide migration planner/runner',\n fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Config validation error (missing required fields).\n */\nexport function errorConfigValidation(\n field: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4009', 'Config validation error', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: 'Check your prisma-next.config.ts and ensure all required fields are provided',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Generic Error\n// ============================================================================\n\n/**\n * Generic unexpected error.\n */\nexport function errorUnexpected(\n message: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4999', 'Unexpected error', {\n domain: 'CLI',\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,MAAM,oBAAoB;CAAC;CAAO;CAAO;CAAO;CAAO;CAAS;;;;;AAQhE,IAAa,qBAAb,cAAwC,MAAM;CAC5C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mB,QAAQ,sCAAsC;EAC1E,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACL,SAAS;EACV,CAAC;;;;;AAMJ,SAAgB,sBACd,OACA,SAGoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,2BAA2B;EAC/D,QAAQ;EACR,KAAK,SAAS,OAAO,uBAAuB,MAAM;EAClD,KAAK;EACL,SAAS;EACV,CAAC;;;;;AAUJ,SAAgB,gBACd,SACA,SAIoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,oBAAoB;EACxD,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;EACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"control-Ly06UGvt.mjs","names":["CLI_ERROR_DOMAIN_SET: ReadonlySet<CliErrorDomain>"],"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// Config Errors (PN-CLI-4001-4007)\n// ============================================================================\n\n/**\n * Config file not found or missing.\n */\nexport function errorConfigFileNotFound(\n configPath?: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n ...(options?.why ? { why: options.why } : { why: 'Config file not found' }),\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n ...(configPath ? { where: { path: configPath } } : {}),\n });\n}\n\n/**\n * Contract configuration missing from config.\n */\nexport function errorContractConfigMissing(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4002', 'Contract configuration missing', {\n domain: 'CLI',\n why: options?.why ?? 'The contract configuration is required for emit',\n fix: 'Add contract configuration to your prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',\n });\n}\n\n/**\n * Contract validation failed.\n */\nexport function errorContractValidationFailed(\n reason: string,\n options?: {\n readonly where?: { readonly path?: string; readonly line?: number };\n },\n): CliStructuredError {\n return new CliStructuredError('4003', 'Contract validation failed', {\n domain: 'CLI',\n why: reason,\n fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',\n docsUrl: 'https://prisma-next.dev/docs/contracts',\n ...(options?.where ? { where: options.where } : {}),\n });\n}\n\n/**\n * File not found.\n */\nexport function errorFileNotFound(\n filePath: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly docsUrl?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: options?.fix ?? 'Check that the file path is correct',\n where: { path: filePath },\n ...(options?.docsUrl ? { docsUrl: options.docsUrl } : {}),\n });\n}\n\n/**\n * Database connection is required but not provided.\n */\nexport function errorDatabaseConnectionRequired(options?: {\n readonly why?: string;\n readonly commandName?: string;\n readonly retryCommand?: string;\n}): CliStructuredError {\n const runHint = options?.retryCommand\n ? `Run \\`${options.retryCommand}\\``\n : options?.commandName\n ? `Run \\`prisma-next ${options.commandName} --db <url>\\``\n : 'Provide `--db <url>`';\n return new CliStructuredError('4005', 'Database connection is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database connection is required for this command',\n fix: `${runHint}, or set \\`db: { connection: \"postgres://…\" }\\` in prisma-next.config.ts`,\n });\n}\n\n/**\n * Query runner factory is required but not provided in config.\n */\nexport function errorQueryRunnerFactoryRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4006', 'Query runner factory is required', {\n domain: 'CLI',\n why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',\n fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4007', 'Family readMarker() is required', {\n domain: 'CLI',\n why: options?.why ?? 'Family verify.readMarker is required for db verify',\n fix: 'Ensure family.verify.readMarker() is exported by your family package',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * JSON output format not supported.\n */\nexport function errorJsonFormatNotSupported(options: {\n readonly command: string;\n readonly format: string;\n readonly supportedFormats: readonly string[];\n}): CliStructuredError {\n return new CliStructuredError('4008', 'Unsupported JSON format', {\n domain: 'CLI',\n why: `The ${options.command} command does not support --json ${options.format}`,\n fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,\n meta: {\n command: options.command,\n format: options.format,\n supportedFormats: options.supportedFormats,\n },\n });\n}\n\n/**\n * Driver is required for DB-connected commands but not provided.\n */\nexport function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {\n domain: 'CLI',\n why: options?.why ?? 'Config.driver is required for DB-connected commands',\n fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n/**\n * Contract requires extension packs that are not provided by config descriptors.\n */\nexport function errorContractMissingExtensionPacks(options: {\n readonly missingExtensionPacks: readonly string[];\n readonly providedComponentIds: readonly string[];\n}): CliStructuredError {\n const missing = [...options.missingExtensionPacks].sort();\n return new CliStructuredError('4011', 'Missing extension packs in config', {\n domain: 'CLI',\n why:\n missing.length === 1\n ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`\n : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,\n fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n meta: {\n missingExtensionPacks: missing,\n providedComponentIds: [...options.providedComponentIds].sort(),\n },\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly CliErrorConflict[];\n readonly why?: string;\n}): CliStructuredError {\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n const conflictFixes = options.conflicts\n .map((c) => c.why)\n .filter((why): why is string => typeof why === 'string');\n const computedFix =\n conflictFixes.length > 0\n ? conflictFixes.join('\\n')\n : 'Use `db verify --schema-only` to inspect conflicts, or ensure the database is empty';\n\n return new CliStructuredError('4020', 'Migration planning failed', {\n domain: 'CLI',\n why: computedWhy,\n fix: computedFix,\n meta: { conflicts: options.conflicts },\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Target does not support migrations (missing createPlanner/createRunner).\n */\nexport function errorTargetMigrationNotSupported(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4021', 'Target does not support migrations', {\n domain: 'CLI',\n why: options?.why ?? 'The configured target does not provide migration planner/runner',\n fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * The migration-file CLI received `--config` without a path argument (either\n * a bare trailing `--config`, or `--config` followed by another flag like\n * `--config --dry-run`). Surfacing this as a structured error fails fast\n * rather than silently consuming the next flag as the config path or\n * falling back to default discovery against the wrong project.\n */\nexport function errorMigrationCliInvalidConfigArg(options?: {\n readonly nextToken?: string;\n}): CliStructuredError {\n const why =\n options?.nextToken !== undefined\n ? `\\`--config\\` was followed by another flag (\\`${options.nextToken}\\`) instead of a path argument.`\n : '`--config` was passed without a following path argument.';\n return new CliStructuredError('4012', '--config flag requires a path argument', {\n domain: 'CLI',\n why,\n fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',\n meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},\n });\n}\n\n/**\n * Config validation error (missing required fields).\n */\nexport function errorConfigValidation(\n field: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4009', 'Config validation error', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: 'Check your prisma-next.config.ts and ensure all required fields are provided',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Generic Error\n// ============================================================================\n\n/**\n * Generic unexpected error.\n */\nexport function errorUnexpected(\n message: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4999', 'Unexpected error', {\n domain: 'CLI',\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mappings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ACxB;EAMJ,MAAM,EAAE,WAAW,QAAQ,WAAW;EACtC,SAAS;EACV,CAAC;;;;;AAMJ,SAAgB,iCAAiC,SAE1B;AACrB,QAAO,IAAI,mBAAmB,QAAQ,sCAAsC;EAC1E,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK;EACL,SAAS;EACV,CAAC;;;;;;;;;AAUJ,SAAgB,kCAAkC,SAE3B;AAKrB,QAAO,IAAI,mBAAmB,QAAQ,0CAA0C;EAC9E,QAAQ;EACR,KALA,SAAS,cAAc,SACnB,gDAAgD,QAAQ,UAAU,mCAClE;EAIJ,KAAK;EACL,MAAM,SAAS,cAAc,SAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;EAC/E,CAAC;;;;;AAMJ,SAAgB,sBACd,OACA,SAGoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,2BAA2B;EAC/D,QAAQ;EACR,KAAK,SAAS,OAAO,uBAAuB,MAAM;EAClD,KAAK;EACL,SAAS;EACV,CAAC;;;;;AAUJ,SAAgB,gBACd,SACA,SAIoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,oBAAoB;EACxD,QAAQ;EACR,KAAK,SAAS,OAAO;EACrB,KAAK,SAAS,OAAO;EACtB,CAAC"}
|
package/dist/control.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { type CliErrorConflict, type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
|
|
1
|
+
import { _ as errorTargetMigrationNotSupported, a as errorConfigValidation, c as errorContractValidationFailed, d as errorFamilyReadMarkerSqlRequired, f as errorFileNotFound, g as errorQueryRunnerFactoryRequired, h as errorMigrationPlanningFailed, i as errorConfigFileNotFound, l as errorDatabaseConnectionRequired, m as errorMigrationCliInvalidConfigArg, n as CliErrorEnvelope, o as errorContractConfigMissing, p as errorJsonFormatNotSupported, r as CliStructuredError, s as errorContractMissingExtensionPacks, t as CliErrorConflict, u as errorDriverRequired, v as errorUnexpected } from "./control-Bzl70Ny9.mjs";
|
|
2
|
+
export { type CliErrorConflict, type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
|
package/dist/control.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as errorContractMissingExtensionPacks, c as errorDriverRequired, d as errorJsonFormatNotSupported, f as
|
|
1
|
+
import { a as errorContractMissingExtensionPacks, c as errorDriverRequired, d as errorJsonFormatNotSupported, f as errorMigrationCliInvalidConfigArg, g as errorUnexpected, h as errorTargetMigrationNotSupported, i as errorContractConfigMissing, l as errorFamilyReadMarkerSqlRequired, m as errorQueryRunnerFactoryRequired, n as errorConfigFileNotFound, o as errorContractValidationFailed, p as errorMigrationPlanningFailed, r as errorConfigValidation, s as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorFileNotFound } from "./control-Ly06UGvt.mjs";
|
|
2
2
|
|
|
3
|
-
export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
|
|
3
|
+
export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorJsonFormatNotSupported, errorMigrationCliInvalidConfigArg, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorTargetMigrationNotSupported, errorUnexpected };
|
package/dist/execution.d.mts
CHANGED
package/dist/execution.mjs
CHANGED
package/dist/migration.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as CliStructuredError } from "./control-
|
|
1
|
+
import { r as CliStructuredError } from "./control-Bzl70Ny9.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/migration.d.ts
|
|
4
4
|
|
|
@@ -53,11 +53,23 @@ declare function errorMigrationFileMissing(dir: string): CliStructuredError;
|
|
|
53
53
|
* `MigrationPlan`-shaped.
|
|
54
54
|
*/
|
|
55
55
|
declare function errorMigrationInvalidDefaultExport(dir: string, actualExportDescription?: string): CliStructuredError;
|
|
56
|
+
/**
|
|
57
|
+
* The migration class declares one `targetId` but the loaded
|
|
58
|
+
* `prisma-next.config.ts` declares another. Thrown by `MigrationCLI.run`
|
|
59
|
+
* when a migration script is invoked against a config whose target
|
|
60
|
+
* descriptor disagrees with the migration's own `targetId`. Distinct from generic
|
|
61
|
+
* config-validation errors because the mismatch is between two valid
|
|
62
|
+
* artifacts (the script and the config), not a malformed input.
|
|
63
|
+
*/
|
|
64
|
+
declare function errorMigrationTargetMismatch(options: {
|
|
65
|
+
readonly migrationTargetId: string;
|
|
66
|
+
readonly configTargetId: string;
|
|
67
|
+
}): CliStructuredError;
|
|
56
68
|
/**
|
|
57
69
|
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
58
70
|
* by emit capabilities after instantiating the authored migration.
|
|
59
71
|
*/
|
|
60
72
|
declare function errorMigrationPlanNotArray(dir: string, actualValueDescription?: string): CliStructuredError;
|
|
61
73
|
//#endregion
|
|
62
|
-
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorUnfilledPlaceholder, placeholder };
|
|
74
|
+
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorMigrationTargetMismatch, errorUnfilledPlaceholder, placeholder };
|
|
63
75
|
//# sourceMappingURL=migration.d.mts.map
|
package/dist/migration.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/migration.ts"],"sourcesContent":[],"mappings":";;;;;;AAkBA;AAkBA;AAgBA;AAsBA;AAkBA;
|
|
1
|
+
{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/migration.ts"],"sourcesContent":[],"mappings":";;;;;;AAkBA;AAkBA;AAgBA;AAsBA;AAkBA;AA0BgB,iBApGA,wBAAA,CAuGZ,IAAA,EAAA,MAAA,CAAA,EAvGoD,kBAuGlC;AAgBtB;;;;;;;;;iBArGgB,WAAA;;;;;;;;;;;;;iBAgBA,kCAAA;;;;IAIZ;;;;;;iBAkBY,yBAAA,eAAwC;;;;;;;;;;iBAkBxC,kCAAA,iDAGb;;;;;;;;;iBAuBa,4BAAA;;;IAGZ;;;;;iBAgBY,0BAAA,gDAGb"}
|
package/dist/migration.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CliStructuredError } from "./control-
|
|
1
|
+
import { t as CliStructuredError } from "./control-Ly06UGvt.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/migration.ts
|
|
4
4
|
/**
|
|
@@ -86,6 +86,25 @@ function errorMigrationInvalidDefaultExport(dir, actualExportDescription) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
+
* The migration class declares one `targetId` but the loaded
|
|
90
|
+
* `prisma-next.config.ts` declares another. Thrown by `MigrationCLI.run`
|
|
91
|
+
* when a migration script is invoked against a config whose target
|
|
92
|
+
* descriptor disagrees with the migration's own `targetId`. Distinct from generic
|
|
93
|
+
* config-validation errors because the mismatch is between two valid
|
|
94
|
+
* artifacts (the script and the config), not a malformed input.
|
|
95
|
+
*/
|
|
96
|
+
function errorMigrationTargetMismatch(options) {
|
|
97
|
+
return new CliStructuredError("2006", "Migration target does not match config target", {
|
|
98
|
+
domain: "MIG",
|
|
99
|
+
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.`,
|
|
100
|
+
fix: "Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.",
|
|
101
|
+
meta: {
|
|
102
|
+
migrationTargetId: options.migrationTargetId,
|
|
103
|
+
configTargetId: options.configTargetId
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
89
108
|
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
90
109
|
* by emit capabilities after instantiating the authored migration.
|
|
91
110
|
*/
|
|
@@ -102,5 +121,5 @@ function errorMigrationPlanNotArray(dir, actualValueDescription) {
|
|
|
102
121
|
}
|
|
103
122
|
|
|
104
123
|
//#endregion
|
|
105
|
-
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorUnfilledPlaceholder, placeholder };
|
|
124
|
+
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorMigrationTargetMismatch, errorUnfilledPlaceholder, placeholder };
|
|
106
125
|
//# sourceMappingURL=migration.mjs.map
|
package/dist/migration.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 * 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;AACzE,QAAO,IAAI,mBAAmB,QAAQ,kCAAkC;EACtE,QAAQ;EACR,KAAK,qEAAqE;EAC1E,KAAK;EACL,MAAM,EAAE,MAAM;EACf,CAAC;;;;;;;;;;;AAYJ,SAAgB,YAAY,MAAqB;AAC/C,OAAM,yBAAyB,KAAK;;;;;;;;;;;;;;AAetC,SAAgB,mCAAmC,SAI5B;AACrB,QAAO,IAAI,mBAAmB,QAAQ,yDAAyD;EAC7F,QAAQ;EACR,KAAK,mBAAmB,QAAQ,kBAAkB,8CAA8C,QAAQ,OAAO,6CAA6C,QAAQ,SAAS;EAC7K,KAAK;EACL,MAAM;GACJ,mBAAmB,QAAQ;GAC3B,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GACjB;EACF,CAAC;;;;;;;AAQJ,SAAgB,0BAA0B,KAAiC;AACzE,QAAO,IAAI,mBAAmB,QAAQ,0BAA0B;EAC9D,QAAQ;EACR,KAAK,sCAAsC,IAAI;EAC/C,KAAK;EACL,MAAM,EAAE,KAAK;EACd,CAAC;;;;;;;;;;;AAYJ,SAAgB,mCACd,KACA,yBACoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,wDAAwD;EAC5F,QAAQ;EACR,KACE,4BAA4B,SACxB,oBAAoB,IAAI,gHAAgH,4BACxI,oBAAoB,IAAI;EAC9B,KAAK;EACL,MAAM;GACJ;GACA,GAAI,4BAA4B,SAAY,EAAE,cAAc,yBAAyB,GAAG,EAAE;GAC3F;EACF,CAAC;;;;;;AAOJ,SAAgB,2BACd,KACA,wBACoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,uDAAuD;EAC3F,QAAQ;EACR,KACE,2BAA2B,SACvB,6CAA6C,IAAI,QAAQ,uBAAuB,yCAChF,6CAA6C,IAAI;EACvD,KAAK;EACL,MAAM;GACJ;GACA,GAAI,2BAA2B,SAAY,EAAE,aAAa,wBAAwB,GAAG,EAAE;GACxF;EACF,CAAC"}
|
|
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,MAAk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D;EAC3F,QAAQ;EACR,KACE,2BAA2B,SACvB,6CAA6C,IAAI,QAAQ,uBAAuB,yCAChF,6CAA6C,IAAI;EACvD,KAAK;EACL,MAAM;GACJ;GACA,GAAI,2BAA2B,SAAY,EAAE,aAAa,wBAAwB,GAAG,EAAE;GACxF;EACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/errors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-dev.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Structured error types for Prisma Next control and execution planes",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/
|
|
9
|
-
"@prisma-next/
|
|
8
|
+
"@prisma-next/utils": "0.5.0-dev.2",
|
|
9
|
+
"@prisma-next/framework-components": "0.5.0-dev.2"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"tsdown": "0.18.4",
|
package/src/control.ts
CHANGED
|
@@ -358,6 +358,28 @@ export function errorTargetMigrationNotSupported(options?: {
|
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/**
|
|
362
|
+
* The migration-file CLI received `--config` without a path argument (either
|
|
363
|
+
* a bare trailing `--config`, or `--config` followed by another flag like
|
|
364
|
+
* `--config --dry-run`). Surfacing this as a structured error fails fast
|
|
365
|
+
* rather than silently consuming the next flag as the config path or
|
|
366
|
+
* falling back to default discovery against the wrong project.
|
|
367
|
+
*/
|
|
368
|
+
export function errorMigrationCliInvalidConfigArg(options?: {
|
|
369
|
+
readonly nextToken?: string;
|
|
370
|
+
}): CliStructuredError {
|
|
371
|
+
const why =
|
|
372
|
+
options?.nextToken !== undefined
|
|
373
|
+
? `\`--config\` was followed by another flag (\`${options.nextToken}\`) instead of a path argument.`
|
|
374
|
+
: '`--config` was passed without a following path argument.';
|
|
375
|
+
return new CliStructuredError('4012', '--config flag requires a path argument', {
|
|
376
|
+
domain: 'CLI',
|
|
377
|
+
why,
|
|
378
|
+
fix: 'Pass a config path: `--config <path>` or `--config=<path>`.',
|
|
379
|
+
meta: options?.nextToken !== undefined ? { nextToken: options.nextToken } : {},
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
361
383
|
/**
|
|
362
384
|
* Config validation error (missing required fields).
|
|
363
385
|
*/
|
package/src/exports/control.ts
CHANGED
package/src/exports/migration.ts
CHANGED
package/src/migration.ts
CHANGED
|
@@ -108,6 +108,29 @@ export function errorMigrationInvalidDefaultExport(
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* The migration class declares one `targetId` but the loaded
|
|
113
|
+
* `prisma-next.config.ts` declares another. Thrown by `MigrationCLI.run`
|
|
114
|
+
* when a migration script is invoked against a config whose target
|
|
115
|
+
* descriptor disagrees with the migration's own `targetId`. Distinct from generic
|
|
116
|
+
* config-validation errors because the mismatch is between two valid
|
|
117
|
+
* artifacts (the script and the config), not a malformed input.
|
|
118
|
+
*/
|
|
119
|
+
export function errorMigrationTargetMismatch(options: {
|
|
120
|
+
readonly migrationTargetId: string;
|
|
121
|
+
readonly configTargetId: string;
|
|
122
|
+
}): CliStructuredError {
|
|
123
|
+
return new CliStructuredError('2006', 'Migration target does not match config target', {
|
|
124
|
+
domain: 'MIG',
|
|
125
|
+
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.`,
|
|
126
|
+
fix: "Switch to a config whose `target` matches the migration's target, or pass `--config <path>` to point at the right config file.",
|
|
127
|
+
meta: {
|
|
128
|
+
migrationTargetId: options.migrationTargetId,
|
|
129
|
+
configTargetId: options.configTargetId,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
111
134
|
/**
|
|
112
135
|
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
113
136
|
* by emit capabilities after instantiating the authored migration.
|