@prisma-next/family-sql 0.8.0 → 0.9.0-dev.2

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.
Files changed (43) hide show
  1. package/README.md +5 -5
  2. package/dist/control-adapter.d.mts +11 -1
  3. package/dist/control-adapter.d.mts.map +1 -1
  4. package/dist/control.d.mts +3 -3
  5. package/dist/control.d.mts.map +1 -1
  6. package/dist/control.mjs +37 -30
  7. package/dist/control.mjs.map +1 -1
  8. package/dist/ir.d.mts +135 -0
  9. package/dist/ir.d.mts.map +1 -0
  10. package/dist/ir.mjs +37 -0
  11. package/dist/ir.mjs.map +1 -0
  12. package/dist/migration.d.mts +1 -1
  13. package/dist/runtime.mjs +1 -1
  14. package/dist/schema-verify.d.mts +2 -1
  15. package/dist/schema-verify.d.mts.map +1 -1
  16. package/dist/schema-verify.mjs +1 -1
  17. package/dist/sql-contract-serializer-qUQCnP-k.mjs +125 -0
  18. package/dist/sql-contract-serializer-qUQCnP-k.mjs.map +1 -0
  19. package/dist/{timestamp-now-generator-BWp8S2sa.mjs → timestamp-now-generator-r7BP5n3l.mjs} +1 -1
  20. package/dist/{timestamp-now-generator-BWp8S2sa.mjs.map → timestamp-now-generator-r7BP5n3l.mjs.map} +1 -1
  21. package/dist/{types-Da-eOg20.d.mts → types-DMINfGUO.d.mts} +37 -25
  22. package/dist/types-DMINfGUO.d.mts.map +1 -0
  23. package/dist/{verify-pRYxnpiG.mjs → verify-Crewz6hG.mjs} +1 -1
  24. package/dist/{verify-pRYxnpiG.mjs.map → verify-Crewz6hG.mjs.map} +1 -1
  25. package/dist/{verify-sql-schema-DV-UsTG9.mjs → verify-sql-schema-BXw7yx6L.mjs} +53 -7
  26. package/dist/verify-sql-schema-BXw7yx6L.mjs.map +1 -0
  27. package/dist/{verify-sql-schema-CPHiuYHR.d.mts → verify-sql-schema-Bfvz07Ik.d.mts} +14 -2
  28. package/dist/verify-sql-schema-Bfvz07Ik.d.mts.map +1 -0
  29. package/dist/verify.mjs +1 -1
  30. package/package.json +22 -21
  31. package/src/core/control-adapter.ts +14 -0
  32. package/src/core/control-instance.ts +33 -52
  33. package/src/core/ir/sql-contract-serializer-base.ts +136 -0
  34. package/src/core/ir/sql-contract-serializer.ts +18 -0
  35. package/src/core/ir/sql-schema-verifier-base.ts +56 -0
  36. package/src/core/migrations/contract-to-schema-ir.ts +71 -22
  37. package/src/core/migrations/types.ts +25 -5
  38. package/src/core/schema-verify/verify-sql-schema.ts +117 -21
  39. package/src/exports/control.ts +1 -1
  40. package/src/exports/ir.ts +6 -0
  41. package/dist/types-Da-eOg20.d.mts.map +0 -1
  42. package/dist/verify-sql-schema-CPHiuYHR.d.mts.map +0 -1
  43. package/dist/verify-sql-schema-DV-UsTG9.mjs.map +0 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ Provides the SQL family descriptor (`ControlFamilyDescriptor`) that includes:
11
11
  ## Responsibilities
12
12
 
13
13
  - **Family Descriptor Export**: Exports the SQL `ControlFamilyDescriptor` for use in CLI configuration files
14
- - **Family Instance Creation**: Creates `SqlFamilyInstance` objects that implement control-plane domain actions (`verify`, `schemaVerify`, `introspect`, `emitContract`, `validateContract`)
14
+ - **Family Instance Creation**: Creates `SqlFamilyInstance` objects that implement control-plane domain actions (`verify`, `schemaVerify`, `introspect`, `emitContract`, `deserializeContract`)
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
@@ -51,7 +51,7 @@ const stack = createControlStack({
51
51
  const familyInstance = sql.create(stack);
52
52
 
53
53
  // Use instance methods for domain actions
54
- const contract = familyInstance.validateContract(contractJson);
54
+ const contract = familyInstance.deserializeContract(contractJson);
55
55
  const verifyResult = await familyInstance.verify({ driver, contract, ... });
56
56
 
57
57
  // Targets that implement SqlControlTargetDescriptor can build planners
@@ -96,7 +96,7 @@ The framework CLI uses this descriptor to:
96
96
  1. Create family instances for control-plane operations (via `create()`)
97
97
 
98
98
  Family instances implement domain actions:
99
- - **`validateContract(contractJson)`**: Validates and normalizes contract, returns `Contract` without mappings
99
+ - **`deserializeContract(contractJson)`**: Validates and normalizes contract, returns `Contract` without mappings
100
100
  - **`verify()`**: Verifies database marker against contract (compares target, storageHash, profileHash)
101
101
  - **`schemaVerify()`**: Verifies database schema against contract (compares contract requirements vs live schema)
102
102
  - **`introspect()`**: Introspects database schema and returns `SqlSchemaIR`
@@ -108,7 +108,7 @@ The descriptor is "pure data + factory" - it only provides the hook and factory
108
108
  ## Package Structure
109
109
 
110
110
  - **`src/core/control-descriptor.ts`**: `SqlFamilyDescriptor` class implementing `ControlFamilyDescriptor` interface (pure data + factory)
111
- - **`src/core/control-instance.ts`**: `createSqlFamilyInstance` function that creates `SqlFamilyInstance` with domain action methods (`validateContract`, `verify`, `schemaVerify`, `introspect`, `toSchemaView`, `emitContract`). Contains `convertOperationManifest` function used internally by instance creation and test utilities in the same package.
111
+ - **`src/core/control-instance.ts`**: `createSqlFamilyInstance` function that creates `SqlFamilyInstance` with domain action methods (`deserializeContract`, `verify`, `schemaVerify`, `introspect`, `toSchemaView`, `emitContract`). Contains `convertOperationManifest` function used internally by instance creation and test utilities in the same package.
112
112
  - **`src/core/assembly.ts`**: Assembly helpers for extracting type imports, collecting codec-owned storage type control hooks, and composing mutation-default registries with duplicate detection.
113
113
  - **`src/core/verify.ts`**: Verification helpers (`parseContractMarkerRow`, `collectSupportedCodecTypeIds`)
114
114
  - **`src/core/control-adapter.ts`**: SQL control adapter interface (`SqlControlAdapter`) for control-plane operations
@@ -140,7 +140,7 @@ The runner returns structured errors with the following codes:
140
140
 
141
141
  - **`@prisma-next/framework-components`**: Control plane types via `./control` (`ControlFamilyDescriptor`, `ControlTargetDescriptor`, `ControlAdapterDescriptor`, `ControlDriverDescriptor`, `ControlExtensionDescriptor`, `ControlDriverInstance`, etc.)
142
142
  - **`@prisma-next/sql-contract-emitter`**: SQL target family hook (`sqlEmission`)
143
- - **`@prisma-next/sql-contract`**: SQL contract types plus validation (`validateContract`)
143
+ - **`@prisma-next/sql-contract`**: SQL contract types plus validation primitives (`validateSqlContractFully`, consumed by the family serializer base)
144
144
  - **`@prisma-next/sql-operations`**: SQL operation registry types (`SqlOperationEntry`, `SqlOperationRegistry`)
145
145
 
146
146
  **Dependents:**
@@ -1,5 +1,6 @@
1
- import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-CPHiuYHR.mjs";
1
+ import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-Bfvz07Ik.mjs";
2
2
  import { ControlAdapterInstance, ControlDriverInstance, ControlStack } from "@prisma-next/framework-components/control";
3
+ import { PostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
3
4
  import { ContractMarkerRecord } from "@prisma-next/contract/types";
4
5
  import { AnyQueryAst, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
5
6
  import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
@@ -61,6 +62,15 @@ interface SqlControlAdapter<TTarget extends string = string> extends ControlAdap
61
62
  * before comparison with contract native types during schema verification.
62
63
  */
63
64
  readonly normalizeNativeType?: NativeTypeNormalizer;
65
+ /**
66
+ * Optional bridging adapter for resolving the existing values of a
67
+ * native enum type from the introspected schema IR. Targets supply
68
+ * this so the family-level schema verifier can walk
69
+ * `PostgresEnumStorageEntry` entries natively without needing to
70
+ * know the target-specific `schema.annotations` shape
71
+ * (e.g. `schema.annotations.pg.storageTypes`).
72
+ */
73
+ readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry) => readonly string[] | null;
64
74
  /**
65
75
  * Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
66
76
  *
@@ -1 +1 @@
1
- {"version":3,"file":"control-adapter.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"mappings":";;;;;;;;;AAoBA;;;;UAAiB,iBAAA,0CACP,sBAAA,QAA8B,OAAA;EAiB5B;;;;;;;;;;;;;;;EADV,UAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,GACrC,KAAA,WACC,OAAA,CAAQ,oBAAA;EAsDgD;;;;;;;EA7C3D,cAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,IACpC,OAAA,CAAQ,WAAA,SAAoB,oBAAA;EAbrB;;;;;;;;;;;;EA2BV,UAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,GACrC,QAAA,YACA,MAAA,YACC,OAAA,CAAQ,WAAA;EAJX;;;;;EAAA,SAWS,gBAAA,GAAmB,iBAAA;EAPzB;;;;;EAAA,SAcM,mBAAA,GAAsB,oBAAA;EAW/B;;;;;;;;AASF;EATE,KAAA,CAAM,GAAA,EAAK,WAAA,EAAa,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAS5C,2BAAA;EAOf;;;;;;EAAA,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
1
+ {"version":3,"file":"control-adapter.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;AAqBA;;;;UAAiB,iBAAA,0CACP,sBAAA,QAA8B,OAAA;EAiB5B;;;;;;;;;;;;;;;EADV,UAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,GACrC,KAAA,WACC,OAAA,CAAQ,oBAAA;EAmEA;;;;;;;EA1DX,cAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,IACpC,OAAA,CAAQ,WAAA,SAAoB,oBAAA;EA9BO;;;;;;;;;;;;EA4CtC,UAAA,CACE,MAAA,EAAQ,qBAAA,QAA6B,OAAA,GACrC,QAAA,YACA,MAAA,YACC,OAAA,CAAQ,WAAA;EAlBA;;;;;EAAA,SAyBF,gBAAA,GAAmB,iBAAA;EAT1B;;;;;EAAA,SAgBO,mBAAA,GAAsB,oBAAA;EAAtB;;;;;;;;EAAA,SAUA,yBAAA,IACP,MAAA,EAAQ,WAAA,EACR,QAAA,EAAU,wBAAA;EAYN;;;;;;AASR;;;EATE,KAAA,CAAM,GAAA,EAAK,WAAA,EAAa,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAS5C,2BAAA;EAOmB;;;;;;EAAlC,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
@@ -1,10 +1,10 @@
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-Da-eOg20.mjs";
1
+ import { A as SqlPlannerConflictKind, C as SqlMigrationRunnerExecuteCallbacks, D as SqlMigrationRunnerSuccessValue, E as SqlMigrationRunnerResult, F as StorageTypePlanResult, I 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-DMINfGUO.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
+ import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
3
4
  import { NotOk, Ok } from "@prisma-next/utils/result";
4
5
  import { ColumnDefault, Contract } from "@prisma-next/contract/types";
5
6
  import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
6
7
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
7
- import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
8
8
  import { EmissionSpi } from "@prisma-next/framework-components/emission";
9
9
 
10
10
  //#region src/core/control-descriptor.d.ts
@@ -411,5 +411,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
411
411
  //#region src/exports/control.d.ts
412
412
  declare const _default: SqlFamilyDescriptor;
413
413
  //#endregion
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 };
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 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 };
415
415
  //# sourceMappingURL=control.d.mts.map
@@ -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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BAAA,CACd,OAAA,EAAS,6BAAA,CAA8B,cAAA,IACtC,gBAAA,CAAiB,cAAA;AAAA,iBAcJ,cAAA,gBAAA,CACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,IACtB,uBAAA,CAAwB,cAAA;AAAA,iBAOX,cAAA,CAAe,SAAA,WAAoB,kBAAA,KAAuB,uBAAA;;;;iBAoB1D,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAA,CAAG,8BAAA;;;;iBAYS,aAAA,CACd,IAAA,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"}
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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B1D,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAA,CAAG,8BAAA;;;;iBAYS,aAAA,CACd,IAAA,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,15 +1,15 @@
1
1
  import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-F4JpCJl7.mjs";
2
- import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-DV-UsTG9.mjs";
3
- import { t as collectSupportedCodecTypeIds } from "./verify-pRYxnpiG.mjs";
4
- import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-BWp8S2sa.mjs";
2
+ import { t as SqlContractSerializer } from "./sql-contract-serializer-qUQCnP-k.mjs";
3
+ import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-BXw7yx6L.mjs";
4
+ import { t as collectSupportedCodecTypeIds } from "./verify-Crewz6hG.mjs";
5
+ import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-r7BP5n3l.mjs";
5
6
  import { sqlEmission } from "@prisma-next/sql-contract-emitter";
6
- import { emptyCodecLookup } from "@prisma-next/framework-components/codec";
7
7
  import { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
8
8
  import { assertDescriptorSelfConsistency } from "@prisma-next/migration-tools/spaces";
9
- import { validateContract } from "@prisma-next/sql-contract/validate";
10
9
  import { ensureSchemaStatement, ensureTableStatement, writeContractMarker } from "@prisma-next/sql-runtime";
11
10
  import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
12
11
  import { ifDefined } from "@prisma-next/utils/defined";
12
+ import { isPostgresEnumStorageEntry, isStorageTypeInstance, toStorageTypeInstance } from "@prisma-next/sql-contract/types";
13
13
  import { notOk, ok } from "@prisma-next/utils/result";
14
14
  //#region src/core/operation-preview.ts
15
15
  function isDdlStatement(sqlStatement) {
@@ -1097,18 +1097,22 @@ function createSqlFamilyInstance(stack) {
1097
1097
  if (!isSqlControlAdapter(controlAdapter)) throw new Error("Adapter does not implement SqlControlAdapter (missing introspect, readMarker, or readAllMarkers)");
1098
1098
  return controlAdapter;
1099
1099
  };
1100
+ const targetSerializer = target.contractSerializer;
1101
+ const deserializeWithTargetSerializer = (contractJson) => {
1102
+ return (targetSerializer ?? new SqlContractSerializer()).deserializeContract(contractJson);
1103
+ };
1100
1104
  return {
1101
1105
  familyId: "sql",
1102
1106
  codecTypeImports,
1103
1107
  extensionIds,
1104
1108
  typeMetadataRegistry,
1105
- validateContract(contractJson) {
1106
- return validateContract(contractJson, emptyCodecLookup);
1109
+ deserializeContract(contractJson) {
1110
+ return deserializeWithTargetSerializer(contractJson);
1107
1111
  },
1108
1112
  async verify(verifyOptions) {
1109
1113
  const { driver, contract: rawContract, expectedTargetId, contractPath, configPath } = verifyOptions;
1110
1114
  const startTime = Date.now();
1111
- const contract = validateContract(rawContract, emptyCodecLookup);
1115
+ const contract = deserializeWithTargetSerializer(rawContract);
1112
1116
  const contractStorageHash = contract.storage.storageHash;
1113
1117
  const contractProfileHash = contract.profileHash;
1114
1118
  const contractTarget = contract.target;
@@ -1196,23 +1200,8 @@ function createSqlFamilyInstance(stack) {
1196
1200
  ...configPath ? { configPath } : {}
1197
1201
  });
1198
1202
  },
1199
- async schemaVerify(options) {
1200
- const { driver, contract: contractInput, strict, context, frameworkComponents } = options;
1201
- const contract = validateContract(contractInput, emptyCodecLookup);
1202
- const controlAdapter = getControlAdapter();
1203
- return verifySqlSchema({
1204
- contract,
1205
- schema: await controlAdapter.introspect(driver, contractInput),
1206
- strict,
1207
- ...ifDefined("context", context),
1208
- typeMetadataRegistry,
1209
- frameworkComponents,
1210
- ...ifDefined("normalizeDefault", controlAdapter.normalizeDefault),
1211
- ...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType)
1212
- });
1213
- },
1214
- schemaVerifyAgainstSchema(options) {
1215
- const contract = validateContract(options.contract, emptyCodecLookup);
1203
+ verifySchema(options) {
1204
+ const contract = deserializeWithTargetSerializer(options.contract);
1216
1205
  const controlAdapter = getControlAdapter();
1217
1206
  return verifySqlSchema({
1218
1207
  contract,
@@ -1221,13 +1210,14 @@ function createSqlFamilyInstance(stack) {
1221
1210
  typeMetadataRegistry,
1222
1211
  frameworkComponents: options.frameworkComponents,
1223
1212
  ...ifDefined("normalizeDefault", controlAdapter.normalizeDefault),
1224
- ...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType)
1213
+ ...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType),
1214
+ ...ifDefined("resolveExistingEnumValues", controlAdapter.resolveExistingEnumValues)
1225
1215
  });
1226
1216
  },
1227
1217
  async sign(options) {
1228
1218
  const { driver, contract: contractInput, contractPath, configPath } = options;
1229
1219
  const startTime = Date.now();
1230
- const contract = validateContract(contractInput, emptyCodecLookup);
1220
+ const contract = deserializeWithTargetSerializer(contractInput);
1231
1221
  const contractStorageHash = contract.storage.storageHash;
1232
1222
  const contractProfileHash = "profileHash" in contract && typeof contract.profileHash === "string" ? contract.profileHash : contractStorageHash;
1233
1223
  const contractTarget = contract.target;
@@ -1436,11 +1426,17 @@ function resolveColumnTypeMetadata(column, storageTypes) {
1436
1426
  if (!column.typeRef) return column;
1437
1427
  const referenced = storageTypes[column.typeRef];
1438
1428
  if (!referenced) throw new Error(`Column references storage type "${column.typeRef}" but it is not defined in storage.types.`);
1439
- return {
1429
+ if (isPostgresEnumStorageEntry(referenced)) return {
1430
+ codecId: referenced.codecId,
1431
+ nativeType: referenced.nativeType,
1432
+ typeParams: { values: referenced.values }
1433
+ };
1434
+ if (isStorageTypeInstance(referenced)) return {
1440
1435
  codecId: referenced.codecId,
1441
1436
  nativeType: referenced.nativeType,
1442
1437
  typeParams: referenced.typeParams
1443
1438
  };
1439
+ throw new Error(`Storage type "${column.typeRef}" has an unknown polymorphic kind; expected codec-instance or postgres-enum.`);
1444
1440
  }
1445
1441
  function convertUnique(unique) {
1446
1442
  return {
@@ -1550,9 +1546,20 @@ function contractToSchemaIR(contract, options) {
1550
1546
  };
1551
1547
  }
1552
1548
  function deriveAnnotations(storage, annotationNamespace) {
1553
- if (!storage.types || Object.keys(storage.types).length === 0) return void 0;
1549
+ const types = storage.types;
1550
+ if (!types || Object.keys(types).length === 0) return void 0;
1554
1551
  const byNativeType = {};
1555
- for (const typeInstance of Object.values(storage.types)) byNativeType[typeInstance.nativeType] = typeInstance;
1552
+ for (const typeInstance of Object.values(types)) {
1553
+ if (isPostgresEnumStorageEntry(typeInstance)) {
1554
+ byNativeType[typeInstance.nativeType] = toStorageTypeInstance({
1555
+ codecId: typeInstance.codecId,
1556
+ nativeType: typeInstance.nativeType,
1557
+ typeParams: { values: typeInstance.values }
1558
+ });
1559
+ continue;
1560
+ }
1561
+ if (isStorageTypeInstance(typeInstance)) byNativeType[typeInstance.nativeType] = typeInstance;
1562
+ }
1556
1563
  return { [annotationNamespace]: { storageTypes: byNativeType } };
1557
1564
  }
1558
1565
  //#endregion