@prisma-next/sql-contract 0.3.0-dev.131 → 0.3.0-dev.132
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/README.md +4 -9
- package/dist/factories.d.mts +11 -15
- package/dist/factories.d.mts.map +1 -1
- package/dist/factories.mjs +10 -13
- package/dist/factories.mjs.map +1 -1
- package/dist/{types-CB821Pqa.d.mts → types-D6K16_9R.d.mts} +4 -23
- package/dist/types-D6K16_9R.d.mts.map +1 -0
- package/dist/types-DRR5stkj.mjs.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/validate.d.mts +1 -1
- package/dist/validate.d.mts.map +1 -1
- package/dist/validate.mjs +39 -270
- package/dist/validate.mjs.map +1 -1
- package/dist/{validators-CNxeypbZ.mjs → validators-_1sYf-29.mjs} +4 -23
- package/dist/validators-_1sYf-29.mjs.map +1 -0
- package/dist/validators.d.mts +2 -9
- package/dist/validators.d.mts.map +1 -1
- package/dist/validators.mjs +1 -1
- package/package.json +4 -4
- package/src/construct.ts +2 -167
- package/src/exports/types.ts +0 -4
- package/src/factories.ts +24 -40
- package/src/types.ts +3 -28
- package/src/validate.ts +57 -286
- package/src/validators.ts +5 -26
- package/dist/types-CB821Pqa.d.mts.map +0 -1
- package/dist/validators-CNxeypbZ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package provides TypeScript type definitions, Arktype validators, and facto
|
|
|
8
8
|
|
|
9
9
|
## Responsibilities
|
|
10
10
|
|
|
11
|
-
- **SQL Contract Types**: Defines SQL-specific contract types (`SqlContract`, `SqlStorage`, `StorageTable`, `
|
|
11
|
+
- **SQL Contract Types**: Defines SQL-specific contract types (`SqlContract`, `SqlStorage`, `StorageTable`, `SqlModelStorage`, `SqlModelFieldStorage`, `ForeignKeysConfig`) that extend framework-level contract types
|
|
12
12
|
- **Contract Validation**: Provides Arktype-based structural validators and the shared `validateContract` entrypoint for runtime-safe contract validation
|
|
13
13
|
- **IR Factories**: Provides pure factory functions for constructing contract IR structures in tests and authoring
|
|
14
14
|
- **Shared Plane Access**: Enables both migration-plane and runtime-plane packages to import SQL contract types without violating plane boundaries
|
|
@@ -25,7 +25,7 @@ Both `nativeType` and `codecId` are required to ensure contracts are consumable
|
|
|
25
25
|
|
|
26
26
|
## Package Contents
|
|
27
27
|
|
|
28
|
-
- **TypeScript Types**: Type definitions for `SqlContract`, `SqlStorage`, `StorageTable`, `
|
|
28
|
+
- **TypeScript Types**: Type definitions for `SqlContract`, `SqlStorage`, `StorageTable`, `SqlModelStorage`, `SqlModelFieldStorage`, `ForeignKeysConfig`, and related types
|
|
29
29
|
- **Validators**: Arktype-based validators for structural validation of contracts, storage, and models
|
|
30
30
|
- **Factories**: Pure factory functions for constructing contract IR structures in tests and authoring
|
|
31
31
|
|
|
@@ -40,7 +40,7 @@ import type {
|
|
|
40
40
|
SqlContract,
|
|
41
41
|
SqlStorage,
|
|
42
42
|
StorageTable,
|
|
43
|
-
|
|
43
|
+
SqlModelStorage,
|
|
44
44
|
ForeignKeysConfig,
|
|
45
45
|
} from '@prisma-next/sql-contract/types';
|
|
46
46
|
```
|
|
@@ -123,15 +123,10 @@ const contract = validateContract<Contract>(contractJson);
|
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
`validateContract` returns a constructed contract that:
|
|
126
|
-
- Computes runtime-real `mappings` (modelToTable, tableToModel, fieldToColumn, columnToField) from models/storage
|
|
127
126
|
- Strips `_generated` if present on input (emitter metadata is excluded from the returned value)
|
|
127
|
+
- Validates model-to-storage cross-references (table existence, column existence)
|
|
128
128
|
- Does not require execution stack or runtime descriptors
|
|
129
129
|
|
|
130
|
-
Mapping overrides in `contract.mappings` follow strict pair semantics:
|
|
131
|
-
- `modelToTable` and `tableToModel` must either both be omitted (auto-computed) or both be provided as inverse maps.
|
|
132
|
-
- `fieldToColumn` and `columnToField` must either both be omitted (auto-computed) or both be provided as inverse maps.
|
|
133
|
-
- Codec and operation type maps are type-only (phantom channel) and are not present at runtime.
|
|
134
|
-
|
|
135
130
|
### Factories
|
|
136
131
|
|
|
137
132
|
Use factory functions to construct contract IR structures in tests:
|
package/dist/factories.d.mts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as SqlModelStorage, D as StorageColumn, E as SqlStorage, M as UniqueConstraint, O as StorageTable, S as SqlModelFieldStorage, f as Index, l as ForeignKey, m as PrimaryKey, u as ForeignKeyOptions, x as SqlContract } from "./types-D6K16_9R.mjs";
|
|
2
2
|
import { ExecutionHashBase, ProfileHashBase, StorageHashBase } from "@prisma-next/contract/types";
|
|
3
3
|
|
|
4
4
|
//#region src/factories.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates a StorageColumn with nativeType and codecId.
|
|
8
|
-
*
|
|
9
|
-
* @param nativeType - Native database type identifier (e.g., 'int4', 'text', 'vector')
|
|
10
|
-
* @param codecId - Codec identifier (e.g., 'pg/int4@1', 'pg/text@1')
|
|
11
|
-
* @param nullable - Whether the column is nullable (default: false)
|
|
12
|
-
* @returns StorageColumn with nativeType and codecId
|
|
13
|
-
*/
|
|
14
5
|
declare function col(nativeType: string, codecId: string, nullable?: boolean): StorageColumn;
|
|
15
6
|
declare function pk(...columns: readonly string[]): PrimaryKey;
|
|
16
7
|
declare function unique(...columns: readonly string[]): UniqueConstraint;
|
|
@@ -25,16 +16,21 @@ declare function table(columns: Record<string, StorageColumn>, opts?: {
|
|
|
25
16
|
indexes?: readonly Index[];
|
|
26
17
|
fks?: readonly ForeignKey[];
|
|
27
18
|
}): StorageTable;
|
|
28
|
-
declare function model(
|
|
19
|
+
declare function model(tableName: string, fields: Record<string, SqlModelFieldStorage>, relations?: Record<string, unknown>): {
|
|
20
|
+
storage: SqlModelStorage;
|
|
21
|
+
fields: Record<string, {
|
|
22
|
+
nullable: boolean;
|
|
23
|
+
codecId?: string;
|
|
24
|
+
}>;
|
|
25
|
+
relations: Record<string, unknown>;
|
|
26
|
+
};
|
|
29
27
|
declare function storage(tables: Record<string, StorageTable>): SqlStorage;
|
|
30
28
|
declare function contract<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>>(opts: {
|
|
31
29
|
target: string;
|
|
32
30
|
storageHash: TStorageHash;
|
|
33
31
|
executionHash?: TExecutionHash;
|
|
34
32
|
storage: SqlStorage;
|
|
35
|
-
models?: Record<string,
|
|
36
|
-
relations?: Record<string, unknown>;
|
|
37
|
-
mappings?: Partial<SqlMappings>;
|
|
33
|
+
models?: Record<string, unknown>;
|
|
38
34
|
schemaVersion?: '1';
|
|
39
35
|
targetFamily?: 'sql';
|
|
40
36
|
profileHash?: TProfileHash;
|
|
@@ -42,7 +38,7 @@ declare function contract<TStorageHash extends StorageHashBase<string> = Storage
|
|
|
42
38
|
extensionPacks?: Record<string, unknown>;
|
|
43
39
|
meta?: Record<string, unknown>;
|
|
44
40
|
sources?: Record<string, unknown>;
|
|
45
|
-
}): SqlContract<SqlStorage, Record<string, unknown>,
|
|
41
|
+
}): SqlContract<SqlStorage, Record<string, unknown>, TStorageHash, TExecutionHash, TProfileHash>;
|
|
46
42
|
//#endregion
|
|
47
43
|
export { col, contract, fk, index, model, pk, storage, table, unique };
|
|
48
44
|
//# sourceMappingURL=factories.d.mts.map
|
package/dist/factories.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.d.mts","names":[],"sources":["../src/factories.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factories.d.mts","names":[],"sources":["../src/factories.ts"],"sourcesContent":[],"mappings":";;;;iBAqBgB,GAAA,2DAA4D;iBAQ5D,EAAA,iCAAmC;AARnC,iBAcA,MAAA,CAd4D,GAAA,OAAa,EAAA,SAAA,MAAA,EAAA,CAAA,EAclC,gBAdkC;AAQzE,iBAYA,KAAA,CAZmC,GAA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AAA,EAAA,qBA0BI,eA1BJ,CAAA,MAAA,CAAA,GA0B8B,eA1B9B,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,EAAA;EAmBH,MAAA,EAAA,MAAO;EAAwB,WAAA,EAUhC,YAVgC;EAAf,aAAA,CAAA,EAWd,cAXc;EAA+B,OAAA,EAYpD,UAZoD;EAAU,MAAA,CAAA,EAa9D,MAb8D,CAAA,MAAA,EAAA,OAAA,CAAA;EAIzD,aAAQ,CAAA,EAAA,GAAA;EACD,YAAA,CAAA,EAAA,KAAA;EAA0B,WAAA,CAAA,EAWjC,YAXiC;EACxB,YAAA,CAAA,EAWR,MAXQ,CAAA,MAAA,EAWO,MAXP,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAA4B,cAAA,CAAA,EAYlC,MAZkC,CAAA,MAAA,EAAA,OAAA,CAAA;EAC9B,IAAA,CAAA,EAYd,MAZc,CAAA,MAAA,EAAA,OAAA,CAAA;EAA0B,OAAA,CAAA,EAarC,MAbqC,CAAA,MAAA,EAAA,OAAA,CAAA;CAGlC,CAAA,EAWX,WAXW,CAWC,UAXD,EAWa,MAXb,CAAA,MAAA,EAAA,OAAA,CAAA,EAWsC,YAXtC,EAWoD,cAXpD,EAWoE,YAXpE,CAAA"}
|
package/dist/factories.mjs
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { r as applyFkDefaults } from "./types-DRR5stkj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/factories.ts
|
|
4
|
-
/**
|
|
5
|
-
* Creates a StorageColumn with nativeType and codecId.
|
|
6
|
-
*
|
|
7
|
-
* @param nativeType - Native database type identifier (e.g., 'int4', 'text', 'vector')
|
|
8
|
-
* @param codecId - Codec identifier (e.g., 'pg/int4@1', 'pg/text@1')
|
|
9
|
-
* @param nullable - Whether the column is nullable (default: false)
|
|
10
|
-
* @returns StorageColumn with nativeType and codecId
|
|
11
|
-
*/
|
|
12
4
|
function col(nativeType, codecId, nullable = false) {
|
|
13
5
|
return {
|
|
14
6
|
nativeType,
|
|
@@ -50,10 +42,16 @@ function table(columns, opts) {
|
|
|
50
42
|
foreignKeys: opts?.fks ?? []
|
|
51
43
|
};
|
|
52
44
|
}
|
|
53
|
-
function model(
|
|
45
|
+
function model(tableName, fields, relations = {}) {
|
|
54
46
|
return {
|
|
55
|
-
storage: {
|
|
56
|
-
|
|
47
|
+
storage: {
|
|
48
|
+
table: tableName,
|
|
49
|
+
fields
|
|
50
|
+
},
|
|
51
|
+
fields: Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, {
|
|
52
|
+
nullable: field.nullable ?? false,
|
|
53
|
+
...field.codecId !== void 0 ? { codecId: field.codecId } : {}
|
|
54
|
+
}])),
|
|
57
55
|
relations
|
|
58
56
|
};
|
|
59
57
|
}
|
|
@@ -69,8 +67,7 @@ function contract(opts) {
|
|
|
69
67
|
...opts.executionHash !== void 0 && { executionHash: opts.executionHash },
|
|
70
68
|
storage: opts.storage,
|
|
71
69
|
models: opts.models ?? {},
|
|
72
|
-
|
|
73
|
-
mappings: opts.mappings ?? {},
|
|
70
|
+
roots: {},
|
|
74
71
|
...opts.profileHash !== void 0 && { profileHash: opts.profileHash },
|
|
75
72
|
...opts.capabilities !== void 0 && { capabilities: opts.capabilities },
|
|
76
73
|
...opts.extensionPacks !== void 0 && { extensionPacks: opts.extensionPacks },
|
package/dist/factories.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.mjs","names":[],"sources":["../src/factories.ts"],"sourcesContent":["import type {\n ExecutionHashBase,\n ProfileHashBase,\n StorageHashBase,\n} from '@prisma-next/contract/types';\nimport type {\n ForeignKey,\n ForeignKeyOptions,\n ForeignKeyReferences,\n Index,\n
|
|
1
|
+
{"version":3,"file":"factories.mjs","names":[],"sources":["../src/factories.ts"],"sourcesContent":["import type {\n ExecutionHashBase,\n ProfileHashBase,\n StorageHashBase,\n} from '@prisma-next/contract/types';\nimport type {\n ForeignKey,\n ForeignKeyOptions,\n ForeignKeyReferences,\n Index,\n PrimaryKey,\n SqlContract,\n SqlModelFieldStorage,\n SqlModelStorage,\n SqlStorage,\n StorageColumn,\n StorageTable,\n UniqueConstraint,\n} from './types';\nimport { applyFkDefaults } from './types';\n\nexport function col(nativeType: string, codecId: string, nullable = false): StorageColumn {\n return {\n nativeType,\n codecId,\n nullable,\n };\n}\n\nexport function pk(...columns: readonly string[]): PrimaryKey {\n return {\n columns,\n };\n}\n\nexport function unique(...columns: readonly string[]): UniqueConstraint {\n return {\n columns,\n };\n}\n\nexport function index(...columns: readonly string[]): Index {\n return {\n columns,\n };\n}\n\nexport function fk(\n columns: readonly string[],\n refTable: string,\n refColumns: readonly string[],\n opts?: ForeignKeyOptions & { constraint?: boolean; index?: boolean },\n): ForeignKey {\n const references: ForeignKeyReferences = {\n table: refTable,\n columns: refColumns,\n };\n\n return {\n columns,\n references,\n ...(opts?.name !== undefined && { name: opts.name }),\n ...(opts?.onDelete !== undefined && { onDelete: opts.onDelete }),\n ...(opts?.onUpdate !== undefined && { onUpdate: opts.onUpdate }),\n ...applyFkDefaults({ constraint: opts?.constraint, index: opts?.index }),\n };\n}\n\nexport function table(\n columns: Record<string, StorageColumn>,\n opts?: {\n pk?: PrimaryKey;\n uniques?: readonly UniqueConstraint[];\n indexes?: readonly Index[];\n fks?: readonly ForeignKey[];\n },\n): StorageTable {\n return {\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, { nullable: boolean; codecId?: string }>;\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 ...(field.codecId !== undefined ? { codecId: field.codecId } : {}),\n },\n ]),\n ) as Record<string, { nullable: boolean; codecId?: string }>;\n return {\n storage,\n fields: domainFields,\n relations,\n };\n}\n\nexport function storage(tables: Record<string, StorageTable>): SqlStorage {\n return { tables };\n}\n\nexport function contract<\n TStorageHash extends StorageHashBase<string> = StorageHashBase<string>,\n TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>,\n TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>,\n>(opts: {\n target: string;\n storageHash: TStorageHash;\n executionHash?: TExecutionHash;\n storage: SqlStorage;\n models?: Record<string, unknown>;\n schemaVersion?: '1';\n targetFamily?: 'sql';\n profileHash?: TProfileHash;\n capabilities?: Record<string, Record<string, boolean>>;\n extensionPacks?: Record<string, unknown>;\n meta?: Record<string, unknown>;\n sources?: Record<string, unknown>;\n}): SqlContract<SqlStorage, Record<string, unknown>, TStorageHash, TExecutionHash, TProfileHash> {\n return {\n schemaVersion: opts.schemaVersion ?? '1',\n target: opts.target,\n targetFamily: opts.targetFamily ?? 'sql',\n storageHash: opts.storageHash,\n ...(opts.executionHash !== undefined && { executionHash: opts.executionHash }),\n storage: opts.storage,\n models: opts.models ?? {},\n roots: {},\n ...(opts.profileHash !== undefined && { profileHash: opts.profileHash }),\n ...(opts.capabilities !== undefined && { capabilities: opts.capabilities }),\n ...(opts.extensionPacks !== undefined && { extensionPacks: opts.extensionPacks }),\n ...(opts.meta !== undefined && { meta: opts.meta }),\n ...(opts.sources !== undefined && { sources: opts.sources as Record<string, unknown> }),\n } as SqlContract<SqlStorage, Record<string, unknown>, TStorageHash, TExecutionHash, TProfileHash>;\n}\n"],"mappings":";;;AAqBA,SAAgB,IAAI,YAAoB,SAAiB,WAAW,OAAsB;AACxF,QAAO;EACL;EACA;EACA;EACD;;AAGH,SAAgB,GAAG,GAAG,SAAwC;AAC5D,QAAO,EACL,SACD;;AAGH,SAAgB,OAAO,GAAG,SAA8C;AACtE,QAAO,EACL,SACD;;AAGH,SAA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E,aAAa,KAAK,aAAa;EACvE,GAAI,KAAK,iBAAiB,UAAa,EAAE,cAAc,KAAK,cAAc;EAC1E,GAAI,KAAK,mBAAmB,UAAa,EAAE,gBAAgB,KAAK,gBAAgB;EAChF,GAAI,KAAK,SAAS,UAAa,EAAE,MAAM,KAAK,MAAM;EAClD,GAAI,KAAK,YAAY,UAAa,EAAE,SAAS,KAAK,SAAoC;EACvF"}
|
|
@@ -103,18 +103,6 @@ type SqlStorage = {
|
|
|
103
103
|
*/
|
|
104
104
|
readonly types?: Record<string, StorageTypeInstance>;
|
|
105
105
|
};
|
|
106
|
-
type ModelField = {
|
|
107
|
-
readonly column: string;
|
|
108
|
-
};
|
|
109
|
-
type ModelStorage = {
|
|
110
|
-
readonly table: string;
|
|
111
|
-
};
|
|
112
|
-
type ModelDefinition = {
|
|
113
|
-
readonly storage: ModelStorage;
|
|
114
|
-
readonly fields: Record<string, ModelField>;
|
|
115
|
-
readonly relations: Record<string, unknown>;
|
|
116
|
-
readonly owner?: string;
|
|
117
|
-
};
|
|
118
106
|
type SqlModelFieldStorage = {
|
|
119
107
|
readonly column: string;
|
|
120
108
|
readonly codecId?: string;
|
|
@@ -129,12 +117,6 @@ type SqlRelation = {
|
|
|
129
117
|
readonly cardinality: '1:1' | '1:N' | 'N:1';
|
|
130
118
|
readonly on: DomainRelationOn;
|
|
131
119
|
};
|
|
132
|
-
type SqlMappings = {
|
|
133
|
-
readonly modelToTable?: Record<string, string>;
|
|
134
|
-
readonly tableToModel?: Record<string, string>;
|
|
135
|
-
readonly fieldToColumn?: Record<string, Record<string, string>>;
|
|
136
|
-
readonly columnToField?: Record<string, Record<string, string>>;
|
|
137
|
-
};
|
|
138
120
|
declare const DEFAULT_FK_CONSTRAINT = true;
|
|
139
121
|
declare const DEFAULT_FK_INDEX = true;
|
|
140
122
|
declare function applyFkDefaults(fk: {
|
|
@@ -179,11 +161,10 @@ type QueryOperationTypesOf<T> = [T] extends [never] ? Record<string, never> : T
|
|
|
179
161
|
} ? Q extends Record<string, unknown> ? Q : Record<string, never> : Record<string, never>;
|
|
180
162
|
type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';
|
|
181
163
|
type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & { readonly [K in TypeMapsPhantomKey]?: TTypeMaps };
|
|
182
|
-
type SqlContract<S extends SqlStorage = SqlStorage,
|
|
164
|
+
type SqlContract<S extends SqlStorage = SqlStorage, TModels extends Record<string, unknown> = Record<string, unknown>, TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> = Omit<ContractBase<TStorageHash, TExecutionHash, TProfileHash>, 'models'> & {
|
|
183
165
|
readonly targetFamily: string;
|
|
184
166
|
readonly storage: S;
|
|
185
|
-
readonly
|
|
186
|
-
readonly mappings: Map;
|
|
167
|
+
readonly models: TModels;
|
|
187
168
|
readonly execution?: ExecutionSection;
|
|
188
169
|
};
|
|
189
170
|
type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T ? NonNullable<T[TypeMapsPhantomKey & keyof T]> : never;
|
|
@@ -193,5 +174,5 @@ type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromCo
|
|
|
193
174
|
type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
|
|
194
175
|
type ResolveOperationTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractOperationTypes<TContract> : OperationTypesOf<TTypeMaps>;
|
|
195
176
|
//#endregion
|
|
196
|
-
export {
|
|
197
|
-
//# sourceMappingURL=types-
|
|
177
|
+
export { TypeMaps as A, SqlModelStorage as C, StorageColumn as D, SqlStorage as E, UniqueConstraint as M, applyFkDefaults as N, StorageTable as O, SqlModelFieldStorage as S, SqlRelation as T, QueryOperationTypesOf as _, ExtractCodecTypes as a, ResolveOperationTypes as b, ExtractTypeMapsFromContract as c, ForeignKeyReferences as d, Index as f, QueryOperationTypesBase as g, QueryOperationTypeEntry as h, DEFAULT_FK_INDEX as i, TypeMapsPhantomKey as j, StorageTypeInstance as k, ForeignKey as l, PrimaryKey as m, ContractWithTypeMaps as n, ExtractOperationTypes as o, OperationTypesOf as p, DEFAULT_FK_CONSTRAINT as r, ExtractQueryOperationTypes as s, CodecTypesOf as t, ForeignKeyOptions as u, ReferentialAction as v, SqlQueryOperationTypes as w, SqlContract as x, ResolveCodecTypes as y };
|
|
178
|
+
//# sourceMappingURL=types-D6K16_9R.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D6K16_9R.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAiBA;AAsBA;AAKA;AAKA;AAeA;AAKY,KApDA,aAAA,GAoDiB;EAEjB,SAAA,UAAA,EAAiB,MAAA;EAMjB,SAAA,OAAU,EAAA,MAAA;EAEC,SAAA,QAAA,EAAA,OAAA;EAED;;;AAQtB;;EACoB,SAAA,UAAA,CAAA,EAhEI,MAgEJ,CAAA,MAAA,EAAA,OAAA,CAAA;EACI;;;;EAEJ,SAAA,OAAA,CAAA,EAAA,MAAA;EACkB;;;AAatC;EAMY,SAAA,OAAU,CAAA,EA7ED,aA6EC;CACY;AAAf,KA3EP,UAAA,GA2EO;EAKe,SAAA,OAAA,EAAA,SAAA,MAAA,EAAA;EAAf,SAAA,IAAA,CAAA,EAAA,MAAA;CAAM;AAGb,KA9EA,gBAAA,GA8EoB;EAMpB,SAAA,OAAA,EAAe,SAAA,MAEO,EAAA;EAGtB,SAAA,IAAA,CAAW,EAAA,MAAA;AAMvB,CAAA;AACa,KA3FD,KAAA,GA2FC;EAEG,SAAA,OAAA,EAAe,SAAA,MAAA,EAAA;EAUnB,SAAA,IAAQ,CAAA,EAAA,MAAA;EACE;;;;;EAEmC,SAAA,KAAA,CAAA,EAAA,MA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a,4BACP,0BAA0B,8CACrB,0BAA0B,gDACxB,4BAA4B,gDAC9B,0BAA0B,2BAC7C,KAAK,aAAa,cAAc,gBAAgB;;oBAEhC;mBACD;uBACI;;KAGX,iCAAiC,iCAAiC,IAC1E,YAAY,EAAE,2BAA2B;KAGjC,uBAAuB,aAAa,4BAA4B;KAChE,2BAA2B,iBAAiB,4BAA4B;KACxE,gCAAgC,sBAAsB,4BAA4B;KAElF,2CAA2C,6BACnD,kBAAkB,aAClB,aAAa;KAEL,+CAA+C,6BACvD,sBAAsB,aACtB,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-DRR5stkj.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n ColumnDefault,\n ContractBase,\n DomainRelationOn,\n ExecutionHashBase,\n ExecutionSection,\n ProfileHashBase,\n StorageHashBase,\n} from '@prisma-next/contract/types';\n\n/**\n * A column definition in storage.\n *\n * `typeParams` is optional because most columns use non-parameterized types.\n * Columns with parameterized types can either inline `typeParams` or reference\n * a named {@link StorageTypeInstance} via `typeRef`.\n */\nexport type StorageColumn = {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n /**\n * Opaque, codec-owned JS/type parameters.\n * The codec that owns `codecId` defines the shape and semantics.\n * Mutually exclusive with `typeRef`.\n */\n readonly typeParams?: Record<string, unknown>;\n /**\n * Reference to a named type instance in `storage.types`.\n * Mutually exclusive with `typeParams`.\n */\n readonly typeRef?: string;\n /**\n * Default value for the column.\n * Can be a literal value or database function.\n */\n readonly default?: ColumnDefault;\n};\n\nexport type PrimaryKey = {\n readonly columns: readonly string[];\n readonly name?: string;\n};\n\nexport type UniqueConstraint = {\n readonly columns: readonly string[];\n readonly name?: string;\n};\n\nexport type Index = {\n readonly columns: readonly string[];\n readonly name?: string;\n /**\n * Optional access method identifier.\n * Extension-specific methods are represented as strings and interpreted\n * by the owning extension package.\n */\n readonly using?: string;\n /**\n * Optional extension-owned index configuration payload.\n */\n readonly config?: Record<string, unknown>;\n};\n\nexport type ForeignKeyReferences = {\n readonly table: string;\n readonly columns: readonly string[];\n};\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type ForeignKey = {\n readonly columns: readonly string[];\n readonly references: ForeignKeyReferences;\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */\n readonly constraint: boolean;\n /** Whether to emit a backing index for the FK columns. */\n readonly index: boolean;\n};\n\nexport type StorageTable = {\n readonly columns: Record<string, StorageColumn>;\n readonly primaryKey?: PrimaryKey;\n readonly uniques: ReadonlyArray<UniqueConstraint>;\n readonly indexes: ReadonlyArray<Index>;\n readonly foreignKeys: ReadonlyArray<ForeignKey>;\n};\n\n/**\n * A named, parameterized type instance.\n * These are registered in `storage.types` for reuse across columns\n * and to enable ergonomic schema surfaces like `schema.types.MyType`.\n *\n * Unlike {@link StorageColumn}, `typeParams` is required here because\n * `StorageTypeInstance` exists specifically to define reusable parameterized types.\n * A type instance without parameters would be redundant—columns can reference\n * the codec directly via `codecId`.\n */\nexport type StorageTypeInstance = {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n};\n\nexport type SqlStorage = {\n readonly tables: Record<string, StorageTable>;\n /**\n * Named type instances for parameterized/custom types.\n * Columns can reference these via `typeRef`.\n */\n readonly types?: Record<string, StorageTypeInstance>;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"types-DRR5stkj.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n ColumnDefault,\n ContractBase,\n DomainRelationOn,\n ExecutionHashBase,\n ExecutionSection,\n ProfileHashBase,\n StorageHashBase,\n} from '@prisma-next/contract/types';\n\n/**\n * A column definition in storage.\n *\n * `typeParams` is optional because most columns use non-parameterized types.\n * Columns with parameterized types can either inline `typeParams` or reference\n * a named {@link StorageTypeInstance} via `typeRef`.\n */\nexport type StorageColumn = {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n /**\n * Opaque, codec-owned JS/type parameters.\n * The codec that owns `codecId` defines the shape and semantics.\n * Mutually exclusive with `typeRef`.\n */\n readonly typeParams?: Record<string, unknown>;\n /**\n * Reference to a named type instance in `storage.types`.\n * Mutually exclusive with `typeParams`.\n */\n readonly typeRef?: string;\n /**\n * Default value for the column.\n * Can be a literal value or database function.\n */\n readonly default?: ColumnDefault;\n};\n\nexport type PrimaryKey = {\n readonly columns: readonly string[];\n readonly name?: string;\n};\n\nexport type UniqueConstraint = {\n readonly columns: readonly string[];\n readonly name?: string;\n};\n\nexport type Index = {\n readonly columns: readonly string[];\n readonly name?: string;\n /**\n * Optional access method identifier.\n * Extension-specific methods are represented as strings and interpreted\n * by the owning extension package.\n */\n readonly using?: string;\n /**\n * Optional extension-owned index configuration payload.\n */\n readonly config?: Record<string, unknown>;\n};\n\nexport type ForeignKeyReferences = {\n readonly table: string;\n readonly columns: readonly string[];\n};\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type ForeignKey = {\n readonly columns: readonly string[];\n readonly references: ForeignKeyReferences;\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */\n readonly constraint: boolean;\n /** Whether to emit a backing index for the FK columns. */\n readonly index: boolean;\n};\n\nexport type StorageTable = {\n readonly columns: Record<string, StorageColumn>;\n readonly primaryKey?: PrimaryKey;\n readonly uniques: ReadonlyArray<UniqueConstraint>;\n readonly indexes: ReadonlyArray<Index>;\n readonly foreignKeys: ReadonlyArray<ForeignKey>;\n};\n\n/**\n * A named, parameterized type instance.\n * These are registered in `storage.types` for reuse across columns\n * and to enable ergonomic schema surfaces like `schema.types.MyType`.\n *\n * Unlike {@link StorageColumn}, `typeParams` is required here because\n * `StorageTypeInstance` exists specifically to define reusable parameterized types.\n * A type instance without parameters would be redundant—columns can reference\n * the codec directly via `codecId`.\n */\nexport type StorageTypeInstance = {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n};\n\nexport type SqlStorage = {\n readonly tables: Record<string, StorageTable>;\n /**\n * Named type instances for parameterized/custom types.\n * Columns can reference these via `typeRef`.\n */\n readonly types?: Record<string, StorageTypeInstance>;\n};\n\nexport type SqlModelFieldStorage = {\n readonly column: string;\n readonly codecId?: string;\n readonly nullable?: boolean;\n};\n\nexport type SqlModelStorage = {\n readonly table: string;\n readonly fields: Record<string, SqlModelFieldStorage>;\n};\n\nexport type SqlRelation = {\n readonly to: string;\n readonly cardinality: '1:1' | '1:N' | 'N:1';\n readonly on: DomainRelationOn;\n};\n\nexport const DEFAULT_FK_CONSTRAINT = true;\nexport const DEFAULT_FK_INDEX = true;\n\nexport function applyFkDefaults(\n fk: { constraint?: boolean | undefined; index?: boolean | undefined },\n overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },\n): { constraint: boolean; index: boolean } {\n return {\n constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,\n index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,\n };\n}\n\nexport type TypeMaps<\n TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,\n TOperationTypes extends Record<string, unknown> = Record<string, never>,\n TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly operationTypes: TOperationTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n};\n\nexport type CodecTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly codecTypes: infer C }\n ? C extends Record<string, { output: unknown }>\n ? C\n : Record<string, never>\n : Record<string, never>;\n\nexport type OperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly operationTypes: infer O }\n ? O extends Record<string, unknown>\n ? O\n : Record<string, never>\n : Record<string, never>;\n\nexport type QueryOperationTypeEntry = {\n readonly args: readonly { readonly codecId: string; readonly nullable: boolean }[];\n readonly returns: { readonly codecId: string; readonly nullable: boolean };\n};\n\nexport type SqlQueryOperationTypes<T extends Record<string, QueryOperationTypeEntry>> = T;\n\nexport type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;\n\nexport type QueryOperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly queryOperationTypes: infer Q }\n ? Q extends Record<string, unknown>\n ? Q\n : Record<string, never>\n : Record<string, never>;\n\nexport type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';\n\nexport type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {\n readonly [K in TypeMapsPhantomKey]?: TTypeMaps;\n};\n\nexport type SqlContract<\n S extends SqlStorage = SqlStorage,\n TModels extends Record<string, unknown> = Record<string, unknown>,\n TStorageHash extends StorageHashBase<string> = StorageHashBase<string>,\n TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>,\n TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>,\n> = Omit<ContractBase<TStorageHash, TExecutionHash, TProfileHash>, 'models'> & {\n readonly targetFamily: string;\n readonly storage: S;\n readonly models: TModels;\n readonly execution?: ExecutionSection;\n};\n\nexport type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T\n ? NonNullable<T[TypeMapsPhantomKey & keyof T]>\n : never;\n\nexport type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractOperationTypes<T> = OperationTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<TContract>\n : CodecTypesOf<TTypeMaps>;\n\nexport type ResolveOperationTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractOperationTypes<TContract>\n : OperationTypesOf<TTypeMaps>;\n"],"mappings":";AA2IA,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,SAAgB,gBACd,IACA,kBACyC;AACzC,QAAO;EACL,YAAY,GAAG,cAAc,kBAAkB,cAAc;EAC7D,OAAO,GAAG,SAAS,kBAAkB,SAAS;EAC/C"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractOperationTypes, type ExtractQueryOperationTypes, type ExtractTypeMapsFromContract, type ForeignKey, type ForeignKeyOptions, type ForeignKeyReferences, type Index, type
|
|
1
|
+
import { A as TypeMaps, C as SqlModelStorage, D as StorageColumn, E as SqlStorage, M as UniqueConstraint, N as applyFkDefaults, O as StorageTable, S as SqlModelFieldStorage, T as SqlRelation, _ as QueryOperationTypesOf, a as ExtractCodecTypes, b as ResolveOperationTypes, c as ExtractTypeMapsFromContract, d as ForeignKeyReferences, f as Index, g as QueryOperationTypesBase, h as QueryOperationTypeEntry, i as DEFAULT_FK_INDEX, j as TypeMapsPhantomKey, k as StorageTypeInstance, l as ForeignKey, m as PrimaryKey, n as ContractWithTypeMaps, o as ExtractOperationTypes, p as OperationTypesOf, r as DEFAULT_FK_CONSTRAINT, s as ExtractQueryOperationTypes, t as CodecTypesOf, u as ForeignKeyOptions, v as ReferentialAction, w as SqlQueryOperationTypes, x as SqlContract, y as ResolveCodecTypes } from "./types-D6K16_9R.mjs";
|
|
2
|
+
export { type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractOperationTypes, type ExtractQueryOperationTypes, type ExtractTypeMapsFromContract, type ForeignKey, type ForeignKeyOptions, type ForeignKeyReferences, type Index, type OperationTypesOf, type PrimaryKey, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type ResolveOperationTypes, type SqlContract, type SqlModelFieldStorage, type SqlModelStorage, type SqlQueryOperationTypes, type SqlRelation, type SqlStorage, type StorageColumn, type StorageTable, type StorageTypeInstance, type TypeMaps, type TypeMapsPhantomKey, type UniqueConstraint, applyFkDefaults };
|
package/dist/validate.d.mts
CHANGED
package/dist/validate.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.mts","names":[],"sources":["../src/validate.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"validate.d.mts","names":[],"sources":["../src/validate.ts"],"sourcesContent":[],"mappings":";;;;iBAgIgB,cAAA,SAAuB;AAAvB,iBAkCA,sBAlCuB,CAAa,UAkCH,WAlCG,CAkCS,UAlCT,CAAA,CAAA,CAAA,QAAA,EAkCgC,CAlChC,CAAA,EAkCoC,CAlCpC;AAkCpC,iBA+GA,iBAAA,CA/GsB,QAAA,EAAA,OAAA,CAAA,EA+GgB,WA/GhB,CA+G4B,UA/G5B,CAAA;AAAuB,iBAoJ7C,gBApJ6C,CAAA,kBAoJV,WApJU,CAoJE,UApJF,CAAA,CAAA,CAAA,KAAA,EAAA,OAAA,CAAA,EAsJ1D,SAtJ0D"}
|