@prisma-next/sql-contract 0.12.0 → 0.13.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/canonicalization-hooks.d.mts.map +1 -1
  2. package/dist/canonicalization-hooks.mjs +10 -11
  3. package/dist/canonicalization-hooks.mjs.map +1 -1
  4. package/dist/factories.d.mts +4 -2
  5. package/dist/factories.d.mts.map +1 -1
  6. package/dist/factories.mjs +3 -2
  7. package/dist/factories.mjs.map +1 -1
  8. package/dist/foreign-key-BATxB95l.d.mts +121 -0
  9. package/dist/foreign-key-BATxB95l.d.mts.map +1 -0
  10. package/dist/index-type-validation.d.mts +2 -2
  11. package/dist/index-type-validation.mjs +1 -1
  12. package/dist/index-type-validation.mjs.map +1 -1
  13. package/dist/{index-types-B1cf5N0F.d.mts → index-types-Czsyu7Iw.d.mts} +1 -1
  14. package/dist/{index-types-B1cf5N0F.d.mts.map → index-types-Czsyu7Iw.d.mts.map} +1 -1
  15. package/dist/index-types.d.mts +1 -1
  16. package/dist/pack-types.d.mts +1 -1
  17. package/dist/referential-action-sql.d.mts +12 -0
  18. package/dist/referential-action-sql.d.mts.map +1 -0
  19. package/dist/referential-action-sql.mjs +17 -0
  20. package/dist/referential-action-sql.mjs.map +1 -0
  21. package/dist/resolve-storage-table.d.mts +20 -0
  22. package/dist/resolve-storage-table.d.mts.map +1 -0
  23. package/dist/resolve-storage-table.mjs +42 -0
  24. package/dist/resolve-storage-table.mjs.map +1 -0
  25. package/dist/sql-storage-CXf9xjAL.d.mts +314 -0
  26. package/dist/sql-storage-CXf9xjAL.d.mts.map +1 -0
  27. package/dist/types-DEnWD3xB.d.mts +208 -0
  28. package/dist/types-DEnWD3xB.d.mts.map +1 -0
  29. package/dist/{types-DPkj4y3_.mjs → types-DqhaAjCH.mjs} +109 -28
  30. package/dist/types-DqhaAjCH.mjs.map +1 -0
  31. package/dist/types.d.mts +4 -2
  32. package/dist/types.mjs +2 -2
  33. package/dist/validators.d.mts +51 -14
  34. package/dist/validators.d.mts.map +1 -1
  35. package/dist/validators.mjs +116 -32
  36. package/dist/validators.mjs.map +1 -1
  37. package/package.json +11 -9
  38. package/src/canonicalization-hooks.ts +5 -6
  39. package/src/exports/referential-action-sql.ts +1 -0
  40. package/src/exports/resolve-storage-table.ts +1 -0
  41. package/src/exports/types.ts +6 -0
  42. package/src/factories.ts +2 -1
  43. package/src/index-type-validation.ts +1 -1
  44. package/src/ir/build-sql-namespace.ts +33 -19
  45. package/src/ir/check-constraint.ts +42 -0
  46. package/src/ir/foreign-key-reference.ts +23 -0
  47. package/src/ir/postgres-enum-storage-entry.ts +2 -0
  48. package/src/ir/sql-storage.ts +53 -50
  49. package/src/ir/sql-unbound-namespace.ts +11 -4
  50. package/src/ir/storage-column.ts +7 -1
  51. package/src/ir/storage-table.ts +10 -0
  52. package/src/ir/storage-type-instance.ts +5 -3
  53. package/src/ir/storage-value-set.ts +42 -0
  54. package/src/referential-action-sql.ts +14 -0
  55. package/src/resolve-storage-table.ts +61 -0
  56. package/src/types.ts +13 -0
  57. package/src/validators.ts +156 -46
  58. package/dist/types-ChlHcJCu.d.mts +0 -508
  59. package/dist/types-ChlHcJCu.d.mts.map +0 -1
  60. package/dist/types-DPkj4y3_.mjs.map +0 -1
@@ -1 +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"}
1
+ {"version":3,"file":"canonicalization-hooks.d.mts","names":[],"sources":["../src/canonicalization-hooks.ts"],"mappings":";;;cAwBa,gCAAA;EAAA,SACF,mBAAA,EAAqB,sBAAA;EAAA,SACrB,WAAA,EAAa,WAAW;AAAA"}
@@ -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,23 +33,19 @@ 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"]
37
- ],
38
- [
39
- "storage",
40
- "types",
41
- "*",
42
- "typeParams"
43
41
  ]
44
42
  ]),
45
43
  sortStorage: createStorageSort([{
46
44
  path: [
47
45
  "namespaces",
48
46
  "*",
49
- "tables",
47
+ "entries",
48
+ "table",
50
49
  "*"
51
50
  ],
52
51
  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] 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":";AAwBA,MAAa,mCAGT;CACF,qBARA,6BAA6B;EAX7B;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;CAQjE,CAQ7B;CACA,aAP+B,kBAAkB,CANjD;EAAE,MAAM;GAAC;GAAc;GAAK;GAAW;GAAS;EAAG;EAAG,WAAW,CAAC,WAAW,SAAS;CAAE,CAMvC,CAOjD;AACF"}
@@ -1,4 +1,6 @@
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-ChlHcJCu.mjs";
1
+ import { t as ForeignKey } from "./foreign-key-BATxB95l.mjs";
2
+ import { S as PrimaryKey, b as Index, g as UniqueConstraint, m as StorageTable, v as StorageColumn, y as StorageColumnInput } from "./sql-storage-CXf9xjAL.mjs";
3
+ import { b as SqlModelFieldStorage, f as ForeignKeyOptions, x as SqlModelStorage } from "./types-DEnWD3xB.mjs";
2
4
  import { ScalarFieldType } from "@prisma-next/contract/types";
3
5
 
4
6
  //#region src/factories.d.ts
@@ -17,7 +19,7 @@ declare function table(columns: Record<string, StorageColumn | StorageColumnInpu
17
19
  indexes?: readonly Index[];
18
20
  fks?: readonly ForeignKey[];
19
21
  }): StorageTable;
20
- declare function model(tableName: string, fields: Record<string, SqlModelFieldStorage>, relations?: Record<string, unknown>): {
22
+ declare function model(tableName: string, fields: Record<string, SqlModelFieldStorage>, relations?: Record<string, unknown>, namespaceId?: string): {
21
23
  storage: SqlModelStorage;
22
24
  fields: Record<string, {
23
25
  readonly nullable: boolean;
@@ -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,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
+ {"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,IAAM,OAAA,sBAA6B,UAAU;AAAA,iBAI7C,MAAA,IAAU,OAAA,sBAA6B,gBAAgB;AAAA,iBAIvD,KAAA,IAAS,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,mBACX,WAAA;EAEA,OAAA,EAAS,eAAA;EACT,MAAA,EAAQ,MAAA;IAAA,SAA0B,QAAA;IAAA,SAA4B,IAAA,EAAM,eAAA;EAAA;EACpE,SAAA,EAAW,MAAA;AAAA"}
@@ -1,4 +1,4 @@
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";
1
+ import { _ as Index, g as StorageColumn, h as UniqueConstraint, m as StorageTable, r as applyFkDefaults, v as PrimaryKey, y as ForeignKey } from "./types-DqhaAjCH.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
@@ -51,10 +51,11 @@ function table(columns, opts) {
51
51
  foreignKeys: opts?.fks ?? []
52
52
  });
53
53
  }
54
- function model(tableName, fields, relations = {}) {
54
+ function model(tableName, fields, relations = {}, namespaceId = UNBOUND_NAMESPACE_ID) {
55
55
  return {
56
56
  storage: {
57
57
  table: tableName,
58
+ namespaceId,
58
59
  fields
59
60
  },
60
61
  fields: Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, {
@@ -1 +1 @@
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
+ {"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 namespaceId: string = UNBOUND_NAMESPACE_ID,\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, namespaceId, 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,GACtC,cAAsB,sBAKtB;CAWA,OAAO;EACL,SAAA;GAXiC,OAAO;GAAW;GAAa;EAW1D;EACN,QAXmB,OAAO,YAC1B,OAAO,QAAQ,MAAM,CAAC,CAAC,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"}
@@ -0,0 +1,121 @@
1
+ import { IRNodeBase } from "@prisma-next/framework-components/ir";
2
+ import { NamespaceId } from "@prisma-next/contract/types";
3
+
4
+ //#region src/ir/sql-node.d.ts
5
+ /**
6
+ * SQL family IR node base. Carries the family-level `kind` discriminator
7
+ * `'sql'` and inherits the framework's `freezeNode` affordance.
8
+ *
9
+ * Single family-level discriminator (not per-leaf) reflects the fact that
10
+ * SQL IR has no polymorphic dispatch today — verifiers and serializers
11
+ * walk by structural position (`storage.tables[name].columns[name]`),
12
+ * not by inspecting `kind`. The abstract bar for per-leaf discriminators
13
+ * isn't earned until a future polymorphic consumer arrives.
14
+ *
15
+ * `kind` is installed as a non-enumerable own property on every instance,
16
+ * which keeps three things clean simultaneously:
17
+ *
18
+ * - `JSON.stringify(node)` produces the canonical pre-lift JSON envelope
19
+ * shape (no `kind` field), so emitted contract.json files and the
20
+ * `validateSqlContractFully` arktype schemas stay unchanged.
21
+ * - Test assertions that use `toEqual({...})` against the pre-lift flat
22
+ * shape continue to pass — only enumerable own properties are
23
+ * compared.
24
+ * - Direct access (`node.kind`) and runtime narrowing
25
+ * (`if (node.kind === 'sql')`) still work, so future polymorphic
26
+ * dispatch can begin reading `kind` without a runtime change.
27
+ *
28
+ * Future per-leaf overrides land cleanly: a class that gains a
29
+ * polymorphic-dispatch consumer (e.g. an enum type instance walked
30
+ * alongside other types) overrides `kind` with its narrower literal
31
+ * at that leaf level. Per-leaf overrides will use enumerable kind
32
+ * (matching the Mongo per-class-discriminator precedent) because they
33
+ * encode dispatch-relevant information that callers need to see in
34
+ * JSON envelopes; the family-level `'sql'` is uniform across all SQL
35
+ * IR and carries no dispatch-relevant information.
36
+ */
37
+ declare abstract class SqlNode extends IRNodeBase {
38
+ readonly kind?: string;
39
+ constructor();
40
+ }
41
+ //#endregion
42
+ //#region src/ir/foreign-key-reference.d.ts
43
+ /**
44
+ * Input for a foreign-key reference (one side of a foreign-key declaration).
45
+ *
46
+ * When `spaceId` is absent the reference is local — the referenced table lives
47
+ * in the same contract-space. When `spaceId` is present the reference is
48
+ * cross-space — the referenced table lives in a different contract-space
49
+ * identified by `spaceId`.
50
+ *
51
+ * Presence-based discrimination keeps local FK JSON byte-identical to
52
+ * contracts authored before cross-space support was added.
53
+ */
54
+ interface ForeignKeyReferenceInput {
55
+ readonly namespaceId: string;
56
+ readonly tableName: string;
57
+ readonly columns: readonly string[];
58
+ readonly spaceId?: string;
59
+ }
60
+ /**
61
+ * SQL Contract IR node for one side (source or target) of a foreign-key
62
+ * declaration. Carries the full coordinate: namespace, table, and columns.
63
+ *
64
+ * Cross-space discrimination is based on `spaceId` presence: absent means
65
+ * local (same contract-space); present means cross-space (the referenced
66
+ * table lives in the contract-space identified by `spaceId`).
67
+ *
68
+ * For local references `spaceId` is absent from JSON, keeping the serialized
69
+ * shape byte-identical to contracts authored before cross-space support was
70
+ * added. For cross-space references `spaceId` appears in JSON so round-trips
71
+ * are lossless.
72
+ *
73
+ * Use `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`
74
+ * as the sentinel `namespaceId` for single-namespace (unbound) references.
75
+ */
76
+ declare class ForeignKeyReference extends SqlNode {
77
+ readonly namespaceId: NamespaceId;
78
+ readonly tableName: string;
79
+ readonly columns: readonly string[];
80
+ readonly spaceId?: string;
81
+ constructor(input: ForeignKeyReferenceInput);
82
+ }
83
+ //#endregion
84
+ //#region src/ir/foreign-key.d.ts
85
+ type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
86
+ interface ForeignKeyInput {
87
+ readonly source: ForeignKeyReference | ForeignKeyReferenceInput;
88
+ readonly target: ForeignKeyReference | ForeignKeyReferenceInput;
89
+ readonly name?: string;
90
+ readonly onDelete?: ReferentialAction;
91
+ readonly onUpdate?: ReferentialAction;
92
+ /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */
93
+ readonly constraint: boolean;
94
+ /** Whether to emit a backing index for the FK columns. */
95
+ readonly index: boolean;
96
+ }
97
+ /**
98
+ * SQL Contract IR node for a table-level foreign-key declaration.
99
+ *
100
+ * Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
101
+ * coordinates (namespace, table, columns). For single-namespace contracts the
102
+ * sentinel `UNBOUND_NAMESPACE_ID` appears on both sides.
103
+ *
104
+ * The nested references are normalised to {@link ForeignKeyReference}
105
+ * instances inside the constructor so downstream walks see a uniform AST
106
+ * regardless of whether the input was a JSON literal or an already-constructed
107
+ * class instance.
108
+ */
109
+ declare class ForeignKey extends SqlNode {
110
+ readonly source: ForeignKeyReference;
111
+ readonly target: ForeignKeyReference;
112
+ readonly constraint: boolean;
113
+ readonly index: boolean;
114
+ readonly name?: string;
115
+ readonly onDelete?: ReferentialAction;
116
+ readonly onUpdate?: ReferentialAction;
117
+ constructor(input: ForeignKeyInput);
118
+ }
119
+ //#endregion
120
+ export { ForeignKeyReferenceInput as a, ForeignKeyReference as i, ForeignKeyInput as n, SqlNode as o, ReferentialAction as r, ForeignKey as t };
121
+ //# sourceMappingURL=foreign-key-BATxB95l.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foreign-key-BATxB95l.d.mts","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts"],"mappings":";;;;;;;AAkCA;;;;;;;;;;;;ACnBA;;;;;;;;;AAIkB;AAmBlB;;;;;;;uBDJsB,OAAA,SAAgB,UAAU;EAAA,SACrC,IAAA;;;;;;;AADX;;;;;;;;;UCnBiB,wBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;AAAA;;;;;;;AAAO;AAmBlB;;;;;;;;;cAAa,mBAAA,SAA4B,OAAA;EAAA,SAC9B,WAAA,EAAa,WAAA;EAAA,SACb,SAAA;EAAA,SACA,OAAA;EAAA,SACQ,OAAA;cAEL,KAAA,EAAO,wBAAA;AAAA;;;KCxCT,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;;;ADAX;;;;;;;;;AAIkB;cCWL,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"}
@@ -1,5 +1,5 @@
1
- import { k as SqlStorage } from "./types-ChlHcJCu.mjs";
2
- import { a as IndexTypeRegistry } from "./index-types-B1cf5N0F.mjs";
1
+ import { r as SqlStorage } from "./sql-storage-CXf9xjAL.mjs";
2
+ import { a as IndexTypeRegistry } from "./index-types-Czsyu7Iw.mjs";
3
3
  import { Contract } from "@prisma-next/contract/types";
4
4
 
5
5
  //#region src/index-type-validation.d.ts
@@ -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"}
@@ -28,4 +28,4 @@ interface IndexTypeRegistry {
28
28
  declare function createIndexTypeRegistry(): IndexTypeRegistry;
29
29
  //#endregion
30
30
  export { IndexTypeRegistry as a, IndexTypeRegistration as i, IndexTypeEntry as n, createIndexTypeRegistry as o, IndexTypeMap as r, defineIndexTypes as s, IndexTypeBuilder as t };
31
- //# sourceMappingURL=index-types-B1cf5N0F.d.mts.map
31
+ //# sourceMappingURL=index-types-Czsyu7Iw.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"index-types-Czsyu7Iw.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,IAAoB,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,IAA2B,iBAAiB"}
@@ -1,2 +1,2 @@
1
- import { a as IndexTypeRegistry, i as IndexTypeRegistration, n as IndexTypeEntry, o as createIndexTypeRegistry, r as IndexTypeMap, s as defineIndexTypes, t as IndexTypeBuilder } from "./index-types-B1cf5N0F.mjs";
1
+ import { a as IndexTypeRegistry, i as IndexTypeRegistration, n as IndexTypeEntry, o as createIndexTypeRegistry, r as IndexTypeMap, s as defineIndexTypes, t as IndexTypeBuilder } from "./index-types-Czsyu7Iw.mjs";
2
2
  export { type IndexTypeBuilder, type IndexTypeEntry, type IndexTypeMap, type IndexTypeRegistration, type IndexTypeRegistry, createIndexTypeRegistry, defineIndexTypes };
@@ -9,5 +9,5 @@ interface StorageTypeMetadata {
9
9
  readonly nativeType?: string;
10
10
  }
11
11
  //#endregion
12
- export { type StorageTypeMetadata };
12
+ export type { StorageTypeMetadata };
13
13
  //# sourceMappingURL=pack-types.d.mts.map
@@ -0,0 +1,12 @@
1
+ import { r as ReferentialAction } from "./foreign-key-BATxB95l.mjs";
2
+
3
+ //#region src/referential-action-sql.d.ts
4
+ /**
5
+ * Maps each `ReferentialAction` value to the SQL keyword used in ON DELETE /
6
+ * ON UPDATE clauses. Shared across the migration planner and adapter DDL
7
+ * renderers — single source of truth for the action → SQL mapping.
8
+ */
9
+ declare const REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string>;
10
+ //#endregion
11
+ export { REFERENTIAL_ACTION_SQL };
12
+ //# sourceMappingURL=referential-action-sql.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referential-action-sql.d.mts","names":[],"sources":["../src/referential-action-sql.ts"],"mappings":";;;;;AAOA;;;cAAa,sBAAA,EAAwB,MAAM,CAAC,iBAAA"}
@@ -0,0 +1,17 @@
1
+ //#region src/referential-action-sql.ts
2
+ /**
3
+ * Maps each `ReferentialAction` value to the SQL keyword used in ON DELETE /
4
+ * ON UPDATE clauses. Shared across the migration planner and adapter DDL
5
+ * renderers — single source of truth for the action → SQL mapping.
6
+ */
7
+ const REFERENTIAL_ACTION_SQL = {
8
+ noAction: "NO ACTION",
9
+ restrict: "RESTRICT",
10
+ cascade: "CASCADE",
11
+ setNull: "SET NULL",
12
+ setDefault: "SET DEFAULT"
13
+ };
14
+ //#endregion
15
+ export { REFERENTIAL_ACTION_SQL };
16
+
17
+ //# sourceMappingURL=referential-action-sql.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referential-action-sql.mjs","names":[],"sources":["../src/referential-action-sql.ts"],"sourcesContent":["import type { ReferentialAction } from './ir/foreign-key';\n\n/**\n * Maps each `ReferentialAction` value to the SQL keyword used in ON DELETE /\n * ON UPDATE clauses. Shared across the migration planner and adapter DDL\n * renderers — single source of truth for the action → SQL mapping.\n */\nexport const REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\n};\n"],"mappings":";;;;;;AAOA,MAAa,yBAA4D;CACvE,UAAU;CACV,UAAU;CACV,SAAS;CACT,SAAS;CACT,YAAY;AACd"}
@@ -0,0 +1,20 @@
1
+ import { m as StorageTable, r as SqlStorage } from "./sql-storage-CXf9xjAL.mjs";
2
+
3
+ //#region src/resolve-storage-table.d.ts
4
+ interface ResolvedStorageTable {
5
+ readonly namespaceId: string;
6
+ readonly table: StorageTable;
7
+ }
8
+ /**
9
+ * Resolve a bare storage table name to its namespace coordinate and table IR.
10
+ *
11
+ * When `namespaceId` is supplied, the table is resolved strictly within that
12
+ * namespace (no scan). When omitted, a bare name unique across namespaces
13
+ * resolves to its sole namespace; a bare name declared in more than one
14
+ * namespace throws a fail-fast diagnostic naming the candidate namespaces
15
+ * rather than silently selecting the first match.
16
+ */
17
+ declare function resolveStorageTable(storage: SqlStorage, tableName: string, namespaceId?: string): ResolvedStorageTable | undefined;
18
+ //#endregion
19
+ export { type ResolvedStorageTable, resolveStorageTable };
20
+ //# sourceMappingURL=resolve-storage-table.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-storage-table.d.mts","names":[],"sources":["../src/resolve-storage-table.ts"],"mappings":";;;UAGiB,oBAAA;EAAA,SACN,WAAA;EAAA,SACA,KAAA,EAAO,YAAY;AAAA;;;;;;AAAA;AA0B9B;;;iBAAgB,mBAAA,CACd,OAAA,EAAS,UAAA,EACT,SAAA,UACA,WAAA,YACC,oBAAoB"}
@@ -0,0 +1,42 @@
1
+ //#region src/resolve-storage-table.ts
2
+ function tableInNamespace(namespace, tableName) {
3
+ if (namespace === void 0) return;
4
+ const tables = namespace.entries.table;
5
+ if (!Object.hasOwn(tables, tableName)) return;
6
+ return tables[tableName];
7
+ }
8
+ /**
9
+ * Resolve a bare storage table name to its namespace coordinate and table IR.
10
+ *
11
+ * When `namespaceId` is supplied, the table is resolved strictly within that
12
+ * namespace (no scan). When omitted, a bare name unique across namespaces
13
+ * resolves to its sole namespace; a bare name declared in more than one
14
+ * namespace throws a fail-fast diagnostic naming the candidate namespaces
15
+ * rather than silently selecting the first match.
16
+ */
17
+ function resolveStorageTable(storage, tableName, namespaceId) {
18
+ if (namespaceId !== void 0) {
19
+ const table = tableInNamespace(storage.namespaces[namespaceId], tableName);
20
+ return table === void 0 ? void 0 : {
21
+ namespaceId,
22
+ table
23
+ };
24
+ }
25
+ const matches = [];
26
+ for (const candidateNamespaceId of Object.keys(storage.namespaces)) {
27
+ const table = tableInNamespace(storage.namespaces[candidateNamespaceId], tableName);
28
+ if (table !== void 0) matches.push({
29
+ namespaceId: candidateNamespaceId,
30
+ table
31
+ });
32
+ }
33
+ if (matches.length > 1) {
34
+ const candidates = matches.map((match) => match.namespaceId).sort().join(", ");
35
+ throw new Error(`Storage table "${tableName}" is ambiguous across namespaces [${candidates}]; qualify it with a namespace coordinate.`);
36
+ }
37
+ return matches[0];
38
+ }
39
+ //#endregion
40
+ export { resolveStorageTable };
41
+
42
+ //# sourceMappingURL=resolve-storage-table.mjs.map
@@ -0,0 +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.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.\n *\n * When `namespaceId` is supplied, the table is resolved strictly within that\n * namespace (no scan). When omitted, a bare name unique across namespaces\n * resolves to its sole namespace; a bare name declared in more than one\n * namespace throws a fail-fast diagnostic naming the candidate namespaces\n * rather than silently selecting the first match.\n */\nexport function resolveStorageTable(\n storage: SqlStorage,\n tableName: string,\n namespaceId?: string,\n): ResolvedStorageTable | undefined {\n if (namespaceId !== undefined) {\n const table = tableInNamespace(storage.namespaces[namespaceId], tableName);\n return table === undefined ? undefined : { namespaceId, table };\n }\n\n const matches: ResolvedStorageTable[] = [];\n for (const candidateNamespaceId of Object.keys(storage.namespaces)) {\n const table = tableInNamespace(storage.namespaces[candidateNamespaceId], tableName);\n if (table !== undefined) {\n matches.push({ namespaceId: candidateNamespaceId, table });\n }\n }\n\n if (matches.length > 1) {\n const candidates = matches\n .map((match) => match.namespaceId)\n .sort()\n .join(', ');\n throw new Error(\n `Storage table \"${tableName}\" is ambiguous across namespaces [${candidates}]; qualify it with a namespace coordinate.`,\n );\n }\n\n return matches[0];\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;;;;;;;;;;AAWA,SAAgB,oBACd,SACA,WACA,aACkC;CAClC,IAAI,gBAAgB,KAAA,GAAW;EAC7B,MAAM,QAAQ,iBAAiB,QAAQ,WAAW,cAAc,SAAS;EACzE,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY;GAAE;GAAa;EAAM;CAChE;CAEA,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,wBAAwB,OAAO,KAAK,QAAQ,UAAU,GAAG;EAClE,MAAM,QAAQ,iBAAiB,QAAQ,WAAW,uBAAuB,SAAS;EAClF,IAAI,UAAU,KAAA,GACZ,QAAQ,KAAK;GAAE,aAAa;GAAsB;EAAM,CAAC;CAE7D;CAEA,IAAI,QAAQ,SAAS,GAAG;EACtB,MAAM,aAAa,QAChB,KAAK,UAAU,MAAM,WAAW,CAAC,CACjC,KAAK,CAAC,CACN,KAAK,IAAI;EACZ,MAAM,IAAI,MACR,kBAAkB,UAAU,oCAAoC,WAAW,2CAC7E;CACF;CAEA,OAAO,QAAQ;AACjB"}