@prisma-next/sql-contract 0.13.0 → 0.14.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.
- package/dist/{types-DqhaAjCH.mjs → entity-kinds-Cl36zL5j.mjs} +121 -205
- package/dist/entity-kinds-Cl36zL5j.mjs.map +1 -0
- package/dist/entity-kinds.d.mts +18 -0
- package/dist/entity-kinds.d.mts.map +1 -0
- package/dist/entity-kinds.mjs +2 -0
- package/dist/factories.d.mts +2 -2
- package/dist/factories.mjs +2 -1
- package/dist/factories.mjs.map +1 -1
- package/dist/index-type-validation.d.mts +1 -1
- package/dist/index-type-validation.mjs +9 -12
- package/dist/index-type-validation.mjs.map +1 -1
- package/dist/resolve-storage-table.d.mts +2 -1
- package/dist/resolve-storage-table.d.mts.map +1 -1
- package/dist/resolve-storage-table.mjs +11 -8
- package/dist/resolve-storage-table.mjs.map +1 -1
- package/dist/sql-storage-Dga0jwP2.d.mts +128 -0
- package/dist/sql-storage-Dga0jwP2.d.mts.map +1 -0
- package/dist/{sql-storage-CXf9xjAL.d.mts → storage-value-set-WnYsIFM8.d.mts} +8 -120
- package/dist/storage-value-set-WnYsIFM8.d.mts.map +1 -0
- package/dist/types-B-eiQXff.mjs +191 -0
- package/dist/types-B-eiQXff.mjs.map +1 -0
- package/dist/{types-DEnWD3xB.d.mts → types-B1N8w0I2.d.mts} +11 -62
- package/dist/types-B1N8w0I2.d.mts.map +1 -0
- package/dist/types.d.mts +4 -3
- package/dist/types.mjs +3 -2
- package/dist/validators.d.mts +75 -40
- package/dist/validators.d.mts.map +1 -1
- package/dist/validators.mjs +54 -184
- package/dist/validators.mjs.map +1 -1
- package/package.json +8 -7
- package/src/entity-kinds.ts +45 -0
- package/src/exports/entity-kinds.ts +5 -0
- package/src/exports/types.ts +2 -4
- package/src/index-type-validation.ts +2 -3
- package/src/ir/build-sql-namespace.ts +39 -32
- package/src/ir/sql-node.ts +2 -2
- package/src/ir/sql-storage.ts +22 -24
- package/src/ir/sql-unbound-namespace.ts +15 -3
- package/src/ir/storage-entry-schemas.ts +128 -0
- package/src/ir/storage-type-instance.ts +3 -3
- package/src/ir/storage-value-set.ts +6 -5
- package/src/resolve-storage-table.ts +12 -17
- package/src/types.ts +10 -10
- package/src/validators.ts +84 -225
- package/dist/sql-storage-CXf9xjAL.d.mts.map +0 -1
- package/dist/types-DEnWD3xB.d.mts.map +0 -1
- package/dist/types-DqhaAjCH.mjs.map +0 -1
- package/src/ir/postgres-enum-storage-entry.ts +0 -57
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as ReferentialAction } from "./foreign-key-BATxB95l.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { r as StorageTable } from "./storage-value-set-WnYsIFM8.mjs";
|
|
3
|
+
import { n as SqlNamespaceEntries, r as SqlNamespaceTablesInput, t as SqlNamespace } from "./sql-storage-Dga0jwP2.mjs";
|
|
4
|
+
import { Namespace, NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
5
5
|
import { CodecTrait } from "@prisma-next/framework-components/codec";
|
|
6
6
|
import { ControlDriverInstance } from "@prisma-next/framework-components/control";
|
|
7
7
|
|
|
@@ -9,57 +9,6 @@ import { ControlDriverInstance } from "@prisma-next/framework-components/control
|
|
|
9
9
|
declare function buildSqlNamespace(input: SqlNamespaceTablesInput): SqlNamespace;
|
|
10
10
|
declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>): Readonly<Record<string, SqlNamespace>>;
|
|
11
11
|
//#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
12
|
//#region src/ir/sql-unbound-namespace.d.ts
|
|
64
13
|
/**
|
|
65
14
|
* Family-layer placeholder for the SQL unbound-namespace singleton —
|
|
@@ -95,11 +44,10 @@ declare function isPostgresEnumStorageEntry(value: unknown): value is PostgresEn
|
|
|
95
44
|
declare class SqlUnboundNamespace extends NamespaceBase {
|
|
96
45
|
static readonly instance: SqlUnboundNamespace;
|
|
97
46
|
readonly id: "__unbound__";
|
|
98
|
-
readonly entries:
|
|
99
|
-
readonly table: Readonly<Record<string, StorageTable>>;
|
|
100
|
-
}>;
|
|
47
|
+
readonly entries: SqlNamespaceEntries;
|
|
101
48
|
readonly kind: string;
|
|
102
49
|
private constructor();
|
|
50
|
+
get table(): Readonly<Record<string, StorageTable>>;
|
|
103
51
|
qualifyTable(tableName: string): string;
|
|
104
52
|
}
|
|
105
53
|
//#endregion
|
|
@@ -136,9 +84,10 @@ declare function applyFkDefaults(fk: {
|
|
|
136
84
|
constraint: boolean;
|
|
137
85
|
index: boolean;
|
|
138
86
|
};
|
|
87
|
+
type NamespacedFieldTypeMap = Record<string, Record<string, Record<string, unknown>>>;
|
|
139
88
|
type TypeMaps<TCodecTypes extends Record<string, {
|
|
140
89
|
output: unknown;
|
|
141
|
-
}> = Record<string, never>, TQueryOperationTypes extends Record<string, unknown> = Record<string, never>, TFieldOutputTypes extends
|
|
90
|
+
}> = Record<string, never>, TQueryOperationTypes extends Record<string, unknown> = Record<string, never>, TFieldOutputTypes extends NamespacedFieldTypeMap = Record<string, never>, TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>> = {
|
|
142
91
|
readonly codecTypes: TCodecTypes;
|
|
143
92
|
readonly queryOperationTypes: TQueryOperationTypes;
|
|
144
93
|
readonly fieldOutputTypes: TFieldOutputTypes;
|
|
@@ -194,15 +143,15 @@ type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & { readonly [K in T
|
|
|
194
143
|
type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T ? NonNullable<T[TypeMapsPhantomKey & keyof T]> : never;
|
|
195
144
|
type FieldOutputTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
196
145
|
readonly fieldOutputTypes: infer F;
|
|
197
|
-
} ? F extends
|
|
146
|
+
} ? F extends NamespacedFieldTypeMap ? F : Record<string, never> : Record<string, never>;
|
|
198
147
|
type FieldInputTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
199
148
|
readonly fieldInputTypes: infer F;
|
|
200
|
-
} ? F extends
|
|
149
|
+
} ? F extends NamespacedFieldTypeMap ? F : Record<string, never> : Record<string, never>;
|
|
201
150
|
type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
202
151
|
type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
203
152
|
type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
204
153
|
type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
205
154
|
type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
|
|
206
155
|
//#endregion
|
|
207
|
-
export {
|
|
208
|
-
//# sourceMappingURL=types-
|
|
156
|
+
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 };
|
|
157
|
+
//# sourceMappingURL=types-B1N8w0I2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-B1N8w0I2.d.mts","names":[],"sources":["../src/ir/build-sql-namespace.ts","../src/ir/sql-unbound-namespace.ts","../src/types.ts"],"mappings":";;;;;;;;iBAyFgB,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;;;;;;;;;;;;;;;;;cCrDa,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;AAA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AA,SAAyB,MAAA;AAAA,cACrD,MAAA,SAAe,uBAAA,KACvB,CAAA;AAAA,KAEQ,uBAAA,GAA0B,MAAM,SAAS,uBAAA;AAAA,KAEzC,qBAAA,OAA4B,CAAA,oBACpC,MAAA,kBACA,CAAA;EAAA,SAAqB,mBAAA;AAAA,IACnB,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,kBAAA;AAAA,KAEA,oBAAA,yBAA6C,SAAA,oBACxC,kBAAA,IAAsB,SAAA;AAAA,KAG3B,2BAAA,MAAiC,kBAAA,eAAiC,CAAA,GAC1E,WAAA,CAAY,CAAA,CAAE,kBAAA,SAA2B,CAAA;AAAA,KAGjC,kBAAA,OAAyB,CAAA,oBACjC,MAAA,kBACA,CAAA;EAAA,SAAqB,gBAAA;AAAA,IACnB,CAAA,SAAU,sBAAA,GACR,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,OAAwB,CAAA,oBAChC,MAAA,kBACA,CAAA;EAAA,SAAqB,eAAA;AAAA,IACnB,CAAA,SAAU,sBAAA,GACR,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,5 @@
|
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { a as UniqueConstraint, c as StorageColumnInput, d as PrimaryKey, f as PrimaryKeyInput, i as StorageTableInput, l as Index, m as CheckConstraintInput, n as StorageValueSetInput, o as UniqueConstraintInput, p as CheckConstraint, r as StorageTable, s as StorageColumn, t as StorageValueSet, u as IndexInput } from "./storage-value-set-WnYsIFM8.mjs";
|
|
3
|
+
import { a as SqlStorageInput, c as StorageTypeInstance, d as toStorageTypeInstance, i as SqlStorage, l as StorageTypeInstanceInput, n as SqlNamespaceEntries, o as SqlStorageTypeEntry, r as SqlNamespaceTablesInput, s as CODEC_INSTANCE_KIND, t as SqlNamespace, u as isStorageTypeInstance } from "./sql-storage-Dga0jwP2.mjs";
|
|
4
|
+
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-B1N8w0I2.mjs";
|
|
5
|
+
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,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as StorageTable, c as Index, d as ForeignKeyReference, f as CheckConstraint, i as StorageValueSet, l as PrimaryKey, o as UniqueConstraint, p as SqlNode, s as StorageColumn, u as ForeignKey } from "./entity-kinds-Cl36zL5j.mjs";
|
|
2
|
+
import { a as CODEC_INSTANCE_KIND, c as buildSqlNamespace, i as SqlStorage, l as buildSqlNamespaceMap, n as DEFAULT_FK_INDEX, o as isStorageTypeInstance, r as applyFkDefaults, s as toStorageTypeInstance, t as DEFAULT_FK_CONSTRAINT, u as SqlUnboundNamespace } from "./types-B-eiQXff.mjs";
|
|
3
|
+
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 };
|
package/dist/validators.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { n as ForeignKeyInput, r as ReferentialAction } from "./foreign-key-BATxB95l.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { f as PrimaryKeyInput, o as UniqueConstraintInput } from "./storage-value-set-WnYsIFM8.mjs";
|
|
3
|
+
import { i as SqlStorage } from "./sql-storage-Dga0jwP2.mjs";
|
|
4
4
|
import { Type } from "arktype";
|
|
5
|
+
import { AnyEntityKindDescriptor } from "@prisma-next/framework-components/ir";
|
|
6
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
5
7
|
|
|
6
|
-
//#region src/
|
|
8
|
+
//#region src/ir/storage-entry-schemas.d.ts
|
|
7
9
|
type ColumnDefaultLiteral = {
|
|
8
10
|
readonly kind: 'literal';
|
|
9
11
|
readonly value: string | number | boolean | Record<string, unknown> | unknown[] | null;
|
|
@@ -15,37 +17,14 @@ type ColumnDefaultFunction = {
|
|
|
15
17
|
declare const ColumnDefaultLiteralSchema: import("arktype/internal/variants/object.ts").ObjectType<ColumnDefaultLiteral, {}>;
|
|
16
18
|
declare const ColumnDefaultFunctionSchema: import("arktype/internal/variants/object.ts").ObjectType<ColumnDefaultFunction, {}>;
|
|
17
19
|
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
20
|
/**
|
|
31
21
|
* Storage value-set entry under `storage.namespaces[id].entries.valueSet[name]`.
|
|
32
|
-
* Carries a `kind: '
|
|
22
|
+
* Carries a `kind: 'valueSet'` discriminator (enumerable, survives JSON) and an
|
|
33
23
|
* ordered `values` array of codec-encoded permitted values.
|
|
34
24
|
*/
|
|
35
25
|
declare const StorageValueSetSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
36
|
-
kind: "
|
|
37
|
-
values: readonly string[];
|
|
38
|
-
}, {}>;
|
|
39
|
-
/**
|
|
40
|
-
* Domain enum entry under `domain.namespaces[id].enum[name]`.
|
|
41
|
-
* Carries the codec id and an ordered `members` array of `{name, value}` pairs.
|
|
42
|
-
*/
|
|
43
|
-
declare const ContractEnumSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
44
|
-
codecId: string;
|
|
45
|
-
members: readonly {
|
|
46
|
-
name: string;
|
|
47
|
-
value: string;
|
|
48
|
-
}[];
|
|
26
|
+
kind: "valueSet";
|
|
27
|
+
values: readonly (string | number | boolean | Record<string, unknown> | unknown[] | null)[];
|
|
49
28
|
}, {}>;
|
|
50
29
|
declare const IndexSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
51
30
|
columns: readonly string[];
|
|
@@ -70,33 +49,89 @@ declare const CheckConstraintSchema: import("arktype/internal/variants/object.ts
|
|
|
70
49
|
name: string;
|
|
71
50
|
column: string;
|
|
72
51
|
valueSet: {
|
|
73
|
-
plane: "
|
|
52
|
+
plane: "storage";
|
|
74
53
|
namespaceId: string;
|
|
75
|
-
entityKind: "
|
|
76
|
-
|
|
54
|
+
entityKind: "valueSet";
|
|
55
|
+
entityName: string;
|
|
77
56
|
spaceId?: string;
|
|
78
57
|
};
|
|
79
58
|
}, {}>;
|
|
59
|
+
declare const StorageTableSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
60
|
+
columns: {
|
|
61
|
+
[x: string]: {
|
|
62
|
+
nativeType: string;
|
|
63
|
+
codecId: string;
|
|
64
|
+
nullable: boolean;
|
|
65
|
+
typeParams?: Record<string, unknown>;
|
|
66
|
+
typeRef?: string;
|
|
67
|
+
default?: ColumnDefaultLiteral | ColumnDefaultFunction;
|
|
68
|
+
control?: "managed" | "tolerated" | "external" | "observed";
|
|
69
|
+
valueSet?: {
|
|
70
|
+
plane: "storage";
|
|
71
|
+
namespaceId: string;
|
|
72
|
+
entityKind: "valueSet";
|
|
73
|
+
entityName: string;
|
|
74
|
+
spaceId?: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
uniques: readonly UniqueConstraintInput[];
|
|
79
|
+
indexes: readonly {
|
|
80
|
+
columns: readonly string[];
|
|
81
|
+
name?: string;
|
|
82
|
+
type?: string;
|
|
83
|
+
options?: Record<string, unknown>;
|
|
84
|
+
}[];
|
|
85
|
+
foreignKeys: readonly ForeignKeyInput[];
|
|
86
|
+
primaryKey?: PrimaryKeyInput;
|
|
87
|
+
control?: "managed" | "tolerated" | "external" | "observed";
|
|
88
|
+
checks?: readonly {
|
|
89
|
+
name: string;
|
|
90
|
+
column: string;
|
|
91
|
+
valueSet: {
|
|
92
|
+
plane: "storage";
|
|
93
|
+
namespaceId: string;
|
|
94
|
+
entityKind: "valueSet";
|
|
95
|
+
entityName: string;
|
|
96
|
+
spaceId?: string;
|
|
97
|
+
};
|
|
98
|
+
}[];
|
|
99
|
+
}, {}>;
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/validators.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* Domain enum entry under `domain.namespaces[id].enum[name]`.
|
|
104
|
+
* Carries the codec id and an ordered `members` array of `{name, value}` pairs.
|
|
105
|
+
*/
|
|
106
|
+
declare const ContractEnumSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
107
|
+
codecId: string;
|
|
108
|
+
members: readonly {
|
|
109
|
+
name: string;
|
|
110
|
+
value: string | number | boolean | unknown[] | Record<string, unknown> | null;
|
|
111
|
+
}[];
|
|
112
|
+
}, {}>;
|
|
80
113
|
/**
|
|
81
114
|
* Builds the per-namespace entry schema for `storage.namespaces[id]`.
|
|
82
|
-
*
|
|
83
|
-
* descriptor
|
|
84
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* Validation is descriptor-driven: the `kinds` map carries both the schema
|
|
117
|
+
* (used here for structural validation) and the construct function (used at
|
|
118
|
+
* hydration time). An unregistered key fails validation naming the kind and
|
|
119
|
+
* the namespace id, so validation fails closed.
|
|
85
120
|
*/
|
|
86
|
-
declare function createNamespaceEntrySchema(
|
|
121
|
+
declare function createNamespaceEntrySchema(kinds: ReadonlyMap<string, AnyEntityKindDescriptor>): Type<unknown>;
|
|
87
122
|
/**
|
|
88
123
|
* Builds the storage schema. Pack contributions reach the per-namespace
|
|
89
124
|
* entry shape through {@link createNamespaceEntrySchema}; the
|
|
90
|
-
* document-scoped `storage.types`
|
|
125
|
+
* document-scoped `storage.types` field (codec triples only) and the
|
|
91
126
|
* storage hash stay family-shared.
|
|
92
127
|
*/
|
|
93
|
-
declare function createSqlStorageSchema(
|
|
128
|
+
declare function createSqlStorageSchema(kinds: ReadonlyMap<string, AnyEntityKindDescriptor>): Type<unknown>;
|
|
94
129
|
/**
|
|
95
130
|
* Builds the full SQL contract schema. The storage subtree threads
|
|
96
131
|
* pack contributions through {@link createSqlStorageSchema}; the rest
|
|
97
132
|
* of the contract envelope is family-shared.
|
|
98
133
|
*/
|
|
99
|
-
declare function createSqlContractSchema(
|
|
134
|
+
declare function createSqlContractSchema(kinds: ReadonlyMap<string, AnyEntityKindDescriptor>): Type<unknown>;
|
|
100
135
|
/**
|
|
101
136
|
* Validates the structural shape of SqlStorage using Arktype.
|
|
102
137
|
*
|
|
@@ -155,5 +190,5 @@ interface ValidateSqlContractFullyOptions {
|
|
|
155
190
|
*/
|
|
156
191
|
declare function validateSqlContractFully<T extends Contract<SqlStorage>>(value: unknown, options?: ValidateSqlContractFullyOptions): T;
|
|
157
192
|
//#endregion
|
|
158
|
-
export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema,
|
|
193
|
+
export { CheckConstraintSchema, ColumnDefaultFunctionSchema, ColumnDefaultLiteralSchema, ColumnDefaultSchema, ContractEnumSchema, ForeignKeyReferenceSchema, ForeignKeySchema, ForeignKeySourceSchema, IndexSchema, ReferentialActionSchema, StorageTableSchema, StorageValueSetSchema, ValidateSqlContractFullyOptions, createNamespaceEntrySchema, createSqlContractSchema, createSqlStorageSchema, validateModel, validateModelStorageReferences, validateSqlContractFully, validateSqlStorageConsistency, validateStorage, validateStorageSemantics };
|
|
159
194
|
//# sourceMappingURL=validators.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.mts","names":[],"sources":["../src/validators.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.d.mts","names":[],"sources":["../src/ir/storage-entry-schemas.ts","../src/validators.ts"],"mappings":";;;;;;;;KAMK,oBAAA;EAAA,SACM,IAAA;EAAA,SACA,KAAA,8BAAmC,MAAM;AAAA;AAAA,KAE/C,qBAAA;EAAA,SAAmC,IAAA;EAAA,SAA2B,UAAU;AAAA;AAAA,cAMhE,0BAAA,gDAA0B,UAAA,CAAA,oBAAA;AAAA,cAK1B,2BAAA,gDAA2B,UAAA,CAAA,qBAAA;AAAA,cAK3B,mBAAA,gDAAmB,UAAA,CAAA,oBAAA,GAAA,qBAAA;;;;AAlBoB;AAAA;cAkDvC,qBAAA,gDAAqB,UAAA;;gDAKhC,MAAA;AAAA;AAAA,cAYW,WAAA,gDAAW,UAAA;;;;YAKtB,MAAA;AAAA;AAAA,cAEW,yBAAA,gDAAyB,UAAA;;;;;;cAQzB,sBAAA,gDAAsB,UAAA;;;;;cAOtB,uBAAA,gDAAuB,UAAA,CAAA,iBAAA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