@prisma-next/family-sql 0.5.0 → 0.6.0-dev.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 +0 -1
- package/dist/control.d.mts +5 -7
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +10 -35
- package/dist/control.mjs.map +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/schema-verify.d.mts +3 -12
- package/dist/schema-verify.d.mts.map +1 -1
- package/dist/schema-verify.mjs +2 -2
- package/dist/{types-BQBbcXg3.d.mts → types-mhjAPuMn.d.mts} +12 -21
- package/dist/types-mhjAPuMn.d.mts.map +1 -0
- package/dist/{verify-sql-schema-r1-2apHI.mjs → verify-sql-schema-1tDh3x5x.mjs} +2 -65
- package/dist/verify-sql-schema-1tDh3x5x.mjs.map +1 -0
- package/dist/verify-sql-schema-CPHiuYHR.d.mts.map +1 -1
- package/package.json +19 -19
- package/src/core/control-instance.ts +1 -12
- package/src/core/migrations/contract-to-schema-ir.ts +4 -29
- package/src/core/migrations/field-event-planner.ts +6 -4
- package/src/core/migrations/types.ts +10 -37
- package/src/core/schema-verify/verify-helpers.ts +1 -64
- package/src/core/schema-verify/verify-sql-schema.ts +1 -6
- package/src/exports/control.ts +0 -3
- package/src/exports/schema-verify.ts +0 -1
- package/dist/types-BQBbcXg3.d.mts.map +0 -1
- package/dist/verify-sql-schema-r1-2apHI.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,6 @@ Provides the SQL family descriptor (`ControlFamilyDescriptor`) that includes:
|
|
|
15
15
|
- **Planner & Runner SPI**: Owns the `MigrationPlanner` / `MigrationRunner` interfaces plus the `SqlControlTargetDescriptor` helper so targets can expose planners and runners (e.g., Postgres init planner/runner)
|
|
16
16
|
- **Family Hook Integration**: Integrates the SQL target family hook (`sqlEmission`) from `@prisma-next/sql-contract-emitter`
|
|
17
17
|
- **Control Plane Entry Point**: Serves as the control plane entry point for the SQL family, enabling the CLI to select the family hook and create family instances
|
|
18
|
-
- **Component Database Dependencies**: Consumes database dependencies declared by framework components (target/adapter/extension packs). Callers pass the active `frameworkComponents` list into planning/execution/verification; SQL layers structurally narrow to components that declare `databaseDependencies` and use their pure verification hooks (no fuzzy matching against `contract.extensionPacks`).
|
|
19
18
|
- **Contract-to-SchemaIR Conversion**: Converts `SqlStorage` from a contract into `SqlSchemaIR` for offline migration planning, enabling `migration plan` to work without a database connection
|
|
20
19
|
- **Destructive Change Detection**: Compares two `SqlStorage` values and identifies destructive changes (dropped tables/columns) for migration policy enforcement
|
|
21
20
|
- **Storage Type Control Hooks**: Extracts codec-owned control hooks for planning/verification/introspection of `storage.types` without adding enum-specific fields to shared IR
|
package/dist/control.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as SqlPlannerConflictKind, C as SqlMigrationRunnerExecuteCallbacks, D as SqlMigrationRunnerSuccessValue, E as SqlMigrationRunnerResult, F as StorageTypePlanResult, I as SchemaVerifyOptions, L as SqlControlFamilyInstance, M as SqlPlannerFailureResult, N as SqlPlannerResult, O as SqlPlanTargetDetails, P as SqlPlannerSuccessResult, S as SqlMigrationRunnerErrorCode, T as SqlMigrationRunnerFailure, _ as SqlMigrationPlanOperationStep, a as FieldEvent, b as SqlMigrationPlannerPlanOptions, c as MultiSpaceRunnerResult, d as SqlControlAdapterDescriptor, f as SqlControlExtensionDescriptor, g as SqlMigrationPlanOperation, h as SqlMigrationPlanContractInfo, i as ExpandNativeTypeInput, j as SqlPlannerConflictLocation, k as SqlPlannerConflict, l as MultiSpaceRunnerSuccessValue, m as SqlMigrationPlan, n as CodecControlHooks, o as FieldEventContext, p as SqlControlTargetDescriptor, r as CreateSqlMigrationPlanOptions, s as MultiSpaceRunnerFailure, t as AnyRecord, u as ResolveIdentityValueInput, v as SqlMigrationPlanOperationTarget, w as SqlMigrationRunnerExecuteOptions, x as SqlMigrationRunner, y as SqlMigrationPlanner } from "./types-mhjAPuMn.mjs";
|
|
2
2
|
import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { NotOk, Ok } from "@prisma-next/utils/result";
|
|
4
4
|
import { ColumnDefault, Contract } from "@prisma-next/contract/types";
|
|
@@ -285,15 +285,13 @@ interface ContractToSchemaIROptions {
|
|
|
285
285
|
readonly annotationNamespace: string;
|
|
286
286
|
readonly expandNativeType?: NativeTypeExpander;
|
|
287
287
|
readonly renderDefault?: DefaultRenderer;
|
|
288
|
-
readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
289
288
|
}
|
|
290
289
|
/**
|
|
291
290
|
* Converts a `Contract` to `SqlSchemaIR`.
|
|
292
291
|
*
|
|
293
|
-
* Reads `contract.storage` for tables
|
|
294
|
-
* annotations
|
|
295
|
-
*
|
|
296
|
-
* Storage-type annotations are written under `options.annotationNamespace`.
|
|
292
|
+
* Reads `contract.storage` for tables and `contract.storage.types` for type
|
|
293
|
+
* annotations. Storage-type annotations are written under
|
|
294
|
+
* `options.annotationNamespace`.
|
|
297
295
|
*
|
|
298
296
|
* Drops codec metadata (`codecId`, `typeRef`) since the schema IR only represents
|
|
299
297
|
* structural information. When `expandNativeType` is provided, parameterized types
|
|
@@ -413,5 +411,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
413
411
|
//#region src/exports/control.d.ts
|
|
414
412
|
declare const _default: SqlFamilyDescriptor;
|
|
415
413
|
//#endregion
|
|
416
|
-
export { type CodecControlHooks, type
|
|
414
|
+
export { type CodecControlHooks, type ContractToSchemaIROptions, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type MultiSpaceRunnerFailure, type MultiSpaceRunnerResult, type MultiSpaceRunnerSuccessValue, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SchemaVerifyOptions, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
417
415
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,0BAAA,CACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,EAAM,2BAAA,EACN,OAAA,UACA,OAAA;EAAY,GAAA;EAAc,IAAA,GAAO,SAAA;AAAA,IAChC,KAAA,CAAM,yBAAA;;;;;;cC1JI,oBAAA,EAAsB,0BAAA;;;;;;;;;;;;;;iBCsBnB,6BAAA,CAAA,GAAiC,kCAAA;;;;;;;;;;;iBAoBjC,wBAAA,+DAAA,CAGd,KAAA;EAAA,SAAkB,OAAA,EAAS,OAAA;EAAA,SAAkB,UAAA,EAAY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCyBlB,QAAA"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-F4JpCJl7.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-1tDh3x5x.mjs";
|
|
3
3
|
import { t as collectSupportedCodecTypeIds } from "./verify-pRYxnpiG.mjs";
|
|
4
4
|
import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-BWp8S2sa.mjs";
|
|
5
5
|
import { sqlEmission } from "@prisma-next/sql-contract-emitter";
|
|
@@ -1389,20 +1389,11 @@ function createSqlFamilyInstance(stack) {
|
|
|
1389
1389
|
...children.length > 0 ? { children } : {}
|
|
1390
1390
|
});
|
|
1391
1391
|
});
|
|
1392
|
-
const dependencyNodes = schema.dependencies.map((dep) => {
|
|
1393
|
-
const shortName = dep.id.split(".").pop() ?? dep.id;
|
|
1394
|
-
return new SchemaTreeNode({
|
|
1395
|
-
kind: "dependency",
|
|
1396
|
-
id: `dependency-${dep.id}`,
|
|
1397
|
-
label: `${shortName} dependency is installed`
|
|
1398
|
-
});
|
|
1399
|
-
});
|
|
1400
|
-
const rootChildren = [...tableNodes, ...dependencyNodes];
|
|
1401
1392
|
return { root: new SchemaTreeNode({
|
|
1402
1393
|
kind: "root",
|
|
1403
1394
|
id: "sql-schema",
|
|
1404
1395
|
label: "database",
|
|
1405
|
-
...
|
|
1396
|
+
...tableNodes.length > 0 ? { children: tableNodes } : {}
|
|
1406
1397
|
}) };
|
|
1407
1398
|
}
|
|
1408
1399
|
};
|
|
@@ -1532,10 +1523,9 @@ function detectDestructiveChanges(from, to) {
|
|
|
1532
1523
|
/**
|
|
1533
1524
|
* Converts a `Contract` to `SqlSchemaIR`.
|
|
1534
1525
|
*
|
|
1535
|
-
* Reads `contract.storage` for tables
|
|
1536
|
-
* annotations
|
|
1537
|
-
*
|
|
1538
|
-
* Storage-type annotations are written under `options.annotationNamespace`.
|
|
1526
|
+
* Reads `contract.storage` for tables and `contract.storage.types` for type
|
|
1527
|
+
* annotations. Storage-type annotations are written under
|
|
1528
|
+
* `options.annotationNamespace`.
|
|
1539
1529
|
*
|
|
1540
1530
|
* Drops codec metadata (`codecId`, `typeRef`) since the schema IR only represents
|
|
1541
1531
|
* structural information. When `expandNativeType` is provided, parameterized types
|
|
@@ -1546,31 +1536,16 @@ function detectDestructiveChanges(from, to) {
|
|
|
1546
1536
|
*/
|
|
1547
1537
|
function contractToSchemaIR(contract, options) {
|
|
1548
1538
|
if (options.annotationNamespace.length === 0) throw new Error("annotationNamespace must be a non-empty string");
|
|
1549
|
-
if (!contract) return {
|
|
1550
|
-
tables: {},
|
|
1551
|
-
dependencies: []
|
|
1552
|
-
};
|
|
1539
|
+
if (!contract) return { tables: {} };
|
|
1553
1540
|
const storage = contract.storage;
|
|
1554
1541
|
const storageTypes = storage.types ?? {};
|
|
1555
1542
|
const tables = {};
|
|
1556
1543
|
for (const [tableName, tableDef] of Object.entries(storage.tables)) tables[tableName] = convertTable(tableName, tableDef, storageTypes, options.expandNativeType, options.renderDefault);
|
|
1557
1544
|
return {
|
|
1558
1545
|
tables,
|
|
1559
|
-
dependencies: deduplicateDependencyIRs(collectInitDependencies(options.frameworkComponents ?? [])),
|
|
1560
1546
|
...ifDefined("annotations", deriveAnnotations(storage, options.annotationNamespace))
|
|
1561
1547
|
};
|
|
1562
1548
|
}
|
|
1563
|
-
function deduplicateDependencyIRs(deps) {
|
|
1564
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1565
|
-
const result = [];
|
|
1566
|
-
for (const dep of deps) {
|
|
1567
|
-
if (dep.id.trim().length === 0) throw new Error("Dependency id must be a non-empty string");
|
|
1568
|
-
if (seen.has(dep.id)) continue;
|
|
1569
|
-
seen.add(dep.id);
|
|
1570
|
-
result.push({ id: dep.id });
|
|
1571
|
-
}
|
|
1572
|
-
return result;
|
|
1573
|
-
}
|
|
1574
1549
|
function deriveAnnotations(storage, annotationNamespace) {
|
|
1575
1550
|
if (!storage.types || Object.keys(storage.types).length === 0) return void 0;
|
|
1576
1551
|
const byNativeType = {};
|
|
@@ -1659,9 +1634,9 @@ function buildContext(event, entry) {
|
|
|
1659
1634
|
* `'altered'` predicate. Returns `false` whenever `codecId` differs —
|
|
1660
1635
|
* any codec change suppresses the `altered` event entirely, including
|
|
1661
1636
|
* cases where another property also differs in the same diff. Codec
|
|
1662
|
-
* rotation is a v1 non-goal
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1637
|
+
* rotation is a v1 non-goal; avoiding the mixed event keeps the
|
|
1638
|
+
* migration semantics for codec changes explicit rather than smuggling
|
|
1639
|
+
* them through as `altered`.
|
|
1665
1640
|
*
|
|
1666
1641
|
* For non-`codecId` diffs, returns `true` iff any other column property
|
|
1667
1642
|
* differs.
|
|
@@ -1795,6 +1770,6 @@ const INIT_ADDITIVE_POLICY = Object.freeze({ allowedOperationClasses: Object.fre
|
|
|
1795
1770
|
//#region src/exports/control.ts
|
|
1796
1771
|
var control_default = new SqlFamilyDescriptor();
|
|
1797
1772
|
//#endregion
|
|
1798
|
-
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions,
|
|
1773
|
+
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
1799
1774
|
|
|
1800
1775
|
//# sourceMappingURL=control.mjs.map
|