@prisma-next/family-sql 0.3.0-pr.99.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +58 -22
  3. package/dist/authoring-type-constructors-DgU-RFaP.mjs +203 -0
  4. package/dist/authoring-type-constructors-DgU-RFaP.mjs.map +1 -0
  5. package/dist/control-adapter.d.mts +54 -0
  6. package/dist/control-adapter.d.mts.map +1 -0
  7. package/dist/control-adapter.mjs +1 -0
  8. package/dist/control.d.mts +386 -0
  9. package/dist/control.d.mts.map +1 -0
  10. package/dist/control.mjs +643 -0
  11. package/dist/control.mjs.map +1 -0
  12. package/dist/operation-descriptors.d.mts +380 -0
  13. package/dist/operation-descriptors.d.mts.map +1 -0
  14. package/dist/operation-descriptors.mjs +294 -0
  15. package/dist/operation-descriptors.mjs.map +1 -0
  16. package/dist/pack.d.mts +248 -0
  17. package/dist/pack.d.mts.map +1 -0
  18. package/dist/pack.mjs +18 -0
  19. package/dist/pack.mjs.map +1 -0
  20. package/dist/runtime.d.mts +27 -0
  21. package/dist/runtime.d.mts.map +1 -0
  22. package/dist/runtime.mjs +38 -0
  23. package/dist/runtime.mjs.map +1 -0
  24. package/dist/schema-verify.d.mts +48 -0
  25. package/dist/schema-verify.d.mts.map +1 -0
  26. package/dist/schema-verify.mjs +3 -0
  27. package/dist/test-utils.d.mts +2 -0
  28. package/dist/test-utils.mjs +3 -0
  29. package/dist/types-BaUzKt6Q.d.mts +353 -0
  30. package/dist/types-BaUzKt6Q.d.mts.map +1 -0
  31. package/dist/verify-DZHtfcmj.mjs +108 -0
  32. package/dist/verify-DZHtfcmj.mjs.map +1 -0
  33. package/dist/verify-sql-schema-BBhkqEDo.d.mts +67 -0
  34. package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +1 -0
  35. package/dist/verify-sql-schema-lR-tlboL.mjs +1174 -0
  36. package/dist/verify-sql-schema-lR-tlboL.mjs.map +1 -0
  37. package/dist/verify.d.mts +31 -0
  38. package/dist/verify.d.mts.map +1 -0
  39. package/dist/verify.mjs +3 -0
  40. package/package.json +35 -43
  41. package/src/core/assembly.ts +123 -155
  42. package/src/core/authoring-field-presets.ts +207 -0
  43. package/src/core/authoring-type-constructors.ts +17 -0
  44. package/src/core/control-adapter.ts +18 -10
  45. package/src/core/control-descriptor.ts +28 -0
  46. package/src/core/control-instance.ts +700 -0
  47. package/src/core/migrations/contract-to-schema-ir.ts +269 -0
  48. package/src/core/migrations/descriptor-schemas.ts +172 -0
  49. package/src/core/migrations/operation-descriptors.ts +213 -0
  50. package/src/core/migrations/policies.ts +1 -1
  51. package/src/core/migrations/types.ts +199 -175
  52. package/src/core/runtime-descriptor.ts +19 -41
  53. package/src/core/runtime-instance.ts +11 -133
  54. package/src/core/schema-verify/verify-helpers.ts +104 -22
  55. package/src/core/schema-verify/verify-sql-schema.ts +964 -418
  56. package/src/core/verify.ts +4 -13
  57. package/src/exports/control.ts +31 -8
  58. package/src/exports/operation-descriptors.ts +52 -0
  59. package/src/exports/pack.ts +16 -0
  60. package/src/exports/runtime.ts +2 -6
  61. package/src/exports/schema-verify.ts +4 -1
  62. package/src/exports/test-utils.ts +3 -4
  63. package/dist/chunk-GYEG3I7U.js +0 -624
  64. package/dist/chunk-GYEG3I7U.js.map +0 -1
  65. package/dist/chunk-SU7LN2UH.js +0 -96
  66. package/dist/chunk-SU7LN2UH.js.map +0 -1
  67. package/dist/chunk-XH2Y5NTD.js +0 -715
  68. package/dist/chunk-XH2Y5NTD.js.map +0 -1
  69. package/dist/core/assembly.d.ts +0 -43
  70. package/dist/core/assembly.d.ts.map +0 -1
  71. package/dist/core/control-adapter.d.ts +0 -42
  72. package/dist/core/control-adapter.d.ts.map +0 -1
  73. package/dist/core/descriptor.d.ts +0 -28
  74. package/dist/core/descriptor.d.ts.map +0 -1
  75. package/dist/core/instance.d.ts +0 -140
  76. package/dist/core/instance.d.ts.map +0 -1
  77. package/dist/core/migrations/plan-helpers.d.ts +0 -20
  78. package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
  79. package/dist/core/migrations/policies.d.ts +0 -6
  80. package/dist/core/migrations/policies.d.ts.map +0 -1
  81. package/dist/core/migrations/types.d.ts +0 -280
  82. package/dist/core/migrations/types.d.ts.map +0 -1
  83. package/dist/core/runtime-descriptor.d.ts +0 -19
  84. package/dist/core/runtime-descriptor.d.ts.map +0 -1
  85. package/dist/core/runtime-instance.d.ts +0 -54
  86. package/dist/core/runtime-instance.d.ts.map +0 -1
  87. package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
  88. package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
  89. package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
  90. package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
  91. package/dist/core/verify.d.ts +0 -39
  92. package/dist/core/verify.d.ts.map +0 -1
  93. package/dist/exports/control-adapter.d.ts +0 -2
  94. package/dist/exports/control-adapter.d.ts.map +0 -1
  95. package/dist/exports/control-adapter.js +0 -1
  96. package/dist/exports/control-adapter.js.map +0 -1
  97. package/dist/exports/control.d.ts +0 -13
  98. package/dist/exports/control.d.ts.map +0 -1
  99. package/dist/exports/control.js +0 -149
  100. package/dist/exports/control.js.map +0 -1
  101. package/dist/exports/runtime.d.ts +0 -8
  102. package/dist/exports/runtime.d.ts.map +0 -1
  103. package/dist/exports/runtime.js +0 -64
  104. package/dist/exports/runtime.js.map +0 -1
  105. package/dist/exports/schema-verify.d.ts +0 -11
  106. package/dist/exports/schema-verify.d.ts.map +0 -1
  107. package/dist/exports/schema-verify.js +0 -15
  108. package/dist/exports/schema-verify.js.map +0 -1
  109. package/dist/exports/test-utils.d.ts +0 -7
  110. package/dist/exports/test-utils.d.ts.map +0 -1
  111. package/dist/exports/test-utils.js +0 -17
  112. package/dist/exports/test-utils.js.map +0 -1
  113. package/dist/exports/verify.d.ts +0 -2
  114. package/dist/exports/verify.d.ts.map +0 -1
  115. package/dist/exports/verify.js +0 -11
  116. package/dist/exports/verify.js.map +0 -1
  117. package/src/core/descriptor.ts +0 -33
  118. package/src/core/instance.ts +0 -909
@@ -1,16 +1,14 @@
1
- /**
2
- * SQL-specific migration types.
3
- *
4
- * These types extend the canonical migration types from the framework control plane
5
- * with SQL-specific fields for execution (precheck SQL, execute SQL, etc.).
6
- */
7
-
8
- import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
9
1
  import type {
2
+ ColumnDefault,
3
+ Contract,
4
+ ExecutionMutationDefaultValue,
5
+ } from '@prisma-next/contract/types';
6
+ import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';
7
+ import type {
8
+ ControlAdapterDescriptor,
10
9
  ControlDriverInstance,
11
10
  ControlExtensionDescriptor,
12
- ControlTargetDescriptor,
13
- ControlTargetInstance,
11
+ MigratableTargetDescriptor,
14
12
  MigrationOperationPolicy,
15
13
  MigrationPlan,
16
14
  MigrationPlannerConflict,
@@ -22,110 +20,231 @@ import type {
22
20
  MigrationRunnerSuccessValue,
23
21
  OperationContext,
24
22
  SchemaIssue,
25
- } from '@prisma-next/core-control-plane/types';
26
- import type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
23
+ } from '@prisma-next/framework-components/control';
24
+ import type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';
25
+ import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
27
26
  import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
28
27
  import type { Result } from '@prisma-next/utils/result';
29
- import type { SqlControlFamilyInstance } from '../instance';
28
+ import type { SqlControlFamilyInstance } from '../control-instance';
30
29
 
31
30
  export type AnyRecord = Readonly<Record<string, unknown>>;
32
31
 
33
- // ============================================================================
34
- // Component Database Dependencies
35
- // ============================================================================
32
+ type ControlMutationDefaultSpan = {
33
+ readonly start: {
34
+ readonly offset: number;
35
+ readonly line: number;
36
+ readonly column: number;
37
+ };
38
+ readonly end: {
39
+ readonly offset: number;
40
+ readonly line: number;
41
+ readonly column: number;
42
+ };
43
+ };
44
+
45
+ type ControlMutationDefaultFunctionCall = {
46
+ readonly name: string;
47
+ readonly raw: string;
48
+ readonly args: readonly {
49
+ readonly raw: string;
50
+ readonly span: ControlMutationDefaultSpan;
51
+ }[];
52
+ readonly span: ControlMutationDefaultSpan;
53
+ };
54
+
55
+ type ControlMutationDefaultLoweringContext = {
56
+ readonly sourceId: string;
57
+ readonly modelName: string;
58
+ readonly fieldName: string;
59
+ readonly columnCodecId?: string;
60
+ };
61
+
62
+ export type ControlMutationDefaultFunctionResult =
63
+ | {
64
+ readonly ok: true;
65
+ readonly value:
66
+ | { readonly kind: 'storage'; readonly defaultValue: ColumnDefault }
67
+ | { readonly kind: 'execution'; readonly generated: ExecutionMutationDefaultValue };
68
+ }
69
+ | {
70
+ readonly ok: false;
71
+ readonly diagnostic: {
72
+ readonly code: string;
73
+ readonly message: string;
74
+ readonly sourceId?: string;
75
+ readonly span?: ControlMutationDefaultSpan;
76
+ };
77
+ };
78
+
79
+ export type ControlMutationDefaultFunctionHandler = (input: {
80
+ readonly call: ControlMutationDefaultFunctionCall;
81
+ readonly context: ControlMutationDefaultLoweringContext;
82
+ }) => ControlMutationDefaultFunctionResult;
83
+
84
+ export interface ControlMutationDefaultFunctionEntry {
85
+ readonly lower: ControlMutationDefaultFunctionHandler;
86
+ readonly usageSignatures?: readonly string[];
87
+ }
88
+
89
+ export interface ControlMutationDefaultGeneratorDescriptor {
90
+ readonly id: string;
91
+ readonly applicableCodecIds: readonly string[];
92
+ readonly resolveGeneratedColumnDescriptor?: (input: {
93
+ readonly generated: {
94
+ readonly kind: string;
95
+ readonly id: string;
96
+ readonly params?: Record<string, unknown>;
97
+ };
98
+ }) =>
99
+ | {
100
+ readonly codecId: string;
101
+ readonly nativeType: string;
102
+ readonly typeRef?: string;
103
+ readonly typeParams?: Record<string, unknown>;
104
+ }
105
+ | undefined;
106
+ }
107
+
108
+ export interface PslScalarTypeDescriptor {
109
+ readonly codecId: string;
110
+ readonly nativeType: string;
111
+ readonly typeRef?: string;
112
+ readonly typeParams?: Record<string, unknown>;
113
+ }
114
+
115
+ export interface SqlControlStaticContributions {
116
+ readonly controlMutationDefaults?: () => {
117
+ readonly defaultFunctionRegistry: ReadonlyMap<string, ControlMutationDefaultFunctionEntry>;
118
+ readonly generatorDescriptors: ReadonlyArray<ControlMutationDefaultGeneratorDescriptor>;
119
+ };
120
+ readonly pslTypeDescriptors?: () => {
121
+ readonly scalarTypeDescriptors: ReadonlyMap<string, PslScalarTypeDescriptor>;
122
+ };
123
+ /** Query operation descriptors for the migration DSL client. Same static data as runtime descriptors. */
124
+ readonly queryOperations?: () => ReadonlyArray<SqlOperationDescriptor>;
125
+ }
36
126
 
37
- /**
38
- * A single database dependency declared by a framework component.
39
- * Uses SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
40
- *
41
- * Database dependencies allow components (extensions, adapters) to declare what database-side
42
- * persistence structures they require (e.g., Postgres extensions, schemas, functions).
43
- * The planner emits these as migration operations, and the verifier uses the pure verification
44
- * hook to check satisfaction against the schema IR.
45
- */
46
127
  export interface ComponentDatabaseDependency<TTargetDetails> {
47
- /** Stable identifier for the dependency (e.g. 'postgres.extension.vector') */
48
128
  readonly id: string;
49
- /** Human label for output (e.g. 'Enable vector extension') */
50
129
  readonly label: string;
51
- /**
52
- * Operations that install/ensure the dependency.
53
- * Use SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
54
- */
55
130
  readonly install: readonly SqlMigrationPlanOperation<TTargetDetails>[];
56
- /**
57
- * Pure verification hook: checks whether this dependency is already installed
58
- * based on the in-memory schema IR (no DB I/O).
59
- *
60
- * This must return structured issues suitable for CLI and tree output, not just a boolean.
61
- */
62
- readonly verifyDatabaseDependencyInstalled: (schema: SqlSchemaIR) => readonly SchemaIssue[];
63
131
  }
64
132
 
65
- /**
66
- * Database dependencies declared by a framework component.
67
- */
68
133
  export interface ComponentDatabaseDependencies<TTargetDetails> {
69
- /**
70
- * Dependencies required for db init.
71
- * Future: update dependencies can be added later (e.g. widening/destructive).
72
- */
73
134
  readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
74
135
  }
75
136
 
76
- /**
77
- * Minimal structural type implemented by any descriptor that can expose
78
- * component-owned database dependencies. Targets/adapters typically omit
79
- * the property, while extensions provide dependency metadata.
80
- */
81
137
  export interface DatabaseDependencyProvider {
82
138
  readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
83
139
  }
84
140
 
85
- // ============================================================================
86
- // SQL Control Extension Descriptor
87
- // ============================================================================
141
+ export function isDatabaseDependencyProvider(value: unknown): value is DatabaseDependencyProvider {
142
+ return typeof value === 'object' && value !== null && 'databaseDependencies' in value;
143
+ }
144
+
145
+ export function collectInitDependencies(
146
+ components: ReadonlyArray<unknown>,
147
+ ): readonly ComponentDatabaseDependency<unknown>[] {
148
+ const result: ComponentDatabaseDependency<unknown>[] = [];
149
+ for (const component of components) {
150
+ if (!isDatabaseDependencyProvider(component)) continue;
151
+ const deps = component.databaseDependencies?.init;
152
+ if (!deps) continue;
153
+ result.push(...deps);
154
+ }
155
+ return result;
156
+ }
157
+
158
+ export interface StorageTypePlanResult<TTargetDetails> {
159
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
160
+ }
161
+
162
+ /**
163
+ * Input for expanding parameterized native types.
164
+ */
165
+ export interface ExpandNativeTypeInput {
166
+ readonly nativeType: string;
167
+ readonly codecId?: string;
168
+ readonly typeParams?: Record<string, unknown>;
169
+ }
88
170
 
89
171
  /**
90
- * SQL-specific extension descriptor with optional database dependencies.
91
- * Extends the core ControlExtensionDescriptor with SQL-specific metadata.
172
+ * Input for resolving an identity-value SQL literal used to backfill existing rows when
173
+ * adding a NOT NULL column without an explicit default.
92
174
  *
93
- * Database dependencies are attached to the descriptor (not the instance) because
94
- * they are declarative metadata that planner/verifier need without constructing instances.
175
+ * "Identity value" in the algebraic (monoid) sense: the neutral element for the type
176
+ * (0 for numbers, '' for strings, false for booleans, etc.).
95
177
  */
178
+ export interface ResolveIdentityValueInput {
179
+ readonly nativeType: string;
180
+ readonly codecId?: string;
181
+ readonly typeParams?: Record<string, unknown>;
182
+ }
183
+
184
+ export interface CodecControlHooks<TTargetDetails = unknown> {
185
+ planTypeOperations?: (options: {
186
+ readonly typeName: string;
187
+ readonly typeInstance: StorageTypeInstance;
188
+ readonly contract: Contract<SqlStorage>;
189
+ readonly schema: SqlSchemaIR;
190
+ readonly schemaName?: string;
191
+ readonly policy: MigrationOperationPolicy;
192
+ }) => StorageTypePlanResult<TTargetDetails>;
193
+ verifyType?: (options: {
194
+ readonly typeName: string;
195
+ readonly typeInstance: StorageTypeInstance;
196
+ readonly schema: SqlSchemaIR;
197
+ readonly schemaName?: string;
198
+ }) => readonly SchemaIssue[];
199
+ introspectTypes?: (options: {
200
+ readonly driver: ControlDriverInstance<'sql', string>;
201
+ readonly schemaName?: string;
202
+ }) => Promise<Record<string, StorageTypeInstance>>;
203
+ /**
204
+ * Expands a parameterized native type to its full SQL representation.
205
+ * Used by schema verification to compare contract types against database types.
206
+ *
207
+ * For example, expands:
208
+ * - { nativeType: 'character varying', typeParams: { length: 255 } } -> 'character varying(255)'
209
+ * - { nativeType: 'numeric', typeParams: { precision: 10, scale: 2 } } -> 'numeric(10,2)'
210
+ *
211
+ * Returns the expanded type string, or the original nativeType if no expansion is needed.
212
+ */
213
+ expandNativeType?: (input: ExpandNativeTypeInput) => string;
214
+ /**
215
+ * Resolves the identity value (monoid neutral element) as a SQL literal for safely adding
216
+ * a NOT NULL column without an explicit default to a non-empty table.
217
+ *
218
+ * Return semantics:
219
+ * - string: use this literal
220
+ * - null: explicitly no safe identity value is known; fall back to another strategy
221
+ * - undefined: no opinion; planner may use built-in fallbacks
222
+ */
223
+ resolveIdentityValue?: (input: ResolveIdentityValueInput) => string | null | undefined;
224
+ }
225
+
96
226
  export interface SqlControlExtensionDescriptor<TTargetId extends string>
97
- extends ControlExtensionDescriptor<'sql', TTargetId> {
98
- /** Optional database dependencies this extension requires. */
227
+ extends ControlExtensionDescriptor<'sql', TTargetId>,
228
+ SqlControlStaticContributions {
99
229
  readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
100
230
  }
101
231
 
102
- // ============================================================================
103
- // SQL-Specific Plan Types
104
- // ============================================================================
232
+ export interface SqlControlAdapterDescriptor<TTargetId extends string>
233
+ extends ControlAdapterDescriptor<'sql', TTargetId>,
234
+ SqlControlStaticContributions {}
105
235
 
106
- /**
107
- * A single step in a SQL migration operation (precheck, execute, or postcheck).
108
- */
109
236
  export interface SqlMigrationPlanOperationStep {
110
237
  readonly description: string;
111
238
  readonly sql: string;
112
239
  readonly meta?: AnyRecord;
113
240
  }
114
241
 
115
- /**
116
- * Target details for a SQL migration operation (table, column, index, etc.).
117
- */
118
242
  export interface SqlMigrationPlanOperationTarget<TTargetDetails> {
119
243
  readonly id: string;
120
244
  readonly details?: TTargetDetails;
121
245
  }
122
246
 
123
- /**
124
- * A single SQL migration operation with SQL-specific fields.
125
- * Extends the core MigrationPlanOperation with SQL execution details.
126
- */
127
247
  export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperation {
128
- /** Optional detailed explanation of what this operation does and why. */
129
248
  readonly summary?: string;
130
249
  readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
131
250
  readonly precheck: readonly SqlMigrationPlanOperationStep[];
@@ -134,23 +253,15 @@ export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlan
134
253
  readonly meta?: AnyRecord;
135
254
  }
136
255
 
137
- /**
138
- * Contract identity information for SQL migrations.
139
- */
140
256
  export interface SqlMigrationPlanContractInfo {
141
- readonly coreHash: string;
257
+ readonly storageHash: string;
142
258
  readonly profileHash?: string;
143
259
  }
144
260
 
145
- /**
146
- * A SQL migration plan with SQL-specific fields.
147
- * Extends the core MigrationPlan with origin tracking and metadata.
148
- */
149
261
  export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
150
262
  /**
151
263
  * Origin contract identity that the plan expects the database to currently be at.
152
- * If omitted, the runner treats the origin as "no marker present" (empty database),
153
- * and will only proceed if no marker exists (or if the marker already matches destination).
264
+ * If omitted or null, the runner skips origin validation entirely.
154
265
  */
155
266
  readonly origin?: SqlMigrationPlanContractInfo | null;
156
267
  /**
@@ -161,73 +272,45 @@ export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
161
272
  readonly meta?: AnyRecord;
162
273
  }
163
274
 
164
- // ============================================================================
165
- // SQL-Specific Planner Types
166
- // ============================================================================
167
-
168
- /**
169
- * Specific conflict kinds for SQL migrations.
170
- */
171
275
  export type SqlPlannerConflictKind =
172
276
  | 'typeMismatch'
173
277
  | 'nullabilityConflict'
174
278
  | 'indexIncompatible'
175
279
  | 'foreignKeyConflict'
176
280
  | 'missingButNonAdditive'
177
- | 'unsupportedExtension'
178
- | 'extensionMissing'
179
281
  | 'unsupportedOperation';
180
282
 
181
- /**
182
- * Location information for SQL planner conflicts.
183
- */
184
283
  export interface SqlPlannerConflictLocation {
185
284
  readonly table?: string;
186
285
  readonly column?: string;
187
286
  readonly index?: string;
188
287
  readonly constraint?: string;
189
- readonly extension?: string;
288
+ readonly type?: string;
190
289
  }
191
290
 
192
- /**
193
- * A SQL-specific planner conflict with additional location information.
194
- * Extends the core MigrationPlannerConflict.
195
- */
196
291
  export interface SqlPlannerConflict extends MigrationPlannerConflict {
197
292
  readonly kind: SqlPlannerConflictKind;
198
293
  readonly location?: SqlPlannerConflictLocation;
199
294
  readonly meta?: AnyRecord;
200
295
  }
201
296
 
202
- /**
203
- * Successful SQL planner result with the migration plan.
204
- */
205
297
  export interface SqlPlannerSuccessResult<TTargetDetails>
206
298
  extends Omit<MigrationPlannerSuccessResult, 'plan'> {
207
299
  readonly kind: 'success';
208
300
  readonly plan: SqlMigrationPlan<TTargetDetails>;
209
301
  }
210
302
 
211
- /**
212
- * Failed SQL planner result with the list of conflicts.
213
- */
214
303
  export interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
215
304
  readonly kind: 'failure';
216
305
  readonly conflicts: readonly SqlPlannerConflict[];
217
306
  }
218
307
 
219
- /**
220
- * Union type for SQL planner results.
221
- */
222
308
  export type SqlPlannerResult<TTargetDetails> =
223
309
  | SqlPlannerSuccessResult<TTargetDetails>
224
310
  | SqlPlannerFailureResult;
225
311
 
226
- /**
227
- * Options for SQL migration planner.
228
- */
229
312
  export interface SqlMigrationPlannerPlanOptions {
230
- readonly contract: SqlContract<SqlStorage>;
313
+ readonly contract: Contract<SqlStorage>;
231
314
  readonly schema: SqlSchemaIR;
232
315
  readonly policy: MigrationOperationPolicy;
233
316
  readonly schemaName?: string;
@@ -239,29 +322,15 @@ export interface SqlMigrationPlannerPlanOptions {
239
322
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
240
323
  }
241
324
 
242
- /**
243
- * SQL migration planner interface.
244
- * Extends the core MigrationPlanner with SQL-specific types.
245
- */
246
325
  export interface SqlMigrationPlanner<TTargetDetails> {
247
326
  plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
248
327
  }
249
328
 
250
- // ============================================================================
251
- // SQL-Specific Runner Types
252
- // ============================================================================
253
-
254
- /**
255
- * Callbacks for SQL migration runner execution.
256
- */
257
329
  export interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
258
330
  onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
259
331
  onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
260
332
  }
261
333
 
262
- /**
263
- * Options for SQL migration runner execution.
264
- */
265
334
  export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
266
335
  readonly plan: SqlMigrationPlan<TTargetDetails>;
267
336
  readonly driver: ControlDriverInstance<'sql', string>;
@@ -269,7 +338,7 @@ export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
269
338
  * Destination contract IR.
270
339
  * Must correspond to `plan.destination` and is used for schema verification and marker/ledger writes.
271
340
  */
272
- readonly destinationContract: SqlContract<SqlStorage>;
341
+ readonly destinationContract: Contract<SqlStorage>;
273
342
  /**
274
343
  * Execution-time policy that defines which operation classes are allowed.
275
344
  * The runner validates each operation against this policy before execution.
@@ -292,9 +361,6 @@ export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
292
361
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
293
362
  }
294
363
 
295
- /**
296
- * Error codes for SQL migration runner failures.
297
- */
298
364
  export type SqlMigrationRunnerErrorCode =
299
365
  | 'DESTINATION_CONTRACT_MISMATCH'
300
366
  | 'MARKER_ORIGIN_MISMATCH'
@@ -304,73 +370,31 @@ export type SqlMigrationRunnerErrorCode =
304
370
  | 'SCHEMA_VERIFY_FAILED'
305
371
  | 'EXECUTION_FAILED';
306
372
 
307
- /**
308
- * Detailed information about a SQL migration runner failure.
309
- * Extends the core MigrationRunnerFailure with SQL-specific error codes.
310
- */
311
373
  export interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
312
374
  readonly code: SqlMigrationRunnerErrorCode;
313
375
  readonly meta?: AnyRecord;
314
376
  }
315
377
 
316
- /**
317
- * Success value for SQL migration runner execution.
318
- * Extends core type for type branding and potential SQL-specific extensions.
319
- */
320
378
  export interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
321
379
 
322
- /**
323
- * Result type for SQL migration runner execution.
324
- */
325
380
  export type SqlMigrationRunnerResult = Result<
326
381
  SqlMigrationRunnerSuccessValue,
327
382
  SqlMigrationRunnerFailure
328
383
  >;
329
384
 
330
- /**
331
- * SQL migration runner interface.
332
- * Extends the core MigrationRunner with SQL-specific types.
333
- */
334
385
  export interface SqlMigrationRunner<TTargetDetails> {
335
386
  execute(
336
387
  options: SqlMigrationRunnerExecuteOptions<TTargetDetails>,
337
388
  ): Promise<SqlMigrationRunnerResult>;
338
389
  }
339
390
 
340
- // ============================================================================
341
- // SQL Control Target Descriptor
342
- // ============================================================================
343
-
344
- /**
345
- * SQL control target descriptor with migration support.
346
- * Extends the core ControlTargetDescriptor with SQL-specific migration methods.
347
- */
348
391
  export interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails>
349
- extends ControlTargetDescriptor<
350
- 'sql',
351
- TTargetId,
352
- ControlTargetInstance<'sql', TTargetId>,
353
- SqlControlFamilyInstance
354
- > {
355
- /**
356
- * Creates a SQL migration planner for this target.
357
- * Direct method for SQL-specific usage.
358
- */
392
+ extends MigratableTargetDescriptor<'sql', TTargetId, SqlControlFamilyInstance>,
393
+ SqlControlStaticContributions {
359
394
  createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
360
- /**
361
- * Creates a SQL migration runner for this target.
362
- * Direct method for SQL-specific usage.
363
- */
364
395
  createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
365
396
  }
366
397
 
367
- // ============================================================================
368
- // Helper Types
369
- // ============================================================================
370
-
371
- /**
372
- * Options for creating a SQL migration plan.
373
- */
374
398
  export interface CreateSqlMigrationPlanOptions<TTargetDetails> {
375
399
  readonly targetId: string;
376
400
  readonly origin?: SqlMigrationPlanContractInfo | null;
@@ -1,45 +1,23 @@
1
- import type {
2
- RuntimeAdapterDescriptor,
3
- RuntimeDriverDescriptor,
4
- RuntimeExtensionDescriptor,
5
- RuntimeFamilyDescriptor,
6
- RuntimeTargetDescriptor,
7
- } from '@prisma-next/core-execution-plane/types';
8
- import {
9
- createSqlRuntimeFamilyInstance,
10
- type SqlRuntimeAdapterInstance,
11
- type SqlRuntimeDriverInstance,
12
- type SqlRuntimeFamilyInstance,
13
- } from './runtime-instance';
1
+ import type { RuntimeFamilyDescriptor } from '@prisma-next/framework-components/execution';
2
+ import { createSqlRuntimeFamilyInstance, type SqlRuntimeFamilyInstance } from './runtime-instance';
14
3
 
15
4
  /**
16
- * SQL runtime family descriptor implementation.
17
- * Provides factory method to create SQL runtime family instance.
5
+ * SQL execution-plane family descriptor.
6
+ *
7
+ * Note: this is currently named `sqlRuntimeFamilyDescriptor` because the execution plane
8
+ * framework types are still using the `Runtime*` naming (`RuntimeFamilyDescriptor`, etc.).
9
+ *
10
+ * This will be renamed to `sqlExecutionFamilyDescriptor` as part of `TML-1842`.
18
11
  */
19
- export class SqlRuntimeFamilyDescriptor
20
- implements RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance>
21
- {
22
- readonly kind = 'family' as const;
23
- readonly id = 'sql';
24
- readonly familyId = 'sql' as const;
25
- readonly version = '0.0.1';
12
+ export const sqlRuntimeFamilyDescriptor: RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance> =
13
+ {
14
+ kind: 'family',
15
+ id: 'sql',
16
+ familyId: 'sql',
17
+ version: '0.0.1',
18
+ create() {
19
+ return createSqlRuntimeFamilyInstance();
20
+ },
21
+ };
26
22
 
27
- create<TTargetId extends string>(options: {
28
- readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;
29
- readonly adapter: RuntimeAdapterDescriptor<
30
- 'sql',
31
- TTargetId,
32
- SqlRuntimeAdapterInstance<TTargetId>
33
- >;
34
- readonly driver: RuntimeDriverDescriptor<'sql', TTargetId, SqlRuntimeDriverInstance<TTargetId>>;
35
- readonly extensionPacks: readonly RuntimeExtensionDescriptor<'sql', TTargetId>[];
36
- }): SqlRuntimeFamilyInstance {
37
- return createSqlRuntimeFamilyInstance({
38
- family: this,
39
- target: options.target,
40
- adapter: options.adapter,
41
- driver: options.driver,
42
- extensionPacks: options.extensionPacks,
43
- });
44
- }
45
- }
23
+ Object.freeze(sqlRuntimeFamilyDescriptor);