@prisma-next/sql-contract 0.13.0-dev.3 → 0.13.0-dev.30

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 (36) hide show
  1. package/dist/factories.d.mts +2 -2
  2. package/dist/factories.mjs +1 -1
  3. package/dist/index-type-validation.d.mts +1 -1
  4. package/dist/index-type-validation.mjs +8 -11
  5. package/dist/index-type-validation.mjs.map +1 -1
  6. package/dist/resolve-storage-table.d.mts +1 -1
  7. package/dist/resolve-storage-table.d.mts.map +1 -1
  8. package/dist/resolve-storage-table.mjs +11 -8
  9. package/dist/resolve-storage-table.mjs.map +1 -1
  10. package/dist/{sql-storage-CXf9xjAL.d.mts → sql-storage-BCLmt-nS.d.mts} +30 -20
  11. package/dist/{sql-storage-CXf9xjAL.d.mts.map → sql-storage-BCLmt-nS.d.mts.map} +1 -1
  12. package/dist/{types-DqhaAjCH.mjs → types-B7kJ6S7m.mjs} +42 -50
  13. package/dist/types-B7kJ6S7m.mjs.map +1 -0
  14. package/dist/{types-DEnWD3xB.d.mts → types-CFpK1iC5.d.mts} +6 -59
  15. package/dist/types-CFpK1iC5.d.mts.map +1 -0
  16. package/dist/types.d.mts +3 -3
  17. package/dist/types.mjs +2 -2
  18. package/dist/validators.d.mts +29 -28
  19. package/dist/validators.d.mts.map +1 -1
  20. package/dist/validators.mjs +71 -95
  21. package/dist/validators.mjs.map +1 -1
  22. package/package.json +7 -7
  23. package/src/exports/types.ts +2 -4
  24. package/src/index-type-validation.ts +2 -3
  25. package/src/ir/build-sql-namespace.ts +62 -32
  26. package/src/ir/sql-node.ts +2 -2
  27. package/src/ir/sql-storage.ts +22 -24
  28. package/src/ir/sql-unbound-namespace.ts +15 -3
  29. package/src/ir/storage-type-instance.ts +3 -3
  30. package/src/ir/storage-value-set.ts +6 -5
  31. package/src/resolve-storage-table.ts +12 -17
  32. package/src/types.ts +2 -6
  33. package/src/validators.ts +93 -113
  34. package/dist/types-DEnWD3xB.d.mts.map +0 -1
  35. package/dist/types-DqhaAjCH.mjs.map +0 -1
  36. package/src/ir/postgres-enum-storage-entry.ts +0 -57
@@ -1,7 +1,6 @@
1
1
  import { r as ReferentialAction } from "./foreign-key-BATxB95l.mjs";
2
- import { m as StorageTable, n as SqlNamespaceTablesInput, t as SqlNamespace } from "./sql-storage-CXf9xjAL.mjs";
3
- import { Namespace, NamespaceBase, StorageType } from "@prisma-next/framework-components/ir";
4
- import { ControlPolicy } from "@prisma-next/contract/types";
2
+ import { m as StorageTable, n as SqlNamespaceEntries, r as SqlNamespaceTablesInput, t as SqlNamespace } from "./sql-storage-BCLmt-nS.mjs";
3
+ import { Namespace, NamespaceBase } from "@prisma-next/framework-components/ir";
5
4
  import { CodecTrait } from "@prisma-next/framework-components/codec";
6
5
  import { ControlDriverInstance } from "@prisma-next/framework-components/control";
7
6
 
@@ -9,57 +8,6 @@ import { ControlDriverInstance } from "@prisma-next/framework-components/control
9
8
  declare function buildSqlNamespace(input: SqlNamespaceTablesInput): SqlNamespace;
10
9
  declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>): Readonly<Record<string, SqlNamespace>>;
11
10
  //#endregion
12
- //#region src/ir/postgres-enum-storage-entry.d.ts
13
- /**
14
- * Discriminator literal for the Postgres-enum variant on the polymorphic
15
- * `SqlStorage.types` slot.
16
- *
17
- * Enums are a target-level concept: Postgres ships native
18
- * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
19
- * constraints. The literal lives at the SQL family layer because every
20
- * SQL-family consumer (verifier, planner, lowering, …) needs to
21
- * discriminate enum-typed slot entries from codec-typed ones. The
22
- * concrete IR class (`PostgresEnumType`) lives in the target-postgres
23
- * package and implements this structural contract; cross-domain
24
- * layering rules forbid the SQL family from importing the concrete
25
- * target class directly, so the discriminator and structural interface
26
- * carry the dispatch.
27
- */
28
- declare const POSTGRES_ENUM_KIND: "postgres-enum";
29
- /**
30
- * Structural contract every Postgres-enum slot entry honours — both
31
- * the live `PostgresEnumType` IR-class instance and the raw JSON
32
- * envelope shape that survives `JSON.stringify` round-trips. SQL
33
- * family-layer dispatch narrows polymorphic `StorageType` slot
34
- * entries to this shape via `isPostgresEnumStorageEntry`.
35
- *
36
- * The `codecBinding` field is accessor-shaped (live class instance) on
37
- * the IR class and undefined on the raw JSON envelope; consumers that
38
- * need it must guard for its presence (the JSON path synthesises an
39
- * equivalent shape from `codecId` + `values`).
40
- */
41
- interface PostgresEnumStorageEntry extends StorageType {
42
- readonly kind: typeof POSTGRES_ENUM_KIND;
43
- readonly name: string;
44
- readonly nativeType: string;
45
- readonly values: readonly string[];
46
- /**
47
- * Enumerable own property on the persisted JSON envelope; the live
48
- * IR-class instance carries it too. Family-shared dispatch sites
49
- * read `codecId` directly rather than going through the IR-class
50
- * `codecBinding` accessor (which lives on the prototype and isn't
51
- * present on raw JSON envelopes).
52
- */
53
- readonly codecId: string;
54
- readonly control?: ControlPolicy;
55
- }
56
- /**
57
- * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
58
- * via its enumerable `kind` discriminator. Type guard returns true for
59
- * both live `PostgresEnumType` instances and raw JSON envelopes.
60
- */
61
- declare function isPostgresEnumStorageEntry(value: unknown): value is PostgresEnumStorageEntry;
62
- //#endregion
63
11
  //#region src/ir/sql-unbound-namespace.d.ts
64
12
  /**
65
13
  * Family-layer placeholder for the SQL unbound-namespace singleton —
@@ -95,11 +43,10 @@ declare function isPostgresEnumStorageEntry(value: unknown): value is PostgresEn
95
43
  declare class SqlUnboundNamespace extends NamespaceBase {
96
44
  static readonly instance: SqlUnboundNamespace;
97
45
  readonly id: "__unbound__";
98
- readonly entries: Readonly<{
99
- readonly table: Readonly<Record<string, StorageTable>>;
100
- }>;
46
+ readonly entries: SqlNamespaceEntries;
101
47
  readonly kind: string;
102
48
  private constructor();
49
+ get table(): Readonly<Record<string, StorageTable>>;
103
50
  qualifyTable(tableName: string): string;
104
51
  }
105
52
  //#endregion
@@ -204,5 +151,5 @@ type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract
204
151
  type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;
205
152
  type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
206
153
  //#endregion
207
- export { buildSqlNamespace as A, TypeMaps as C, POSTGRES_ENUM_KIND as D, SqlUnboundNamespace as E, PostgresEnumStorageEntry as O, SqlQueryOperationTypes as S, applyFkDefaults as T, QueryOperationTypesOf as _, ExtractCodecTypes as a, SqlModelFieldStorage as b, ExtractQueryOperationTypes as c, FieldOutputTypesOf as d, ForeignKeyOptions as f, QueryOperationTypesBase as g, QueryOperationTypeEntry as h, DEFAULT_FK_INDEX as i, buildSqlNamespaceMap as j, isPostgresEnumStorageEntry as k, ExtractTypeMapsFromContract as l, QueryOperationSelfSpec as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, QueryOperationReturn as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, FieldInputTypesOf as u, ResolveCodecTypes as v, TypeMapsPhantomKey as w, SqlModelStorage as x, SqlControlDriverInstance as y };
208
- //# sourceMappingURL=types-DEnWD3xB.d.mts.map
154
+ export { TypeMaps as C, buildSqlNamespace as D, SqlUnboundNamespace as E, buildSqlNamespaceMap as O, SqlQueryOperationTypes as S, applyFkDefaults as T, QueryOperationTypesOf as _, ExtractCodecTypes as a, SqlModelFieldStorage as b, ExtractQueryOperationTypes as c, FieldOutputTypesOf as d, ForeignKeyOptions as f, QueryOperationTypesBase as g, QueryOperationTypeEntry as h, DEFAULT_FK_INDEX as i, ExtractTypeMapsFromContract as l, QueryOperationSelfSpec as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, QueryOperationReturn as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, FieldInputTypesOf as u, ResolveCodecTypes as v, TypeMapsPhantomKey as w, SqlModelStorage as x, SqlControlDriverInstance as y };
155
+ //# sourceMappingURL=types-CFpK1iC5.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CFpK1iC5.d.mts","names":[],"sources":["../src/ir/build-sql-namespace.ts","../src/ir/sql-unbound-namespace.ts","../src/types.ts"],"mappings":";;;;;;;iBAgHgB,iBAAA,CAAkB,KAAA,EAAO,uBAAA,GAA0B,YAAY;AAAA,iBAI/D,oBAAA,CACd,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA,GAAY,uBAAA,KAC/C,QAAA,CAAS,MAAA,SAAe,YAAA;;;;;;;AAN3B;;;;;;;;AAA+E;AAI/E;;;;;;;;;;;;;;;;;;cC5Ea,mBAAA,SAA4B,aAAA;EAAA,gBACvB,QAAA,EAAU,mBAAA;EAAA,SAEjB,EAAA;EAAA,SACA,OAAA,EAAS,mBAAA;EAAA,SAMD,IAAA;EAAA,QAEV,WAAA;EAAA,IAWH,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe,YAAA;EAOrC,YAAA,CAAa,SAAA;AAAA;;;UClEE,wBAAA,oCACP,qBAAA,QAA6B,CAAA;EACrC,KAAA,OAAY,MAAA,mBACV,GAAA,UACA,MAAA,wBACC,OAAA;IAAA,SAAmB,IAAA,EAAM,GAAA;EAAA;AAAA;AAAA,KAyClB,iBAAA;EAAA,SACD,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA;AAAA,KAG3B,oBAAA;EAAA,SACD,MAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGC,eAAA;EAAA,SACD,KAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,MAAM,SAAS,oBAAA;AAAA;AAAA,cAGrB,qBAAA;AAAA,cACA,gBAAA;AAAA,iBAEG,eAAA,CACd,EAAA;EAAM,UAAA;EAAkC,KAAA;AAAA,GACxC,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BAAA,IAAsB,SAAA;AAAA,KAG3B,2BAAA,MAAiC,kBAAA,eAAiC,CAAA,GAC1E,WAAA,CAAY,CAAA,CAAE,kBAAA,SAA2B,CAAA;AAAA,KAGjC,kBAAA,OAAyB,CAAA,oBACjC,MAAA,kBACA,CAAA;EAAA,SAAqB,gBAAA;AAAA,IACnB,CAAA,SAAU,MAAA,SAAe,MAAA,qBACvB,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,OAAwB,CAAA,oBAChC,MAAA,kBACA,CAAA;EAAA,SAAqB,eAAA;AAAA,IACnB,CAAA,SAAU,MAAA,SAAe,MAAA,qBACvB,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,MAAuB,YAAA,CAAa,2BAAA,CAA4B,CAAA;AAAA,KAChE,0BAAA,MAAgC,qBAAA,CAAsB,2BAAA,CAA4B,CAAA;AAAA,KAClF,uBAAA,MAA6B,kBAAA,CAAmB,2BAAA,CAA4B,CAAA;AAAA,KAC5E,sBAAA,MAA4B,iBAAA,CAAkB,2BAAA,CAA4B,CAAA;AAAA,KAE1E,iBAAA,0BAA2C,SAAA,oBACnD,iBAAA,CAAkB,SAAA,IAClB,YAAA,CAAa,SAAA"}
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { a as ForeignKeyReferenceInput, i as ForeignKeyReference, n as ForeignKeyInput, o as SqlNode, r as ReferentialAction, t as ForeignKey } from "./foreign-key-BATxB95l.mjs";
2
- import { C as PrimaryKeyInput, S as PrimaryKey, T as CheckConstraintInput, _ as UniqueConstraintInput, a as SqlStorageTypeEntry, b as Index, c as StorageValueSetInput, d as StorageTypeInstanceInput, f as isStorageTypeInstance, g as UniqueConstraint, h as StorageTableInput, i as SqlStorageInput, l as CODEC_INSTANCE_KIND, m as StorageTable, n as SqlNamespaceTablesInput, o as storageTableAt, p as toStorageTypeInstance, r as SqlStorage, s as StorageValueSet, u as StorageTypeInstance, v as StorageColumn, w as CheckConstraint, x as IndexInput, y as StorageColumnInput } from "./sql-storage-CXf9xjAL.mjs";
3
- import { A as buildSqlNamespace, C as TypeMaps, D as POSTGRES_ENUM_KIND, E as SqlUnboundNamespace, O as PostgresEnumStorageEntry, S as SqlQueryOperationTypes, T as applyFkDefaults, _ as QueryOperationTypesOf, a as ExtractCodecTypes, b as SqlModelFieldStorage, c as ExtractQueryOperationTypes, d as FieldOutputTypesOf, f as ForeignKeyOptions, g as QueryOperationTypesBase, h as QueryOperationTypeEntry, i as DEFAULT_FK_INDEX, j as buildSqlNamespaceMap, k as isPostgresEnumStorageEntry, l as ExtractTypeMapsFromContract, m as QueryOperationSelfSpec, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as QueryOperationReturn, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as FieldInputTypesOf, v as ResolveCodecTypes, w as TypeMapsPhantomKey, x as SqlModelStorage, y as SqlControlDriverInstance } from "./types-DEnWD3xB.mjs";
4
- export { CODEC_INSTANCE_KIND, CheckConstraint, type CheckConstraintInput, type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractFieldInputTypes, type ExtractFieldOutputTypes, type ExtractQueryOperationTypes, type ExtractTypeMapsFromContract, type FieldInputTypesOf, type FieldOutputTypesOf, ForeignKey, type ForeignKeyInput, type ForeignKeyOptions, ForeignKeyReference, type ForeignKeyReferenceInput, Index, type IndexInput, POSTGRES_ENUM_KIND, type PostgresEnumStorageEntry, PrimaryKey, type PrimaryKeyInput, type QueryOperationReturn, type QueryOperationSelfSpec, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type SqlControlDriverInstance, type SqlModelFieldStorage, type SqlModelStorage, type SqlNamespaceTablesInput, SqlNode, type SqlQueryOperationTypes, SqlStorage, type SqlStorageInput, type SqlStorageTypeEntry, SqlUnboundNamespace, StorageColumn, type StorageColumnInput, StorageTable, type StorageTableInput, type StorageTypeInstance, type StorageTypeInstanceInput, StorageValueSet, type StorageValueSetInput, type TypeMaps, type TypeMapsPhantomKey, UniqueConstraint, type UniqueConstraintInput, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isPostgresEnumStorageEntry, isStorageTypeInstance, storageTableAt, toStorageTypeInstance };
2
+ import { C as PrimaryKeyInput, S as PrimaryKey, T as CheckConstraintInput, _ as UniqueConstraintInput, a as SqlStorageInput, b as Index, c as StorageValueSetInput, d as StorageTypeInstanceInput, f as isStorageTypeInstance, g as UniqueConstraint, h as StorageTableInput, i as SqlStorage, l as CODEC_INSTANCE_KIND, m as StorageTable, n as SqlNamespaceEntries, o as SqlStorageTypeEntry, p as toStorageTypeInstance, r as SqlNamespaceTablesInput, s as StorageValueSet, t as SqlNamespace, u as StorageTypeInstance, v as StorageColumn, w as CheckConstraint, x as IndexInput, y as StorageColumnInput } from "./sql-storage-BCLmt-nS.mjs";
3
+ import { C as TypeMaps, D as buildSqlNamespace, E as SqlUnboundNamespace, O as buildSqlNamespaceMap, S as SqlQueryOperationTypes, T as applyFkDefaults, _ as QueryOperationTypesOf, a as ExtractCodecTypes, b as SqlModelFieldStorage, c as ExtractQueryOperationTypes, d as FieldOutputTypesOf, f as ForeignKeyOptions, g as QueryOperationTypesBase, h as QueryOperationTypeEntry, i as DEFAULT_FK_INDEX, l as ExtractTypeMapsFromContract, m as QueryOperationSelfSpec, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as QueryOperationReturn, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as FieldInputTypesOf, v as ResolveCodecTypes, w as TypeMapsPhantomKey, x as SqlModelStorage, y as SqlControlDriverInstance } from "./types-CFpK1iC5.mjs";
4
+ export { CODEC_INSTANCE_KIND, CheckConstraint, type CheckConstraintInput, type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractFieldInputTypes, type ExtractFieldOutputTypes, type ExtractQueryOperationTypes, type ExtractTypeMapsFromContract, type FieldInputTypesOf, type FieldOutputTypesOf, ForeignKey, type ForeignKeyInput, type ForeignKeyOptions, ForeignKeyReference, type ForeignKeyReferenceInput, Index, type IndexInput, PrimaryKey, type PrimaryKeyInput, type QueryOperationReturn, type QueryOperationSelfSpec, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type SqlControlDriverInstance, type SqlModelFieldStorage, type SqlModelStorage, type SqlNamespace, type SqlNamespaceEntries, type SqlNamespaceTablesInput, SqlNode, type SqlQueryOperationTypes, SqlStorage, type SqlStorageInput, type SqlStorageTypeEntry, SqlUnboundNamespace, StorageColumn, type StorageColumnInput, StorageTable, type StorageTableInput, type StorageTypeInstance, type StorageTypeInstanceInput, StorageValueSet, type StorageValueSetInput, type TypeMaps, type TypeMapsPhantomKey, UniqueConstraint, type UniqueConstraintInput, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isStorageTypeInstance, toStorageTypeInstance };
package/dist/types.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as SqlUnboundNamespace, S as SqlNode, _ as Index, a as storageTableAt, b as ForeignKeyReference, c as toStorageTypeInstance, d as buildSqlNamespace, f as buildSqlNamespaceMap, g as StorageColumn, h as UniqueConstraint, i as SqlStorage, l as POSTGRES_ENUM_KIND, m as StorageTable, n as DEFAULT_FK_INDEX, o as CODEC_INSTANCE_KIND, p as StorageValueSet, r as applyFkDefaults, s as isStorageTypeInstance, t as DEFAULT_FK_CONSTRAINT, u as isPostgresEnumStorageEntry, v as PrimaryKey, x as CheckConstraint, y as ForeignKey } from "./types-DqhaAjCH.mjs";
2
- export { CODEC_INSTANCE_KIND, CheckConstraint, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, ForeignKey, ForeignKeyReference, Index, POSTGRES_ENUM_KIND, PrimaryKey, SqlNode, SqlStorage, SqlUnboundNamespace, StorageColumn, StorageTable, StorageValueSet, UniqueConstraint, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isPostgresEnumStorageEntry, isStorageTypeInstance, storageTableAt, toStorageTypeInstance };
1
+ import { _ as ForeignKeyReference, a as CODEC_INSTANCE_KIND, b as SqlUnboundNamespace, c as buildSqlNamespace, d as StorageTable, f as UniqueConstraint, g as ForeignKey, h as PrimaryKey, i as SqlStorage, l as buildSqlNamespaceMap, m as Index, n as DEFAULT_FK_INDEX, o as isStorageTypeInstance, p as StorageColumn, r as applyFkDefaults, s as toStorageTypeInstance, t as DEFAULT_FK_CONSTRAINT, u as StorageValueSet, v as CheckConstraint, y as SqlNode } from "./types-B7kJ6S7m.mjs";
2
+ export { CODEC_INSTANCE_KIND, CheckConstraint, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, ForeignKey, ForeignKeyReference, Index, PrimaryKey, SqlNode, SqlStorage, SqlUnboundNamespace, StorageColumn, StorageTable, StorageValueSet, UniqueConstraint, applyFkDefaults, buildSqlNamespace, buildSqlNamespaceMap, isStorageTypeInstance, toStorageTypeInstance };
@@ -1,5 +1,5 @@
1
1
  import { n as ForeignKeyInput, r as ReferentialAction } from "./foreign-key-BATxB95l.mjs";
2
- import { r as SqlStorage } from "./sql-storage-CXf9xjAL.mjs";
2
+ import { i as SqlStorage } from "./sql-storage-BCLmt-nS.mjs";
3
3
  import { Contract } from "@prisma-next/contract/types";
4
4
  import { Type } from "arktype";
5
5
 
@@ -15,26 +15,14 @@ type ColumnDefaultFunction = {
15
15
  declare const ColumnDefaultLiteralSchema: import("arktype/internal/variants/object.ts").ObjectType<ColumnDefaultLiteral, {}>;
16
16
  declare const ColumnDefaultFunctionSchema: import("arktype/internal/variants/object.ts").ObjectType<ColumnDefaultFunction, {}>;
17
17
  declare const ColumnDefaultSchema: import("arktype/internal/variants/object.ts").ObjectType<ColumnDefaultLiteral | ColumnDefaultFunction, {}>;
18
- /**
19
- * Postgres native enum entry under `storage.namespaces[namespaceId].entries.type[name]`.
20
- * Document-scoped `storage.types` carries codec aliases only
21
- * (`DocumentScopedStorageTypeSchema`).
22
- */
23
- declare const PostgresEnumTypeSchema: import("arktype/internal/variants/object.ts").ObjectType<{
24
- kind: "postgres-enum";
25
- values: readonly string[];
26
- name?: string;
27
- nativeType?: string;
28
- control?: "managed" | "tolerated" | "external" | "observed";
29
- }, {}>;
30
18
  /**
31
19
  * Storage value-set entry under `storage.namespaces[id].entries.valueSet[name]`.
32
- * Carries a `kind: 'value-set'` discriminator (enumerable, survives JSON) and an
20
+ * Carries a `kind: 'valueSet'` discriminator (enumerable, survives JSON) and an
33
21
  * ordered `values` array of codec-encoded permitted values.
34
22
  */
35
23
  declare const StorageValueSetSchema: import("arktype/internal/variants/object.ts").ObjectType<{
36
- kind: "value-set";
37
- values: readonly string[];
24
+ kind: "valueSet";
25
+ values: readonly (string | number | boolean | Record<string, unknown> | unknown[] | null)[];
38
26
  }, {}>;
39
27
  /**
40
28
  * Domain enum entry under `domain.namespaces[id].enum[name]`.
@@ -44,7 +32,7 @@ declare const ContractEnumSchema: import("arktype/internal/variants/object.ts").
44
32
  codecId: string;
45
33
  members: readonly {
46
34
  name: string;
47
- value: string;
35
+ value: string | number | boolean | Record<string, unknown> | unknown[] | null;
48
36
  }[];
49
37
  }, {}>;
50
38
  declare const IndexSchema: import("arktype/internal/variants/object.ts").ObjectType<{
@@ -70,33 +58,46 @@ declare const CheckConstraintSchema: import("arktype/internal/variants/object.ts
70
58
  name: string;
71
59
  column: string;
72
60
  valueSet: {
73
- plane: "domain" | "storage";
61
+ plane: "storage";
74
62
  namespaceId: string;
75
- entityKind: "value-set" | "enum";
76
- name: string;
63
+ entityKind: "valueSet";
64
+ entityName: string;
77
65
  spaceId?: string;
78
66
  };
79
67
  }, {}>;
68
+ /**
69
+ * Composes the single entry-validator registry consulted during
70
+ * structural validation. SQL core registers its own kinds (`'table'`,
71
+ * `'valueSet'`) into the same registry targets extend — there is no
72
+ * separate built-in fallback tier. Target packs pass their contributed
73
+ * kinds via `packSchemas`.
74
+ */
75
+ declare function createSqlEntrySchemaRegistry(packSchemas?: ReadonlyMap<string, Type<unknown>>): ReadonlyMap<string, Type<unknown>>;
80
76
  /**
81
77
  * Builds the per-namespace entry schema for `storage.namespaces[id]`.
82
- * Pack-contributed `validatorSchema` fragments — keyed by the
83
- * descriptor's `discriminator` validate each entry by matching the
84
- * entry's `kind` field on the `'entries.type'` slot.
78
+ *
79
+ * Validation is registry-driven: the `registry` parameter maps each
80
+ * entries key to an arktype schema that validates a single inner-map
81
+ * value for that kind. Compose the registry with
82
+ * {@link createSqlEntrySchemaRegistry} — SQL core's kinds and pack
83
+ * contributions live in the same map. An unregistered key fails
84
+ * validation naming the kind and the namespace id, so validation fails
85
+ * closed.
85
86
  */
86
- declare function createNamespaceEntrySchema(fragments?: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
87
+ declare function createNamespaceEntrySchema(registry: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
87
88
  /**
88
89
  * Builds the storage schema. Pack contributions reach the per-namespace
89
90
  * entry shape through {@link createNamespaceEntrySchema}; the
90
- * document-scoped `storage.types` slot (codec triples only) and the
91
+ * document-scoped `storage.types` field (codec triples only) and the
91
92
  * storage hash stay family-shared.
92
93
  */
93
- declare function createSqlStorageSchema(fragments?: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
94
+ declare function createSqlStorageSchema(registry: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
94
95
  /**
95
96
  * Builds the full SQL contract schema. The storage subtree threads
96
97
  * pack contributions through {@link createSqlStorageSchema}; the rest
97
98
  * of the contract envelope is family-shared.
98
99
  */
99
- declare function createSqlContractSchema(fragments?: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
100
+ declare function createSqlContractSchema(registry: ReadonlyMap<string, Type<unknown>>): Type<unknown>;
100
101
  /**
101
102
  * Validates the structural shape of SqlStorage using Arktype.
102
103
  *
@@ -155,5 +156,5 @@ interface ValidateSqlContractFullyOptions {
155
156
  */
156
157
  declare function validateSqlContractFully<T extends Contract<SqlStorage>>(value: unknown, options?: ValidateSqlContractFullyOptions): T;
157
158
  //#endregion
158
- export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema, PostgresEnumTypeSchema, ReferentialActionSchema, StorageValueSetSchema, ValidateSqlContractFullyOptions, createNamespaceEntrySchema, createSqlContractSchema, createSqlStorageSchema, validateModel, validateModelStorageReferences, validateSqlContractFully, validateSqlStorageConsistency, validateStorage, validateStorageSemantics };
159
+ export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema, ReferentialActionSchema, StorageValueSetSchema, ValidateSqlContractFullyOptions, createNamespaceEntrySchema, createSqlContractSchema, createSqlEntrySchemaRegistry, createSqlStorageSchema, validateModel, validateModelStorageReferences, validateSqlContractFully, validateSqlStorageConsistency, validateStorage, validateStorageSemantics };
159
160
  //# sourceMappingURL=validators.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.mts","names":[],"sources":["../src/validators.ts"],"mappings":";;;;;;KA2BK,oBAAA;EAAA,SACM,IAAA;EAAA,SACA,KAAA,8BAAmC,MAAM;AAAA;AAAA,KAE/C,qBAAA;EAAA,SAAmC,IAAA;EAAA,SAA2B,UAAU;AAAA;AAAA,cAShE,0BAAA,gDAA0B,UAAA,CAAA,oBAAA;AAAA,cAK1B,2BAAA,gDAA2B,UAAA,CAAA,qBAAA;AAAA,cAK3B,mBAAA,gDAAmB,UAAA,CAAA,oBAAA,GAAA,qBAAA;;AArBoB;AAAA;;;cA+F9C,sBAAA,gDAAsB,UAAA;;;;;;;AA/E5B;;;;AAAwC;AAA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,UAwGhD,+BAAA;EAtrBU;AA6B3B;;;;;;;EA7B2B,SA+rBhB,cAAA,GAAiB,IAAI;AAAA;;;;;AAhqBzB;AAuCP;;;iBAooBgB,wBAAA,WAAmC,QAAA,CAAS,UAAA,GAC1D,KAAA,WACA,OAAA,GAAU,+BAAA,GACT,CAAA"}
@@ -1,10 +1,10 @@
1
- import { C as SqlUnboundNamespace, f as buildSqlNamespaceMap, i as SqlStorage } from "./types-DqhaAjCH.mjs";
1
+ import { b as SqlUnboundNamespace, i as SqlStorage, l as buildSqlNamespaceMap } from "./types-B7kJ6S7m.mjs";
2
2
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
3
- import { blindCast } from "@prisma-next/utils/casts";
3
+ import { blindCast, castAs } from "@prisma-next/utils/casts";
4
+ import { ifDefined } from "@prisma-next/utils/defined";
4
5
  import { CrossReferenceSchema } from "@prisma-next/contract/types";
5
6
  import { ContractValidationError } from "@prisma-next/contract/contract-validation-error";
6
7
  import { validateContractDomain } from "@prisma-next/contract/validate-domain";
7
- import { ifDefined } from "@prisma-next/utils/defined";
8
8
  import { type } from "arktype";
9
9
  //#region src/validators.ts
10
10
  const literalKindSchema = type("'literal'");
@@ -46,11 +46,18 @@ const ExecutionSchema = type({
46
46
  }).array().readonly()
47
47
  }
48
48
  });
49
- const ValueSetRefSchema = type({
50
- plane: "'domain' | 'storage'",
49
+ const StorageValueSetRefSchema = type({
50
+ plane: "'storage'",
51
51
  namespaceId: "string",
52
- entityKind: "'enum' | 'value-set'",
53
- name: "string",
52
+ entityKind: "'valueSet'",
53
+ entityName: "string",
54
+ "spaceId?": "string"
55
+ });
56
+ const DomainEnumRefSchema = type({
57
+ plane: "'domain'",
58
+ namespaceId: "string",
59
+ entityKind: "'enum'",
60
+ entityName: "string",
54
61
  "spaceId?": "string"
55
62
  });
56
63
  const StorageColumnSchema = type({
@@ -62,45 +69,26 @@ const StorageColumnSchema = type({
62
69
  "typeRef?": "string",
63
70
  "default?": ColumnDefaultSchema,
64
71
  "control?": ControlPolicySchema,
65
- "valueSet?": ValueSetRefSchema
72
+ "valueSet?": StorageValueSetRefSchema
66
73
  }).narrow((col, ctx) => {
67
74
  if (col.typeParams !== void 0 && col.typeRef !== void 0) return ctx.mustBe("a column with either typeParams or typeRef, not both");
68
75
  return true;
69
76
  });
70
- /**
71
- * Codec-triple entry persisted under `storage.types[name]`. Carries an
72
- * enumerable literal `kind: 'codec-instance'` discriminator so the
73
- * polymorphic slot dispatch can distinguish codec triples from
74
- * class-instance kinds (e.g. `'postgres-enum'`) sharing the slot.
75
- */
76
- const StorageTypeInstanceSchema = type.declare().type({
77
+ /** Document-scoped `storage.types`: codec triples only. */
78
+ const DocumentScopedStorageTypeSchema = type.declare().type({
77
79
  kind: "'codec-instance'",
78
80
  codecId: "string",
79
81
  nativeType: "string",
80
82
  "typeParams?": "Record<string, unknown>"
81
83
  });
82
84
  /**
83
- * Postgres native enum entry under `storage.namespaces[namespaceId].entries.type[name]`.
84
- * Document-scoped `storage.types` carries codec aliases only
85
- * (`DocumentScopedStorageTypeSchema`).
86
- */
87
- const PostgresEnumTypeSchema = type({
88
- kind: "'postgres-enum'",
89
- "name?": "string",
90
- "nativeType?": "string",
91
- values: type.string.array().readonly(),
92
- "control?": ControlPolicySchema
93
- });
94
- /** Document-scoped `storage.types`: codec triples only. */
95
- const DocumentScopedStorageTypeSchema = StorageTypeInstanceSchema;
96
- /**
97
85
  * Storage value-set entry under `storage.namespaces[id].entries.valueSet[name]`.
98
- * Carries a `kind: 'value-set'` discriminator (enumerable, survives JSON) and an
86
+ * Carries a `kind: 'valueSet'` discriminator (enumerable, survives JSON) and an
99
87
  * ordered `values` array of codec-encoded permitted values.
100
88
  */
101
89
  const StorageValueSetSchema = type({
102
- kind: "'value-set'",
103
- values: type.string.array().readonly()
90
+ kind: "'valueSet'",
91
+ values: type("string | number | boolean | null | unknown[] | Record<string, unknown>").array().readonly()
104
92
  });
105
93
  /**
106
94
  * Domain enum entry under `domain.namespaces[id].enum[name]`.
@@ -111,7 +99,7 @@ const ContractEnumSchema = type({
111
99
  codecId: "string",
112
100
  members: type({
113
101
  name: "string",
114
- value: "string"
102
+ value: "string | number | boolean | null | unknown[] | Record<string, unknown>"
115
103
  }).array().readonly()
116
104
  });
117
105
  const PrimaryKeySchema = type.declare().type({
@@ -155,7 +143,7 @@ const CheckConstraintSchema = type({
155
143
  "+": "reject",
156
144
  name: "string",
157
145
  column: "string",
158
- valueSet: ValueSetRefSchema
146
+ valueSet: StorageValueSetRefSchema
159
147
  });
160
148
  const StorageTableSchema = type({
161
149
  "+": "reject",
@@ -168,73 +156,59 @@ const StorageTableSchema = type({
168
156
  "checks?": CheckConstraintSchema.array().readonly()
169
157
  });
170
158
  /**
171
- * Composes a hardcoded family `fallback` schema with optional
172
- * pack-contributed `fragments` keyed by the entry's `kind`
173
- * discriminator. The composition is **additive**, not substitutive:
174
- *
175
- * - No fragments registered → entries are validated by `fallback`
176
- * alone (the unchanged baseline).
177
- * - An entry's `kind` matches `fallbackKind` AND a fragment for that
178
- * kind is registered → the entry must pass **both** `fallback` and
179
- * the fragment. This preserves family-owned invariants (e.g. the
180
- * built-in `PostgresEnumType` shape) even when a pack contributes
181
- * its own schema for the same kind.
182
- * - An entry's `kind` matches a registered fragment for some
183
- * non-fallback kind → the fragment alone validates the entry.
184
- * `fallback` is family-specific (validates a single hardcoded kind)
185
- * and would reject any other kind, so it does not apply here.
186
- * - An entry's `kind` matches no fragment → fall through to
187
- * `fallback`.
159
+ * Composes the single entry-validator registry consulted during
160
+ * structural validation. SQL core registers its own kinds (`'table'`,
161
+ * `'valueSet'`) into the same registry targets extend — there is no
162
+ * separate built-in fallback tier. Target packs pass their contributed
163
+ * kinds via `packSchemas`.
188
164
  */
189
- function namespaceSlotEntrySchema(fallback, fallbackKind, fragments) {
190
- if (fragments === void 0 || fragments.size === 0) return fallback;
191
- return type("unknown").narrow((entry, ctx) => {
192
- if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return ctx.mustBe("an object");
193
- const kind = entry.kind;
194
- if (typeof kind === "string") {
195
- const fragment = fragments.get(kind);
196
- if (fragment !== void 0) {
197
- if (kind === fallbackKind) {
198
- const baseParsed = fallback(entry);
199
- if (baseParsed instanceof type.errors) return ctx.reject({ expected: baseParsed.summary });
200
- }
201
- const parsed = fragment(entry);
202
- if (parsed instanceof type.errors) return ctx.reject({ expected: parsed.summary });
203
- return true;
204
- }
205
- }
206
- const parsed = fallback(entry);
207
- if (parsed instanceof type.errors) return ctx.reject({ expected: parsed.summary });
208
- return true;
209
- });
165
+ function createSqlEntrySchemaRegistry(packSchemas) {
166
+ const registry = new Map([["table", castAs(StorageTableSchema)], ["valueSet", castAs(StorageValueSetSchema)]]);
167
+ if (packSchemas !== void 0) for (const [kind, schema] of packSchemas) {
168
+ if (registry.has(kind)) throw new Error(`createSqlEntrySchemaRegistry: pack schema "${kind}" collides with a core kind pack schemas cannot override "table" or "valueSet"`);
169
+ registry.set(kind, schema);
170
+ }
171
+ return registry;
210
172
  }
211
173
  /**
212
174
  * Builds the per-namespace entry schema for `storage.namespaces[id]`.
213
- * Pack-contributed `validatorSchema` fragments — keyed by the
214
- * descriptor's `discriminator` validate each entry by matching the
215
- * entry's `kind` field on the `'entries.type'` slot.
175
+ *
176
+ * Validation is registry-driven: the `registry` parameter maps each
177
+ * entries key to an arktype schema that validates a single inner-map
178
+ * value for that kind. Compose the registry with
179
+ * {@link createSqlEntrySchemaRegistry} — SQL core's kinds and pack
180
+ * contributions live in the same map. An unregistered key fails
181
+ * validation naming the kind and the namespace id, so validation fails
182
+ * closed.
216
183
  */
217
- function createNamespaceEntrySchema(fragments) {
184
+ function createNamespaceEntrySchema(registry) {
218
185
  return type({
219
186
  "+": "reject",
220
187
  id: "string",
221
188
  "kind?": "string",
222
- entries: type({
223
- "+": "reject",
224
- "table?": type({ "[string]": StorageTableSchema }),
225
- "type?": type({ "[string]": namespaceSlotEntrySchema(PostgresEnumTypeSchema, "postgres-enum", fragments) }),
226
- "valueSet?": type({ "[string]": StorageValueSetSchema })
227
- })
189
+ entries: "object"
190
+ }).narrow((ns, ctx) => {
191
+ if (!isPlainRecord(ns.entries)) return ctx.mustBe("an entries object");
192
+ for (const [key, innerMap] of Object.entries(ns.entries)) {
193
+ const entrySchema = registry.get(key);
194
+ if (entrySchema === void 0) return ctx.reject({ expected: `entries key "${key}" in namespace "${ns.id}" is not a registered entity kind` });
195
+ if (!isPlainRecord(innerMap)) return ctx.reject({ expected: `entries["${key}"] in namespace "${ns.id}" must be an object` });
196
+ for (const [, value] of Object.entries(innerMap)) {
197
+ const parsed = entrySchema(value);
198
+ if (parsed instanceof type.errors) return ctx.reject({ expected: parsed.summary });
199
+ }
200
+ }
201
+ return true;
228
202
  });
229
203
  }
230
204
  /**
231
205
  * Builds the storage schema. Pack contributions reach the per-namespace
232
206
  * entry shape through {@link createNamespaceEntrySchema}; the
233
- * document-scoped `storage.types` slot (codec triples only) and the
207
+ * document-scoped `storage.types` field (codec triples only) and the
234
208
  * storage hash stay family-shared.
235
209
  */
236
- function createSqlStorageSchema(fragments) {
237
- const namespaceEntry = createNamespaceEntrySchema(fragments);
210
+ function createSqlStorageSchema(registry) {
211
+ const namespaceEntry = createNamespaceEntrySchema(registry);
238
212
  return type({
239
213
  "+": "reject",
240
214
  storageHash: "string",
@@ -242,16 +216,18 @@ function createSqlStorageSchema(fragments) {
242
216
  "namespaces?": type({ "[string]": namespaceEntry })
243
217
  });
244
218
  }
245
- const StorageSchema = createSqlStorageSchema();
219
+ const StorageSchema = createSqlStorageSchema(createSqlEntrySchemaRegistry());
246
220
  function eachStorageTable(storage) {
247
- return Object.entries(storage.namespaces).flatMap(([namespaceId, ns]) => Object.entries(ns.entries.table).map(([tableName, table]) => ({
221
+ return Object.entries(storage.namespaces).flatMap(([namespaceId, ns]) => Object.entries(ns.entries["table"] ?? {}).map(([tableName, table]) => ({
248
222
  namespaceId,
249
223
  tableName,
250
224
  table
251
225
  })));
252
226
  }
253
227
  function isPlainRecord(value) {
254
- return typeof value === "object" && value !== null && !Array.isArray(value);
228
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
229
+ const proto = Object.getPrototypeOf(value);
230
+ return proto === Object.prototype || proto === null;
255
231
  }
256
232
  function findDuplicateValue(values) {
257
233
  const seen = /* @__PURE__ */ new Set();
@@ -283,7 +259,7 @@ const ModelFieldSchema = type({
283
259
  type: type("unknown").narrow((value, ctx) => isContractFieldType(value) ? true : ctx.mustBe("scalar, valueObject, or union field type")),
284
260
  "many?": "true",
285
261
  "dict?": "true",
286
- "valueSet?": ValueSetRefSchema
262
+ "valueSet?": DomainEnumRefSchema
287
263
  });
288
264
  const ModelStorageSchema = type({
289
265
  table: "string",
@@ -342,8 +318,8 @@ const ContractMetaSchema = type({ "[string]": "unknown" });
342
318
  * pack contributions through {@link createSqlStorageSchema}; the rest
343
319
  * of the contract envelope is family-shared.
344
320
  */
345
- function createSqlContractSchema(fragments) {
346
- const storage = createSqlStorageSchema(fragments);
321
+ function createSqlContractSchema(registry) {
322
+ const storage = createSqlStorageSchema(registry);
347
323
  return type({
348
324
  "+": "reject",
349
325
  target: "string",
@@ -364,7 +340,7 @@ function createSqlContractSchema(fragments) {
364
340
  "execution?": ExecutionSchema
365
341
  });
366
342
  }
367
- const SqlContractSchema = createSqlContractSchema();
343
+ const SqlContractSchema = createSqlContractSchema(createSqlEntrySchemaRegistry());
368
344
  /**
369
345
  * Validates the structural shape of SqlStorage using Arktype.
370
346
  *
@@ -525,7 +501,7 @@ function validateModelStorageReferences(contract) {
525
501
  const storageNamespaceId = model.storage.namespaceId;
526
502
  if (storageNamespaceId !== namespaceId) throw new ContractValidationError(`Model "${qualifiedName}" storage.namespaceId "${storageNamespaceId}" does not match domain namespace "${namespaceId}"`, "storage");
527
503
  const storageTable = model.storage.table;
528
- const rawTable = contract.storage.namespaces[storageNamespaceId]?.entries.table[storageTable];
504
+ const rawTable = contract.storage.namespaces[storageNamespaceId]?.entries.table?.[storageTable];
529
505
  if (rawTable === void 0) throw new ContractValidationError(`Model "${qualifiedName}" references non-existent table "${storageNamespaceId}.${storageTable}"`, "storage");
530
506
  const table = rawTable;
531
507
  const columnNames = new Set(Object.keys(table.columns));
@@ -563,7 +539,7 @@ function validateSqlStorageConsistency(contract) {
563
539
  if (fk.source.namespaceId !== namespaceId || fk.source.tableName !== tableName) throw new ContractValidationError(`Namespace "${namespaceId}" table "${tableName}" contains foreignKey with mismatched source coordinates (${fk.source.namespaceId}.${fk.source.tableName})`, "storage");
564
540
  for (const colName of fk.source.columns) if (!columnNames.has(colName)) throw new ContractValidationError(`Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent column "${colName}"`, "storage");
565
541
  if (fk.target.spaceId === void 0) {
566
- const referencedRaw = contract.storage.namespaces[fk.target.namespaceId]?.entries.table[fk.target.tableName];
542
+ const referencedRaw = contract.storage.namespaces[fk.target.namespaceId]?.entries.table?.[fk.target.tableName];
567
543
  if (referencedRaw === void 0) throw new ContractValidationError(`Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent table "${fk.target.namespaceId}.${fk.target.tableName}"`, "storage");
568
544
  const referencedColumnNames = new Set(Object.keys(referencedRaw.columns));
569
545
  for (const colName of fk.target.columns) if (!referencedColumnNames.has(colName)) throw new ContractValidationError(`Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent column "${colName}" in table "${fk.target.tableName}"`, "storage");
@@ -596,6 +572,6 @@ function validateSqlContractFully(value, options) {
596
572
  return validated;
597
573
  }
598
574
  //#endregion
599
- export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema, PostgresEnumTypeSchema, ReferentialActionSchema, StorageValueSetSchema, createNamespaceEntrySchema, createSqlContractSchema, createSqlStorageSchema, validateModel, validateModelStorageReferences, validateSqlContractFully, validateSqlStorageConsistency, validateStorage, validateStorageSemantics };
575
+ export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema, ReferentialActionSchema, StorageValueSetSchema, createNamespaceEntrySchema, createSqlContractSchema, createSqlEntrySchemaRegistry, createSqlStorageSchema, validateModel, validateModelStorageReferences, validateSqlContractFully, validateSqlStorageConsistency, validateStorage, validateStorageSemantics };
600
576
 
601
577
  //# sourceMappingURL=validators.mjs.map