@prisma-next/core-control-plane 0.1.0-dev.15 → 0.1.0-dev.17

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.
@@ -106,6 +106,27 @@ function errorDriverRequired(options) {
106
106
  docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
107
107
  });
108
108
  }
109
+ function errorMigrationPlanningFailed(options) {
110
+ const conflictSummaries = options.conflicts.map((c) => c.summary);
111
+ const computedWhy = options.why ?? conflictSummaries.join("\n");
112
+ const conflictFixes = options.conflicts.map((c) => c.why).filter((why) => typeof why === "string");
113
+ const computedFix = conflictFixes.length > 0 ? conflictFixes.join("\n") : "Use `db schema-verify` to inspect conflicts, or ensure the database is empty";
114
+ return new CliStructuredError("4020", "Migration planning failed", {
115
+ domain: "CLI",
116
+ why: computedWhy,
117
+ fix: computedFix,
118
+ meta: { conflicts: options.conflicts },
119
+ docsUrl: "https://prisma-next.dev/docs/cli/db-init"
120
+ });
121
+ }
122
+ function errorTargetMigrationNotSupported(options) {
123
+ return new CliStructuredError("4021", "Target does not support migrations", {
124
+ domain: "CLI",
125
+ why: options?.why ?? "The configured target does not provide migration planner/runner",
126
+ fix: "Ensure you are using a target that supports migrations",
127
+ docsUrl: "https://prisma-next.dev/docs/cli/db-init"
128
+ });
129
+ }
109
130
  function errorConfigValidation(field, options) {
110
131
  return new CliStructuredError("4001", "Config file not found", {
111
132
  domain: "CLI",
@@ -168,6 +189,8 @@ export {
168
189
  errorQueryRunnerFactoryRequired,
169
190
  errorFamilyReadMarkerSqlRequired,
170
191
  errorDriverRequired,
192
+ errorMigrationPlanningFailed,
193
+ errorTargetMigrationNotSupported,
171
194
  errorConfigValidation,
172
195
  errorMarkerMissing,
173
196
  errorHashMismatch,
@@ -175,4 +198,4 @@ export {
175
198
  errorRuntime,
176
199
  errorUnexpected
177
200
  };
178
- //# sourceMappingURL=chunk-DZPZSLCM.js.map
201
+ //# sourceMappingURL=chunk-R7MOUJNP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * CLI error envelope for output formatting.\n * This is the serialized form of a CliStructuredError.\n */\nexport interface CliErrorEnvelope {\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 * 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: 'CLI' | 'RTM';\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?: 'CLI' | 'RTM';\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;\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 const codePrefix = this.domain === 'CLI' ? 'PN-CLI-' : 'PN-RTM-';\n return {\n code: `${codePrefix}${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// ============================================================================\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: 'Check your contract file for errors',\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 },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: 'Check that the file path is correct',\n where: { path: filePath },\n });\n}\n\n/**\n * Database URL is required but not provided.\n */\nexport function errorDatabaseUrlRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4005', 'Database URL is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database URL is required for db verify',\n fix: 'Provide --db flag or config.db.url 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 * 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 verify',\n fix: 'Add driver to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly {\n readonly kind: string;\n readonly summary: string;\n readonly why?: string;\n }[];\n readonly why?: string;\n}): CliStructuredError {\n // Build \"why\" from conflict summaries - these contain the actual problem description\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n // Build \"fix\" from conflict \"why\" fields - these contain actionable advice\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 schema-verify` 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: 'Ensure you are using a target that supports migrations',\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('4001', 'Config file not found', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Runtime Errors (PN-RTM-3000-3003)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: {\n readonly why?: string;\n readonly dbUrl?: string;\n}): CliStructuredError {\n return new CliStructuredError('3001', 'Marker missing', {\n domain: 'RTM',\n why: options?.why ?? 'Contract marker not found in database',\n fix: 'Run `prisma-next db sign --db <url>` to create marker',\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: 'RTM',\n why: options?.why ?? 'Contract hash does not match database marker',\n fix: 'Migrate database or re-sign if intentional',\n ...(options?.expected || options?.actual\n ? {\n meta: {\n ...(options.expected ? { expected: options.expected } : {}),\n ...(options.actual ? { 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: 'RTM',\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 * 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: 'RTM',\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\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":";AAyBO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMA;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,SASA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS,UAAU;AACjC,SAAK,WAAW,SAAS,YAAY;AACrC,SAAK,MAAM,SAAS;AACpB,SAAK,MAAM,SAAS;AACpB,SAAK,QAAQ,SAAS,QAClB;AAAA,MACE,MAAM,QAAQ,MAAM;AAAA,MACpB,MAAM,QAAQ,MAAM;AAAA,IACtB,IACA;AACJ,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,aAA+B;AAC7B,UAAM,aAAa,KAAK,WAAW,QAAQ,YAAY;AACvD,WAAO;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EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,oCAAoC;AAAA,IACrF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;AAAA,EAChD,CAAC;AACH;AASO,SAAS,gBACd,SACA,SAIoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,oBAAoB;AAAA,IACxD,QAAQ;AAAA,IACR,KAAK,SAAS,OAAO;AAAA,IACrB,KAAK,SAAS,OAAO;AAAA,EACvB,CAAC;AACH;","names":[]}
@@ -2,6 +2,7 @@ import { ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescrip
2
2
  import '@prisma-next/contract/ir';
3
3
  import '@prisma-next/contract/pack-manifest-types';
4
4
  import '@prisma-next/contract/types';
5
+ import '@prisma-next/utils/result';
5
6
  import './schema-view.js';
6
7
 
7
8
  /**
@@ -3,6 +3,7 @@ import './types.js';
3
3
  import '@prisma-next/contract/ir';
4
4
  import '@prisma-next/contract/pack-manifest-types';
5
5
  import '@prisma-next/contract/types';
6
+ import '@prisma-next/utils/result';
6
7
  import './schema-view.js';
7
8
 
8
9
  /**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  errorConfigValidation
3
- } from "../chunk-DZPZSLCM.js";
3
+ } from "../chunk-R7MOUJNP.js";
4
4
 
5
5
  // src/config-validation.ts
6
6
  function validateConfig(config) {
@@ -100,6 +100,23 @@ declare function errorFamilyReadMarkerSqlRequired(options?: {
100
100
  declare function errorDriverRequired(options?: {
101
101
  readonly why?: string;
102
102
  }): CliStructuredError;
103
+ /**
104
+ * Migration planning failed due to conflicts.
105
+ */
106
+ declare function errorMigrationPlanningFailed(options: {
107
+ readonly conflicts: readonly {
108
+ readonly kind: string;
109
+ readonly summary: string;
110
+ readonly why?: string;
111
+ }[];
112
+ readonly why?: string;
113
+ }): CliStructuredError;
114
+ /**
115
+ * Target does not support migrations (missing createPlanner/createRunner).
116
+ */
117
+ declare function errorTargetMigrationNotSupported(options?: {
118
+ readonly why?: string;
119
+ }): CliStructuredError;
103
120
  /**
104
121
  * Config validation error (missing required fields).
105
122
  */
@@ -143,4 +160,4 @@ declare function errorUnexpected(message: string, options?: {
143
160
  readonly fix?: string;
144
161
  }): CliStructuredError;
145
162
 
146
- export { type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractValidationFailed, errorDatabaseUrlRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorHashMismatch, errorMarkerMissing, errorQueryRunnerFactoryRequired, errorRuntime, errorTargetMismatch, errorUnexpected };
163
+ export { type CliErrorEnvelope, CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractValidationFailed, errorDatabaseUrlRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorHashMismatch, errorMarkerMissing, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorRuntime, errorTargetMigrationNotSupported, errorTargetMismatch, errorUnexpected };
@@ -10,11 +10,13 @@ import {
10
10
  errorFileNotFound,
11
11
  errorHashMismatch,
12
12
  errorMarkerMissing,
13
+ errorMigrationPlanningFailed,
13
14
  errorQueryRunnerFactoryRequired,
14
15
  errorRuntime,
16
+ errorTargetMigrationNotSupported,
15
17
  errorTargetMismatch,
16
18
  errorUnexpected
17
- } from "../chunk-DZPZSLCM.js";
19
+ } from "../chunk-R7MOUJNP.js";
18
20
  export {
19
21
  CliStructuredError,
20
22
  errorConfigFileNotFound,
@@ -27,8 +29,10 @@ export {
27
29
  errorFileNotFound,
28
30
  errorHashMismatch,
29
31
  errorMarkerMissing,
32
+ errorMigrationPlanningFailed,
30
33
  errorQueryRunnerFactoryRequired,
31
34
  errorRuntime,
35
+ errorTargetMigrationNotSupported,
32
36
  errorTargetMismatch,
33
37
  errorUnexpected
34
38
  };
@@ -1,8 +1,149 @@
1
1
  import { ContractIR } from '@prisma-next/contract/ir';
2
2
  import { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';
3
3
  import { TargetFamilyHook } from '@prisma-next/contract/types';
4
+ import { Result } from '@prisma-next/utils/result';
4
5
  import { CoreSchemaView } from './schema-view.js';
5
6
 
7
+ /**
8
+ * Core migration types for the framework control plane.
9
+ *
10
+ * These are family-agnostic, display-oriented types that provide a stable
11
+ * vocabulary for CLI commands to work with migration planners and runners
12
+ * without importing family-specific types.
13
+ *
14
+ * Family-specific types (e.g., SqlMigrationPlan) extend these base types
15
+ * with additional fields for execution (precheck SQL, execute SQL, etc.).
16
+ */
17
+
18
+ /**
19
+ * Migration operation classes define the safety level of an operation.
20
+ * - 'additive': Adds new structures without modifying existing ones (safe)
21
+ * - 'widening': Relaxes constraints or expands types (generally safe)
22
+ * - 'destructive': Removes or alters existing structures (potentially unsafe)
23
+ */
24
+ type MigrationOperationClass = 'additive' | 'widening' | 'destructive';
25
+ /**
26
+ * Policy defining which operation classes are allowed during a migration.
27
+ */
28
+ interface MigrationOperationPolicy {
29
+ readonly allowedOperationClasses: readonly MigrationOperationClass[];
30
+ }
31
+ /**
32
+ * A single migration operation for display purposes.
33
+ * Contains only the fields needed for CLI output (tree view, JSON envelope).
34
+ */
35
+ interface MigrationPlanOperation {
36
+ /** Unique identifier for this operation (e.g., "table.users.create"). */
37
+ readonly id: string;
38
+ /** Human-readable label for display in UI/CLI (e.g., "Create table users"). */
39
+ readonly label: string;
40
+ /** The class of operation (additive, widening, destructive). */
41
+ readonly operationClass: MigrationOperationClass;
42
+ }
43
+ /**
44
+ * A migration plan for display purposes.
45
+ * Contains only the fields needed for CLI output (summary, JSON envelope).
46
+ */
47
+ interface MigrationPlan {
48
+ /** The target ID this plan is for (e.g., 'postgres'). */
49
+ readonly targetId: string;
50
+ /** Destination contract identity that the plan intends to reach. */
51
+ readonly destination: {
52
+ readonly coreHash: string;
53
+ readonly profileHash?: string;
54
+ };
55
+ /** Ordered list of operations to execute. */
56
+ readonly operations: readonly MigrationPlanOperation[];
57
+ }
58
+ /**
59
+ * A conflict detected during migration planning.
60
+ */
61
+ interface MigrationPlannerConflict {
62
+ /** Kind of conflict (e.g., 'typeMismatch', 'nullabilityConflict'). */
63
+ readonly kind: string;
64
+ /** Human-readable summary of the conflict. */
65
+ readonly summary: string;
66
+ /** Optional explanation of why this conflict occurred. */
67
+ readonly why?: string;
68
+ }
69
+ /**
70
+ * Successful planner result with the migration plan.
71
+ */
72
+ interface MigrationPlannerSuccessResult {
73
+ readonly kind: 'success';
74
+ readonly plan: MigrationPlan;
75
+ }
76
+ /**
77
+ * Failed planner result with the list of conflicts.
78
+ */
79
+ interface MigrationPlannerFailureResult {
80
+ readonly kind: 'failure';
81
+ readonly conflicts: readonly MigrationPlannerConflict[];
82
+ }
83
+ /**
84
+ * Union type for planner results.
85
+ */
86
+ type MigrationPlannerResult = MigrationPlannerSuccessResult | MigrationPlannerFailureResult;
87
+ /**
88
+ * Success value for migration runner execution.
89
+ */
90
+ interface MigrationRunnerSuccessValue {
91
+ readonly operationsPlanned: number;
92
+ readonly operationsExecuted: number;
93
+ }
94
+ /**
95
+ * Failure details for migration runner execution.
96
+ */
97
+ interface MigrationRunnerFailure {
98
+ /** Error code for the failure. */
99
+ readonly code: string;
100
+ /** Human-readable summary of the failure. */
101
+ readonly summary: string;
102
+ /** Optional explanation of why the failure occurred. */
103
+ readonly why?: string;
104
+ }
105
+ /**
106
+ * Result type for migration runner execution.
107
+ */
108
+ type MigrationRunnerResult = Result<MigrationRunnerSuccessValue, MigrationRunnerFailure>;
109
+ /**
110
+ * Migration planner interface for planning schema changes.
111
+ * This is the minimal interface that CLI commands use.
112
+ */
113
+ interface MigrationPlanner {
114
+ plan(options: {
115
+ readonly contract: unknown;
116
+ readonly schema: unknown;
117
+ readonly policy: MigrationOperationPolicy;
118
+ }): MigrationPlannerResult;
119
+ }
120
+ /**
121
+ * Migration runner interface for executing migration plans.
122
+ * This is the minimal interface that CLI commands use.
123
+ */
124
+ interface MigrationRunner {
125
+ execute(options: {
126
+ readonly plan: MigrationPlan;
127
+ readonly driver: ControlDriverInstance;
128
+ readonly destinationContract: unknown;
129
+ readonly policy: MigrationOperationPolicy;
130
+ readonly callbacks?: {
131
+ onOperationStart?(op: MigrationPlanOperation): void;
132
+ onOperationComplete?(op: MigrationPlanOperation): void;
133
+ };
134
+ }): Promise<MigrationRunnerResult>;
135
+ }
136
+ /**
137
+ * Optional capability interface for targets that support migrations.
138
+ * Targets that implement migrations expose this via their descriptor.
139
+ *
140
+ * @template TFamilyInstance - The family instance type (e.g., SqlControlFamilyInstance)
141
+ */
142
+ interface TargetMigrationsCapability<TFamilyInstance extends ControlFamilyInstance<string> = ControlFamilyInstance<string>> {
143
+ createPlanner(family: TFamilyInstance): MigrationPlanner;
144
+ createRunner(family: TFamilyInstance): MigrationRunner;
145
+ }
146
+
6
147
  /**
7
148
  * Base interface for control-plane family instances.
8
149
  * Families extend this with domain-specific methods.
@@ -117,13 +258,19 @@ interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance exte
117
258
  * @template TFamilyId - The family ID (e.g., 'sql', 'document')
118
259
  * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
119
260
  * @template TTargetInstance - The target instance type
261
+ * @template TFamilyInstance - The family instance type for migrations (optional)
120
262
  */
121
- interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends string, TTargetInstance extends ControlTargetInstance<TFamilyId, TTargetId> = ControlTargetInstance<TFamilyId, TTargetId>> {
263
+ interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends string, TTargetInstance extends ControlTargetInstance<TFamilyId, TTargetId> = ControlTargetInstance<TFamilyId, TTargetId>, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> {
122
264
  readonly kind: 'target';
123
265
  readonly id: string;
124
266
  readonly familyId: TFamilyId;
125
267
  readonly targetId: TTargetId;
126
268
  readonly manifest: ExtensionPackManifest;
269
+ /**
270
+ * Optional migrations capability.
271
+ * Targets that support migrations expose this property.
272
+ */
273
+ readonly migrations?: TargetMigrationsCapability<TFamilyInstance>;
127
274
  create(): TTargetInstance;
128
275
  }
129
276
  /**
@@ -283,7 +430,7 @@ interface VerifyDatabaseResult {
283
430
  * Schema issue type for schema verification results.
284
431
  */
285
432
  interface SchemaIssue {
286
- readonly kind: 'missing_table' | 'missing_column' | 'type_mismatch' | 'nullability_mismatch' | 'primary_key_mismatch' | 'foreign_key_mismatch' | 'unique_constraint_mismatch' | 'index_mismatch' | 'extension_missing';
433
+ readonly kind: 'missing_table' | 'missing_column' | 'extra_table' | 'extra_column' | 'extra_primary_key' | 'extra_foreign_key' | 'extra_unique_constraint' | 'extra_index' | 'type_mismatch' | 'nullability_mismatch' | 'primary_key_mismatch' | 'foreign_key_mismatch' | 'unique_constraint_mismatch' | 'index_mismatch' | 'extension_missing';
287
434
  readonly table: string;
288
435
  readonly column?: string;
289
436
  readonly indexOrConstraint?: string;
@@ -403,4 +550,4 @@ interface SignDatabaseResult {
403
550
  };
404
551
  }
405
552
 
406
- export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult, FamilyInstance, IntrospectSchemaResult, OperationContext, SchemaIssue, SchemaVerificationNode, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult };
553
+ export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult, FamilyInstance, IntrospectSchemaResult, MigrationOperationClass, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerResult, MigrationPlannerSuccessResult, MigrationRunner, MigrationRunnerFailure, MigrationRunnerResult, MigrationRunnerSuccessValue, OperationContext, SchemaIssue, SchemaVerificationNode, SignDatabaseResult, TargetMigrationsCapability, VerifyDatabaseResult, VerifyDatabaseSchemaResult };
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@prisma-next/core-control-plane",
3
- "version": "0.1.0-dev.15",
3
+ "version": "0.1.0-dev.17",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Control plane domain actions, config types, validation, and error factories for Prisma Next",
7
7
  "dependencies": {
8
8
  "arktype": "^2.1.26",
9
9
  "prettier": "^3.3.3",
10
- "@prisma-next/contract": "0.1.0-dev.15",
11
- "@prisma-next/operations": "0.1.0-dev.15"
10
+ "@prisma-next/contract": "0.1.0-dev.17",
11
+ "@prisma-next/operations": "0.1.0-dev.17",
12
+ "@prisma-next/utils": "0.1.0-dev.17"
12
13
  },
13
14
  "devDependencies": {
14
15
  "tsup": "^8.3.0",
@@ -43,10 +44,6 @@
43
44
  "./schema-view": {
44
45
  "types": "./dist/exports/schema-view.d.ts",
45
46
  "import": "./dist/exports/schema-view.js"
46
- },
47
- "./result": {
48
- "types": "./dist/exports/result.d.ts",
49
- "import": "./dist/exports/result.js"
50
47
  }
51
48
  },
52
49
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * CLI error envelope for output formatting.\n * This is the serialized form of a CliStructuredError.\n */\nexport interface CliErrorEnvelope {\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 * 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: 'CLI' | 'RTM';\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?: 'CLI' | 'RTM';\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;\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 const codePrefix = this.domain === 'CLI' ? 'PN-CLI-' : 'PN-RTM-';\n return {\n code: `${codePrefix}${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// ============================================================================\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: 'Check your contract file for errors',\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 },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: 'Check that the file path is correct',\n where: { path: filePath },\n });\n}\n\n/**\n * Database URL is required but not provided.\n */\nexport function errorDatabaseUrlRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4005', 'Database URL is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database URL is required for db verify',\n fix: 'Provide --db flag or config.db.url 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 * 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 verify',\n fix: 'Add driver to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\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('4001', 'Config file not found', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Runtime Errors (PN-RTM-3000-3003)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: {\n readonly why?: string;\n readonly dbUrl?: string;\n}): CliStructuredError {\n return new CliStructuredError('3001', 'Marker missing', {\n domain: 'RTM',\n why: options?.why ?? 'Contract marker not found in database',\n fix: 'Run `prisma-next db sign --db <url>` to create marker',\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: 'RTM',\n why: options?.why ?? 'Contract hash does not match database marker',\n fix: 'Migrate database or re-sign if intentional',\n ...(options?.expected || options?.actual\n ? {\n meta: {\n ...(options.expected ? { expected: options.expected } : {}),\n ...(options.actual ? { 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: 'RTM',\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 * 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: 'RTM',\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\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":";AAyBO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMA;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,SASA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS,UAAU;AACjC,SAAK,WAAW,SAAS,YAAY;AACrC,SAAK,MAAM,SAAS;AACpB,SAAK,MAAM,SAAS;AACpB,SAAK,QAAQ,SAAS,QAClB;AAAA,MACE,MAAM,QAAQ,MAAM;AAAA,MACpB,MAAM,QAAQ,MAAM;AAAA,IACtB,IACA;AACJ,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,aAA+B;AAC7B,UAAM,aAAa,KAAK,WAAW,QAAQ,YAAY;AACvD,WAAO;AAAA,MACL,MAAM,GAAG,UAAU,GAAG,KAAK,IAAI;AAAA,MAC/B,QAAQ,KAAK;AAA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AAC;AAAA,MACrD;AAAA,IACF,IACA,CAAC;AAAA,EACP,CAAC;AACH;AAKO,SAAS,oBACd,UACA,QACA,SAGoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,mBAAmB;AAAA,IACvD,QAAQ;AAAA,IACR,KACE,SAAS,OACT,2DAA2D,QAAQ,aAAa,MAAM;AAAA,IACxF,KAAK;AAAA,IACL,MAAM,EAAE,UAAU,OAAO;AAAA,EAC3B,CAAC;AACH;AAKO,SAAS,aACd,SACA,SAKoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,SAAS;AAAA,IAC7C,QAAQ;AAAA,IACR,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,sBAAsB;AAAA,IACvE,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,oCAAoC;AAAA,IACrF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;AAAA,EAChD,CAAC;AACH;AASO,SAAS,gBACd,SACA,SAIoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,oBAAoB;AAAA,IACxD,QAAQ;AAAA,IACR,KAAK,SAAS,OAAO;AAAA,IACrB,KAAK,SAAS,OAAO;AAAA,EACvB,CAAC;AACH;","names":[]}
@@ -1,47 +0,0 @@
1
- /**
2
- * Generic Result type for representing success or failure outcomes.
3
- *
4
- * This is the standard way to return "expected failures" as values rather than
5
- * throwing exceptions. See docs/Error Handling.md for the full taxonomy.
6
- *
7
- * Naming rationale:
8
- * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
9
- * - `NotOk` avoids collision with domain types like "Failure" or "Error"
10
- * - `failure` property distinguishes from JS Error semantics
11
- */
12
- /**
13
- * Represents a successful result containing a value.
14
- */
15
- interface Ok<T> {
16
- readonly ok: true;
17
- readonly value: T;
18
- }
19
- /**
20
- * Represents an unsuccessful result containing failure details.
21
- */
22
- interface NotOk<F> {
23
- readonly ok: false;
24
- readonly failure: F;
25
- }
26
- /**
27
- * A discriminated union representing either success (Ok) or failure (NotOk).
28
- *
29
- * @typeParam T - The success value type
30
- * @typeParam F - The failure details type
31
- */
32
- type Result<T, F> = Ok<T> | NotOk<F>;
33
- /**
34
- * Creates a successful result.
35
- */
36
- declare function ok<T>(value: T): Ok<T>;
37
- /**
38
- * Creates an unsuccessful result.
39
- */
40
- declare function notOk<F>(failure: F): NotOk<F>;
41
- /**
42
- * Returns a successful void result.
43
- * Use this for validation checks that don't produce a value.
44
- */
45
- declare function okVoid(): Ok<void>;
46
-
47
- export { type NotOk, type Ok, type Result, notOk, ok, okVoid };
@@ -1,17 +0,0 @@
1
- // src/result.ts
2
- function ok(value) {
3
- return Object.freeze({ ok: true, value });
4
- }
5
- function notOk(failure) {
6
- return Object.freeze({ ok: false, failure });
7
- }
8
- var OK_VOID = Object.freeze({ ok: true, value: void 0 });
9
- function okVoid() {
10
- return OK_VOID;
11
- }
12
- export {
13
- notOk,
14
- ok,
15
- okVoid
16
- };
17
- //# sourceMappingURL=result.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/result.ts"],"sourcesContent":["/**\n * Generic Result type for representing success or failure outcomes.\n *\n * This is the standard way to return \"expected failures\" as values rather than\n * throwing exceptions. See docs/Error Handling.md for the full taxonomy.\n *\n * Naming rationale:\n * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator\n * - `NotOk` avoids collision with domain types like \"Failure\" or \"Error\"\n * - `failure` property distinguishes from JS Error semantics\n */\n\n/**\n * Represents a successful result containing a value.\n */\nexport interface Ok<T> {\n readonly ok: true;\n readonly value: T;\n}\n\n/**\n * Represents an unsuccessful result containing failure details.\n */\nexport interface NotOk<F> {\n readonly ok: false;\n readonly failure: F;\n}\n\n/**\n * A discriminated union representing either success (Ok) or failure (NotOk).\n *\n * @typeParam T - The success value type\n * @typeParam F - The failure details type\n */\nexport type Result<T, F> = Ok<T> | NotOk<F>;\n\n/**\n * Creates a successful result.\n */\nexport function ok<T>(value: T): Ok<T> {\n return Object.freeze({ ok: true, value });\n}\n\n/**\n * Creates an unsuccessful result.\n */\nexport function notOk<F>(failure: F): NotOk<F> {\n return Object.freeze({ ok: false, failure });\n}\n\n/**\n * Singleton for void success results.\n * Use this for validation checks that don't produce a value.\n */\nconst OK_VOID: Ok<void> = Object.freeze({ ok: true, value: undefined });\n\n/**\n * Returns a successful void result.\n * Use this for validation checks that don't produce a value.\n */\nexport function okVoid(): Ok<void> {\n return OK_VOID;\n}\n"],"mappings":";AAuCO,SAAS,GAAM,OAAiB;AACrC,SAAO,OAAO,OAAO,EAAE,IAAI,MAAM,MAAM,CAAC;AAC1C;AAKO,SAAS,MAAS,SAAsB;AAC7C,SAAO,OAAO,OAAO,EAAE,IAAI,OAAO,QAAQ,CAAC;AAC7C;AAMA,IAAM,UAAoB,OAAO,OAAO,EAAE,IAAI,MAAM,OAAO,OAAU,CAAC;AAM/D,SAAS,SAAmB;AACjC,SAAO;AACT;","names":[]}