@prisma-next/core-control-plane 0.1.0-pr.57.2 → 0.1.0-pr.57.3
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 +25 -0
- package/dist/exports/types.d.ts +27 -11
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ This package provides the core domain logic for control plane operations (contra
|
|
|
17
17
|
Note: Contract emission is implemented on family instances (e.g., `familyInstance.emitContract()`), not as a core domain action.
|
|
18
18
|
- **Error Factories**: Domain error factories (`CliStructuredError`, config errors, runtime errors)
|
|
19
19
|
- **Pack Manifest Types**: Type definitions for extension pack manifests
|
|
20
|
+
- **Migration SPI**: Generic migration planner/runner interfaces (`MigrationPlanner<TFamilyId, TTargetId>`, `MigrationRunner<TFamilyId, TTargetId>`, `TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>`) that thread family/target IDs for compile-time component compatibility enforcement
|
|
20
21
|
|
|
21
22
|
## Dependencies
|
|
22
23
|
|
|
@@ -102,6 +103,30 @@ throw errorConfigFileNotFound('prisma-next.config.ts', {
|
|
|
102
103
|
});
|
|
103
104
|
```
|
|
104
105
|
|
|
106
|
+
## Migration SPI Design
|
|
107
|
+
|
|
108
|
+
The migration planner/runner interfaces are generic over `TFamilyId` and `TTargetId` to enable compile-time enforcement of component compatibility:
|
|
109
|
+
|
|
110
|
+
- **`MigrationPlanner<TFamilyId, TTargetId>`**: Generic planner interface that accepts `TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]`
|
|
111
|
+
- **`MigrationRunner<TFamilyId, TTargetId>`**: Generic runner interface that accepts `TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]`
|
|
112
|
+
- **`TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>`**: Generic capability interface for targets that support migrations
|
|
113
|
+
|
|
114
|
+
The CLI performs runtime validation at the composition boundary using `assertFrameworkComponentsCompatible()` before calling typed planner/runner instances. This validates that all components have matching `familyId` and `targetId`, then returns a typed `TargetBoundComponentDescriptor` array that satisfies the planner/runner interface requirements.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// CLI composition boundary - runtime assertion + type narrowing
|
|
118
|
+
const rawComponents = [config.target, config.adapter, ...(config.extensions ?? [])];
|
|
119
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
120
|
+
config.family.familyId,
|
|
121
|
+
config.target.targetId,
|
|
122
|
+
rawComponents,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Now frameworkComponents is typed as TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]
|
|
126
|
+
const planner = target.migrations.createPlanner(familyInstance);
|
|
127
|
+
planner.plan({ contract, schema, policy, frameworkComponents });
|
|
128
|
+
```
|
|
129
|
+
|
|
105
130
|
## Package Location
|
|
106
131
|
|
|
107
132
|
This package is part of the **framework domain**, **core layer**, **migration plane**:
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TargetBoundComponentDescriptor, FamilyInstance, DriverInstance, FamilyDescriptor, TargetInstance, TargetDescriptor, AdapterInstance, AdapterDescriptor, DriverDescriptor, ExtensionInstance, ExtensionDescriptor } from '@prisma-next/contract/framework-components';
|
|
2
2
|
import { ContractIR } from '@prisma-next/contract/ir';
|
|
3
3
|
import { TargetFamilyHook } from '@prisma-next/contract/types';
|
|
4
4
|
import { Result } from '@prisma-next/utils/result';
|
|
@@ -109,8 +109,11 @@ type MigrationRunnerResult = Result<MigrationRunnerSuccessValue, MigrationRunner
|
|
|
109
109
|
/**
|
|
110
110
|
* Migration planner interface for planning schema changes.
|
|
111
111
|
* This is the minimal interface that CLI commands use.
|
|
112
|
+
*
|
|
113
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
114
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
112
115
|
*/
|
|
113
|
-
interface MigrationPlanner {
|
|
116
|
+
interface MigrationPlanner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
114
117
|
plan(options: {
|
|
115
118
|
readonly contract: unknown;
|
|
116
119
|
readonly schema: unknown;
|
|
@@ -118,18 +121,22 @@ interface MigrationPlanner {
|
|
|
118
121
|
/**
|
|
119
122
|
* Active framework components participating in this composition.
|
|
120
123
|
* Families/targets can interpret this bag to derive family-specific metadata.
|
|
124
|
+
* All components must have matching familyId and targetId.
|
|
121
125
|
*/
|
|
122
|
-
readonly frameworkComponents: ReadonlyArray<
|
|
126
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
123
127
|
}): MigrationPlannerResult;
|
|
124
128
|
}
|
|
125
129
|
/**
|
|
126
130
|
* Migration runner interface for executing migration plans.
|
|
127
131
|
* This is the minimal interface that CLI commands use.
|
|
132
|
+
*
|
|
133
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
134
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
128
135
|
*/
|
|
129
|
-
interface MigrationRunner {
|
|
136
|
+
interface MigrationRunner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
130
137
|
execute(options: {
|
|
131
138
|
readonly plan: MigrationPlan;
|
|
132
|
-
readonly driver: ControlDriverInstance<
|
|
139
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
133
140
|
readonly destinationContract: unknown;
|
|
134
141
|
readonly policy: MigrationOperationPolicy;
|
|
135
142
|
readonly callbacks?: {
|
|
@@ -139,19 +146,22 @@ interface MigrationRunner {
|
|
|
139
146
|
/**
|
|
140
147
|
* Active framework components participating in this composition.
|
|
141
148
|
* Families/targets can interpret this bag to derive family-specific metadata.
|
|
149
|
+
* All components must have matching familyId and targetId.
|
|
142
150
|
*/
|
|
143
|
-
readonly frameworkComponents: ReadonlyArray<
|
|
151
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
144
152
|
}): Promise<MigrationRunnerResult>;
|
|
145
153
|
}
|
|
146
154
|
/**
|
|
147
155
|
* Optional capability interface for targets that support migrations.
|
|
148
156
|
* Targets that implement migrations expose this via their descriptor.
|
|
149
157
|
*
|
|
158
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
159
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
150
160
|
* @template TFamilyInstance - The family instance type (e.g., SqlControlFamilyInstance)
|
|
151
161
|
*/
|
|
152
|
-
interface TargetMigrationsCapability<TFamilyInstance extends ControlFamilyInstance<
|
|
153
|
-
createPlanner(family: TFamilyInstance): MigrationPlanner
|
|
154
|
-
createRunner(family: TFamilyInstance): MigrationRunner
|
|
162
|
+
interface TargetMigrationsCapability<TFamilyId extends string = string, TTargetId extends string = string, TFamilyInstance extends ControlFamilyInstance<TFamilyId> = ControlFamilyInstance<TFamilyId>> {
|
|
163
|
+
createPlanner(family: TFamilyInstance): MigrationPlanner<TFamilyId, TTargetId>;
|
|
164
|
+
createRunner(family: TFamilyInstance): MigrationRunner<TFamilyId, TTargetId>;
|
|
155
165
|
}
|
|
156
166
|
|
|
157
167
|
/**
|
|
@@ -196,7 +206,11 @@ interface ControlFamilyInstance<TFamilyId extends string, TSchemaIR = unknown> e
|
|
|
196
206
|
readonly strict: boolean;
|
|
197
207
|
readonly contractPath: string;
|
|
198
208
|
readonly configPath?: string;
|
|
199
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Active framework components participating in this composition.
|
|
211
|
+
* All components must have matching familyId and targetId.
|
|
212
|
+
*/
|
|
213
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, string>>;
|
|
200
214
|
}): Promise<VerifyDatabaseSchemaResult>;
|
|
201
215
|
/**
|
|
202
216
|
* Signs the database with the contract marker.
|
|
@@ -348,8 +362,10 @@ interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends st
|
|
|
348
362
|
/**
|
|
349
363
|
* Optional migrations capability.
|
|
350
364
|
* Targets that support migrations expose this property.
|
|
365
|
+
* The capability is parameterized by family and target IDs to ensure type-level
|
|
366
|
+
* compatibility of framework components.
|
|
351
367
|
*/
|
|
352
|
-
readonly migrations?: TargetMigrationsCapability<TFamilyInstance>;
|
|
368
|
+
readonly migrations?: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;
|
|
353
369
|
create(): TTargetInstance;
|
|
354
370
|
}
|
|
355
371
|
/**
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/core-control-plane",
|
|
3
|
-
"version": "0.1.0-pr.57.
|
|
3
|
+
"version": "0.1.0-pr.57.3",
|
|
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.57.
|
|
11
|
-
"@prisma-next/operations": "0.1.0-pr.57.
|
|
12
|
-
"@prisma-next/utils": "0.1.0-pr.57.
|
|
10
|
+
"@prisma-next/contract": "0.1.0-pr.57.3",
|
|
11
|
+
"@prisma-next/operations": "0.1.0-pr.57.3",
|
|
12
|
+
"@prisma-next/utils": "0.1.0-pr.57.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"tsup": "^8.3.0",
|