@prisma-next/family-sql 0.11.0-dev.9 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/authoring-type-constructors-F4JpCJl7.mjs.map +1 -1
  2. package/dist/control-adapter.d.mts +11 -4
  3. package/dist/control-adapter.d.mts.map +1 -1
  4. package/dist/control.d.mts +25 -2
  5. package/dist/control.d.mts.map +1 -1
  6. package/dist/control.mjs +43 -23
  7. package/dist/control.mjs.map +1 -1
  8. package/dist/ir.d.mts +4 -1
  9. package/dist/ir.d.mts.map +1 -1
  10. package/dist/ir.mjs +1 -1
  11. package/dist/ir.mjs.map +1 -1
  12. package/dist/migration.d.mts +1 -1
  13. package/dist/migration.d.mts.map +1 -1
  14. package/dist/migration.mjs.map +1 -1
  15. package/dist/pack.mjs.map +1 -1
  16. package/dist/runtime.d.mts.map +1 -1
  17. package/dist/runtime.mjs.map +1 -1
  18. package/dist/schema-verify.d.mts +1 -1
  19. package/dist/schema-verify.d.mts.map +1 -1
  20. package/dist/schema-verify.mjs +1 -1
  21. package/dist/{sql-contract-serializer-VVoSAnYg.mjs → sql-contract-serializer-8axtK4lg.mjs} +20 -7
  22. package/dist/sql-contract-serializer-8axtK4lg.mjs.map +1 -0
  23. package/dist/timestamp-now-generator-r7BP5n3l.mjs.map +1 -1
  24. package/dist/{types-hQoMXr54.d.mts → types-CeeCStqw.d.mts} +22 -41
  25. package/dist/types-CeeCStqw.d.mts.map +1 -0
  26. package/dist/verify-Crewz6hG.mjs.map +1 -1
  27. package/dist/{verify-sql-schema-Bfvz07Ik.d.mts → verify-sql-schema-CN7pPoTC.d.mts} +2 -2
  28. package/dist/verify-sql-schema-CN7pPoTC.d.mts.map +1 -0
  29. package/dist/{verify-sql-schema-DcP55TWb.mjs → verify-sql-schema-CYLsGCFO.mjs} +50 -36
  30. package/dist/verify-sql-schema-CYLsGCFO.mjs.map +1 -0
  31. package/dist/verify.d.mts.map +1 -1
  32. package/package.json +32 -21
  33. package/src/core/control-adapter.ts +16 -2
  34. package/src/core/control-instance.ts +6 -1
  35. package/src/core/ir/sql-contract-serializer-base.ts +48 -10
  36. package/src/core/migrations/contract-to-schema-ir.ts +83 -34
  37. package/src/core/migrations/types.ts +21 -45
  38. package/src/core/schema-verify/verify-sql-schema.ts +89 -40
  39. package/src/exports/control.ts +1 -3
  40. package/dist/sql-contract-serializer-VVoSAnYg.mjs.map +0 -1
  41. package/dist/types-hQoMXr54.d.mts.map +0 -1
  42. package/dist/verify-sql-schema-Bfvz07Ik.d.mts.map +0 -1
  43. package/dist/verify-sql-schema-DcP55TWb.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"authoring-type-constructors-F4JpCJl7.mjs","names":[],"sources":["../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ulid',\n },\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'cuid2',\n },\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ksuid',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;CAC5B,MAAM;CACN,UAAU;CACV,YAAY,EACV,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,SAAS;EACV,EACF;CACF;AAED,MAAa,iCAAiC;CAC5C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;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N,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;KACL,EACF;IACD,IAAI;IACL;GACF;EACD,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,IACT;IACD,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;KACL,EACF;IACD,IAAI;IACL;GACF;EACF;CACF;;;AC/MD,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;EAAU,CAAC;CACxF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF,EACF"}
1
+ {"version":3,"file":"authoring-type-constructors-F4JpCJl7.mjs","names":[],"sources":["../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ulid',\n },\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'cuid2',\n },\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ksuid',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;CAC5B,MAAM;CACN,UAAU;CACV,YAAY,EACV,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,SAAS;CACX,EACF;AACF;AAEA,MAAa,iCAAiC;CAC5C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,S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IAAI;KACJ,QAAQ,EACN,MAAM;MACJ,MAAM;MACN,OAAO;MACP,MAAM,CAAC,MAAM;KACf,EACF;IACF,EACF;IACA,IAAI;GACN;EACF;EACA,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,GACV;IACA,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,GACV;IACA,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF;;;AC/MA,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;CAAS,CAAC;CACvF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;EAAE,EAClC;CACF;AACF,EACF,EACF"}
@@ -1,7 +1,7 @@
1
- import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-Bfvz07Ik.mjs";
1
+ import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-CN7pPoTC.mjs";
2
2
  import { ControlAdapterInstance, ControlDriverInstance, ControlStack } from "@prisma-next/framework-components/control";
3
- import { PostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
4
- import { ContractMarkerRecord } from "@prisma-next/contract/types";
3
+ import { PostgresEnumStorageEntry, SqlStorage } from "@prisma-next/sql-contract/types";
4
+ import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
5
5
  import { AnyQueryAst, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
6
6
  import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
7
7
 
@@ -70,7 +70,14 @@ interface SqlControlAdapter<TTarget extends string = string> extends ControlAdap
70
70
  * know the target-specific `schema.annotations` shape
71
71
  * (e.g. `schema.annotations.pg.storageTypes`).
72
72
  */
73
- readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry) => readonly string[] | null;
73
+ readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
74
+ /**
75
+ * Optional contract-scoped factory for {@link resolveExistingEnumValues}.
76
+ * Targets that need the contract storage to resolve namespace → DDL schema
77
+ * supply this; the family control instance prefers it over the bare adapter
78
+ * hook when present.
79
+ */
80
+ readonly resolveExistingEnumValuesForContract?: (contract: Contract<SqlStorage>) => (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
74
81
  /**
75
82
  * Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
76
83
  *
@@ -1 +1 @@
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,QAA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OAAA;AAAA"}
@@ -1,4 +1,4 @@
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-hQoMXr54.mjs";
1
+ import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-CeeCStqw.mjs";
2
2
  import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
3
3
  import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
4
4
  import { NotOk, Ok } from "@prisma-next/utils/result";
@@ -271,6 +271,21 @@ type NativeTypeExpander = (input: {
271
271
  * `contractToSchemaIR`, keeping the family layer target-agnostic.
272
272
  */
273
273
  type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
274
+ /**
275
+ * Target-supplied callback that computes the schema-qualified annotation-map
276
+ * key for a namespace-scoped enum storage type.
277
+ *
278
+ * Enum lookups (`readExistingEnumValues`) are namespace/schema-qualified so two
279
+ * namespaces holding an enum with the same TypeScript name (and even the same
280
+ * native type) resolve to distinct live-database types. The *format* of that
281
+ * key — and the namespace → DDL-schema resolution it depends on — is a
282
+ * target-specific concern (Postgres schemas; SQLite/MySQL differ), so the
283
+ * target injects it here as data rather than the family layer importing a
284
+ * concrete `ddlSchemaName`/key implementation. This keeps the family layer
285
+ * target-agnostic (no `@prisma-next/target-*` dependency) while the projection
286
+ * still emits keys that match the target's read side exactly.
287
+ */
288
+ type EnumStorageKeyResolver = (storage: SqlStorage, namespaceId: string, nativeType: string) => string;
274
289
  /**
275
290
  * Detects destructive changes between two contract storages.
276
291
  *
@@ -285,6 +300,14 @@ interface ContractToSchemaIROptions {
285
300
  readonly annotationNamespace: string;
286
301
  readonly expandNativeType?: NativeTypeExpander;
287
302
  readonly renderDefault?: DefaultRenderer;
303
+ /**
304
+ * Target-supplied resolver for namespace/schema-qualified enum annotation
305
+ * keys. When provided (Postgres), every namespace-scoped enum is keyed by the
306
+ * resolver's output so the projected `storageTypes` map matches the target's
307
+ * `readExistingEnumValues` lookup. Targets without namespace-qualified enum
308
+ * storage (SQLite) omit it; enums are absent there.
309
+ */
310
+ readonly resolveEnumStorageKey?: EnumStorageKeyResolver;
288
311
  }
289
312
  /**
290
313
  * Converts a `Contract` to `SqlSchemaIR`.
@@ -411,5 +434,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
411
434
  //#region src/exports/control.d.ts
412
435
  declare const _default: SqlFamilyDescriptor;
413
436
  //#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 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 };
437
+ export { type CodecControlHooks, type ContractToSchemaIROptions, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumStorageKeyResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, 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
438
  //# 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,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,0BAAA,CACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADdf;;;;KE2BY,kBAAA,IAAsB,KAAA;EAAA,SACvB,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAA;AAAA;;;;;;;;;;KAYZ,eAAA,IAAmB,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,aAAA;;;;;;;;;;iBAgK3C,wBAAA,CACd,IAAA,EAAM,UAAA,SACN,EAAA,EAAI,UAAA,YACM,0BAAA;AAAA,UA8CK,yBAAA;EAAA,SACN,mBAAA;EAAA,SACA,gBAAA,GAAmB,kBAAA;EAAA,SACnB,aAAA,GAAgB,eAAA;AAAA;;;;;;;;;;;;;;;iBAiBX,kBAAA,CACd,QAAA,EAAU,QAAA,CAAS,UAAA,UACnB,OAAA,EAAS,yBAAA,GACR,WAAA;;;UC/Pc,+BAAA;EHZI;;;;EAAA,SGiBV,aAAA,EAAe,QAAA,CAAS,UAAA;;;;WAIxB,WAAA,EAAa,QAAA,CAAS,UAAA;;;;;;;;;;WAUtB,UAAA,EAAY,WAAA,SAAoB,iBAAA;AAAA;AAAA,iBAa3B,wBAAA,CACd,OAAA,EAAS,+BAAA,YACC,aAAA;;;iBCgCI,mBAAA,gBAAA,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,I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AA,CAAS,UAAA;;;;;;;;;;WAUtB,UAAA,EAAY,WAAA,SAAoB,iBAAA;AAAA;AAAA,iBAa3B,wBAAA,CACd,OAAA,EAAS,+BAAA,YACC,aAAa;;;iBCgCT,mBAAA,gBAAA,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,uBAAuB;;;;iBAoBjF,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAE,CAAC,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,0BAEjC;;;;;;;;;;;;;;iBCoBc,6BAAA,CAAA,GAAiC,kCAAkC;;;;;;;;;;;iBAoBnE,wBAAA,+DAAA,CAGd,KAAA;EAAA,SAAkB,OAAA,EAAS,OAAA;EAAA,SAAkB,UAAA,EAAY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCuBlB,QAAA"}
package/dist/control.mjs CHANGED
@@ -1,14 +1,16 @@
1
1
  import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-F4JpCJl7.mjs";
2
- import { t as SqlContractSerializer } from "./sql-contract-serializer-VVoSAnYg.mjs";
3
- import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-DcP55TWb.mjs";
2
+ import { t as SqlContractSerializer } from "./sql-contract-serializer-8axtK4lg.mjs";
3
+ import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-CYLsGCFO.mjs";
4
4
  import { t as collectSupportedCodecTypeIds } from "./verify-Crewz6hG.mjs";
5
5
  import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-r7BP5n3l.mjs";
6
6
  import { sqlEmission } from "@prisma-next/sql-contract-emitter";
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 { sqlContractCanonicalizationHooks } from "@prisma-next/sql-contract/canonicalization-hooks";
9
10
  import { ensureSchemaStatement, ensureTableStatement, writeContractMarker } from "@prisma-next/sql-runtime";
10
11
  import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
11
12
  import { ifDefined } from "@prisma-next/utils/defined";
13
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
12
14
  import { StorageTable, isPostgresEnumStorageEntry, isStorageTypeInstance, toStorageTypeInstance } from "@prisma-next/sql-contract/types";
13
15
  import { UNSPECIFIED_PSL_NAMESPACE_ID } from "@prisma-next/framework-components/psl-ast";
14
16
  import { notOk, ok } from "@prisma-next/utils/result";
@@ -1091,7 +1093,8 @@ function createSqlFamilyInstance(stack) {
1091
1093
  target: contractJson.target,
1092
1094
  targetFamily: contractJson.targetFamily,
1093
1095
  storage: contractJson.storage,
1094
- headRefHash: headRef.hash
1096
+ headRefHash: headRef.hash,
1097
+ ...sqlContractCanonicalizationHooks
1095
1098
  });
1096
1099
  }
1097
1100
  const { codecTypeImports, extensionIds } = stack;
@@ -1211,6 +1214,7 @@ function createSqlFamilyInstance(stack) {
1211
1214
  verifySchema(options) {
1212
1215
  const contract = deserializeWithTargetSerializer(options.contract);
1213
1216
  const controlAdapter = getControlAdapter();
1217
+ const resolveExistingEnumValues = controlAdapter.resolveExistingEnumValuesForContract?.(contract) ?? controlAdapter.resolveExistingEnumValues;
1214
1218
  return verifySqlSchema({
1215
1219
  contract,
1216
1220
  schema: options.schema,
@@ -1219,7 +1223,7 @@ function createSqlFamilyInstance(stack) {
1219
1223
  frameworkComponents: options.frameworkComponents,
1220
1224
  ...ifDefined("normalizeDefault", controlAdapter.normalizeDefault),
1221
1225
  ...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType),
1222
- ...ifDefined("resolveExistingEnumValues", controlAdapter.resolveExistingEnumValues)
1226
+ ...ifDefined("resolveExistingEnumValues", resolveExistingEnumValues)
1223
1227
  });
1224
1228
  },
1225
1229
  async sign(options) {
@@ -1465,7 +1469,9 @@ function convertForeignKey(fk) {
1465
1469
  referencedTable: fk.target.tableName,
1466
1470
  referencedSchema: fk.target.namespaceId,
1467
1471
  referencedColumns: fk.target.columns,
1468
- ...ifDefined("name", fk.name)
1472
+ ...ifDefined("name", fk.name),
1473
+ ...ifDefined("onDelete", fk.onDelete),
1474
+ ...ifDefined("onUpdate", fk.onUpdate)
1469
1475
  };
1470
1476
  }
1471
1477
  function convertTable(name, table, storageTypes, expandNativeType, renderDefault) {
@@ -1570,30 +1576,44 @@ function contractToSchemaIR(contract, options) {
1570
1576
  }
1571
1577
  return {
1572
1578
  tables,
1573
- ...ifDefined("annotations", deriveAnnotations(storage, options.annotationNamespace))
1579
+ ...ifDefined("annotations", deriveAnnotations(storage, options.annotationNamespace, options.resolveEnumStorageKey))
1574
1580
  };
1575
1581
  }
1576
- function deriveAnnotations(storage, annotationNamespace) {
1577
- const allTypes = { ...storage.types ?? {} };
1578
- for (const ns of Object.values(storage.namespaces)) {
1579
- const nsEnums = ns.enum;
1580
- if (nsEnums) for (const [k, v] of Object.entries(nsEnums)) allTypes[k] = v;
1581
- }
1582
- const types = allTypes;
1583
- if (Object.keys(types).length === 0) return void 0;
1584
- const byNativeType = {};
1585
- for (const typeInstance of Object.values(types)) {
1582
+ /**
1583
+ * Normalises a native enum storage entry to the codec-typed annotation shape
1584
+ * `{codecId, nativeType, typeParams}` the introspector writes and
1585
+ * `readExistingEnumValues` reads (`existing.codecId` + `existing.typeParams.values`).
1586
+ * Without this the projector would emit the raw `PostgresEnumStorageEntry`
1587
+ * shape (top-level `values`, no `typeParams`) and the enum would read as new.
1588
+ */
1589
+ function normalizeEnumAnnotation(entry) {
1590
+ return toStorageTypeInstance({
1591
+ codecId: entry.codecId,
1592
+ nativeType: entry.nativeType,
1593
+ typeParams: { values: entry.values }
1594
+ });
1595
+ }
1596
+ function deriveAnnotations(storage, annotationNamespace, resolveEnumStorageKey) {
1597
+ const storageTypes = {};
1598
+ for (const typeInstance of Object.values(storage.types ?? {})) {
1586
1599
  if (isPostgresEnumStorageEntry(typeInstance)) {
1587
- byNativeType[typeInstance.nativeType] = toStorageTypeInstance({
1588
- codecId: typeInstance.codecId,
1589
- nativeType: typeInstance.nativeType,
1590
- typeParams: { values: typeInstance.values }
1591
- });
1600
+ const key = resolveEnumStorageKey ? resolveEnumStorageKey(storage, UNBOUND_NAMESPACE_ID, typeInstance.nativeType) : typeInstance.nativeType;
1601
+ storageTypes[key] = normalizeEnumAnnotation(typeInstance);
1592
1602
  continue;
1593
1603
  }
1594
- if (isStorageTypeInstance(typeInstance)) byNativeType[typeInstance.nativeType] = typeInstance;
1604
+ if (isStorageTypeInstance(typeInstance)) storageTypes[typeInstance.nativeType] = typeInstance;
1605
+ }
1606
+ for (const [namespaceId, ns] of Object.entries(storage.namespaces)) {
1607
+ const nsEnums = ns.enum;
1608
+ if (!nsEnums) continue;
1609
+ for (const entry of Object.values(nsEnums)) {
1610
+ if (!isPostgresEnumStorageEntry(entry)) continue;
1611
+ const key = resolveEnumStorageKey ? resolveEnumStorageKey(storage, namespaceId, entry.nativeType) : entry.nativeType;
1612
+ storageTypes[key] = normalizeEnumAnnotation(entry);
1613
+ }
1595
1614
  }
1596
- return { [annotationNamespace]: { storageTypes: byNativeType } };
1615
+ if (Object.keys(storageTypes).length === 0) return void 0;
1616
+ return { [annotationNamespace]: { storageTypes } };
1597
1617
  }
1598
1618
  //#endregion
1599
1619
  //#region src/core/migrations/field-event-planner.ts