@prisma-next/family-sql 0.12.0 → 0.13.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/{authoring-type-constructors-F4JpCJl7.mjs → authoring-type-constructors-D4lQ-qpj.mjs} +1 -1
  2. package/dist/{authoring-type-constructors-F4JpCJl7.mjs.map → authoring-type-constructors-D4lQ-qpj.mjs.map} +1 -1
  3. package/dist/control-adapter-CgIL9Vtx.d.mts +182 -0
  4. package/dist/control-adapter-CgIL9Vtx.d.mts.map +1 -0
  5. package/dist/control-adapter.d.mts +2 -109
  6. package/dist/control.d.mts +132 -4
  7. package/dist/control.d.mts.map +1 -1
  8. package/dist/control.mjs +277 -215
  9. package/dist/control.mjs.map +1 -1
  10. package/dist/ir.d.mts +4 -5
  11. package/dist/ir.d.mts.map +1 -1
  12. package/dist/ir.mjs +1 -1
  13. package/dist/migration.d.mts +1 -1
  14. package/dist/migration.d.mts.map +1 -1
  15. package/dist/pack.mjs +1 -1
  16. package/dist/runtime.d.mts +4 -2
  17. package/dist/runtime.d.mts.map +1 -1
  18. package/dist/runtime.mjs +4 -2
  19. package/dist/runtime.mjs.map +1 -1
  20. package/dist/schema-verify.d.mts +2 -1
  21. package/dist/schema-verify.d.mts.map +1 -1
  22. package/dist/schema-verify.mjs +1 -1
  23. package/dist/{sql-contract-serializer-8axtK4lg.mjs → sql-contract-serializer-CY7qnms7.mjs} +18 -36
  24. package/dist/sql-contract-serializer-CY7qnms7.mjs.map +1 -0
  25. package/dist/{timestamp-now-generator-r7BP5n3l.mjs → timestamp-now-generator-CloimujU.mjs} +2 -1
  26. package/dist/{timestamp-now-generator-r7BP5n3l.mjs.map → timestamp-now-generator-CloimujU.mjs.map} +1 -1
  27. package/dist/{types-CeeCStqw.d.mts → types-CbwQCzXY.d.mts} +70 -16
  28. package/dist/types-CbwQCzXY.d.mts.map +1 -0
  29. package/dist/{verify-Crewz6hG.mjs → verify-C-G0obRm.mjs} +1 -1
  30. package/dist/{verify-Crewz6hG.mjs.map → verify-C-G0obRm.mjs.map} +1 -1
  31. package/dist/{verify-sql-schema-CN7pPoTC.d.mts → verify-sql-schema-DcMaT5Zj.d.mts} +1 -1
  32. package/dist/{verify-sql-schema-CN7pPoTC.d.mts.map → verify-sql-schema-DcMaT5Zj.d.mts.map} +1 -1
  33. package/dist/{verify-sql-schema-CYLsGCFO.mjs → verify-sql-schema-DlAgBiT_.mjs} +756 -319
  34. package/dist/verify-sql-schema-DlAgBiT_.mjs.map +1 -0
  35. package/dist/verify.mjs +1 -1
  36. package/package.json +23 -23
  37. package/src/core/control-adapter.ts +116 -7
  38. package/src/core/control-instance.ts +269 -66
  39. package/src/core/default-namespace.ts +9 -0
  40. package/src/core/ir/sql-contract-serializer-base.ts +72 -56
  41. package/src/core/migrations/contract-to-schema-ir.ts +75 -9
  42. package/src/core/migrations/control-policy.ts +322 -0
  43. package/src/core/migrations/field-event-planner.ts +2 -2
  44. package/src/core/migrations/plan-helpers.ts +16 -0
  45. package/src/core/migrations/types.ts +17 -7
  46. package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +8 -6
  47. package/src/core/schema-verify/control-verify-emit.ts +46 -0
  48. package/src/core/schema-verify/verifier-disposition.ts +58 -0
  49. package/src/core/schema-verify/verify-helpers.ts +310 -111
  50. package/src/core/schema-verify/verify-sql-schema.ts +309 -178
  51. package/src/core/timestamp-now-generator.ts +1 -0
  52. package/src/exports/control-adapter.ts +5 -1
  53. package/src/exports/control.ts +7 -0
  54. package/src/exports/runtime.ts +7 -0
  55. package/dist/control-adapter.d.mts.map +0 -1
  56. package/dist/sql-contract-serializer-8axtK4lg.mjs.map +0 -1
  57. package/dist/types-CeeCStqw.d.mts.map +0 -1
  58. package/dist/verify-sql-schema-CYLsGCFO.mjs.map +0 -1
package/dist/ir.d.mts CHANGED
@@ -3,11 +3,10 @@ import { Namespace } from "@prisma-next/framework-components/ir";
3
3
  import { SqlNamespaceTablesInput, SqlStorage, SqlStorageTypeEntry } from "@prisma-next/sql-contract/types";
4
4
  import { Type } from "arktype";
5
5
  import { Contract } from "@prisma-next/contract/types";
6
- import * as _$_prisma_next_contract_hashing0 from "@prisma-next/contract/hashing";
7
6
  import { JsonObject } from "@prisma-next/utils/json";
8
7
 
9
8
  //#region src/core/ir/sql-contract-serializer-base.d.ts
10
- type SqlEntityHydrationFactory = (entry: unknown) => SqlStorageTypeEntry;
9
+ type SqlEntityHydrationFactory = (entry: unknown) => unknown;
11
10
  /**
12
11
  * SQL family `ContractSerializer` abstract base. Carries the SQL-shared
13
12
  * deserialization pipeline:
@@ -33,13 +32,13 @@ type SqlEntityHydrationFactory = (entry: unknown) => SqlStorageTypeEntry;
33
32
  * `serializeContract` directly.
34
33
  */
35
34
  declare abstract class SqlContractSerializerBase<TContract extends Contract<SqlStorage>> implements ContractSerializer<TContract> {
36
- private readonly entityTypeRegistry;
35
+ protected readonly entityTypeRegistry: ReadonlyMap<string, SqlEntityHydrationFactory>;
37
36
  private readonly contractSchema;
38
37
  constructor(entityTypeRegistry?: ReadonlyMap<string, SqlEntityHydrationFactory>, validatorFragments?: ReadonlyMap<string, Type<unknown>>);
39
38
  deserializeContract<T extends TContract = TContract>(json: unknown): T;
40
39
  serializeContract(contract: TContract): JsonObject;
41
- shouldPreserveEmpty: _$_prisma_next_contract_hashing0.PreserveEmptyPredicate;
42
- sortStorage: _$_prisma_next_contract_hashing0.StorageSort;
40
+ shouldPreserveEmpty: import("@prisma-next/contract/hashing").PreserveEmptyPredicate;
41
+ sortStorage: import("@prisma-next/contract/hashing").StorageSort;
43
42
  protected parseSqlContractStructure(json: unknown): Contract<SqlStorage>;
44
43
  protected hydrateSqlStorage(validated: Contract<SqlStorage>): Contract<SqlStorage>;
45
44
  protected hydrateSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | Record<string, unknown>>>): Readonly<Record<string, Namespace>>;
package/dist/ir.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/core/ir/sql-contract-serializer-base.ts","../src/core/ir/sql-contract-serializer.ts","../src/core/ir/sql-schema-verifier-base.ts"],"mappings":";;;;;;;;;KAwCY,yBAAA,IAA6B,KAAA,cAAmB,mBAAmB;;;AAA/E;;;;AAA+E;AA0B/E;;;;;;;;;;;;;;;;;uBAAsB,yBAAA,mBAA4C,QAAA,CAAS,UAAA,cAC9D,kBAAA,CAAmB,SAAA;EAAA,iBAKX,kBAAA;EAAA,iBAHF,cAAA;cAGE,kBAAA,GAAoB,WAAA,SAAoB,yBAAA,GACzD,kBAAA,GAAqB,WAAA,SAAoB,IAAA;EAW3C,mBAAA,WAA8B,SAAA,GAAY,SAAA,CAAA,CAAW,IAAA,YAAgB,CAAA;EAMrE,iBAAA,CAAkB,QAAA,EAAU,SAAA,GAAY,UAAA;EAIxC,mBAAA,EAJkD,gCAAA,CAI/B,sBAAA;EAEnB,WAAA,EAFmB,gCAAA,CAER,WAAA;EAAA,UAED,yBAAA,CAA0B,IAAA,YAAgB,QAAA,CAAS,UAAA;EAAA,UAOnD,iBAAA,CAAkB,SAAA,EAAW,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,UA6C7D,sBAAA,CACR,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA,GAAY,MAAA,sBAC/C,QAAA,CAAS,MAAA,SAAe,SAAA;EAAA,UAcjB,wBAAA,CACR,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EAAA,UAsEL,uBAAA,CAAwB,KAAA,EAAO,mBAAA,GAAsB,mBAAA;EAAA,UAerD,uBAAA,CAAwB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,SAAA;AAAA;;;;;;;;;AAtNrE;;;cC3Ba,qBAAA,SAA8B,yBAAA,CAA0B,QAAA,CAAS,UAAA;;;;;;;;;;;;;AD2B9E;;;;AAA+E;AA0B/E;;;;;;;uBEvCsB,qBAAA,gCACT,cAAA,CAAe,SAAA,EAAW,OAAA;EAErC,YAAA,CAAa,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,IAAW,kBAAA;EF2CzC;;;;;;EAAA,mBE9BJ,qBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;EFiDO;;;;;EAAA,mBE1CA,sBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;AAAA"}
1
+ {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/core/ir/sql-contract-serializer-base.ts","../src/core/ir/sql-contract-serializer.ts","../src/core/ir/sql-schema-verifier-base.ts"],"mappings":";;;;;;;;KA0CY,yBAAA,IAA6B,KAAc;;AAAvD;;;;AAAuD;AA0BvD;;;;;;;;;;;;;;;;;;uBAAsB,yBAAA,mBAA4C,QAAA,CAAS,UAAA,cAC9D,kBAAA,CAAmB,SAAA;EAAA,mBAKT,kBAAA,EAAoB,WAAA,SAErC,yBAAA;EAAA,iBALa,cAAA;cAGI,kBAAA,GAAoB,WAAA,SAErC,yBAAA,GAEF,kBAAA,GAAqB,WAAA,SAAoB,IAAA;EAW3C,mBAAA,WAA8B,SAAA,GAAY,SAAA,EAAW,IAAA,YAAgB,CAAA;EAMrE,iBAAA,CAAkB,QAAA,EAAU,SAAA,GAAY,UAAA;EAIxC,mBAAA,0CAAmB,sBAAA;EAEnB,WAAA,0CAAW,WAAA;EAAA,UAED,yBAAA,CAA0B,IAAA,YAAgB,QAAA,CAAS,UAAA;EAAA,UAOnD,iBAAA,CAAkB,SAAA,EAAW,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,UA6C7D,sBAAA,CACR,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA,GAAY,MAAA,sBAC/C,QAAA,CAAS,MAAA,SAAe,SAAA;EAAA,UAmBjB,wBAAA,CACR,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EAAA,UAyEL,uBAAA,CAAwB,KAAA,EAAO,mBAAA,GAAsB,mBAAA;EAAA,UAkBrD,uBAAA,CAAwB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,SAAA;AAAA;;;;;;;;AApOrE;;;;cC7Ba,qBAAA,SAA8B,yBAAA,CAA0B,QAAA,CAAS,UAAA;;;;;;;;;;;;AD6B9E;;;;AAAuD;AA0BvD;;;;;;;;uBEzCsB,qBAAA,gCACT,cAAA,CAAe,SAAA,EAAW,OAAA;EAErC,YAAA,CAAa,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,IAAW,kBAAA;EFgDrB;;;;;;EAAA,mBEnCxB,qBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;EF0DiD;;;;;EAAA,mBEnD1C,sBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;AAAA"}
package/dist/ir.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as SqlContractSerializerBase, t as SqlContractSerializer } from "./sql-contract-serializer-8axtK4lg.mjs";
1
+ import { n as SqlContractSerializerBase, t as SqlContractSerializer } from "./sql-contract-serializer-CY7qnms7.mjs";
2
2
  //#region src/core/ir/sql-schema-verifier-base.ts
3
3
  /**
4
4
  * SQL family `SchemaVerifier` abstract base. Centralises the SQL-shared
@@ -1,4 +1,4 @@
1
- import { T as SqlPlanTargetDetails, p as SqlMigrationPlanOperation } from "./types-CeeCStqw.mjs";
1
+ import { T as SqlPlanTargetDetails, p as SqlMigrationPlanOperation } from "./types-CbwQCzXY.mjs";
2
2
  import { Migration } from "@prisma-next/migration-tools/migration";
3
3
 
4
4
  //#region src/core/sql-migration.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/sql-migration.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;uBAAsB,YAAA,kBACH,oBAAA,6CAET,SAAA,CAAU,yBAAA,CAA0B,QAAA,UAAkB,SAAA;EAAtD;;;;;;AAWc;;;;EAXd,IAWJ,kBAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/sql-migration.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;uBAAsB,YAAA,kBACH,oBAAA,6CAET,SAAA,CAAU,yBAAA,CAA0B,QAAA,UAAkB,SAAA;EAAtD;;;;;;AAWc;;;;EAXd,IAWJ,kBAAA;AAAA"}
package/dist/pack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-F4JpCJl7.mjs";
1
+ import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-D4lQ-qpj.mjs";
2
2
  //#region src/exports/pack.ts
3
3
  const sqlFamilyPack = {
4
4
  kind: "family",
@@ -1,5 +1,7 @@
1
- import { RuntimeMutationDefaultGenerator } from "@prisma-next/sql-runtime";
1
+ import { ResolvedDomainModel, UNBOUND_DOMAIN_NAMESPACE_ID, resolveDomainModel } from "@prisma-next/contract/types";
2
+ import { ResolvedStorageTable, resolveStorageTable } from "@prisma-next/sql-contract/resolve-storage-table";
2
3
  import { RuntimeFamilyDescriptor, RuntimeFamilyInstance } from "@prisma-next/framework-components/execution";
4
+ import { RuntimeMutationDefaultGenerator } from "@prisma-next/sql-runtime";
3
5
 
4
6
  //#region src/core/runtime-instance.d.ts
5
7
  /**
@@ -40,5 +42,5 @@ declare const sqlRuntimeFamilyDescriptor: RuntimeFamilyDescriptor<'sql', SqlRunt
40
42
  */
41
43
  declare function timestampNowRuntimeGenerator(): RuntimeMutationDefaultGenerator;
42
44
  //#endregion
43
- export { sqlRuntimeFamilyDescriptor as default, timestampNowRuntimeGenerator };
45
+ export { type ResolvedDomainModel, type ResolvedStorageTable, UNBOUND_DOMAIN_NAMESPACE_ID, sqlRuntimeFamilyDescriptor as default, resolveDomainModel, resolveStorageTable, timestampNowRuntimeGenerator };
44
46
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-instance.ts","../src/core/runtime-descriptor.ts","../src/core/timestamp-now-runtime-generator.ts"],"mappings":";;;;;;;AAUA;;;;AAAuE;UAAtD,wBAAA,SAAiC,qBAAqB;;;;;AAAvE;;;;AAAuE;;cCC1D,0BAAA,EAA4B,uBAAuB,QAAQ,wBAAA;;;;;;ADDxE;;;;AAAuE;;;;ACCvE;;;iBCMgB,4BAAA,CAAA,GAAgC,+BAA+B"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-instance.ts","../src/core/runtime-descriptor.ts","../src/core/timestamp-now-runtime-generator.ts"],"mappings":";;;;;;;;;;;AAUA;;;UAAiB,wBAAA,SAAiC,qBAAqB;;;;;;;AAAvE;;;;cCCa,0BAAA,EAA4B,uBAAuB,QAAQ,wBAAA;;;;;;;;ADDxE;;;;AAAuE;;;;ACCvE;iBCMgB,4BAAA,IAAgC,+BAA+B"}
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { t as TIMESTAMP_NOW_GENERATOR_ID } from "./timestamp-now-generator-r7BP5n3l.mjs";
1
+ import { t as TIMESTAMP_NOW_GENERATOR_ID } from "./timestamp-now-generator-CloimujU.mjs";
2
+ import { UNBOUND_DOMAIN_NAMESPACE_ID, resolveDomainModel } from "@prisma-next/contract/types";
3
+ import { resolveStorageTable } from "@prisma-next/sql-contract/resolve-storage-table";
2
4
  //#region src/core/runtime-instance.ts
3
5
  /**
4
6
  * Creates a SQL execution-plane family instance.
@@ -55,6 +57,6 @@ function timestampNowRuntimeGenerator() {
55
57
  //#region src/exports/runtime.ts
56
58
  var runtime_default = sqlRuntimeFamilyDescriptor;
57
59
  //#endregion
58
- export { runtime_default as default, timestampNowRuntimeGenerator };
60
+ export { UNBOUND_DOMAIN_NAMESPACE_ID, runtime_default as default, resolveDomainModel, resolveStorageTable, timestampNowRuntimeGenerator };
59
61
 
60
62
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/core/runtime-instance.ts","../src/core/runtime-descriptor.ts","../src/core/timestamp-now-runtime-generator.ts","../src/exports/runtime.ts"],"sourcesContent":["import type { RuntimeFamilyInstance } from '@prisma-next/framework-components/execution';\n\n/**\n * SQL execution-plane family instance interface.\n *\n * Note: this is currently named `SqlRuntimeFamilyInstance` because the execution plane\n * framework types are still using the `Runtime*` naming (`RuntimeFamilyInstance`, etc.).\n *\n * This will be renamed to `SqlExecutionFamilyInstance` as part of `TML-1842`.\n */\nexport interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {}\n\n/**\n * Creates a SQL execution-plane family instance.\n *\n * This will be renamed to `createSqlExecutionFamilyInstance()` as part of `TML-1842`.\n */\nexport function createSqlRuntimeFamilyInstance(): SqlRuntimeFamilyInstance {\n return {\n familyId: 'sql' as const,\n };\n}\n","import type { RuntimeFamilyDescriptor } from '@prisma-next/framework-components/execution';\nimport { createSqlRuntimeFamilyInstance, type SqlRuntimeFamilyInstance } from './runtime-instance';\n\n/**\n * SQL execution-plane family descriptor.\n *\n * Note: this is currently named `sqlRuntimeFamilyDescriptor` because the execution plane\n * framework types are still using the `Runtime*` naming (`RuntimeFamilyDescriptor`, etc.).\n *\n * This will be renamed to `sqlExecutionFamilyDescriptor` as part of `TML-1842`.\n */\nexport const sqlRuntimeFamilyDescriptor: RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance> =\n {\n kind: 'family',\n id: 'sql',\n familyId: 'sql',\n version: '0.0.1',\n create() {\n return createSqlRuntimeFamilyInstance();\n },\n };\n\nObject.freeze(sqlRuntimeFamilyDescriptor);\n","import type { RuntimeMutationDefaultGenerator } from '@prisma-next/sql-runtime';\nimport { TIMESTAMP_NOW_GENERATOR_ID } from './timestamp-now-generator';\n\n/**\n * Builds the canonical runtime-plane generator for the wall-clock-now\n * mutation default. Returns `new Date()`; semantics are target-agnostic\n * so all SQL targets share this single implementation.\n *\n * Declares `stability: 'query'` so a single ORM bulk operation\n * (e.g. `createAll([...])`) shares one timestamp across every row and\n * every timestamp-defaulted column. Matches Prisma 6's `@updatedAt`\n * semantics: one `new Date()` per lowered mutation, not per row.\n *\n * Lives in a runtime-plane-only module so the control-plane\n * `timestamp-now-generator.ts` (descriptor + authoring presets) stays\n * free of `@prisma-next/sql-runtime` imports.\n */\nexport function timestampNowRuntimeGenerator(): RuntimeMutationDefaultGenerator {\n return {\n id: TIMESTAMP_NOW_GENERATOR_ID,\n generate: () => new Date(),\n stability: 'query',\n };\n}\n","import { sqlRuntimeFamilyDescriptor } from '../core/runtime-descriptor';\n\nexport { timestampNowRuntimeGenerator } from '../core/timestamp-now-runtime-generator';\n\nexport default sqlRuntimeFamilyDescriptor;\n"],"mappings":";;;;;;;AAiBA,SAAgB,iCAA2D;CACzE,OAAO,EACL,UAAU,MACZ;AACF;;;;;;;;;;;ACVA,MAAa,6BACX;CACE,MAAM;CACN,IAAI;CACJ,UAAU;CACV,SAAS;CACT,SAAS;EACP,OAAO,+BAA+B;CACxC;AACF;AAEF,OAAO,OAAO,0BAA0B;;;;;;;;;;;;;;;;;ACLxC,SAAgB,+BAAgE;CAC9E,OAAO;EACL,IAAI;EACJ,gCAAgB,IAAI,KAAK;EACzB,WAAW;CACb;AACF;;;ACnBA,IAAA,kBAAe"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/core/runtime-instance.ts","../src/core/runtime-descriptor.ts","../src/core/timestamp-now-runtime-generator.ts","../src/exports/runtime.ts"],"sourcesContent":["import type { RuntimeFamilyInstance } from '@prisma-next/framework-components/execution';\n\n/**\n * SQL execution-plane family instance interface.\n *\n * Note: this is currently named `SqlRuntimeFamilyInstance` because the execution plane\n * framework types are still using the `Runtime*` naming (`RuntimeFamilyInstance`, etc.).\n *\n * This will be renamed to `SqlExecutionFamilyInstance` as part of `TML-1842`.\n */\nexport interface SqlRuntimeFamilyInstance extends RuntimeFamilyInstance<'sql'> {}\n\n/**\n * Creates a SQL execution-plane family instance.\n *\n * This will be renamed to `createSqlExecutionFamilyInstance()` as part of `TML-1842`.\n */\nexport function createSqlRuntimeFamilyInstance(): SqlRuntimeFamilyInstance {\n return {\n familyId: 'sql' as const,\n };\n}\n","import type { RuntimeFamilyDescriptor } from '@prisma-next/framework-components/execution';\nimport { createSqlRuntimeFamilyInstance, type SqlRuntimeFamilyInstance } from './runtime-instance';\n\n/**\n * SQL execution-plane family descriptor.\n *\n * Note: this is currently named `sqlRuntimeFamilyDescriptor` because the execution plane\n * framework types are still using the `Runtime*` naming (`RuntimeFamilyDescriptor`, etc.).\n *\n * This will be renamed to `sqlExecutionFamilyDescriptor` as part of `TML-1842`.\n */\nexport const sqlRuntimeFamilyDescriptor: RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance> =\n {\n kind: 'family',\n id: 'sql',\n familyId: 'sql',\n version: '0.0.1',\n create() {\n return createSqlRuntimeFamilyInstance();\n },\n };\n\nObject.freeze(sqlRuntimeFamilyDescriptor);\n","import type { RuntimeMutationDefaultGenerator } from '@prisma-next/sql-runtime';\nimport { TIMESTAMP_NOW_GENERATOR_ID } from './timestamp-now-generator';\n\n/**\n * Builds the canonical runtime-plane generator for the wall-clock-now\n * mutation default. Returns `new Date()`; semantics are target-agnostic\n * so all SQL targets share this single implementation.\n *\n * Declares `stability: 'query'` so a single ORM bulk operation\n * (e.g. `createAll([...])`) shares one timestamp across every row and\n * every timestamp-defaulted column. Matches Prisma 6's `@updatedAt`\n * semantics: one `new Date()` per lowered mutation, not per row.\n *\n * Lives in a runtime-plane-only module so the control-plane\n * `timestamp-now-generator.ts` (descriptor + authoring presets) stays\n * free of `@prisma-next/sql-runtime` imports.\n */\nexport function timestampNowRuntimeGenerator(): RuntimeMutationDefaultGenerator {\n return {\n id: TIMESTAMP_NOW_GENERATOR_ID,\n generate: () => new Date(),\n stability: 'query',\n };\n}\n","import { sqlRuntimeFamilyDescriptor } from '../core/runtime-descriptor';\n\nexport {\n type ResolvedDomainModel,\n type ResolvedStorageTable,\n resolveDomainModel,\n resolveStorageTable,\n UNBOUND_DOMAIN_NAMESPACE_ID,\n} from '../core/default-namespace';\nexport { timestampNowRuntimeGenerator } from '../core/timestamp-now-runtime-generator';\n\nexport default sqlRuntimeFamilyDescriptor;\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,iCAA2D;CACzE,OAAO,EACL,UAAU,MACZ;AACF;;;;;;;;;;;ACVA,MAAa,6BACX;CACE,MAAM;CACN,IAAI;CACJ,UAAU;CACV,SAAS;CACT,SAAS;EACP,OAAO,+BAA+B;CACxC;AACF;AAEF,OAAO,OAAO,0BAA0B;;;;;;;;;;;;;;;;;ACLxC,SAAgB,+BAAgE;CAC9E,OAAO;EACL,IAAI;EACJ,gCAAgB,IAAI,KAAK;EACzB,WAAW;CACb;AACF;;;ACZA,IAAA,kBAAe"}
@@ -1,5 +1,6 @@
1
- import { i as verifySqlSchema, n as NativeTypeNormalizer, r as VerifySqlSchemaOptions } from "./verify-sql-schema-CN7pPoTC.mjs";
1
+ import { i as verifySqlSchema, n as NativeTypeNormalizer, r as VerifySqlSchemaOptions } from "./verify-sql-schema-DcMaT5Zj.mjs";
2
2
  import { SchemaIssue } from "@prisma-next/framework-components/control";
3
+ import { ControlPolicy } from "@prisma-next/contract/types";
3
4
  import { SqlIndexIR, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
4
5
 
5
6
  //#region src/core/schema-verify/verify-helpers.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"schema-verify.d.mts","names":[],"sources":["../src/core/schema-verify/verify-helpers.ts"],"mappings":";;;;;;;;iBAsDgB,WAAA,CAAY,CAAA,qBAAsB,CAAoB;AA+BtE;;;;;;;;;;AAG4B;AAuB5B;AA1BA,iBAAgB,2BAAA,CACd,OAAA,WAAkB,WAAA,IAClB,OAAA,WAAkB,UAAU,IAC5B,OAAA;;;;;;;;;AA0B0B;;;;iBAHZ,gBAAA,CACd,OAAA,WAAkB,UAAA,IAClB,OAAA,WAAkB,WAAW,IAC7B,OAAA"}
1
+ {"version":3,"file":"schema-verify.d.mts","names":[],"sources":["../src/core/schema-verify/verify-helpers.ts"],"mappings":";;;;;;;;;iBAgEgB,WAAA,CAAY,CAAA,qBAAsB,CAAoB;AA+BtE;;;;;;;;;;AAG4B;AAuB5B;AA1BA,iBAAgB,2BAAA,CACd,OAAA,WAAkB,WAAA,IAClB,OAAA,WAAkB,UAAU,IAC5B,OAAA;;;;;;;;;AA0B0B;;;;iBAHZ,gBAAA,CACd,OAAA,WAAkB,UAAA,IAClB,OAAA,WAAkB,WAAW,IAC7B,OAAA"}
@@ -1,2 +1,2 @@
1
- import { i as isUniqueConstraintSatisfied, n as arraysEqual, r as isIndexSatisfied, t as verifySqlSchema } from "./verify-sql-schema-CYLsGCFO.mjs";
1
+ import { i as isUniqueConstraintSatisfied, n as arraysEqual, r as isIndexSatisfied, t as verifySqlSchema } from "./verify-sql-schema-DlAgBiT_.mjs";
2
2
  export { arraysEqual, isIndexSatisfied, isUniqueConstraintSatisfied, verifySqlSchema };
@@ -2,7 +2,7 @@ import { sqlContractCanonicalizationHooks } from "@prisma-next/sql-contract/cano
2
2
  import { ifDefined } from "@prisma-next/utils/defined";
3
3
  import { ContractValidationError } from "@prisma-next/contract/contract-validation-error";
4
4
  import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
- import { SqlStorage, SqlUnboundNamespace, StorageTable, buildSqlNamespace } from "@prisma-next/sql-contract/types";
5
+ import { SqlStorage, SqlUnboundNamespace, StorageTable, StorageValueSet, buildSqlNamespace } from "@prisma-next/sql-contract/types";
6
6
  import { createSqlContractSchema, validateSqlContractFully } from "@prisma-next/sql-contract/validators";
7
7
  import { blindCast } from "@prisma-next/utils/casts";
8
8
  import { type } from "arktype";
@@ -10,7 +10,7 @@ import { type } from "arktype";
10
10
  const NamespaceRawSchema = type({
11
11
  id: "string",
12
12
  "kind?": "string",
13
- "+": "ignore"
13
+ entries: type({ "+": "ignore" })
14
14
  });
15
15
  function isPlainRecord(value) {
16
16
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -81,50 +81,32 @@ var SqlContractSerializerBase = class {
81
81
  hydrateSqlNamespaceMap(namespaces) {
82
82
  return Object.fromEntries(Object.entries(namespaces).map(([nsId, namespaceEntryRaw]) => {
83
83
  const namespaceHydrated = this.hydrateSqlNamespaceEntry(nsId, namespaceEntryRaw);
84
- return [nsId, namespaceHydrated instanceof NamespaceBase ? namespaceHydrated : buildSqlNamespace(namespaceHydrated)];
84
+ return [nsId, namespaceHydrated instanceof NamespaceBase ? namespaceHydrated : buildSqlNamespace(blindCast(namespaceHydrated))];
85
85
  }));
86
86
  }
87
87
  hydrateSqlNamespaceEntry(nsId, raw) {
88
88
  if (raw instanceof NamespaceBase) return raw;
89
89
  const rawRecord = isPlainRecord(raw) ? raw : {};
90
+ if (Object.hasOwn(rawRecord, "tables") || Object.hasOwn(rawRecord, "enum") || Object.hasOwn(rawRecord, "collections")) throw new ContractValidationError("Namespace envelope uses deprecated flat slot keys; expected `entries: { table? }`", "structural");
90
91
  const id = typeof rawRecord["id"] === "string" ? rawRecord["id"] : nsId;
91
92
  const parsed = NamespaceRawSchema({
92
93
  ...rawRecord,
93
94
  id
94
95
  });
95
96
  if (parsed instanceof type.errors) throw new ContractValidationError(`Namespace hydration failed: ${parsed.map((p) => p.message).join("; ")}`, "structural");
96
- const result = { id };
97
- for (const [propertyKey, slotValue] of Object.entries(parsed)) {
98
- if (propertyKey === "id") continue;
99
- if (slotValue === null || typeof slotValue !== "object") continue;
100
- if (propertyKey === "tables") {
101
- result["tables"] = Object.fromEntries(Object.entries(slotValue).map(([tableName, table]) => [tableName, table instanceof StorageTable ? table : new StorageTable(table)]));
102
- continue;
103
- }
104
- const hydratedSlot = Object.fromEntries(Object.entries(slotValue).map(([entryName, entry]) => {
105
- if (typeof entry !== "object" || entry === null) return [entryName, entry];
106
- const kind = entry.kind;
107
- if (typeof kind === "string") {
108
- const factory = this.entityTypeRegistry.get(kind);
109
- if (factory !== void 0) return [entryName, factory(entry)];
110
- }
111
- return [entryName, entry];
112
- }));
113
- if (Object.keys(hydratedSlot).length > 0) result[propertyKey] = hydratedSlot;
97
+ const entriesInput = { table: {} };
98
+ const entriesRaw = parsed.entries;
99
+ if (entriesRaw !== void 0 && typeof entriesRaw === "object" && entriesRaw !== null) {
100
+ const rawEntries = entriesRaw;
101
+ const tableSlot = rawEntries["table"];
102
+ if (tableSlot !== null && typeof tableSlot === "object" && !Array.isArray(tableSlot)) entriesInput.table = Object.fromEntries(Object.entries(tableSlot).map(([tableName, table]) => [tableName, table instanceof StorageTable ? table : new StorageTable(table)]));
103
+ const valueSetSlot = rawEntries["valueSet"];
104
+ if (valueSetSlot !== null && typeof valueSetSlot === "object" && !Array.isArray(valueSetSlot)) entriesInput.valueSet = Object.fromEntries(Object.entries(blindCast(valueSetSlot)).map(([vsName, vs]) => [vsName, vs instanceof StorageValueSet ? vs : new StorageValueSet(blindCast(vs))]));
114
105
  }
115
- const enumRaw = rawRecord["enum"];
116
- if (enumRaw !== void 0 && typeof enumRaw === "object" && enumRaw !== null) for (const entry of Object.values(enumRaw)) {
117
- if (typeof entry !== "object" || entry === null) continue;
118
- const kind = entry.kind;
119
- if (typeof kind === "string" && this.entityTypeRegistry.get(kind) === void 0) throw new ContractValidationError(`Entry kind '${kind}' has no registered hydration factory.`, "structural");
120
- }
121
- const tables = result["tables"] ?? {};
122
- const enumSlot = result["enum"];
123
- return {
124
- ...result,
125
- tables,
126
- ...enumSlot !== void 0 ? { enum: enumSlot } : {}
127
- };
106
+ return blindCast({
107
+ id,
108
+ entries: entriesInput
109
+ });
128
110
  }
129
111
  hydrateStorageTypeEntry(entry) {
130
112
  if (typeof entry !== "object" || entry === null) return entry;
@@ -132,7 +114,7 @@ var SqlContractSerializerBase = class {
132
114
  if (typeof kind !== "string") return entry;
133
115
  const factory = this.entityTypeRegistry.get(kind);
134
116
  if (factory === void 0) return entry;
135
- return factory(entry);
117
+ return blindCast(factory(entry));
136
118
  }
137
119
  constructTargetContract(hydrated) {
138
120
  return hydrated;
@@ -157,4 +139,4 @@ var SqlContractSerializer = class extends SqlContractSerializerBase {
157
139
  //#endregion
158
140
  export { SqlContractSerializerBase as n, SqlContractSerializer as t };
159
141
 
160
- //# sourceMappingURL=sql-contract-serializer-8axtK4lg.mjs.map
142
+ //# sourceMappingURL=sql-contract-serializer-CY7qnms7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-contract-serializer-CY7qnms7.mjs","names":[],"sources":["../src/core/ir/sql-contract-serializer-base.ts","../src/core/ir/sql-contract-serializer.ts"],"sourcesContent":["import { ContractValidationError } from '@prisma-next/contract/contract-validation-error';\nimport type { Contract } from '@prisma-next/contract/types';\nimport type { ContractSerializer } from '@prisma-next/framework-components/control';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { sqlContractCanonicalizationHooks } from '@prisma-next/sql-contract/canonicalization-hooks';\nimport {\n buildSqlNamespace,\n type SqlNamespaceTablesInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n SqlUnboundNamespace,\n StorageTable,\n type StorageTableInput,\n StorageValueSet,\n type StorageValueSetInput,\n} from '@prisma-next/sql-contract/types';\nimport {\n createSqlContractSchema,\n validateSqlContractFully,\n} from '@prisma-next/sql-contract/validators';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { type Type, type } from 'arktype';\n\nconst NamespaceRawSchema = type({\n id: 'string',\n 'kind?': 'string',\n entries: type({\n '+': 'ignore',\n }),\n});\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport type SqlEntityHydrationFactory = (entry: unknown) => unknown;\n\n/**\n * SQL family `ContractSerializer` abstract base. Carries the SQL-shared\n * deserialization pipeline:\n *\n * 1. `parseSqlContractStructure` validates the on-disk JSON envelope\n * against the SQL contract arktype schema (`validateSqlContractFully`)\n * and returns the validated flat-data shape.\n * 2. `hydrateSqlStorage` walks the validated `storage` subtree and\n * constructs the family-shared SQL Contract IR class hierarchy\n * (`SqlStorage` -> `StorageTable` -> `StorageColumn` / `PrimaryKey`\n * / …). The rest of the contract envelope is JSON-clean primitive\n * data and passes through unchanged.\n * 3. `constructTargetContract` is the target-specific extension hook;\n * defaults to identity. Targets that need to attach target-only\n * fields (e.g. target-specific derived storage fields) override it.\n *\n * Default `serializeContract` is identity over the contract — concrete\n * SQL targets ship JSON-clean class instances, so the contract value\n * can be stringified directly. The non-enumerable family-level `kind`\n * discriminator on `SqlNode` instances stays out of the persisted\n * envelope automatically. Targets that need to canonicalize on the way\n * out (key ordering, dropping computed-only fields) override\n * `serializeContract` directly.\n */\nexport abstract class SqlContractSerializerBase<TContract extends Contract<SqlStorage>>\n implements ContractSerializer<TContract>\n{\n private readonly contractSchema: Type<unknown> | undefined;\n\n constructor(\n protected readonly entityTypeRegistry: ReadonlyMap<\n string,\n SqlEntityHydrationFactory\n > = new Map(),\n validatorFragments?: ReadonlyMap<string, Type<unknown>>,\n ) {\n // Only build a fragments-aware contract schema when pack contributions\n // exist. The cached module-level default in `validators.ts` covers the\n // no-contributions case and avoids per-instance schema compilation.\n this.contractSchema =\n validatorFragments !== undefined && validatorFragments.size > 0\n ? createSqlContractSchema(validatorFragments)\n : undefined;\n }\n\n deserializeContract<T extends TContract = TContract>(json: unknown): T {\n const validated = this.parseSqlContractStructure(json);\n const hydrated = this.hydrateSqlStorage(validated);\n return this.constructTargetContract(hydrated) as T;\n }\n\n serializeContract(contract: TContract): JsonObject {\n return contract as unknown as JsonObject;\n }\n\n shouldPreserveEmpty = sqlContractCanonicalizationHooks.shouldPreserveEmpty;\n\n sortStorage = sqlContractCanonicalizationHooks.sortStorage;\n\n protected parseSqlContractStructure(json: unknown): Contract<SqlStorage> {\n return validateSqlContractFully<Contract<SqlStorage>>(\n json,\n this.contractSchema !== undefined ? { contractSchema: this.contractSchema } : undefined,\n );\n }\n\n protected hydrateSqlStorage(validated: Contract<SqlStorage>): Contract<SqlStorage> {\n const types = validated.storage.types;\n const hydratedTypes =\n types !== undefined\n ? Object.fromEntries(\n Object.entries(types).map(([name, entry]) => [\n name,\n this.hydrateStorageTypeEntry(entry),\n ]),\n )\n : undefined;\n\n const rawNamespaces = validated.storage.namespaces;\n if (rawNamespaces === undefined) {\n throw new ContractValidationError(\n 'Contract storage.namespaces is required after structural validation',\n 'structural',\n );\n }\n const hydratedNamespaces = this.hydrateSqlNamespaceMap(rawNamespaces);\n // Compatibility shim: production code that addresses `__unbound__` for table\n // metadata lookups (collection-contract, query-plan-mutations, model-accessor,\n // query-plan-meta, where-binding) uses optional chaining and tolerates absence,\n // but runtime-qualification (TML-2605) has not yet landed cross-namespace table\n // routing. Injecting the empty singleton here keeps helpers that augment the\n // deserialized JSON (e.g. buildMixedPolyContract) working by providing a slot to\n // write into. Once runtime-qualification routes table lookups by namespace, this\n // shim should be removed.\n const unbound = hydratedNamespaces[UNBOUND_NAMESPACE_ID] ?? SqlUnboundNamespace.instance;\n\n return {\n ...validated,\n storage: new SqlStorage({\n storageHash: validated.storage.storageHash,\n ...ifDefined('types', hydratedTypes),\n // Cast narrows the result of hydrateSqlNamespaceMap from the wider\n // framework `Namespace` to the SQL-family `SqlNamespace`.\n namespaces: blindCast<\n SqlStorageInput['namespaces'],\n 'hydrated SQL namespaces are SqlNamespace instances (family hydration guarantees this)'\n >({ ...hydratedNamespaces, [UNBOUND_NAMESPACE_ID]: unbound }),\n }),\n };\n }\n\n protected hydrateSqlNamespaceMap(\n namespaces: Readonly<Record<string, Namespace | Record<string, unknown>>>,\n ): Readonly<Record<string, Namespace>> {\n return Object.fromEntries(\n Object.entries(namespaces).map(([nsId, namespaceEntryRaw]) => {\n // Raw entries passed structural validation; hydrate materialises family IR class instances.\n const namespaceHydrated = this.hydrateSqlNamespaceEntry(nsId, namespaceEntryRaw);\n const namespaceMaterialised =\n namespaceHydrated instanceof NamespaceBase\n ? namespaceHydrated\n : buildSqlNamespace(\n blindCast<\n SqlNamespaceTablesInput,\n 'hydrateSqlNamespaceEntry returns SqlNamespaceTablesInput when raw is not a NamespaceBase'\n >(namespaceHydrated),\n );\n return [nsId, namespaceMaterialised];\n }),\n );\n }\n\n protected hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const rawRecord = isPlainRecord(raw) ? raw : {};\n if (\n Object.hasOwn(rawRecord, 'tables') ||\n Object.hasOwn(rawRecord, 'enum') ||\n Object.hasOwn(rawRecord, 'collections')\n ) {\n throw new ContractValidationError(\n 'Namespace envelope uses deprecated flat slot keys; expected `entries: { table? }`',\n 'structural',\n );\n }\n const id = typeof rawRecord['id'] === 'string' ? rawRecord['id'] : nsId;\n const parsed = NamespaceRawSchema({ ...rawRecord, id });\n if (parsed instanceof type.errors) {\n const messages = parsed.map((p: { message: string }) => p.message).join('; ');\n throw new ContractValidationError(`Namespace hydration failed: ${messages}`, 'structural');\n }\n // Default to empty table; overwritten below if raw entries carry a table slot.\n const entriesInput: {\n table: Record<string, StorageTable>;\n valueSet?: Record<string, StorageValueSet>;\n } = { table: {} };\n const entriesRaw = parsed.entries;\n if (entriesRaw !== undefined && typeof entriesRaw === 'object' && entriesRaw !== null) {\n const rawEntries = entriesRaw as Record<string, unknown>;\n const tableSlot = rawEntries['table'];\n if (tableSlot !== null && typeof tableSlot === 'object' && !Array.isArray(tableSlot)) {\n entriesInput.table = Object.fromEntries(\n Object.entries(tableSlot as Record<string, unknown>).map(([tableName, table]) => [\n tableName,\n table instanceof StorageTable ? table : new StorageTable(table as StorageTableInput),\n ]),\n );\n }\n const valueSetSlot = rawEntries['valueSet'];\n if (\n valueSetSlot !== null &&\n typeof valueSetSlot === 'object' &&\n !Array.isArray(valueSetSlot)\n ) {\n entriesInput.valueSet = Object.fromEntries(\n Object.entries(\n blindCast<\n Record<string, unknown>,\n 'valueSet slot is a plain record after object check'\n >(valueSetSlot),\n ).map(([vsName, vs]) => [\n vsName,\n vs instanceof StorageValueSet\n ? vs\n : new StorageValueSet(\n blindCast<\n StorageValueSetInput,\n 'non-instance valueSet entry is StorageValueSetInput'\n >(vs),\n ),\n ]),\n );\n }\n // Target-specific slots (e.g. postgres `type`) are left for target\n // overrides to extract from the original `raw` parameter.\n }\n\n return blindCast<SqlNamespaceTablesInput, 'hydrated namespace tables input'>({\n id,\n entries: entriesInput,\n });\n }\n\n protected hydrateStorageTypeEntry(entry: SqlStorageTypeEntry): SqlStorageTypeEntry {\n if (typeof entry !== 'object' || entry === null) {\n return entry;\n }\n const kind = (entry as { kind?: unknown }).kind;\n if (typeof kind !== 'string') {\n return entry;\n }\n const factory = this.entityTypeRegistry.get(kind);\n if (factory === undefined) {\n return entry;\n }\n return blindCast<\n SqlStorageTypeEntry,\n 'entity registry factory returns SqlStorageTypeEntry for storage.types entries'\n >(factory(entry));\n }\n\n protected constructTargetContract(hydrated: Contract<SqlStorage>): TContract {\n return hydrated as TContract;\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SqlContractSerializerBase } from './sql-contract-serializer-base';\n\n/**\n * Default SQL family `ContractSerializer` concretion. Inherits the\n * full SQL-shared deserialization pipeline (structural validation +\n * IR-class hydration) without pack-registered `storage.types`\n * hydration factories — targets that emit polymorphic JSON outside the\n * codec-typed envelope wire a target-specific subclass with a populated\n * registry (see Postgres). Family-level call sites instantiate this\n * default directly when no target serializer is supplied.\n */\nexport class SqlContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(new Map());\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,qBAAqB,KAAK;CAC9B,IAAI;CACJ,SAAS;CACT,SAAS,KAAK,EACZ,KAAK,SACP,CAAC;AACH,CAAC;AAED,SAAS,cAAc,OAAkD;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAsB,4BAAtB,MAEA;CAIuB;CAHrB;CAEA,YACE,qCAGI,IAAI,IAAI,GACZ,oBACA;EALmB,KAAA,qBAAA;EASnB,KAAK,iBACH,uBAAuB,KAAA,KAAa,mBAAmB,OAAO,IAC1D,wBAAwB,kBAAkB,IAC1C,KAAA;CACR;CAEA,oBAAqD,MAAkB;EACrE,MAAM,YAAY,KAAK,0BAA0B,IAAI;EACrD,MAAM,WAAW,KAAK,kBAAkB,SAAS;EACjD,OAAO,KAAK,wBAAwB,QAAQ;CAC9C;CAEA,kBAAkB,UAAiC;EACjD,OAAO;CACT;CAEA,sBAAsB,iCAAiC;CAEvD,cAAc,iCAAiC;CAE/C,0BAAoC,MAAqC;EACvE,OAAO,yBACL,MACA,KAAK,mBAAmB,KAAA,IAAY,EAAE,gBAAgB,KAAK,eAAe,IAAI,KAAA,CAChF;CACF;CAEA,kBAA4B,WAAuD;EACjF,MAAM,QAAQ,UAAU,QAAQ;EAChC,MAAM,gBACJ,UAAU,KAAA,IACN,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC3C,MACA,KAAK,wBAAwB,KAAK,CACpC,CAAC,CACH,IACA,KAAA;EAEN,MAAM,gBAAgB,UAAU,QAAQ;EACxC,IAAI,kBAAkB,KAAA,GACpB,MAAM,IAAI,wBACR,uEACA,YACF;EAEF,MAAM,qBAAqB,KAAK,uBAAuB,aAAa;EASpE,MAA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SAAoC,CAAC,CAAC,KAAK,CAAC,WAAW,WAAW,CAC/E,WACA,iBAAiB,eAAe,QAAQ,IAAI,aAAa,KAA0B,CACrF,CAAC,CACH;GAEF,MAAM,eAAe,WAAW;GAChC,IACE,iBAAiB,QACjB,OAAO,iBAAiB,YACxB,CAAC,MAAM,QAAQ,YAAY,GAE3B,aAAa,WAAW,OAAO,YAC7B,OAAO,QACL,UAGE,YAAY,CAChB,CAAC,CAAC,KAAK,CAAC,QAAQ,QAAQ,CACtB,QACA,cAAc,kBACV,KACA,IAAI,gBACF,UAGE,EAAE,CACN,CACN,CAAC,CACH;EAIJ;EAEA,OAAO,UAAsE;GAC3E;GACA,SAAS;EACX,CAAC;CACH;CAEA,wBAAkC,OAAiD;EACjF,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;EAET,MAAM,OAAQ,MAA6B;EAC3C,IAAI,OAAO,SAAS,UAClB,OAAO;EAET,MAAM,UAAU,KAAK,mBAAmB,IAAI,IAAI;EAChD,IAAI,YAAY,KAAA,GACd,OAAO;EAET,OAAO,UAGL,QAAQ,KAAK,CAAC;CAClB;CAEA,wBAAkC,UAA2C;EAC3E,OAAO;CACT;AACF;;;;;;;;;;;;ACpQA,IAAa,wBAAb,cAA2C,0BAAgD;CACzF,cAAc;EACZ,sBAAM,IAAI,IAAI,CAAC;CACjB;AACF"}
@@ -47,6 +47,7 @@ function timestampNowControlDescriptor() {
47
47
  * `field.temporal.updatedAt()` lower to byte-identical contracts across
48
48
  * targets by construction.
49
49
  */
50
+ /* @__NO_SIDE_EFFECTS__ */
50
51
  function temporalAuthoringPresets(input) {
51
52
  const { codecId, nativeType } = input;
52
53
  return {
@@ -83,4 +84,4 @@ function temporalAuthoringPresets(input) {
83
84
  //#endregion
84
85
  export { temporalAuthoringPresets as n, timestampNowControlDescriptor as r, TIMESTAMP_NOW_GENERATOR_ID as t };
85
86
 
86
- //# sourceMappingURL=timestamp-now-generator-r7BP5n3l.mjs.map
87
+ //# sourceMappingURL=timestamp-now-generator-CloimujU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"timestamp-now-generator-r7BP5n3l.mjs","names":[],"sources":["../src/core/timestamp-now-generator.ts"],"sourcesContent":["import type { AuthoringFieldPresetDescriptor } from '@prisma-next/framework-components/authoring';\nimport type { MutationDefaultGeneratorDescriptor } from '@prisma-next/framework-components/control';\n\n/**\n * Canonical id for the wall-clock-now mutation default generator.\n *\n * Owned by `family-sql` because that's where the generator lives. The\n * id flows out from here to (1) the control-plane descriptor and the\n * temporal field-preset pair below, (2) the runtime-plane sibling\n * `timestamp-now-runtime-generator.ts`, and (3) authoring surfaces\n * (PSL `temporal.updatedAt()`, TS `field.temporal.updatedAt()`) via\n * the descriptor flow. Co-locating the constant with its only owner\n * keeps the framework layer free of concrete generator ids.\n */\nexport const TIMESTAMP_NOW_GENERATOR_ID = 'timestampNow' as const;\n\n/**\n * Builds the canonical control-plane descriptor for the wall-clock-now\n * mutation default generator. The descriptor's `id` and `buildPhases`\n * are target-agnostic so PSL `temporal.updatedAt()` and TS\n * `field.temporal.updatedAt()` lower to byte-identical contracts.\n *\n * `applicableCodecIds` is omitted: `timestampNow` is preset-only (not\n * reachable via `@default(timestampNow())` lowering), and the codec is\n * co-registered by the preset descriptor itself, so the\n * `@default(...)` compatibility check has no role to play here.\n */\nexport function timestampNowControlDescriptor(): MutationDefaultGeneratorDescriptor {\n return {\n id: TIMESTAMP_NOW_GENERATOR_ID,\n buildPhases: () => ({\n onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n }),\n };\n}\n\n/**\n * Builds the canonical `temporal.{createdAt,updatedAt}` field-preset pair\n * for a SQL target. `createdAt` lowers to a `now()` storage default;\n * `updatedAt` lowers to the `timestampNow` execution generator on both\n * `onCreate` and `onUpdate` (RD: \"last modified time\", non-null). Targets\n * supply the codec/native-type pair that matches their timestamp column;\n * everything else is shared so PSL `temporal.updatedAt()` and TS\n * `field.temporal.updatedAt()` lower to byte-identical contracts across\n * targets by construction.\n */\nexport function temporalAuthoringPresets<\n const CodecId extends string,\n const NativeType extends string,\n>(input: { readonly codecId: CodecId; readonly nativeType: NativeType }) {\n const { codecId, nativeType } = input;\n return {\n createdAt: {\n kind: 'fieldPreset',\n output: {\n codecId,\n nativeType,\n default: { kind: 'function', expression: 'now()' },\n },\n },\n updatedAt: {\n kind: 'fieldPreset',\n output: {\n codecId,\n nativeType,\n executionDefaults: {\n onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n },\n },\n },\n } as const satisfies Record<string, AuthoringFieldPresetDescriptor>;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,6BAA6B;;;;;;;;;;;;AAa1C,SAAgB,gCAAoE;CAClF,OAAO;EACL,IAAI;EACJ,oBAAoB;GAClB,UAAU;IAAE,MAAM;IAAa,IAAI;GAA2B;GAC9D,UAAU;IAAE,MAAM;IAAa,IAAI;GAA2B;EAChE;CACF;AACF;;;;;;;;;;;AAYA,SAAgB,yBAGd,OAAuE;CACvE,MAAM,EAAE,SAAS,eAAe;CAChC,OAAO;EACL,WAAW;GACT,MAAM;GACN,QAAQ;IACN;IACA;IACA,SAAS;KAAE,MAAM;KAAY,YAAY;IAAQ;GACnD;EACF;EACA,WAAW;GACT,MAAM;GACN,QAAQ;IACN;IACA;IACA,mBAAmB;KACjB,UAAU;MAAE,MAAM;MAAa,IAAI;KAA2B;KAC9D,UAAU;MAAE,MAAM;MAAa,IAAI;KAA2B;IAChE;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"timestamp-now-generator-CloimujU.mjs","names":[],"sources":["../src/core/timestamp-now-generator.ts"],"sourcesContent":["import type { AuthoringFieldPresetDescriptor } from '@prisma-next/framework-components/authoring';\nimport type { MutationDefaultGeneratorDescriptor } from '@prisma-next/framework-components/control';\n\n/**\n * Canonical id for the wall-clock-now mutation default generator.\n *\n * Owned by `family-sql` because that's where the generator lives. The\n * id flows out from here to (1) the control-plane descriptor and the\n * temporal field-preset pair below, (2) the runtime-plane sibling\n * `timestamp-now-runtime-generator.ts`, and (3) authoring surfaces\n * (PSL `temporal.updatedAt()`, TS `field.temporal.updatedAt()`) via\n * the descriptor flow. Co-locating the constant with its only owner\n * keeps the framework layer free of concrete generator ids.\n */\nexport const TIMESTAMP_NOW_GENERATOR_ID = 'timestampNow' as const;\n\n/**\n * Builds the canonical control-plane descriptor for the wall-clock-now\n * mutation default generator. The descriptor's `id` and `buildPhases`\n * are target-agnostic so PSL `temporal.updatedAt()` and TS\n * `field.temporal.updatedAt()` lower to byte-identical contracts.\n *\n * `applicableCodecIds` is omitted: `timestampNow` is preset-only (not\n * reachable via `@default(timestampNow())` lowering), and the codec is\n * co-registered by the preset descriptor itself, so the\n * `@default(...)` compatibility check has no role to play here.\n */\nexport function timestampNowControlDescriptor(): MutationDefaultGeneratorDescriptor {\n return {\n id: TIMESTAMP_NOW_GENERATOR_ID,\n buildPhases: () => ({\n onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n }),\n };\n}\n\n/**\n * Builds the canonical `temporal.{createdAt,updatedAt}` field-preset pair\n * for a SQL target. `createdAt` lowers to a `now()` storage default;\n * `updatedAt` lowers to the `timestampNow` execution generator on both\n * `onCreate` and `onUpdate` (RD: \"last modified time\", non-null). Targets\n * supply the codec/native-type pair that matches their timestamp column;\n * everything else is shared so PSL `temporal.updatedAt()` and TS\n * `field.temporal.updatedAt()` lower to byte-identical contracts across\n * targets by construction.\n */\n/* @__NO_SIDE_EFFECTS__ */\nexport function temporalAuthoringPresets<\n const CodecId extends string,\n const NativeType extends string,\n>(input: { readonly codecId: CodecId; readonly nativeType: NativeType }) {\n const { codecId, nativeType } = input;\n return {\n createdAt: {\n kind: 'fieldPreset',\n output: {\n codecId,\n nativeType,\n default: { kind: 'function', expression: 'now()' },\n },\n },\n updatedAt: {\n kind: 'fieldPreset',\n output: {\n codecId,\n nativeType,\n executionDefaults: {\n onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },\n },\n },\n },\n } as const satisfies Record<string, AuthoringFieldPresetDescriptor>;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,6BAA6B;;;;;;;;;;;;AAa1C,SAAgB,gCAAoE;CAClF,OAAO;EACL,IAAI;EACJ,oBAAoB;GAClB,UAAU;IAAE,MAAM;IAAa,IAAI;GAA2B;GAC9D,UAAU;IAAE,MAAM;IAAa,IAAI;GAA2B;EAChE;CACF;AACF;;;;;;;;;;;;AAaA,SAAgB,yBAGd,OAAuE;CACvE,MAAM,EAAE,SAAS,eAAe;CAChC,OAAO;EACL,WAAW;GACT,MAAM;GACN,QAAQ;IACN;IACA;IACA,SAAS;KAAE,MAAM;KAAY,YAAY;IAAQ;GACnD;EACF;EACA,WAAW;GACT,MAAM;GACN,QAAQ;IACN;IACA;IACA,mBAAmB;KACjB,UAAU;MAAE,MAAM;MAAa,IAAI;KAA2B;KAC9D,UAAU;MAAE,MAAM;MAAa,IAAI;KAA2B;IAChE;GACF;EACF;CACF;AACF"}
@@ -1,12 +1,14 @@
1
- import { ContractSerializer, ContractSpace, ControlAdapterDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationRunnerResult, OpFactoryCall, OperationContext, OperationPreview, OperationPreviewCapable, PslContractInferCapable, SchemaIssue, SchemaVerifier, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
2
- import { SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
1
+ import { n as SqlControlAdapter } from "./control-adapter-CgIL9Vtx.mjs";
2
+ import { ContractSerializer, ContractSpace, ControlAdapterDescriptor, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationRunnerResult, OpFactoryCall, OperationContext, OperationPreview, OperationPreviewCapable, PslContractInferCapable, SchemaIssue, SchemaVerifier, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
3
+ import { SqlControlDriverInstance, SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
3
4
  import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
4
- import { Result } from "@prisma-next/utils/result";
5
5
  import { Contract } from "@prisma-next/contract/types";
6
- import { AnyQueryAst, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
6
+ import { Result } from "@prisma-next/utils/result";
7
+ import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
7
8
  import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
8
9
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
9
10
  import { TypesImportSpec } from "@prisma-next/framework-components/emission";
11
+ import { AggregateMigrationEdgeRef } from "@prisma-next/migration-tools/aggregate";
10
12
  import { SqlOperationDescriptors } from "@prisma-next/sql-operations";
11
13
 
12
14
  //#region src/core/control-instance.d.ts
@@ -33,7 +35,7 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
33
35
  */
34
36
  deserializeContract(contractJson: unknown): Contract;
35
37
  verify(options: {
36
- readonly driver: ControlDriverInstance<'sql', string>;
38
+ readonly driver: SqlControlDriverInstance<string>;
37
39
  readonly contract: unknown;
38
40
  readonly expectedTargetId: string;
39
41
  readonly contractPath: string;
@@ -56,17 +58,63 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
56
58
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
57
59
  }): VerifyDatabaseSchemaResult;
58
60
  sign(options: {
59
- readonly driver: ControlDriverInstance<'sql', string>;
61
+ readonly driver: SqlControlDriverInstance<string>;
60
62
  readonly contract: unknown;
61
63
  readonly contractPath: string;
62
64
  readonly configPath?: string;
63
65
  }): Promise<SignDatabaseResult>;
64
66
  introspect(options: {
65
- readonly driver: ControlDriverInstance<'sql', string>;
67
+ readonly driver: SqlControlDriverInstance<string>;
66
68
  readonly contract?: unknown;
67
69
  }): Promise<SqlSchemaIR>;
68
70
  inferPslContract(schemaIR: SqlSchemaIR): PslDocumentAst;
69
- lowerAst(ast: AnyQueryAst, context: LowererContext<unknown>): LoweredStatement;
71
+ lowerAst(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
72
+ /**
73
+ * Inserts the initial marker row for `space` (upsert on `space`).
74
+ * Delegates to the target control adapter's write SPI; see
75
+ * `SqlControlAdapter.initMarker`.
76
+ */
77
+ initMarker(options: {
78
+ readonly driver: SqlControlDriverInstance<string>;
79
+ readonly space: string;
80
+ readonly destination: {
81
+ readonly storageHash: string;
82
+ readonly profileHash: string;
83
+ readonly invariants?: readonly string[];
84
+ };
85
+ }): Promise<void>;
86
+ /**
87
+ * Compare-and-swap advance of the marker row for `space`. Returns `true`
88
+ * when the swap matched a row; see `SqlControlAdapter.updateMarker`.
89
+ */
90
+ updateMarker(options: {
91
+ readonly driver: SqlControlDriverInstance<string>;
92
+ readonly space: string;
93
+ readonly expectedFrom: string;
94
+ readonly destination: {
95
+ readonly storageHash: string;
96
+ readonly profileHash: string;
97
+ readonly invariants?: readonly string[];
98
+ };
99
+ }): Promise<boolean>;
100
+ /**
101
+ * Appends a ledger entry for `space`; see
102
+ * `SqlControlAdapter.writeLedgerEntry`.
103
+ */
104
+ writeLedgerEntry(options: {
105
+ readonly driver: SqlControlDriverInstance<string>;
106
+ readonly space: string;
107
+ readonly entry: {
108
+ readonly edgeId: string;
109
+ readonly from: string;
110
+ readonly to: string;
111
+ readonly migrationName: string;
112
+ readonly migrationHash: string;
113
+ readonly operations: readonly unknown[];
114
+ };
115
+ }): Promise<void>;
116
+ bootstrapControlTableQueries(): readonly DdlNode[];
117
+ bootstrapSignMarkerQueries(): readonly DdlNode[];
70
118
  toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
71
119
  }
72
120
  //#endregion
@@ -147,7 +195,7 @@ interface CodecControlHooks<TTargetDetails = unknown> {
147
195
  readonly schemaName?: string;
148
196
  }) => readonly SchemaIssue[];
149
197
  introspectTypes?: (options: {
150
- readonly driver: ControlDriverInstance<'sql', string>;
198
+ readonly driver: SqlControlDriverInstance<string>;
151
199
  readonly schemaName?: string;
152
200
  }) => Promise<Record<string, StorageTypeInstance>>;
153
201
  /**
@@ -202,7 +250,7 @@ interface SqlControlExtensionDescriptor<TTargetId extends string> extends Contro
202
250
  */
203
251
  readonly contractSpace?: ContractSpace<Contract<SqlStorage>>;
204
252
  }
205
- interface SqlControlAdapterDescriptor<TTargetId extends string> extends ControlAdapterDescriptor<'sql', TTargetId> {
253
+ interface SqlControlAdapterDescriptor<TTargetId extends string> extends ControlAdapterDescriptor<'sql', TTargetId, SqlControlAdapter<TTargetId>> {
206
254
  readonly queryOperations?: () => SqlOperationDescriptors;
207
255
  }
208
256
  interface SqlMigrationPlanOperationStep {
@@ -283,8 +331,9 @@ interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
283
331
  readonly providedInvariants: readonly string[];
284
332
  readonly meta?: AnyRecord;
285
333
  }
286
- type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedOperation';
334
+ type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedOperation' | 'controlPolicySuppressedCall';
287
335
  interface SqlPlannerConflictLocation {
336
+ readonly namespace?: string;
288
337
  readonly table?: string;
289
338
  readonly column?: string;
290
339
  readonly index?: string;
@@ -352,7 +401,7 @@ interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
352
401
  }
353
402
  interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
354
403
  readonly plan: SqlMigrationPlan<TTargetDetails>;
355
- readonly driver: ControlDriverInstance<'sql', string>;
404
+ readonly driver: SqlControlDriverInstance<string>;
356
405
  /**
357
406
  * Logical contract space this plan applies to. When omitted the
358
407
  * runner derives the space from {@link SqlMigrationPlan.spaceId};
@@ -387,8 +436,13 @@ interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
387
436
  * All components must have matching familyId ('sql') and targetId.
388
437
  */
389
438
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
439
+ /**
440
+ * Per-edge breakdown from graph-walk planning. When present, the runner
441
+ * writes one ledger row per edge instead of one collapsed row per apply.
442
+ */
443
+ readonly migrationEdges: readonly AggregateMigrationEdgeRef[];
390
444
  }
391
- type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'LEGACY_MARKER_SHAPE' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'FOREIGN_KEY_VIOLATION' | 'EXECUTION_FAILED';
445
+ type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'LEGACY_MARKER_SHAPE' | 'MARKER_ORIGIN_MISMATCH' | 'MARKER_CAS_FAILURE' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'FOREIGN_KEY_VIOLATION' | 'EXECUTION_FAILED';
392
446
  interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
393
447
  readonly code: SqlMigrationRunnerErrorCode;
394
448
  readonly meta?: AnyRecord;
@@ -410,7 +464,7 @@ interface SqlMigrationRunner<TTargetDetails> {
410
464
  * (the connection the outer transaction is open on).
411
465
  */
412
466
  execute(options: {
413
- readonly driver: ControlDriverInstance<'sql', string>;
467
+ readonly driver: SqlControlDriverInstance<string>;
414
468
  readonly perSpaceOptions: ReadonlyArray<SqlMigrationRunnerExecuteOptions<TTargetDetails>>;
415
469
  }): Promise<MigrationRunnerResult>;
416
470
  /**
@@ -441,7 +495,7 @@ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails, T
441
495
  * the base, the target-specific dispatch on the subclass.
442
496
  */
443
497
  readonly schemaVerifier: SchemaVerifier<TContract, SqlSchemaIR>;
444
- createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
498
+ createPlanner(adapter: SqlControlAdapter<TTargetId>): SqlMigrationPlanner<TTargetDetails>;
445
499
  createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
446
500
  }
447
501
  interface CreateSqlMigrationPlanOptions<TTargetDetails> {
@@ -463,4 +517,4 @@ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
463
517
  }
464
518
  //#endregion
465
519
  export { SqlPlannerResult as A, SqlMigrationRunnerResult as C, SqlPlannerConflictKind as D, SqlPlannerConflict as E, StorageTypePlanResult as M, SqlControlFamilyInstance as N, SqlPlannerConflictLocation as O, SqlMigrationRunnerFailure as S, SqlPlanTargetDetails as T, SqlMigrationPlannerPlanOptions as _, FieldEvent as a, SqlMigrationRunnerExecuteCallbacks as b, SqlControlAdapterDescriptor as c, SqlMigrationPlan as d, SqlMigrationPlanContractInfo as f, SqlMigrationPlanner as g, SqlMigrationPlanOperationTarget as h, ExpandNativeTypeInput as i, SqlPlannerSuccessResult as j, SqlPlannerFailureResult as k, SqlControlExtensionDescriptor as l, SqlMigrationPlanOperationStep as m, CodecControlHooks as n, FieldEventContext as o, SqlMigrationPlanOperation as p, CreateSqlMigrationPlanOptions as r, ResolveIdentityValueInput as s, AnyRecord as t, SqlControlTargetDescriptor as u, SqlMigrationRunner as v, SqlMigrationRunnerSuccessValue as w, SqlMigrationRunnerExecuteOptions as x, SqlMigrationRunnerErrorCode as y };
466
- //# sourceMappingURL=types-CeeCStqw.d.mts.map
520
+ //# sourceMappingURL=types-CbwQCzXY.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CbwQCzXY.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/types.ts"],"mappings":";;;;;;;;;;;;;;UA4KU,eAAA;EAAA,SACC,MAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;AAAA;AAAA,KAGN,uBAAA,GAA0B,GAAG,SAAS,eAAA;AAAA,UAEjC,sBAAA;EAAA,SACC,gBAAA,EAAkB,aAAA,CAAc,eAAA;EAAA,SAChC,YAAA,EAAc,aAAA;EAAA,SACd,oBAAA,EAAsB,uBAAA;AAAA;AAAA,UAGhB,wBAAA,SACP,qBAAA,QAA6B,WAAA,GACnC,iBAAA,CAAkB,WAAA,GAClB,uBAAA,CAAwB,WAAA,GACxB,uBAAA,EACA,sBAAA;EAhBO;;AAAU;AAAA;;;;AAGqC;EAsBxD,mBAAA,CAAoB,YAAA,YAAwB,QAAA;EAE5C,MAAA,CAAO,OAAA;IAAA,SACI,MAAA,EAAQ,wBAAA;IAAA,SACR,QAAA;IAAA,SACA,gBAAA;IAAA,SACA,YAAA;IAAA,SACA,UAAA;EAAA,IACP,OAAA,CAAQ,oBAAA;EAzB0C;;;;;;;;;AAAA;EAqCtD,YAAA,CAAa,OAAA;IAAA,SAC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B,kBAAA,CAAmB,cAAA;AAAA;AAAA,UAGpD,6BAAA;EAAA,SACN,QAAA;EA7QU;;AAAc;EAAd,SAiRV,OAAA;EAAA,SACA,MAAA,GAAS,4BAAA;EAAA,SACT,WAAA,EAAa,4BAAA;EAAA,SACb,UAAA,WAAqB,yBAAA,CAA0B,cAAA;EA/QvC;;;;;EAAA,SAqRR,kBAAA;EAAA,SACA,IAAA,GAAO,SAAA;AAAA"}
@@ -78,4 +78,4 @@ function collectSupportedCodecTypeIds(descriptors) {
78
78
  //#endregion
79
79
  export { parseContractMarkerRow as n, collectSupportedCodecTypeIds as t };
80
80
 
81
- //# sourceMappingURL=verify-Crewz6hG.mjs.map
81
+ //# sourceMappingURL=verify-C-G0obRm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-Crewz6hG.mjs","names":[],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport { type } from 'arktype';\n\nconst MetaSchema = type({ '[string]': 'unknown' });\n\nfunction parseMeta(meta: unknown): Record<string, unknown> {\n if (meta === null || meta === undefined) {\n return {};\n }\n\n let parsed: unknown;\n if (typeof meta === 'string') {\n try {\n parsed = JSON.parse(meta);\n } catch {\n return {};\n }\n } else {\n parsed = meta;\n }\n\n const result = MetaSchema(parsed);\n if (result instanceof type.errors) {\n return {};\n }\n\n return result as Record<string, unknown>;\n}\n\n/**\n * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;\n * Postgres uses `jsonb` and returns an already-parsed value. Normalize both\n * here so `ContractMarkerRecord.contractJson` is always the structured form.\n */\nfunction parseContractJson(value: unknown): unknown {\n if (value === null || value === undefined) return null;\n if (typeof value !== 'string') return value;\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n}\n\n/**\n * Wire shape of a `prisma_contract.marker` row as it comes out of a SQL\n * driver. Snake-cased to match the on-disk column names. Shared by every\n * SQL target's `readMarker` so each runner doesn't redeclare it inline.\n */\nexport type ContractMarkerRow = {\n core_hash: string;\n profile_hash: string;\n contract_json: unknown | null;\n canonical_version: number | null;\n updated_at: Date | string;\n app_tag: string | null;\n meta: unknown | null;\n // SQLite stores arrays as JSON-TEXT, so this is `string` on the wire from\n // a SQLite driver and `string[]` from a Postgres driver. Targets normalize\n // before passing to `parseContractMarkerRow`.\n invariants: unknown;\n};\n\nconst ContractMarkerRowSchema = type({\n core_hash: 'string',\n profile_hash: 'string',\n 'contract_json?': 'unknown | null',\n 'canonical_version?': 'number | null',\n 'updated_at?': 'Date | string',\n 'app_tag?': 'string | null',\n 'meta?': 'unknown | null',\n invariants: type('string').array(),\n});\n\n/**\n * Parses a contract marker row from database query result.\n * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n */\nexport function parseContractMarkerRow(row: unknown): ContractMarkerRecord {\n const result = ContractMarkerRowSchema(row);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid contract marker row: ${messages}`);\n }\n\n const updatedAt = result.updated_at\n ? result.updated_at instanceof Date\n ? result.updated_at\n : new Date(result.updated_at)\n : new Date();\n\n return {\n storageHash: result.core_hash,\n profileHash: result.profile_hash,\n contractJson: parseContractJson(result.contract_json),\n canonicalVersion: result.canonical_version ?? null,\n updatedAt,\n appTag: result.app_tag ?? null,\n meta: parseMeta(result.meta),\n invariants: result.invariants,\n };\n}\n\n/**\n * Collects supported codec type IDs from adapter and extension manifests.\n * Returns a sorted, unique array of type IDs that are declared in the manifests.\n * This enables coverage checks by comparing contract column types against supported types.\n *\n * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n * The manifests declare which codec types are available, but the actual type IDs\n * are defined in the codec-types TypeScript modules that are imported.\n *\n * For MVP, we return an empty array since extracting type IDs from TypeScript modules\n * would require runtime evaluation or static analysis. This can be enhanced later.\n */\nexport function collectSupportedCodecTypeIds(\n descriptors: ReadonlyArray<{ readonly id: string }>,\n): readonly string[] {\n // For MVP, return empty array\n // Future enhancement: Extract type IDs from codec-types modules via static analysis\n // or require manifests to explicitly list supported type IDs\n void descriptors;\n return [];\n}\n"],"mappings":";;AAGA,MAAM,aAAa,KAAK,EAAE,YAAY,UAAU,CAAC;AAEjD,SAAS,UAAU,MAAwC;CACzD,IAAI,SAAS,QAAQ,SAAS,KAAA,GAC5B,OAAO,CAAC;CAGV,IAAI;CACJ,IAAI,OAAO,SAAS,UAClB,IAAI;EACF,SAAS,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACN,OAAO,CAAC;CACV;MAEA,SAAS;CAGX,MAAM,SAAS,WAAW,MAAM;CAChC,IAAI,kBAAkB,KAAK,QACzB,OAAO,CAAC;CAGV,OAAO;AACT;;;;;;AAOA,SAAS,kBAAkB,OAAyB;CAClD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAqBA,MAAM,0BAA0B,KAAK;CACnC,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,sBAAsB;CACtB,eAAe;CACf,YAAY;CACZ,SAAS;CACT,YAAY,KAAK,QAAQ,EAAE,MAAM;AACnC,CAAC;;;;;AAMD,SAAgB,uBAAuB,KAAoC;CACzE,MAAM,SAAS,wBAAwB,GAAG;CAC1C,IAAI,kBAAkB,KAAK,QAAQ;EACjC,MAAM,WAAW,OAAO,KAAK,MAA2B,EAAE,OAAO,EAAE,KAAK,IAAI;EAC5E,MAAM,IAAI,MAAM,gCAAgC,UAAU;CAC5D;CAEA,MAAM,YAAY,OAAO,aACrB,OAAO,sBAAsB,OAC3B,OAAO,aACP,IAAI,KAAK,OAAO,UAAU,oBAC5B,IAAI,KAAK;CAEb,OAAO;EACL,aAAa,OAAO;EACpB,aAAa,OAAO;EACpB,cAAc,kBAAkB,OAAO,aAAa;EACpD,kBAAkB,OAAO,qBAAqB;EAC9C;EACA,QAAQ,OAAO,WAAW;EAC1B,MAAM,UAAU,OAAO,IAAI;EAC3B,YAAY,OAAO;CACrB;AACF;;;;;;;;;;;;;AAcA,SAAgB,6BACd,aACmB;CAKnB,OAAO,CAAC;AACV"}
1
+ {"version":3,"file":"verify-C-G0obRm.mjs","names":[],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport { type } from 'arktype';\n\nconst MetaSchema = type({ '[string]': 'unknown' });\n\nfunction parseMeta(meta: unknown): Record<string, unknown> {\n if (meta === null || meta === undefined) {\n return {};\n }\n\n let parsed: unknown;\n if (typeof meta === 'string') {\n try {\n parsed = JSON.parse(meta);\n } catch {\n return {};\n }\n } else {\n parsed = meta;\n }\n\n const result = MetaSchema(parsed);\n if (result instanceof type.errors) {\n return {};\n }\n\n return result as Record<string, unknown>;\n}\n\n/**\n * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;\n * Postgres uses `jsonb` and returns an already-parsed value. Normalize both\n * here so `ContractMarkerRecord.contractJson` is always the structured form.\n */\nfunction parseContractJson(value: unknown): unknown {\n if (value === null || value === undefined) return null;\n if (typeof value !== 'string') return value;\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n}\n\n/**\n * Wire shape of a `prisma_contract.marker` row as it comes out of a SQL\n * driver. Snake-cased to match the on-disk column names. Shared by every\n * SQL target's `readMarker` so each runner doesn't redeclare it inline.\n */\nexport type ContractMarkerRow = {\n core_hash: string;\n profile_hash: string;\n contract_json: unknown | null;\n canonical_version: number | null;\n updated_at: Date | string;\n app_tag: string | null;\n meta: unknown | null;\n // SQLite stores arrays as JSON-TEXT, so this is `string` on the wire from\n // a SQLite driver and `string[]` from a Postgres driver. Targets normalize\n // before passing to `parseContractMarkerRow`.\n invariants: unknown;\n};\n\nconst ContractMarkerRowSchema = type({\n core_hash: 'string',\n profile_hash: 'string',\n 'contract_json?': 'unknown | null',\n 'canonical_version?': 'number | null',\n 'updated_at?': 'Date | string',\n 'app_tag?': 'string | null',\n 'meta?': 'unknown | null',\n invariants: type('string').array(),\n});\n\n/**\n * Parses a contract marker row from database query result.\n * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n */\nexport function parseContractMarkerRow(row: unknown): ContractMarkerRecord {\n const result = ContractMarkerRowSchema(row);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid contract marker row: ${messages}`);\n }\n\n const updatedAt = result.updated_at\n ? result.updated_at instanceof Date\n ? result.updated_at\n : new Date(result.updated_at)\n : new Date();\n\n return {\n storageHash: result.core_hash,\n profileHash: result.profile_hash,\n contractJson: parseContractJson(result.contract_json),\n canonicalVersion: result.canonical_version ?? null,\n updatedAt,\n appTag: result.app_tag ?? null,\n meta: parseMeta(result.meta),\n invariants: result.invariants,\n };\n}\n\n/**\n * Collects supported codec type IDs from adapter and extension manifests.\n * Returns a sorted, unique array of type IDs that are declared in the manifests.\n * This enables coverage checks by comparing contract column types against supported types.\n *\n * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n * The manifests declare which codec types are available, but the actual type IDs\n * are defined in the codec-types TypeScript modules that are imported.\n *\n * For MVP, we return an empty array since extracting type IDs from TypeScript modules\n * would require runtime evaluation or static analysis. This can be enhanced later.\n */\nexport function collectSupportedCodecTypeIds(\n descriptors: ReadonlyArray<{ readonly id: string }>,\n): readonly string[] {\n // For MVP, return empty array\n // Future enhancement: Extract type IDs from codec-types modules via static analysis\n // or require manifests to explicitly list supported type IDs\n void descriptors;\n return [];\n}\n"],"mappings":";;AAGA,MAAM,aAAa,KAAK,EAAE,YAAY,UAAU,CAAC;AAEjD,SAAS,UAAU,MAAwC;CACzD,IAAI,SAAS,QAAQ,SAAS,KAAA,GAC5B,OAAO,CAAC;CAGV,IAAI;CACJ,IAAI,OAAO,SAAS,UAClB,IAAI;EACF,SAAS,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACN,OAAO,CAAC;CACV;MAEA,SAAS;CAGX,MAAM,SAAS,WAAW,MAAM;CAChC,IAAI,kBAAkB,KAAK,QACzB,OAAO,CAAC;CAGV,OAAO;AACT;;;;;;AAOA,SAAS,kBAAkB,OAAyB;CAClD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAqBA,MAAM,0BAA0B,KAAK;CACnC,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,sBAAsB;CACtB,eAAe;CACf,YAAY;CACZ,SAAS;CACT,YAAY,KAAK,QAAQ,CAAC,CAAC,MAAM;AACnC,CAAC;;;;;AAMD,SAAgB,uBAAuB,KAAoC;CACzE,MAAM,SAAS,wBAAwB,GAAG;CAC1C,IAAI,kBAAkB,KAAK,QAAQ;EACjC,MAAM,WAAW,OAAO,KAAK,MAA2B,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI;EAC5E,MAAM,IAAI,MAAM,gCAAgC,UAAU;CAC5D;CAEA,MAAM,YAAY,OAAO,aACrB,OAAO,sBAAsB,OAC3B,OAAO,aACP,IAAI,KAAK,OAAO,UAAU,oBAC5B,IAAI,KAAK;CAEb,OAAO;EACL,aAAa,OAAO;EACpB,aAAa,OAAO;EACpB,cAAc,kBAAkB,OAAO,aAAa;EACpD,kBAAkB,OAAO,qBAAqB;EAC9C;EACA,QAAQ,OAAO,WAAW;EAC1B,MAAM,UAAU,OAAO,IAAI;EAC3B,YAAY,OAAO;CACrB;AACF;;;;;;;;;;;;;AAcA,SAAgB,6BACd,aACmB;CAKnB,OAAO,CAAC;AACV"}
@@ -75,4 +75,4 @@ interface VerifySqlSchemaOptions {
75
75
  declare function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult;
76
76
  //#endregion
77
77
  export { verifySqlSchema as i, NativeTypeNormalizer as n, VerifySqlSchemaOptions as r, DefaultNormalizer as t };
78
- //# sourceMappingURL=verify-sql-schema-CN7pPoTC.d.mts.map
78
+ //# sourceMappingURL=verify-sql-schema-DcMaT5Zj.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-sql-schema-CN7pPoTC.d.mts","names":[],"sources":["../src/core/schema-verify/verify-sql-schema.ts"],"mappings":";;;;;;;;;;AA+CkB;KAHN,iBAAA,IACV,UAAA,UACA,UAAA,aACG,aAAa;;;;AAOoC;AAKtD;KALY,oBAAA,IAAwB,UAAkB;;;;UAKrC,sBAAA;EAQI;EAAA,SANV,QAAA,EAAU,QAAA,CAAS,UAAA;EAagB;EAAA,SAXnC,MAAA,EAAQ,WAAA;EAiBW;EAAA,SAfnB,MAAA;EAkCC;EAAA,SAhCD,OAAA,GAAU,gBAAA;EAiCiB;EAAA,SA/B3B,oBAAA,EAAsB,WAAA;IAAsB,UAAA;EAAA;EARzB;;;;EAAA,SAanB,mBAAA,EAAqB,aAAA,CAAc,8BAAA;EAPzB;;;;;EAAA,SAaV,gBAAA,GAAmB,iBAAA;EANgB;;;;;EAAA,SAYnC,mBAAA,GAAsB,oBAAA;EAarB;;;;;;AAEW;AAcvB;;;;EAhBY,SADD,yBAAA,IACP,MAAA,EAAQ,WAAA,EACR,QAAA,EAAU,wBAAA,EACV,WAAA;AAAA;;;AAcwF;;;;;;;;iBAA5E,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,0BAA0B"}
1
+ {"version":3,"file":"verify-sql-schema-DcMaT5Zj.d.mts","names":[],"sources":["../src/core/schema-verify/verify-sql-schema.ts"],"mappings":";;;;;;;;;;AAsDkB;KAHN,iBAAA,IACV,UAAA,UACA,UAAA,aACG,aAAa;;;;AAOoC;AAKtD;KALY,oBAAA,IAAwB,UAAkB;;;;UAKrC,sBAAA;EAQI;EAAA,SANV,QAAA,EAAU,QAAA,CAAS,UAAA;EAagB;EAAA,SAXnC,MAAA,EAAQ,WAAA;EAiBW;EAAA,SAfnB,MAAA;EAkCC;EAAA,SAhCD,OAAA,GAAU,gBAAA;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