@prisma-next/core-control-plane 0.1.0-pr.55.2 → 0.1.0-pr.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescriptor, ControlExtensionDescriptor, ControlDriverDescriptor } from './types.js';
|
|
2
|
+
import '@prisma-next/contract/framework-components';
|
|
2
3
|
import '@prisma-next/contract/ir';
|
|
3
|
-
import '@prisma-next/contract/pack-manifest-types';
|
|
4
4
|
import '@prisma-next/contract/types';
|
|
5
5
|
import '@prisma-next/utils/result';
|
|
6
6
|
import './schema-view.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrismaNextConfig } from './config-types.js';
|
|
2
2
|
import './types.js';
|
|
3
|
+
import '@prisma-next/contract/framework-components';
|
|
3
4
|
import '@prisma-next/contract/ir';
|
|
4
|
-
import '@prisma-next/contract/pack-manifest-types';
|
|
5
5
|
import '@prisma-next/contract/types';
|
|
6
6
|
import '@prisma-next/utils/result';
|
|
7
7
|
import './schema-view.js';
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor } from '@prisma-next/contract/framework-components';
|
|
1
2
|
import { ContractIR } from '@prisma-next/contract/ir';
|
|
2
|
-
import {
|
|
3
|
-
import { TargetFamilyHook } from '@prisma-next/contract/types';
|
|
3
|
+
import { FamilyInstance, TargetFamilyHook } from '@prisma-next/contract/types';
|
|
4
4
|
import { Result } from '@prisma-next/utils/result';
|
|
5
5
|
import { CoreSchemaView } from './schema-view.js';
|
|
6
6
|
|
|
@@ -145,13 +145,88 @@ interface TargetMigrationsCapability<TFamilyInstance extends ControlFamilyInstan
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
148
|
+
* Control-plane family instance interface.
|
|
149
|
+
* Extends the base FamilyInstance with control-plane domain actions.
|
|
150
150
|
*
|
|
151
151
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
152
|
+
* @template TSchemaIR - The schema IR type returned by introspect()
|
|
153
|
+
* @template TVerifyResult - The result type for verify()
|
|
154
|
+
* @template TSchemaVerifyResult - The result type for schemaVerify()
|
|
155
|
+
* @template TSignResult - The result type for sign()
|
|
152
156
|
*/
|
|
153
|
-
interface ControlFamilyInstance<TFamilyId extends string = string> {
|
|
154
|
-
|
|
157
|
+
interface ControlFamilyInstance<TFamilyId extends string = string, TSchemaIR = unknown, TVerifyResult = unknown, TSchemaVerifyResult = unknown, TSignResult = unknown> extends FamilyInstance<TFamilyId> {
|
|
158
|
+
/**
|
|
159
|
+
* Validates a contract JSON and returns a validated ContractIR (without mappings).
|
|
160
|
+
* Mappings are runtime-only and should not be part of ContractIR.
|
|
161
|
+
*/
|
|
162
|
+
validateContractIR(contractJson: unknown): unknown;
|
|
163
|
+
/**
|
|
164
|
+
* Verifies the database marker against the contract.
|
|
165
|
+
* Compares target, coreHash, and profileHash.
|
|
166
|
+
*/
|
|
167
|
+
verify(options: {
|
|
168
|
+
readonly driver: ControlDriverInstance;
|
|
169
|
+
readonly contractIR: unknown;
|
|
170
|
+
readonly expectedTargetId: string;
|
|
171
|
+
readonly contractPath: string;
|
|
172
|
+
readonly configPath?: string;
|
|
173
|
+
}): Promise<TVerifyResult>;
|
|
174
|
+
/**
|
|
175
|
+
* Verifies the database schema against the contract.
|
|
176
|
+
* Compares contract requirements against live database schema.
|
|
177
|
+
*/
|
|
178
|
+
schemaVerify(options: {
|
|
179
|
+
readonly driver: ControlDriverInstance;
|
|
180
|
+
readonly contractIR: unknown;
|
|
181
|
+
readonly strict: boolean;
|
|
182
|
+
readonly contractPath: string;
|
|
183
|
+
readonly configPath?: string;
|
|
184
|
+
}): Promise<TSchemaVerifyResult>;
|
|
185
|
+
/**
|
|
186
|
+
* Signs the database with the contract marker.
|
|
187
|
+
* Writes or updates the contract marker if schema verification passes.
|
|
188
|
+
* This operation is idempotent - if the marker already matches, no changes are made.
|
|
189
|
+
*/
|
|
190
|
+
sign(options: {
|
|
191
|
+
readonly driver: ControlDriverInstance;
|
|
192
|
+
readonly contractIR: unknown;
|
|
193
|
+
readonly contractPath: string;
|
|
194
|
+
readonly configPath?: string;
|
|
195
|
+
}): Promise<TSignResult>;
|
|
196
|
+
/**
|
|
197
|
+
* Introspects the database schema and returns a family-specific schema IR.
|
|
198
|
+
*
|
|
199
|
+
* This is a read-only operation that returns a snapshot of the live database schema.
|
|
200
|
+
* The method is family-owned and delegates to target/adapter-specific introspectors
|
|
201
|
+
* to perform the actual schema introspection.
|
|
202
|
+
*
|
|
203
|
+
* @param options - Introspection options
|
|
204
|
+
* @param options.driver - Control plane driver for database connection
|
|
205
|
+
* @param options.contractIR - Optional contract IR for contract-guided introspection.
|
|
206
|
+
* When provided, families may use it for filtering, optimization, or validation
|
|
207
|
+
* during introspection. The contract IR does not change the meaning of "what exists"
|
|
208
|
+
* in the database - it only guides how introspection is performed.
|
|
209
|
+
* @returns Promise resolving to the family-specific Schema IR (e.g., `SqlSchemaIR` for SQL).
|
|
210
|
+
* The IR represents the complete schema snapshot at the time of introspection.
|
|
211
|
+
*/
|
|
212
|
+
introspect(options: {
|
|
213
|
+
readonly driver: ControlDriverInstance;
|
|
214
|
+
readonly contractIR?: unknown;
|
|
215
|
+
}): Promise<TSchemaIR>;
|
|
216
|
+
/**
|
|
217
|
+
* Optionally projects a family-specific Schema IR into a core schema view.
|
|
218
|
+
* Families that provide this method enable rich tree output for CLI visualization.
|
|
219
|
+
* Families that do not provide it still support introspection via raw Schema IR.
|
|
220
|
+
*/
|
|
221
|
+
toSchemaView?(schema: TSchemaIR): CoreSchemaView;
|
|
222
|
+
/**
|
|
223
|
+
* Emits contract JSON and DTS as strings.
|
|
224
|
+
* Uses the instance's preassembled state (operation registry, type imports, extension IDs).
|
|
225
|
+
* Handles stripping mappings and validation internally.
|
|
226
|
+
*/
|
|
227
|
+
emitContract(options: {
|
|
228
|
+
readonly contractIR: ContractIR | unknown;
|
|
229
|
+
}): Promise<EmitContractResult>;
|
|
155
230
|
}
|
|
156
231
|
/**
|
|
157
232
|
* Base interface for control-plane target instances.
|
|
@@ -239,11 +314,7 @@ interface OperationContext {
|
|
|
239
314
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
240
315
|
* @template TFamilyInstance - The family instance type
|
|
241
316
|
*/
|
|
242
|
-
interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> {
|
|
243
|
-
readonly kind: 'family';
|
|
244
|
-
readonly id: string;
|
|
245
|
-
readonly familyId: TFamilyId;
|
|
246
|
-
readonly manifest: ExtensionPackManifest;
|
|
317
|
+
interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> extends FamilyDescriptor<TFamilyId> {
|
|
247
318
|
readonly hook: TargetFamilyHook;
|
|
248
319
|
create<TTargetId extends string>(options: {
|
|
249
320
|
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
@@ -253,19 +324,14 @@ interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance exte
|
|
|
253
324
|
}): TFamilyInstance;
|
|
254
325
|
}
|
|
255
326
|
/**
|
|
256
|
-
* Descriptor for a control-plane target
|
|
327
|
+
* Descriptor for a control-plane target component (e.g., Postgres target).
|
|
257
328
|
*
|
|
258
329
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
259
330
|
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
260
331
|
* @template TTargetInstance - The target instance type
|
|
261
332
|
* @template TFamilyInstance - The family instance type for migrations (optional)
|
|
262
333
|
*/
|
|
263
|
-
interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends string, TTargetInstance extends ControlTargetInstance<TFamilyId, TTargetId> = ControlTargetInstance<TFamilyId, TTargetId>, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> {
|
|
264
|
-
readonly kind: 'target';
|
|
265
|
-
readonly id: string;
|
|
266
|
-
readonly familyId: TFamilyId;
|
|
267
|
-
readonly targetId: TTargetId;
|
|
268
|
-
readonly manifest: ExtensionPackManifest;
|
|
334
|
+
interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends string, TTargetInstance extends ControlTargetInstance<TFamilyId, TTargetId> = ControlTargetInstance<TFamilyId, TTargetId>, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> extends TargetDescriptor<TFamilyId, TTargetId> {
|
|
269
335
|
/**
|
|
270
336
|
* Optional migrations capability.
|
|
271
337
|
* Targets that support migrations expose this property.
|
|
@@ -274,129 +340,35 @@ interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends st
|
|
|
274
340
|
create(): TTargetInstance;
|
|
275
341
|
}
|
|
276
342
|
/**
|
|
277
|
-
* Descriptor for a control-plane adapter
|
|
343
|
+
* Descriptor for a control-plane adapter component (e.g., Postgres adapter).
|
|
278
344
|
*
|
|
279
345
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
280
346
|
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
281
347
|
* @template TAdapterInstance - The adapter instance type
|
|
282
348
|
*/
|
|
283
|
-
interface ControlAdapterDescriptor<TFamilyId extends string, TTargetId extends string, TAdapterInstance extends ControlAdapterInstance<TFamilyId, TTargetId> = ControlAdapterInstance<TFamilyId, TTargetId>> {
|
|
284
|
-
readonly kind: 'adapter';
|
|
285
|
-
readonly id: string;
|
|
286
|
-
readonly familyId: TFamilyId;
|
|
287
|
-
readonly targetId: TTargetId;
|
|
288
|
-
readonly manifest: ExtensionPackManifest;
|
|
349
|
+
interface ControlAdapterDescriptor<TFamilyId extends string, TTargetId extends string, TAdapterInstance extends ControlAdapterInstance<TFamilyId, TTargetId> = ControlAdapterInstance<TFamilyId, TTargetId>> extends AdapterDescriptor<TFamilyId, TTargetId> {
|
|
289
350
|
create(): TAdapterInstance;
|
|
290
351
|
}
|
|
291
352
|
/**
|
|
292
|
-
* Descriptor for a control-plane driver
|
|
353
|
+
* Descriptor for a control-plane driver component (e.g., Postgres driver).
|
|
293
354
|
*
|
|
294
355
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
295
356
|
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
296
357
|
* @template TDriverInstance - The driver instance type
|
|
297
358
|
*/
|
|
298
|
-
interface ControlDriverDescriptor<TFamilyId extends string, TTargetId extends string, TDriverInstance extends ControlDriverInstance<TTargetId> = ControlDriverInstance<TTargetId>> {
|
|
299
|
-
readonly kind: 'driver';
|
|
300
|
-
readonly id: string;
|
|
301
|
-
readonly familyId: TFamilyId;
|
|
302
|
-
readonly targetId: TTargetId;
|
|
303
|
-
readonly manifest: ExtensionPackManifest;
|
|
359
|
+
interface ControlDriverDescriptor<TFamilyId extends string, TTargetId extends string, TDriverInstance extends ControlDriverInstance<TTargetId> = ControlDriverInstance<TTargetId>> extends DriverDescriptor<TFamilyId, TTargetId> {
|
|
304
360
|
create(url: string): Promise<TDriverInstance>;
|
|
305
361
|
}
|
|
306
362
|
/**
|
|
307
|
-
* Descriptor for a control-plane extension
|
|
363
|
+
* Descriptor for a control-plane extension component (e.g., pgvector).
|
|
308
364
|
*
|
|
309
365
|
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
310
366
|
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
311
367
|
* @template TExtensionInstance - The extension instance type
|
|
312
368
|
*/
|
|
313
|
-
interface ControlExtensionDescriptor<TFamilyId extends string, TTargetId extends string, TExtensionInstance extends ControlExtensionInstance<TFamilyId, TTargetId> = ControlExtensionInstance<TFamilyId, TTargetId>> {
|
|
314
|
-
readonly kind: 'extension';
|
|
315
|
-
readonly id: string;
|
|
316
|
-
readonly familyId: TFamilyId;
|
|
317
|
-
readonly targetId: TTargetId;
|
|
318
|
-
readonly manifest: ExtensionPackManifest;
|
|
369
|
+
interface ControlExtensionDescriptor<TFamilyId extends string, TTargetId extends string, TExtensionInstance extends ControlExtensionInstance<TFamilyId, TTargetId> = ControlExtensionInstance<TFamilyId, TTargetId>> extends ExtensionDescriptor<TFamilyId, TTargetId> {
|
|
319
370
|
create(): TExtensionInstance;
|
|
320
371
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Family instance interface for control-plane domain actions.
|
|
323
|
-
* Each family implements this interface with family-specific types.
|
|
324
|
-
*/
|
|
325
|
-
interface FamilyInstance<TFamilyId extends string, TSchemaIR = unknown, TVerifyResult = unknown, TSchemaVerifyResult = unknown, TSignResult = unknown> {
|
|
326
|
-
readonly familyId: TFamilyId;
|
|
327
|
-
/**
|
|
328
|
-
* Validates a contract JSON and returns a validated ContractIR (without mappings).
|
|
329
|
-
* Mappings are runtime-only and should not be part of ContractIR.
|
|
330
|
-
*/
|
|
331
|
-
validateContractIR(contractJson: unknown): unknown;
|
|
332
|
-
/**
|
|
333
|
-
* Verifies the database marker against the contract.
|
|
334
|
-
* Compares target, coreHash, and profileHash.
|
|
335
|
-
*/
|
|
336
|
-
verify(options: {
|
|
337
|
-
readonly driver: ControlDriverInstance;
|
|
338
|
-
readonly contractIR: unknown;
|
|
339
|
-
readonly expectedTargetId: string;
|
|
340
|
-
readonly contractPath: string;
|
|
341
|
-
readonly configPath?: string;
|
|
342
|
-
}): Promise<TVerifyResult>;
|
|
343
|
-
/**
|
|
344
|
-
* Verifies the database schema against the contract.
|
|
345
|
-
* Compares contract requirements against live database schema.
|
|
346
|
-
*/
|
|
347
|
-
schemaVerify(options: {
|
|
348
|
-
readonly driver: ControlDriverInstance;
|
|
349
|
-
readonly contractIR: unknown;
|
|
350
|
-
readonly strict: boolean;
|
|
351
|
-
readonly contractPath: string;
|
|
352
|
-
readonly configPath?: string;
|
|
353
|
-
}): Promise<TSchemaVerifyResult>;
|
|
354
|
-
/**
|
|
355
|
-
* Signs the database with the contract marker.
|
|
356
|
-
* Writes or updates the contract marker if schema verification passes.
|
|
357
|
-
* This operation is idempotent - if the marker already matches, no changes are made.
|
|
358
|
-
*/
|
|
359
|
-
sign(options: {
|
|
360
|
-
readonly driver: ControlDriverInstance;
|
|
361
|
-
readonly contractIR: unknown;
|
|
362
|
-
readonly contractPath: string;
|
|
363
|
-
readonly configPath?: string;
|
|
364
|
-
}): Promise<TSignResult>;
|
|
365
|
-
/**
|
|
366
|
-
* Introspects the database schema and returns a family-specific schema IR.
|
|
367
|
-
*
|
|
368
|
-
* This is a read-only operation that returns a snapshot of the live database schema.
|
|
369
|
-
* The method is family-owned and delegates to target/adapter-specific introspectors
|
|
370
|
-
* to perform the actual schema introspection.
|
|
371
|
-
*
|
|
372
|
-
* @param options - Introspection options
|
|
373
|
-
* @param options.driver - Control plane driver for database connection
|
|
374
|
-
* @param options.contractIR - Optional contract IR for contract-guided introspection.
|
|
375
|
-
* When provided, families may use it for filtering, optimization, or validation
|
|
376
|
-
* during introspection. The contract IR does not change the meaning of "what exists"
|
|
377
|
-
* in the database - it only guides how introspection is performed.
|
|
378
|
-
* @returns Promise resolving to the family-specific Schema IR (e.g., `SqlSchemaIR` for SQL).
|
|
379
|
-
* The IR represents the complete schema snapshot at the time of introspection.
|
|
380
|
-
*/
|
|
381
|
-
introspect(options: {
|
|
382
|
-
readonly driver: ControlDriverInstance;
|
|
383
|
-
readonly contractIR?: unknown;
|
|
384
|
-
}): Promise<TSchemaIR>;
|
|
385
|
-
/**
|
|
386
|
-
* Optionally projects a family-specific Schema IR into a core schema view.
|
|
387
|
-
* Families that provide this method enable rich tree output for CLI visualization.
|
|
388
|
-
* Families that do not provide it still support introspection via raw Schema IR.
|
|
389
|
-
*/
|
|
390
|
-
toSchemaView?(schema: TSchemaIR): CoreSchemaView;
|
|
391
|
-
/**
|
|
392
|
-
* Emits contract JSON and DTS as strings.
|
|
393
|
-
* Uses the instance's preassembled state (operation registry, type imports, extension IDs).
|
|
394
|
-
* Handles stripping mappings and validation internally.
|
|
395
|
-
*/
|
|
396
|
-
emitContract(options: {
|
|
397
|
-
readonly contractIR: ContractIR | unknown;
|
|
398
|
-
}): Promise<EmitContractResult>;
|
|
399
|
-
}
|
|
400
372
|
/**
|
|
401
373
|
* Result type for database marker verification operations.
|
|
402
374
|
*/
|
|
@@ -550,4 +522,4 @@ interface SignDatabaseResult {
|
|
|
550
522
|
};
|
|
551
523
|
}
|
|
552
524
|
|
|
553
|
-
export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult,
|
|
525
|
+
export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult, IntrospectSchemaResult, MigrationOperationClass, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerResult, MigrationPlannerSuccessResult, MigrationRunner, MigrationRunnerFailure, MigrationRunnerResult, MigrationRunnerSuccessValue, OperationContext, SchemaIssue, SchemaVerificationNode, SignDatabaseResult, TargetMigrationsCapability, VerifyDatabaseResult, VerifyDatabaseSchemaResult };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/core-control-plane",
|
|
3
|
-
"version": "0.1.0-pr.
|
|
3
|
+
"version": "0.1.0-pr.56.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Control plane domain actions, config types, validation, and error factories for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.1.26",
|
|
9
9
|
"prettier": "^3.3.3",
|
|
10
|
-
"@prisma-next/contract": "0.1.0-pr.
|
|
11
|
-
"@prisma-next/operations": "0.1.0-pr.
|
|
12
|
-
"@prisma-next/utils": "0.1.0-pr.
|
|
10
|
+
"@prisma-next/contract": "0.1.0-pr.56.1",
|
|
11
|
+
"@prisma-next/operations": "0.1.0-pr.56.1",
|
|
12
|
+
"@prisma-next/utils": "0.1.0-pr.56.1"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"tsup": "^8.3.0",
|