@prisma-next/errors 0.4.0-dev.9 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migration.d.mts +22 -26
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +29 -36
- package/dist/migration.mjs.map +1 -1
- package/package.json +5 -5
- package/src/exports/migration.ts +1 -2
- package/src/migration.ts +33 -45
package/dist/migration.d.mts
CHANGED
|
@@ -20,10 +20,27 @@ declare function errorUnfilledPlaceholder(slot: string): CliStructuredError;
|
|
|
20
20
|
* `() => MongoQueryPlan` without polluting them with a sentinel union arm.
|
|
21
21
|
*/
|
|
22
22
|
declare function placeholder(slot: string): never;
|
|
23
|
+
/**
|
|
24
|
+
* A `dataTransform(endContract, …)` factory was handed a `SqlQueryPlan` whose
|
|
25
|
+
* `meta.storageHash` does not match the `endContract.storage.storageHash` it
|
|
26
|
+
* was configured with. This almost always means the user's query-builder
|
|
27
|
+
* (`sql({ context: createExecutionContext({ contract: endContract, … }) })`)
|
|
28
|
+
* was instantiated from a different contract reference than the one passed
|
|
29
|
+
* to `dataTransform(endContract, …)`.
|
|
30
|
+
*
|
|
31
|
+
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
|
|
32
|
+
* rejects a plan at runtime execution; this is an authoring-time rejection
|
|
33
|
+
* so it lives in the `MIG` namespace.
|
|
34
|
+
*/
|
|
35
|
+
declare function errorDataTransformContractMismatch(options: {
|
|
36
|
+
readonly dataTransformName: string;
|
|
37
|
+
readonly expected: string;
|
|
38
|
+
readonly actual: string;
|
|
39
|
+
}): CliStructuredError;
|
|
23
40
|
/**
|
|
24
41
|
* `migration.ts` was expected at the given package directory but could not be
|
|
25
|
-
* located. Thrown
|
|
26
|
-
*
|
|
42
|
+
* located. Thrown when consumers attempt to read a migration package that is
|
|
43
|
+
* missing its source file.
|
|
27
44
|
*/
|
|
28
45
|
declare function errorMigrationFileMissing(dir: string): CliStructuredError;
|
|
29
46
|
/**
|
|
@@ -37,31 +54,10 @@ declare function errorMigrationFileMissing(dir: string): CliStructuredError;
|
|
|
37
54
|
*/
|
|
38
55
|
declare function errorMigrationInvalidDefaultExport(dir: string, actualExportDescription?: string): CliStructuredError;
|
|
39
56
|
/**
|
|
40
|
-
* A
|
|
41
|
-
*
|
|
42
|
-
* authored migration.
|
|
57
|
+
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
58
|
+
* by emit capabilities after instantiating the authored migration.
|
|
43
59
|
*/
|
|
44
60
|
declare function errorMigrationPlanNotArray(dir: string, actualValueDescription?: string): CliStructuredError;
|
|
45
|
-
/**
|
|
46
|
-
* A target's migrations capability registers neither `resolveDescriptors`
|
|
47
|
-
* (descriptor flow) nor `emit` (class flow). Surfaced by the strategy
|
|
48
|
-
* selector when it is unable to choose a flow for the target. This is an
|
|
49
|
-
* internal wiring error: every migration-supporting target must implement
|
|
50
|
-
* exactly one of the two flows.
|
|
51
|
-
*/
|
|
52
|
-
declare function errorTargetHasIncompleteMigrationCapabilities(options: {
|
|
53
|
-
readonly targetId: string;
|
|
54
|
-
}): CliStructuredError;
|
|
55
|
-
/**
|
|
56
|
-
* A migration plan was asked to render itself back to TypeScript but the
|
|
57
|
-
* target does not support authoring-surface rendering. Thrown by Postgres's
|
|
58
|
-
* descriptor-flow plan when `renderTypeScript()` is invoked (the CLI only
|
|
59
|
-
* calls it in the class-flow branch of `migration plan`, so this acts as a
|
|
60
|
-
* safety rail rather than a user-visible error in normal use).
|
|
61
|
-
*/
|
|
62
|
-
declare function errorPlanDoesNotSupportAuthoringSurface(options: {
|
|
63
|
-
readonly targetId: string;
|
|
64
|
-
}): CliStructuredError;
|
|
65
61
|
//#endregion
|
|
66
|
-
export { errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray,
|
|
62
|
+
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorUnfilledPlaceholder, placeholder };
|
|
67
63
|
//# 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;
|
|
1
|
+
{"version":3,"file":"migration.d.mts","names":[],"sources":["../src/migration.ts"],"sourcesContent":[],"mappings":";;;;;;AAkBA;AAkBA;AAgBA;AAsBA;AAkBA;AAsBgB,iBAhGA,wBAAA,CAmGb,IAAA,EAAA,MAAA,CAAA,EAnGqD,kBAmGnC;;;;;;;;;;iBAjFL,WAAA;;;;;;;;;;;;;iBAgBA,kCAAA;;;;IAIZ;;;;;;iBAkBY,yBAAA,eAAwC;;;;;;;;;;iBAkBxC,kCAAA,iDAGb;;;;;iBAmBa,0BAAA,gDAGb"}
|
package/dist/migration.mjs
CHANGED
|
@@ -29,9 +29,33 @@ function placeholder(slot) {
|
|
|
29
29
|
throw errorUnfilledPlaceholder(slot);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
+
* A `dataTransform(endContract, …)` factory was handed a `SqlQueryPlan` whose
|
|
33
|
+
* `meta.storageHash` does not match the `endContract.storage.storageHash` it
|
|
34
|
+
* was configured with. This almost always means the user's query-builder
|
|
35
|
+
* (`sql({ context: createExecutionContext({ contract: endContract, … }) })`)
|
|
36
|
+
* was instantiated from a different contract reference than the one passed
|
|
37
|
+
* to `dataTransform(endContract, …)`.
|
|
38
|
+
*
|
|
39
|
+
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
|
|
40
|
+
* rejects a plan at runtime execution; this is an authoring-time rejection
|
|
41
|
+
* so it lives in the `MIG` namespace.
|
|
42
|
+
*/
|
|
43
|
+
function errorDataTransformContractMismatch(options) {
|
|
44
|
+
return new CliStructuredError("2005", "dataTransform query plan built against wrong contract", {
|
|
45
|
+
domain: "MIG",
|
|
46
|
+
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, ...).`,
|
|
47
|
+
fix: "Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.",
|
|
48
|
+
meta: {
|
|
49
|
+
dataTransformName: options.dataTransformName,
|
|
50
|
+
expected: options.expected,
|
|
51
|
+
actual: options.actual
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
32
56
|
* `migration.ts` was expected at the given package directory but could not be
|
|
33
|
-
* located. Thrown
|
|
34
|
-
*
|
|
57
|
+
* located. Thrown when consumers attempt to read a migration package that is
|
|
58
|
+
* missing its source file.
|
|
35
59
|
*/
|
|
36
60
|
function errorMigrationFileMissing(dir) {
|
|
37
61
|
return new CliStructuredError("2002", "migration.ts not found", {
|
|
@@ -62,9 +86,8 @@ function errorMigrationInvalidDefaultExport(dir, actualExportDescription) {
|
|
|
62
86
|
});
|
|
63
87
|
}
|
|
64
88
|
/**
|
|
65
|
-
* A
|
|
66
|
-
*
|
|
67
|
-
* authored migration.
|
|
89
|
+
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
90
|
+
* by emit capabilities after instantiating the authored migration.
|
|
68
91
|
*/
|
|
69
92
|
function errorMigrationPlanNotArray(dir, actualValueDescription) {
|
|
70
93
|
return new CliStructuredError("2004", "Migration.operations must be an array of operations", {
|
|
@@ -77,37 +100,7 @@ function errorMigrationPlanNotArray(dir, actualValueDescription) {
|
|
|
77
100
|
}
|
|
78
101
|
});
|
|
79
102
|
}
|
|
80
|
-
/**
|
|
81
|
-
* A target's migrations capability registers neither `resolveDescriptors`
|
|
82
|
-
* (descriptor flow) nor `emit` (class flow). Surfaced by the strategy
|
|
83
|
-
* selector when it is unable to choose a flow for the target. This is an
|
|
84
|
-
* internal wiring error: every migration-supporting target must implement
|
|
85
|
-
* exactly one of the two flows.
|
|
86
|
-
*/
|
|
87
|
-
function errorTargetHasIncompleteMigrationCapabilities(options) {
|
|
88
|
-
return new CliStructuredError("2011", "Target migrations capability is incomplete", {
|
|
89
|
-
domain: "MIG",
|
|
90
|
-
why: `Target "${options.targetId}" registers a migrations capability but implements neither \`resolveDescriptors\` (descriptor flow) nor \`emit\` (class flow); the CLI cannot choose an authoring strategy.`,
|
|
91
|
-
fix: "This is an internal wiring error. Report it — the target descriptor must implement exactly one of the two migration flows.",
|
|
92
|
-
meta: { targetId: options.targetId }
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* A migration plan was asked to render itself back to TypeScript but the
|
|
97
|
-
* target does not support authoring-surface rendering. Thrown by Postgres's
|
|
98
|
-
* descriptor-flow plan when `renderTypeScript()` is invoked (the CLI only
|
|
99
|
-
* calls it in the class-flow branch of `migration plan`, so this acts as a
|
|
100
|
-
* safety rail rather than a user-visible error in normal use).
|
|
101
|
-
*/
|
|
102
|
-
function errorPlanDoesNotSupportAuthoringSurface(options) {
|
|
103
|
-
return new CliStructuredError("2010", "Migration plan does not support TypeScript authoring surface", {
|
|
104
|
-
domain: "MIG",
|
|
105
|
-
why: `Target "${options.targetId}" produced a descriptor-flow plan; descriptor-flow plans cannot be rendered back to TypeScript via renderTypeScript().`,
|
|
106
|
-
fix: "This is an internal wiring error. Report it — the CLI should route descriptor-flow targets through renderDescriptorTypeScript, not renderTypeScript.",
|
|
107
|
-
meta: { targetId: options.targetId }
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
103
|
|
|
111
104
|
//#endregion
|
|
112
|
-
export { errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray,
|
|
105
|
+
export { errorDataTransformContractMismatch, errorMigrationFileMissing, errorMigrationInvalidDefaultExport, errorMigrationPlanNotArray, errorUnfilledPlaceholder, placeholder };
|
|
113
106
|
//# 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 * `migration.ts` was expected at the given package directory but could not be\n * located. Thrown
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/errors",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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/framework-components": "0.4.1",
|
|
9
|
+
"@prisma-next/utils": "0.4.1"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"tsdown": "0.18.4",
|
|
13
13
|
"typescript": "5.9.3",
|
|
14
14
|
"vitest": "4.0.17",
|
|
15
|
-
"@prisma-next/
|
|
16
|
-
"@prisma-next/
|
|
15
|
+
"@prisma-next/tsdown": "0.0.0",
|
|
16
|
+
"@prisma-next/tsconfig": "0.0.0"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
package/src/exports/migration.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export {
|
|
2
|
+
errorDataTransformContractMismatch,
|
|
2
3
|
errorMigrationFileMissing,
|
|
3
4
|
errorMigrationInvalidDefaultExport,
|
|
4
5
|
errorMigrationPlanNotArray,
|
|
5
|
-
errorPlanDoesNotSupportAuthoringSurface,
|
|
6
|
-
errorTargetHasIncompleteMigrationCapabilities,
|
|
7
6
|
errorUnfilledPlaceholder,
|
|
8
7
|
placeholder,
|
|
9
8
|
} from '../migration';
|
package/src/migration.ts
CHANGED
|
@@ -38,10 +38,39 @@ export function placeholder(slot: string): never {
|
|
|
38
38
|
throw errorUnfilledPlaceholder(slot);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* A `dataTransform(endContract, …)` factory was handed a `SqlQueryPlan` whose
|
|
43
|
+
* `meta.storageHash` does not match the `endContract.storage.storageHash` it
|
|
44
|
+
* was configured with. This almost always means the user's query-builder
|
|
45
|
+
* (`sql({ context: createExecutionContext({ contract: endContract, … }) })`)
|
|
46
|
+
* was instantiated from a different contract reference than the one passed
|
|
47
|
+
* to `dataTransform(endContract, …)`.
|
|
48
|
+
*
|
|
49
|
+
* Distinct from `runtimeError('PLAN.HASH_MISMATCH', …)` (`PN-RUN-*`) which
|
|
50
|
+
* rejects a plan at runtime execution; this is an authoring-time rejection
|
|
51
|
+
* so it lives in the `MIG` namespace.
|
|
52
|
+
*/
|
|
53
|
+
export function errorDataTransformContractMismatch(options: {
|
|
54
|
+
readonly dataTransformName: string;
|
|
55
|
+
readonly expected: string;
|
|
56
|
+
readonly actual: string;
|
|
57
|
+
}): CliStructuredError {
|
|
58
|
+
return new CliStructuredError('2005', 'dataTransform query plan built against wrong contract', {
|
|
59
|
+
domain: 'MIG',
|
|
60
|
+
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, ...).`,
|
|
61
|
+
fix: 'Ensure the `endContract` imported at module scope (used for both `dataTransform(endContract, …)` and `sql({ context: createExecutionContext({ contract: endContract, … }) })`) is the same reference.',
|
|
62
|
+
meta: {
|
|
63
|
+
dataTransformName: options.dataTransformName,
|
|
64
|
+
expected: options.expected,
|
|
65
|
+
actual: options.actual,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
41
70
|
/**
|
|
42
71
|
* `migration.ts` was expected at the given package directory but could not be
|
|
43
|
-
* located. Thrown
|
|
44
|
-
*
|
|
72
|
+
* located. Thrown when consumers attempt to read a migration package that is
|
|
73
|
+
* missing its source file.
|
|
45
74
|
*/
|
|
46
75
|
export function errorMigrationFileMissing(dir: string): CliStructuredError {
|
|
47
76
|
return new CliStructuredError('2002', 'migration.ts not found', {
|
|
@@ -80,9 +109,8 @@ export function errorMigrationInvalidDefaultExport(
|
|
|
80
109
|
}
|
|
81
110
|
|
|
82
111
|
/**
|
|
83
|
-
* A
|
|
84
|
-
*
|
|
85
|
-
* authored migration.
|
|
112
|
+
* A `Migration.operations` getter returned a value that is not an array. Used
|
|
113
|
+
* by emit capabilities after instantiating the authored migration.
|
|
86
114
|
*/
|
|
87
115
|
export function errorMigrationPlanNotArray(
|
|
88
116
|
dir: string,
|
|
@@ -101,43 +129,3 @@ export function errorMigrationPlanNotArray(
|
|
|
101
129
|
},
|
|
102
130
|
});
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* A target's migrations capability registers neither `resolveDescriptors`
|
|
107
|
-
* (descriptor flow) nor `emit` (class flow). Surfaced by the strategy
|
|
108
|
-
* selector when it is unable to choose a flow for the target. This is an
|
|
109
|
-
* internal wiring error: every migration-supporting target must implement
|
|
110
|
-
* exactly one of the two flows.
|
|
111
|
-
*/
|
|
112
|
-
export function errorTargetHasIncompleteMigrationCapabilities(options: {
|
|
113
|
-
readonly targetId: string;
|
|
114
|
-
}): CliStructuredError {
|
|
115
|
-
return new CliStructuredError('2011', 'Target migrations capability is incomplete', {
|
|
116
|
-
domain: 'MIG',
|
|
117
|
-
why: `Target "${options.targetId}" registers a migrations capability but implements neither \`resolveDescriptors\` (descriptor flow) nor \`emit\` (class flow); the CLI cannot choose an authoring strategy.`,
|
|
118
|
-
fix: 'This is an internal wiring error. Report it — the target descriptor must implement exactly one of the two migration flows.',
|
|
119
|
-
meta: { targetId: options.targetId },
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* A migration plan was asked to render itself back to TypeScript but the
|
|
125
|
-
* target does not support authoring-surface rendering. Thrown by Postgres's
|
|
126
|
-
* descriptor-flow plan when `renderTypeScript()` is invoked (the CLI only
|
|
127
|
-
* calls it in the class-flow branch of `migration plan`, so this acts as a
|
|
128
|
-
* safety rail rather than a user-visible error in normal use).
|
|
129
|
-
*/
|
|
130
|
-
export function errorPlanDoesNotSupportAuthoringSurface(options: {
|
|
131
|
-
readonly targetId: string;
|
|
132
|
-
}): CliStructuredError {
|
|
133
|
-
return new CliStructuredError(
|
|
134
|
-
'2010',
|
|
135
|
-
'Migration plan does not support TypeScript authoring surface',
|
|
136
|
-
{
|
|
137
|
-
domain: 'MIG',
|
|
138
|
-
why: `Target "${options.targetId}" produced a descriptor-flow plan; descriptor-flow plans cannot be rendered back to TypeScript via renderTypeScript().`,
|
|
139
|
-
fix: 'This is an internal wiring error. Report it — the CLI should route descriptor-flow targets through renderDescriptorTypeScript, not renderTypeScript.',
|
|
140
|
-
meta: { targetId: options.targetId },
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
}
|