@prisma-next/sql-contract 0.11.0-dev.6 → 0.11.0-dev.60

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.
@@ -0,0 +1,10 @@
1
+ import { PreserveEmptyPredicate, StorageSort } from "@prisma-next/contract/hashing";
2
+
3
+ //#region src/canonicalization-hooks.d.ts
4
+ declare const sqlContractCanonicalizationHooks: {
5
+ readonly shouldPreserveEmpty: PreserveEmptyPredicate;
6
+ readonly sortStorage: StorageSort;
7
+ };
8
+ //#endregion
9
+ export { sqlContractCanonicalizationHooks };
10
+ //# sourceMappingURL=canonicalization-hooks.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalization-hooks.d.mts","names":[],"sources":["../src/canonicalization-hooks.ts"],"mappings":";;;cAyBa,gCAAA;EAAA,SACF,mBAAA,EAAqB,sBAAA;EAAA,SACrB,WAAA,EAAa,WAAW;AAAA"}
@@ -0,0 +1,58 @@
1
+ import { createPreserveEmptyPredicate, createStorageSort } from "@prisma-next/contract/hashing-utils";
2
+ const sqlContractCanonicalizationHooks = {
3
+ shouldPreserveEmpty: createPreserveEmptyPredicate([
4
+ [
5
+ "storage",
6
+ "namespaces",
7
+ "*",
8
+ "tables"
9
+ ],
10
+ [
11
+ "storage",
12
+ "namespaces",
13
+ "*",
14
+ "tables",
15
+ "*"
16
+ ],
17
+ [
18
+ "storage",
19
+ "namespaces",
20
+ "*",
21
+ "tables",
22
+ "*",
23
+ [
24
+ "uniques",
25
+ "indexes",
26
+ "foreignKeys"
27
+ ]
28
+ ],
29
+ [
30
+ "storage",
31
+ "namespaces",
32
+ "*",
33
+ "tables",
34
+ "*",
35
+ "foreignKeys",
36
+ ["constraint", "index"]
37
+ ],
38
+ [
39
+ "storage",
40
+ "types",
41
+ "*",
42
+ "typeParams"
43
+ ]
44
+ ]),
45
+ sortStorage: createStorageSort([{
46
+ path: [
47
+ "namespaces",
48
+ "*",
49
+ "tables",
50
+ "*"
51
+ ],
52
+ arrayKeys: ["indexes", "uniques"]
53
+ }])
54
+ };
55
+ //#endregion
56
+ export { sqlContractCanonicalizationHooks };
57
+
58
+ //# sourceMappingURL=canonicalization-hooks.mjs.map
@@ -0,0 +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,4 +1,4 @@
1
- import { B as StorageColumnInput, F as StorageTable, J as ForeignKey, L as UniqueConstraint, U as PrimaryKey, V as Index, b as SqlModelStorage, f as ForeignKeyOptions, y as SqlModelFieldStorage, z as StorageColumn } from "./types-DZpIXwK4.mjs";
1
+ import { G as PrimaryKey, H as StorageColumnInput, L as StorageTable, U as Index, V as StorageColumn, X as ForeignKey, b as SqlModelStorage, f as ForeignKeyOptions, y as SqlModelFieldStorage, z as UniqueConstraint } from "./types-DU3qUbxM.mjs";
2
2
  import { ScalarFieldType } from "@prisma-next/contract/types";
3
3
 
4
4
  //#region src/factories.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"factories.d.mts","names":[],"sources":["../src/factories.ts"],"mappings":";;;;iBAgBgB,GAAA,CAAI,UAAA,UAAoB,OAAA,UAAiB,QAAA,aAAmB,aAAA;AAAA,iBAI5D,EAAA,CAAA,GAAM,OAAA,sBAA6B,UAAA;AAAA,iBAInC,MAAA,CAAA,GAAU,OAAA,sBAA6B,gBAAA;AAAA,iBAIvC,KAAA,CAAA,GAAS,OAAA,sBAA6B,KAAA;AAAA,iBAItC,EAAA,CACd,YAAA,UACA,UAAA,qBACA,eAAA,UACA,aAAA,qBACA,IAAA,GAAO,iBAAA;EAAsB,UAAA;EAAsB,KAAA;EAAiB,WAAA;AAAA,IACnE,UAAA;AAAA,iBAca,KAAA,CACd,OAAA,EAAS,MAAA,SAAe,aAAA,GAAgB,kBAAA,GACxC,IAAA;EACE,EAAA,GAAK,UAAA;EACL,OAAA,YAAmB,gBAAA;EACnB,OAAA,YAAmB,KAAA;EACnB,GAAA,YAAe,UAAA;AAAA,IAEhB,YAAA;AAAA,iBAUa,KAAA,CACd,SAAA,UACA,MAAA,EAAQ,MAAA,SAAe,oBAAA,GACvB,SAAA,GAAW,MAAA;EAEX,OAAA,EAAS,eAAA;EACT,MAAA,EAAQ,MAAA;IAAA,SAA0B,QAAA;IAAA,SAA4B,IAAA,EAAM,eAAA;EAAA;EACpE,SAAA,EAAW,MAAA;AAAA"}
1
+ {"version":3,"file":"factories.d.mts","names":[],"sources":["../src/factories.ts"],"mappings":";;;;iBAgBgB,GAAA,CAAI,UAAA,UAAoB,OAAA,UAAiB,QAAA,aAAmB,aAAa;AAAA,iBAIzE,EAAA,CAAA,GAAM,OAAA,sBAA6B,UAAU;AAAA,iBAI7C,MAAA,CAAA,GAAU,OAAA,sBAA6B,gBAAgB;AAAA,iBAIvD,KAAA,CAAA,GAAS,OAAA,sBAA6B,KAAK;AAAA,iBAI3C,EAAA,CACd,YAAA,UACA,UAAA,qBACA,eAAA,UACA,aAAA,qBACA,IAAA,GAAO,iBAAA;EAAsB,UAAA;EAAsB,KAAA;EAAiB,WAAA;AAAA,IACnE,UAAU;AAAA,iBAcG,KAAA,CACd,OAAA,EAAS,MAAA,SAAe,aAAA,GAAgB,kBAAA,GACxC,IAAA;EACE,EAAA,GAAK,UAAA;EACL,OAAA,YAAmB,gBAAA;EACnB,OAAA,YAAmB,KAAA;EACnB,GAAA,YAAe,UAAA;AAAA,IAEhB,YAAA;AAAA,iBAUa,KAAA,CACd,SAAA,UACA,MAAA,EAAQ,MAAA,SAAe,oBAAA,GACvB,SAAA,GAAW,MAAA;EAEX,OAAA,EAAS,eAAA;EACT,MAAA,EAAQ,MAAA;IAAA,SAA0B,QAAA;IAAA,SAA4B,IAAA,EAAM,eAAA;EAAA;EACpE,SAAA,EAAW,MAAA;AAAA"}
@@ -1,5 +1,6 @@
1
- import { c as StorageTable, f as Index, g as ForeignKey, l as UniqueConstraint, p as PrimaryKey, r as applyFkDefaults, u as StorageColumn } from "./types-L8p7B1dP.mjs";
1
+ import { _ as ForeignKey, f as StorageTable, g as PrimaryKey, h as Index, m as StorageColumn, p as UniqueConstraint, r as applyFkDefaults } from "./types-DPkj4y3_.mjs";
2
2
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
3
+ import { asNamespaceId } from "@prisma-next/contract/types";
3
4
  //#region src/factories.ts
4
5
  function col(nativeType, codecId, nullable = false) {
5
6
  return new StorageColumn({
@@ -22,7 +23,7 @@ function fk(srcTableName, srcColumns, targetTableName, targetColumns, opts) {
22
23
  constraint: opts?.constraint,
23
24
  index: opts?.index
24
25
  });
25
- const namespaceId = opts?.namespaceId ?? UNBOUND_NAMESPACE_ID;
26
+ const namespaceId = asNamespaceId(opts?.namespaceId ?? UNBOUND_NAMESPACE_ID);
26
27
  return new ForeignKey({
27
28
  source: {
28
29
  namespaceId,
@@ -1 +1 @@
1
- {"version":3,"file":"factories.mjs","names":[],"sources":["../src/factories.ts"],"sourcesContent":["import type { ScalarFieldType } from '@prisma-next/contract/types';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport {\n applyFkDefaults,\n ForeignKey,\n type ForeignKeyOptions,\n Index,\n PrimaryKey,\n type SqlModelFieldStorage,\n type SqlModelStorage,\n StorageColumn,\n type StorageColumnInput,\n StorageTable,\n UniqueConstraint,\n} from './types';\n\nexport function col(nativeType: string, codecId: string, nullable = false): StorageColumn {\n return new StorageColumn({ nativeType, codecId, nullable });\n}\n\nexport function pk(...columns: readonly string[]): PrimaryKey {\n return new PrimaryKey({ columns });\n}\n\nexport function unique(...columns: readonly string[]): UniqueConstraint {\n return new UniqueConstraint({ columns });\n}\n\nexport function index(...columns: readonly string[]): Index {\n return new Index({ columns });\n}\n\nexport function fk(\n srcTableName: string,\n srcColumns: readonly string[],\n targetTableName: string,\n targetColumns: readonly string[],\n opts?: ForeignKeyOptions & { constraint?: boolean; index?: boolean; namespaceId?: string },\n): ForeignKey {\n const defaults = applyFkDefaults({ constraint: opts?.constraint, index: opts?.index });\n const namespaceId = opts?.namespaceId ?? UNBOUND_NAMESPACE_ID;\n return new ForeignKey({\n source: { namespaceId, tableName: srcTableName, columns: srcColumns },\n target: { namespaceId, tableName: targetTableName, columns: targetColumns },\n ...(opts?.name !== undefined && { name: opts.name }),\n ...(opts?.onDelete !== undefined && { onDelete: opts.onDelete }),\n ...(opts?.onUpdate !== undefined && { onUpdate: opts.onUpdate }),\n constraint: defaults.constraint,\n index: defaults.index,\n });\n}\n\nexport function table(\n columns: Record<string, StorageColumn | StorageColumnInput>,\n opts?: {\n pk?: PrimaryKey;\n uniques?: readonly UniqueConstraint[];\n indexes?: readonly Index[];\n fks?: readonly ForeignKey[];\n },\n): StorageTable {\n return new StorageTable({\n columns,\n ...(opts?.pk !== undefined && { primaryKey: opts.pk }),\n uniques: opts?.uniques ?? [],\n indexes: opts?.indexes ?? [],\n foreignKeys: opts?.fks ?? [],\n });\n}\n\nexport function model(\n tableName: string,\n fields: Record<string, SqlModelFieldStorage>,\n relations: Record<string, unknown> = {},\n): {\n storage: SqlModelStorage;\n fields: Record<string, { readonly nullable: boolean; readonly type: ScalarFieldType }>;\n relations: Record<string, unknown>;\n} {\n const storage: SqlModelStorage = { table: tableName, fields };\n const domainFields = Object.fromEntries(\n Object.entries(fields).map(([name, field]) => [\n name,\n {\n nullable: field.nullable ?? false,\n type: { kind: 'scalar' as const, codecId: field.codecId ?? 'core/unknown@1' },\n },\n ]),\n ) as Record<string, { nullable: boolean; type: ScalarFieldType }>;\n return {\n storage,\n fields: domainFields,\n relations,\n };\n}\n"],"mappings":";;;AAgBA,SAAgB,IAAI,YAAoB,SAAiB,WAAW,OAAsB;CACxF,OAAO,IAAI,cAAc;EAAE;EAAY;EAAS;EAAU,CAAC;;AAG7D,SAAgB,GAAG,GAAG,SAAwC;CAC5D,OAAO,IAAI,WAAW,EAAE,SAAS,CAAC;;AAGpC,SAAgB,OAAO,GAAG,SAA8C;CACtE,OAAO,IAAI,iBAAiB,EAAE,SAAS,CAAC;;AAG1C,SAAgB,MAAM,GAAG,SAAmC;CAC1D,OAAO,IAAI,MAAM,EAAE,SAAS,CAAC;;AAG/B,SAAgB,GACd,cACA,YACA,iBACA,eACA,MACY;CACZ,MAAM,WAAW,gBAAgB;EAAE,YAAY,MAAM;EAAY,OAAO,MAAM;EAAO,CAAC;CACtF,MAAM,cAAc,MAAM,eAAe;CACzC,OAAO,IAAI,WAAW;EACpB,QAAQ;GAAE;GAAa,WAAW;GAAc,SAAS;GAAY;EACrE,QAAQ;GAAE;GAAa,WAAW;GAAiB,SAAS;GAAe;EAC3E,GAAI,MAAM,SAAS,KAAA,KAAa,EAAE,MAAM,KAAK,MAAM;EACnD,GAAI,MAAM,aAAa,KAAA,KAAa,EAAE,UAAU,KAAK,UAAU;EAC/D,GAAI,MAAM,aAAa,KAAA,KAAa,EAAE,UAAU,KAAK,UAAU;EAC/D,YAAY,SAAS;EACrB,OAAO,SAAS;EACjB,CAAC;;AAGJ,SAAgB,MACd,SACA,MAMc;CACd,OAAO,IAAI,aAAa;EACtB;EACA,GAAI,MAAM,OAAO,KAAA,KAAa,EAAE,YAAY,KAAK,IAAI;EACrD,SAAS,MAAM,WAAW,EAAE;EAC5B,SAAS,MAAM,WAAW,EAAE;EAC5B,aAAa,MAAM,OAAO,EAAE;EAC7B,CAAC;;AAGJ,SAAgB,MACd,WACA,QACA,YAAqC,EAAE,EAKvC;CAWA,OAAO;EACL,SAAA;GAXiC,OAAO;GAAW;GAW5C;EACP,QAXmB,OAAO,YAC1B,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,MAAM,WAAW,CAC5C,MACA;GACE,UAAU,MAAM,YAAY;GAC5B,MAAM;IAAE,MAAM;IAAmB,SAAS,MAAM,WAAW;IAAkB;GAC9E,CACF,CAAC,CAIkB;EACpB;EACD"}
1
+ {"version":3,"file":"factories.mjs","names":[],"sources":["../src/factories.ts"],"sourcesContent":["import { asNamespaceId, type ScalarFieldType } from '@prisma-next/contract/types';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport {\n applyFkDefaults,\n ForeignKey,\n type ForeignKeyOptions,\n Index,\n PrimaryKey,\n type SqlModelFieldStorage,\n type SqlModelStorage,\n StorageColumn,\n type StorageColumnInput,\n StorageTable,\n UniqueConstraint,\n} from './types';\n\nexport function col(nativeType: string, codecId: string, nullable = false): StorageColumn {\n return new StorageColumn({ nativeType, codecId, nullable });\n}\n\nexport function pk(...columns: readonly string[]): PrimaryKey {\n return new PrimaryKey({ columns });\n}\n\nexport function unique(...columns: readonly string[]): UniqueConstraint {\n return new UniqueConstraint({ columns });\n}\n\nexport function index(...columns: readonly string[]): Index {\n return new Index({ columns });\n}\n\nexport function fk(\n srcTableName: string,\n srcColumns: readonly string[],\n targetTableName: string,\n targetColumns: readonly string[],\n opts?: ForeignKeyOptions & { constraint?: boolean; index?: boolean; namespaceId?: string },\n): ForeignKey {\n const defaults = applyFkDefaults({ constraint: opts?.constraint, index: opts?.index });\n const namespaceId = asNamespaceId(opts?.namespaceId ?? UNBOUND_NAMESPACE_ID);\n return new ForeignKey({\n source: { namespaceId, tableName: srcTableName, columns: srcColumns },\n target: { namespaceId, tableName: targetTableName, columns: targetColumns },\n ...(opts?.name !== undefined && { name: opts.name }),\n ...(opts?.onDelete !== undefined && { onDelete: opts.onDelete }),\n ...(opts?.onUpdate !== undefined && { onUpdate: opts.onUpdate }),\n constraint: defaults.constraint,\n index: defaults.index,\n });\n}\n\nexport function table(\n columns: Record<string, StorageColumn | StorageColumnInput>,\n opts?: {\n pk?: PrimaryKey;\n uniques?: readonly UniqueConstraint[];\n indexes?: readonly Index[];\n fks?: readonly ForeignKey[];\n },\n): StorageTable {\n return new StorageTable({\n columns,\n ...(opts?.pk !== undefined && { primaryKey: opts.pk }),\n uniques: opts?.uniques ?? [],\n indexes: opts?.indexes ?? [],\n foreignKeys: opts?.fks ?? [],\n });\n}\n\nexport function model(\n tableName: string,\n fields: Record<string, SqlModelFieldStorage>,\n relations: Record<string, unknown> = {},\n): {\n storage: SqlModelStorage;\n fields: Record<string, { readonly nullable: boolean; readonly type: ScalarFieldType }>;\n relations: Record<string, unknown>;\n} {\n const storage: SqlModelStorage = { table: tableName, fields };\n const domainFields = Object.fromEntries(\n Object.entries(fields).map(([name, field]) => [\n name,\n {\n nullable: field.nullable ?? false,\n type: { kind: 'scalar' as const, codecId: field.codecId ?? 'core/unknown@1' },\n },\n ]),\n ) as Record<string, { nullable: boolean; type: ScalarFieldType }>;\n return {\n storage,\n fields: domainFields,\n relations,\n };\n}\n"],"mappings":";;;;AAgBA,SAAgB,IAAI,YAAoB,SAAiB,WAAW,OAAsB;CACxF,OAAO,IAAI,cAAc;EAAE;EAAY;EAAS;CAAS,CAAC;AAC5D;AAEA,SAAgB,GAAG,GAAG,SAAwC;CAC5D,OAAO,IAAI,WAAW,EAAE,QAAQ,CAAC;AACnC;AAEA,SAAgB,OAAO,GAAG,SAA8C;CACtE,OAAO,IAAI,iBAAiB,EAAE,QAAQ,CAAC;AACzC;AAEA,SAAgB,MAAM,GAAG,SAAmC;CAC1D,OAAO,IAAI,MAAM,EAAE,QAAQ,CAAC;AAC9B;AAEA,SAAgB,GACd,cACA,YACA,iBACA,eACA,MACY;CACZ,MAAM,WAAW,gBAAgB;EAAE,YAAY,MAAM;EAAY,OAAO,MAAM;CAAM,CAAC;CACrF,MAAM,cAAc,cAAc,MAAM,eAAe,oBAAoB;CAC3E,OAAO,IAAI,WAAW;EACpB,QAAQ;GAAE;GAAa,WAAW;GAAc,SAAS;EAAW;EACpE,QAAQ;GAAE;GAAa,WAAW;GAAiB,SAAS;EAAc;EAC1E,GAAI,MAAM,SAAS,KAAA,KAAa,EAAE,MAAM,KAAK,KAAK;EAClD,GAAI,MAAM,aAAa,KAAA,KAAa,EAAE,UAAU,KAAK,SAAS;EAC9D,GAAI,MAAM,aAAa,KAAA,KAAa,EAAE,UAAU,KAAK,SAAS;EAC9D,YAAY,SAAS;EACrB,OAAO,SAAS;CAClB,CAAC;AACH;AAEA,SAAgB,MACd,SACA,MAMc;CACd,OAAO,IAAI,aAAa;EACtB;EACA,GAAI,MAAM,OAAO,KAAA,KAAa,EAAE,YAAY,KAAK,GAAG;EACpD,SAAS,MAAM,WAAW,CAAC;EAC3B,SAAS,MAAM,WAAW,CAAC;EAC3B,aAAa,MAAM,OAAO,CAAC;CAC7B,CAAC;AACH;AAEA,SAAgB,MACd,WACA,QACA,YAAqC,CAAC,GAKtC;CAWA,OAAO;EACL,SAAA;GAXiC,OAAO;GAAW;EAW7C;EACN,QAXmB,OAAO,YAC1B,OAAO,QAAQ,MAAM,EAAE,KAAK,CAAC,MAAM,WAAW,CAC5C,MACA;GACE,UAAU,MAAM,YAAY;GAC5B,MAAM;IAAE,MAAM;IAAmB,SAAS,MAAM,WAAW;GAAiB;EAC9E,CACF,CAAC,CAIkB;EACnB;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { D as SqlStorage } from "./types-DZpIXwK4.mjs";
1
+ import { k as SqlStorage } from "./types-DU3qUbxM.mjs";
2
2
  import { a as IndexTypeRegistry } from "./index-types-B1cf5N0F.mjs";
3
3
  import { Contract } from "@prisma-next/contract/types";
4
4
 
@@ -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,WAAW,EACzE,KAAK,MAAM,CAAC,WAAW,aAAa,OAAO,QAAQ,GAAG,OAAO,EAAE;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,KAAK,CAAC,+BAC9F,UACD;GAEH,IAAI,MAAM,SAAS,KAAA,GAAW;GAC9B,MAAM,QAAQ,kBAAkB,IAAI,MAAM,KAAK;GAC/C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,KAAK,CAAC,kCAAkC,MAAM,KAAK,IAC3I,UACD;GAEH,MAAM,eAAe,MAAM,WAAW,EAAE;GACxC,MAAM,SAAS,MAAM,QAAQ,aAAa;GAC1C,IAAI,kBAAkB,KAAK,QACzB,MAAM,IAAI,wBACR,cAAc,YAAY,WAAW,UAAU,sBAAsB,MAAM,QAAQ,KAAK,KAAK,CAAC,kCAAkC,MAAM,KAAK,KAAK,OAAO,WACvJ,UACD"}
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,KAA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AAA,iBAsBU,uBAAA,CAAA,GAA2B,iBAAA"}
1
+ {"version":3,"file":"index-types-B1cf5N0F.d.mts","names":[],"sources":["../src/index-types.ts"],"mappings":";;;UAEiB,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,EAAS,IAAI,CAAC,QAAA;AAAA;AAAA,KAGb,YAAA;EAAA,SAAoD,OAAO;AAAA;AAAA,UAEtD,qBAAA,cAAmC,YAAA,GAAe,MAAA;EAAA,SACxD,UAAA,EAAY,IAAA;EAAA,SACZ,OAAA,EAAS,aAAA,CAAc,cAAA;AAAA;AAAA,UAGjB,gBAAA,cAA8B,YAAA,GAAe,MAAA,wBACpD,qBAAA,CAAsB,IAAA;EAC9B,GAAA,6BACE,WAAA,EAAa,IAAA,EACb,KAAA;IAAA,SAAkB,OAAA,EAAS,IAAA,CAAK,KAAA;EAAA,IAC/B,gBAAA,CAAiB,IAAA,GAAO,MAAA,CAAO,IAAA;IAAA,SAAiB,OAAA,EAAS,KAAA;EAAA;AAAA;AAAA,iBA0B9C,gBAAA,CAAA,GAAoB,gBAAgB,CAAC,MAAA;AAAA,UAIpC,iBAAA;EACf,QAAA,CAAS,KAAA,EAAO,cAAA;EAChB,GAAA,CAAI,WAAA,WAAsB,cAAc;EACxC,GAAA,CAAI,WAAA;AAAA;AAAA,iBAsBU,uBAAA,CAAA,GAA2B,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-types.mjs","names":[],"sources":["../src/index-types.ts"],"sourcesContent":["import type { Type } from 'arktype';\n\nexport interface IndexTypeEntry<TOptions = unknown> {\n readonly type: string;\n readonly options: Type<TOptions>;\n}\n\nexport type IndexTypeMap = { readonly [K in string]: { readonly options: unknown } };\n\nexport interface IndexTypeRegistration<TMap extends IndexTypeMap = Record<never, never>> {\n readonly IndexTypes: TMap;\n readonly entries: ReadonlyArray<IndexTypeEntry>;\n}\n\nexport interface IndexTypeBuilder<TMap extends IndexTypeMap = Record<never, never>>\n extends IndexTypeRegistration<TMap> {\n add<TLit extends string, TOpts>(\n typeLiteral: TLit,\n entry: { readonly options: Type<TOpts> },\n ): IndexTypeBuilder<TMap & Record<TLit, { readonly options: TOpts }>>;\n}\n\nclass IndexTypeBuilderImpl<TMap extends IndexTypeMap> implements IndexTypeBuilder<TMap> {\n readonly entries: ReadonlyArray<IndexTypeEntry>;\n readonly IndexTypes: TMap;\n\n constructor(entries: ReadonlyArray<IndexTypeEntry>) {\n this.entries = entries;\n this.IndexTypes = {} as TMap;\n }\n\n add<TLit extends string, TOpts>(\n typeLiteral: TLit,\n entry: { readonly options: Type<TOpts> },\n ): IndexTypeBuilder<TMap & Record<TLit, { readonly options: TOpts }>> {\n if (this.entries.some((e) => e.type === typeLiteral)) {\n throw new Error(`Index type \"${typeLiteral}\" is already declared in this builder`);\n }\n return new IndexTypeBuilderImpl<TMap & Record<TLit, { readonly options: TOpts }>>([\n ...this.entries,\n { type: typeLiteral, options: entry.options as Type<unknown> },\n ]);\n }\n}\n\nexport function defineIndexTypes(): IndexTypeBuilder<Record<never, never>> {\n return new IndexTypeBuilderImpl([]);\n}\n\nexport interface IndexTypeRegistry {\n register(entry: IndexTypeEntry): void;\n get(typeLiteral: string): IndexTypeEntry | undefined;\n has(typeLiteral: string): boolean;\n}\n\nclass IndexTypeRegistryImpl implements IndexTypeRegistry {\n private readonly entries = new Map<string, IndexTypeEntry>();\n\n register(entry: IndexTypeEntry): void {\n if (this.entries.has(entry.type)) {\n throw new Error(`Index type \"${entry.type}\" is already registered`);\n }\n this.entries.set(entry.type, entry);\n }\n\n get(typeLiteral: string): IndexTypeEntry | undefined {\n return this.entries.get(typeLiteral);\n }\n\n has(typeLiteral: string): boolean {\n return this.entries.has(typeLiteral);\n }\n}\n\nexport function createIndexTypeRegistry(): IndexTypeRegistry {\n return new IndexTypeRegistryImpl();\n}\n"],"mappings":";AAsBA,IAAM,uBAAN,MAAM,qBAAkF;CACtF;CACA;CAEA,YAAY,SAAwC;EAClD,KAAK,UAAU;EACf,KAAK,aAAa,EAAE;;CAGtB,IACE,aACA,OACoE;EACpE,IAAI,KAAK,QAAQ,MAAM,MAAM,EAAE,SAAS,YAAY,EAClD,MAAM,IAAI,MAAM,eAAe,YAAY,uCAAuC;EAEpF,OAAO,IAAI,qBAAuE,CAChF,GAAG,KAAK,SACR;GAAE,MAAM;GAAa,SAAS,MAAM;GAA0B,CAC/D,CAAC;;;AAIN,SAAgB,mBAA2D;CACzE,OAAO,IAAI,qBAAqB,EAAE,CAAC;;AASrC,IAAM,wBAAN,MAAyD;CACvD,0BAA2B,IAAI,KAA6B;CAE5D,SAAS,OAA6B;EACpC,IAAI,KAAK,QAAQ,IAAI,MAAM,KAAK,EAC9B,MAAM,IAAI,MAAM,eAAe,MAAM,KAAK,yBAAyB;EAErE,KAAK,QAAQ,IAAI,MAAM,MAAM,MAAM;;CAGrC,IAAI,aAAiD;EACnD,OAAO,KAAK,QAAQ,IAAI,YAAY;;CAGtC,IAAI,aAA8B;EAChC,OAAO,KAAK,QAAQ,IAAI,YAAY;;;AAIxC,SAAgB,0BAA6C;CAC3D,OAAO,IAAI,uBAAuB"}
1
+ {"version":3,"file":"index-types.mjs","names":[],"sources":["../src/index-types.ts"],"sourcesContent":["import type { Type } from 'arktype';\n\nexport interface IndexTypeEntry<TOptions = unknown> {\n readonly type: string;\n readonly options: Type<TOptions>;\n}\n\nexport type IndexTypeMap = { readonly [K in string]: { readonly options: unknown } };\n\nexport interface IndexTypeRegistration<TMap extends IndexTypeMap = Record<never, never>> {\n readonly IndexTypes: TMap;\n readonly entries: ReadonlyArray<IndexTypeEntry>;\n}\n\nexport interface IndexTypeBuilder<TMap extends IndexTypeMap = Record<never, never>>\n extends IndexTypeRegistration<TMap> {\n add<TLit extends string, TOpts>(\n typeLiteral: TLit,\n entry: { readonly options: Type<TOpts> },\n ): IndexTypeBuilder<TMap & Record<TLit, { readonly options: TOpts }>>;\n}\n\nclass IndexTypeBuilderImpl<TMap extends IndexTypeMap> implements IndexTypeBuilder<TMap> {\n readonly entries: ReadonlyArray<IndexTypeEntry>;\n readonly IndexTypes: TMap;\n\n constructor(entries: ReadonlyArray<IndexTypeEntry>) {\n this.entries = entries;\n this.IndexTypes = {} as TMap;\n }\n\n add<TLit extends string, TOpts>(\n typeLiteral: TLit,\n entry: { readonly options: Type<TOpts> },\n ): IndexTypeBuilder<TMap & Record<TLit, { readonly options: TOpts }>> {\n if (this.entries.some((e) => e.type === typeLiteral)) {\n throw new Error(`Index type \"${typeLiteral}\" is already declared in this builder`);\n }\n return new IndexTypeBuilderImpl<TMap & Record<TLit, { readonly options: TOpts }>>([\n ...this.entries,\n { type: typeLiteral, options: entry.options as Type<unknown> },\n ]);\n }\n}\n\nexport function defineIndexTypes(): IndexTypeBuilder<Record<never, never>> {\n return new IndexTypeBuilderImpl([]);\n}\n\nexport interface IndexTypeRegistry {\n register(entry: IndexTypeEntry): void;\n get(typeLiteral: string): IndexTypeEntry | undefined;\n has(typeLiteral: string): boolean;\n}\n\nclass IndexTypeRegistryImpl implements IndexTypeRegistry {\n private readonly entries = new Map<string, IndexTypeEntry>();\n\n register(entry: IndexTypeEntry): void {\n if (this.entries.has(entry.type)) {\n throw new Error(`Index type \"${entry.type}\" is already registered`);\n }\n this.entries.set(entry.type, entry);\n }\n\n get(typeLiteral: string): IndexTypeEntry | undefined {\n return this.entries.get(typeLiteral);\n }\n\n has(typeLiteral: string): boolean {\n return this.entries.has(typeLiteral);\n }\n}\n\nexport function createIndexTypeRegistry(): IndexTypeRegistry {\n return new IndexTypeRegistryImpl();\n}\n"],"mappings":";AAsBA,IAAM,uBAAN,MAAM,qBAAkF;CACtF;CACA;CAEA,YAAY,SAAwC;EAClD,KAAK,UAAU;EACf,KAAK,aAAa,CAAC;CACrB;CAEA,IACE,aACA,OACoE;EACpE,IAAI,KAAK,QAAQ,MAAM,MAAM,EAAE,SAAS,WAAW,GACjD,MAAM,IAAI,MAAM,eAAe,YAAY,sCAAsC;EAEnF,OAAO,IAAI,qBAAuE,CAChF,GAAG,KAAK,SACR;GAAE,MAAM;GAAa,SAAS,MAAM;EAAyB,CAC/D,CAAC;CACH;AACF;AAEA,SAAgB,mBAA2D;CACzE,OAAO,IAAI,qBAAqB,CAAC,CAAC;AACpC;AAQA,IAAM,wBAAN,MAAyD;CACvD,0BAA2B,IAAI,IAA4B;CAE3D,SAAS,OAA6B;EACpC,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,GAC7B,MAAM,IAAI,MAAM,eAAe,MAAM,KAAK,wBAAwB;EAEpE,KAAK,QAAQ,IAAI,MAAM,MAAM,KAAK;CACpC;CAEA,IAAI,aAAiD;EACnD,OAAO,KAAK,QAAQ,IAAI,WAAW;CACrC;CAEA,IAAI,aAA8B;EAChC,OAAO,KAAK,QAAQ,IAAI,WAAW;CACrC;AACF;AAEA,SAAgB,0BAA6C;CAC3D,OAAO,IAAI,sBAAsB;AACnC"}
@@ -1,4 +1,53 @@
1
1
  import { IRNodeBase, NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
2
+ import { blindCast, castAs } from "@prisma-next/utils/casts";
3
+ import { asNamespaceId } from "@prisma-next/contract/types";
4
+ //#region src/ir/sql-unbound-namespace.ts
5
+ /**
6
+ * Family-layer placeholder for the SQL unbound-namespace singleton —
7
+ * the late-bound slot whose binding the target resolves at connection
8
+ * time rather than at authoring time.
9
+ *
10
+ * SQL contracts honour the framework `Storage.namespaces` invariant from
11
+ * the moment they appear in the IR. Today `SqlStorage` is family-shared
12
+ * (Postgres + SQLite consume the same class); a per-target namespace
13
+ * concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)
14
+ * earns its existence when each target's namespace shape lands. Until
15
+ * then the family ships a single placeholder singleton so the JSON
16
+ * envelope and runtime walk are honest at every layer.
17
+ *
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.
22
+ *
23
+ * **Freeze-trap warning.** The leaf constructor calls
24
+ * `freezeNode(this)` after installing `kind`. The leaf-class shape
25
+ * works today only because `NamespaceBase` does NOT freeze in its
26
+ * constructor — the `Object.defineProperty(this, 'kind', …)` call after
27
+ * `super()` succeeds because the instance is still mutable at that
28
+ * point. Subclasses that add instance fields will still hit the freeze
29
+ * trap once leaf-class `freezeNode(this)` runs; and if a future
30
+ * framework change lifts the freeze to `NamespaceBase`, even the
31
+ * `defineProperty` here would silently fail. To add subclass instance
32
+ * fields safely, lift `freezeNode` to a leaf-class `seal()` hook each
33
+ * leaf calls explicitly at the end of its own constructor.
34
+ */
35
+ var SqlUnboundNamespace = class SqlUnboundNamespace extends NamespaceBase {
36
+ static instance = new SqlUnboundNamespace();
37
+ id = UNBOUND_NAMESPACE_ID;
38
+ tables = Object.freeze({});
39
+ constructor() {
40
+ super();
41
+ Object.defineProperty(this, "kind", {
42
+ value: "sql-namespace",
43
+ writable: false,
44
+ enumerable: false,
45
+ configurable: true
46
+ });
47
+ freezeNode(this);
48
+ }
49
+ };
50
+ //#endregion
2
51
  //#region src/ir/sql-node.ts
3
52
  /**
4
53
  * SQL family IR node base. Carries the family-level `kind` discriminator
@@ -59,7 +108,7 @@ var ForeignKeyReference = class extends SqlNode {
59
108
  columns;
60
109
  constructor(input) {
61
110
  super();
62
- this.namespaceId = input.namespaceId;
111
+ this.namespaceId = asNamespaceId(input.namespaceId);
63
112
  this.tableName = input.tableName;
64
113
  this.columns = input.columns;
65
114
  freezeNode(this);
@@ -97,33 +146,6 @@ var ForeignKey = class extends SqlNode {
97
146
  }
98
147
  };
99
148
  //#endregion
100
- //#region src/ir/postgres-enum-storage-entry.ts
101
- /**
102
- * Discriminator literal for the Postgres-enum variant on the polymorphic
103
- * `SqlStorage.types` slot.
104
- *
105
- * Enums are a target-level concept: Postgres ships native
106
- * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
107
- * constraints. The literal lives at the SQL family layer because every
108
- * SQL-family consumer (verifier, planner, lowering, …) needs to
109
- * discriminate enum-typed slot entries from codec-typed ones. The
110
- * concrete IR class (`PostgresEnumType`) lives in the target-postgres
111
- * package and implements this structural contract; cross-domain
112
- * layering rules forbid the SQL family from importing the concrete
113
- * target class directly, so the discriminator and structural interface
114
- * carry the dispatch.
115
- */
116
- const POSTGRES_ENUM_KIND = "postgres-enum";
117
- /**
118
- * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
119
- * via its enumerable `kind` discriminator. Type guard returns true for
120
- * both live `PostgresEnumType` instances and raw JSON envelopes.
121
- */
122
- function isPostgresEnumStorageEntry(value) {
123
- if (typeof value !== "object" || value === null) return false;
124
- return value.kind === POSTGRES_ENUM_KIND;
125
- }
126
- //#endregion
127
149
  //#region src/ir/primary-key.ts
128
150
  /**
129
151
  * SQL Contract IR node for a table's primary-key constraint.
@@ -159,53 +181,6 @@ var Index = class extends SqlNode {
159
181
  }
160
182
  };
161
183
  //#endregion
162
- //#region src/ir/sql-unbound-namespace.ts
163
- /**
164
- * Family-layer placeholder for the SQL unbound-namespace singleton —
165
- * the late-bound slot whose binding the target resolves at connection
166
- * time rather than at authoring time.
167
- *
168
- * SQL contracts honour the framework `Storage.namespaces` invariant from
169
- * the moment they appear in the IR. Today `SqlStorage` is family-shared
170
- * (Postgres + SQLite consume the same class); a per-target namespace
171
- * concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)
172
- * earns its existence when each target's namespace shape lands. Until
173
- * then the family ships a single placeholder singleton so the JSON
174
- * envelope and runtime walk are honest at every layer.
175
- *
176
- * The `kind` discriminator is installed as a non-enumerable own property
177
- * so the JSON envelope reads `{ "id": "__unbound__" }` — symmetric
178
- * with the family-level non-enumerable `kind` on `SqlNode` and bounded
179
- * to the minimum data the framework `Namespace` interface promises.
180
- *
181
- * **Freeze-trap warning.** The leaf constructor calls
182
- * `freezeNode(this)` after installing `kind`. The leaf-class shape
183
- * works today only because `NamespaceBase` does NOT freeze in its
184
- * constructor — the `Object.defineProperty(this, 'kind', …)` call after
185
- * `super()` succeeds because the instance is still mutable at that
186
- * point. Subclasses that add instance fields will still hit the freeze
187
- * trap once leaf-class `freezeNode(this)` runs; and if a future
188
- * framework change lifts the freeze to `NamespaceBase`, even the
189
- * `defineProperty` here would silently fail. To add subclass instance
190
- * fields safely, lift `freezeNode` to a leaf-class `seal()` hook each
191
- * leaf calls explicitly at the end of its own constructor.
192
- */
193
- var SqlUnboundNamespace = class SqlUnboundNamespace extends NamespaceBase {
194
- static instance = new SqlUnboundNamespace();
195
- id = UNBOUND_NAMESPACE_ID;
196
- tables = Object.freeze({});
197
- constructor() {
198
- super();
199
- Object.defineProperty(this, "kind", {
200
- value: "sql-namespace",
201
- writable: false,
202
- enumerable: false,
203
- configurable: true
204
- });
205
- freezeNode(this);
206
- }
207
- };
208
- //#endregion
209
184
  //#region src/ir/storage-column.ts
210
185
  /**
211
186
  * SQL Contract IR node for a single column entry in `StorageTable.columns`.
@@ -279,6 +254,76 @@ var StorageTable = class extends SqlNode {
279
254
  }
280
255
  };
281
256
  //#endregion
257
+ //#region src/ir/build-sql-namespace.ts
258
+ const SQL_NAMESPACE_KIND = "sql-namespace";
259
+ function isMaterializedSqlNamespace(ns) {
260
+ if (typeof ns !== "object" || ns === null) return false;
261
+ const proto = Object.getPrototypeOf(ns);
262
+ if (proto === Object.prototype || proto === null) return false;
263
+ return ns.kind === SQL_NAMESPACE_KIND;
264
+ }
265
+ var SqlBoundNamespace = class SqlBoundNamespace extends NamespaceBase {
266
+ id;
267
+ tables;
268
+ static fromTablesInput(input) {
269
+ const tableCount = Object.keys(input.tables ?? {}).length;
270
+ const enumCount = Object.keys(input.enum ?? {}).length;
271
+ if (input.id === UNBOUND_NAMESPACE_ID && tableCount === 0 && enumCount === 0) return castAs(SqlUnboundNamespace.instance);
272
+ return castAs(new SqlBoundNamespace(input));
273
+ }
274
+ constructor(input) {
275
+ super();
276
+ this.id = input.id;
277
+ this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables ?? {}).map(([name, t]) => [name, t instanceof StorageTable ? t : new StorageTable(t)])));
278
+ if (input.enum !== void 0 && Object.keys(input.enum).length > 0) Object.defineProperty(this, "enum", {
279
+ value: Object.freeze({ ...input.enum }),
280
+ writable: false,
281
+ enumerable: true,
282
+ configurable: false
283
+ });
284
+ Object.defineProperty(this, "kind", {
285
+ value: SQL_NAMESPACE_KIND,
286
+ writable: false,
287
+ enumerable: false,
288
+ configurable: true
289
+ });
290
+ freezeNode(this);
291
+ }
292
+ };
293
+ function buildSqlNamespace(input) {
294
+ return SqlBoundNamespace.fromTablesInput(input);
295
+ }
296
+ function buildSqlNamespaceMap(namespaces) {
297
+ return Object.fromEntries(Object.entries(namespaces).map(([nsKey, ns]) => [nsKey, isMaterializedSqlNamespace(ns) ? blindCast(ns) : SqlBoundNamespace.fromTablesInput(ns)]));
298
+ }
299
+ //#endregion
300
+ //#region src/ir/postgres-enum-storage-entry.ts
301
+ /**
302
+ * Discriminator literal for the Postgres-enum variant on the polymorphic
303
+ * `SqlStorage.types` slot.
304
+ *
305
+ * Enums are a target-level concept: Postgres ships native
306
+ * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
307
+ * constraints. The literal lives at the SQL family layer because every
308
+ * SQL-family consumer (verifier, planner, lowering, …) needs to
309
+ * discriminate enum-typed slot entries from codec-typed ones. The
310
+ * concrete IR class (`PostgresEnumType`) lives in the target-postgres
311
+ * package and implements this structural contract; cross-domain
312
+ * layering rules forbid the SQL family from importing the concrete
313
+ * target class directly, so the discriminator and structural interface
314
+ * carry the dispatch.
315
+ */
316
+ const POSTGRES_ENUM_KIND = "postgres-enum";
317
+ /**
318
+ * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
319
+ * via its enumerable `kind` discriminator. Type guard returns true for
320
+ * both live `PostgresEnumType` instances and raw JSON envelopes.
321
+ */
322
+ function isPostgresEnumStorageEntry(value) {
323
+ if (typeof value !== "object" || value === null) return false;
324
+ return value.kind === POSTGRES_ENUM_KIND;
325
+ }
326
+ //#endregion
282
327
  //#region src/ir/storage-type-instance.ts
283
328
  /**
284
329
  * Sentinel kind for the legacy codec-triple shape persisted under
@@ -312,47 +357,13 @@ function isStorageTypeInstance(value) {
312
357
  }
313
358
  //#endregion
314
359
  //#region src/ir/sql-storage.ts
315
- const DEFAULT_NAMESPACES = Object.freeze({ [UNBOUND_NAMESPACE_ID]: SqlUnboundNamespace.instance });
316
- var SqlNamespacePayload = class extends NamespaceBase {
317
- id;
318
- tables;
319
- constructor(input) {
320
- super();
321
- this.id = input.id;
322
- this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables ?? {}).map(([name, t]) => [name, t instanceof StorageTable ? t : new StorageTable(t)])));
323
- if (input.types !== void 0 && Object.keys(input.types).length > 0) Object.defineProperty(this, "types", {
324
- value: Object.freeze({ ...input.types }),
325
- writable: false,
326
- enumerable: true,
327
- configurable: false
328
- });
329
- Object.defineProperty(this, "kind", {
330
- value: "sql-namespace",
331
- writable: false,
332
- enumerable: false,
333
- configurable: true
334
- });
335
- freezeNode(this);
336
- }
337
- };
338
- function normaliseNamespaceEntry(nsKey, ns) {
339
- if (ns instanceof NamespaceBase) return ns;
340
- const input = ns;
341
- const tableCount = Object.keys(input.tables ?? {}).length;
342
- const typeCount = Object.keys(input.types ?? {}).length;
343
- if (nsKey === UNBOUND_NAMESPACE_ID && tableCount === 0 && typeCount === 0) return SqlUnboundNamespace.instance;
344
- return new SqlNamespacePayload(input);
345
- }
346
360
  var SqlStorage = class extends SqlNode {
347
361
  storageHash;
348
362
  namespaces;
349
363
  constructor(input) {
350
364
  super();
351
365
  this.storageHash = input.storageHash;
352
- const inputNamespaces = input.namespaces ?? DEFAULT_NAMESPACES;
353
- const normalised = Object.fromEntries(Object.entries(inputNamespaces).map(([nsKey, ns]) => [nsKey, normaliseNamespaceEntry(nsKey, ns)]));
354
- if (!normalised[UNBOUND_NAMESPACE_ID]) normalised[UNBOUND_NAMESPACE_ID] = SqlUnboundNamespace.instance;
355
- this.namespaces = Object.freeze(normalised);
366
+ this.namespaces = Object.freeze(input.namespaces);
356
367
  if (input.types !== void 0) this.types = Object.freeze(Object.fromEntries(Object.entries(input.types).map(([name, ti]) => [name, normaliseTypeEntry(name, ti)])));
357
368
  freezeNode(this);
358
369
  }
@@ -395,6 +406,6 @@ function applyFkDefaults(fk, overrideDefaults) {
395
406
  };
396
407
  }
397
408
  //#endregion
398
- export { ForeignKeyReference as _, CODEC_INSTANCE_KIND as a, StorageTable as c, SqlUnboundNamespace as d, Index as f, ForeignKey as g, isPostgresEnumStorageEntry as h, SqlStorage as i, UniqueConstraint as l, POSTGRES_ENUM_KIND as m, DEFAULT_FK_INDEX as n, isStorageTypeInstance as o, PrimaryKey as p, applyFkDefaults as r, toStorageTypeInstance as s, DEFAULT_FK_CONSTRAINT as t, StorageColumn as u, SqlNode as v };
409
+ export { ForeignKey as _, CODEC_INSTANCE_KIND as a, SqlUnboundNamespace as b, POSTGRES_ENUM_KIND as c, buildSqlNamespaceMap as d, StorageTable as f, PrimaryKey as g, Index as h, SqlStorage as i, isPostgresEnumStorageEntry as l, StorageColumn as m, DEFAULT_FK_INDEX as n, isStorageTypeInstance as o, UniqueConstraint as p, applyFkDefaults as r, toStorageTypeInstance as s, DEFAULT_FK_CONSTRAINT as t, buildSqlNamespace as u, ForeignKeyReference as v, SqlNode as y };
399
410
 
400
- //# sourceMappingURL=types-L8p7B1dP.mjs.map
411
+ //# sourceMappingURL=types-DPkj4y3_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DPkj4y3_.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__\" }` — symmetric\n * with the family-level non-enumerable `kind` on `SqlNode` and bounded\n * to the minimum data the framework `Namespace` interface 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 tables: Readonly<Record<string, StorageTable>> = 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","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 } 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}\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\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 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 { 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}\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\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 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 { PostgresEnumStorageEntry } from './postgres-enum-storage-entry';\nimport type { SqlNamespace, SqlNamespaceTablesInput } from './sql-storage';\nimport { SqlUnboundNamespace } from './sql-unbound-namespace';\nimport { StorageTable } 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 declare readonly enum?: Readonly<Record<string, PostgresEnumStorageEntry>>;\n\n readonly id: string;\n readonly tables: Readonly<Record<string, StorageTable>>;\n\n static fromTablesInput(input: SqlNamespaceTablesInput): SqlNamespace {\n const tableCount = Object.keys(input.tables ?? {}).length;\n const enumCount = Object.keys(input.enum ?? {}).length;\n if (input.id === UNBOUND_NAMESPACE_ID && tableCount === 0 && enumCount === 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.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables ?? {}).map(([name, t]) => [\n name,\n t instanceof StorageTable ? t : new StorageTable(t),\n ]),\n ),\n );\n if (input.enum !== undefined && Object.keys(input.enum).length > 0) {\n Object.defineProperty(this, 'enum', {\n value: Object.freeze({ ...input.enum }),\n writable: false,\n enumerable: true,\n configurable: false,\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\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(ns),\n ]),\n );\n}\n","import 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}\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 {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n} from './postgres-enum-storage-entry';\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). Postgres\n * native enum registrations live under\n * `storage.namespaces[namespaceId].enum` instead.\n */\nexport type SqlStorageTypeEntry =\n | StorageTypeInstance\n | StorageTypeInstanceInput\n | PostgresEnumStorageEntry;\n\nexport interface SqlNamespaceTablesInput {\n readonly id: string;\n readonly tables?: Record<string, StorageTable | StorageTableInput>;\n readonly enum?: Record<string, PostgresEnumStorageEntry>;\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 readonly __unbound__: SqlNamespace;\n };\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'`; class-instance kinds\n * (e.g. Postgres-enum entries satisfying `PostgresEnumStorageEntry`)\n * pass through; hydration of raw JSON class-instance entries (carrying\n * their narrower `kind` literal) is the per-target serializer's\n * responsibility (so the family base does not import target-specific\n * subclasses).\n */\n// SQL concretions always store `StorageTable`-shaped values in `tables`.\n// `tables` is a SQL-family idiom — the framework `Namespace` contract no\n// longer mandates this field; Mongo namespaces carry `collections`\n// instead. The `__unbound__` slot uses the same narrowing as every other\n// SQL namespace; the wider `Record<string, object>` on `StorageTable` is\n// only there so emitted `contract.d.ts` table literals (which lack the\n// runtime `kind` discriminator on `StorageTable`) structurally satisfy\n// the slot without a class-instance check.\nexport type SqlNamespace = Namespace & {\n readonly tables: Readonly<Record<string, StorageTable>>;\n readonly enum?: Readonly<Record<string, PostgresEnumStorageEntry>>;\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 readonly __unbound__: SqlNamespace;\n };\n declare readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;\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\n/**\n * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.\n * Every entry must carry a recognised `kind` discriminator — either\n * `'codec-instance'` (codec triple, family-shared) or\n * `'postgres-enum'` (target-specific IR class). 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(\n name: string,\n entry: SqlStorageTypeEntry,\n): StorageTypeInstance | PostgresEnumStorageEntry {\n if (isPostgresEnumStorageEntry(entry)) {\n // Live class instances pass through unchanged; raw JSON envelopes\n // (e.g. `kind: 'postgres-enum'` without the class identity) are\n // rejected so the target serializer's hydration path is the only\n // way IR class instances enter the slot.\n if (entry instanceof SqlNode) {\n return entry;\n }\n throw new Error(\n `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.`,\n );\n }\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')} or ${JSON.stringify('postgres-enum')}. 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} 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 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<TContract>\n : CodecTypesOf<TTypeMaps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,sBAAb,MAAa,4BAA4B,cAAc;CACrD,OAAgB,WAAgC,IAAI,oBAAoB;CAExE,KAAc;CACd,SAA0D,OAAO,OAAO,CAAC,CAAC;CAG1E,cAAsB;EACpB,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpBA,IAAsB,UAAtB,cAAsC,WAAW;CAC/C;CAEA,cAAc;EACZ,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GAMZ,cAAc;EAChB,CAAC;CACH;A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