@prisma-next/contract 0.3.0-dev.14 → 0.3.0-dev.141
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/LICENSE +201 -0
- package/README.md +43 -254
- package/dist/contract-types-x89nqTli.d.mts +49 -0
- package/dist/contract-types-x89nqTli.d.mts.map +1 -0
- package/dist/hashing-D1EPxYRl.mjs +215 -0
- package/dist/hashing-D1EPxYRl.mjs.map +1 -0
- package/dist/hashing.d.mts +38 -0
- package/dist/hashing.d.mts.map +1 -0
- package/dist/hashing.mjs +3 -0
- package/dist/testing.d.mts +29 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +56 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-DYikGC04.mjs +33 -0
- package/dist/types-DYikGC04.mjs.map +1 -0
- package/dist/types-DmKtoEd-.d.mts +303 -0
- package/dist/types-DmKtoEd-.d.mts.map +1 -0
- package/dist/types.d.mts +3 -0
- package/dist/types.mjs +3 -0
- package/dist/validate-contract.d.mts +35 -0
- package/dist/validate-contract.d.mts.map +1 -0
- package/dist/validate-contract.mjs +61 -0
- package/dist/validate-contract.mjs.map +1 -0
- package/dist/validate-domain-CTQiBiei.mjs +84 -0
- package/dist/validate-domain-CTQiBiei.mjs.map +1 -0
- package/dist/validate-domain.d.mts +24 -0
- package/dist/validate-domain.d.mts.map +1 -0
- package/dist/validate-domain.mjs +3 -0
- package/package.json +24 -25
- package/schemas/data-contract-document-v1.json +5 -5
- package/src/canonicalization.ts +286 -0
- package/src/contract-types.ts +54 -0
- package/src/domain-types.ts +85 -0
- package/src/exports/hashing.ts +6 -0
- package/src/exports/testing.ts +1 -0
- package/src/exports/types.ts +49 -10
- package/src/exports/validate-contract.ts +5 -0
- package/src/exports/validate-domain.ts +6 -0
- package/src/hashing.ts +69 -0
- package/src/testing-factories.ts +93 -0
- package/src/types.ts +153 -91
- package/src/validate-contract.ts +93 -0
- package/src/validate-domain.ts +205 -0
- package/dist/exports/framework-components.d.ts +0 -3
- package/dist/exports/framework-components.d.ts.map +0 -1
- package/dist/exports/framework-components.js +0 -24
- package/dist/exports/framework-components.js.map +0 -1
- package/dist/exports/ir.d.ts +0 -2
- package/dist/exports/ir.d.ts.map +0 -1
- package/dist/exports/ir.js +0 -35
- package/dist/exports/ir.js.map +0 -1
- package/dist/exports/pack-manifest-types.d.ts +0 -2
- package/dist/exports/pack-manifest-types.d.ts.map +0 -1
- package/dist/exports/pack-manifest-types.js +0 -1
- package/dist/exports/pack-manifest-types.js.map +0 -1
- package/dist/exports/types.d.ts +0 -3
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -8
- package/dist/exports/types.js.map +0 -1
- package/dist/framework-components.d.ts +0 -408
- package/dist/framework-components.d.ts.map +0 -1
- package/dist/ir.d.ts +0 -76
- package/dist/ir.d.ts.map +0 -1
- package/dist/types.d.ts +0 -222
- package/dist/types.d.ts.map +0 -1
- package/src/exports/framework-components.ts +0 -26
- package/src/exports/ir.ts +0 -1
- package/src/exports/pack-manifest-types.ts +0 -6
- package/src/framework-components.ts +0 -525
- package/src/ir.ts +0 -113
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
//#region src/domain-types.d.ts
|
|
2
|
+
type ContractField = {
|
|
3
|
+
readonly nullable: boolean;
|
|
4
|
+
readonly codecId: string;
|
|
5
|
+
};
|
|
6
|
+
type ContractRelationOn = {
|
|
7
|
+
readonly localFields: readonly string[];
|
|
8
|
+
readonly targetFields: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
type ContractReferenceRelation = {
|
|
11
|
+
readonly to: string;
|
|
12
|
+
readonly cardinality: '1:1' | '1:N' | 'N:1';
|
|
13
|
+
readonly on: ContractRelationOn;
|
|
14
|
+
};
|
|
15
|
+
type ContractEmbedRelation = {
|
|
16
|
+
readonly to: string;
|
|
17
|
+
readonly cardinality: '1:1' | '1:N';
|
|
18
|
+
};
|
|
19
|
+
type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
|
|
20
|
+
type ContractDiscriminator = {
|
|
21
|
+
readonly field: string;
|
|
22
|
+
};
|
|
23
|
+
type ContractVariantEntry = {
|
|
24
|
+
readonly value: string;
|
|
25
|
+
};
|
|
26
|
+
type ModelStorageBase = Readonly<Record<string, unknown>>;
|
|
27
|
+
interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> {
|
|
28
|
+
readonly fields: Record<string, ContractField>;
|
|
29
|
+
readonly relations: Record<string, ContractRelation>;
|
|
30
|
+
readonly storage: TModelStorage;
|
|
31
|
+
readonly discriminator?: ContractDiscriminator;
|
|
32
|
+
readonly variants?: Record<string, ContractVariantEntry>;
|
|
33
|
+
readonly base?: string;
|
|
34
|
+
readonly owner?: string;
|
|
35
|
+
}
|
|
36
|
+
/** @deprecated Use {@link ContractField} */
|
|
37
|
+
type DomainField = ContractField;
|
|
38
|
+
/** @deprecated Use {@link ContractRelationOn} */
|
|
39
|
+
type DomainRelationOn = ContractRelationOn;
|
|
40
|
+
/** @deprecated Use {@link ContractReferenceRelation} */
|
|
41
|
+
type DomainReferenceRelation = ContractReferenceRelation;
|
|
42
|
+
/** @deprecated Use {@link ContractEmbedRelation} */
|
|
43
|
+
type DomainEmbedRelation = ContractEmbedRelation;
|
|
44
|
+
/** @deprecated Use {@link ContractRelation} */
|
|
45
|
+
type DomainRelation = ContractRelation;
|
|
46
|
+
/** @deprecated Use {@link ContractDiscriminator} */
|
|
47
|
+
type DomainDiscriminator = ContractDiscriminator;
|
|
48
|
+
/** @deprecated Use {@link ContractVariantEntry} */
|
|
49
|
+
type DomainVariantEntry = ContractVariantEntry;
|
|
50
|
+
/** @deprecated Use {@link ContractModel} */
|
|
51
|
+
type DomainModel = ContractModel;
|
|
52
|
+
type HasModelsWithRelations = {
|
|
53
|
+
readonly models: Record<string, {
|
|
54
|
+
readonly relations: Record<string, ContractRelation>;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
type ReferenceRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TContract['models'][ModelName]['relations']];
|
|
58
|
+
type EmbedRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TContract['models'][ModelName]['relations']];
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/types.d.ts
|
|
61
|
+
/**
|
|
62
|
+
* Unique symbol used as the key for branding types.
|
|
63
|
+
*/
|
|
64
|
+
declare const $: unique symbol;
|
|
65
|
+
/**
|
|
66
|
+
* A helper type to brand a given type with a unique identifier.
|
|
67
|
+
*
|
|
68
|
+
* @template TKey Text used as the brand key.
|
|
69
|
+
* @template TValue Optional value associated with the brand key. Defaults to `true`.
|
|
70
|
+
*/
|
|
71
|
+
type Brand<TKey extends string | number | symbol, TValue = true> = {
|
|
72
|
+
[$]: { [K in TKey]: TValue };
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Base type for storage contract hashes.
|
|
76
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
77
|
+
* `type StorageHash = StorageHashBase<'sha256:abc123...'>`
|
|
78
|
+
*/
|
|
79
|
+
type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;
|
|
80
|
+
/**
|
|
81
|
+
* Base type for execution contract hashes.
|
|
82
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
83
|
+
* `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`
|
|
84
|
+
*/
|
|
85
|
+
type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;
|
|
86
|
+
declare function executionHash<const T extends string>(value: T): ExecutionHashBase<T>;
|
|
87
|
+
declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Base type for profile contract hashes.
|
|
90
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
91
|
+
* `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
|
|
92
|
+
*/
|
|
93
|
+
type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
|
|
94
|
+
declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Base type for family-specific storage blocks.
|
|
97
|
+
* Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
|
|
98
|
+
* storage hash alongside family-specific data (tables, collections, etc.).
|
|
99
|
+
*/
|
|
100
|
+
interface StorageBase<THash extends string = string> {
|
|
101
|
+
readonly storageHash: StorageHashBase<THash>;
|
|
102
|
+
}
|
|
103
|
+
interface ContractBase<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> {
|
|
104
|
+
readonly schemaVersion: string;
|
|
105
|
+
readonly target: string;
|
|
106
|
+
readonly targetFamily: string;
|
|
107
|
+
readonly storageHash: TStorageHash;
|
|
108
|
+
readonly executionHash?: TExecutionHash | undefined;
|
|
109
|
+
readonly profileHash?: TProfileHash | undefined;
|
|
110
|
+
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
111
|
+
readonly extensionPacks: Record<string, unknown>;
|
|
112
|
+
readonly meta: Record<string, unknown>;
|
|
113
|
+
readonly sources: Record<string, Source>;
|
|
114
|
+
readonly execution?: ExecutionSection;
|
|
115
|
+
readonly roots: Record<string, string>;
|
|
116
|
+
readonly models: Record<string, DomainModel>;
|
|
117
|
+
}
|
|
118
|
+
interface FieldType {
|
|
119
|
+
readonly type: string;
|
|
120
|
+
readonly nullable: boolean;
|
|
121
|
+
readonly items?: FieldType;
|
|
122
|
+
readonly properties?: Record<string, FieldType>;
|
|
123
|
+
}
|
|
124
|
+
type GeneratedValueSpec = {
|
|
125
|
+
readonly id: string;
|
|
126
|
+
readonly params?: Record<string, unknown>;
|
|
127
|
+
};
|
|
128
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
129
|
+
type JsonValue = JsonPrimitive | {
|
|
130
|
+
readonly [key: string]: JsonValue;
|
|
131
|
+
} | readonly JsonValue[];
|
|
132
|
+
type TaggedBigInt = {
|
|
133
|
+
readonly $type: 'bigint';
|
|
134
|
+
readonly value: string;
|
|
135
|
+
};
|
|
136
|
+
declare function isTaggedBigInt(value: unknown): value is TaggedBigInt;
|
|
137
|
+
declare function bigintJsonReplacer(_key: string, value: unknown): unknown;
|
|
138
|
+
type TaggedRaw = {
|
|
139
|
+
readonly $type: 'raw';
|
|
140
|
+
readonly value: JsonValue;
|
|
141
|
+
};
|
|
142
|
+
declare function isTaggedRaw(value: unknown): value is TaggedRaw;
|
|
143
|
+
type TaggedLiteralValue = TaggedBigInt | TaggedRaw;
|
|
144
|
+
type ColumnDefaultLiteralValue = JsonValue | TaggedLiteralValue;
|
|
145
|
+
type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | bigint | Date;
|
|
146
|
+
type ColumnDefault = {
|
|
147
|
+
readonly kind: 'literal';
|
|
148
|
+
readonly value: ColumnDefaultLiteralInputValue;
|
|
149
|
+
} | {
|
|
150
|
+
readonly kind: 'function';
|
|
151
|
+
readonly expression: string;
|
|
152
|
+
};
|
|
153
|
+
type ExecutionMutationDefaultValue = {
|
|
154
|
+
readonly kind: 'generator';
|
|
155
|
+
readonly id: GeneratedValueSpec['id'];
|
|
156
|
+
readonly params?: Record<string, unknown>;
|
|
157
|
+
};
|
|
158
|
+
type ExecutionMutationDefault = {
|
|
159
|
+
readonly ref: {
|
|
160
|
+
readonly table: string;
|
|
161
|
+
readonly column: string;
|
|
162
|
+
};
|
|
163
|
+
readonly onCreate?: ExecutionMutationDefaultValue;
|
|
164
|
+
readonly onUpdate?: ExecutionMutationDefaultValue;
|
|
165
|
+
};
|
|
166
|
+
type ExecutionSection<THash extends string = string> = {
|
|
167
|
+
readonly executionHash: ExecutionHashBase<THash>;
|
|
168
|
+
readonly mutations: {
|
|
169
|
+
readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
interface Source {
|
|
173
|
+
readonly readOnly: boolean;
|
|
174
|
+
readonly projection: Record<string, FieldType>;
|
|
175
|
+
readonly origin?: Record<string, unknown>;
|
|
176
|
+
readonly capabilities?: Record<string, boolean>;
|
|
177
|
+
}
|
|
178
|
+
interface DocIndex {
|
|
179
|
+
readonly name: string;
|
|
180
|
+
readonly keys: Record<string, 'asc' | 'desc'>;
|
|
181
|
+
readonly unique?: boolean;
|
|
182
|
+
readonly where?: Expr;
|
|
183
|
+
}
|
|
184
|
+
type Expr = {
|
|
185
|
+
readonly kind: 'eq';
|
|
186
|
+
readonly path: ReadonlyArray<string>;
|
|
187
|
+
readonly value: unknown;
|
|
188
|
+
} | {
|
|
189
|
+
readonly kind: 'exists';
|
|
190
|
+
readonly path: ReadonlyArray<string>;
|
|
191
|
+
};
|
|
192
|
+
interface DocCollection {
|
|
193
|
+
readonly name: string;
|
|
194
|
+
readonly id?: {
|
|
195
|
+
readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';
|
|
196
|
+
};
|
|
197
|
+
readonly fields: Record<string, FieldType>;
|
|
198
|
+
readonly indexes?: ReadonlyArray<DocIndex>;
|
|
199
|
+
readonly readOnly?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface DocumentStorage {
|
|
202
|
+
readonly document: {
|
|
203
|
+
readonly collections: Record<string, DocCollection>;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
interface DocumentContract<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> extends ContractBase<TStorageHash, TExecutionHash, TProfileHash> {
|
|
207
|
+
readonly targetFamily: string;
|
|
208
|
+
readonly storage: DocumentStorage;
|
|
209
|
+
}
|
|
210
|
+
interface ParamDescriptor {
|
|
211
|
+
readonly index?: number;
|
|
212
|
+
readonly name?: string;
|
|
213
|
+
readonly codecId?: string;
|
|
214
|
+
readonly nativeType?: string;
|
|
215
|
+
readonly nullable?: boolean;
|
|
216
|
+
readonly source: 'dsl' | 'raw' | 'lane';
|
|
217
|
+
readonly refs?: {
|
|
218
|
+
table: string;
|
|
219
|
+
column: string;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
interface PlanRefs {
|
|
223
|
+
readonly tables?: readonly string[];
|
|
224
|
+
readonly columns?: ReadonlyArray<{
|
|
225
|
+
table: string;
|
|
226
|
+
column: string;
|
|
227
|
+
}>;
|
|
228
|
+
readonly indexes?: ReadonlyArray<{
|
|
229
|
+
readonly table: string;
|
|
230
|
+
readonly columns: ReadonlyArray<string>;
|
|
231
|
+
readonly name?: string;
|
|
232
|
+
}>;
|
|
233
|
+
}
|
|
234
|
+
interface PlanMeta {
|
|
235
|
+
readonly target: string;
|
|
236
|
+
readonly targetFamily?: string;
|
|
237
|
+
readonly storageHash: string;
|
|
238
|
+
readonly profileHash?: string;
|
|
239
|
+
readonly lane: string;
|
|
240
|
+
readonly annotations?: {
|
|
241
|
+
codecs?: Record<string, string>;
|
|
242
|
+
[key: string]: unknown;
|
|
243
|
+
};
|
|
244
|
+
readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
|
|
245
|
+
readonly refs?: PlanRefs;
|
|
246
|
+
readonly projection?: Record<string, string> | ReadonlyArray<string>;
|
|
247
|
+
/**
|
|
248
|
+
* Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
|
|
249
|
+
* Used for codec resolution when AST+refs don't provide enough type info.
|
|
250
|
+
*/
|
|
251
|
+
readonly projectionTypes?: Record<string, string>;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Canonical execution plan shape used by runtimes.
|
|
255
|
+
*
|
|
256
|
+
* - Row is the inferred result row type (TypeScript-only).
|
|
257
|
+
* - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
|
|
258
|
+
*
|
|
259
|
+
* The payload executed by the runtime is represented by the sql + params pair
|
|
260
|
+
* for now; future families can specialize this via Ast or additional metadata.
|
|
261
|
+
*/
|
|
262
|
+
interface ExecutionPlan<Row = unknown, Ast = unknown> {
|
|
263
|
+
readonly sql: string;
|
|
264
|
+
readonly params: readonly unknown[];
|
|
265
|
+
readonly ast?: Ast;
|
|
266
|
+
readonly meta: PlanMeta;
|
|
267
|
+
/**
|
|
268
|
+
* Phantom property to carry the Row generic for type-level utilities.
|
|
269
|
+
* Not set at runtime; used only for ResultType extraction.
|
|
270
|
+
*/
|
|
271
|
+
readonly _row?: Row;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Utility type to extract the Row type from an ExecutionPlan.
|
|
275
|
+
* Example: `type Row = ResultType<typeof plan>`
|
|
276
|
+
*
|
|
277
|
+
* Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
|
|
278
|
+
* SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
|
|
279
|
+
* for type extraction.
|
|
280
|
+
*/
|
|
281
|
+
type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
|
|
282
|
+
readonly _Row?: infer R;
|
|
283
|
+
} ? R : never;
|
|
284
|
+
/**
|
|
285
|
+
* Type guard to check if a contract is a Document contract
|
|
286
|
+
*/
|
|
287
|
+
declare function isDocumentContract(contract: unknown): contract is DocumentContract;
|
|
288
|
+
/**
|
|
289
|
+
* Contract marker record stored in the database.
|
|
290
|
+
* Represents the current contract identity for a database.
|
|
291
|
+
*/
|
|
292
|
+
interface ContractMarkerRecord {
|
|
293
|
+
readonly storageHash: string;
|
|
294
|
+
readonly profileHash: string;
|
|
295
|
+
readonly contractJson: unknown | null;
|
|
296
|
+
readonly canonicalVersion: number | null;
|
|
297
|
+
readonly updatedAt: Date;
|
|
298
|
+
readonly appTag: string | null;
|
|
299
|
+
readonly meta: Record<string, unknown>;
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
export { DomainRelation as $, TaggedBigInt as A, ContractDiscriminator as B, PlanMeta as C, Source as D, ResultType as E, executionHash as F, ContractRelation as G, ContractField as H, isDocumentContract as I, DomainDiscriminator as J, ContractRelationOn as K, isTaggedBigInt as L, TaggedRaw as M, bigintJsonReplacer as N, StorageBase as O, coreHash as P, DomainReferenceRelation as Q, isTaggedRaw as R, ParamDescriptor as S, ProfileHashBase as T, ContractModel as U, ContractEmbedRelation as V, ContractReferenceRelation as W, DomainField as X, DomainEmbedRelation as Y, DomainModel as Z, Expr as _, ColumnDefaultLiteralValue as a, JsonPrimitive as b, DocCollection as c, DocumentStorage as d, DomainRelationOn as et, ExecutionHashBase as f, ExecutionSection as g, ExecutionPlan as h, ColumnDefaultLiteralInputValue as i, ReferenceRelationKeys as it, TaggedLiteralValue as j, StorageHashBase as k, DocIndex as l, ExecutionMutationDefaultValue as m, Brand as n, EmbedRelationKeys as nt, ContractBase as o, ExecutionMutationDefault as p, ContractVariantEntry as q, ColumnDefault as r, ModelStorageBase as rt, ContractMarkerRecord as s, $ as t, DomainVariantEntry as tt, DocumentContract as u, FieldType as v, PlanRefs as w, JsonValue as x, GeneratedValueSpec as y, profileHash as z };
|
|
303
|
+
//# sourceMappingURL=types-DmKtoEd-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DmKtoEd-.d.mts","names":[],"sources":["../src/domain-types.ts","../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,aAAA;EAAA,SAAA,QAAa,EAAA,OAAA;EAKb,SAAA,OAAA,EAAA,MAAkB;AAK9B,CAAA;AAMY,KAXA,kBAAA,GAWqB;EAKrB,SAAA,WAAgB,EAAA,SAAG,MAAA,EAAA;EAEnB,SAAA,YAAA,EAAA,SAAqB,MAAA,EAAA;AAIjC,CAAA;AAIY,KArBA,yBAAA,GAqB4B;E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,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;EAAG,CAAA;EAWT,SAAA,gBAAU,EAvCO,aAuCP,CAvCqB,eAuCrB,CAAA;EACpB,SAAA,IAAA,CAAA,EAvCgB,QAuChB;EAAU,SAAA,UAAA,CAAA,EAtCY,MAsCZ,CAAA,MAAA,EAAA,MAAA,CAAA,GAtCqC,aAsCrC,CAAA,MAAA,CAAA;EAAsC;;AAKlD;AAaA;6BAnD6B;;;;;;;;;;;UAYZ;;;iBAGA;iBACA;;;;;kBAKC;;;;;;;;;;KAWN,gBACV,UAAU,sCAAsC;;;;;;iBAKlC,kBAAA,iCAAmD;;;;;UAalD,oBAAA;;;;;sBAKK;;iBAEL"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { $ as DomainRelation, A as TaggedBigInt, B as ContractDiscriminator, C as PlanMeta, D as Source, E as ResultType, F as executionHash, G as ContractRelation, H as ContractField, I as isDocumentContract, J as DomainDiscriminator, K as ContractRelationOn, L as isTaggedBigInt, M as TaggedRaw, N as bigintJsonReplacer, O as StorageBase, P as coreHash, Q as DomainReferenceRelation, R as isTaggedRaw, S as ParamDescriptor, T as ProfileHashBase, U as ContractModel, V as ContractEmbedRelation, W as ContractReferenceRelation, X as DomainField, Y as DomainEmbedRelation, Z as DomainModel, _ as Expr, a as ColumnDefaultLiteralValue, b as JsonPrimitive, c as DocCollection, d as DocumentStorage, et as DomainRelationOn, f as ExecutionHashBase, g as ExecutionSection, h as ExecutionPlan, i as ColumnDefaultLiteralInputValue, it as ReferenceRelationKeys, j as TaggedLiteralValue, k as StorageHashBase, l as DocIndex, m as ExecutionMutationDefaultValue, n as Brand, nt as EmbedRelationKeys, o as ContractBase, p as ExecutionMutationDefault, q as ContractVariantEntry, r as ColumnDefault, rt as ModelStorageBase, s as ContractMarkerRecord, t as $, tt as DomainVariantEntry, u as DocumentContract, v as FieldType, w as PlanRefs, x as JsonValue, y as GeneratedValueSpec, z as profileHash } from "./types-DmKtoEd-.mjs";
|
|
2
|
+
import { n as ContractExecutionSection, t as Contract } from "./contract-types-x89nqTli.mjs";
|
|
3
|
+
export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractBase, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractMarkerRecord, type ContractModel, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractVariantEntry, type DocCollection, type DocIndex, type DocumentContract, type DocumentStorage, type DomainDiscriminator, type DomainEmbedRelation, type DomainField, type DomainModel, type DomainReferenceRelation, type DomainRelation, type DomainRelationOn, type DomainVariantEntry, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultValue, type ExecutionPlan, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ModelStorageBase, type ParamDescriptor, type PlanMeta, type PlanRefs, type ProfileHashBase, type ReferenceRelationKeys, type ResultType, type Source, type StorageBase, type StorageHashBase, type TaggedBigInt, type TaggedLiteralValue, type TaggedRaw, bigintJsonReplacer, coreHash, executionHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as isTaggedBigInt, i as isDocumentContract, n as coreHash, o as isTaggedRaw, r as executionHash, s as profileHash, t as bigintJsonReplacer } from "./types-DYikGC04.mjs";
|
|
2
|
+
|
|
3
|
+
export { bigintJsonReplacer, coreHash, executionHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { t as Contract } from "./contract-types-x89nqTli.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/validate-contract.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Family-provided storage validator.
|
|
7
|
+
* SQL validates tables/columns/FKs; Mongo validates collections/embedding.
|
|
8
|
+
*/
|
|
9
|
+
type StorageValidator = (contract: Contract) => void;
|
|
10
|
+
interface ValidateContractResult {
|
|
11
|
+
readonly warnings: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Framework-level contract validation (ADR 182).
|
|
15
|
+
*
|
|
16
|
+
* Three-pass validation:
|
|
17
|
+
* 1. **Structural validation** (arktype): verifies required fields exist with
|
|
18
|
+
* correct base types.
|
|
19
|
+
* 2. **Domain validation** (framework-owned): roots, relation targets,
|
|
20
|
+
* variant/base consistency, discriminators, ownership, orphans.
|
|
21
|
+
* 3. **Storage validation** (family-provided): SQL validates tables/columns/FKs;
|
|
22
|
+
* Mongo validates collections/embedding.
|
|
23
|
+
*
|
|
24
|
+
* JSON persistence fields (`schemaVersion`, `sources`) are stripped before
|
|
25
|
+
* validation — they are not part of the in-memory contract representation.
|
|
26
|
+
*
|
|
27
|
+
* @template TContract The fully-typed contract type (preserves literal types).
|
|
28
|
+
* @param value Raw contract value (e.g. parsed from JSON).
|
|
29
|
+
* @param storageValidator Family-specific storage validation function.
|
|
30
|
+
* @returns The validated contract with full literal types.
|
|
31
|
+
*/
|
|
32
|
+
declare function validateContract<TContract extends Contract>(value: unknown, storageValidator: StorageValidator): TContract & ValidateContractResult;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { type StorageValidator, type ValidateContractResult, validateContract };
|
|
35
|
+
//# sourceMappingURL=validate-contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-contract.d.mts","names":[],"sources":["../src/validate-contract.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAEA;AAqDgB,KAvDJ,gBAAA,GAuDoB,CAAA,QAAA,EAvDU,QAuDV,EAAA,GAAA,IAAA;AAAmB,UArDlC,sBAAA,CAqDkC;EAE/B,SAAA,QAAA,EAAA,MAAA,EAAA;;;;;;;;;;;;;;;;;;;;;iBAFJ,mCAAmC,4CAE/B,mBACjB,YAAY"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { t as validateContractDomain } from "./validate-domain-CTQiBiei.mjs";
|
|
2
|
+
import { type } from "arktype";
|
|
3
|
+
|
|
4
|
+
//#region src/validate-contract.ts
|
|
5
|
+
const ContractSchema = type({
|
|
6
|
+
target: "string",
|
|
7
|
+
targetFamily: "string",
|
|
8
|
+
roots: "Record<string, string>",
|
|
9
|
+
models: "Record<string, unknown>",
|
|
10
|
+
storage: "Record<string, unknown>",
|
|
11
|
+
capabilities: "Record<string, Record<string, boolean>>",
|
|
12
|
+
extensionPacks: "Record<string, unknown>",
|
|
13
|
+
meta: "Record<string, unknown>",
|
|
14
|
+
"execution?": {
|
|
15
|
+
"executionHash?": "string",
|
|
16
|
+
mutations: { defaults: "unknown[]" }
|
|
17
|
+
},
|
|
18
|
+
"profileHash?": "string"
|
|
19
|
+
});
|
|
20
|
+
function stripPersistenceFields(raw) {
|
|
21
|
+
const { schemaVersion: _, sources: _s, ...rest } = raw;
|
|
22
|
+
return rest;
|
|
23
|
+
}
|
|
24
|
+
function extractDomainShape(contract) {
|
|
25
|
+
return {
|
|
26
|
+
roots: contract.roots,
|
|
27
|
+
models: contract.models
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Framework-level contract validation (ADR 182).
|
|
32
|
+
*
|
|
33
|
+
* Three-pass validation:
|
|
34
|
+
* 1. **Structural validation** (arktype): verifies required fields exist with
|
|
35
|
+
* correct base types.
|
|
36
|
+
* 2. **Domain validation** (framework-owned): roots, relation targets,
|
|
37
|
+
* variant/base consistency, discriminators, ownership, orphans.
|
|
38
|
+
* 3. **Storage validation** (family-provided): SQL validates tables/columns/FKs;
|
|
39
|
+
* Mongo validates collections/embedding.
|
|
40
|
+
*
|
|
41
|
+
* JSON persistence fields (`schemaVersion`, `sources`) are stripped before
|
|
42
|
+
* validation — they are not part of the in-memory contract representation.
|
|
43
|
+
*
|
|
44
|
+
* @template TContract The fully-typed contract type (preserves literal types).
|
|
45
|
+
* @param value Raw contract value (e.g. parsed from JSON).
|
|
46
|
+
* @param storageValidator Family-specific storage validation function.
|
|
47
|
+
* @returns The validated contract with full literal types.
|
|
48
|
+
*/
|
|
49
|
+
function validateContract(value, storageValidator) {
|
|
50
|
+
if (typeof value !== "object" || value === null) throw new Error("Contract must be a non-null object");
|
|
51
|
+
const parsed = ContractSchema(stripPersistenceFields(value));
|
|
52
|
+
if (parsed instanceof type.errors) throw new Error(`Invalid contract structure: ${parsed.summary}`);
|
|
53
|
+
const contract = parsed;
|
|
54
|
+
const domainResult = validateContractDomain(extractDomainShape(contract));
|
|
55
|
+
storageValidator(contract);
|
|
56
|
+
return Object.assign(contract, { warnings: domainResult.warnings });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { validateContract };
|
|
61
|
+
//# sourceMappingURL=validate-contract.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-contract.mjs","names":["domainResult: DomainValidationResult"],"sources":["../src/validate-contract.ts"],"sourcesContent":["import { type } from 'arktype';\nimport type { Contract } from './contract-types';\nimport type { DomainContractShape, DomainValidationResult } from './validate-domain';\nimport { validateContractDomain } from './validate-domain';\n\n/**\n * Family-provided storage validator.\n * SQL validates tables/columns/FKs; Mongo validates collections/embedding.\n */\nexport type StorageValidator = (contract: Contract) => void;\n\nexport interface ValidateContractResult {\n readonly warnings: string[];\n}\n\nconst ContractSchema = type({\n target: 'string',\n targetFamily: 'string',\n roots: 'Record<string, string>',\n models: 'Record<string, unknown>',\n storage: 'Record<string, unknown>',\n capabilities: 'Record<string, Record<string, boolean>>',\n extensionPacks: 'Record<string, unknown>',\n meta: 'Record<string, unknown>',\n 'execution?': {\n 'executionHash?': 'string',\n mutations: {\n defaults: 'unknown[]',\n },\n },\n 'profileHash?': 'string',\n});\n\nfunction stripPersistenceFields(raw: Record<string, unknown>): Record<string, unknown> {\n const { schemaVersion: _, sources: _s, ...rest } = raw;\n return rest;\n}\n\nfunction extractDomainShape(contract: Contract): DomainContractShape {\n return {\n roots: contract.roots,\n models: contract.models,\n };\n}\n\n/**\n * Framework-level contract validation (ADR 182).\n *\n * Three-pass validation:\n * 1. **Structural validation** (arktype): verifies required fields exist with\n * correct base types.\n * 2. **Domain validation** (framework-owned): roots, relation targets,\n * variant/base consistency, discriminators, ownership, orphans.\n * 3. **Storage validation** (family-provided): SQL validates tables/columns/FKs;\n * Mongo validates collections/embedding.\n *\n * JSON persistence fields (`schemaVersion`, `sources`) are stripped before\n * validation — they are not part of the in-memory contract representation.\n *\n * @template TContract The fully-typed contract type (preserves literal types).\n * @param value Raw contract value (e.g. parsed from JSON).\n * @param storageValidator Family-specific storage validation function.\n * @returns The validated contract with full literal types.\n */\nexport function validateContract<TContract extends Contract>(\n value: unknown,\n storageValidator: StorageValidator,\n): TContract & ValidateContractResult {\n if (typeof value !== 'object' || value === null) {\n throw new Error('Contract must be a non-null object');\n }\n\n const stripped = stripPersistenceFields(value as Record<string, unknown>);\n\n const parsed = ContractSchema(stripped);\n if (parsed instanceof type.errors) {\n throw new Error(`Invalid contract structure: ${parsed.summary}`);\n }\n\n // Arktype verified the structural shape; Contract adds branded hash types and\n // ContractModel generics that can't be expressed in the schema.\n const contract = parsed as unknown as Contract;\n\n const domainResult: DomainValidationResult = validateContractDomain(extractDomainShape(contract));\n\n storageValidator(contract);\n\n // TContract narrows Contract with literal types from the caller's contract.d.ts;\n // the runtime object is the same — the cast preserves the caller's type parameter.\n return Object.assign(contract as unknown as TContract, {\n warnings: domainResult.warnings,\n });\n}\n"],"mappings":";;;;AAeA,MAAM,iBAAiB,KAAK;CAC1B,QAAQ;CACR,cAAc;CACd,OAAO;CACP,QAAQ;CACR,SAAS;CACT,cAAc;CACd,gBAAgB;CAChB,MAAM;CACN,cAAc;EACZ,kBAAkB;EAClB,WAAW,EACT,UAAU,aACX;EACF;CACD,gBAAgB;CACjB,CAAC;AAEF,SAAS,uBAAuB,KAAuD;CACrF,MAAM,EAAE,eAAe,GAAG,SAAS,IAAI,GAAG,SAAS;AACnD,QAAO;;AAGT,SAAS,mBAAmB,UAAyC;AACnE,QAAO;EACL,OAAO,SAAS;EAChB,QAAQ,SAAS;EAClB;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,iBACd,OACA,kBACoC;AACpC,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,OAAM,IAAI,MAAM,qCAAqC;CAKvD,MAAM,SAAS,eAFE,uBAAuB,MAAiC,CAElC;AACvC,KAAI,kBAAkB,KAAK,OACzB,OAAM,IAAI,MAAM,+BAA+B,OAAO,UAAU;CAKlE,MAAM,WAAW;CAEjB,MAAMA,eAAuC,uBAAuB,mBAAmB,SAAS,CAAC;AAEjG,kBAAiB,SAAS;AAI1B,QAAO,OAAO,OAAO,UAAkC,EACrD,UAAU,aAAa,UACxB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/validate-domain.ts
|
|
2
|
+
function validateContractDomain(contract) {
|
|
3
|
+
const errors = [];
|
|
4
|
+
const warnings = [];
|
|
5
|
+
const modelNames = new Set(Object.keys(contract.models));
|
|
6
|
+
validateRoots(contract, modelNames, errors);
|
|
7
|
+
validateVariantsAndBases(contract, modelNames, errors);
|
|
8
|
+
validateRelationTargets(contract, modelNames, errors);
|
|
9
|
+
validateDiscriminators(contract, errors);
|
|
10
|
+
validateOwnership(contract, modelNames, errors);
|
|
11
|
+
detectOrphanedModels(contract, modelNames, warnings);
|
|
12
|
+
if (errors.length > 0) throw new Error(`Contract domain validation failed:\n- ${errors.join("\n- ")}`);
|
|
13
|
+
return { warnings };
|
|
14
|
+
}
|
|
15
|
+
function validateRoots(contract, modelNames, errors) {
|
|
16
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const [rootKey, modelName] of Object.entries(contract.roots)) {
|
|
18
|
+
if (seenValues.has(modelName)) errors.push(`Duplicate root value: "${modelName}" is mapped by multiple root keys`);
|
|
19
|
+
seenValues.add(modelName);
|
|
20
|
+
if (!modelNames.has(modelName)) errors.push(`Root "${rootKey}" references model "${modelName}" which does not exist in models`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function validateVariantsAndBases(contract, modelNames, errors) {
|
|
24
|
+
const models = new Map(Object.entries(contract.models));
|
|
25
|
+
for (const [modelName, model] of models) {
|
|
26
|
+
if (model.variants) for (const variantName of Object.keys(model.variants)) {
|
|
27
|
+
if (!modelNames.has(variantName)) {
|
|
28
|
+
errors.push(`Model "${modelName}" lists variant "${variantName}" which does not exist in models`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const variantModel = models.get(variantName);
|
|
32
|
+
if (!variantModel) continue;
|
|
33
|
+
if (variantModel.base !== modelName) errors.push(`Variant "${variantName}" has base "${variantModel.base ?? "(none)"}" but expected "${modelName}"`);
|
|
34
|
+
}
|
|
35
|
+
if (model.base) {
|
|
36
|
+
if (!modelNames.has(model.base)) {
|
|
37
|
+
errors.push(`Model "${modelName}" has base "${model.base}" which does not exist in models`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const baseModel = models.get(model.base);
|
|
41
|
+
if (!baseModel) continue;
|
|
42
|
+
if (!baseModel.variants || !Object.hasOwn(baseModel.variants, modelName)) errors.push(`Model "${modelName}" has base "${model.base}" which does not list it as a variant`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function validateRelationTargets(contract, modelNames, errors) {
|
|
47
|
+
for (const [modelName, model] of Object.entries(contract.models)) for (const [relName, relation] of Object.entries(model.relations ?? {})) if (!modelNames.has(relation.to)) errors.push(`Relation "${relName}" on model "${modelName}" targets "${relation.to}" which does not exist in models`);
|
|
48
|
+
}
|
|
49
|
+
function validateDiscriminators(contract, errors) {
|
|
50
|
+
for (const [modelName, model] of Object.entries(contract.models)) {
|
|
51
|
+
if (model.discriminator) {
|
|
52
|
+
if (!model.variants || Object.keys(model.variants).length === 0) errors.push(`Model "${modelName}" has discriminator but no variants`);
|
|
53
|
+
if (!Object.hasOwn(model.fields, model.discriminator.field)) errors.push(`Discriminator field "${model.discriminator.field}" is not a field on model "${modelName}"`);
|
|
54
|
+
}
|
|
55
|
+
if (model.variants && Object.keys(model.variants).length > 0 && !model.discriminator) errors.push(`Model "${modelName}" has variants but no discriminator`);
|
|
56
|
+
if (model.base) {
|
|
57
|
+
if (model.discriminator) errors.push(`Model "${modelName}" has base and must not have discriminator`);
|
|
58
|
+
if (model.variants && Object.keys(model.variants).length > 0) errors.push(`Model "${modelName}" has base and must not have variants`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function validateOwnership(contract, modelNames, errors) {
|
|
63
|
+
for (const [modelName, model] of Object.entries(contract.models)) {
|
|
64
|
+
if (!model.owner) continue;
|
|
65
|
+
if (model.owner === modelName) errors.push(`Model "${modelName}" cannot own itself`);
|
|
66
|
+
if (!modelNames.has(model.owner)) errors.push(`Model "${modelName}" has owner "${model.owner}" which does not exist in models`);
|
|
67
|
+
for (const [rootKey, rootModel] of Object.entries(contract.roots)) if (rootModel === modelName) errors.push(`Owned model "${modelName}" must not appear in roots (found as root "${rootKey}")`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function detectOrphanedModels(contract, modelNames, warnings) {
|
|
71
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const modelName of Object.values(contract.roots)) referenced.add(modelName);
|
|
73
|
+
for (const [modelName, model] of Object.entries(contract.models)) {
|
|
74
|
+
for (const relation of Object.values(model.relations ?? {})) referenced.add(relation.to);
|
|
75
|
+
if (model.variants) for (const variantName of Object.keys(model.variants)) referenced.add(variantName);
|
|
76
|
+
if (model.base) referenced.add(model.base);
|
|
77
|
+
if (model.owner) referenced.add(modelName);
|
|
78
|
+
}
|
|
79
|
+
for (const modelName of modelNames) if (!referenced.has(modelName)) warnings.push(`Orphaned model: "${modelName}" is not referenced by any root, relation, or variant`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { validateContractDomain as t };
|
|
84
|
+
//# sourceMappingURL=validate-domain-CTQiBiei.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-domain-CTQiBiei.mjs","names":["errors: string[]","warnings: string[]"],"sources":["../src/validate-domain.ts"],"sourcesContent":["export interface DomainModelShape {\n readonly fields: Record<string, unknown>;\n readonly relations?: Record<string, { readonly to: string }>;\n readonly discriminator?: { readonly field: string };\n readonly variants?: Record<string, unknown>;\n readonly base?: string;\n readonly owner?: string;\n}\n\nexport interface DomainContractShape {\n readonly roots: Record<string, string>;\n readonly models: Record<string, DomainModelShape>;\n}\n\nexport interface DomainValidationResult {\n readonly warnings: string[];\n}\n\nexport function validateContractDomain(contract: DomainContractShape): DomainValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n const modelNames = new Set(Object.keys(contract.models));\n\n validateRoots(contract, modelNames, errors);\n validateVariantsAndBases(contract, modelNames, errors);\n validateRelationTargets(contract, modelNames, errors);\n validateDiscriminators(contract, errors);\n validateOwnership(contract, modelNames, errors);\n detectOrphanedModels(contract, modelNames, warnings);\n\n if (errors.length > 0) {\n throw new Error(`Contract domain validation failed:\\n- ${errors.join('\\n- ')}`);\n }\n\n return { warnings };\n}\n\nfunction validateRoots(\n contract: DomainContractShape,\n modelNames: Set<string>,\n errors: string[],\n): void {\n const seenValues = new Set<string>();\n for (const [rootKey, modelName] of Object.entries(contract.roots)) {\n if (seenValues.has(modelName)) {\n errors.push(`Duplicate root value: \"${modelName}\" is mapped by multiple root keys`);\n }\n seenValues.add(modelName);\n\n if (!modelNames.has(modelName)) {\n errors.push(\n `Root \"${rootKey}\" references model \"${modelName}\" which does not exist in models`,\n );\n }\n }\n}\n\nfunction validateVariantsAndBases(\n contract: DomainContractShape,\n modelNames: Set<string>,\n errors: string[],\n): void {\n const models = new Map(Object.entries(contract.models));\n\n for (const [modelName, model] of models) {\n if (model.variants) {\n for (const variantName of Object.keys(model.variants)) {\n if (!modelNames.has(variantName)) {\n errors.push(\n `Model \"${modelName}\" lists variant \"${variantName}\" which does not exist in models`,\n );\n continue;\n }\n const variantModel = models.get(variantName);\n if (!variantModel) continue;\n if (variantModel.base !== modelName) {\n errors.push(\n `Variant \"${variantName}\" has base \"${variantModel.base ?? '(none)'}\" but expected \"${modelName}\"`,\n );\n }\n }\n }\n\n if (model.base) {\n if (!modelNames.has(model.base)) {\n errors.push(`Model \"${modelName}\" has base \"${model.base}\" which does not exist in models`);\n continue;\n }\n const baseModel = models.get(model.base);\n if (!baseModel) continue;\n if (!baseModel.variants || !Object.hasOwn(baseModel.variants, modelName)) {\n errors.push(\n `Model \"${modelName}\" has base \"${model.base}\" which does not list it as a variant`,\n );\n }\n }\n }\n}\n\nfunction validateRelationTargets(\n contract: DomainContractShape,\n modelNames: Set<string>,\n errors: string[],\n): void {\n for (const [modelName, model] of Object.entries(contract.models)) {\n for (const [relName, relation] of Object.entries(model.relations ?? {})) {\n if (!modelNames.has(relation.to)) {\n errors.push(\n `Relation \"${relName}\" on model \"${modelName}\" targets \"${relation.to}\" which does not exist in models`,\n );\n }\n }\n }\n}\n\nfunction validateDiscriminators(contract: DomainContractShape, errors: string[]): void {\n for (const [modelName, model] of Object.entries(contract.models)) {\n if (model.discriminator) {\n if (!model.variants || Object.keys(model.variants).length === 0) {\n errors.push(`Model \"${modelName}\" has discriminator but no variants`);\n }\n if (!Object.hasOwn(model.fields, model.discriminator.field)) {\n errors.push(\n `Discriminator field \"${model.discriminator.field}\" is not a field on model \"${modelName}\"`,\n );\n }\n }\n\n if (model.variants && Object.keys(model.variants).length > 0 && !model.discriminator) {\n errors.push(`Model \"${modelName}\" has variants but no discriminator`);\n }\n\n if (model.base) {\n if (model.discriminator) {\n errors.push(`Model \"${modelName}\" has base and must not have discriminator`);\n }\n if (model.variants && Object.keys(model.variants).length > 0) {\n errors.push(`Model \"${modelName}\" has base and must not have variants`);\n }\n }\n }\n}\n\nfunction validateOwnership(\n contract: DomainContractShape,\n modelNames: Set<string>,\n errors: string[],\n): void {\n for (const [modelName, model] of Object.entries(contract.models)) {\n if (!model.owner) continue;\n\n if (model.owner === modelName) {\n errors.push(`Model \"${modelName}\" cannot own itself`);\n }\n\n if (!modelNames.has(model.owner)) {\n errors.push(`Model \"${modelName}\" has owner \"${model.owner}\" which does not exist in models`);\n }\n\n for (const [rootKey, rootModel] of Object.entries(contract.roots)) {\n if (rootModel === modelName) {\n errors.push(\n `Owned model \"${modelName}\" must not appear in roots (found as root \"${rootKey}\")`,\n );\n }\n }\n }\n}\n\nfunction detectOrphanedModels(\n contract: DomainContractShape,\n modelNames: Set<string>,\n warnings: string[],\n): void {\n const referenced = new Set<string>();\n\n for (const modelName of Object.values(contract.roots)) {\n referenced.add(modelName);\n }\n\n for (const [modelName, model] of Object.entries(contract.models)) {\n for (const relation of Object.values(model.relations ?? {})) {\n referenced.add(relation.to);\n }\n if (model.variants) {\n for (const variantName of Object.keys(model.variants)) {\n referenced.add(variantName);\n }\n }\n if (model.base) {\n referenced.add(model.base);\n }\n if (model.owner) {\n referenced.add(modelName);\n }\n }\n\n for (const modelName of modelNames) {\n if (!referenced.has(modelName)) {\n warnings.push(\n `Orphaned model: \"${modelName}\" is not referenced by any root, relation, or variant`,\n );\n }\n }\n}\n"],"mappings":";AAkBA,SAAgB,uBAAuB,UAAuD;CAC5F,MAAMA,SAAmB,EAAE;CAC3B,MAAMC,WAAqB,EAAE;CAC7B,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,SAAS,OAAO,CAAC;AAExD,eAAc,UAAU,YAAY,OAAO;AAC3C,0BAAyB,UAAU,YAAY,OAAO;AACtD,yBAAwB,UAAU,YAAY,OAAO;AACrD,wBAAuB,UAAU,OAAO;AACxC,mBAAkB,UAAU,YAAY,OAAO;AAC/C,sBAAqB,UAAU,YAAY,SAAS;AAEpD,KAAI,OAAO,SAAS,EAClB,OAAM,IAAI,MAAM,yCAAyC,OAAO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KAAI,cAAc,UAChB,QAAO,KACL,gBAAgB,UAAU,6CAA6C,QAAQ,IAChF;;;AAMT,SAAS,qBACP,UACA,YACA,UACM;CACN,MAAM,6BAAa,IAAI,KAAa;AAEpC,MAAK,MAAM,aAAa,OAAO,OAAO,SAAS,MAAM,CACnD,YAAW,IAAI,UAAU;AAG3B,MAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,SAAS,OAAO,EAAE;AAChE,OAAK,MAAM,YAAY,OAAO,OAAO,MAAM,aAAa,EAAE,CAAC,CACzD,YAAW,IAAI,SAAS,GAAG;AAE7B,MAAI,MAAM,SACR,MAAK,MAAM,eAAe,OAAO,KAAK,MAAM,SAAS,CACnD,YAAW,IAAI,YAAY;AAG/B,MAAI,MAAM,KACR,YAAW,IAAI,MAAM,KAAK;AAE5B,MAAI,MAAM,MACR,YAAW,IAAI,UAAU;;AAI7B,MAAK,MAAM,aAAa,WACtB,KAAI,CAAC,WAAW,IAAI,UAAU,CAC5B,UAAS,KACP,oBAAoB,UAAU,uDAC/B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/validate-domain.d.ts
|
|
2
|
+
interface DomainModelShape {
|
|
3
|
+
readonly fields: Record<string, unknown>;
|
|
4
|
+
readonly relations?: Record<string, {
|
|
5
|
+
readonly to: string;
|
|
6
|
+
}>;
|
|
7
|
+
readonly discriminator?: {
|
|
8
|
+
readonly field: string;
|
|
9
|
+
};
|
|
10
|
+
readonly variants?: Record<string, unknown>;
|
|
11
|
+
readonly base?: string;
|
|
12
|
+
readonly owner?: string;
|
|
13
|
+
}
|
|
14
|
+
interface DomainContractShape {
|
|
15
|
+
readonly roots: Record<string, string>;
|
|
16
|
+
readonly models: Record<string, DomainModelShape>;
|
|
17
|
+
}
|
|
18
|
+
interface DomainValidationResult {
|
|
19
|
+
readonly warnings: string[];
|
|
20
|
+
}
|
|
21
|
+
declare function validateContractDomain(contract: DomainContractShape): DomainValidationResult;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { type DomainContractShape, type DomainModelShape, type DomainValidationResult, validateContractDomain };
|
|
24
|
+
//# sourceMappingURL=validate-domain.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-domain.d.mts","names":[],"sources":["../src/validate-domain.ts"],"sourcesContent":[],"mappings":";UAAiB,gBAAA;EAAA,SAAA,MAAA,EACE,MADc,CAAA,MAAA,EAAA,OAAA,CAAA;EACd,SAAA,SAAA,CAAA,EACI,MADJ,CAAA,MAAA,EAAA;IACI,SAAA,EAAA,EAAA,MAAA;EAED,CAAA,CAAA;EAAM,SAAA,aAAA,CAAA,EAAA;IAKX,SAAA,KAAA,EAAA,MAAmB;EAClB,CAAA;EACgB,SAAA,QAAA,CAAA,EAPZ,MAOY,CAAA,MAAA,EAAA,OAAA,CAAA;EAAf,SAAA,IAAA,CAAA,EAAA,MAAA;EAAM,SAAA,KAAA,CAAA,EAAA,MAAA;AAGzB;AAIgB,UATC,mBAAA,CASqB;kBARpB;mBACC,eAAe;;UAGjB,sBAAA;;;iBAID,sBAAA,WAAiC,sBAAsB"}
|