@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.
- package/dist/authoring-type-constructors-F4JpCJl7.mjs.map +1 -1
- package/dist/control-adapter.d.mts +11 -4
- package/dist/control-adapter.d.mts.map +1 -1
- package/dist/control.d.mts +25 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +43 -23
- package/dist/control.mjs.map +1 -1
- package/dist/ir.d.mts +4 -1
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +1 -1
- package/dist/ir.mjs.map +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs.map +1 -1
- package/dist/pack.mjs.map +1 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-verify.d.mts +1 -1
- package/dist/schema-verify.d.mts.map +1 -1
- package/dist/schema-verify.mjs +1 -1
- package/dist/{sql-contract-serializer-VVoSAnYg.mjs → sql-contract-serializer-8axtK4lg.mjs} +20 -7
- package/dist/sql-contract-serializer-8axtK4lg.mjs.map +1 -0
- package/dist/timestamp-now-generator-r7BP5n3l.mjs.map +1 -1
- package/dist/{types-hQoMXr54.d.mts → types-CeeCStqw.d.mts} +22 -41
- package/dist/types-CeeCStqw.d.mts.map +1 -0
- package/dist/verify-Crewz6hG.mjs.map +1 -1
- package/dist/{verify-sql-schema-Bfvz07Ik.d.mts → verify-sql-schema-CN7pPoTC.d.mts} +2 -2
- package/dist/verify-sql-schema-CN7pPoTC.d.mts.map +1 -0
- package/dist/{verify-sql-schema-DcP55TWb.mjs → verify-sql-schema-CYLsGCFO.mjs} +50 -36
- package/dist/verify-sql-schema-CYLsGCFO.mjs.map +1 -0
- package/dist/verify.d.mts.map +1 -1
- package/package.json +32 -21
- package/src/core/control-adapter.ts +16 -2
- package/src/core/control-instance.ts +6 -1
- package/src/core/ir/sql-contract-serializer-base.ts +48 -10
- package/src/core/migrations/contract-to-schema-ir.ts +83 -34
- package/src/core/migrations/types.ts +21 -45
- package/src/core/schema-verify/verify-sql-schema.ts +89 -40
- package/src/exports/control.ts +1 -3
- package/dist/sql-contract-serializer-VVoSAnYg.mjs.map +0 -1
- package/dist/types-hQoMXr54.d.mts.map +0 -1
- package/dist/verify-sql-schema-Bfvz07Ik.d.mts.map +0 -1
- 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;
|
|
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,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,QAAQ;EACN,MAAM;EACN,MAAM,CAAC,qBAAqB;EAC5B,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ;IACN,MAAM;IACN,OAAO;IACP,MAAM,CAAC,MAAM;IACb,SAAS;GACX,EACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,GACV;EACF;CACF;CACA,IAAI;EACF,QAAQ;GACN,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,QAAQ;GACN,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,MAAM;GACJ,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,QAAQ;GACN,MAAM;GACN,MAAM,CAAC,qBAAqB;GAC5B,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ;KACN,MAAM;KACN,OAAO;KACP,MAAM,CAAC,MAAM;KACb,SAAS;IACX,EACF;IACA,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,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-
|
|
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;;;;UAAi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as
|
|
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
|
|
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
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,0BAAA,CACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADdf;;;;
|
|
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,EA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AA,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-
|
|
3
|
-
import { a as extractCodecControlHooks, t as verifySqlSchema } from "./verify-sql-schema-
|
|
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",
|
|
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
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
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
|
-
|
|
1588
|
-
|
|
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))
|
|
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
|
-
|
|
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
|