@prisma-next/sql-contract 0.12.0-dev.40 → 0.12.0-dev.42

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.
@@ -5,20 +5,23 @@ const sqlContractCanonicalizationHooks = {
5
5
  "storage",
6
6
  "namespaces",
7
7
  "*",
8
- "tables"
8
+ "entries",
9
+ "table"
9
10
  ],
10
11
  [
11
12
  "storage",
12
13
  "namespaces",
13
14
  "*",
14
- "tables",
15
+ "entries",
16
+ "table",
15
17
  "*"
16
18
  ],
17
19
  [
18
20
  "storage",
19
21
  "namespaces",
20
22
  "*",
21
- "tables",
23
+ "entries",
24
+ "table",
22
25
  "*",
23
26
  [
24
27
  "uniques",
@@ -30,7 +33,8 @@ const sqlContractCanonicalizationHooks = {
30
33
  "storage",
31
34
  "namespaces",
32
35
  "*",
33
- "tables",
36
+ "entries",
37
+ "table",
34
38
  "*",
35
39
  "foreignKeys",
36
40
  ["constraint", "index"]
@@ -46,7 +50,8 @@ const sqlContractCanonicalizationHooks = {
46
50
  path: [
47
51
  "namespaces",
48
52
  "*",
49
- "tables",
53
+ "entries",
54
+ "table",
50
55
  "*"
51
56
  ],
52
57
  arrayKeys: ["indexes", "uniques"]
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalization-hooks.mjs","names":[],"sources":["../src/canonicalization-hooks.ts"],"sourcesContent":["import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/hashing';\nimport {\n createPreserveEmptyPredicate,\n createStorageSort,\n type NamedArraySortTarget,\n type PathPattern,\n} from '@prisma-next/contract/hashing-utils';\n\nconst preserveEmptyPatterns = [\n ['storage', 'namespaces', '*', 'tables'],\n ['storage', 'namespaces', '*', 'tables', '*'],\n ['storage', 'namespaces', '*', 'tables', '*', ['uniques', 'indexes', 'foreignKeys']],\n ['storage', 'namespaces', '*', 'tables', '*', 'foreignKeys', ['constraint', 'index']],\n ['storage', 'types', '*', 'typeParams'],\n] as const satisfies readonly PathPattern[];\n\nconst sortTargets = [\n { path: ['namespaces', '*', 'tables', '*'], arrayKeys: ['indexes', 'uniques'] },\n] as const satisfies readonly NamedArraySortTarget[];\n\nconst shouldPreserveEmpty: PreserveEmptyPredicate =\n createPreserveEmptyPredicate(preserveEmptyPatterns);\n\nconst sortStorage: StorageSort = createStorageSort(sortTargets);\n\nexport const sqlContractCanonicalizationHooks: {\n readonly shouldPreserveEmpty: PreserveEmptyPredicate;\n readonly sortStorage: StorageSort;\n} = {\n shouldPreserveEmpty,\n sortStorage,\n};\n"],"mappings":";AAyBA,MAAa,mCAGT;CACF,qBARA,6BAA6B;EAZ7B;GAAC;GAAW;GAAc;GAAK;EAAQ;EACvC;GAAC;GAAW;GAAc;GAAK;GAAU;EAAG;EAC5C;GAAC;GAAW;GAAc;GAAK;GAAU;GAAK;IAAC;IAAW;IAAW;GAAa;EAAC;EACnF;GAAC;GAAW;GAAc;GAAK;GAAU;GAAK;GAAe,CAAC,cAAc,OAAO;EAAC;EACpF;GAAC;GAAW;GAAS;GAAK;EAAY;CAQT,CAQ7B;CACA,aAP+B,kBAAkB,CANjD;EAAE,MAAM;GAAC;GAAc;GAAK;GAAU;EAAG;EAAG,WAAW,CAAC,WAAW,SAAS;CAAE,CAM7B,CAOjD;AACF"}
1
+ {"version":3,"file":"canonicalization-hooks.mjs","names":[],"sources":["../src/canonicalization-hooks.ts"],"sourcesContent":["import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/hashing';\nimport {\n createPreserveEmptyPredicate,\n createStorageSort,\n type NamedArraySortTarget,\n type PathPattern,\n} from '@prisma-next/contract/hashing-utils';\n\nconst preserveEmptyPatterns = [\n ['storage', 'namespaces', '*', 'entries', 'table'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*'],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', ['uniques', 'indexes', 'foreignKeys']],\n ['storage', 'namespaces', '*', 'entries', 'table', '*', 'foreignKeys', ['constraint', 'index']],\n ['storage', 'types', '*', 'typeParams'],\n] as const satisfies readonly PathPattern[];\n\nconst sortTargets = [\n { path: ['namespaces', '*', 'entries', 'table', '*'], arrayKeys: ['indexes', 'uniques'] },\n] as const satisfies readonly NamedArraySortTarget[];\n\nconst shouldPreserveEmpty: PreserveEmptyPredicate =\n createPreserveEmptyPredicate(preserveEmptyPatterns);\n\nconst sortStorage: StorageSort = createStorageSort(sortTargets);\n\nexport const sqlContractCanonicalizationHooks: {\n readonly shouldPreserveEmpty: PreserveEmptyPredicate;\n readonly sortStorage: StorageSort;\n} = {\n shouldPreserveEmpty,\n sortStorage,\n};\n"],"mappings":";AAyBA,MAAa,mCAGT;CACF,qBARA,6BAA6B;EAZ7B;GAAC;GAAW;GAAc;GAAK;GAAW;EAAO;EACjD;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;EAAG;EACtD;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;GAAK;IAAC;IAAW;IAAW;GAAa;EAAC;EAC7F;GAAC;GAAW;GAAc;GAAK;GAAW;GAAS;GAAK;GAAe,CAAC,cAAc,OAAO;EAAC;EAC9F;GAAC;GAAW;GAAS;GAAK;EAAY;CAQT,CAQ7B;CACA,aAP+B,kBAAkB,CANjD;EAAE,MAAM;GAAC;GAAc;GAAK;GAAW;GAAS;EAAG;EAAG,WAAW,CAAC,WAAW,SAAS;CAAE,CAMvC,CAOjD;AACF"}
@@ -1,5 +1,5 @@
1
- import { T as ForeignKey, _ as StorageColumnInput, b as PrimaryKey, f as StorageTable, g as StorageColumn, m as UniqueConstraint, v as Index } from "./sql-storage-DPT3m3zO.mjs";
2
- import { b as SqlModelStorage, f as ForeignKeyOptions, y as SqlModelFieldStorage } from "./types-RVAlD0Qk.mjs";
1
+ import { S as ForeignKey, _ as StorageColumnInput, b as PrimaryKey, f as StorageTable, g as StorageColumn, m as UniqueConstraint, v as Index } from "./sql-storage-CV7Tc9Vh.mjs";
2
+ import { b as SqlModelStorage, f as ForeignKeyOptions, y as SqlModelFieldStorage } from "./types-ZwTLmfx4.mjs";
3
3
  import { ScalarFieldType } from "@prisma-next/contract/types";
4
4
 
5
5
  //#region src/factories.d.ts
@@ -1,4 +1,4 @@
1
- import { _ as PrimaryKey, g as Index, h as StorageColumn, m as UniqueConstraint, p as StorageTable, r as applyFkDefaults, v as ForeignKey } from "./types-BYtBgKiP.mjs";
1
+ import { _ as PrimaryKey, g as Index, h as StorageColumn, m as UniqueConstraint, p as StorageTable, r as applyFkDefaults, v as ForeignKey } from "./types-ByD-iN24.mjs";
2
2
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
3
3
  import { asNamespaceId } from "@prisma-next/contract/types";
4
4
  //#region src/factories.ts
@@ -1,4 +1,4 @@
1
- import { r as SqlStorage } from "./sql-storage-DPT3m3zO.mjs";
1
+ import { r as SqlStorage } from "./sql-storage-CV7Tc9Vh.mjs";
2
2
  import { a as IndexTypeRegistry } from "./index-types-DqVqGHwg.mjs";
3
3
  import { Contract } from "@prisma-next/contract/types";
4
4
 
@@ -2,7 +2,7 @@ import { ContractValidationError } from "@prisma-next/contract/contract-validati
2
2
  import { type } from "arktype";
3
3
  //#region src/index-type-validation.ts
4
4
  function validateIndexTypes(contract, indexTypeRegistry) {
5
- for (const [namespaceId, ns] of Object.entries(contract.storage.namespaces)) for (const [tableName, rawTable] of Object.entries(ns.tables)) {
5
+ for (const [namespaceId, ns] of Object.entries(contract.storage.namespaces)) for (const [tableName, rawTable] of Object.entries(ns.entries.table)) {
6
6
  const table = rawTable;
7
7
  for (const index of table.indexes) {
8
8
  if (index.type === void 0 && index.options !== void 0) throw new ContractValidationError(`Namespace "${namespaceId}" table "${tableName}" index on columns [${index.columns.join(", ")}] has options without a type`, "storage");
@@ -1 +1 @@
1
- {"version":3,"file":"index-type-validation.mjs","names":[],"sources":["../src/index-type-validation.ts"],"sourcesContent":["import { ContractValidationError } from '@prisma-next/contract/contract-validation-error';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { type } from 'arktype';\nimport type { IndexTypeRegistry } from './index-types';\nimport type { SqlStorage, StorageTable } from './types';\n\nexport function validateIndexTypes(\n contract: Contract<SqlStorage>,\n indexTypeRegistry: IndexTypeRegistry,\n): void {\n for (const [namespaceId, ns] of Object.entries(contract.storage.namespaces)) {\n for (const [tableName, rawTable] of Object.entries(ns.tables)) {\n const table = rawTable as StorageTable;\n for (const index of table.indexes) {\n if (index.type === undefined && index.options !== undefined) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] has options without a type`,\n 'storage',\n );\n }\n if (index.type === undefined) continue;\n const entry = indexTypeRegistry.get(index.type);\n if (entry === undefined) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] uses unregistered index type \"${index.type}\"`,\n 'storage',\n );\n }\n const optionsValue = index.options ?? {};\n const result = entry.options(optionsValue);\n if (result instanceof type.errors) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] has invalid options for type \"${index.type}\": ${result.summary}`,\n 'storage',\n );\n }\n }\n }\n }\n}\n"],"mappings":";;;AAMA,SAAgB,mBACd,UACA,mBACM;CACN,KAAK,MAAM,CAAC,aAAa,OAAO,OAAO,QAAQ,SAAS,QAAQ,UAAU,GACxE,KAAK,MAAM,CAAC,WAAW,aAAa,OAAO,QAAQ,GAAG,MAAM,GAAG;EAC7D,MAAM,QAAQ;EACd,KAAK,MAAM,SAAS,MAAM,SAAS;GACjC,IAAI,MAAM,SAAS,KAAA,KAAa,MAAM,YAAY,KAAA,GAChD,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,+BAC9F,SACF;GAEF,IAAI,MAAM,SAAS,KAAA,GAAW;GAC9B,MAAM,QAAQ,kBAAkB,IAAI,MAAM,IAAI;GAC9C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,kCAAkC,MAAM,KAAK,IAC3I,SACF;GAEF,MAAM,eAAe,MAAM,WAAW,CAAC;GACvC,MAAM,SAAS,MAAM,QAAQ,YAAY;GACzC,IAAI,kBAAkB,KAAK,QACzB,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,kCAAkC,MAAM,KAAK,KAAK,OAAO,WACvJ,SACF;EAEJ;CACF;AAEJ"}
1
+ {"version":3,"file":"index-type-validation.mjs","names":[],"sources":["../src/index-type-validation.ts"],"sourcesContent":["import { ContractValidationError } from '@prisma-next/contract/contract-validation-error';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { type } from 'arktype';\nimport type { IndexTypeRegistry } from './index-types';\nimport type { SqlStorage, StorageTable } from './types';\n\nexport function validateIndexTypes(\n contract: Contract<SqlStorage>,\n indexTypeRegistry: IndexTypeRegistry,\n): void {\n for (const [namespaceId, ns] of Object.entries(contract.storage.namespaces)) {\n for (const [tableName, rawTable] of Object.entries(ns.entries.table)) {\n const table = rawTable as StorageTable;\n for (const index of table.indexes) {\n if (index.type === undefined && index.options !== undefined) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] has options without a type`,\n 'storage',\n );\n }\n if (index.type === undefined) continue;\n const entry = indexTypeRegistry.get(index.type);\n if (entry === undefined) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] uses unregistered index type \"${index.type}\"`,\n 'storage',\n );\n }\n const optionsValue = index.options ?? {};\n const result = entry.options(optionsValue);\n if (result instanceof type.errors) {\n throw new ContractValidationError(\n `Namespace \"${namespaceId}\" table \"${tableName}\" index on columns [${index.columns.join(', ')}] has invalid options for type \"${index.type}\": ${result.summary}`,\n 'storage',\n );\n }\n }\n }\n }\n}\n"],"mappings":";;;AAMA,SAAgB,mBACd,UACA,mBACM;CACN,KAAK,MAAM,CAAC,aAAa,OAAO,OAAO,QAAQ,SAAS,QAAQ,UAAU,GACxE,KAAK,MAAM,CAAC,WAAW,aAAa,OAAO,QAAQ,GAAG,QAAQ,KAAK,GAAG;EACpE,MAAM,QAAQ;EACd,KAAK,MAAM,SAAS,MAAM,SAAS;GACjC,IAAI,MAAM,SAAS,KAAA,KAAa,MAAM,YAAY,KAAA,GAChD,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,+BAC9F,SACF;GAEF,IAAI,MAAM,SAAS,KAAA,GAAW;GAC9B,MAAM,QAAQ,kBAAkB,IAAI,MAAM,IAAI;GAC9C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,kCAAkC,MAAM,KAAK,IAC3I,SACF;GAEF,MAAM,eAAe,MAAM,WAAW,CAAC;GACvC,MAAM,SAAS,MAAM,QAAQ,YAAY;GACzC,IAAI,kBAAkB,KAAK,QACzB,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,IAAI,EAAE,kCAAkC,MAAM,KAAK,KAAK,OAAO,WACvJ,SACF;EAEJ;CACF;AAEJ"}
@@ -1,4 +1,4 @@
1
- import { f as StorageTable, r as SqlStorage } from "./sql-storage-DPT3m3zO.mjs";
1
+ import { f as StorageTable, r as SqlStorage } from "./sql-storage-CV7Tc9Vh.mjs";
2
2
 
3
3
  //#region src/resolve-storage-table.d.ts
4
4
  interface ResolvedStorageTable {
@@ -1,7 +1,7 @@
1
1
  //#region src/resolve-storage-table.ts
2
2
  function tableInNamespace(namespace, tableName) {
3
3
  if (namespace === void 0) return;
4
- const tables = namespace.tables;
4
+ const tables = namespace.entries.table;
5
5
  if (!Object.hasOwn(tables, tableName)) return;
6
6
  return tables[tableName];
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-storage-table.mjs","names":[],"sources":["../src/resolve-storage-table.ts"],"sourcesContent":["import type { SqlNamespace, SqlStorage } from './ir/sql-storage';\nimport type { StorageTable } from './ir/storage-table';\n\nexport interface ResolvedStorageTable {\n readonly namespaceId: string;\n readonly table: StorageTable;\n}\n\nfunction tableInNamespace(\n namespace: SqlNamespace | undefined,\n tableName: string,\n): StorageTable | undefined {\n if (namespace === undefined) {\n return undefined;\n }\n const tables = namespace.tables;\n if (!Object.hasOwn(tables, tableName)) {\n return undefined;\n }\n return tables[tableName];\n}\n\n/**\n * Resolve a bare storage table name to its namespace coordinate and table IR by\n * scanning the contract's namespaces. For the single-namespace contracts in\n * scope the scan is exact; cross-namespace bare-name collisions are selected\n * explicitly (TML-2550).\n */\nexport function resolveStorageTable(\n storage: SqlStorage,\n tableName: string,\n): ResolvedStorageTable | undefined {\n for (const namespaceId of Object.keys(storage.namespaces)) {\n const table = tableInNamespace(storage.namespaces[namespaceId], tableName);\n if (table !== undefined) {\n return { namespaceId, table };\n }\n }\n\n return undefined;\n}\n"],"mappings":";AAQA,SAAS,iBACP,WACA,WAC0B;CAC1B,IAAI,cAAc,KAAA,GAChB;CAEF,MAAM,SAAS,UAAU;CACzB,IAAI,CAAC,OAAO,OAAO,QAAQ,SAAS,GAClC;CAEF,OAAO,OAAO;AAChB;;;;;;;AAQA,SAAgB,oBACd,SACA,WACkC;CAClC,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG;EACzD,MAAM,QAAQ,iBAAiB,QAAQ,WAAW,cAAc,SAAS;EACzE,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE;GAAa;EAAM;CAEhC;AAGF"}
1
+ {"version":3,"file":"resolve-storage-table.mjs","names":[],"sources":["../src/resolve-storage-table.ts"],"sourcesContent":["import type { SqlNamespace, SqlStorage } from './ir/sql-storage';\nimport type { StorageTable } from './ir/storage-table';\n\nexport interface ResolvedStorageTable {\n readonly namespaceId: string;\n readonly table: StorageTable;\n}\n\nfunction tableInNamespace(\n namespace: SqlNamespace | undefined,\n tableName: string,\n): StorageTable | undefined {\n if (namespace === undefined) {\n return undefined;\n }\n const tables = namespace.entries.table;\n if (!Object.hasOwn(tables, tableName)) {\n return undefined;\n }\n return tables[tableName];\n}\n\n/**\n * Resolve a bare storage table name to its namespace coordinate and table IR by\n * scanning the contract's namespaces. For the single-namespace contracts in\n * scope the scan is exact; cross-namespace bare-name collisions are selected\n * explicitly (TML-2550).\n */\nexport function resolveStorageTable(\n storage: SqlStorage,\n tableName: string,\n): ResolvedStorageTable | undefined {\n for (const namespaceId of Object.keys(storage.namespaces)) {\n const table = tableInNamespace(storage.namespaces[namespaceId], tableName);\n if (table !== undefined) {\n return { namespaceId, table };\n }\n }\n\n return undefined;\n}\n"],"mappings":";AAQA,SAAS,iBACP,WACA,WAC0B;CAC1B,IAAI,cAAc,KAAA,GAChB;CAEF,MAAM,SAAS,UAAU,QAAQ;CACjC,IAAI,CAAC,OAAO,OAAO,QAAQ,SAAS,GAClC;CAEF,OAAO,OAAO;AAChB;;;;;;;AAQA,SAAgB,oBACd,SACA,WACkC;CAClC,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG;EACzD,MAAM,QAAQ,iBAAiB,QAAQ,WAAW,cAAc,SAAS;EACzE,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE;GAAa;EAAM;CAEhC;AAGF"}
@@ -95,57 +95,6 @@ declare class ForeignKey extends SqlNode {
95
95
  constructor(input: ForeignKeyInput);
96
96
  }
97
97
  //#endregion
98
- //#region src/ir/postgres-enum-storage-entry.d.ts
99
- /**
100
- * Discriminator literal for the Postgres-enum variant on the polymorphic
101
- * `SqlStorage.types` slot.
102
- *
103
- * Enums are a target-level concept: Postgres ships native
104
- * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
105
- * constraints. The literal lives at the SQL family layer because every
106
- * SQL-family consumer (verifier, planner, lowering, …) needs to
107
- * discriminate enum-typed slot entries from codec-typed ones. The
108
- * concrete IR class (`PostgresEnumType`) lives in the target-postgres
109
- * package and implements this structural contract; cross-domain
110
- * layering rules forbid the SQL family from importing the concrete
111
- * target class directly, so the discriminator and structural interface
112
- * carry the dispatch.
113
- */
114
- declare const POSTGRES_ENUM_KIND: "postgres-enum";
115
- /**
116
- * Structural contract every Postgres-enum slot entry honours — both
117
- * the live `PostgresEnumType` IR-class instance and the raw JSON
118
- * envelope shape that survives `JSON.stringify` round-trips. SQL
119
- * family-layer dispatch narrows polymorphic `StorageType` slot
120
- * entries to this shape via `isPostgresEnumStorageEntry`.
121
- *
122
- * The `codecBinding` field is accessor-shaped (live class instance) on
123
- * the IR class and undefined on the raw JSON envelope; consumers that
124
- * need it must guard for its presence (the JSON path synthesises an
125
- * equivalent shape from `codecId` + `values`).
126
- */
127
- interface PostgresEnumStorageEntry extends StorageType {
128
- readonly kind: typeof POSTGRES_ENUM_KIND;
129
- readonly name: string;
130
- readonly nativeType: string;
131
- readonly values: readonly string[];
132
- /**
133
- * Enumerable own property on the persisted JSON envelope; the live
134
- * IR-class instance carries it too. Family-shared dispatch sites
135
- * read `codecId` directly rather than going through the IR-class
136
- * `codecBinding` accessor (which lives on the prototype and isn't
137
- * present on raw JSON envelopes).
138
- */
139
- readonly codecId: string;
140
- readonly control?: ControlPolicy;
141
- }
142
- /**
143
- * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
144
- * via its enumerable `kind` discriminator. Type guard returns true for
145
- * both live `PostgresEnumType` instances and raw JSON envelopes.
146
- */
147
- declare function isPostgresEnumStorageEntry(value: unknown): value is PostgresEnumStorageEntry;
148
- //#endregion
149
98
  //#region src/ir/primary-key.d.ts
150
99
  interface PrimaryKeyInput {
151
100
  readonly columns: readonly string[];
@@ -321,15 +270,17 @@ declare function isStorageTypeInstance(value: unknown): value is StorageTypeInst
321
270
  //#region src/ir/sql-storage.d.ts
322
271
  /**
323
272
  * Polymorphic value type for document-scoped `SqlStorage.types` entries
324
- * (codec aliases / parameterised native type registrations). Postgres
325
- * native enum registrations live under
326
- * `storage.namespaces[namespaceId].enum` instead.
273
+ * (codec aliases / parameterised native type registrations).
274
+ *
275
+ * Postgres native enum registrations live under the postgres-specific
276
+ * `entries.type` slot on `PostgresSchema` (target layer), not here.
327
277
  */
328
- type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput | PostgresEnumStorageEntry;
278
+ type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;
329
279
  interface SqlNamespaceTablesInput {
330
280
  readonly id: string;
331
- readonly tables?: Record<string, StorageTable | StorageTableInput>;
332
- readonly enum?: Record<string, PostgresEnumStorageEntry>;
281
+ readonly entries: {
282
+ readonly table: Record<string, StorageTable | StorageTableInput>;
283
+ };
333
284
  }
334
285
  interface SqlStorageInput<THash extends string = string> {
335
286
  readonly storageHash: StorageHashBase<THash>;
@@ -352,16 +303,15 @@ interface SqlStorageInput<THash extends string = string> {
352
303
  *
353
304
  * The constructor normalises optional `types` into class instances.
354
305
  * `types` is polymorphic per Decision 18 Option B: codec-triple inputs
355
- * are stamped with `kind: 'codec-instance'`; class-instance kinds
356
- * (e.g. Postgres-enum entries satisfying `PostgresEnumStorageEntry`)
357
- * pass through; hydration of raw JSON class-instance entries (carrying
358
- * their narrower `kind` literal) is the per-target serializer's
359
- * responsibility (so the family base does not import target-specific
360
- * subclasses).
306
+ * are stamped with `kind: 'codec-instance'`; hydration of raw JSON
307
+ * class-instance entries (carrying their narrower `kind` literal) is
308
+ * the per-target serializer's responsibility (so the family base does
309
+ * not import target-specific subclasses).
361
310
  */
362
311
  type SqlNamespace = Namespace & {
363
- readonly tables: Readonly<Record<string, StorageTable>>;
364
- readonly enum?: Readonly<Record<string, PostgresEnumStorageEntry>>;
312
+ readonly entries: Readonly<{
313
+ readonly table: Readonly<Record<string, StorageTable>>;
314
+ }>;
365
315
  /**
366
316
  * Render a dialect-qualified table reference for runtime SQL emission.
367
317
  * Present on materialised target concretions (`PostgresSchema`,
@@ -373,10 +323,10 @@ type SqlNamespace = Namespace & {
373
323
  declare class SqlStorage<THash extends string = string> extends SqlNode implements Storage {
374
324
  readonly storageHash: StorageHashBase<THash>;
375
325
  readonly namespaces: Readonly<Record<string, SqlNamespace>>;
376
- readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;
326
+ readonly types?: Readonly<Record<string, StorageTypeInstance>>;
377
327
  constructor(input: SqlStorageInput<THash>);
378
328
  }
379
329
  declare function storageTableAt(storage: SqlStorage, namespaceId: string, tableName: string): StorageTable | undefined;
380
330
  //#endregion
381
- export { SqlNode as A, PostgresEnumStorageEntry as C, ReferentialAction as D, ForeignKeyInput as E, ForeignKeyReference as O, POSTGRES_ENUM_KIND as S, ForeignKey as T, StorageColumnInput as _, SqlStorageTypeEntry as a, PrimaryKey as b, StorageTypeInstance as c, toStorageTypeInstance as d, StorageTable as f, StorageColumn as g, UniqueConstraintInput as h, SqlStorageInput as i, ForeignKeyReferenceInput as k, StorageTypeInstanceInput as l, UniqueConstraint as m, SqlNamespaceTablesInput as n, storageTableAt as o, StorageTableInput as p, SqlStorage as r, CODEC_INSTANCE_KIND as s, SqlNamespace as t, isStorageTypeInstance as u, Index as v, isPostgresEnumStorageEntry as w, PrimaryKeyInput as x, IndexInput as y };
382
- //# sourceMappingURL=sql-storage-DPT3m3zO.d.mts.map
331
+ export { ForeignKeyInput as C, SqlNode as D, ForeignKeyReferenceInput as E, ForeignKey as S, ForeignKeyReference as T, StorageColumnInput as _, SqlStorageTypeEntry as a, PrimaryKey as b, StorageTypeInstance as c, toStorageTypeInstance as d, StorageTable as f, StorageColumn as g, UniqueConstraintInput as h, SqlStorageInput as i, StorageTypeInstanceInput as l, UniqueConstraint as m, SqlNamespaceTablesInput as n, storageTableAt as o, StorageTableInput as p, SqlStorage as r, CODEC_INSTANCE_KIND as s, SqlNamespace as t, isStorageTypeInstance as u, Index as v, ReferentialAction as w, PrimaryKeyInput as x, IndexInput as y };
332
+ //# sourceMappingURL=sql-storage-CV7Tc9Vh.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-storage-CV7Tc9Vh.d.mts","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts","../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/storage-column.ts","../src/ir/unique-constraint.ts","../src/ir/storage-table.ts","../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts"],"mappings":";;;;;;;AAkCA;;;;;;;;;;;;AC9BA;;;;;;;;AAGkB;AAUlB;;;;;;;;uBDiBsB,OAAA,SAAgB,UAAU;EAAA,SACrC,IAAA;;;;;UC/BM,wBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;AAAA;;;;;;;;cAUE,mBAAA,SAA4B,OAAA;EAAA,SAC9B,WAAA,EAAa,WAAA;EAAA,SACb,SAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,wBAAA;AAAA;;;KClBT,iBAAA;AAAA,UAEK,eAAA;EAAA,SACN,MAAA,EAAQ,mBAAA,GAAsB,wBAAA;EAAA,SAC9B,MAAA,EAAQ,mBAAA,GAAsB,wBAAA;EAAA,SAC9B,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;EFwBX;EAAA,SEtBA,UAAA;;WAEA,KAAA;AAAA;;;ADXX;;;;;;;;AAGkB;AAUlB;cCaa,UAAA,SAAmB,OAAA;EAAA,SACrB,MAAA,EAAQ,mBAAA;EAAA,SACR,MAAA,EAAQ,mBAAA;EAAA,SACR,UAAA;EAAA,SACA,KAAA;EAAA,SACQ,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;cAEhB,KAAA,EAAO,eAAA;AAAA;;;UCpCJ,eAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAI;AAAA;;;;cAMF,UAAA,SAAmB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YAAA;EAAA;EPzDf;AAAA;AAE7B;;;;EO+DE,YAAA,EAAc,SAAA;AAAA;AAAA,cAGH,UAAA,wCAAkD,OAAA,YAAmB,OAAA;EAAA,SACvE,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAC5B,KAAA,GAAQ,QAAA,CAAS,MAAA,SAAe,mBAAA;cAErC,KAAA,EAAO,eAAA,CAAgB,KAAA;AAAA;AAAA,iBAerB,cAAA,CACd,OAAA,EAAS,UAAA,EACT,WAAA,UACA,SAAA,WACC,YAAY"}
@@ -16,9 +16,10 @@ import { asNamespaceId } from "@prisma-next/contract/types";
16
16
  * envelope and runtime walk are honest at every layer.
17
17
  *
18
18
  * The `kind` discriminator is installed as a non-enumerable own property
19
- * so the JSON envelope reads `{ "id": "__unbound__" }` — symmetric
20
- * with the family-level non-enumerable `kind` on `SqlNode` and bounded
21
- * to the minimum data the framework `Namespace` interface promises.
19
+ * so the JSON envelope reads `{ "id": "__unbound__", "entries": { … } }`
20
+ * — symmetric with the family-level non-enumerable `kind` on `SqlNode`
21
+ * and bounded to the minimum data the framework `Namespace` interface
22
+ * promises.
22
23
  *
23
24
  * **Freeze-trap warning.** The leaf constructor calls
24
25
  * `freezeNode(this)` after installing `kind`. The leaf-class shape
@@ -35,7 +36,7 @@ import { asNamespaceId } from "@prisma-next/contract/types";
35
36
  var SqlUnboundNamespace = class SqlUnboundNamespace extends NamespaceBase {
36
37
  static instance = new SqlUnboundNamespace();
37
38
  id = UNBOUND_NAMESPACE_ID;
38
- tables = Object.freeze({});
39
+ entries = Object.freeze({ table: Object.freeze({}) });
39
40
  constructor() {
40
41
  super();
41
42
  Object.defineProperty(this, "kind", {
@@ -269,23 +270,16 @@ function isMaterializedSqlNamespace(ns) {
269
270
  }
270
271
  var SqlBoundNamespace = class SqlBoundNamespace extends NamespaceBase {
271
272
  id;
272
- tables;
273
+ entries;
273
274
  static fromTablesInput(input) {
274
- const tableCount = Object.keys(input.tables ?? {}).length;
275
- const enumCount = Object.keys(input.enum ?? {}).length;
276
- if (input.id === UNBOUND_NAMESPACE_ID && tableCount === 0 && enumCount === 0) return castAs(SqlUnboundNamespace.instance);
275
+ const tableCount = Object.keys(input.entries.table).length;
276
+ if (input.id === UNBOUND_NAMESPACE_ID && tableCount === 0) return castAs(SqlUnboundNamespace.instance);
277
277
  return castAs(new SqlBoundNamespace(input));
278
278
  }
279
279
  constructor(input) {
280
280
  super();
281
281
  this.id = input.id;
282
- this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables ?? {}).map(([name, t]) => [name, t instanceof StorageTable ? t : new StorageTable(t)])));
283
- if (input.enum !== void 0 && Object.keys(input.enum).length > 0) Object.defineProperty(this, "enum", {
284
- value: Object.freeze({ ...input.enum }),
285
- writable: false,
286
- enumerable: true,
287
- configurable: false
288
- });
282
+ this.entries = Object.freeze({ table: Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)]))) });
289
283
  Object.defineProperty(this, "kind", {
290
284
  value: SQL_NAMESPACE_KIND,
291
285
  writable: false,
@@ -303,7 +297,7 @@ function buildSqlNamespace(input) {
303
297
  return SqlBoundNamespace.fromTablesInput(input);
304
298
  }
305
299
  function buildSqlNamespaceMap(namespaces) {
306
- return Object.fromEntries(Object.entries(namespaces).map(([nsKey, ns]) => [nsKey, isMaterializedSqlNamespace(ns) ? blindCast(ns) : SqlBoundNamespace.fromTablesInput(ns)]));
300
+ return Object.fromEntries(Object.entries(namespaces).map(([nsKey, ns]) => [nsKey, isMaterializedSqlNamespace(ns) ? blindCast(ns) : SqlBoundNamespace.fromTablesInput(blindCast(ns))]));
307
301
  }
308
302
  //#endregion
309
303
  //#region src/ir/postgres-enum-storage-entry.ts
@@ -378,13 +372,12 @@ var SqlStorage = class extends SqlNode {
378
372
  }
379
373
  };
380
374
  function storageTableAt(storage, namespaceId, tableName) {
381
- return storage.namespaces[namespaceId]?.tables?.[tableName];
375
+ return storage.namespaces[namespaceId]?.entries.table[tableName];
382
376
  }
383
377
  /**
384
378
  * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.
385
- * Every entry must carry a recognised `kind` discriminator — either
386
- * `'codec-instance'` (codec triple, family-shared) or
387
- * `'postgres-enum'` (target-specific IR class). Untagged or
379
+ * Every entry must carry a `kind: 'codec-instance'` discriminator or
380
+ * be an already-constructed `StorageTypeInstance`. Untagged or
388
381
  * unrecognised inputs throw a diagnostic naming the entry and its
389
382
  * `kind`, so format drift surfaces loudly at the deserializer
390
383
  * boundary instead of slipping past the seam and corrupting
@@ -398,14 +391,10 @@ function storageTableAt(storage, namespaceId, tableName) {
398
391
  * only fires for in-memory authoring bugs.
399
392
  */
400
393
  function normaliseTypeEntry(name, entry) {
401
- if (isPostgresEnumStorageEntry(entry)) {
402
- if (entry instanceof SqlNode) return entry;
403
- throw new Error(`Encountered raw postgres-enum JSON in storage.types[${JSON.stringify(name)}] without serializer hydration; use a target ContractSerializer that registers the matching entity-type factory.`);
404
- }
405
394
  if (isStorageTypeInstance(entry)) return entry;
406
395
  const rawKind = entry.kind;
407
396
  const kindDescription = rawKind === void 0 ? "missing `kind` discriminator" : `unrecognised \`kind\` discriminator ${JSON.stringify(rawKind)}`;
408
- throw new Error(`storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify("codec-instance")} or ${JSON.stringify("postgres-enum")}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`);
397
+ throw new Error(`storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify("codec-instance")}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`);
409
398
  }
410
399
  //#endregion
411
400
  //#region src/types.ts
@@ -420,4 +409,4 @@ function applyFkDefaults(fk, overrideDefaults) {
420
409
  //#endregion
421
410
  export { PrimaryKey as _, storageTableAt as a, SqlNode as b, toStorageTypeInstance as c, buildSqlNamespace as d, buildSqlNamespaceMap as f, Index as g, StorageColumn as h, SqlStorage as i, POSTGRES_ENUM_KIND as l, UniqueConstraint as m, DEFAULT_FK_INDEX as n, CODEC_INSTANCE_KIND as o, StorageTable as p, applyFkDefaults as r, isStorageTypeInstance as s, DEFAULT_FK_CONSTRAINT as t, isPostgresEnumStorageEntry as u, ForeignKey as v, SqlUnboundNamespace as x, ForeignKeyReference as y };
422
411
 
423
- //# sourceMappingURL=types-BYtBgKiP.mjs.map
412
+ //# sourceMappingURL=types-ByD-iN24.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-ByD-iN24.mjs","names":[],"sources":["../src/ir/sql-unbound-namespace.ts","../src/ir/sql-node.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts","../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/storage-column.ts","../src/ir/unique-constraint.ts","../src/ir/storage-table.ts","../src/ir/build-sql-namespace.ts","../src/ir/postgres-enum-storage-entry.ts","../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/types.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { StorageTable } from './storage-table';\n\n/**\n * Family-layer placeholder for the SQL unbound-namespace singleton —\n * the late-bound slot whose binding the target resolves at connection\n * time rather than at authoring time.\n *\n * SQL contracts honour the framework `Storage.namespaces` invariant from\n * the moment they appear in the IR. Today `SqlStorage` is family-shared\n * (Postgres + SQLite consume the same class); a per-target namespace\n * concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)\n * earns its existence when each target's namespace shape lands. Until\n * then the family ships a single placeholder singleton so the JSON\n * envelope and runtime walk are honest at every layer.\n *\n * The `kind` discriminator is installed as a non-enumerable own property\n * so the JSON envelope reads `{ \"id\": \"__unbound__\", \"entries\": { … } }`\n * — symmetric with the family-level non-enumerable `kind` on `SqlNode`\n * and bounded to the minimum data the framework `Namespace` interface\n * promises.\n *\n * **Freeze-trap warning.** The leaf constructor calls\n * `freezeNode(this)` after installing `kind`. The leaf-class shape\n * works today only because `NamespaceBase` does NOT freeze in its\n * constructor — the `Object.defineProperty(this, 'kind', …)` call after\n * `super()` succeeds because the instance is still mutable at that\n * point. Subclasses that add instance fields will still hit the freeze\n * trap once leaf-class `freezeNode(this)` runs; and if a future\n * framework change lifts the freeze to `NamespaceBase`, even the\n * `defineProperty` here would silently fail. To add subclass instance\n * fields safely, lift `freezeNode` to a leaf-class `seal()` hook each\n * leaf calls explicitly at the end of its own constructor.\n */\nexport class SqlUnboundNamespace extends NamespaceBase {\n static readonly instance: SqlUnboundNamespace = new SqlUnboundNamespace();\n\n readonly id = UNBOUND_NAMESPACE_ID;\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n }> = Object.freeze({ table: Object.freeze({}) });\n declare readonly kind: string;\n\n private constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql-namespace',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n}\n","import { IRNodeBase } from '@prisma-next/framework-components/ir';\n\n/**\n * SQL family IR node base. Carries the family-level `kind` discriminator\n * `'sql'` and inherits the framework's `freezeNode` affordance.\n *\n * Single family-level discriminator (not per-leaf) reflects the fact that\n * SQL IR has no polymorphic dispatch today — verifiers and serializers\n * walk by structural position (`storage.tables[name].columns[name]`),\n * not by inspecting `kind`. The abstract bar for per-leaf discriminators\n * isn't earned until a future polymorphic consumer arrives.\n *\n * `kind` is installed as a non-enumerable own property on every instance,\n * which keeps three things clean simultaneously:\n *\n * - `JSON.stringify(node)` produces the canonical pre-lift JSON envelope\n * shape (no `kind` field), so emitted contract.json files and the\n * `validateSqlContractFully` arktype schemas stay unchanged.\n * - Test assertions that use `toEqual({...})` against the pre-lift flat\n * shape continue to pass — only enumerable own properties are\n * compared.\n * - Direct access (`node.kind`) and runtime narrowing\n * (`if (node.kind === 'sql')`) still work, so future polymorphic\n * dispatch can begin reading `kind` without a runtime change.\n *\n * Future per-leaf overrides land cleanly: a class that gains a\n * polymorphic-dispatch consumer (e.g. an enum type instance walked\n * alongside other types) overrides `kind` with its narrower literal\n * at that leaf level. Per-leaf overrides will use enumerable kind\n * (matching the Mongo per-class-discriminator precedent) because they\n * encode dispatch-relevant information that callers need to see in\n * JSON envelopes; the family-level `'sql'` is uniform across all SQL\n * IR and carries no dispatch-relevant information.\n */\nexport abstract class SqlNode extends IRNodeBase {\n readonly kind?: string;\n\n constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql',\n writable: false,\n enumerable: false,\n // configurable so per-leaf subclasses (e.g. PostgresEnumType in\n // target-postgres) can override `kind` with their narrower\n // enumerable literal via a class-field initializer. SqlNode\n // itself never needs to mutate the property again, so\n // configurability has no surface impact at this layer.\n configurable: true,\n });\n }\n}\n","import { asNamespaceId, type NamespaceId } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface ForeignKeyReferenceInput {\n readonly namespaceId: string;\n readonly tableName: string;\n readonly columns: readonly string[];\n}\n\n/**\n * SQL Contract IR node for one side (source or target) of a foreign-key\n * declaration. Carries the full coordinate: namespace, table, and columns.\n *\n * Use `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`\n * as the sentinel `namespaceId` for single-namespace (unbound) references.\n */\nexport class ForeignKeyReference extends SqlNode {\n readonly namespaceId: NamespaceId;\n readonly tableName: string;\n readonly columns: readonly string[];\n\n constructor(input: ForeignKeyReferenceInput) {\n super();\n this.namespaceId = asNamespaceId(input.namespaceId);\n this.tableName = input.tableName;\n this.columns = input.columns;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKeyReference, type ForeignKeyReferenceInput } from './foreign-key-reference';\nimport { SqlNode } from './sql-node';\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface ForeignKeyInput {\n readonly source: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly target: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */\n readonly constraint: boolean;\n /** Whether to emit a backing index for the FK columns. */\n readonly index: boolean;\n}\n\n/**\n * SQL Contract IR node for a table-level foreign-key declaration.\n *\n * Each FK carries explicit `source` and `target` {@link ForeignKeyReference}\n * coordinates (namespace, table, columns). For single-namespace contracts the\n * sentinel `UNBOUND_NAMESPACE_ID` appears on both sides.\n *\n * The nested references are normalised to {@link ForeignKeyReference}\n * instances inside the constructor so downstream walks see a uniform AST\n * regardless of whether the input was a JSON literal or an already-constructed\n * class instance.\n */\nexport class ForeignKey extends SqlNode {\n readonly source: ForeignKeyReference;\n readonly target: ForeignKeyReference;\n readonly constraint: boolean;\n readonly index: boolean;\n declare readonly name?: string;\n declare readonly onDelete?: ReferentialAction;\n declare readonly onUpdate?: ReferentialAction;\n\n constructor(input: ForeignKeyInput) {\n super();\n this.source =\n input.source instanceof ForeignKeyReference\n ? input.source\n : new ForeignKeyReference(input.source);\n this.target =\n input.target instanceof ForeignKeyReference\n ? input.target\n : new ForeignKeyReference(input.target);\n this.constraint = input.constraint;\n this.index = input.index;\n if (input.name !== undefined) this.name = input.name;\n if (input.onDelete !== undefined) this.onDelete = input.onDelete;\n if (input.onUpdate !== undefined) this.onUpdate = input.onUpdate;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table's primary-key constraint.\n */\nexport class PrimaryKey extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: PrimaryKeyInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface IndexInput {\n readonly columns: readonly string[];\n readonly name?: string;\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\n/**\n * SQL Contract IR node for a table-level secondary index.\n *\n * Note that this class shadows the global TypeScript `Index` lib type\n * at the family-shared name; consumer files that need both should\n * alias one (e.g.\n * `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).\n */\nexport class Index extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n\n constructor(input: IndexInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n if (input.type !== undefined) this.type = input.type;\n if (input.options !== undefined) this.options = input.options;\n freezeNode(this);\n }\n}\n","import type { ColumnDefault, ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Hydration / construction input shape for {@link StorageColumn}. Mirrors\n * the on-disk storage JSON envelope exactly so the family-base\n * serializer's hydration walker can hand an arktype-validated literal\n * straight to `new`.\n *\n * `typeParams` and `typeRef` remain mutually exclusive (one or the\n * other, not both); the constructor preserves whichever caller-side\n * choice the input encodes.\n */\nexport interface StorageColumnInput {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n readonly typeParams?: Record<string, unknown>;\n readonly typeRef?: string;\n readonly default?: ColumnDefault;\n readonly control?: ControlPolicy;\n}\n\n/**\n * SQL Contract IR node for a single column entry in `StorageTable.columns`.\n *\n * Single concrete family-shared class — every SQL target reads the\n * same column shape today, so there is no per-target subclass. The\n * class type accepts any caller that constructs via\n * `new StorageColumn(input)`; literal construction sites must pass\n * through the constructor or the family-base hydration walker.\n *\n * The column's `name` is not on the class — columns are keyed by name\n * in the parent `StorageTable.columns: Record<string, StorageColumn>`\n * map, so a `name` field would be redundant with the key.\n */\nexport class StorageColumn extends SqlNode {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n declare readonly typeParams?: Record<string, unknown>;\n declare readonly typeRef?: string;\n declare readonly default?: ColumnDefault;\n declare readonly control?: ControlPolicy;\n\n constructor(input: StorageColumnInput) {\n super();\n this.nativeType = input.nativeType;\n this.codecId = input.codecId;\n this.nullable = input.nullable;\n if (input.typeParams !== undefined) this.typeParams = input.typeParams;\n if (input.typeRef !== undefined) this.typeRef = input.typeRef;\n if (input.default !== undefined) this.default = input.default;\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface UniqueConstraintInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table-level unique constraint.\n */\nexport class UniqueConstraint extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: UniqueConstraintInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKey, type ForeignKeyInput } from './foreign-key';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\nimport { Index, type IndexInput } from './sql-index';\nimport { SqlNode } from './sql-node';\nimport { StorageColumn, type StorageColumnInput } from './storage-column';\nimport { UniqueConstraint, type UniqueConstraintInput } from './unique-constraint';\n\nexport interface StorageTableInput {\n readonly columns: Record<string, StorageColumn | StorageColumnInput>;\n readonly primaryKey?: PrimaryKey | PrimaryKeyInput;\n readonly uniques: ReadonlyArray<UniqueConstraint | UniqueConstraintInput>;\n readonly indexes: ReadonlyArray<Index | IndexInput>;\n readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;\n readonly control?: ControlPolicy;\n}\n\n/**\n * SQL Contract IR node for a single table entry in a namespace's\n * `tables` map.\n *\n * The constructor normalises nested IR-class fields (columns, primary\n * key, uniques, indexes, foreign keys) into the appropriate class\n * instances so downstream walks see a uniform AST regardless of whether\n * the input was a JSON literal or an already-constructed class.\n *\n * The table's `name` is not on the class — tables are keyed by name in\n * the parent namespace's `tables: Record<string, StorageTable>` map.\n */\nexport class StorageTable extends SqlNode {\n readonly columns: Readonly<Record<string, StorageColumn>>;\n readonly uniques: ReadonlyArray<UniqueConstraint>;\n readonly indexes: ReadonlyArray<Index>;\n readonly foreignKeys: ReadonlyArray<ForeignKey>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly control?: ControlPolicy;\n\n constructor(input: StorageTableInput) {\n super();\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([name, col]) => [\n name,\n col instanceof StorageColumn ? col : new StorageColumn(col),\n ]),\n ),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof UniqueConstraint ? u : new UniqueConstraint(u))),\n );\n this.indexes = Object.freeze(input.indexes.map((i) => (i instanceof Index ? i : new Index(i))));\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof ForeignKey ? fk : new ForeignKey(fk))),\n );\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n}\n","import {\n freezeNode,\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { blindCast, castAs } from '@prisma-next/utils/casts';\nimport type { SqlNamespace, SqlNamespaceTablesInput } from './sql-storage';\nimport { SqlUnboundNamespace } from './sql-unbound-namespace';\nimport { StorageTable, type StorageTableInput } from './storage-table';\n\nconst SQL_NAMESPACE_KIND = 'sql-namespace' as const;\n\nfunction isMaterializedSqlNamespace(ns: Namespace | SqlNamespaceTablesInput): ns is SqlNamespace {\n if (typeof ns !== 'object' || ns === null) {\n return false;\n }\n const proto = Object.getPrototypeOf(ns);\n if (proto === Object.prototype || proto === null) {\n return false;\n }\n return (ns as Namespace).kind === SQL_NAMESPACE_KIND;\n}\n\nclass SqlBoundNamespace extends NamespaceBase {\n declare readonly kind: string;\n\n readonly id: string;\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n }>;\n\n static fromTablesInput(input: SqlNamespaceTablesInput): SqlNamespace {\n const tableCount = Object.keys(input.entries.table).length;\n if (input.id === UNBOUND_NAMESPACE_ID && tableCount === 0) {\n return castAs<SqlNamespace>(SqlUnboundNamespace.instance);\n }\n return castAs<SqlNamespace>(new SqlBoundNamespace(input));\n }\n\n private constructor(input: SqlNamespaceTablesInput) {\n super();\n this.id = input.id;\n this.entries = Object.freeze({\n table: Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.table).map(([k, v]) => [\n k,\n v instanceof StorageTable ? v : new StorageTable(v as StorageTableInput),\n ]),\n ),\n ),\n });\n Object.defineProperty(this, 'kind', {\n value: SQL_NAMESPACE_KIND,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n qualifyTable(tableName: string): string {\n if (this.id === UNBOUND_NAMESPACE_ID) {\n return `\"${tableName}\"`;\n }\n return `\"${this.id}\".\"${tableName}\"`;\n }\n}\n\nexport function buildSqlNamespace(input: SqlNamespaceTablesInput): SqlNamespace {\n return SqlBoundNamespace.fromTablesInput(input);\n}\n\nexport function buildSqlNamespaceMap(\n namespaces: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>,\n): Readonly<Record<string, SqlNamespace>> {\n return Object.fromEntries(\n Object.entries(namespaces).map(([nsKey, ns]) => [\n nsKey,\n isMaterializedSqlNamespace(ns)\n ? blindCast<\n SqlNamespace,\n 'a materialised SQL-family namespace entry in a namespace map is a SqlNamespace'\n >(ns)\n : SqlBoundNamespace.fromTablesInput(\n blindCast<\n SqlNamespaceTablesInput,\n 'non-materialized SQL namespace map entry is a SqlNamespaceTablesInput'\n >(ns),\n ),\n ]),\n );\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Discriminator literal for the Postgres-enum variant on the polymorphic\n * `SqlStorage.types` slot.\n *\n * Enums are a target-level concept: Postgres ships native\n * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via\n * constraints. The literal lives at the SQL family layer because every\n * SQL-family consumer (verifier, planner, lowering, …) needs to\n * discriminate enum-typed slot entries from codec-typed ones. The\n * concrete IR class (`PostgresEnumType`) lives in the target-postgres\n * package and implements this structural contract; cross-domain\n * layering rules forbid the SQL family from importing the concrete\n * target class directly, so the discriminator and structural interface\n * carry the dispatch.\n */\nexport const POSTGRES_ENUM_KIND = 'postgres-enum' as const;\n\n/**\n * Structural contract every Postgres-enum slot entry honours — both\n * the live `PostgresEnumType` IR-class instance and the raw JSON\n * envelope shape that survives `JSON.stringify` round-trips. SQL\n * family-layer dispatch narrows polymorphic `StorageType` slot\n * entries to this shape via `isPostgresEnumStorageEntry`.\n *\n * The `codecBinding` field is accessor-shaped (live class instance) on\n * the IR class and undefined on the raw JSON envelope; consumers that\n * need it must guard for its presence (the JSON path synthesises an\n * equivalent shape from `codecId` + `values`).\n */\nexport interface PostgresEnumStorageEntry extends StorageType {\n readonly kind: typeof POSTGRES_ENUM_KIND;\n readonly name: string;\n readonly nativeType: string;\n readonly values: readonly string[];\n /**\n * Enumerable own property on the persisted JSON envelope; the live\n * IR-class instance carries it too. Family-shared dispatch sites\n * read `codecId` directly rather than going through the IR-class\n * `codecBinding` accessor (which lives on the prototype and isn't\n * present on raw JSON envelopes).\n */\n readonly codecId: string;\n readonly control?: ControlPolicy;\n}\n\n/**\n * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape\n * via its enumerable `kind` discriminator. Type guard returns true for\n * both live `PostgresEnumType` instances and raw JSON envelopes.\n */\nexport function isPostgresEnumStorageEntry(value: unknown): value is PostgresEnumStorageEntry {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === POSTGRES_ENUM_KIND;\n}\n","import type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Sentinel kind for the legacy codec-triple shape persisted under\n * `SqlStorage.types`. Plain JSON-clean object literals carry this\n * discriminator so the polymorphic slot dispatch can route them down\n * the codec path while target-specific IR class instances (e.g. the\n * Postgres enum class) keep their own narrower `kind` literal.\n */\nexport const CODEC_INSTANCE_KIND = 'codec-instance' as const;\n\n/**\n * Structural sub-interface of {@link StorageType} for codec-typed entries\n * in `SqlStorage.types`. These are plain object literals — there is no\n * runtime IR class, the JSON envelope round-trips through the slot\n * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch\n * key that distinguishes codec-typed entries from class-instance entries\n * (e.g. `PostgresEnumType`) sharing the polymorphic slot.\n */\nexport interface StorageTypeInstance extends StorageType {\n readonly kind: typeof CODEC_INSTANCE_KIND;\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Construction-time input for a codec-triple entry. Symmetric with the\n * structural runtime shape minus the `kind` discriminator — callers may\n * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on.\n */\nexport interface StorageTypeInstanceInput {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Stamp the codec-instance `kind` discriminator on a caller-supplied\n * codec triple. Idempotent: input that already carries the discriminator\n * passes through unchanged.\n */\nexport function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance {\n return {\n kind: CODEC_INSTANCE_KIND,\n codecId: input.codecId,\n nativeType: input.nativeType,\n typeParams: input.typeParams,\n };\n}\n\n/**\n * Type-guard for codec-typed entries on the polymorphic\n * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from\n * class-instance kinds (e.g. `PostgresEnumType`).\n */\nexport function isStorageTypeInstance(value: unknown): value is StorageTypeInstance {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === CODEC_INSTANCE_KIND;\n}\n","import type { StorageHashBase } from '@prisma-next/contract/types';\nimport { freezeNode, type Namespace, type Storage } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\nimport type { StorageTable, StorageTableInput } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n} from './storage-type-instance';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations).\n *\n * Postgres native enum registrations live under the postgres-specific\n * `entries.type` slot on `PostgresSchema` (target layer), not here.\n */\nexport type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;\n\nexport interface SqlNamespaceTablesInput {\n readonly id: string;\n readonly entries: {\n readonly table: Record<string, StorageTable | StorageTableInput>;\n };\n}\n\nexport interface SqlStorageInput<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly types?: Record<string, SqlStorageTypeEntry>;\n readonly namespaces: Readonly<Record<string, SqlNamespace>>;\n}\n\n/**\n * SQL Contract IR root node for the `storage` field.\n *\n * Single concrete family-shared class — both Postgres and SQLite\n * consume this class today. Per-target storage subclasses are\n * introduced when each target's namespace shape earns its\n * target-specific concretion (target-specific derived fields,\n * target-specific storage extensions).\n *\n * Honours the framework `Storage` interface: every SQL IR carries a\n * `namespaces` map keyed by namespace id. Callers must supply fully\n * constructed `Namespace` instances — construction discipline lives\n * in the authoring builders and deserializer hydration paths.\n *\n * The constructor normalises optional `types` into class instances.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; hydration of raw JSON\n * class-instance entries (carrying their narrower `kind` literal) is\n * the per-target serializer's responsibility (so the family base does\n * not import target-specific subclasses).\n */\n// SQL concretions store `StorageTable` values under `entries.table`.\n// Mongo namespaces carry `entries.collection` instead. The wider\n// `Record<string, object>` on `StorageTable` is only there so emitted\n// `contract.d.ts` table literals (which lack the runtime `kind`\n// discriminator on `StorageTable`) structurally satisfy the slot without\n// a class-instance check.\nexport type SqlNamespace = Namespace & {\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n }>;\n /**\n * Render a dialect-qualified table reference for runtime SQL emission.\n * Present on materialised target concretions (`PostgresSchema`,\n * `SqliteDatabase`, …) and family placeholders; omitted on emitted\n * contract structural namespace literals (methods are not serialised).\n */\n qualifyTable?(tableName: string): string;\n};\n\nexport class SqlStorage<THash extends string = string> extends SqlNode implements Storage {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, SqlNamespace>>;\n declare readonly types?: Readonly<Record<string, StorageTypeInstance>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n this.namespaces = Object.freeze(input.namespaces);\n if (input.types !== undefined) {\n this.types = Object.freeze(\n Object.fromEntries(\n Object.entries(input.types).map(([name, ti]) => [name, normaliseTypeEntry(name, ti)]),\n ),\n );\n }\n freezeNode(this);\n }\n}\n\nexport function storageTableAt(\n storage: SqlStorage,\n namespaceId: string,\n tableName: string,\n): StorageTable | undefined {\n return storage.namespaces[namespaceId]?.entries.table[tableName];\n}\n\n/**\n * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.\n * Every entry must carry a `kind: 'codec-instance'` discriminator or\n * be an already-constructed `StorageTypeInstance`. Untagged or\n * unrecognised inputs throw a diagnostic naming the entry and its\n * `kind`, so format drift surfaces loudly at the deserializer\n * boundary instead of slipping past the seam and corrupting\n * downstream IR walks.\n *\n * Codec-triple authors that have an untagged shape on hand can call\n * `toStorageTypeInstance(...)` (which stamps the `'codec-instance'`\n * discriminator) before constructing `SqlStorage`. On-disk reads\n * cross `familyInstance.deserializeContract` first; the structural\n * arktype schema rejects untagged entries earlier, so this throw\n * only fires for in-memory authoring bugs.\n */\nfunction normaliseTypeEntry(name: string, entry: SqlStorageTypeEntry): StorageTypeInstance {\n if (isStorageTypeInstance(entry)) {\n return entry;\n }\n const rawKind = (entry as { kind?: unknown }).kind;\n const kindDescription =\n rawKind === undefined\n ? 'missing `kind` discriminator'\n : `unrecognised \\`kind\\` discriminator ${JSON.stringify(rawKind)}`;\n throw new Error(\n `storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify('codec-instance')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n","import type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { ReferentialAction } from './ir/foreign-key';\n\nexport { buildSqlNamespace, buildSqlNamespaceMap } from './ir/build-sql-namespace';\nexport {\n ForeignKey,\n type ForeignKeyInput,\n type ReferentialAction,\n} from './ir/foreign-key';\nexport {\n ForeignKeyReference,\n type ForeignKeyReferenceInput,\n} from './ir/foreign-key-reference';\nexport {\n isPostgresEnumStorageEntry,\n POSTGRES_ENUM_KIND,\n type PostgresEnumStorageEntry,\n} from './ir/postgres-enum-storage-entry';\nexport { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';\nexport { Index, type IndexInput } from './ir/sql-index';\nexport { SqlNode } from './ir/sql-node';\nexport {\n type SqlNamespaceTablesInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n storageTableAt,\n} from './ir/sql-storage';\nexport { SqlUnboundNamespace } from './ir/sql-unbound-namespace';\nexport { StorageColumn, type StorageColumnInput } from './ir/storage-column';\nexport { StorageTable, type StorageTableInput } from './ir/storage-table';\nexport {\n CODEC_INSTANCE_KIND,\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './ir/storage-type-instance';\nexport {\n UniqueConstraint,\n type UniqueConstraintInput,\n} from './ir/unique-constraint';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type SqlModelFieldStorage = {\n readonly column: string;\n readonly codecId?: string;\n readonly nullable?: boolean;\n};\n\nexport type SqlModelStorage = {\n readonly table: string;\n readonly namespaceId: string;\n readonly fields: Record<string, SqlModelFieldStorage>;\n};\n\nexport const DEFAULT_FK_CONSTRAINT = true;\nexport const DEFAULT_FK_INDEX = true;\n\nexport function applyFkDefaults(\n fk: { constraint?: boolean | undefined; index?: boolean | undefined },\n overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },\n): { constraint: boolean; index: boolean } {\n return {\n constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,\n index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,\n };\n}\n\nexport type TypeMaps<\n TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,\n TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,\n TFieldOutputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,\n TFieldInputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n readonly fieldOutputTypes: TFieldOutputTypes;\n readonly fieldInputTypes: TFieldInputTypes;\n};\n\nexport type CodecTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly codecTypes: infer C }\n ? C extends Record<string, { output: unknown }>\n ? C\n : Record<string, never>\n : Record<string, never>;\n\n/**\n * Dispatch hint identifying the first-argument target of an operation.\n *\n * Used by ORM column helpers to decide whether an operation is reachable on a\n * field. Either names a concrete codec identity or a set of capability traits\n * that the field's codec must carry.\n */\nexport type QueryOperationSelfSpec =\n | { readonly codecId: string; readonly traits?: never }\n | { readonly traits: readonly CodecTrait[]; readonly codecId?: never };\n\n/**\n * Structural shape an operation's impl must return: any value carrying a\n * codec-exact `returnType` descriptor. `Expression<T>` (from\n * `@prisma-next/sql-relational-core/expression`, with `T extends ScopeField`)\n * extends this. Trait-targeted returns are deliberately excluded — predicate\n * detection and result decoding both depend on knowing the concrete return\n * codec.\n */\nexport type QueryOperationReturn = {\n readonly returnType: { readonly codecId: string; readonly nullable: boolean };\n};\n\nexport type QueryOperationTypeEntry = {\n readonly self?: QueryOperationSelfSpec;\n readonly impl: (...args: never[]) => QueryOperationReturn;\n};\n\nexport type SqlQueryOperationTypes<\n _CT extends Record<string, { readonly input: unknown; readonly output: unknown }>,\n T extends Record<string, QueryOperationTypeEntry>,\n> = T;\n\nexport type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;\n\nexport type QueryOperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly queryOperationTypes: infer Q }\n ? Q extends Record<string, unknown>\n ? Q\n : Record<string, never>\n : Record<string, never>;\n\nexport type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';\n\nexport type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {\n readonly [K in TypeMapsPhantomKey]?: TTypeMaps;\n};\n\nexport type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T\n ? NonNullable<T[TypeMapsPhantomKey & keyof T]>\n : never;\n\nexport type FieldOutputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldOutputTypes: infer F }\n ? F extends Record<string, Record<string, unknown>>\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type FieldInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldInputTypes: infer F }\n ? F extends Record<string, Record<string, unknown>>\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<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AY,OAA+B;EACzC,MAAM;EACN,KAAK,cAAc,MAAM;EACzB,KAAK,aAAa,OAAO,OAAO,MAAM,UAAU;EAChD,IAAI,MAAM,UAAU,KAAA,GAClB,KAAK,QAAQ,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,KAAK,EAAE,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,mBAAmB,MAAM,EAAE,CAAC,CAAC,CACtF,CACF;EAEF,WAAW,IAAI;CACjB;AACF;AAEA,SAAgB,eACd,SACA,aACA,WAC0B;CAC1B,OAAO,QAAQ,WAAW,cAAc,QAAQ,MAAM;AACxD;;;;;;;;;;;;;;;;;AAkBA,SAAS,mBAAmB,MAAc,OAAiD;CACzF,IAAI,sBAAsB,KAAK,GAC7B,OAAO;CAET,MAAM,UAAW,MAA6B;CAC9C,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,OAAO;CACnE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,IAAI,EAAE,QAAQ,gBAAgB,aAAa,KAAK,UAAU,gBAAgB,EAAE,gGAC9G;AACF;;;ACnEA,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,SAAgB,gBACd,IACA,kBACyC;CACzC,OAAO;EACL,YAAY,GAAG,cAAc,kBAAkB,cAAA;EAC/C,OAAO,GAAG,SAAS,kBAAkB,SAAA;CACvC;AACF"}
@@ -1,11 +1,63 @@
1
- import { D as ReferentialAction, f as StorageTable, n as SqlNamespaceTablesInput, t as SqlNamespace } from "./sql-storage-DPT3m3zO.mjs";
2
- import { Namespace, NamespaceBase } from "@prisma-next/framework-components/ir";
1
+ import { f as StorageTable, n as SqlNamespaceTablesInput, t as SqlNamespace, w as ReferentialAction } from "./sql-storage-CV7Tc9Vh.mjs";
2
+ import { Namespace, NamespaceBase, StorageType } from "@prisma-next/framework-components/ir";
3
+ import { ControlPolicy } from "@prisma-next/contract/types";
3
4
  import { CodecTrait } from "@prisma-next/framework-components/codec";
4
5
 
5
6
  //#region src/ir/build-sql-namespace.d.ts
6
7
  declare function buildSqlNamespace(input: SqlNamespaceTablesInput): SqlNamespace;
7
8
  declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>): Readonly<Record<string, SqlNamespace>>;
8
9
  //#endregion
10
+ //#region src/ir/postgres-enum-storage-entry.d.ts
11
+ /**
12
+ * Discriminator literal for the Postgres-enum variant on the polymorphic
13
+ * `SqlStorage.types` slot.
14
+ *
15
+ * Enums are a target-level concept: Postgres ships native
16
+ * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
17
+ * constraints. The literal lives at the SQL family layer because every
18
+ * SQL-family consumer (verifier, planner, lowering, …) needs to
19
+ * discriminate enum-typed slot entries from codec-typed ones. The
20
+ * concrete IR class (`PostgresEnumType`) lives in the target-postgres
21
+ * package and implements this structural contract; cross-domain
22
+ * layering rules forbid the SQL family from importing the concrete
23
+ * target class directly, so the discriminator and structural interface
24
+ * carry the dispatch.
25
+ */
26
+ declare const POSTGRES_ENUM_KIND: "postgres-enum";
27
+ /**
28
+ * Structural contract every Postgres-enum slot entry honours — both
29
+ * the live `PostgresEnumType` IR-class instance and the raw JSON
30
+ * envelope shape that survives `JSON.stringify` round-trips. SQL
31
+ * family-layer dispatch narrows polymorphic `StorageType` slot
32
+ * entries to this shape via `isPostgresEnumStorageEntry`.
33
+ *
34
+ * The `codecBinding` field is accessor-shaped (live class instance) on
35
+ * the IR class and undefined on the raw JSON envelope; consumers that
36
+ * need it must guard for its presence (the JSON path synthesises an
37
+ * equivalent shape from `codecId` + `values`).
38
+ */
39
+ interface PostgresEnumStorageEntry extends StorageType {
40
+ readonly kind: typeof POSTGRES_ENUM_KIND;
41
+ readonly name: string;
42
+ readonly nativeType: string;
43
+ readonly values: readonly string[];
44
+ /**
45
+ * Enumerable own property on the persisted JSON envelope; the live
46
+ * IR-class instance carries it too. Family-shared dispatch sites
47
+ * read `codecId` directly rather than going through the IR-class
48
+ * `codecBinding` accessor (which lives on the prototype and isn't
49
+ * present on raw JSON envelopes).
50
+ */
51
+ readonly codecId: string;
52
+ readonly control?: ControlPolicy;
53
+ }
54
+ /**
55
+ * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
56
+ * via its enumerable `kind` discriminator. Type guard returns true for
57
+ * both live `PostgresEnumType` instances and raw JSON envelopes.
58
+ */
59
+ declare function isPostgresEnumStorageEntry(value: unknown): value is PostgresEnumStorageEntry;
60
+ //#endregion
9
61
  //#region src/ir/sql-unbound-namespace.d.ts
10
62
  /**
11
63
  * Family-layer placeholder for the SQL unbound-namespace singleton —
@@ -21,9 +73,10 @@ declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namesp
21
73
  * envelope and runtime walk are honest at every layer.
22
74
  *
23
75
  * The `kind` discriminator is installed as a non-enumerable own property
24
- * so the JSON envelope reads `{ "id": "__unbound__" }` — symmetric
25
- * with the family-level non-enumerable `kind` on `SqlNode` and bounded
26
- * to the minimum data the framework `Namespace` interface promises.
76
+ * so the JSON envelope reads `{ "id": "__unbound__", "entries": { … } }`
77
+ * — symmetric with the family-level non-enumerable `kind` on `SqlNode`
78
+ * and bounded to the minimum data the framework `Namespace` interface
79
+ * promises.
27
80
  *
28
81
  * **Freeze-trap warning.** The leaf constructor calls
29
82
  * `freezeNode(this)` after installing `kind`. The leaf-class shape
@@ -40,7 +93,9 @@ declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namesp
40
93
  declare class SqlUnboundNamespace extends NamespaceBase {
41
94
  static readonly instance: SqlUnboundNamespace;
42
95
  readonly id: "__unbound__";
43
- readonly tables: Readonly<Record<string, StorageTable>>;
96
+ readonly entries: Readonly<{
97
+ readonly table: Readonly<Record<string, StorageTable>>;
98
+ }>;
44
99
  readonly kind: string;
45
100
  private constructor();
46
101
  qualifyTable(tableName: string): string;
@@ -142,5 +197,5 @@ type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract
142
197
  type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;
143
198
  type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
144
199
  //#endregion
145
- export { TypeMapsPhantomKey as C, buildSqlNamespaceMap as D, buildSqlNamespace as E, TypeMaps as S, SqlUnboundNamespace as T, QueryOperationTypesOf as _, ExtractCodecTypes as a, SqlModelStorage as b, ExtractQueryOperationTypes as c, FieldOutputTypesOf as d, ForeignKeyOptions as f, QueryOperationTypesBase as g, QueryOperationTypeEntry as h, DEFAULT_FK_INDEX as i, ExtractTypeMapsFromContract as l, QueryOperationSelfSpec as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, QueryOperationReturn as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, FieldInputTypesOf as u, ResolveCodecTypes as v, applyFkDefaults as w, SqlQueryOperationTypes as x, SqlModelFieldStorage as y };
146
- //# sourceMappingURL=types-RVAlD0Qk.d.mts.map
200
+ export { buildSqlNamespaceMap as A, TypeMapsPhantomKey as C, PostgresEnumStorageEntry as D, POSTGRES_ENUM_KIND as E, isPostgresEnumStorageEntry as O, TypeMaps as S, SqlUnboundNamespace as T, QueryOperationTypesOf as _, ExtractCodecTypes as a, SqlModelStorage as b, ExtractQueryOperationTypes as c, FieldOutputTypesOf as d, ForeignKeyOptions as f, QueryOperationTypesBase as g, QueryOperationTypeEntry as h, DEFAULT_FK_INDEX as i, buildSqlNamespace as k, ExtractTypeMapsFromContract as l, QueryOperationSelfSpec as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, QueryOperationReturn as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, FieldInputTypesOf as u, ResolveCodecTypes as v, applyFkDefaults as w, SqlQueryOperationTypes as x, SqlModelFieldStorage as y };
201
+ //# sourceMappingURL=types-ZwTLmfx4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-ZwTLmfx4.d.mts","names":[],"sources":["../src/ir/build-sql-namespace.ts","../src/ir/postgres-enum-storage-entry.ts","../src/ir/sql-unbound-namespace.ts","../src/types.ts"],"mappings":";;;;;;iBAsEgB,iBAAA,CAAkB,KAAA,EAAO,uBAAA,GAA0B,YAAY;AAAA,iBAI/D,oBAAA,CACd,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA,GAAY,uBAAA,KAC/C,QAAA,CAAS,MAAA,SAAe,YAAA;;;;;;;AAN3B;;;;;;;;AAA+E;AAI/E;;cCxDa,kBAAA;;;;;;;;;;;;;UAcI,wBAAA,SAAiC,WAAA;EAAA,SACvC,IAAA,SAAa,kBAAA;EAAA,SACb,IAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EDwC4B;AAAA;;;;AC1DvC;;ED0DuC,SChC5B,OAAA;EAAA,SACA,OAAA,GAAU,aAAA;AAAA;AAbrB;;;;;AAAA,iBAqBgB,0BAAA,CAA2B,KAAA,YAAiB,KAAA,IAAS,wBAAwB;;;;;;;ADiB7F;;;;;;;;AAA+E;AAI/E;;;;;;;;;;;;;;;;;;cEpCa,mBAAA,SAA4B,aAAA;EAAA,gBACvB,QAAA,EAAU,mBAAA;EAAA,SAEjB,EAAA;EAAA,SACA,OAAA,EAAS,QAAA;IAAA,SACP,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA;EAAA,SAEzB,IAAA;EAAA,QAEV,WAAA,CAAA;EAWP,YAAA,CAAa,SAAA;AAAA;;;KCfH,iBAAA;EAAA,SACD,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA;AAAA,KAG3B,oBAAA;EAAA,SACD,MAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGC,eAAA;EAAA,SACD,KAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,MAAM,SA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AAA,IACnB,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,kBAAA;AAAA,KAEA,oBAAA,yBAA6C,SAAA,oBACxC,kBAAA,IAAsB,SAAA;AAAA,KAG3B,2BAAA,MAAiC,kBAAA,eAAiC,CAAA,GAC1E,WAAA,CAAY,CAAA,CAAE,kBAAA,SAA2B,CAAA;AAAA,KAGjC,kBAAA,OAAyB,CAAA,oBACjC,MAAA,kBACA,CAAA;EAAA,SAAqB,gBAAA;AAAA,IACnB,CAAA,SAAU,MAAA,SAAe,MAAA,qBACvB,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,OAAwB,CAAA,oBAChC,MAAA,kBACA,CAAA;EAAA,SAAqB,eAAA;AAAA,IACnB,CAAA,SAAU,MAAA,SAAe,MAAA,qBACvB,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,MAAuB,YAAA,CAAa,2BAAA,CAA4B,CAAA;AAAA,KAChE,0BAAA,MAAgC,qBAAA,CAAsB,2BAAA,CAA4B,CAAA;AAAA,KAClF,uBAAA,MAA6B,kBAAA,CAAmB,2BAAA,CAA4B,CAAA;AAAA,KAC5E,sBAAA,MAA4B,iBAAA,CAAkB,2BAAA,CAA4B,CAAA;AAAA,KAE1E,iBAAA,0BAA2C,SAAA,oBACnD,iBAAA,CAAkB,SAAA,IAClB,YAAA,CAAa,SAAA"}
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SqlNode, C as PostgresEnumStorageEntry, D as ReferentialAction, E as ForeignKeyInput, O as ForeignKeyReference, S as POSTGRES_ENUM_KIND, T as ForeignKey, _ as StorageColumnInput, a as SqlStorageTypeEntry, b as PrimaryKey, c as StorageTypeInstance, d as toStorageTypeInstance, f as StorageTable, g as StorageColumn, h as UniqueConstraintInput, i as SqlStorageInput, k as ForeignKeyReferenceInput, l as StorageTypeInstanceInput, m as UniqueConstraint, n as SqlNamespaceTablesInput, o as storageTableAt, p as StorageTableInput, r as SqlStorage, s as CODEC_INSTANCE_KIND, u as isStorageTypeInstance, v as Index, w as isPostgresEnumStorageEntry, x as PrimaryKeyInput, y as IndexInput } from "./sql-storage-DPT3m3zO.mjs";
2
- import { C as TypeMapsPhantomKey, D as buildSqlNamespaceMap, E as buildSqlNamespace, S as TypeMaps, T as SqlUnboundNamespace, _ as QueryOperationTypesOf, a as ExtractCodecTypes, b as SqlModelStorage, c as ExtractQueryOperationTypes, d as FieldOutputTypesOf, f as ForeignKeyOptions, g as QueryOperationTypesBase, h as QueryOperationTypeEntry, i as DEFAULT_FK_INDEX, l as ExtractTypeMapsFromContract, m as QueryOperationSelfSpec, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as QueryOperationReturn, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as FieldInputTypesOf, v as ResolveCodecTypes, w as applyFkDefaults, x as SqlQueryOperationTypes, y as SqlModelFieldStorage } from "./types-RVAlD0Qk.mjs";
1
+ import { C as ForeignKeyInput, D as SqlNode, E as ForeignKeyReferenceInput, S as ForeignKey, T as ForeignKeyReference, _ as StorageColumnInput, a as SqlStorageTypeEntry, b as PrimaryKey, c as StorageTypeInstance, d as toStorageTypeInstance, f as StorageTable, g as StorageColumn, h as UniqueConstraintInput, i as SqlStorageInput, l as StorageTypeInstanceInput, m as UniqueConstraint, n as SqlNamespaceTablesInput, o as storageTableAt, p as StorageTableInput, r as SqlStorage, s as CODEC_INSTANCE_KIND, u as isStorageTypeInstance, v as Index, w as ReferentialAction, x as PrimaryKeyInput, y as IndexInput } from "./sql-storage-CV7Tc9Vh.mjs";
2
+ import { A as buildSqlNamespaceMap, C as TypeMapsPhantomKey, D as PostgresEnumStorageEntry, E as POSTGRES_ENUM_KIND, O as isPostgresEnumStorageEntry, S as TypeMaps, T as SqlUnboundNamespace, _ as QueryOperationTypesOf, a as ExtractCodecTypes, b as SqlModelStorage, c as ExtractQueryOperationTypes, d as FieldOutputTypesOf, f as ForeignKeyOptions, g as QueryOperationTypesBase, h as QueryOperationTypeEntry, i as DEFAULT_FK_INDEX, k as buildSqlNamespace, l as ExtractTypeMapsFromContract, m as QueryOperationSelfSpec, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as QueryOperationReturn, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as FieldInputTypesOf, v as ResolveCodecTypes, w as applyFkDefaults, x as SqlQueryOperationTypes, y as SqlModelFieldStorage } from "./types-ZwTLmfx4.mjs";
3
3
  export { CODEC_INSTANCE_KIND, type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractFieldInputTypes, type ExtractFieldOutputTypes, type ExtractQueryOperationTypes, type ExtractTypeMapsFromContract, type FieldInputTypesOf, type FieldOutputTypesOf, ForeignKey, type ForeignKeyInput, type ForeignKeyOptions, ForeignKeyReference, type ForeignKeyReferenceInput, Index, type IndexInput, POSTGRES_ENUM_KIND, type PostgresEnumStorageEntry, PrimaryKey, type PrimaryKeyInput, type QueryOperationReturn, type QueryOperationSelfSpec, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type SqlModelFieldStorage, type SqlModelStorage, type SqlNamespaceTablesInput, SqlNode, type SqlQueryOperationTypes, SqlStorage, type SqlStorageInput, type SqlStorageTypeEntry, SqlUnboundNamespace, StorageColumn, type StorageColumnInput, StorageTable, type StorageTableInput, type StorageTypeInstance, type StorageTypeInstanceInput, type TypeMaps, type TypeMapsPhantomKey, UniqueConstraint, type UniqueConstraintInput, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isPostgresEnumStorageEntry, isStorageTypeInstance, storageTableAt, toStorageTypeInstance };
package/dist/types.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as PrimaryKey, a as storageTableAt, b as SqlNode, c as toStorageTypeInstance, d as buildSqlNamespace, f as buildSqlNamespaceMap, g as Index, h as StorageColumn, i as SqlStorage, l as POSTGRES_ENUM_KIND, m as UniqueConstraint, n as DEFAULT_FK_INDEX, o as CODEC_INSTANCE_KIND, p as StorageTable, r as applyFkDefaults, s as isStorageTypeInstance, t as DEFAULT_FK_CONSTRAINT, u as isPostgresEnumStorageEntry, v as ForeignKey, x as SqlUnboundNamespace, y as ForeignKeyReference } from "./types-BYtBgKiP.mjs";
1
+ import { _ as PrimaryKey, a as storageTableAt, b as SqlNode, c as toStorageTypeInstance, d as buildSqlNamespace, f as buildSqlNamespaceMap, g as Index, h as StorageColumn, i as SqlStorage, l as POSTGRES_ENUM_KIND, m as UniqueConstraint, n as DEFAULT_FK_INDEX, o as CODEC_INSTANCE_KIND, p as StorageTable, r as applyFkDefaults, s as isStorageTypeInstance, t as DEFAULT_FK_CONSTRAINT, u as isPostgresEnumStorageEntry, v as ForeignKey, x as SqlUnboundNamespace, y as ForeignKeyReference } from "./types-ByD-iN24.mjs";
2
2
  export { CODEC_INSTANCE_KIND, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, ForeignKey, ForeignKeyReference, Index, POSTGRES_ENUM_KIND, PrimaryKey, SqlNode, SqlStorage, SqlUnboundNamespace, StorageColumn, StorageTable, UniqueConstraint, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isPostgresEnumStorageEntry, isStorageTypeInstance, storageTableAt, toStorageTypeInstance };