@prisma-next/framework-components 0.5.0-dev.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -4
- package/dist/authoring.d.mts +2 -2
- package/dist/authoring.mjs +2 -122
- package/dist/codec-m_-FAyQn.d.mts +168 -0
- package/dist/codec-m_-FAyQn.d.mts.map +1 -0
- package/dist/codec.d.mts +48 -2
- package/dist/codec.d.mts.map +1 -0
- package/dist/codec.mjs +67 -4
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +2 -3
- package/dist/control.d.mts +420 -76
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +83 -58
- package/dist/control.mjs.map +1 -1
- package/dist/emission-types-CMv_053d.d.mts +38 -0
- package/dist/emission-types-CMv_053d.d.mts.map +1 -0
- package/dist/emission.d.mts +2 -2
- package/dist/emission.mjs +1 -1
- package/dist/execution.d.mts +5 -5
- package/dist/execution.d.mts.map +1 -1
- package/dist/execution.mjs +4 -6
- package/dist/execution.mjs.map +1 -1
- package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-DGIQbNPt.d.mts} +43 -12
- package/dist/framework-authoring-DGIQbNPt.d.mts.map +1 -0
- package/dist/framework-authoring-DxXcjyJX.mjs +209 -0
- package/dist/framework-authoring-DxXcjyJX.mjs.map +1 -0
- package/dist/{framework-components-DFZMi2h7.d.mts → framework-components-CHuBHXQN.d.mts} +45 -58
- package/dist/framework-components-CHuBHXQN.d.mts.map +1 -0
- package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-FdqmlGUj.mjs} +3 -3
- package/dist/framework-components-FdqmlGUj.mjs.map +1 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts +159 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts.map +1 -0
- package/dist/psl-ast.d.mts +2 -0
- package/dist/psl-ast.mjs +1 -0
- package/dist/runtime.d.mts +273 -37
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +172 -30
- package/dist/runtime.mjs.map +1 -1
- package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-BxI5cSQy.d.mts} +2 -2
- package/dist/types-import-spec-BxI5cSQy.d.mts.map +1 -0
- package/package.json +10 -6
- package/src/control/control-capabilities.ts +96 -0
- package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
- package/src/{control-instances.ts → control/control-instances.ts} +52 -6
- package/src/{control-migration-types.ts → control/control-migration-types.ts} +251 -63
- package/src/control/control-operation-preview.ts +23 -0
- package/src/control/control-spaces.ts +82 -0
- package/src/{control-stack.ts → control/control-stack.ts} +77 -111
- package/src/control/emission-types.ts +48 -0
- package/src/control/psl-ast.ts +193 -0
- package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
- package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
- package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
- package/src/execution/race-against-abort.ts +89 -0
- package/src/execution/run-with-middleware.ts +153 -0
- package/src/{runtime-core.ts → execution/runtime-core.ts} +27 -3
- package/src/execution/runtime-error.ts +94 -0
- package/src/execution/runtime-middleware.ts +235 -0
- package/src/exports/authoring.ts +5 -2
- package/src/exports/codec.ts +27 -2
- package/src/exports/components.ts +2 -2
- package/src/exports/control.ts +41 -14
- package/src/exports/emission.ts +2 -2
- package/src/exports/execution.ts +5 -5
- package/src/exports/psl-ast.ts +1 -0
- package/src/exports/runtime.ts +18 -9
- package/src/shared/codec-descriptor.ts +87 -0
- package/src/shared/codec-types.ts +79 -0
- package/src/shared/codec.ts +80 -0
- package/src/shared/column-spec.ts +83 -0
- package/src/{framework-authoring.ts → shared/framework-authoring.ts} +210 -23
- package/src/{framework-components.ts → shared/framework-components.ts} +22 -49
- package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +22 -2
- package/dist/authoring.mjs.map +0 -1
- package/dist/codec-types-DQ1Agjom.d.mts +0 -58
- package/dist/codec-types-DQ1Agjom.d.mts.map +0 -1
- package/dist/emission-types-BPAALJbF.d.mts +0 -24
- package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
- package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
- package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
- package/dist/framework-components-DFZMi2h7.d.mts.map +0 -1
- package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
- package/src/codec-types.ts +0 -64
- package/src/control-capabilities.ts +0 -34
- package/src/emission-types.ts +0 -28
- package/src/run-with-middleware.ts +0 -77
- package/src/runtime-error.ts +0 -55
- package/src/runtime-middleware.ts +0 -87
- /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
- /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
- /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
- /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
- /package/src/{query-plan.ts → execution/query-plan.ts} +0 -0
- /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
package/dist/control.d.mts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { a as AuthoringFieldNamespace, d as AuthoringTypeNamespace, i as AuthoringContributions } from "./framework-authoring-
|
|
2
|
-
import {
|
|
3
|
-
import { A as LoweredDefaultResult, C as ControlMutationDefaultEntry, D as DefaultFunctionLoweringHandler, E as DefaultFunctionLoweringContext, F as SourceSpan, M as MutationDefaultGeneratorDescriptor, N as ParsedDefaultFunctionCall, O as DefaultFunctionRegistry, P as SourceDiagnostic, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as LoweredDefaultValue, k as DefaultFunctionRegistryEntry, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-
|
|
4
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
5
|
-
import { t as EmissionSpi } from "./emission-types-
|
|
1
|
+
import { a as AuthoringFieldNamespace, d as AuthoringTypeNamespace, i as AuthoringContributions } from "./framework-authoring-DGIQbNPt.mjs";
|
|
2
|
+
import { c as CodecLookup } from "./codec-m_-FAyQn.mjs";
|
|
3
|
+
import { A as LoweredDefaultResult, C as ControlMutationDefaultEntry, D as DefaultFunctionLoweringHandler, E as DefaultFunctionLoweringContext, F as SourceSpan, M as MutationDefaultGeneratorDescriptor, N as ParsedDefaultFunctionCall, O as DefaultFunctionRegistry, P as SourceDiagnostic, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as LoweredDefaultValue, k as DefaultFunctionRegistryEntry, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-CHuBHXQN.mjs";
|
|
4
|
+
import { t as TypesImportSpec } from "./types-import-spec-BxI5cSQy.mjs";
|
|
5
|
+
import { t as EmissionSpi } from "./emission-types-CMv_053d.mjs";
|
|
6
|
+
import { m as PslDocumentAst } from "./psl-ast-Ckn_G-jv.mjs";
|
|
6
7
|
import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
|
|
8
|
+
import { ImportRequirement, ImportRequirement as ImportRequirement$1 } from "@prisma-next/ts-render";
|
|
7
9
|
import { Result } from "@prisma-next/utils/result";
|
|
8
10
|
|
|
9
|
-
//#region src/control-result-types.d.ts
|
|
11
|
+
//#region src/control/control-result-types.d.ts
|
|
10
12
|
declare const VERIFY_CODE_MARKER_MISSING = "PN-RUN-3001";
|
|
11
13
|
declare const VERIFY_CODE_HASH_MISMATCH = "PN-RUN-3002";
|
|
12
14
|
declare const VERIFY_CODE_TARGET_MISMATCH = "PN-RUN-3003";
|
|
@@ -154,7 +156,7 @@ interface SignDatabaseResult {
|
|
|
154
156
|
};
|
|
155
157
|
}
|
|
156
158
|
//#endregion
|
|
157
|
-
//#region src/control-instances.d.ts
|
|
159
|
+
//#region src/control/control-instances.d.ts
|
|
158
160
|
interface ControlFamilyInstance<TFamilyId extends string, TSchemaIR> extends FamilyInstance<TFamilyId> {
|
|
159
161
|
validateContract(contractJson: unknown): Contract;
|
|
160
162
|
verify(options: {
|
|
@@ -172,15 +174,59 @@ interface ControlFamilyInstance<TFamilyId extends string, TSchemaIR> extends Fam
|
|
|
172
174
|
readonly configPath?: string;
|
|
173
175
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, string>>;
|
|
174
176
|
}): Promise<VerifyDatabaseSchemaResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Verify a contract against an already-introspected schema slice.
|
|
179
|
+
*
|
|
180
|
+
* Difference from {@link schemaVerify}: no `driver`, no introspection
|
|
181
|
+
* — the caller hands over the schema directly. Used by the aggregate
|
|
182
|
+
* verifier to invoke the family's verification logic per member,
|
|
183
|
+
* with the schema **pre-projected** to that member's claimed slice
|
|
184
|
+
* via {@link import('@prisma-next/migration-tools/aggregate').projectSchemaToSpace}.
|
|
185
|
+
*
|
|
186
|
+
* Synchronous — no I/O. Idempotent.
|
|
187
|
+
*/
|
|
188
|
+
schemaVerifyAgainstSchema(options: {
|
|
189
|
+
readonly contract: unknown;
|
|
190
|
+
readonly schema: TSchemaIR;
|
|
191
|
+
readonly strict: boolean;
|
|
192
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, string>>;
|
|
193
|
+
}): VerifyDatabaseSchemaResult;
|
|
175
194
|
sign(options: {
|
|
176
195
|
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
177
196
|
readonly contract: unknown;
|
|
178
197
|
readonly contractPath: string;
|
|
179
198
|
readonly configPath?: string;
|
|
180
199
|
}): Promise<SignDatabaseResult>;
|
|
200
|
+
/**
|
|
201
|
+
* Reads the contract marker for `space` from the database, returning
|
|
202
|
+
* `null` if no marker row exists for that space (or if the marker
|
|
203
|
+
* table itself is missing).
|
|
204
|
+
*
|
|
205
|
+
* `space` is required at every call site so the type system surfaces
|
|
206
|
+
* every place that needs to thread the value: callers in single-app
|
|
207
|
+
* paths pass {@link import('./control-spaces').APP_SPACE_ID}
|
|
208
|
+
* (`'app'`); per-extension callers pass the extension's space id.
|
|
209
|
+
* Defaulting at the family-interface level was a silent bug door —
|
|
210
|
+
* it let multi-space-aware callers forget to pass `space` and
|
|
211
|
+
* collapse onto the app's marker row.
|
|
212
|
+
*
|
|
213
|
+
* Families whose underlying storage doesn't yet support per-space
|
|
214
|
+
* markers (Mongo, today) accept `space` for interface conformance and
|
|
215
|
+
* reject any non-`APP_SPACE_ID` value rather than silently ignoring
|
|
216
|
+
* it; see the family-specific implementation for details.
|
|
217
|
+
*/
|
|
181
218
|
readMarker(options: {
|
|
182
219
|
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
220
|
+
readonly space: string;
|
|
183
221
|
}): Promise<ContractMarkerRecord | null>;
|
|
222
|
+
/**
|
|
223
|
+
* Reads every marker row keyed by `space`. Used by the per-space
|
|
224
|
+
* verifier to detect orphan marker rows and marker-vs-on-disk drift.
|
|
225
|
+
* Returns an empty map when the marker table does not yet exist.
|
|
226
|
+
*/
|
|
227
|
+
readAllMarkers(options: {
|
|
228
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
229
|
+
}): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
184
230
|
introspect(options: {
|
|
185
231
|
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
186
232
|
readonly contract?: unknown;
|
|
@@ -196,7 +242,7 @@ interface ControlDriverInstance<TFamilyId extends string, TTargetId extends stri
|
|
|
196
242
|
}
|
|
197
243
|
interface ControlExtensionInstance<TFamilyId extends string, TTargetId extends string> extends ExtensionInstance<TFamilyId, TTargetId> {}
|
|
198
244
|
//#endregion
|
|
199
|
-
//#region src/control-stack.d.ts
|
|
245
|
+
//#region src/control/control-stack.d.ts
|
|
200
246
|
interface AssembledAuthoringContributions {
|
|
201
247
|
readonly field: AuthoringFieldNamespace;
|
|
202
248
|
readonly type: AuthoringTypeNamespace;
|
|
@@ -208,7 +254,6 @@ interface ControlStack<TFamilyId extends string = string, TTargetId extends stri
|
|
|
208
254
|
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;
|
|
209
255
|
readonly extensionPacks: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
210
256
|
readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
211
|
-
readonly operationTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
212
257
|
readonly queryOperationTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
213
258
|
readonly extensionIds: ReadonlyArray<string>;
|
|
214
259
|
readonly codecLookup: CodecLookup;
|
|
@@ -231,7 +276,6 @@ declare function assertUniqueCodecOwner(options: {
|
|
|
231
276
|
readonly entityOwnershipLabel: string;
|
|
232
277
|
}): void;
|
|
233
278
|
declare function extractCodecTypeImports(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>): ReadonlyArray<TypesImportSpec>;
|
|
234
|
-
declare function extractOperationTypeImports(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>): ReadonlyArray<TypesImportSpec>;
|
|
235
279
|
declare function extractQueryOperationTypeImports(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>): ReadonlyArray<TypesImportSpec>;
|
|
236
280
|
declare function extractComponentIds(family: {
|
|
237
281
|
readonly id: string;
|
|
@@ -252,11 +296,11 @@ declare function assembleControlMutationDefaults(descriptors: ReadonlyArray<Pick
|
|
|
252
296
|
readonly id?: string;
|
|
253
297
|
}>): ControlMutationDefaults;
|
|
254
298
|
declare function extractCodecLookup(descriptors: ReadonlyArray<Pick<ComponentMetadata & {
|
|
255
|
-
id
|
|
299
|
+
id: string;
|
|
256
300
|
}, 'types' | 'id'>>): CodecLookup;
|
|
257
301
|
declare function createControlStack<TFamilyId extends string, TTargetId extends string>(input: CreateControlStackInput<TFamilyId, TTargetId>): ControlStack<TFamilyId, TTargetId>;
|
|
258
302
|
//#endregion
|
|
259
|
-
//#region src/control-descriptors.d.ts
|
|
303
|
+
//#region src/control/control-descriptors.d.ts
|
|
260
304
|
interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<TFamilyId, unknown>> extends FamilyDescriptor<TFamilyId> {
|
|
261
305
|
readonly emission: EmissionSpi;
|
|
262
306
|
create<TTargetId extends string>(stack: ControlStack<TFamilyId, TTargetId>): TFamilyInstance;
|
|
@@ -281,7 +325,62 @@ interface ControlExtensionDescriptor<TFamilyId extends string, TTargetId extends
|
|
|
281
325
|
create(): TExtensionInstance;
|
|
282
326
|
}
|
|
283
327
|
//#endregion
|
|
284
|
-
//#region src/control-migration-types.d.ts
|
|
328
|
+
//#region src/control/control-migration-types.d.ts
|
|
329
|
+
/**
|
|
330
|
+
* Planner provenance recorded inside {@link MigrationMetadata}.
|
|
331
|
+
*
|
|
332
|
+
* `used` / `applied` track which migration hints the planner consulted
|
|
333
|
+
* vs. which it actually applied during emission; `plannerVersion`
|
|
334
|
+
* pins the planner build that produced the migration so future
|
|
335
|
+
* verification passes can recognise plans authored against an older
|
|
336
|
+
* planner.
|
|
337
|
+
*/
|
|
338
|
+
interface MigrationHints {
|
|
339
|
+
readonly used: readonly string[];
|
|
340
|
+
readonly applied: readonly string[];
|
|
341
|
+
readonly plannerVersion: string;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* In-memory migration metadata envelope. Every migration is
|
|
345
|
+
* content-addressed: the `migrationHash` is a hash over the metadata
|
|
346
|
+
* envelope plus the operations list, computed at write time. There is no
|
|
347
|
+
* draft state — a migration directory either exists with fully attested
|
|
348
|
+
* metadata or it does not.
|
|
349
|
+
*
|
|
350
|
+
* When the planner cannot lower an operation because of an unfilled
|
|
351
|
+
* `placeholder(...)` slot, the migration is still written with
|
|
352
|
+
* `migrationHash` hashed over `ops: []`. Re-running self-emit after the
|
|
353
|
+
* user fills the placeholder produces a *different* `migrationHash`
|
|
354
|
+
* (committed to the real ops); this is intentional.
|
|
355
|
+
*
|
|
356
|
+
* The on-disk JSON shape in `migration.json` matches this type
|
|
357
|
+
* field-for-field — `JSON.stringify(metadata, null, 2)` is the canonical
|
|
358
|
+
* writer output (defined in `@prisma-next/migration-tools/io`).
|
|
359
|
+
*/
|
|
360
|
+
interface MigrationMetadata {
|
|
361
|
+
readonly migrationHash: string;
|
|
362
|
+
readonly from: string | null;
|
|
363
|
+
readonly to: string;
|
|
364
|
+
readonly fromContract: Contract | null;
|
|
365
|
+
readonly toContract: Contract;
|
|
366
|
+
readonly hints: MigrationHints;
|
|
367
|
+
readonly labels: readonly string[];
|
|
368
|
+
/**
|
|
369
|
+
* Sorted, deduplicated list of `invariantId`s declared by the
|
|
370
|
+
* migration's data-transform ops. Always present; an empty array
|
|
371
|
+
* means the migration has no routing-visible data transforms.
|
|
372
|
+
*/
|
|
373
|
+
readonly providedInvariants: readonly string[];
|
|
374
|
+
readonly authorship?: {
|
|
375
|
+
readonly author?: string;
|
|
376
|
+
readonly email?: string;
|
|
377
|
+
};
|
|
378
|
+
readonly signature?: {
|
|
379
|
+
readonly keyId: string;
|
|
380
|
+
readonly value: string;
|
|
381
|
+
} | null;
|
|
382
|
+
readonly createdAt: string;
|
|
383
|
+
}
|
|
285
384
|
/**
|
|
286
385
|
* Migration operation classes define the safety level of an operation.
|
|
287
386
|
* - 'additive': Adds new structures without modifying existing ones (safe)
|
|
@@ -294,52 +393,15 @@ type MigrationOperationClass = 'additive' | 'widening' | 'destructive' | 'data';
|
|
|
294
393
|
* A lowered query statement as stored in ops.json.
|
|
295
394
|
* Contains the SQL string and parameter values — ready for execution.
|
|
296
395
|
* Lowering from query builder AST to SQL happens at verify time.
|
|
396
|
+
*
|
|
397
|
+
* The Postgres `dataTransform` factory uses this shape internally to
|
|
398
|
+
* carry the user's lowered `check`/`run` plans before wrapping them
|
|
399
|
+
* into precheck/execute/postcheck steps on the unified migration op.
|
|
297
400
|
*/
|
|
298
401
|
interface SerializedQueryPlan {
|
|
299
402
|
readonly sql: string;
|
|
300
403
|
readonly params: readonly unknown[];
|
|
301
404
|
}
|
|
302
|
-
/**
|
|
303
|
-
* A data transform operation within a migration edge.
|
|
304
|
-
*
|
|
305
|
-
* Data transforms are authored in TypeScript using the query builder,
|
|
306
|
-
* serialized to JSON ASTs at verification time, and rendered to SQL
|
|
307
|
-
* by the target adapter at apply time.
|
|
308
|
-
*
|
|
309
|
-
* The `name` serves as the invariant identity — it's recorded in the
|
|
310
|
-
* ledger and used for invariant-aware routing via environment refs.
|
|
311
|
-
*
|
|
312
|
-
* In draft state (before verification), `check` and `run` are null.
|
|
313
|
-
* After verification, they contain the serialized query ASTs.
|
|
314
|
-
*/
|
|
315
|
-
interface DataTransformOperation extends MigrationPlanOperation {
|
|
316
|
-
readonly operationClass: 'data';
|
|
317
|
-
/**
|
|
318
|
-
* The invariant name for this data transform.
|
|
319
|
-
* Recorded in the ledger on successful edge completion.
|
|
320
|
-
* Used by environment refs to declare required invariants.
|
|
321
|
-
*/
|
|
322
|
-
readonly name: string;
|
|
323
|
-
/**
|
|
324
|
-
* Path to the TypeScript source file that produced this operation.
|
|
325
|
-
* Not part of edgeId computation — for traceability only.
|
|
326
|
-
*/
|
|
327
|
-
readonly source: string;
|
|
328
|
-
/**
|
|
329
|
-
* Serialized check query plan, or a boolean literal.
|
|
330
|
-
* - SerializedQueryPlan: describes violations; empty result = already applied.
|
|
331
|
-
* - false: always run (no check).
|
|
332
|
-
* - true: always skip.
|
|
333
|
-
* - null: not yet serialized (draft state).
|
|
334
|
-
*/
|
|
335
|
-
readonly check: SerializedQueryPlan | boolean | null;
|
|
336
|
-
/**
|
|
337
|
-
* Serialized run query plans.
|
|
338
|
-
* - Array of serialized query plans to execute sequentially.
|
|
339
|
-
* - null: not yet serialized (draft state).
|
|
340
|
-
*/
|
|
341
|
-
readonly run: readonly SerializedQueryPlan[] | null;
|
|
342
|
-
}
|
|
343
405
|
/**
|
|
344
406
|
* Policy defining which operation classes are allowed during a migration.
|
|
345
407
|
*/
|
|
@@ -357,11 +419,46 @@ interface MigrationPlanOperation {
|
|
|
357
419
|
readonly label: string;
|
|
358
420
|
/** The class of operation (additive, widening, destructive). */
|
|
359
421
|
readonly operationClass: MigrationOperationClass;
|
|
422
|
+
/**
|
|
423
|
+
* Optional opt-in routing identity for data-transform operations.
|
|
424
|
+
* Presence opts the transform into invariant-aware routing; absence
|
|
425
|
+
* means it is path-dependent and not referenceable from refs.
|
|
426
|
+
*
|
|
427
|
+
* Lives on the base op so the manifest emitter and
|
|
428
|
+
* `deriveProvidedInvariants` can read it without depending on a
|
|
429
|
+
* target-specific shape. Schema-DDL ops (additive / widening /
|
|
430
|
+
* destructive) leave it undefined.
|
|
431
|
+
*/
|
|
432
|
+
readonly invariantId?: string;
|
|
360
433
|
}
|
|
361
434
|
/**
|
|
362
|
-
* Framework-level contract for a single factory call in a target's planner
|
|
435
|
+
* Framework-level contract for a single factory call in a target's planner
|
|
436
|
+
* IR — the canonical shape for any node participating in the two-renderer
|
|
437
|
+
* pattern (source-text rendering for `migration.ts` + runtime-op derivation
|
|
438
|
+
* for `ops.json`).
|
|
439
|
+
*
|
|
440
|
+
* Implementations declare:
|
|
441
|
+
*
|
|
442
|
+
* - **Identity / display metadata** (`factoryName`, `operationClass`,
|
|
443
|
+
* `label`) used by CLI summaries and the issue planner.
|
|
444
|
+
* - **`renderTypeScript()`** — emit the call as a TypeScript expression
|
|
445
|
+
* suitable for inclusion in a generated `migration.ts`. Polymorphic
|
|
446
|
+
* across postgres / mongo / sqlite / extension-owned calls.
|
|
447
|
+
* - **`importRequirements()`** — the symbols this rendered expression
|
|
448
|
+
* pulls in. Aggregated and deduplicated by the top-level renderer
|
|
449
|
+
* into a single import block per file.
|
|
450
|
+
* - **`toOp()`** — lower the call to a runtime
|
|
451
|
+
* `MigrationPlanOperation`. Returns the framework base; concrete
|
|
452
|
+
* implementations narrow via covariant return (e.g. SQL targets
|
|
453
|
+
* return `SqlMigrationPlanOperation<TTargetDetails>`).
|
|
454
|
+
*
|
|
455
|
+
* Each domain (target, extension) defines its own set of concrete `*Call`
|
|
456
|
+
* classes that implement this interface — typically by extending
|
|
457
|
+
* {@link import('@prisma-next/ts-render').TsExpression} and adding the
|
|
458
|
+
* concrete `toOp()` body. Extensions can implement the interface
|
|
459
|
+
* directly without depending on a target's package-private base.
|
|
363
460
|
*
|
|
364
|
-
* @see ADR 195
|
|
461
|
+
* @see ADR 195 — Planner IR with two renderers.
|
|
365
462
|
*/
|
|
366
463
|
interface OpFactoryCall {
|
|
367
464
|
/** The name of the factory that would produce this call's runtime op. */
|
|
@@ -370,6 +467,26 @@ interface OpFactoryCall {
|
|
|
370
467
|
readonly operationClass: MigrationOperationClass;
|
|
371
468
|
/** Human-readable label for CLI output and diagnostics. */
|
|
372
469
|
readonly label: string;
|
|
470
|
+
/**
|
|
471
|
+
* Render this call as a TypeScript expression suitable for inclusion in
|
|
472
|
+
* a generated `migration.ts`. The output is composed alongside other
|
|
473
|
+
* calls' rendered expressions inside the migration's `operations`
|
|
474
|
+
* array.
|
|
475
|
+
*/
|
|
476
|
+
renderTypeScript(): string;
|
|
477
|
+
/**
|
|
478
|
+
* Import requirements pulled in by the rendered TypeScript expression.
|
|
479
|
+
* Aggregated and deduplicated across all calls into a single import
|
|
480
|
+
* block per file.
|
|
481
|
+
*/
|
|
482
|
+
importRequirements(): readonly ImportRequirement$1[];
|
|
483
|
+
/**
|
|
484
|
+
* Lower this call to a runtime migration plan operation suitable for
|
|
485
|
+
* execution / inclusion in `ops.json`. Concrete implementations narrow
|
|
486
|
+
* the return type via covariant return (e.g. SQL targets return
|
|
487
|
+
* `SqlMigrationPlanOperation<TTargetDetails>`).
|
|
488
|
+
*/
|
|
489
|
+
toOp(): MigrationPlanOperation;
|
|
373
490
|
}
|
|
374
491
|
/**
|
|
375
492
|
* A migration plan for display purposes.
|
|
@@ -378,6 +495,16 @@ interface OpFactoryCall {
|
|
|
378
495
|
interface MigrationPlan {
|
|
379
496
|
/** The target ID this plan is for (e.g., 'postgres'). */
|
|
380
497
|
readonly targetId: string;
|
|
498
|
+
/**
|
|
499
|
+
* Contract space this plan applies to. Runners cross-check
|
|
500
|
+
* `options.space` against `plan.spaceId` so the marker row gets keyed
|
|
501
|
+
* by the right space when applying via `executeAcrossSpaces`.
|
|
502
|
+
*
|
|
503
|
+
* Optional for backward compatibility with single-space callers that
|
|
504
|
+
* pre-date the contract-space aggregate; when present, runners
|
|
505
|
+
* enforce that it matches `options.space`.
|
|
506
|
+
*/
|
|
507
|
+
readonly spaceId?: string;
|
|
381
508
|
/**
|
|
382
509
|
* Origin contract identity that the plan expects the database to currently be at.
|
|
383
510
|
* If omitted or null, the runner skips origin validation entirely.
|
|
@@ -393,6 +520,17 @@ interface MigrationPlan {
|
|
|
393
520
|
};
|
|
394
521
|
/** Ordered list of operations to execute. */
|
|
395
522
|
readonly operations: readonly MigrationPlanOperation[];
|
|
523
|
+
/**
|
|
524
|
+
* Sorted, deduplicated invariant ids declared by this plan's data-transform
|
|
525
|
+
* ops. Authored migrations carry the canonical value from
|
|
526
|
+
* `migration.json.providedInvariants`; planner-built plans (`db init`,
|
|
527
|
+
* `db update`) omit it (the runner treats it as `[]`). Runners read this
|
|
528
|
+
* field for marker writes and self-edge no-op detection rather than
|
|
529
|
+
* re-deriving from `operations`, since the manifest is the canonical
|
|
530
|
+
* source for the invariant set across all runners (postgres, sqlite,
|
|
531
|
+
* mongo).
|
|
532
|
+
*/
|
|
533
|
+
readonly providedInvariants?: readonly string[];
|
|
396
534
|
}
|
|
397
535
|
/**
|
|
398
536
|
* A migration plan that can also render itself back to user-editable
|
|
@@ -502,27 +640,36 @@ interface MigrationPlanner<TFamilyId extends string = string, TTargetId extends
|
|
|
502
640
|
readonly contract: unknown;
|
|
503
641
|
readonly schema: unknown;
|
|
504
642
|
readonly policy: MigrationOperationPolicy;
|
|
505
|
-
/**
|
|
506
|
-
* Storage hash of the "from" contract (the state the planner assumes the
|
|
507
|
-
* database starts at). Planners use this to populate `describe()` on the
|
|
508
|
-
* produced plan so the rendered `migration.ts` has correct `from`/`to`
|
|
509
|
-
* metadata.
|
|
510
|
-
*/
|
|
511
|
-
readonly fromHash: string;
|
|
512
643
|
/**
|
|
513
644
|
* The "from" contract (the state the planner assumes the database starts
|
|
514
|
-
* at)
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
645
|
+
* at), or `null` for a baseline plan with no prior state.
|
|
646
|
+
*
|
|
647
|
+
* Planners derive any "from" identity they need to stamp onto the
|
|
648
|
+
* produced plan's `describe()` from `fromContract?.storage.storageHash
|
|
649
|
+
* ?? null`. They also pass this to data-safety strategies so they can
|
|
650
|
+
* compare `from` and `to` column shapes (e.g. to detect unsafe type
|
|
651
|
+
* changes).
|
|
652
|
+
*
|
|
653
|
+
* Required at every call site to make the structural fact "I have a
|
|
654
|
+
* prior contract / I don't" visible in the type. Reconciliation
|
|
655
|
+
* commands (`db init`, `db update`) introspect a live schema and pass
|
|
656
|
+
* `null`; authoring commands (`migration plan`) pass the previous
|
|
657
|
+
* bundle's `metadata.toContract`.
|
|
518
658
|
*/
|
|
519
|
-
readonly fromContract
|
|
659
|
+
readonly fromContract: Contract | null;
|
|
520
660
|
/**
|
|
521
661
|
* Active framework components participating in this composition.
|
|
522
662
|
* Families/targets can interpret this list to derive family-specific metadata.
|
|
523
663
|
* All components must have matching familyId and targetId.
|
|
524
664
|
*/
|
|
525
665
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
666
|
+
/**
|
|
667
|
+
* Contract space this plan applies to. Stamped onto the produced
|
|
668
|
+
* plan so the runner keys the marker row by the right space when
|
|
669
|
+
* executing. App-plan callers pass `APP_SPACE_ID` (`'app'`);
|
|
670
|
+
* per-extension callers pass the extension's space id.
|
|
671
|
+
*/
|
|
672
|
+
readonly spaceId: string;
|
|
526
673
|
}): MigrationPlannerResult;
|
|
527
674
|
/**
|
|
528
675
|
* Produce an empty migration with the target's authoring conventions.
|
|
@@ -530,8 +677,12 @@ interface MigrationPlanner<TFamilyId extends string = string, TTargetId extends
|
|
|
530
677
|
* Used by `migration new` to scaffold a fresh `migration.ts`. The
|
|
531
678
|
* returned plan has no operations; its `renderTypeScript()` yields a
|
|
532
679
|
* stub the user can edit.
|
|
680
|
+
*
|
|
681
|
+
* `spaceId` is stamped onto the produced plan; reconciliation flows
|
|
682
|
+
* (`db init`, `db update`) and authoring flows (`migration new`) all
|
|
683
|
+
* pass it explicitly.
|
|
533
684
|
*/
|
|
534
|
-
emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface;
|
|
685
|
+
emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
|
|
535
686
|
}
|
|
536
687
|
/**
|
|
537
688
|
* Migration runner interface for executing migration plans.
|
|
@@ -541,6 +692,16 @@ interface MigrationPlanner<TFamilyId extends string = string, TTargetId extends
|
|
|
541
692
|
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
542
693
|
*/
|
|
543
694
|
interface MigrationRunner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
695
|
+
/**
|
|
696
|
+
* Execute a migration plan against the configured driver.
|
|
697
|
+
*
|
|
698
|
+
* The `plan` parameter is trusted input. Callers are responsible for
|
|
699
|
+
* upstream verification of the originating migration package — typically
|
|
700
|
+
* by obtaining the package via `readMigrationPackage` from
|
|
701
|
+
* `@prisma-next/migration-tools/io`, which performs hash-integrity checks
|
|
702
|
+
* at the load boundary. Runners do not re-verify the plan and assume the
|
|
703
|
+
* `(metadata, ops)` pair on disk has not been tampered with since emit.
|
|
704
|
+
*/
|
|
544
705
|
execute(options: {
|
|
545
706
|
readonly plan: MigrationPlan;
|
|
546
707
|
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
@@ -563,6 +724,58 @@ interface MigrationRunner<TFamilyId extends string = string, TTargetId extends s
|
|
|
563
724
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
564
725
|
}): Promise<MigrationRunnerResult>;
|
|
565
726
|
}
|
|
727
|
+
/**
|
|
728
|
+
* Per-space input for {@link MultiSpaceCapableRunner.executeAcrossSpaces}.
|
|
729
|
+
*
|
|
730
|
+
* Mirrors the single-space `MigrationRunner.execute` options, extended with a
|
|
731
|
+
* required `space` identifier. Each entry's `driver` must reference the same
|
|
732
|
+
* connection the outer transaction is opened on (typically the same value as
|
|
733
|
+
* the top-level `driver` on `executeAcrossSpaces`).
|
|
734
|
+
*
|
|
735
|
+
* Family-specific runners (e.g. the SQL family's `SqlMigrationRunner`) define
|
|
736
|
+
* a richer per-space option shape that is structurally compatible with this
|
|
737
|
+
* one — additional optional fields (e.g. SQL's `strictVerification`,
|
|
738
|
+
* `schemaName`, `callbacks`) are tolerated by the underlying runner without
|
|
739
|
+
* affecting cross-target wiring.
|
|
740
|
+
*/
|
|
741
|
+
interface MultiSpaceRunnerPerSpaceOptions<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
742
|
+
readonly space: string;
|
|
743
|
+
readonly plan: MigrationPlan;
|
|
744
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
745
|
+
readonly destinationContract: unknown;
|
|
746
|
+
readonly policy: MigrationOperationPolicy;
|
|
747
|
+
readonly executionChecks?: MigrationRunnerExecutionChecks;
|
|
748
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
749
|
+
}
|
|
750
|
+
interface MultiSpaceRunnerSuccessValue {
|
|
751
|
+
readonly perSpaceResults: ReadonlyArray<{
|
|
752
|
+
readonly space: string;
|
|
753
|
+
readonly value: MigrationRunnerSuccessValue;
|
|
754
|
+
}>;
|
|
755
|
+
}
|
|
756
|
+
interface MultiSpaceRunnerFailure extends MigrationRunnerFailure {
|
|
757
|
+
/** Identifier of the space whose plan caused the rollback. */
|
|
758
|
+
readonly failingSpace: string;
|
|
759
|
+
}
|
|
760
|
+
type MultiSpaceRunnerResult = Result<MultiSpaceRunnerSuccessValue, MultiSpaceRunnerFailure>;
|
|
761
|
+
/**
|
|
762
|
+
* Optional capability for runners that can apply a list of per-space plans
|
|
763
|
+
* inside a single outer transaction. A failure on any space rolls back every
|
|
764
|
+
* space's writes.
|
|
765
|
+
*
|
|
766
|
+
* The SQL family (`SqlMigrationRunner`) implements this with a true outer
|
|
767
|
+
* transaction across every space. The Mongo family implements a degenerate
|
|
768
|
+
* single-space shim (per-space is a non-goal per the extension-contract-spaces
|
|
769
|
+
* project spec — Mongo aggregates are always single-member). The capability
|
|
770
|
+
* is declared at the framework layer so CLI utilities can route through it
|
|
771
|
+
* without importing any specific family directly.
|
|
772
|
+
*/
|
|
773
|
+
interface MultiSpaceCapableRunner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
774
|
+
executeAcrossSpaces(options: {
|
|
775
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
776
|
+
readonly perSpaceOptions: ReadonlyArray<MultiSpaceRunnerPerSpaceOptions<TFamilyId, TTargetId>>;
|
|
777
|
+
}): Promise<MultiSpaceRunnerResult>;
|
|
778
|
+
}
|
|
566
779
|
/**
|
|
567
780
|
* Optional capability interface for targets that support migrations.
|
|
568
781
|
* Targets that implement migrations expose this via their descriptor.
|
|
@@ -598,11 +811,12 @@ interface MigrationScaffoldContext {
|
|
|
598
811
|
/** Absolute path to the contract.json file, if one exists. Used by targets that emit typed-contract imports. */
|
|
599
812
|
readonly contractJsonPath?: string;
|
|
600
813
|
/**
|
|
601
|
-
* Storage hash of the "from" contract
|
|
602
|
-
* `describe()` on the
|
|
603
|
-
* is correctly
|
|
814
|
+
* Storage hash of the "from" contract, or `null` for a baseline scaffold
|
|
815
|
+
* with no prior state. Targets use this to populate `describe()` on the
|
|
816
|
+
* rendered empty migration so that identity metadata is correctly
|
|
817
|
+
* populated.
|
|
604
818
|
*/
|
|
605
|
-
readonly fromHash: string;
|
|
819
|
+
readonly fromHash: string | null;
|
|
606
820
|
/**
|
|
607
821
|
* Storage hash of the "to" contract. Same purpose as `fromHash` — threaded
|
|
608
822
|
* through so the rendered class's `describe()` declares the correct
|
|
@@ -611,7 +825,30 @@ interface MigrationScaffoldContext {
|
|
|
611
825
|
readonly toHash: string;
|
|
612
826
|
}
|
|
613
827
|
//#endregion
|
|
614
|
-
//#region src/control-
|
|
828
|
+
//#region src/control/control-operation-preview.d.ts
|
|
829
|
+
/**
|
|
830
|
+
* Family-agnostic textual preview of a migration plan, used by the CLI to
|
|
831
|
+
* render a "DDL preview" section for `db init` / `db update` / `migration plan`
|
|
832
|
+
* / `migration show`. Each statement carries a free-form `language` tag so
|
|
833
|
+
* formatters can suffix `;` for SQL but render Mongo shell lines verbatim.
|
|
834
|
+
*
|
|
835
|
+
* Producers are family-specific: SQL emits `language: 'sql'` (existing DDL
|
|
836
|
+
* extraction); Mongo emits `language: 'mongodb-shell'` via the
|
|
837
|
+
* `MongoDdlCommandFormatter` visitor.
|
|
838
|
+
*
|
|
839
|
+
* The capability `OperationPreviewCapable` (declared in
|
|
840
|
+
* `./control-capabilities`) is how a family announces it can produce these.
|
|
841
|
+
*/
|
|
842
|
+
interface OperationPreviewStatement {
|
|
843
|
+
readonly text: string;
|
|
844
|
+
/** Dialect identifier, e.g. `'sql'`, `'mongodb-shell'`. Free-form by design (OQ-3). */
|
|
845
|
+
readonly language: string;
|
|
846
|
+
}
|
|
847
|
+
interface OperationPreview {
|
|
848
|
+
readonly statements: readonly OperationPreviewStatement[];
|
|
849
|
+
}
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region src/control/control-schema-view.d.ts
|
|
615
852
|
/**
|
|
616
853
|
* Core schema view types for family-agnostic schema visualization.
|
|
617
854
|
*
|
|
@@ -649,7 +886,7 @@ interface CoreSchemaView {
|
|
|
649
886
|
readonly root: SchemaTreeNode;
|
|
650
887
|
}
|
|
651
888
|
//#endregion
|
|
652
|
-
//#region src/control-capabilities.d.ts
|
|
889
|
+
//#region src/control/control-capabilities.d.ts
|
|
653
890
|
interface MigratableTargetDescriptor<TFamilyId extends string, TTargetId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<TFamilyId, unknown>> extends ControlTargetDescriptor<TFamilyId, TTargetId> {
|
|
654
891
|
readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;
|
|
655
892
|
}
|
|
@@ -658,6 +895,113 @@ interface SchemaViewCapable<TSchemaIR = unknown> {
|
|
|
658
895
|
toSchemaView(schema: TSchemaIR): CoreSchemaView;
|
|
659
896
|
}
|
|
660
897
|
declare function hasSchemaView<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR>;
|
|
898
|
+
/**
|
|
899
|
+
* Capability declaring that a family can infer a PSL contract AST from its
|
|
900
|
+
* opaque introspected schema IR. Consumed by `prisma-next contract infer`.
|
|
901
|
+
*/
|
|
902
|
+
interface PslContractInferCapable<TSchemaIR = unknown> {
|
|
903
|
+
inferPslContract(schemaIR: TSchemaIR): PslDocumentAst;
|
|
904
|
+
}
|
|
905
|
+
declare function hasPslContractInfer<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & PslContractInferCapable<TSchemaIR>;
|
|
906
|
+
/**
|
|
907
|
+
* Capability declaring that a family can render a textual preview of migration
|
|
908
|
+
* operations for the CLI's "DDL preview" output. SQL families emit
|
|
909
|
+
* `language: 'sql'` statements; Mongo families emit `language: 'mongodb-shell'`.
|
|
910
|
+
*/
|
|
911
|
+
interface OperationPreviewCapable {
|
|
912
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
|
|
913
|
+
}
|
|
914
|
+
declare function hasOperationPreview<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & OperationPreviewCapable;
|
|
915
|
+
/**
|
|
916
|
+
* Capability declaring that a runner can apply per-space plans inside a
|
|
917
|
+
* single outer transaction. The SQL family (`SqlMigrationRunner`) implements
|
|
918
|
+
* this with a true outer transaction. The Mongo family implements a
|
|
919
|
+
* degenerate single-space shim (Mongo per-space is a non-goal per the
|
|
920
|
+
* extension-contract-spaces project spec — TML-2397).
|
|
921
|
+
*
|
|
922
|
+
* The CLI's shared `applyAggregate` primitive uses this guard so that
|
|
923
|
+
* `db init` / `db update` / `migration apply` route uniformly through one
|
|
924
|
+
* dispatch path regardless of family.
|
|
925
|
+
*/
|
|
926
|
+
declare function hasMultiSpaceRunner<TFamilyId extends string, TTargetId extends string>(runner: MigrationRunner<TFamilyId, TTargetId>): runner is MigrationRunner<TFamilyId, TTargetId> & MultiSpaceCapableRunner<TFamilyId, TTargetId>;
|
|
927
|
+
//#endregion
|
|
928
|
+
//#region src/control/control-spaces.d.ts
|
|
929
|
+
/**
|
|
930
|
+
* Canonical control-plane identifiers for contract spaces.
|
|
931
|
+
*
|
|
932
|
+
* A contract space is the disjoint `(contract.json, migration-graph)` unit
|
|
933
|
+
* the per-space planner / runner / verifier (project: extension contract
|
|
934
|
+
* spaces, TML-2397) operates on. The application owns one well-known
|
|
935
|
+
* space — the value below — and each loaded extension that contributes
|
|
936
|
+
* schema owns a uniquely-named space.
|
|
937
|
+
*
|
|
938
|
+
* Lives in `framework-components/control` so every layer that has to
|
|
939
|
+
* reason about space identity (the migration tooling, the SQL runtime's
|
|
940
|
+
* marker reader, target-side statement builders, target-side adapters)
|
|
941
|
+
* can import a single value rather than duplicating the literal. Raw
|
|
942
|
+
* `'app'` string literals in framework / target / runtime / adapter
|
|
943
|
+
* source code are forbidden and policed by
|
|
944
|
+
* `scripts/lint-app-space-id.mjs` (wired into `pnpm lint:deps`).
|
|
945
|
+
*
|
|
946
|
+
* @see specs/framework-mechanism.spec.md § 3 — Layout convention (γ).
|
|
947
|
+
*/
|
|
948
|
+
declare const APP_SPACE_ID: "app";
|
|
949
|
+
/**
|
|
950
|
+
* Head ref for a contract space — the `(hash, invariants)` tuple
|
|
951
|
+
* a runner targets when applying that space's migration graph. Identical
|
|
952
|
+
* in shape to the on-disk `migrations/<space-id>/refs/head.json` the
|
|
953
|
+
* framework writes per loaded extension, and to the app-space
|
|
954
|
+
* `<projectRoot>/refs/head.json`. Family-agnostic: SQL, Mongo, and any
|
|
955
|
+
* future family share the same head-ref shape.
|
|
956
|
+
*
|
|
957
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
958
|
+
*/
|
|
959
|
+
interface ContractSpaceHeadRef {
|
|
960
|
+
readonly hash: string;
|
|
961
|
+
readonly invariants: readonly string[];
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Canonical structural shape of a migration package — the unit a planner
|
|
965
|
+
* produces and a runner consumes: a directory name, the ADR 197 metadata
|
|
966
|
+
* envelope (which carries the `toContract` snapshot), and the operation
|
|
967
|
+
* list.
|
|
968
|
+
*
|
|
969
|
+
* In-memory by default. Readers in `@prisma-next/migration-tools`
|
|
970
|
+
* (`readMigrationPackage` / `readMigrationsDir`) return the augmented
|
|
971
|
+
* {@link import('@prisma-next/migration-tools/package').OnDiskMigrationPackage}
|
|
972
|
+
* variant which adds `dirPath`; everything else operates against the
|
|
973
|
+
* canonical shape so the same value flows through pre-emission
|
|
974
|
+
* authoring, on-disk loading, and runner execution without conversion.
|
|
975
|
+
*
|
|
976
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
977
|
+
*/
|
|
978
|
+
interface MigrationPackage {
|
|
979
|
+
readonly dirName: string;
|
|
980
|
+
readonly metadata: MigrationMetadata;
|
|
981
|
+
readonly ops: readonly MigrationPlanOperation[];
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Canonical structural shape of a contract space — one disjoint
|
|
985
|
+
* `(contractJson, migration-graph)` unit the per-space planner / runner
|
|
986
|
+
* / verifier operates on. The application owns one well-known space
|
|
987
|
+
* ({@link APP_SPACE_ID}); each loaded extension that contributes schema
|
|
988
|
+
* owns a uniquely-named space. Whether a value is the app's space or an
|
|
989
|
+
* extension's space is a control-plane concern; the type carries no
|
|
990
|
+
* such distinction.
|
|
991
|
+
*
|
|
992
|
+
* Generic over the contract so each family pins a typed contract value
|
|
993
|
+
* at consumption time. The SQL family specialises to
|
|
994
|
+
* `ContractSpace<Contract<SqlStorage>>` at the descriptor surface;
|
|
995
|
+
* Mongo's symmetrical `ContractSpace<Contract<MongoStorage>>` will land
|
|
996
|
+
* with that family.
|
|
997
|
+
*
|
|
998
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
999
|
+
*/
|
|
1000
|
+
interface ContractSpace<TContract extends Contract = Contract> {
|
|
1001
|
+
readonly contractJson: TContract;
|
|
1002
|
+
readonly migrations: readonly MigrationPackage[];
|
|
1003
|
+
readonly headRef: ContractSpaceHeadRef;
|
|
1004
|
+
}
|
|
661
1005
|
//#endregion
|
|
662
|
-
export { type AssembledAuthoringContributions, type BaseSchemaIssue, type ControlAdapterDescriptor, type ControlAdapterInstance, type ControlDriverDescriptor, type ControlDriverInstance, type ControlExtensionDescriptor, type ControlExtensionInstance, type ControlFamilyDescriptor, type ControlFamilyInstance, type ControlMutationDefaultEntry, type ControlMutationDefaultRegistry, type ControlMutationDefaults, type ControlStack, type ControlTargetDescriptor, type ControlTargetInstance, type CoreSchemaView, type CreateControlStackInput, type
|
|
1006
|
+
export { APP_SPACE_ID, type AssembledAuthoringContributions, type BaseSchemaIssue, type ContractSpace, type ContractSpaceHeadRef, type ControlAdapterDescriptor, type ControlAdapterInstance, type ControlDriverDescriptor, type ControlDriverInstance, type ControlExtensionDescriptor, type ControlExtensionInstance, type ControlFamilyDescriptor, type ControlFamilyInstance, type ControlMutationDefaultEntry, type ControlMutationDefaultRegistry, type ControlMutationDefaults, type ControlStack, type ControlTargetDescriptor, type ControlTargetInstance, type CoreSchemaView, type CreateControlStackInput, type DefaultFunctionLoweringContext, type DefaultFunctionLoweringHandler, type DefaultFunctionRegistry, type DefaultFunctionRegistryEntry, type EmitContractResult, type EnumValuesChangedIssue, type ImportRequirement, type IntrospectSchemaResult, type LoweredDefaultResult, type LoweredDefaultValue, type MigratableTargetDescriptor, type MigrationHints, type MigrationMetadata, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPackage, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanWithAuthoringSurface, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerFailureResult, type MigrationPlannerResult, type MigrationPlannerSuccessResult, type MigrationRunner, type MigrationRunnerExecutionChecks, type MigrationRunnerFailure, type MigrationRunnerResult, type MigrationRunnerSuccessValue, type MigrationScaffoldContext, type MultiSpaceCapableRunner, type MultiSpaceRunnerFailure, type MultiSpaceRunnerPerSpaceOptions, type MultiSpaceRunnerResult, type MultiSpaceRunnerSuccessValue, type MutationDefaultGeneratorDescriptor, type OpFactoryCall, type OperationContext, type OperationPreview, type OperationPreviewCapable, type OperationPreviewStatement, type ParsedDefaultFunctionCall, type PslContractInferCapable, type SchemaIssue, type SchemaNodeKind, SchemaTreeNode, type SchemaTreeNodeOptions, type SchemaTreeVisitor, type SchemaVerificationNode, type SchemaViewCapable, type SerializedQueryPlan, type SignDatabaseResult, type SourceDiagnostic, type SourceSpan, type TargetMigrationsCapability, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, type VerifyDatabaseResult, type VerifyDatabaseSchemaResult, assembleAuthoringContributions, assembleControlMutationDefaults, assembleScalarTypeDescriptors, assertUniqueCodecOwner, createControlStack, extractCodecLookup, extractCodecTypeImports, extractComponentIds, extractQueryOperationTypeImports, hasMigrations, hasMultiSpaceRunner, hasOperationPreview, hasPslContractInfer, hasSchemaView };
|
|
663
1007
|
//# sourceMappingURL=control.d.mts.map
|