@prisma-next/family-sql 0.3.0-dev.5 → 0.3.0-dev.52
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/README.md +12 -6
- package/dist/assembly-BVS641kd.mjs +106 -0
- package/dist/assembly-BVS641kd.mjs.map +1 -0
- package/dist/control-adapter.d.mts +60 -0
- package/dist/control-adapter.d.mts.map +1 -0
- package/dist/control-adapter.mjs +1 -0
- package/dist/control-instance-CWKSpACr.d.mts +292 -0
- package/dist/control-instance-CWKSpACr.d.mts.map +1 -0
- package/dist/control.d.mts +64 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +536 -0
- package/dist/control.mjs.map +1 -0
- package/dist/runtime.d.mts +27 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +38 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-verify.d.mts +48 -0
- package/dist/schema-verify.d.mts.map +1 -0
- package/dist/schema-verify.mjs +4 -0
- package/dist/test-utils.d.mts +2 -0
- package/dist/test-utils.mjs +3 -0
- package/dist/verify-BfMETJcM.mjs +108 -0
- package/dist/verify-BfMETJcM.mjs.map +1 -0
- package/dist/verify-sql-schema-CpAVEi8A.mjs +1058 -0
- package/dist/verify-sql-schema-CpAVEi8A.mjs.map +1 -0
- package/dist/verify-sql-schema-DhHnkpPa.d.mts +67 -0
- package/dist/verify-sql-schema-DhHnkpPa.d.mts.map +1 -0
- package/dist/verify.d.mts +31 -0
- package/dist/verify.d.mts.map +1 -0
- package/dist/verify.mjs +3 -0
- package/package.json +36 -47
- package/src/core/assembly.ts +158 -59
- package/src/core/control-adapter.ts +15 -0
- package/src/core/control-descriptor.ts +37 -0
- package/src/core/{instance.ts → control-instance.ts} +108 -241
- package/src/core/migrations/types.ts +62 -163
- package/src/core/runtime-descriptor.ts +19 -41
- package/src/core/runtime-instance.ts +11 -133
- package/src/core/schema-verify/verify-helpers.ts +187 -97
- package/src/core/schema-verify/verify-sql-schema.ts +910 -392
- package/src/core/verify.ts +4 -13
- package/src/exports/control.ts +9 -6
- package/src/exports/runtime.ts +2 -6
- package/src/exports/schema-verify.ts +10 -2
- package/src/exports/test-utils.ts +0 -1
- package/dist/chunk-6K3RPBDP.js +0 -580
- package/dist/chunk-6K3RPBDP.js.map +0 -1
- package/dist/chunk-BHEGVBY7.js +0 -772
- package/dist/chunk-BHEGVBY7.js.map +0 -1
- package/dist/chunk-SU7LN2UH.js +0 -96
- package/dist/chunk-SU7LN2UH.js.map +0 -1
- package/dist/core/assembly.d.ts +0 -25
- package/dist/core/assembly.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -42
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor.d.ts +0 -31
- package/dist/core/descriptor.d.ts.map +0 -1
- package/dist/core/instance.d.ts +0 -142
- package/dist/core/instance.d.ts.map +0 -1
- package/dist/core/migrations/plan-helpers.d.ts +0 -20
- package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
- package/dist/core/migrations/policies.d.ts +0 -6
- package/dist/core/migrations/policies.d.ts.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -280
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/runtime-descriptor.d.ts +0 -19
- package/dist/core/runtime-descriptor.d.ts.map +0 -1
- package/dist/core/runtime-instance.d.ts +0 -54
- package/dist/core/runtime-instance.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-helpers.d.ts +0 -50
- package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
- package/dist/core/verify.d.ts +0 -39
- package/dist/core/verify.d.ts.map +0 -1
- package/dist/exports/control-adapter.d.ts +0 -2
- package/dist/exports/control-adapter.d.ts.map +0 -1
- package/dist/exports/control-adapter.js +0 -1
- package/dist/exports/control-adapter.js.map +0 -1
- package/dist/exports/control.d.ts +0 -13
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -149
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -64
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/schema-verify.d.ts +0 -11
- package/dist/exports/schema-verify.d.ts.map +0 -1
- package/dist/exports/schema-verify.js +0 -11
- package/dist/exports/schema-verify.js.map +0 -1
- package/dist/exports/test-utils.d.ts +0 -7
- package/dist/exports/test-utils.d.ts.map +0 -1
- package/dist/exports/test-utils.js +0 -17
- package/dist/exports/test-utils.js.map +0 -1
- package/dist/exports/verify.d.ts +0 -2
- package/dist/exports/verify.d.ts.map +0 -1
- package/dist/exports/verify.js +0 -11
- package/dist/exports/verify.js.map +0 -1
- package/src/core/descriptor.ts +0 -37
|
@@ -1,12 +1,6 @@
|
|
|
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
1
|
import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
|
|
9
2
|
import type {
|
|
3
|
+
ControlAdapterDescriptor,
|
|
10
4
|
ControlDriverInstance,
|
|
11
5
|
ControlExtensionDescriptor,
|
|
12
6
|
ControlTargetDescriptor,
|
|
@@ -23,109 +17,100 @@ import type {
|
|
|
23
17
|
OperationContext,
|
|
24
18
|
SchemaIssue,
|
|
25
19
|
} from '@prisma-next/core-control-plane/types';
|
|
26
|
-
import type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
20
|
+
import type { SqlContract, SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';
|
|
21
|
+
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
27
22
|
import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
28
23
|
import type { Result } from '@prisma-next/utils/result';
|
|
29
|
-
import type { SqlControlFamilyInstance } from '../instance';
|
|
24
|
+
import type { SqlControlFamilyInstance } from '../control-instance';
|
|
30
25
|
|
|
31
26
|
export type AnyRecord = Readonly<Record<string, unknown>>;
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export interface SqlControlStaticContributions {
|
|
29
|
+
readonly operationSignatures: () => ReadonlyArray<SqlOperationSignature>;
|
|
30
|
+
}
|
|
36
31
|
|
|
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
32
|
export interface ComponentDatabaseDependency<TTargetDetails> {
|
|
47
|
-
/** Stable identifier for the dependency (e.g. 'postgres.extension.vector') */
|
|
48
33
|
readonly id: string;
|
|
49
|
-
/** Human label for output (e.g. 'Enable vector extension') */
|
|
50
34
|
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
35
|
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
36
|
readonly verifyDatabaseDependencyInstalled: (schema: SqlSchemaIR) => readonly SchemaIssue[];
|
|
63
37
|
}
|
|
64
38
|
|
|
65
|
-
/**
|
|
66
|
-
* Database dependencies declared by a framework component.
|
|
67
|
-
*/
|
|
68
39
|
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
40
|
readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
|
|
74
41
|
}
|
|
75
42
|
|
|
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
43
|
export interface DatabaseDependencyProvider {
|
|
82
44
|
readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
|
|
83
45
|
}
|
|
84
46
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
47
|
+
export interface StorageTypePlanResult<TTargetDetails> {
|
|
48
|
+
readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
49
|
+
}
|
|
88
50
|
|
|
89
51
|
/**
|
|
90
|
-
*
|
|
91
|
-
* Extends the core ControlExtensionDescriptor with SQL-specific metadata.
|
|
92
|
-
*
|
|
93
|
-
* Database dependencies are attached to the descriptor (not the instance) because
|
|
94
|
-
* they are declarative metadata that planner/verifier need without constructing instances.
|
|
52
|
+
* Input for expanding parameterized native types.
|
|
95
53
|
*/
|
|
54
|
+
export interface ExpandNativeTypeInput {
|
|
55
|
+
readonly nativeType: string;
|
|
56
|
+
readonly codecId?: string;
|
|
57
|
+
readonly typeParams?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CodecControlHooks<TTargetDetails = unknown> {
|
|
61
|
+
planTypeOperations?: (options: {
|
|
62
|
+
readonly typeName: string;
|
|
63
|
+
readonly typeInstance: StorageTypeInstance;
|
|
64
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
65
|
+
readonly schema: SqlSchemaIR;
|
|
66
|
+
readonly schemaName?: string;
|
|
67
|
+
readonly policy: MigrationOperationPolicy;
|
|
68
|
+
}) => StorageTypePlanResult<TTargetDetails>;
|
|
69
|
+
verifyType?: (options: {
|
|
70
|
+
readonly typeName: string;
|
|
71
|
+
readonly typeInstance: StorageTypeInstance;
|
|
72
|
+
readonly schema: SqlSchemaIR;
|
|
73
|
+
readonly schemaName?: string;
|
|
74
|
+
}) => readonly SchemaIssue[];
|
|
75
|
+
introspectTypes?: (options: {
|
|
76
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
77
|
+
readonly schemaName?: string;
|
|
78
|
+
}) => Promise<Record<string, StorageTypeInstance>>;
|
|
79
|
+
/**
|
|
80
|
+
* Expands a parameterized native type to its full SQL representation.
|
|
81
|
+
* Used by schema verification to compare contract types against database types.
|
|
82
|
+
*
|
|
83
|
+
* For example, expands:
|
|
84
|
+
* - { nativeType: 'character varying', typeParams: { length: 255 } } -> 'character varying(255)'
|
|
85
|
+
* - { nativeType: 'numeric', typeParams: { precision: 10, scale: 2 } } -> 'numeric(10,2)'
|
|
86
|
+
*
|
|
87
|
+
* Returns the expanded type string, or the original nativeType if no expansion is needed.
|
|
88
|
+
*/
|
|
89
|
+
expandNativeType?: (input: ExpandNativeTypeInput) => string;
|
|
90
|
+
}
|
|
91
|
+
|
|
96
92
|
export interface SqlControlExtensionDescriptor<TTargetId extends string>
|
|
97
|
-
extends ControlExtensionDescriptor<'sql', TTargetId
|
|
98
|
-
|
|
93
|
+
extends ControlExtensionDescriptor<'sql', TTargetId>,
|
|
94
|
+
SqlControlStaticContributions {
|
|
99
95
|
readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
export interface SqlControlAdapterDescriptor<TTargetId extends string>
|
|
99
|
+
extends ControlAdapterDescriptor<'sql', TTargetId>,
|
|
100
|
+
SqlControlStaticContributions {}
|
|
105
101
|
|
|
106
|
-
/**
|
|
107
|
-
* A single step in a SQL migration operation (precheck, execute, or postcheck).
|
|
108
|
-
*/
|
|
109
102
|
export interface SqlMigrationPlanOperationStep {
|
|
110
103
|
readonly description: string;
|
|
111
104
|
readonly sql: string;
|
|
112
105
|
readonly meta?: AnyRecord;
|
|
113
106
|
}
|
|
114
107
|
|
|
115
|
-
/**
|
|
116
|
-
* Target details for a SQL migration operation (table, column, index, etc.).
|
|
117
|
-
*/
|
|
118
108
|
export interface SqlMigrationPlanOperationTarget<TTargetDetails> {
|
|
119
109
|
readonly id: string;
|
|
120
110
|
readonly details?: TTargetDetails;
|
|
121
111
|
}
|
|
122
112
|
|
|
123
|
-
/**
|
|
124
|
-
* A single SQL migration operation with SQL-specific fields.
|
|
125
|
-
* Extends the core MigrationPlanOperation with SQL execution details.
|
|
126
|
-
*/
|
|
127
113
|
export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperation {
|
|
128
|
-
/** Optional detailed explanation of what this operation does and why. */
|
|
129
114
|
readonly summary?: string;
|
|
130
115
|
readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
|
|
131
116
|
readonly precheck: readonly SqlMigrationPlanOperationStep[];
|
|
@@ -134,18 +119,11 @@ export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlan
|
|
|
134
119
|
readonly meta?: AnyRecord;
|
|
135
120
|
}
|
|
136
121
|
|
|
137
|
-
/**
|
|
138
|
-
* Contract identity information for SQL migrations.
|
|
139
|
-
*/
|
|
140
122
|
export interface SqlMigrationPlanContractInfo {
|
|
141
|
-
readonly
|
|
123
|
+
readonly storageHash: string;
|
|
142
124
|
readonly profileHash?: string;
|
|
143
125
|
}
|
|
144
126
|
|
|
145
|
-
/**
|
|
146
|
-
* A SQL migration plan with SQL-specific fields.
|
|
147
|
-
* Extends the core MigrationPlan with origin tracking and metadata.
|
|
148
|
-
*/
|
|
149
127
|
export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
|
|
150
128
|
/**
|
|
151
129
|
* Origin contract identity that the plan expects the database to currently be at.
|
|
@@ -161,13 +139,6 @@ export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
|
|
|
161
139
|
readonly meta?: AnyRecord;
|
|
162
140
|
}
|
|
163
141
|
|
|
164
|
-
// ============================================================================
|
|
165
|
-
// SQL-Specific Planner Types
|
|
166
|
-
// ============================================================================
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Specific conflict kinds for SQL migrations.
|
|
170
|
-
*/
|
|
171
142
|
export type SqlPlannerConflictKind =
|
|
172
143
|
| 'typeMismatch'
|
|
173
144
|
| 'nullabilityConflict'
|
|
@@ -178,54 +149,36 @@ export type SqlPlannerConflictKind =
|
|
|
178
149
|
| 'extensionMissing'
|
|
179
150
|
| 'unsupportedOperation';
|
|
180
151
|
|
|
181
|
-
/**
|
|
182
|
-
* Location information for SQL planner conflicts.
|
|
183
|
-
*/
|
|
184
152
|
export interface SqlPlannerConflictLocation {
|
|
185
153
|
readonly table?: string;
|
|
186
154
|
readonly column?: string;
|
|
187
155
|
readonly index?: string;
|
|
188
156
|
readonly constraint?: string;
|
|
189
157
|
readonly extension?: string;
|
|
158
|
+
readonly type?: string;
|
|
190
159
|
}
|
|
191
160
|
|
|
192
|
-
/**
|
|
193
|
-
* A SQL-specific planner conflict with additional location information.
|
|
194
|
-
* Extends the core MigrationPlannerConflict.
|
|
195
|
-
*/
|
|
196
161
|
export interface SqlPlannerConflict extends MigrationPlannerConflict {
|
|
197
162
|
readonly kind: SqlPlannerConflictKind;
|
|
198
163
|
readonly location?: SqlPlannerConflictLocation;
|
|
199
164
|
readonly meta?: AnyRecord;
|
|
200
165
|
}
|
|
201
166
|
|
|
202
|
-
/**
|
|
203
|
-
* Successful SQL planner result with the migration plan.
|
|
204
|
-
*/
|
|
205
167
|
export interface SqlPlannerSuccessResult<TTargetDetails>
|
|
206
168
|
extends Omit<MigrationPlannerSuccessResult, 'plan'> {
|
|
207
169
|
readonly kind: 'success';
|
|
208
170
|
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
209
171
|
}
|
|
210
172
|
|
|
211
|
-
/**
|
|
212
|
-
* Failed SQL planner result with the list of conflicts.
|
|
213
|
-
*/
|
|
214
173
|
export interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
|
|
215
174
|
readonly kind: 'failure';
|
|
216
175
|
readonly conflicts: readonly SqlPlannerConflict[];
|
|
217
176
|
}
|
|
218
177
|
|
|
219
|
-
/**
|
|
220
|
-
* Union type for SQL planner results.
|
|
221
|
-
*/
|
|
222
178
|
export type SqlPlannerResult<TTargetDetails> =
|
|
223
179
|
| SqlPlannerSuccessResult<TTargetDetails>
|
|
224
180
|
| SqlPlannerFailureResult;
|
|
225
181
|
|
|
226
|
-
/**
|
|
227
|
-
* Options for SQL migration planner.
|
|
228
|
-
*/
|
|
229
182
|
export interface SqlMigrationPlannerPlanOptions {
|
|
230
183
|
readonly contract: SqlContract<SqlStorage>;
|
|
231
184
|
readonly schema: SqlSchemaIR;
|
|
@@ -239,29 +192,15 @@ export interface SqlMigrationPlannerPlanOptions {
|
|
|
239
192
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
240
193
|
}
|
|
241
194
|
|
|
242
|
-
/**
|
|
243
|
-
* SQL migration planner interface.
|
|
244
|
-
* Extends the core MigrationPlanner with SQL-specific types.
|
|
245
|
-
*/
|
|
246
195
|
export interface SqlMigrationPlanner<TTargetDetails> {
|
|
247
196
|
plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
|
|
248
197
|
}
|
|
249
198
|
|
|
250
|
-
// ============================================================================
|
|
251
|
-
// SQL-Specific Runner Types
|
|
252
|
-
// ============================================================================
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Callbacks for SQL migration runner execution.
|
|
256
|
-
*/
|
|
257
199
|
export interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
|
|
258
200
|
onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
259
201
|
onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
260
202
|
}
|
|
261
203
|
|
|
262
|
-
/**
|
|
263
|
-
* Options for SQL migration runner execution.
|
|
264
|
-
*/
|
|
265
204
|
export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
|
|
266
205
|
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
267
206
|
readonly driver: ControlDriverInstance<'sql', string>;
|
|
@@ -292,9 +231,6 @@ export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
|
|
|
292
231
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
293
232
|
}
|
|
294
233
|
|
|
295
|
-
/**
|
|
296
|
-
* Error codes for SQL migration runner failures.
|
|
297
|
-
*/
|
|
298
234
|
export type SqlMigrationRunnerErrorCode =
|
|
299
235
|
| 'DESTINATION_CONTRACT_MISMATCH'
|
|
300
236
|
| 'MARKER_ORIGIN_MISMATCH'
|
|
@@ -304,73 +240,36 @@ export type SqlMigrationRunnerErrorCode =
|
|
|
304
240
|
| 'SCHEMA_VERIFY_FAILED'
|
|
305
241
|
| 'EXECUTION_FAILED';
|
|
306
242
|
|
|
307
|
-
/**
|
|
308
|
-
* Detailed information about a SQL migration runner failure.
|
|
309
|
-
* Extends the core MigrationRunnerFailure with SQL-specific error codes.
|
|
310
|
-
*/
|
|
311
243
|
export interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
|
|
312
244
|
readonly code: SqlMigrationRunnerErrorCode;
|
|
313
245
|
readonly meta?: AnyRecord;
|
|
314
246
|
}
|
|
315
247
|
|
|
316
|
-
/**
|
|
317
|
-
* Success value for SQL migration runner execution.
|
|
318
|
-
* Extends core type for type branding and potential SQL-specific extensions.
|
|
319
|
-
*/
|
|
320
248
|
export interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
|
|
321
249
|
|
|
322
|
-
/**
|
|
323
|
-
* Result type for SQL migration runner execution.
|
|
324
|
-
*/
|
|
325
250
|
export type SqlMigrationRunnerResult = Result<
|
|
326
251
|
SqlMigrationRunnerSuccessValue,
|
|
327
252
|
SqlMigrationRunnerFailure
|
|
328
253
|
>;
|
|
329
254
|
|
|
330
|
-
/**
|
|
331
|
-
* SQL migration runner interface.
|
|
332
|
-
* Extends the core MigrationRunner with SQL-specific types.
|
|
333
|
-
*/
|
|
334
255
|
export interface SqlMigrationRunner<TTargetDetails> {
|
|
335
256
|
execute(
|
|
336
257
|
options: SqlMigrationRunnerExecuteOptions<TTargetDetails>,
|
|
337
258
|
): Promise<SqlMigrationRunnerResult>;
|
|
338
259
|
}
|
|
339
260
|
|
|
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
261
|
export interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails>
|
|
349
262
|
extends ControlTargetDescriptor<
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
* Creates a SQL migration planner for this target.
|
|
357
|
-
* Direct method for SQL-specific usage.
|
|
358
|
-
*/
|
|
263
|
+
'sql',
|
|
264
|
+
TTargetId,
|
|
265
|
+
ControlTargetInstance<'sql', TTargetId>,
|
|
266
|
+
SqlControlFamilyInstance
|
|
267
|
+
>,
|
|
268
|
+
SqlControlStaticContributions {
|
|
359
269
|
createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
|
|
360
|
-
/**
|
|
361
|
-
* Creates a SQL migration runner for this target.
|
|
362
|
-
* Direct method for SQL-specific usage.
|
|
363
|
-
*/
|
|
364
270
|
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
365
271
|
}
|
|
366
272
|
|
|
367
|
-
// ============================================================================
|
|
368
|
-
// Helper Types
|
|
369
|
-
// ============================================================================
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Options for creating a SQL migration plan.
|
|
373
|
-
*/
|
|
374
273
|
export interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
375
274
|
readonly targetId: string;
|
|
376
275
|
readonly origin?: SqlMigrationPlanContractInfo | null;
|
|
@@ -1,45 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
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/core-execution-plane/types';
|
|
2
|
+
import { createSqlRuntimeFamilyInstance, type SqlRuntimeFamilyInstance } from './runtime-instance';
|
|
14
3
|
|
|
15
4
|
/**
|
|
16
|
-
* SQL
|
|
17
|
-
*
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -1,144 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
RuntimeAdapterDescriptor,
|
|
4
|
-
RuntimeDriverDescriptor,
|
|
5
|
-
RuntimeDriverInstance,
|
|
6
|
-
RuntimeFamilyDescriptor,
|
|
7
|
-
RuntimeFamilyInstance,
|
|
8
|
-
RuntimeTargetDescriptor,
|
|
9
|
-
} from '@prisma-next/core-execution-plane/types';
|
|
10
|
-
import type { Log, Plugin, RuntimeVerifyOptions } from '@prisma-next/runtime-executor';
|
|
11
|
-
import type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
12
|
-
import type {
|
|
13
|
-
Adapter,
|
|
14
|
-
LoweredStatement,
|
|
15
|
-
SelectAst,
|
|
16
|
-
SqlDriver,
|
|
17
|
-
} from '@prisma-next/sql-relational-core/ast';
|
|
18
|
-
import type {
|
|
19
|
-
Runtime,
|
|
20
|
-
RuntimeOptions,
|
|
21
|
-
SqlRuntimeAdapterInstance,
|
|
22
|
-
SqlRuntimeExtensionDescriptor,
|
|
23
|
-
} from '@prisma-next/sql-runtime';
|
|
24
|
-
import { createRuntime, createRuntimeContext } from '@prisma-next/sql-runtime';
|
|
1
|
+
import type { RuntimeFamilyInstance } from '@prisma-next/core-execution-plane/types';
|
|
25
2
|
|
|
26
3
|
/**
|
|
27
|
-
* SQL
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
> &
|
|
34
|
-
SqlDriver;
|
|
35
|
-
|
|
36
|
-
// Re-export SqlRuntimeAdapterInstance from sql-runtime for consumers
|
|
37
|
-
export type { SqlRuntimeAdapterInstance } from '@prisma-next/sql-runtime';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* SQL runtime family instance interface.
|
|
41
|
-
* Extends base RuntimeFamilyInstance with SQL-specific runtime creation method.
|
|
4
|
+
* SQL execution-plane family instance interface.
|
|
5
|
+
*
|
|
6
|
+
* Note: this is currently named `SqlRuntimeFamilyInstance` because the execution plane
|
|
7
|
+
* framework types are still using the `Runtime*` naming (`RuntimeFamilyInstance`, etc.).
|
|
8
|
+
*
|
|
9
|
+
* This will be renamed to `SqlExecutionFamilyInstance` as part of `TML-1842`.
|
|
42
10
|
*/
|
|
43
|
-
export interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {
|
|
44
|
-
/**
|
|
45
|
-
* Creates a SQL runtime from contract, driver options, and verification settings.
|
|
46
|
-
*
|
|
47
|
-
* Extension packs are routed through composition (at instance creation time),
|
|
48
|
-
* not through this method. This aligns with control-plane composition patterns.
|
|
49
|
-
*
|
|
50
|
-
* @param options - Runtime creation options
|
|
51
|
-
* @param options.contract - SQL contract
|
|
52
|
-
* @param options.driverOptions - Driver options (e.g., PostgresDriverOptions)
|
|
53
|
-
* @param options.verify - Runtime verification options
|
|
54
|
-
* @param options.plugins - Optional plugins
|
|
55
|
-
* @param options.mode - Optional runtime mode
|
|
56
|
-
* @param options.log - Optional log instance
|
|
57
|
-
* @returns Runtime instance
|
|
58
|
-
*/
|
|
59
|
-
createRuntime<TContract extends SqlContract<SqlStorage>>(options: {
|
|
60
|
-
readonly contract: TContract;
|
|
61
|
-
readonly driverOptions: unknown;
|
|
62
|
-
readonly verify: RuntimeVerifyOptions;
|
|
63
|
-
readonly plugins?: readonly Plugin<
|
|
64
|
-
TContract,
|
|
65
|
-
Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,
|
|
66
|
-
SqlDriver
|
|
67
|
-
>[];
|
|
68
|
-
readonly mode?: 'strict' | 'permissive';
|
|
69
|
-
readonly log?: Log;
|
|
70
|
-
}): Runtime;
|
|
71
|
-
}
|
|
11
|
+
export interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {}
|
|
72
12
|
|
|
73
13
|
/**
|
|
74
|
-
* Creates a SQL
|
|
14
|
+
* Creates a SQL execution-plane family instance.
|
|
75
15
|
*
|
|
76
|
-
*
|
|
77
|
-
* family, target, adapter, driver, extensionPacks (all as descriptors with IDs).
|
|
16
|
+
* This will be renamed to `createSqlExecutionFamilyInstance()` as part of `TML-1842`.
|
|
78
17
|
*/
|
|
79
|
-
export function createSqlRuntimeFamilyInstance
|
|
80
|
-
readonly family: RuntimeFamilyDescriptor<'sql'>;
|
|
81
|
-
readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;
|
|
82
|
-
readonly adapter: RuntimeAdapterDescriptor<
|
|
83
|
-
'sql',
|
|
84
|
-
TTargetId,
|
|
85
|
-
SqlRuntimeAdapterInstance<TTargetId>
|
|
86
|
-
>;
|
|
87
|
-
readonly driver: RuntimeDriverDescriptor<'sql', TTargetId, SqlRuntimeDriverInstance<TTargetId>>;
|
|
88
|
-
readonly extensionPacks?: readonly SqlRuntimeExtensionDescriptor<TTargetId>[];
|
|
89
|
-
}): SqlRuntimeFamilyInstance {
|
|
90
|
-
const {
|
|
91
|
-
family: familyDescriptor,
|
|
92
|
-
target: targetDescriptor,
|
|
93
|
-
adapter: adapterDescriptor,
|
|
94
|
-
driver: driverDescriptor,
|
|
95
|
-
extensionPacks: extensionDescriptors = [],
|
|
96
|
-
} = options;
|
|
97
|
-
|
|
18
|
+
export function createSqlRuntimeFamilyInstance(): SqlRuntimeFamilyInstance {
|
|
98
19
|
return {
|
|
99
20
|
familyId: 'sql' as const,
|
|
100
|
-
createRuntime<TContract extends SqlContract<SqlStorage>>(runtimeOptions: {
|
|
101
|
-
readonly contract: TContract;
|
|
102
|
-
readonly driverOptions: unknown;
|
|
103
|
-
readonly verify: RuntimeVerifyOptions;
|
|
104
|
-
readonly plugins?: readonly Plugin<
|
|
105
|
-
TContract,
|
|
106
|
-
Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,
|
|
107
|
-
SqlDriver
|
|
108
|
-
>[];
|
|
109
|
-
readonly mode?: 'strict' | 'permissive';
|
|
110
|
-
readonly log?: Log;
|
|
111
|
-
}): Runtime {
|
|
112
|
-
// Validate contract requirements against provided descriptors
|
|
113
|
-
assertRuntimeContractRequirementsSatisfied({
|
|
114
|
-
contract: runtimeOptions.contract,
|
|
115
|
-
family: familyDescriptor,
|
|
116
|
-
target: targetDescriptor,
|
|
117
|
-
adapter: adapterDescriptor,
|
|
118
|
-
extensionPacks: extensionDescriptors,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Create driver instance
|
|
122
|
-
const driverInstance = driverDescriptor.create(runtimeOptions.driverOptions);
|
|
123
|
-
|
|
124
|
-
// Create context via descriptor-first API
|
|
125
|
-
const context = createRuntimeContext<TContract, TTargetId>({
|
|
126
|
-
contract: runtimeOptions.contract,
|
|
127
|
-
target: targetDescriptor,
|
|
128
|
-
adapter: adapterDescriptor,
|
|
129
|
-
extensionPacks: extensionDescriptors,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const runtimeOptions_: RuntimeOptions<TContract> = {
|
|
133
|
-
driver: driverInstance,
|
|
134
|
-
verify: runtimeOptions.verify,
|
|
135
|
-
context,
|
|
136
|
-
...(runtimeOptions.plugins ? { plugins: runtimeOptions.plugins } : {}),
|
|
137
|
-
...(runtimeOptions.mode ? { mode: runtimeOptions.mode } : {}),
|
|
138
|
-
...(runtimeOptions.log ? { log: runtimeOptions.log } : {}),
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
return createRuntime(runtimeOptions_);
|
|
142
|
-
},
|
|
143
21
|
};
|
|
144
22
|
}
|