@prisma-next/contract 0.5.0-dev.6 → 0.5.0-dev.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -12
- package/dist/{contract-types-MYdoYIIh.d.mts → contract-types-Bjujh4Fu.d.mts} +20 -67
- package/dist/contract-types-Bjujh4Fu.d.mts.map +1 -0
- package/dist/hashing.d.mts +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/types-BfYvmUes.mjs +46 -0
- package/dist/types-BfYvmUes.mjs.map +1 -0
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +2 -2
- package/dist/validate-contract.d.mts +1 -1
- package/package.json +5 -4
- package/src/exports/types.ts +9 -5
- package/src/types.ts +64 -63
- package/dist/contract-types-MYdoYIIh.d.mts.map +0 -1
- package/dist/types-aMyNgejf.mjs +0 -14
- package/dist/types-aMyNgejf.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Core contract data types and JSON schemas for Prisma Next.
|
|
|
11
11
|
This package provides the foundational type definitions for Prisma Next data contracts:
|
|
12
12
|
|
|
13
13
|
- **Contract data types**: The canonical description of an application's data model and storage layout (`ContractBase`, `DocumentContract`, `Source`, `FieldType`)
|
|
14
|
-
- **Plan
|
|
14
|
+
- **Plan metadata**: Target-family-agnostic plan metadata (`PlanMeta`). The plan markers themselves (`QueryPlan`, `ExecutionPlan`) live in `@prisma-next/framework-components/runtime`; family-specific plans (`SqlExecutionPlan`, `MongoExecutionPlan`) live in their respective domains. Per [ADR 205](../../../../docs/architecture%20docs/adrs/ADR%20205%20-%20Execution%20metadata%20lives%20on%20AST.md), execution metadata (codec IDs, projection refs, parameter descriptors) lives on the family AST when one is present, not on `PlanMeta`.
|
|
15
15
|
- **Hash types**: Branded hash types for storage, execution, and profile hashing (`StorageHashBase`, `ExecutionHashBase`, `ProfileHashBase`)
|
|
16
16
|
- **JSON Schemas**: Validation schemas for contract files
|
|
17
17
|
- **Type guards**: Runtime type guards for narrowing contract types (`isDocumentContract`)
|
|
@@ -25,7 +25,6 @@ import type {
|
|
|
25
25
|
Contract,
|
|
26
26
|
ContractMarkerRecord,
|
|
27
27
|
DocumentContract,
|
|
28
|
-
ExecutionPlan,
|
|
29
28
|
PlanMeta,
|
|
30
29
|
} from '@prisma-next/contract/types';
|
|
31
30
|
import { isDocumentContract, coreHash, profileHash } from '@prisma-next/contract/types';
|
|
@@ -61,16 +60,6 @@ For SQL contracts, use `@prisma-next/sql-contract-ts/schema-sql` instead.
|
|
|
61
60
|
|
|
62
61
|
## Type System
|
|
63
62
|
|
|
64
|
-
### Plan Types
|
|
65
|
-
|
|
66
|
-
`ParamDescriptor` describes a single parameter in an execution plan:
|
|
67
|
-
|
|
68
|
-
- **`source`**: Origin of the parameter (`'dsl'`, `'raw'`, or `'lane'`)
|
|
69
|
-
- **`index`** (optional): 1-based position into `plan.params`
|
|
70
|
-
- **`name`** (optional): Parameter name for codec resolution
|
|
71
|
-
- **`codecId`**, **`nativeType`**, **`nullable`** (optional): Type metadata from contract
|
|
72
|
-
- **`refs`** (optional): `{ table, column }` when the param is used against a known column
|
|
73
|
-
|
|
74
63
|
### Column Defaults
|
|
75
64
|
|
|
76
65
|
- When adding column defaults, re-emit the contract and verify the emitted JSON includes the full default payload.
|
|
@@ -122,6 +122,15 @@ type JsonValue = JsonPrimitive | {
|
|
|
122
122
|
} | readonly JsonValue[];
|
|
123
123
|
type ColumnDefaultLiteralValue = JsonValue;
|
|
124
124
|
type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;
|
|
125
|
+
/**
|
|
126
|
+
* Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers
|
|
127
|
+
* resolve template values from caller-supplied args (typed `unknown` at the
|
|
128
|
+
* boundary) and need to validate before constructing a `ColumnDefault`.
|
|
129
|
+
* Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`
|
|
130
|
+
* instances. Rejects functions, class instances (other than `Date`),
|
|
131
|
+
* `undefined`, `bigint`, `symbol`, and arrays/objects containing those.
|
|
132
|
+
*/
|
|
133
|
+
declare function isColumnDefaultLiteralInputValue(value: unknown): value is ColumnDefaultLiteralInputValue;
|
|
125
134
|
type ColumnDefault = {
|
|
126
135
|
readonly kind: 'literal';
|
|
127
136
|
readonly value: ColumnDefaultLiteralInputValue;
|
|
@@ -129,11 +138,13 @@ type ColumnDefault = {
|
|
|
129
138
|
readonly kind: 'function';
|
|
130
139
|
readonly expression: string;
|
|
131
140
|
};
|
|
141
|
+
declare function isColumnDefault(value: unknown): value is ColumnDefault;
|
|
132
142
|
type ExecutionMutationDefaultValue = {
|
|
133
143
|
readonly kind: 'generator';
|
|
134
144
|
readonly id: GeneratedValueSpec['id'];
|
|
135
145
|
readonly params?: Record<string, unknown>;
|
|
136
146
|
};
|
|
147
|
+
declare function isExecutionMutationDefaultValue(value: unknown): value is ExecutionMutationDefaultValue;
|
|
137
148
|
type ExecutionMutationDefault = {
|
|
138
149
|
readonly ref: {
|
|
139
150
|
readonly table: string;
|
|
@@ -142,6 +153,11 @@ type ExecutionMutationDefault = {
|
|
|
142
153
|
readonly onCreate?: ExecutionMutationDefaultValue;
|
|
143
154
|
readonly onUpdate?: ExecutionMutationDefaultValue;
|
|
144
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* `ExecutionMutationDefault` minus its `ref` — the per-field phases value
|
|
158
|
+
* authoring layers attach to a column before the column ref is known.
|
|
159
|
+
*/
|
|
160
|
+
type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;
|
|
145
161
|
type ExecutionSection<THash extends string = string> = {
|
|
146
162
|
readonly executionHash: ExecutionHashBase<THash>;
|
|
147
163
|
readonly mutations: {
|
|
@@ -177,30 +193,6 @@ interface DocCollection {
|
|
|
177
193
|
readonly indexes?: ReadonlyArray<DocIndex>;
|
|
178
194
|
readonly readOnly?: boolean;
|
|
179
195
|
}
|
|
180
|
-
interface ParamDescriptor {
|
|
181
|
-
readonly index?: number;
|
|
182
|
-
readonly name?: string;
|
|
183
|
-
readonly codecId?: string;
|
|
184
|
-
readonly nativeType?: string;
|
|
185
|
-
readonly nullable?: boolean;
|
|
186
|
-
readonly source: 'dsl' | 'raw' | 'lane';
|
|
187
|
-
readonly refs?: {
|
|
188
|
-
table: string;
|
|
189
|
-
column: string;
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
interface PlanRefs {
|
|
193
|
-
readonly tables?: readonly string[];
|
|
194
|
-
readonly columns?: ReadonlyArray<{
|
|
195
|
-
table: string;
|
|
196
|
-
column: string;
|
|
197
|
-
}>;
|
|
198
|
-
readonly indexes?: ReadonlyArray<{
|
|
199
|
-
readonly table: string;
|
|
200
|
-
readonly columns: ReadonlyArray<string>;
|
|
201
|
-
readonly name?: string;
|
|
202
|
-
}>;
|
|
203
|
-
}
|
|
204
196
|
interface PlanMeta {
|
|
205
197
|
readonly target: string;
|
|
206
198
|
readonly targetFamily?: string;
|
|
@@ -208,49 +200,9 @@ interface PlanMeta {
|
|
|
208
200
|
readonly profileHash?: string;
|
|
209
201
|
readonly lane: string;
|
|
210
202
|
readonly annotations?: {
|
|
211
|
-
|
|
212
|
-
[key: string]: unknown;
|
|
203
|
+
readonly [key: string]: unknown;
|
|
213
204
|
};
|
|
214
|
-
readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
|
|
215
|
-
readonly refs?: PlanRefs;
|
|
216
|
-
readonly projection?: Record<string, string> | ReadonlyArray<string>;
|
|
217
|
-
/**
|
|
218
|
-
* Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
|
|
219
|
-
* Used for codec resolution when AST+refs don't provide enough type info.
|
|
220
|
-
*/
|
|
221
|
-
readonly projectionTypes?: Record<string, string>;
|
|
222
205
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Canonical execution plan shape used by runtimes.
|
|
225
|
-
*
|
|
226
|
-
* - Row is the inferred result row type (TypeScript-only).
|
|
227
|
-
* - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
|
|
228
|
-
*
|
|
229
|
-
* The payload executed by the runtime is represented by the sql + params pair
|
|
230
|
-
* for now; future families can specialize this via Ast or additional metadata.
|
|
231
|
-
*/
|
|
232
|
-
interface ExecutionPlan<Row = unknown, Ast = unknown> {
|
|
233
|
-
readonly sql: string;
|
|
234
|
-
readonly params: readonly unknown[];
|
|
235
|
-
readonly ast?: Ast;
|
|
236
|
-
readonly meta: PlanMeta;
|
|
237
|
-
/**
|
|
238
|
-
* Phantom property to carry the Row generic for type-level utilities.
|
|
239
|
-
* Not set at runtime; used only for ResultType extraction.
|
|
240
|
-
*/
|
|
241
|
-
readonly _row?: Row;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Utility type to extract the Row type from an ExecutionPlan.
|
|
245
|
-
* Example: `type Row = ResultType<typeof plan>`
|
|
246
|
-
*
|
|
247
|
-
* Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
|
|
248
|
-
* SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
|
|
249
|
-
* for type extraction.
|
|
250
|
-
*/
|
|
251
|
-
type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
|
|
252
|
-
readonly _Row?: infer R;
|
|
253
|
-
} ? R : never;
|
|
254
206
|
/**
|
|
255
207
|
* Contract marker record stored in the database.
|
|
256
208
|
* Represents the current contract identity for a database.
|
|
@@ -263,6 +215,7 @@ interface ContractMarkerRecord {
|
|
|
263
215
|
readonly updatedAt: Date;
|
|
264
216
|
readonly appTag: string | null;
|
|
265
217
|
readonly meta: Record<string, unknown>;
|
|
218
|
+
readonly invariants: readonly string[];
|
|
266
219
|
}
|
|
267
220
|
//#endregion
|
|
268
221
|
//#region src/contract-types.d.ts
|
|
@@ -310,5 +263,5 @@ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends R
|
|
|
310
263
|
readonly meta: Record<string, unknown>;
|
|
311
264
|
}
|
|
312
265
|
//#endregion
|
|
313
|
-
export {
|
|
314
|
-
//# sourceMappingURL=contract-types-
|
|
266
|
+
export { isExecutionMutationDefaultValue as A, ContractRelationOn as B, Source as C, executionHash as D, coreHash as E, ContractFieldType as F, ReferenceRelationKeys as G, ContractVariantEntry as H, ContractModel as I, ValueObjectFieldType as J, ScalarFieldType as K, ContractModelBase as L, ContractDiscriminator as M, ContractEmbedRelation as N, isColumnDefault as O, ContractField as P, ContractReferenceRelation as R, ProfileHashBase as S, StorageHashBase as T, EmbedRelationKeys as U, ContractValueObject as V, ModelStorageBase as W, FieldType as _, ColumnDefault as a, JsonValue as b, ContractMarkerRecord as c, ExecutionHashBase as d, ExecutionMutationDefault as f, Expr as g, ExecutionSection as h, Brand as i, profileHash as j, isColumnDefaultLiteralInputValue as k, DocCollection as l, ExecutionMutationDefaultValue as m, ContractExecutionSection as n, ColumnDefaultLiteralInputValue as o, ExecutionMutationDefaultPhases as p, UnionFieldType as q, $ as r, ColumnDefaultLiteralValue as s, Contract as t, DocIndex as u, GeneratedValueSpec as v, StorageBase as w, PlanMeta as x, JsonPrimitive as y, ContractRelation as z };
|
|
267
|
+
//# sourceMappingURL=contract-types-Bjujh4Fu.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-types-Bjujh4Fu.d.mts","names":[],"sources":["../src/domain-types.ts","../src/types.ts","../src/contract-types.ts"],"sourcesContent":[],"mappings":";KAAY,eAAA;EAAA,SAAA,IAAA,EAAA,QAAe;EAMf,SAAA,OAAA,EAAA,MAAoB;EAKpB,SAAA,UAAc,CAAA,EARF,MAQE,CAAA,MAAA,EAAA,OAAA,CAAA;CAEQ;AAAkB,KAPxC,oBAAA,GAOwC;EAAhC,SAAA,IAAA,EAAA,aAAA;EAAa,SAAA,IAAA,EAAA,MAAA;AAGjC,CAAA;AAAgC,KALpB,cAAA,GAKoB;EAAkB,SAAA,IAAA,EAAA,OAAA;EAAuB,SAAA,OAAA,EAHrD,aAGqD,CAHvC,eAGuC,GAHrB,oB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EtBH,WFsBG,GEtBW,WFsBX,EAAA,gBErBJ,MFqBI,CAAA,MAAA,EErBW,iBFqBX,CAAA,GErBgC,MFqBhC,CAAA,MAAA,EErB+C,iBFqB/C,CAAA,CAAA,CAAA;EAAM,SAAA,MAAA,EAAA,MAAA;EAKX,SAAA,YAAa,EAAA,MAAA;EAAuB,SAAA,KAAA,EEtBnC,MFsBmC,CAAA,MAAA,EAAA,MAAA,CAAA;EAAmB,SAAA,MAAA,EErBrD,OFqBqD;EAC5C,SAAA,YAAA,CAAA,EErBF,MFqBE,CAAA,MAAA,EErBa,mBFqBb,CAAA;EACM,SAAA,OAAA,EErBd,QFqBc;EAAf,SAAA,YAAA,EEpBM,MFoBN,CAAA,MAAA,EEpBqB,MFoBrB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EADT,SAAA,cAAA,EElBiB,MFkBjB,CAAA,MAAA,EAAA,OAAA,CAAA;EAAiB,SAAA,SAAA,CAAA,EEjBJ,wBFiBI;EAMtB,SAAA,WAAA,EEtBmB,eFsBG,CAAA,MAAA,CAAA;EAC4C,SAAA,IAAA,EEtBtD,MFsBsD,CAAA,MAAA,EAAA,OAAA,CAAA"}
|
package/dist/hashing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as ProfileHashBase, T as StorageHashBase, d as ExecutionHashBase, t as Contract } from "./contract-types-Bjujh4Fu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/canonicalization.d.ts
|
|
4
4
|
declare function canonicalizeContractToObject(contract: Contract, options?: {
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as ContractModel, L as ContractModelBase, S as ProfileHashBase, T as StorageHashBase, V as ContractValueObject, W as ModelStorageBase, h as ExecutionSection, t as Contract, w as StorageBase } from "./contract-types-Bjujh4Fu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/testing-factories.d.ts
|
|
4
4
|
type ContractOverrides<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModel>> = {
|
package/dist/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as coreHash } from "./types-
|
|
1
|
+
import { t as coreHash } from "./types-BfYvmUes.mjs";
|
|
2
2
|
import { n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-CyaA_Qvf.mjs";
|
|
3
3
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
4
4
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
function executionHash(value) {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
function coreHash(value) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
function profileHash(value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers
|
|
13
|
+
* resolve template values from caller-supplied args (typed `unknown` at the
|
|
14
|
+
* boundary) and need to validate before constructing a `ColumnDefault`.
|
|
15
|
+
* Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`
|
|
16
|
+
* instances. Rejects functions, class instances (other than `Date`),
|
|
17
|
+
* `undefined`, `bigint`, `symbol`, and arrays/objects containing those.
|
|
18
|
+
*/
|
|
19
|
+
function isColumnDefaultLiteralInputValue(value) {
|
|
20
|
+
if (value === null) return true;
|
|
21
|
+
const t = typeof value;
|
|
22
|
+
if (t === "string" || t === "number" || t === "boolean") return true;
|
|
23
|
+
if (value instanceof Date) return true;
|
|
24
|
+
if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);
|
|
25
|
+
if (t === "object" && Object.getPrototypeOf(value) === Object.prototype) return Object.values(value).every(isColumnDefaultLiteralInputValue);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function isColumnDefault(value) {
|
|
29
|
+
if (typeof value !== "object" || value === null) return false;
|
|
30
|
+
const kind = value.kind;
|
|
31
|
+
if (kind === "literal") return "value" in value;
|
|
32
|
+
if (kind === "function") return typeof value.expression === "string";
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function isExecutionMutationDefaultValue(value) {
|
|
36
|
+
if (typeof value !== "object" || value === null) return false;
|
|
37
|
+
const candidate = value;
|
|
38
|
+
if (candidate.kind !== "generator") return false;
|
|
39
|
+
if (typeof candidate.id !== "string") return false;
|
|
40
|
+
if (candidate.params !== void 0 && (typeof candidate.params !== "object" || candidate.params === null || Array.isArray(candidate.params))) return false;
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { isExecutionMutationDefaultValue as a, isColumnDefaultLiteralInputValue as i, executionHash as n, profileHash as o, isColumnDefault as r, coreHash as t };
|
|
46
|
+
//# sourceMappingURL=types-BfYvmUes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BfYvmUes.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'sha256:abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\n/**\n * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers\n * resolve template values from caller-supplied args (typed `unknown` at the\n * boundary) and need to validate before constructing a `ColumnDefault`.\n * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`\n * instances. Rejects functions, class instances (other than `Date`),\n * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.\n */\nexport function isColumnDefaultLiteralInputValue(\n value: unknown,\n): value is ColumnDefaultLiteralInputValue {\n if (value === null) return true;\n const t = typeof value;\n if (t === 'string' || t === 'number' || t === 'boolean') return true;\n if (value instanceof Date) return true;\n if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);\n if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);\n }\n return false;\n}\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport function isColumnDefault(value: unknown): value is ColumnDefault {\n if (typeof value !== 'object' || value === null) return false;\n const kind = (value as { kind?: unknown }).kind;\n if (kind === 'literal') {\n return 'value' in value;\n }\n if (kind === 'function') {\n return typeof (value as { expression?: unknown }).expression === 'string';\n }\n return false;\n}\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport function isExecutionMutationDefaultValue(\n value: unknown,\n): value is ExecutionMutationDefaultValue {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {\n kind?: unknown;\n id?: unknown;\n params?: unknown;\n };\n if (candidate.kind !== 'generator') return false;\n if (typeof candidate.id !== 'string') return false;\n if (\n candidate.params !== undefined &&\n (typeof candidate.params !== 'object' ||\n candidate.params === null ||\n Array.isArray(candidate.params))\n ) {\n return false;\n }\n return true;\n}\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\n/**\n * `ExecutionMutationDefault` minus its `ref` — the per-field phases value\n * authoring layers attach to a column before the column ref is known.\n */\nexport type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n readonly [key: string]: unknown;\n };\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n readonly invariants: readonly string[];\n}\n"],"mappings":";AA+BA,SAAgB,cAAsC,OAAgC;AACpF,QAAO;;AAGT,SAAgB,SAAiC,OAA8B;AAC7E,QAAO;;AAUT,SAAgB,YAAoC,OAA8B;AAChF,QAAO;;;;;;;;;;AA2CT,SAAgB,iCACd,OACyC;AACzC,KAAI,UAAU,KAAM,QAAO;CAC3B,MAAM,IAAI,OAAO;AACjB,KAAI,MAAM,YAAY,MAAM,YAAY,MAAM,UAAW,QAAO;AAChE,KAAI,iBAAiB,KAAM,QAAO;AAClC,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,MAAM,iCAAiC;AAC9E,KAAI,MAAM,YAAY,OAAO,eAAe,MAAM,KAAK,OAAO,UAC5D,QAAO,OAAO,OAAO,MAAiC,CAAC,MAAM,iCAAiC;AAEhG,QAAO;;AAUT,SAAgB,gBAAgB,OAAwC;AACtE,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,OAAQ,MAA6B;AAC3C,KAAI,SAAS,UACX,QAAO,WAAW;AAEpB,KAAI,SAAS,WACX,QAAO,OAAQ,MAAmC,eAAe;AAEnE,QAAO;;AAST,SAAgB,gCACd,OACwC;AACxC,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,YAAY;AAKlB,KAAI,UAAU,SAAS,YAAa,QAAO;AAC3C,KAAI,OAAO,UAAU,OAAO,SAAU,QAAO;AAC7C,KACE,UAAU,WAAW,WACpB,OAAO,UAAU,WAAW,YAC3B,UAAU,WAAW,QACrB,MAAM,QAAQ,UAAU,OAAO,EAEjC,QAAO;AAET,QAAO"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractValueObject, type ContractVariantEntry, type DocCollection, type DocIndex, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type
|
|
1
|
+
import { A as isExecutionMutationDefaultValue, B as ContractRelationOn, C as Source, D as executionHash, E as coreHash, F as ContractFieldType, G as ReferenceRelationKeys, H as ContractVariantEntry, I as ContractModel, J as ValueObjectFieldType, K as ScalarFieldType, L as ContractModelBase, M as ContractDiscriminator, N as ContractEmbedRelation, O as isColumnDefault, P as ContractField, R as ContractReferenceRelation, S as ProfileHashBase, T as StorageHashBase, U as EmbedRelationKeys, V as ContractValueObject, W as ModelStorageBase, _ as FieldType, a as ColumnDefault, b as JsonValue, c as ContractMarkerRecord, d as ExecutionHashBase, f as ExecutionMutationDefault, g as Expr, h as ExecutionSection, i as Brand, j as profileHash, k as isColumnDefaultLiteralInputValue, l as DocCollection, m as ExecutionMutationDefaultValue, n as ContractExecutionSection, o as ColumnDefaultLiteralInputValue, p as ExecutionMutationDefaultPhases, q as UnionFieldType, r as $, s as ColumnDefaultLiteralValue, t as Contract, u as DocIndex, v as GeneratedValueSpec, w as StorageBase, x as PlanMeta, y as JsonPrimitive, z as ContractRelation } from "./contract-types-Bjujh4Fu.mjs";
|
|
2
|
+
export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractValueObject, type ContractVariantEntry, type DocCollection, type DocIndex, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultPhases, type ExecutionMutationDefaultValue, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ModelStorageBase, type PlanMeta, type ProfileHashBase, type ReferenceRelationKeys, type ScalarFieldType, type Source, type StorageBase, type StorageHashBase, type UnionFieldType, type ValueObjectFieldType, coreHash, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash };
|
package/dist/types.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as executionHash,
|
|
1
|
+
import { a as isExecutionMutationDefaultValue, i as isColumnDefaultLiteralInputValue, n as executionHash, o as profileHash, r as isColumnDefault, t as coreHash } from "./types-BfYvmUes.mjs";
|
|
2
2
|
|
|
3
|
-
export { coreHash, executionHash, profileHash };
|
|
3
|
+
export { coreHash, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash };
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/contract",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.60",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"description": "Data contract type definitions and JSON schema for Prisma Next",
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"arktype": "^2.1.29",
|
|
9
|
-
"@prisma-next/utils": "0.5.0-dev.
|
|
10
|
+
"@prisma-next/utils": "0.5.0-dev.60"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"tsdown": "0.18.4",
|
|
13
14
|
"typescript": "5.9.3",
|
|
14
15
|
"vitest": "4.0.17",
|
|
15
16
|
"@prisma-next/test-utils": "0.0.1",
|
|
16
|
-
"@prisma-next/
|
|
17
|
-
"@prisma-next/
|
|
17
|
+
"@prisma-next/tsdown": "0.0.0",
|
|
18
|
+
"@prisma-next/tsconfig": "0.0.0"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
21
|
"dist",
|
package/src/exports/types.ts
CHANGED
|
@@ -29,21 +29,25 @@ export type {
|
|
|
29
29
|
DocIndex,
|
|
30
30
|
ExecutionHashBase,
|
|
31
31
|
ExecutionMutationDefault,
|
|
32
|
+
ExecutionMutationDefaultPhases,
|
|
32
33
|
ExecutionMutationDefaultValue,
|
|
33
|
-
ExecutionPlan,
|
|
34
34
|
ExecutionSection,
|
|
35
35
|
Expr,
|
|
36
36
|
FieldType,
|
|
37
37
|
GeneratedValueSpec,
|
|
38
38
|
JsonPrimitive,
|
|
39
39
|
JsonValue,
|
|
40
|
-
ParamDescriptor,
|
|
41
40
|
PlanMeta,
|
|
42
|
-
PlanRefs,
|
|
43
41
|
ProfileHashBase,
|
|
44
|
-
ResultType,
|
|
45
42
|
Source,
|
|
46
43
|
StorageBase,
|
|
47
44
|
StorageHashBase,
|
|
48
45
|
} from '../types';
|
|
49
|
-
export {
|
|
46
|
+
export {
|
|
47
|
+
coreHash,
|
|
48
|
+
executionHash,
|
|
49
|
+
isColumnDefault,
|
|
50
|
+
isColumnDefaultLiteralInputValue,
|
|
51
|
+
isExecutionMutationDefaultValue,
|
|
52
|
+
profileHash,
|
|
53
|
+
} from '../types';
|
package/src/types.ts
CHANGED
|
@@ -80,6 +80,28 @@ export type ColumnDefaultLiteralValue = JsonValue;
|
|
|
80
80
|
|
|
81
81
|
export type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers
|
|
85
|
+
* resolve template values from caller-supplied args (typed `unknown` at the
|
|
86
|
+
* boundary) and need to validate before constructing a `ColumnDefault`.
|
|
87
|
+
* Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`
|
|
88
|
+
* instances. Rejects functions, class instances (other than `Date`),
|
|
89
|
+
* `undefined`, `bigint`, `symbol`, and arrays/objects containing those.
|
|
90
|
+
*/
|
|
91
|
+
export function isColumnDefaultLiteralInputValue(
|
|
92
|
+
value: unknown,
|
|
93
|
+
): value is ColumnDefaultLiteralInputValue {
|
|
94
|
+
if (value === null) return true;
|
|
95
|
+
const t = typeof value;
|
|
96
|
+
if (t === 'string' || t === 'number' || t === 'boolean') return true;
|
|
97
|
+
if (value instanceof Date) return true;
|
|
98
|
+
if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);
|
|
99
|
+
if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {
|
|
100
|
+
return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
83
105
|
export type ColumnDefault =
|
|
84
106
|
| {
|
|
85
107
|
readonly kind: 'literal';
|
|
@@ -87,18 +109,58 @@ export type ColumnDefault =
|
|
|
87
109
|
}
|
|
88
110
|
| { readonly kind: 'function'; readonly expression: string };
|
|
89
111
|
|
|
112
|
+
export function isColumnDefault(value: unknown): value is ColumnDefault {
|
|
113
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
114
|
+
const kind = (value as { kind?: unknown }).kind;
|
|
115
|
+
if (kind === 'literal') {
|
|
116
|
+
return 'value' in value;
|
|
117
|
+
}
|
|
118
|
+
if (kind === 'function') {
|
|
119
|
+
return typeof (value as { expression?: unknown }).expression === 'string';
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
90
124
|
export type ExecutionMutationDefaultValue = {
|
|
91
125
|
readonly kind: 'generator';
|
|
92
126
|
readonly id: GeneratedValueSpec['id'];
|
|
93
127
|
readonly params?: Record<string, unknown>;
|
|
94
128
|
};
|
|
95
129
|
|
|
130
|
+
export function isExecutionMutationDefaultValue(
|
|
131
|
+
value: unknown,
|
|
132
|
+
): value is ExecutionMutationDefaultValue {
|
|
133
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
134
|
+
const candidate = value as {
|
|
135
|
+
kind?: unknown;
|
|
136
|
+
id?: unknown;
|
|
137
|
+
params?: unknown;
|
|
138
|
+
};
|
|
139
|
+
if (candidate.kind !== 'generator') return false;
|
|
140
|
+
if (typeof candidate.id !== 'string') return false;
|
|
141
|
+
if (
|
|
142
|
+
candidate.params !== undefined &&
|
|
143
|
+
(typeof candidate.params !== 'object' ||
|
|
144
|
+
candidate.params === null ||
|
|
145
|
+
Array.isArray(candidate.params))
|
|
146
|
+
) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
|
|
96
152
|
export type ExecutionMutationDefault = {
|
|
97
153
|
readonly ref: { readonly table: string; readonly column: string };
|
|
98
154
|
readonly onCreate?: ExecutionMutationDefaultValue;
|
|
99
155
|
readonly onUpdate?: ExecutionMutationDefaultValue;
|
|
100
156
|
};
|
|
101
157
|
|
|
158
|
+
/**
|
|
159
|
+
* `ExecutionMutationDefault` minus its `ref` — the per-field phases value
|
|
160
|
+
* authoring layers attach to a column before the column ref is known.
|
|
161
|
+
*/
|
|
162
|
+
export type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;
|
|
163
|
+
|
|
102
164
|
export type ExecutionSection<THash extends string = string> = {
|
|
103
165
|
readonly executionHash: ExecutionHashBase<THash>;
|
|
104
166
|
readonly mutations: {
|
|
@@ -135,27 +197,6 @@ export interface DocCollection {
|
|
|
135
197
|
readonly readOnly?: boolean;
|
|
136
198
|
}
|
|
137
199
|
|
|
138
|
-
// Plan types - target-family agnostic execution types
|
|
139
|
-
export interface ParamDescriptor {
|
|
140
|
-
readonly index?: number;
|
|
141
|
-
readonly name?: string;
|
|
142
|
-
readonly codecId?: string;
|
|
143
|
-
readonly nativeType?: string;
|
|
144
|
-
readonly nullable?: boolean;
|
|
145
|
-
readonly source: 'dsl' | 'raw' | 'lane';
|
|
146
|
-
readonly refs?: { table: string; column: string };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface PlanRefs {
|
|
150
|
-
readonly tables?: readonly string[];
|
|
151
|
-
readonly columns?: ReadonlyArray<{ table: string; column: string }>;
|
|
152
|
-
readonly indexes?: ReadonlyArray<{
|
|
153
|
-
readonly table: string;
|
|
154
|
-
readonly columns: ReadonlyArray<string>;
|
|
155
|
-
readonly name?: string;
|
|
156
|
-
}>;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
200
|
export interface PlanMeta {
|
|
160
201
|
readonly target: string;
|
|
161
202
|
readonly targetFamily?: string;
|
|
@@ -163,51 +204,10 @@ export interface PlanMeta {
|
|
|
163
204
|
readonly profileHash?: string;
|
|
164
205
|
readonly lane: string;
|
|
165
206
|
readonly annotations?: {
|
|
166
|
-
|
|
167
|
-
[key: string]: unknown;
|
|
207
|
+
readonly [key: string]: unknown;
|
|
168
208
|
};
|
|
169
|
-
readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
|
|
170
|
-
readonly refs?: PlanRefs;
|
|
171
|
-
readonly projection?: Record<string, string> | ReadonlyArray<string>;
|
|
172
|
-
/**
|
|
173
|
-
* Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
|
|
174
|
-
* Used for codec resolution when AST+refs don't provide enough type info.
|
|
175
|
-
*/
|
|
176
|
-
readonly projectionTypes?: Record<string, string>;
|
|
177
209
|
}
|
|
178
210
|
|
|
179
|
-
/**
|
|
180
|
-
* Canonical execution plan shape used by runtimes.
|
|
181
|
-
*
|
|
182
|
-
* - Row is the inferred result row type (TypeScript-only).
|
|
183
|
-
* - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
|
|
184
|
-
*
|
|
185
|
-
* The payload executed by the runtime is represented by the sql + params pair
|
|
186
|
-
* for now; future families can specialize this via Ast or additional metadata.
|
|
187
|
-
*/
|
|
188
|
-
export interface ExecutionPlan<Row = unknown, Ast = unknown> {
|
|
189
|
-
readonly sql: string;
|
|
190
|
-
readonly params: readonly unknown[];
|
|
191
|
-
readonly ast?: Ast;
|
|
192
|
-
readonly meta: PlanMeta;
|
|
193
|
-
/**
|
|
194
|
-
* Phantom property to carry the Row generic for type-level utilities.
|
|
195
|
-
* Not set at runtime; used only for ResultType extraction.
|
|
196
|
-
*/
|
|
197
|
-
readonly _row?: Row;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Utility type to extract the Row type from an ExecutionPlan.
|
|
202
|
-
* Example: `type Row = ResultType<typeof plan>`
|
|
203
|
-
*
|
|
204
|
-
* Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
|
|
205
|
-
* SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
|
|
206
|
-
* for type extraction.
|
|
207
|
-
*/
|
|
208
|
-
export type ResultType<P> =
|
|
209
|
-
P extends ExecutionPlan<infer R, unknown> ? R : P extends { readonly _Row?: infer R } ? R : never;
|
|
210
|
-
|
|
211
211
|
/**
|
|
212
212
|
* Contract marker record stored in the database.
|
|
213
213
|
* Represents the current contract identity for a database.
|
|
@@ -220,4 +220,5 @@ export interface ContractMarkerRecord {
|
|
|
220
220
|
readonly updatedAt: Date;
|
|
221
221
|
readonly appTag: string | null;
|
|
222
222
|
readonly meta: Record<string, unknown>;
|
|
223
|
+
readonly invariants: readonly string[];
|
|
223
224
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-types-MYdoYIIh.d.mts","names":[],"sources":["../src/domain-types.ts","../src/types.ts","../src/contract-types.ts"],"sourcesContent":[],"mappings":";KAAY,eAAA;EAAA,SAAA,IAAA,EAAA,QAAe;EAMf,SAAA,OAAA,EAAA,MAAoB;EAKpB,SAAA,UAAc,CAAA,EARF,MAQE,CAAA,MAAA,EAAA,OAAA,CAAA;CAEQ;AAAkB,KAPxC,oBAAA,GAOwC;EAAhC,SAAA,IAAA,EAAA,aAAA;EAAa,SAAA,IAAA,EAAA,MAAA;AAGjC,CAAA;AAAgC,KALpB,cAAA,GAKoB;EAAkB,SAAA,IAAA,EAAA,OAAA;EAAuB,SAAA,OAAA,EAHrD,aAGqD,CAHvC,eAGuC,GAHrB,oBAGqB,CAAA;CAAc;AAE3E,KAFA,iBAAA,GAAoB,eAIf,GAJiC,oBAIhB,GAJuC,cAIvC;AAKtB,KAPA,aAAA,GAOkB;EAKlB,SAAA,QAAA,EAAA,OAAA;EAMA,SAAA,IAAA,EAhBK,iBAgBgB;EAKrB,SAAA,IAAA,CAAA,EAAA,IAAgB;EAEhB,SAAA,IAAA,CAAA,EAAA,IAAA;AAIZ,CAAA;AAIY,KA1BA,kBAAA,GA0BmB;EAInB,SAAA,WAAgB,EAAA,SAAY,MAAA,EAAT;EAEd,SAAA,YAAiB,EAAA,SAAA,MAAA,EAAA;CAAuB;AAAmB,KA3BhE,yBAAA,GA2BgE;EAC1C,SAAA,EAAA,EAAA,MAAA;EAAf,SAAA,WAAA,EAAA,KAAA,GAAA,KAAA,GAAA,KAAA;EACkB,SAAA,EAAA,EA1BtB,kBA0BsB;CAAf;AACF,KAxBR,qBAAA,GAwBQ;EACO,SAAA,EAAA,EAAA,MAA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
|
-
function profileHash(value) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { executionHash as n, profileHash as r, coreHash as t };
|
|
14
|
-
//# sourceMappingURL=types-aMyNgejf.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-aMyNgejf.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'sha256:abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\n// Plan types - target-family agnostic execution types\nexport interface ParamDescriptor {\n readonly index?: number;\n readonly name?: string;\n readonly codecId?: string;\n readonly nativeType?: string;\n readonly nullable?: boolean;\n readonly source: 'dsl' | 'raw' | 'lane';\n readonly refs?: { table: string; column: string };\n}\n\nexport interface PlanRefs {\n readonly tables?: readonly string[];\n readonly columns?: ReadonlyArray<{ table: string; column: string }>;\n readonly indexes?: ReadonlyArray<{\n readonly table: string;\n readonly columns: ReadonlyArray<string>;\n readonly name?: string;\n }>;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n codecs?: Record<string, string>; // alias/param → codec id ('ns/name@v')\n [key: string]: unknown;\n };\n readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;\n readonly refs?: PlanRefs;\n readonly projection?: Record<string, string> | ReadonlyArray<string>;\n /**\n * Optional mapping of projection alias → column type ID (fully qualified ns/name@version).\n * Used for codec resolution when AST+refs don't provide enough type info.\n */\n readonly projectionTypes?: Record<string, string>;\n}\n\n/**\n * Canonical execution plan shape used by runtimes.\n *\n * - Row is the inferred result row type (TypeScript-only).\n * - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).\n *\n * The payload executed by the runtime is represented by the sql + params pair\n * for now; future families can specialize this via Ast or additional metadata.\n */\nexport interface ExecutionPlan<Row = unknown, Ast = unknown> {\n readonly sql: string;\n readonly params: readonly unknown[];\n readonly ast?: Ast;\n readonly meta: PlanMeta;\n /**\n * Phantom property to carry the Row generic for type-level utilities.\n * Not set at runtime; used only for ResultType extraction.\n */\n readonly _row?: Row;\n}\n\n/**\n * Utility type to extract the Row type from an ExecutionPlan.\n * Example: `type Row = ResultType<typeof plan>`\n *\n * Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).\n * SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter\n * for type extraction.\n */\nexport type ResultType<P> =\n P extends ExecutionPlan<infer R, unknown> ? R : P extends { readonly _Row?: infer R } ? R : never;\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n}\n"],"mappings":";AA+BA,SAAgB,cAAsC,OAAgC;AACpF,QAAO;;AAGT,SAAgB,SAAiC,OAA8B;AAC7E,QAAO;;AAUT,SAAgB,YAAoC,OAA8B;AAChF,QAAO"}
|