@prisma-next/family-sql 0.1.0-dev.2 → 0.1.0-dev.21
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 +42 -0
- package/dist/exports/chunk-54XYY6SU.js +772 -0
- package/dist/exports/chunk-54XYY6SU.js.map +1 -0
- package/dist/exports/{chunk-3HYKCN35.js → chunk-C3GKWCKA.js} +16 -9
- package/dist/exports/chunk-C3GKWCKA.js.map +1 -0
- package/dist/exports/chunk-LECWNGKN.js +609 -0
- package/dist/exports/chunk-LECWNGKN.js.map +1 -0
- package/dist/exports/control-adapter.d.ts +1 -1
- package/dist/exports/control.d.ts +40 -113
- package/dist/exports/control.js +126 -1349
- package/dist/exports/control.js.map +1 -1
- package/dist/exports/instance-BDpyIYu5.d.ts +384 -0
- package/dist/exports/runtime.d.ts +13 -3
- package/dist/exports/runtime.js +2 -3
- package/dist/exports/runtime.js.map +1 -1
- package/dist/exports/schema-verify.d.ts +72 -0
- package/dist/exports/schema-verify.js +11 -0
- package/dist/exports/schema-verify.js.map +1 -0
- package/dist/exports/test-utils.d.ts +34 -0
- package/dist/exports/test-utils.js +15 -0
- package/dist/exports/test-utils.js.map +1 -0
- package/dist/exports/verify.d.ts +1 -1
- package/dist/exports/verify.js +1 -1
- package/package.json +29 -21
- package/dist/exports/chunk-3HYKCN35.js.map +0 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
|
|
2
|
+
import { ControlTargetDescriptor, ControlTargetInstance, MigrationOperationPolicy, MigrationPlannerSuccessResult, MigrationPlan, MigrationPlanOperation, MigrationPlannerFailureResult, MigrationPlannerConflict, ControlDriverInstance, OperationContext, MigrationRunnerSuccessValue, MigrationRunnerFailure, SchemaIssue, ControlExtensionDescriptor, ControlFamilyInstance, VerifyDatabaseResult, VerifyDatabaseSchemaResult, SignDatabaseResult, EmitContractResult } from '@prisma-next/core-control-plane/types';
|
|
3
|
+
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
4
|
+
import { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
5
|
+
import { Result } from '@prisma-next/utils/result';
|
|
6
|
+
import { ContractIR } from '@prisma-next/contract/ir';
|
|
7
|
+
import { TypesImportSpec } from '@prisma-next/contract/types';
|
|
8
|
+
import { CoreSchemaView } from '@prisma-next/core-control-plane/schema-view';
|
|
9
|
+
import { OperationRegistry } from '@prisma-next/operations';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SQL-specific migration types.
|
|
13
|
+
*
|
|
14
|
+
* These types extend the canonical migration types from the framework control plane
|
|
15
|
+
* with SQL-specific fields for execution (precheck SQL, execute SQL, etc.).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
type AnyRecord = Readonly<Record<string, unknown>>;
|
|
19
|
+
/**
|
|
20
|
+
* A single database dependency declared by a framework component.
|
|
21
|
+
* Uses SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
|
|
22
|
+
*
|
|
23
|
+
* Database dependencies allow components (extensions, adapters) to declare what database-side
|
|
24
|
+
* persistence structures they require (e.g., Postgres extensions, schemas, functions).
|
|
25
|
+
* The planner emits these as migration operations, and the verifier uses the pure verification
|
|
26
|
+
* hook to check satisfaction against the schema IR.
|
|
27
|
+
*/
|
|
28
|
+
interface ComponentDatabaseDependency<TTargetDetails = Record<string, never>> {
|
|
29
|
+
/** Stable identifier for the dependency (e.g. 'postgres.extension.vector') */
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/** Human label for output (e.g. 'Enable vector extension') */
|
|
32
|
+
readonly label: string;
|
|
33
|
+
/**
|
|
34
|
+
* Operations that install/ensure the dependency.
|
|
35
|
+
* Use SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
|
|
36
|
+
*/
|
|
37
|
+
readonly install: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
38
|
+
/**
|
|
39
|
+
* Pure verification hook: checks whether this dependency is already installed
|
|
40
|
+
* based on the in-memory schema IR (no DB I/O).
|
|
41
|
+
*
|
|
42
|
+
* This must return structured issues suitable for CLI and tree output, not just a boolean.
|
|
43
|
+
*/
|
|
44
|
+
readonly verifyDatabaseDependencyInstalled: (schema: SqlSchemaIR) => readonly SchemaIssue[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Database dependencies declared by a framework component.
|
|
48
|
+
*/
|
|
49
|
+
interface ComponentDatabaseDependencies<TTargetDetails = Record<string, never>> {
|
|
50
|
+
/**
|
|
51
|
+
* Dependencies required for db init.
|
|
52
|
+
* Future: update dependencies can be added later (e.g. widening/destructive).
|
|
53
|
+
*/
|
|
54
|
+
readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* SQL-specific extension descriptor with optional database dependencies.
|
|
58
|
+
* Extends the core ControlExtensionDescriptor with SQL-specific metadata.
|
|
59
|
+
*
|
|
60
|
+
* Database dependencies are attached to the descriptor (not the instance) because
|
|
61
|
+
* they are declarative metadata that planner/verifier need without constructing instances.
|
|
62
|
+
*/
|
|
63
|
+
interface SqlControlExtensionDescriptor<TTargetId extends string> extends ControlExtensionDescriptor<'sql', TTargetId> {
|
|
64
|
+
/** Optional database dependencies this extension requires. */
|
|
65
|
+
readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A single step in a SQL migration operation (precheck, execute, or postcheck).
|
|
69
|
+
*/
|
|
70
|
+
interface SqlMigrationPlanOperationStep {
|
|
71
|
+
readonly description: string;
|
|
72
|
+
readonly sql: string;
|
|
73
|
+
readonly meta?: AnyRecord;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Target details for a SQL migration operation (table, column, index, etc.).
|
|
77
|
+
*/
|
|
78
|
+
interface SqlMigrationPlanOperationTarget<TTargetDetails> {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly details?: TTargetDetails;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A single SQL migration operation with SQL-specific fields.
|
|
84
|
+
* Extends the core MigrationPlanOperation with SQL execution details.
|
|
85
|
+
*/
|
|
86
|
+
interface SqlMigrationPlanOperation<TTargetDetails = Record<string, never>> extends MigrationPlanOperation {
|
|
87
|
+
/** Optional detailed explanation of what this operation does and why. */
|
|
88
|
+
readonly summary?: string;
|
|
89
|
+
readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
|
|
90
|
+
readonly precheck: readonly SqlMigrationPlanOperationStep[];
|
|
91
|
+
readonly execute: readonly SqlMigrationPlanOperationStep[];
|
|
92
|
+
readonly postcheck: readonly SqlMigrationPlanOperationStep[];
|
|
93
|
+
readonly meta?: AnyRecord;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Contract identity information for SQL migrations.
|
|
97
|
+
*/
|
|
98
|
+
interface SqlMigrationPlanContractInfo {
|
|
99
|
+
readonly coreHash: string;
|
|
100
|
+
readonly profileHash?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A SQL migration plan with SQL-specific fields.
|
|
104
|
+
* Extends the core MigrationPlan with origin tracking and metadata.
|
|
105
|
+
*/
|
|
106
|
+
interface SqlMigrationPlan<TTargetDetails = Record<string, never>> extends MigrationPlan {
|
|
107
|
+
/**
|
|
108
|
+
* Origin contract identity that the plan expects the database to currently be at.
|
|
109
|
+
* If omitted, the runner treats the origin as "no marker present" (empty database),
|
|
110
|
+
* and will only proceed if no marker exists (or if the marker already matches destination).
|
|
111
|
+
*/
|
|
112
|
+
readonly origin?: SqlMigrationPlanContractInfo | null;
|
|
113
|
+
/**
|
|
114
|
+
* Destination contract identity that the plan intends to reach.
|
|
115
|
+
*/
|
|
116
|
+
readonly destination: SqlMigrationPlanContractInfo;
|
|
117
|
+
readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
118
|
+
readonly meta?: AnyRecord;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Specific conflict kinds for SQL migrations.
|
|
122
|
+
*/
|
|
123
|
+
type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedExtension' | 'extensionMissing' | 'unsupportedOperation';
|
|
124
|
+
/**
|
|
125
|
+
* Location information for SQL planner conflicts.
|
|
126
|
+
*/
|
|
127
|
+
interface SqlPlannerConflictLocation {
|
|
128
|
+
readonly table?: string;
|
|
129
|
+
readonly column?: string;
|
|
130
|
+
readonly index?: string;
|
|
131
|
+
readonly constraint?: string;
|
|
132
|
+
readonly extension?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A SQL-specific planner conflict with additional location information.
|
|
136
|
+
* Extends the core MigrationPlannerConflict.
|
|
137
|
+
*/
|
|
138
|
+
interface SqlPlannerConflict extends MigrationPlannerConflict {
|
|
139
|
+
readonly kind: SqlPlannerConflictKind;
|
|
140
|
+
readonly location?: SqlPlannerConflictLocation;
|
|
141
|
+
readonly meta?: AnyRecord;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Successful SQL planner result with the migration plan.
|
|
145
|
+
*/
|
|
146
|
+
interface SqlPlannerSuccessResult<TTargetDetails> extends Omit<MigrationPlannerSuccessResult, 'plan'> {
|
|
147
|
+
readonly kind: 'success';
|
|
148
|
+
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Failed SQL planner result with the list of conflicts.
|
|
152
|
+
*/
|
|
153
|
+
interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
|
|
154
|
+
readonly kind: 'failure';
|
|
155
|
+
readonly conflicts: readonly SqlPlannerConflict[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Union type for SQL planner results.
|
|
159
|
+
*/
|
|
160
|
+
type SqlPlannerResult<TTargetDetails = Record<string, never>> = SqlPlannerSuccessResult<TTargetDetails> | SqlPlannerFailureResult;
|
|
161
|
+
/**
|
|
162
|
+
* Options for SQL migration planner.
|
|
163
|
+
*/
|
|
164
|
+
interface SqlMigrationPlannerPlanOptions {
|
|
165
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
166
|
+
readonly schema: SqlSchemaIR;
|
|
167
|
+
readonly policy: MigrationOperationPolicy;
|
|
168
|
+
readonly schemaName?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Active framework components participating in this composition.
|
|
171
|
+
* SQL targets can interpret this list to derive database dependencies.
|
|
172
|
+
* All components must have matching familyId ('sql') and targetId.
|
|
173
|
+
*/
|
|
174
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* SQL migration planner interface.
|
|
178
|
+
* Extends the core MigrationPlanner with SQL-specific types.
|
|
179
|
+
*/
|
|
180
|
+
interface SqlMigrationPlanner<TTargetDetails = Record<string, never>> {
|
|
181
|
+
plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Callbacks for SQL migration runner execution.
|
|
185
|
+
*/
|
|
186
|
+
interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails = Record<string, never>> {
|
|
187
|
+
onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
188
|
+
onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Options for SQL migration runner execution.
|
|
192
|
+
*/
|
|
193
|
+
interface SqlMigrationRunnerExecuteOptions<TTargetDetails = Record<string, never>> {
|
|
194
|
+
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
195
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
196
|
+
/**
|
|
197
|
+
* Destination contract IR.
|
|
198
|
+
* Must correspond to `plan.destination` and is used for schema verification and marker/ledger writes.
|
|
199
|
+
*/
|
|
200
|
+
readonly destinationContract: SqlContract<SqlStorage>;
|
|
201
|
+
/**
|
|
202
|
+
* Execution-time policy that defines which operation classes are allowed.
|
|
203
|
+
* The runner validates each operation against this policy before execution.
|
|
204
|
+
*/
|
|
205
|
+
readonly policy: MigrationOperationPolicy;
|
|
206
|
+
readonly schemaName?: string;
|
|
207
|
+
readonly strictVerification?: boolean;
|
|
208
|
+
readonly callbacks?: SqlMigrationRunnerExecuteCallbacks<TTargetDetails>;
|
|
209
|
+
readonly context?: OperationContext;
|
|
210
|
+
/**
|
|
211
|
+
* Active framework components participating in this composition.
|
|
212
|
+
* SQL targets can interpret this list to derive database dependencies.
|
|
213
|
+
* All components must have matching familyId ('sql') and targetId.
|
|
214
|
+
*/
|
|
215
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Error codes for SQL migration runner failures.
|
|
219
|
+
*/
|
|
220
|
+
type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'EXECUTION_FAILED';
|
|
221
|
+
/**
|
|
222
|
+
* Detailed information about a SQL migration runner failure.
|
|
223
|
+
* Extends the core MigrationRunnerFailure with SQL-specific error codes.
|
|
224
|
+
*/
|
|
225
|
+
interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
|
|
226
|
+
readonly code: SqlMigrationRunnerErrorCode;
|
|
227
|
+
readonly meta?: AnyRecord;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Success value for SQL migration runner execution.
|
|
231
|
+
* Extends core type for type branding and potential SQL-specific extensions.
|
|
232
|
+
*/
|
|
233
|
+
interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Result type for SQL migration runner execution.
|
|
237
|
+
*/
|
|
238
|
+
type SqlMigrationRunnerResult = Result<SqlMigrationRunnerSuccessValue, SqlMigrationRunnerFailure>;
|
|
239
|
+
/**
|
|
240
|
+
* SQL migration runner interface.
|
|
241
|
+
* Extends the core MigrationRunner with SQL-specific types.
|
|
242
|
+
*/
|
|
243
|
+
interface SqlMigrationRunner<TTargetDetails = Record<string, never>> {
|
|
244
|
+
execute(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* SQL control target descriptor with migration support.
|
|
248
|
+
* Extends the core ControlTargetDescriptor with SQL-specific migration methods.
|
|
249
|
+
*/
|
|
250
|
+
interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails = Record<string, never>> extends ControlTargetDescriptor<'sql', TTargetId, ControlTargetInstance<'sql', TTargetId>, SqlControlFamilyInstance> {
|
|
251
|
+
/**
|
|
252
|
+
* Creates a SQL migration planner for this target.
|
|
253
|
+
* Direct method for SQL-specific usage.
|
|
254
|
+
*/
|
|
255
|
+
createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a SQL migration runner for this target.
|
|
258
|
+
* Direct method for SQL-specific usage.
|
|
259
|
+
*/
|
|
260
|
+
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Options for creating a SQL migration plan.
|
|
264
|
+
*/
|
|
265
|
+
interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
266
|
+
readonly targetId: string;
|
|
267
|
+
readonly origin?: SqlMigrationPlanContractInfo | null;
|
|
268
|
+
readonly destination: SqlMigrationPlanContractInfo;
|
|
269
|
+
readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
270
|
+
readonly meta?: AnyRecord;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Type metadata for SQL storage types.
|
|
275
|
+
* Maps contract storage type IDs to native database types.
|
|
276
|
+
*/
|
|
277
|
+
interface SqlTypeMetadata {
|
|
278
|
+
readonly typeId: string;
|
|
279
|
+
readonly familyId: 'sql';
|
|
280
|
+
readonly targetId: string;
|
|
281
|
+
readonly nativeType?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Registry mapping type IDs to their metadata.
|
|
285
|
+
* Keyed by contract storage type ID (e.g., 'pg/int4@1').
|
|
286
|
+
*/
|
|
287
|
+
type SqlTypeMetadataRegistry = Map<string, SqlTypeMetadata>;
|
|
288
|
+
/**
|
|
289
|
+
* State fields for SQL family instance that hold assembly data.
|
|
290
|
+
*/
|
|
291
|
+
interface SqlFamilyInstanceState {
|
|
292
|
+
readonly operationRegistry: OperationRegistry;
|
|
293
|
+
readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
294
|
+
readonly operationTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
295
|
+
readonly extensionIds: ReadonlyArray<string>;
|
|
296
|
+
readonly typeMetadataRegistry: SqlTypeMetadataRegistry;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Options for schema verification.
|
|
300
|
+
*/
|
|
301
|
+
interface SchemaVerifyOptions {
|
|
302
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
303
|
+
readonly contractIR: unknown;
|
|
304
|
+
readonly strict: boolean;
|
|
305
|
+
readonly context?: OperationContext;
|
|
306
|
+
/**
|
|
307
|
+
* Active framework components participating in this composition.
|
|
308
|
+
* All components must have matching familyId ('sql') and targetId.
|
|
309
|
+
*/
|
|
310
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* SQL control family instance interface.
|
|
314
|
+
* Extends ControlFamilyInstance with SQL-specific domain actions.
|
|
315
|
+
*/
|
|
316
|
+
interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql'>, SqlFamilyInstanceState {
|
|
317
|
+
/**
|
|
318
|
+
* Validates a contract JSON and returns a validated ContractIR (without mappings).
|
|
319
|
+
* Mappings are runtime-only and should not be part of ContractIR.
|
|
320
|
+
*/
|
|
321
|
+
validateContractIR(contractJson: unknown): ContractIR;
|
|
322
|
+
/**
|
|
323
|
+
* Verifies the database marker against the contract.
|
|
324
|
+
* Compares target, coreHash, and profileHash.
|
|
325
|
+
*/
|
|
326
|
+
verify(options: {
|
|
327
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
328
|
+
readonly contractIR: unknown;
|
|
329
|
+
readonly expectedTargetId: string;
|
|
330
|
+
readonly contractPath: string;
|
|
331
|
+
readonly configPath?: string;
|
|
332
|
+
}): Promise<VerifyDatabaseResult>;
|
|
333
|
+
/**
|
|
334
|
+
* Verifies the database schema against the contract.
|
|
335
|
+
* Compares contract requirements against live database schema.
|
|
336
|
+
*/
|
|
337
|
+
schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
|
|
338
|
+
/**
|
|
339
|
+
* Signs the database with the contract marker.
|
|
340
|
+
* Writes or updates the contract marker if schema verification passes.
|
|
341
|
+
* This operation is idempotent - if the marker already matches, no changes are made.
|
|
342
|
+
*/
|
|
343
|
+
sign(options: {
|
|
344
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
345
|
+
readonly contractIR: unknown;
|
|
346
|
+
readonly contractPath: string;
|
|
347
|
+
readonly configPath?: string;
|
|
348
|
+
}): Promise<SignDatabaseResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Introspects the database schema and returns a family-specific schema IR.
|
|
351
|
+
*
|
|
352
|
+
* This is a read-only operation that returns a snapshot of the live database schema.
|
|
353
|
+
* The method is family-owned and delegates to target/adapter-specific introspectors
|
|
354
|
+
* to perform the actual schema introspection.
|
|
355
|
+
*
|
|
356
|
+
* @param options - Introspection options
|
|
357
|
+
* @param options.driver - Control plane driver for database connection
|
|
358
|
+
* @param options.contractIR - Optional contract IR for contract-guided introspection.
|
|
359
|
+
* When provided, families may use it for filtering, optimization, or validation
|
|
360
|
+
* during introspection. The contract IR does not change the meaning of "what exists"
|
|
361
|
+
* in the database - it only guides how introspection is performed.
|
|
362
|
+
* @returns Promise resolving to the family-specific Schema IR (e.g., `SqlSchemaIR` for SQL).
|
|
363
|
+
* The IR represents the complete schema snapshot at the time of introspection.
|
|
364
|
+
*/
|
|
365
|
+
introspect(options: {
|
|
366
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
367
|
+
readonly contractIR?: unknown;
|
|
368
|
+
}): Promise<SqlSchemaIR>;
|
|
369
|
+
/**
|
|
370
|
+
* Projects a SQL Schema IR into a core schema view for CLI visualization.
|
|
371
|
+
* Converts SqlSchemaIR (tables, columns, indexes, extensions) into a tree structure.
|
|
372
|
+
*/
|
|
373
|
+
toSchemaView(schema: SqlSchemaIR): CoreSchemaView;
|
|
374
|
+
/**
|
|
375
|
+
* Emits contract JSON and DTS as strings.
|
|
376
|
+
* Uses the instance's preassembled state (operation registry, type imports, extension IDs).
|
|
377
|
+
* Handles stripping mappings and validation internally.
|
|
378
|
+
*/
|
|
379
|
+
emitContract(options: {
|
|
380
|
+
readonly contractIR: ContractIR | unknown;
|
|
381
|
+
}): Promise<EmitContractResult>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export type { AnyRecord as A, CreateSqlMigrationPlanOptions as C, SqlControlFamilyInstance as S, SqlControlTargetDescriptor as a, SqlMigrationPlan as b, SqlPlannerConflict as c, SqlPlannerFailureResult as d, SqlPlannerSuccessResult as e, SqlMigrationRunnerErrorCode as f, SqlMigrationRunnerFailure as g, SqlMigrationRunnerSuccessValue as h, SchemaVerifyOptions as i, ComponentDatabaseDependencies as j, ComponentDatabaseDependency as k, SqlControlExtensionDescriptor as l, SqlMigrationPlanContractInfo as m, SqlMigrationPlanner as n, SqlMigrationPlannerPlanOptions as o, SqlMigrationPlanOperation as p, SqlMigrationPlanOperationStep as q, SqlMigrationPlanOperationTarget as r, SqlMigrationRunner as s, SqlMigrationRunnerExecuteCallbacks as t, SqlMigrationRunnerExecuteOptions as u, SqlMigrationRunnerResult as v, SqlPlannerConflictKind as w, SqlPlannerConflictLocation as x, SqlPlannerResult as y };
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';
|
|
2
|
-
import { RuntimeFamilyInstance, RuntimeFamilyDescriptor, RuntimeTargetDescriptor, RuntimeAdapterDescriptor, RuntimeDriverDescriptor, RuntimeExtensionDescriptor } from '@prisma-next/core-execution-plane/types';
|
|
2
|
+
import { RuntimeFamilyInstance, RuntimeAdapterInstance, RuntimeDriverInstance, RuntimeFamilyDescriptor, RuntimeTargetDescriptor, RuntimeAdapterDescriptor, RuntimeDriverDescriptor, RuntimeExtensionDescriptor } from '@prisma-next/core-execution-plane/types';
|
|
3
3
|
import { RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
|
|
4
4
|
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
5
5
|
import { Adapter, SelectAst, LoweredStatement, SqlDriver } from '@prisma-next/sql-relational-core/ast';
|
|
6
6
|
import { Extension, Runtime } from '@prisma-next/sql-runtime';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* SQL runtime driver instance type.
|
|
10
|
+
* Combines identity properties with SQL-specific behavior methods.
|
|
11
|
+
*/
|
|
12
|
+
type SqlRuntimeDriverInstance<TTargetId extends string = string> = RuntimeDriverInstance<'sql', TTargetId> & SqlDriver;
|
|
13
|
+
/**
|
|
14
|
+
* SQL runtime adapter instance type.
|
|
15
|
+
* Combines identity properties with SQL-specific adapter behavior.
|
|
16
|
+
*/
|
|
17
|
+
type SqlRuntimeAdapterInstance<TTargetId extends string = string> = RuntimeAdapterInstance<'sql', TTargetId> & Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
8
18
|
/**
|
|
9
19
|
* SQL runtime family instance interface.
|
|
10
20
|
* Extends base RuntimeFamilyInstance with SQL-specific runtime creation method.
|
|
@@ -45,8 +55,8 @@ declare class SqlRuntimeFamilyDescriptor implements RuntimeFamilyDescriptor<'sql
|
|
|
45
55
|
readonly manifest: ExtensionPackManifest;
|
|
46
56
|
create<TTargetId extends string>(options: {
|
|
47
57
|
readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;
|
|
48
|
-
readonly adapter: RuntimeAdapterDescriptor<'sql', TTargetId
|
|
49
|
-
readonly driver: RuntimeDriverDescriptor<'sql', TTargetId
|
|
58
|
+
readonly adapter: RuntimeAdapterDescriptor<'sql', TTargetId, SqlRuntimeAdapterInstance<TTargetId>>;
|
|
59
|
+
readonly driver: RuntimeDriverDescriptor<'sql', TTargetId, SqlRuntimeDriverInstance<TTargetId>>;
|
|
50
60
|
readonly extensions: readonly RuntimeExtensionDescriptor<'sql', TTargetId>[];
|
|
51
61
|
}): SqlRuntimeFamilyInstance;
|
|
52
62
|
}
|
package/dist/exports/runtime.js
CHANGED
|
@@ -23,14 +23,13 @@ function createSqlRuntimeFamilyInstance(options) {
|
|
|
23
23
|
return extension;
|
|
24
24
|
});
|
|
25
25
|
const extensions = [...descriptorExtensions, ...runtimeOptions.extensions ?? []];
|
|
26
|
-
const adapter = adapterInstance;
|
|
27
26
|
const context = createRuntimeContext({
|
|
28
27
|
contract: runtimeOptions.contract,
|
|
29
|
-
adapter,
|
|
28
|
+
adapter: adapterInstance,
|
|
30
29
|
extensions
|
|
31
30
|
});
|
|
32
31
|
const runtimeOptions_ = {
|
|
33
|
-
adapter,
|
|
32
|
+
adapter: adapterInstance,
|
|
34
33
|
driver: driverInstance,
|
|
35
34
|
verify: runtimeOptions.verify,
|
|
36
35
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/runtime-instance.ts","../../src/core/runtime-descriptor.ts","../../src/exports/runtime.ts"],"sourcesContent":["import type {\n RuntimeAdapterDescriptor,\n RuntimeDriverDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeFamilyInstance,\n RuntimeTargetDescriptor,\n} from '@prisma-next/core-execution-plane/types';\nimport type { Log, Plugin, RuntimeVerifyOptions } from '@prisma-next/runtime-executor';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type {\n Adapter,\n LoweredStatement,\n SelectAst,\n SqlDriver,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { Runtime, RuntimeContext, RuntimeOptions } from '@prisma-next/sql-runtime';\nimport { createRuntime, createRuntimeContext, type Extension } from '@prisma-next/sql-runtime';\n\n/**\n * SQL runtime family instance interface.\n * Extends base RuntimeFamilyInstance with SQL-specific runtime creation method.\n */\nexport interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {\n /**\n * Creates a SQL runtime from contract, adapter, driver, and extensions.\n *\n * @param options - Runtime creation options\n * @param options.contract - SQL contract\n * @param options.driverOptions - Driver options (e.g., PostgresDriverOptions)\n * @param options.verify - Runtime verification options\n * @param options.extensions - Optional extensions (Extension objects, not descriptors)\n * @param options.plugins - Optional plugins\n * @param options.mode - Optional runtime mode\n * @param options.log - Optional log instance\n * @returns Runtime instance\n */\n createRuntime<TContract extends SqlContract<SqlStorage>>(options: {\n readonly contract: TContract;\n readonly driverOptions: unknown;\n readonly verify: RuntimeVerifyOptions;\n readonly extensions?: readonly Extension[];\n readonly plugins?: readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[];\n readonly mode?: 'strict' | 'permissive';\n readonly log?: Log;\n }): Runtime;\n}\n\n/**\n * Creates a SQL runtime family instance from runtime descriptors.\n */\nexport function createSqlRuntimeFamilyInstance(options: {\n readonly target: RuntimeTargetDescriptor<'sql', string>;\n readonly adapter: RuntimeAdapterDescriptor<'sql', string>;\n readonly driver: RuntimeDriverDescriptor<'sql', string>;\n readonly extensions: readonly RuntimeExtensionDescriptor<'sql', string>[];\n}): SqlRuntimeFamilyInstance {\n const {\n adapter: adapterDescriptor,\n driver: driverDescriptor,\n extensions: extensionDescriptors,\n } = options;\n\n return {\n familyId: 'sql' as const,\n createRuntime<TContract extends SqlContract<SqlStorage>>(runtimeOptions: {\n readonly contract: TContract;\n readonly driverOptions: unknown;\n readonly verify: RuntimeVerifyOptions;\n readonly extensions?: readonly Extension[];\n readonly plugins?: readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[];\n readonly mode?: 'strict' | 'permissive';\n readonly log?: Log;\n }): Runtime {\n const adapterInstance = adapterDescriptor.create();\n const driverInstance = driverDescriptor.create(runtimeOptions.driverOptions);\n\n const extensionInstances = extensionDescriptors.map((ext) => ext.create());\n\n const descriptorExtensions: Extension[] = extensionInstances.map((ext) => {\n const extension: Extension = {};\n if ('codecs' in ext && typeof ext.codecs === 'function') {\n extension.codecs =\n ext.codecs as () => import('@prisma-next/sql-relational-core/ast').CodecRegistry;\n }\n if ('operations' in ext && typeof ext.operations === 'function') {\n extension.operations =\n ext.operations as () => readonly import('@prisma-next/sql-operations').SqlOperationSignature[];\n }\n return extension;\n });\n\n const extensions = [...descriptorExtensions, ...(runtimeOptions.extensions ?? [])];\n\n const
|
|
1
|
+
{"version":3,"sources":["../../src/core/runtime-instance.ts","../../src/core/runtime-descriptor.ts","../../src/exports/runtime.ts"],"sourcesContent":["import type {\n RuntimeAdapterDescriptor,\n RuntimeAdapterInstance,\n RuntimeDriverDescriptor,\n RuntimeDriverInstance,\n RuntimeExtensionDescriptor,\n RuntimeFamilyInstance,\n RuntimeTargetDescriptor,\n} from '@prisma-next/core-execution-plane/types';\nimport type { Log, Plugin, RuntimeVerifyOptions } from '@prisma-next/runtime-executor';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type {\n Adapter,\n LoweredStatement,\n SelectAst,\n SqlDriver,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { Runtime, RuntimeContext, RuntimeOptions } from '@prisma-next/sql-runtime';\nimport { createRuntime, createRuntimeContext, type Extension } from '@prisma-next/sql-runtime';\n\n/**\n * SQL runtime driver instance type.\n * Combines identity properties with SQL-specific behavior methods.\n */\nexport type SqlRuntimeDriverInstance<TTargetId extends string = string> = RuntimeDriverInstance<\n 'sql',\n TTargetId\n> &\n SqlDriver;\n\n/**\n * SQL runtime adapter instance type.\n * Combines identity properties with SQL-specific adapter behavior.\n */\nexport type SqlRuntimeAdapterInstance<TTargetId extends string = string> = RuntimeAdapterInstance<\n 'sql',\n TTargetId\n> &\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>;\n\n/**\n * SQL runtime family instance interface.\n * Extends base RuntimeFamilyInstance with SQL-specific runtime creation method.\n */\nexport interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {\n /**\n * Creates a SQL runtime from contract, adapter, driver, and extensions.\n *\n * @param options - Runtime creation options\n * @param options.contract - SQL contract\n * @param options.driverOptions - Driver options (e.g., PostgresDriverOptions)\n * @param options.verify - Runtime verification options\n * @param options.extensions - Optional extensions (Extension objects, not descriptors)\n * @param options.plugins - Optional plugins\n * @param options.mode - Optional runtime mode\n * @param options.log - Optional log instance\n * @returns Runtime instance\n */\n createRuntime<TContract extends SqlContract<SqlStorage>>(options: {\n readonly contract: TContract;\n readonly driverOptions: unknown;\n readonly verify: RuntimeVerifyOptions;\n readonly extensions?: readonly Extension[];\n readonly plugins?: readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[];\n readonly mode?: 'strict' | 'permissive';\n readonly log?: Log;\n }): Runtime;\n}\n\n/**\n * Creates a SQL runtime family instance from runtime descriptors.\n */\nexport function createSqlRuntimeFamilyInstance(options: {\n readonly target: RuntimeTargetDescriptor<'sql', string>;\n readonly adapter: RuntimeAdapterDescriptor<'sql', string, SqlRuntimeAdapterInstance>;\n readonly driver: RuntimeDriverDescriptor<'sql', string, SqlRuntimeDriverInstance>;\n readonly extensions: readonly RuntimeExtensionDescriptor<'sql', string>[];\n}): SqlRuntimeFamilyInstance {\n const {\n adapter: adapterDescriptor,\n driver: driverDescriptor,\n extensions: extensionDescriptors,\n } = options;\n\n return {\n familyId: 'sql' as const,\n createRuntime<TContract extends SqlContract<SqlStorage>>(runtimeOptions: {\n readonly contract: TContract;\n readonly driverOptions: unknown;\n readonly verify: RuntimeVerifyOptions;\n readonly extensions?: readonly Extension[];\n readonly plugins?: readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[];\n readonly mode?: 'strict' | 'permissive';\n readonly log?: Log;\n }): Runtime {\n const adapterInstance = adapterDescriptor.create();\n const driverInstance = driverDescriptor.create(runtimeOptions.driverOptions);\n\n const extensionInstances = extensionDescriptors.map((ext) => ext.create());\n\n const descriptorExtensions: Extension[] = extensionInstances.map((ext) => {\n const extension: Extension = {};\n if ('codecs' in ext && typeof ext.codecs === 'function') {\n extension.codecs =\n ext.codecs as () => import('@prisma-next/sql-relational-core/ast').CodecRegistry;\n }\n if ('operations' in ext && typeof ext.operations === 'function') {\n extension.operations =\n ext.operations as () => readonly import('@prisma-next/sql-operations').SqlOperationSignature[];\n }\n return extension;\n });\n\n const extensions = [...descriptorExtensions, ...(runtimeOptions.extensions ?? [])];\n\n const context = createRuntimeContext({\n contract: runtimeOptions.contract,\n adapter: adapterInstance,\n extensions,\n }) as RuntimeContext<TContract>;\n\n const runtimeOptions_: RuntimeOptions<TContract> = {\n adapter: adapterInstance,\n driver: driverInstance,\n verify: runtimeOptions.verify,\n context,\n ...(runtimeOptions.plugins ? { plugins: runtimeOptions.plugins } : {}),\n ...(runtimeOptions.mode ? { mode: runtimeOptions.mode } : {}),\n ...(runtimeOptions.log ? { log: runtimeOptions.log } : {}),\n };\n\n return createRuntime(runtimeOptions_);\n },\n };\n}\n","import type { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';\nimport type {\n RuntimeAdapterDescriptor,\n RuntimeDriverDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeFamilyDescriptor,\n RuntimeTargetDescriptor,\n} from '@prisma-next/core-execution-plane/types';\nimport {\n createSqlRuntimeFamilyInstance,\n type SqlRuntimeAdapterInstance,\n type SqlRuntimeDriverInstance,\n type SqlRuntimeFamilyInstance,\n} from './runtime-instance';\n\n/**\n * SQL family manifest for runtime plane.\n */\nconst sqlFamilyManifest: ExtensionPackManifest = {\n id: 'sql',\n version: '0.0.1',\n};\n\n/**\n * SQL runtime family descriptor implementation.\n * Provides factory method to create SQL runtime family instance.\n */\nexport class SqlRuntimeFamilyDescriptor\n implements RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance>\n{\n readonly kind = 'family' as const;\n readonly id = 'sql';\n readonly familyId = 'sql' as const;\n readonly manifest = sqlFamilyManifest;\n\n create<TTargetId extends string>(options: {\n readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<\n 'sql',\n TTargetId,\n SqlRuntimeAdapterInstance<TTargetId>\n >;\n readonly driver: RuntimeDriverDescriptor<'sql', TTargetId, SqlRuntimeDriverInstance<TTargetId>>;\n readonly extensions: readonly RuntimeExtensionDescriptor<'sql', TTargetId>[];\n }): SqlRuntimeFamilyInstance {\n return createSqlRuntimeFamilyInstance({\n target: options.target,\n adapter: options.adapter,\n driver: options.driver,\n extensions: options.extensions,\n });\n }\n}\n","import { SqlRuntimeFamilyDescriptor } from '../core/runtime-descriptor';\n\n/**\n * SQL runtime family descriptor for execution/runtime plane.\n * Provides factory method to create SQL runtime family instance.\n */\nexport default new SqlRuntimeFamilyDescriptor();\n"],"mappings":";AAkBA,SAAS,eAAe,4BAA4C;AA0D7D,SAAS,+BAA+B,SAKlB;AAC3B,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,YAAY;AAAA,EACd,IAAI;AAEJ,SAAO;AAAA,IACL,UAAU;AAAA,IACV,cAAyD,gBAY7C;AACV,YAAM,kBAAkB,kBAAkB,OAAO;AACjD,YAAM,iBAAiB,iBAAiB,OAAO,eAAe,aAAa;AAE3E,YAAM,qBAAqB,qBAAqB,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;AAEzE,YAAM,uBAAoC,mBAAmB,IAAI,CAAC,QAAQ;AACxE,cAAM,YAAuB,CAAC;AAC9B,YAAI,YAAY,OAAO,OAAO,IAAI,WAAW,YAAY;AACvD,oBAAU,SACR,IAAI;AAAA,QACR;AACA,YAAI,gBAAgB,OAAO,OAAO,IAAI,eAAe,YAAY;AAC/D,oBAAU,aACR,IAAI;AAAA,QACR;AACA,eAAO;AAAA,MACT,CAAC;AAED,YAAM,aAAa,CAAC,GAAG,sBAAsB,GAAI,eAAe,cAAc,CAAC,CAAE;AAEjF,YAAM,UAAU,qBAAqB;AAAA,QACnC,UAAU,eAAe;AAAA,QACzB,SAAS;AAAA,QACT;AAAA,MACF,CAAC;AAED,YAAM,kBAA6C;AAAA,QACjD,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,eAAe;AAAA,QACvB;AAAA,QACA,GAAI,eAAe,UAAU,EAAE,SAAS,eAAe,QAAQ,IAAI,CAAC;AAAA,QACpE,GAAI,eAAe,OAAO,EAAE,MAAM,eAAe,KAAK,IAAI,CAAC;AAAA,QAC3D,GAAI,eAAe,MAAM,EAAE,KAAK,eAAe,IAAI,IAAI,CAAC;AAAA,MAC1D;AAEA,aAAO,cAAc,eAAe;AAAA,IACtC;AAAA,EACF;AACF;;;AC5HA,IAAM,oBAA2C;AAAA,EAC/C,IAAI;AAAA,EACJ,SAAS;AACX;AAMO,IAAM,6BAAN,MAEP;AAAA,EACW,OAAO;AAAA,EACP,KAAK;AAAA,EACL,WAAW;AAAA,EACX,WAAW;AAAA,EAEpB,OAAiC,SASJ;AAC3B,WAAO,+BAA+B;AAAA,MACpC,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,YAAY,QAAQ;AAAA,IACtB,CAAC;AAAA,EACH;AACF;;;AC9CA,IAAO,kBAAQ,IAAI,2BAA2B;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SchemaIssue, SchemaVerificationNode, OperationContext, VerifyDatabaseSchemaResult } from '@prisma-next/core-control-plane/types';
|
|
2
|
+
import { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
3
|
+
import { k as ComponentDatabaseDependency } from './instance-BDpyIYu5.js';
|
|
4
|
+
import { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
|
|
5
|
+
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
6
|
+
import '@prisma-next/utils/result';
|
|
7
|
+
import '@prisma-next/contract/ir';
|
|
8
|
+
import '@prisma-next/contract/types';
|
|
9
|
+
import '@prisma-next/core-control-plane/schema-view';
|
|
10
|
+
import '@prisma-next/operations';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Pure verification helper functions for SQL schema verification.
|
|
14
|
+
* These functions verify schema IR against contract requirements.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Compares two arrays of strings for equality (order-sensitive).
|
|
19
|
+
*/
|
|
20
|
+
declare function arraysEqual(a: readonly string[], b: readonly string[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Verifies database dependencies are installed using component-owned verification hooks.
|
|
23
|
+
* Each dependency provides a pure verifyDatabaseDependencyInstalled function that checks
|
|
24
|
+
* whether the dependency is satisfied based on the in-memory schema IR (no DB I/O).
|
|
25
|
+
*
|
|
26
|
+
* Returns verification nodes for the tree.
|
|
27
|
+
*/
|
|
28
|
+
declare function verifyDatabaseDependencies(dependencies: ReadonlyArray<ComponentDatabaseDependency<unknown>>, schema: SqlSchemaIR, issues: SchemaIssue[]): SchemaVerificationNode[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Pure SQL schema verification function.
|
|
32
|
+
*
|
|
33
|
+
* This module provides a pure function that verifies a SqlSchemaIR against
|
|
34
|
+
* a SqlContract without requiring a database connection. It can be reused
|
|
35
|
+
* by migration planners and other tools that need to compare schema states.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Options for the pure schema verification function.
|
|
40
|
+
*/
|
|
41
|
+
interface VerifySqlSchemaOptions {
|
|
42
|
+
/** The validated SQL contract to verify against */
|
|
43
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
44
|
+
/** The schema IR from introspection (or another source) */
|
|
45
|
+
readonly schema: SqlSchemaIR;
|
|
46
|
+
/** Whether to run in strict mode (detects extra tables/columns) */
|
|
47
|
+
readonly strict: boolean;
|
|
48
|
+
/** Optional operation context for metadata */
|
|
49
|
+
readonly context?: OperationContext;
|
|
50
|
+
/** Type metadata registry for codec consistency warnings */
|
|
51
|
+
readonly typeMetadataRegistry: ReadonlyMap<string, {
|
|
52
|
+
nativeType?: string;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Active framework components participating in this composition.
|
|
56
|
+
* All components must have matching familyId ('sql') and targetId.
|
|
57
|
+
*/
|
|
58
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Verifies that a SqlSchemaIR matches a SqlContract.
|
|
62
|
+
*
|
|
63
|
+
* This is a pure function that does NOT perform any database I/O.
|
|
64
|
+
* It takes an already-introspected schema IR and compares it against
|
|
65
|
+
* the contract requirements.
|
|
66
|
+
*
|
|
67
|
+
* @param options - Verification options
|
|
68
|
+
* @returns VerifyDatabaseSchemaResult with verification tree and issues
|
|
69
|
+
*/
|
|
70
|
+
declare function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult;
|
|
71
|
+
|
|
72
|
+
export { type VerifySqlSchemaOptions, arraysEqual, verifyDatabaseDependencies, verifySqlSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';
|
|
2
|
+
import { TypesImportSpec } from '@prisma-next/contract/types';
|
|
3
|
+
import { OperationRegistry } from '@prisma-next/operations';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extracts codec type imports from extension packs for contract.d.ts generation.
|
|
7
|
+
* Pack-based version for use in tests.
|
|
8
|
+
*/
|
|
9
|
+
declare function extractCodecTypeImportsFromPacks(packs: ReadonlyArray<{
|
|
10
|
+
readonly manifest: ExtensionPackManifest;
|
|
11
|
+
}>): ReadonlyArray<TypesImportSpec>;
|
|
12
|
+
/**
|
|
13
|
+
* Extracts operation type imports from extension packs for contract.d.ts generation.
|
|
14
|
+
* Pack-based version for use in tests.
|
|
15
|
+
*/
|
|
16
|
+
declare function extractOperationTypeImportsFromPacks(packs: ReadonlyArray<{
|
|
17
|
+
readonly manifest: ExtensionPackManifest;
|
|
18
|
+
}>): ReadonlyArray<TypesImportSpec>;
|
|
19
|
+
/**
|
|
20
|
+
* Assembles an operation registry from extension packs.
|
|
21
|
+
* Pack-based version for use in tests.
|
|
22
|
+
*/
|
|
23
|
+
declare function assembleOperationRegistryFromPacks(packs: ReadonlyArray<{
|
|
24
|
+
readonly manifest: ExtensionPackManifest;
|
|
25
|
+
}>): OperationRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* Extracts extension IDs from packs.
|
|
28
|
+
* Pack-based version for use in tests.
|
|
29
|
+
*/
|
|
30
|
+
declare function extractExtensionIdsFromPacks(packs: ReadonlyArray<{
|
|
31
|
+
readonly manifest: ExtensionPackManifest;
|
|
32
|
+
}>): ReadonlyArray<string>;
|
|
33
|
+
|
|
34
|
+
export { assembleOperationRegistryFromPacks, extractCodecTypeImportsFromPacks, extractExtensionIdsFromPacks, extractOperationTypeImportsFromPacks };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assembleOperationRegistryFromPacks,
|
|
3
|
+
extractCodecTypeImportsFromPacks,
|
|
4
|
+
extractExtensionIdsFromPacks,
|
|
5
|
+
extractOperationTypeImportsFromPacks
|
|
6
|
+
} from "./chunk-LECWNGKN.js";
|
|
7
|
+
import "./chunk-C3GKWCKA.js";
|
|
8
|
+
import "./chunk-54XYY6SU.js";
|
|
9
|
+
export {
|
|
10
|
+
assembleOperationRegistryFromPacks,
|
|
11
|
+
extractCodecTypeImportsFromPacks,
|
|
12
|
+
extractExtensionIdsFromPacks,
|
|
13
|
+
extractOperationTypeImportsFromPacks
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/exports/verify.d.ts
CHANGED
|
@@ -23,6 +23,6 @@ declare function readMarkerSql(): {
|
|
|
23
23
|
* @param driver - ControlDriverInstance instance for executing queries
|
|
24
24
|
* @returns Promise resolving to ContractMarkerRecord or null if marker not found
|
|
25
25
|
*/
|
|
26
|
-
declare function readMarker(driver: ControlDriverInstance): Promise<ContractMarkerRecord | null>;
|
|
26
|
+
declare function readMarker(driver: ControlDriverInstance<'sql', string>): Promise<ContractMarkerRecord | null>;
|
|
27
27
|
|
|
28
28
|
export { parseContractMarkerRow, readMarker, readMarkerSql };
|