@prisma-next/mongo-contract 0.13.0-dev.34 → 0.13.0-dev.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entity-kinds-C9KNr9IE.mjs +572 -0
- package/dist/entity-kinds-C9KNr9IE.mjs.map +1 -0
- package/dist/entity-kinds.d.mts +16 -0
- package/dist/entity-kinds.d.mts.map +1 -0
- package/dist/entity-kinds.mjs +2 -0
- package/dist/index.d.mts +3 -527
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -558
- package/dist/index.mjs.map +1 -1
- package/dist/mongo-collection-BCi-Bq_a.d.mts +530 -0
- package/dist/mongo-collection-BCi-Bq_a.d.mts.map +1 -0
- package/package.json +9 -8
- package/src/contract-schema.ts +1 -1
- package/src/entity-kinds.ts +34 -0
- package/src/exports/entity-kinds.ts +1 -0
- package/src/ir/build-mongo-namespace.ts +13 -21
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { Contract, ContractField, ContractModel, ContractValueObject, ContractValueObjectDefinitions, ControlPolicy, StorageBase } from "@prisma-next/contract/types";
|
|
2
|
+
import { IRNodeBase, Namespace, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
3
|
+
import { CollationOptions } from "@prisma-next/mongo-value/mongodb-types";
|
|
4
|
+
|
|
5
|
+
//#region src/ir/mongo-collation-options.d.ts
|
|
6
|
+
type MongoCollationCaseFirst = 'off' | 'upper' | 'lower';
|
|
7
|
+
type MongoCollationStrength = 1 | 2 | 3 | 4 | 5;
|
|
8
|
+
type MongoCollationAlternate = 'non-ignorable' | 'shifted';
|
|
9
|
+
type MongoCollationMaxVariable = 'punct' | 'space';
|
|
10
|
+
/**
|
|
11
|
+
* Authoring / hydration input shape for {@link MongoCollationOptions}. Carries
|
|
12
|
+
* the canonical data without the IR-class `kind` discriminator; the class
|
|
13
|
+
* fabricates `kind` so the authoring DSL and the SPI hydration walker can
|
|
14
|
+
* pass plain data literals through the constructor without forcing every
|
|
15
|
+
* call site to spell out `kind: 'mongo-collation-options'`.
|
|
16
|
+
*/
|
|
17
|
+
interface MongoCollationOptionsInput {
|
|
18
|
+
readonly locale: string;
|
|
19
|
+
readonly caseLevel?: boolean;
|
|
20
|
+
readonly caseFirst?: MongoCollationCaseFirst;
|
|
21
|
+
readonly strength?: MongoCollationStrength;
|
|
22
|
+
readonly numericOrdering?: boolean;
|
|
23
|
+
readonly alternate?: MongoCollationAlternate;
|
|
24
|
+
readonly maxVariable?: MongoCollationMaxVariable;
|
|
25
|
+
readonly backwards?: boolean;
|
|
26
|
+
readonly normalization?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Mongo Contract IR leaf for collection / index collation options.
|
|
30
|
+
*
|
|
31
|
+
* Lifted from a `type =` data shape to an AST class extending
|
|
32
|
+
* `IRNodeBase` per FR18 ("Mongo's Contract IR is fully unified under
|
|
33
|
+
* the AST-class pattern, layered family / target"). Single concrete class
|
|
34
|
+
* (no target subclass): collation options carry no target-specific
|
|
35
|
+
* variation at this layer — both Atlas and self-hosted Mongo consume the
|
|
36
|
+
* same option vocabulary.
|
|
37
|
+
*
|
|
38
|
+
* Undefined optional fields are not assigned, so `JSON.stringify` omits
|
|
39
|
+
* them from the canonical JSON output (matches the pre-lift data shape's
|
|
40
|
+
* round-trip behaviour, modulo the new `kind` discriminator).
|
|
41
|
+
*/
|
|
42
|
+
declare class MongoCollationOptions extends IRNodeBase {
|
|
43
|
+
readonly kind: "mongo-collation-options";
|
|
44
|
+
readonly locale: string;
|
|
45
|
+
readonly caseLevel?: boolean;
|
|
46
|
+
readonly caseFirst?: MongoCollationCaseFirst;
|
|
47
|
+
readonly strength?: MongoCollationStrength;
|
|
48
|
+
readonly numericOrdering?: boolean;
|
|
49
|
+
readonly alternate?: MongoCollationAlternate;
|
|
50
|
+
readonly maxVariable?: MongoCollationMaxVariable;
|
|
51
|
+
readonly backwards?: boolean;
|
|
52
|
+
readonly normalization?: boolean;
|
|
53
|
+
constructor(options: MongoCollationOptionsInput);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/ir/mongo-index-options.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Authoring / hydration input shape for {@link MongoIndexOptions}. Carries
|
|
59
|
+
* the index option vocabulary as plain data without the IR-class `kind`
|
|
60
|
+
* discriminator. `collation` accepts either a class instance or its own
|
|
61
|
+
* input shape — the constructor normalises to the class form internally.
|
|
62
|
+
*/
|
|
63
|
+
interface MongoIndexOptionsInput {
|
|
64
|
+
readonly unique?: boolean;
|
|
65
|
+
readonly name?: string;
|
|
66
|
+
readonly partialFilterExpression?: MongoJsonObject;
|
|
67
|
+
readonly sparse?: boolean;
|
|
68
|
+
readonly expireAfterSeconds?: number;
|
|
69
|
+
readonly weights?: Readonly<Record<string, number>>;
|
|
70
|
+
readonly default_language?: string;
|
|
71
|
+
readonly language_override?: string;
|
|
72
|
+
readonly textIndexVersion?: number;
|
|
73
|
+
readonly '2dsphereIndexVersion'?: number;
|
|
74
|
+
readonly bits?: number;
|
|
75
|
+
readonly min?: number;
|
|
76
|
+
readonly max?: number;
|
|
77
|
+
readonly bucketSize?: number;
|
|
78
|
+
readonly hidden?: boolean;
|
|
79
|
+
readonly collation?: MongoCollationOptions | MongoCollationOptionsInput;
|
|
80
|
+
readonly wildcardProjection?: MongoWildcardProjection;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Mongo Contract IR node for the per-index option vocabulary (the second
|
|
84
|
+
* argument to `db.collection.createIndex(keys, options)` minus the keys
|
|
85
|
+
* themselves). Lifted from a `type =` data shape to an AST class
|
|
86
|
+
* extending `IRNodeBase` per FR18.
|
|
87
|
+
*
|
|
88
|
+
* Nested `collation` is itself an IR class (`MongoCollationOptions`); the
|
|
89
|
+
* constructor accepts either a class instance or a data literal and
|
|
90
|
+
* normalises to the class form so downstream walks see a uniform IR tree.
|
|
91
|
+
*/
|
|
92
|
+
declare class MongoIndexOptions extends IRNodeBase {
|
|
93
|
+
readonly kind: "mongo-index-options";
|
|
94
|
+
readonly unique?: boolean;
|
|
95
|
+
readonly name?: string;
|
|
96
|
+
readonly partialFilterExpression?: MongoJsonObject;
|
|
97
|
+
readonly sparse?: boolean;
|
|
98
|
+
readonly expireAfterSeconds?: number;
|
|
99
|
+
readonly weights?: Readonly<Record<string, number>>;
|
|
100
|
+
readonly default_language?: string;
|
|
101
|
+
readonly language_override?: string;
|
|
102
|
+
readonly textIndexVersion?: number;
|
|
103
|
+
readonly '2dsphereIndexVersion'?: number;
|
|
104
|
+
readonly bits?: number;
|
|
105
|
+
readonly min?: number;
|
|
106
|
+
readonly max?: number;
|
|
107
|
+
readonly bucketSize?: number;
|
|
108
|
+
readonly hidden?: boolean;
|
|
109
|
+
readonly collation?: MongoCollationOptions;
|
|
110
|
+
readonly wildcardProjection?: MongoWildcardProjection;
|
|
111
|
+
constructor(options?: MongoIndexOptionsInput);
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/contract-types.d.ts
|
|
115
|
+
type MongoIndexFieldValue = 1 | -1 | 'text' | '2dsphere' | '2d' | 'hashed';
|
|
116
|
+
type MongoIndexFields = Record<string, MongoIndexFieldValue>;
|
|
117
|
+
type MongoJsonPrimitive = string | number | boolean | null;
|
|
118
|
+
type MongoJsonValue = MongoJsonPrimitive | readonly MongoJsonValue[] | MongoJsonObject;
|
|
119
|
+
type MongoJsonObject = {
|
|
120
|
+
readonly [key: string]: MongoJsonValue;
|
|
121
|
+
};
|
|
122
|
+
type MongoWildcardProjection = Readonly<Record<string, 0 | 1>>;
|
|
123
|
+
/**
|
|
124
|
+
* Authoring-DSL shape for a single index entry on a model — the
|
|
125
|
+
* `indexes` array element accepted by the contract-ts builder. The
|
|
126
|
+
* builder translates these (with model context) into {@link MongoIndex}
|
|
127
|
+
* IR-class instances on `MongoCollection.indexes`.
|
|
128
|
+
*/
|
|
129
|
+
type MongoIndexAuthoringInput = {
|
|
130
|
+
readonly fields: MongoIndexFields;
|
|
131
|
+
readonly options?: MongoIndexOptionsInput;
|
|
132
|
+
};
|
|
133
|
+
type MongoIndexKeyDirection = 1 | -1 | 'text' | '2dsphere' | '2d' | 'hashed';
|
|
134
|
+
interface MongoIndexKey {
|
|
135
|
+
readonly field: string;
|
|
136
|
+
readonly direction: MongoIndexKeyDirection;
|
|
137
|
+
}
|
|
138
|
+
type MongoModelStorage = {
|
|
139
|
+
readonly collection?: string;
|
|
140
|
+
readonly relations?: Record<string, {
|
|
141
|
+
readonly field: string;
|
|
142
|
+
}>;
|
|
143
|
+
};
|
|
144
|
+
type MongoModelDefinition = ContractModel<MongoModelStorage>;
|
|
145
|
+
type MongoNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & {
|
|
146
|
+
readonly collection?: Readonly<Record<string, MongoCollection>>;
|
|
147
|
+
};
|
|
148
|
+
type MongoStorageShape<THash extends string = string> = StorageBase<THash> & {
|
|
149
|
+
readonly namespaces: Record<string, Namespace & {
|
|
150
|
+
readonly entries: MongoNamespaceEntries;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
type MongoContract<S extends MongoStorageShape = MongoStorageShape> = Contract<S>;
|
|
154
|
+
/**
|
|
155
|
+
* Model map for the contract's sole (unbound) domain namespace. Mongo is
|
|
156
|
+
* structurally single-namespace, so its models live under
|
|
157
|
+
* {@link UNBOUND_NAMESPACE_ID} rather than in a flat cross-namespace union.
|
|
158
|
+
* Every Mongo type that needs the model map reads it through here, so none
|
|
159
|
+
* indexes the contract's namespaces directly.
|
|
160
|
+
*/
|
|
161
|
+
type MongoModelsMap<TContract extends MongoContract> = TContract['domain']['namespaces'][typeof UNBOUND_NAMESPACE_ID]['models'];
|
|
162
|
+
type RootModelName<TContract extends MongoContract, RootName extends keyof TContract['roots'] & string> = TContract['roots'][RootName] extends {
|
|
163
|
+
readonly model: infer M extends string;
|
|
164
|
+
} ? M & keyof MongoModelsMap<TContract> : never;
|
|
165
|
+
type MongoTypeMaps<TCodecTypes extends Record<string, {
|
|
166
|
+
output: unknown;
|
|
167
|
+
}> = Record<string, {
|
|
168
|
+
output: unknown;
|
|
169
|
+
}>, TFieldOutputTypes extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TFieldInputTypes extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
|
|
170
|
+
readonly codecTypes: TCodecTypes;
|
|
171
|
+
readonly fieldOutputTypes: TFieldOutputTypes;
|
|
172
|
+
readonly fieldInputTypes: TFieldInputTypes;
|
|
173
|
+
};
|
|
174
|
+
type MongoTypeMapsPhantomKey = '__@prisma-next/mongo-core/typeMaps@__';
|
|
175
|
+
type MongoContractWithTypeMaps<TContract, TTypeMaps> = TContract & { readonly [K in MongoTypeMapsPhantomKey]?: TTypeMaps };
|
|
176
|
+
type ExtractMongoTypeMaps<T> = MongoTypeMapsPhantomKey extends keyof T ? NonNullable<T[MongoTypeMapsPhantomKey & keyof T]> : never;
|
|
177
|
+
type ExtractMongoCodecTypes<T> = ExtractMongoTypeMaps<T> extends {
|
|
178
|
+
codecTypes: infer C;
|
|
179
|
+
} ? C extends Record<string, {
|
|
180
|
+
output: unknown;
|
|
181
|
+
}> ? C : Record<string, never> : Record<string, never>;
|
|
182
|
+
type ExtractMongoFieldOutputTypes<T> = ExtractMongoTypeMaps<T> extends {
|
|
183
|
+
fieldOutputTypes: infer F;
|
|
184
|
+
} ? F extends Record<string, Record<string, unknown>> ? F : Record<string, never> : Record<string, never>;
|
|
185
|
+
type ExtractMongoFieldInputTypes<T> = ExtractMongoTypeMaps<T> extends {
|
|
186
|
+
fieldInputTypes: infer F;
|
|
187
|
+
} ? F extends Record<string, Record<string, unknown>> ? F : Record<string, never> : Record<string, never>;
|
|
188
|
+
/**
|
|
189
|
+
* The per-model field-output map at the contract's unbound namespace. The
|
|
190
|
+
* framework emitter nests `FieldOutputTypes` by namespace id
|
|
191
|
+
* (`{ [ns]: { [model]: { [field]: <refined> } } }`); Mongo is structurally
|
|
192
|
+
* single-namespace, so its refined rows resolve the per-model map under
|
|
193
|
+
* {@link UNBOUND_NAMESPACE_ID}. A map without that coordinate (e.g. a contract
|
|
194
|
+
* carrying no type maps) resolves to `never`, which the row resolvers read as
|
|
195
|
+
* "no refined map" and fall back to codec-based inference.
|
|
196
|
+
*/
|
|
197
|
+
type MongoUnboundFieldOutputTypes<T> = ExtractMongoFieldOutputTypes<T> extends Record<typeof UNBOUND_NAMESPACE_ID, infer Inner> ? Inner : never;
|
|
198
|
+
/** Input-side counterpart of {@link MongoUnboundFieldOutputTypes}. */
|
|
199
|
+
type MongoUnboundFieldInputTypes<T> = ExtractMongoFieldInputTypes<T> extends Record<typeof UNBOUND_NAMESPACE_ID, infer Inner> ? Inner : never;
|
|
200
|
+
type ExtractValueObjects<TContract extends Contract> = ContractValueObjectDefinitions<TContract>;
|
|
201
|
+
type NormalizeContractFields<TFields> = { [K in keyof TFields]: TFields[K] extends ContractField ? TFields[K] : never };
|
|
202
|
+
type ExtractValueObjectFields<TValueObjects extends Record<string, ContractValueObject>, VOName extends keyof TValueObjects> = NormalizeContractFields<TValueObjects[VOName]['fields']>;
|
|
203
|
+
type InferFieldBaseType<TFieldType, TValueObjects extends Record<string, ContractValueObject>, TCodecTypes extends Record<string, {
|
|
204
|
+
output: unknown;
|
|
205
|
+
}>> = TFieldType extends {
|
|
206
|
+
kind: 'scalar';
|
|
207
|
+
codecId: infer CId extends string & keyof TCodecTypes;
|
|
208
|
+
} ? TCodecTypes[CId]['output'] : TFieldType extends {
|
|
209
|
+
kind: 'valueObject';
|
|
210
|
+
name: infer VOName extends string;
|
|
211
|
+
} ? VOName extends keyof TValueObjects ? { -readonly [K in keyof ExtractValueObjectFields<TValueObjects, VOName>]: InferFieldType<ExtractValueObjectFields<TValueObjects, VOName>[K], TValueObjects, TCodecTypes> } : unknown : TFieldType extends {
|
|
212
|
+
kind: 'union';
|
|
213
|
+
members: infer TMembers extends ReadonlyArray<unknown>;
|
|
214
|
+
} ? TMembers[number] extends infer TMember ? InferFieldBaseType<TMember, TValueObjects, TCodecTypes> : unknown : unknown;
|
|
215
|
+
type InferFieldType<TField, TValueObjects extends Record<string, ContractValueObject>, TCodecTypes extends Record<string, {
|
|
216
|
+
output: unknown;
|
|
217
|
+
}>> = TField extends ContractField ? TField extends {
|
|
218
|
+
many: true;
|
|
219
|
+
} ? TField['nullable'] extends true ? InferFieldBaseType<TField['type'], TValueObjects, TCodecTypes>[] | null : InferFieldBaseType<TField['type'], TValueObjects, TCodecTypes>[] : TField['nullable'] extends true ? InferFieldBaseType<TField['type'], TValueObjects, TCodecTypes> | null : InferFieldBaseType<TField['type'], TValueObjects, TCodecTypes> : never;
|
|
220
|
+
type InferModelRow<TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>, ModelName extends string & keyof MongoModelsMap<TContract>, TFields extends Record<string, ContractField> = MongoModelsMap<TContract>[ModelName]['fields'], TCodecTypes extends Record<string, {
|
|
221
|
+
output: unknown;
|
|
222
|
+
}> = ExtractMongoCodecTypes<TContract>, TValueObjects extends Record<string, ContractValueObject> = ExtractValueObjects<TContract>> = { -readonly [FieldName in keyof TFields]: InferFieldType<TFields[FieldName], TValueObjects, TCodecTypes> };
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/ir/mongo-change-stream-pre-and-post-images-options.d.ts
|
|
225
|
+
interface MongoChangeStreamPreAndPostImagesOptionsInput {
|
|
226
|
+
readonly enabled: boolean;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Change-stream pre-and-post-images collection option. Lifted from a
|
|
230
|
+
* `type =` data shape to an AST class extending `IRNodeBase` per
|
|
231
|
+
* FR18. Single-field shape; the class exists for AST-pattern
|
|
232
|
+
* consistency (every nested data shape inside `MongoCollectionOptions`
|
|
233
|
+
* is an AST node so the verifier can walk uniformly).
|
|
234
|
+
*/
|
|
235
|
+
declare class MongoChangeStreamPreAndPostImagesOptions extends IRNodeBase {
|
|
236
|
+
readonly kind: "mongo-change-stream-pre-and-post-images-options";
|
|
237
|
+
readonly enabled: boolean;
|
|
238
|
+
constructor(options: MongoChangeStreamPreAndPostImagesOptionsInput);
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/ir/mongo-clustered-collection-options.d.ts
|
|
242
|
+
type MongoClusteredCollectionKey = Readonly<Record<string, 1>>;
|
|
243
|
+
interface MongoClusteredCollectionOptionsInput {
|
|
244
|
+
readonly name?: string;
|
|
245
|
+
readonly key: MongoClusteredCollectionKey;
|
|
246
|
+
readonly unique: boolean;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Clustered-collection options (the `clusteredIndex` collection-creation
|
|
250
|
+
* field). Lifted from a `type =` data shape to an AST class extending
|
|
251
|
+
* `IRNodeBase` per FR18.
|
|
252
|
+
*
|
|
253
|
+
* MongoDB requires `key` and `unique` for any clustered collection; the
|
|
254
|
+
* constructor enforces presence by type signature.
|
|
255
|
+
*/
|
|
256
|
+
declare class MongoClusteredCollectionOptions extends IRNodeBase {
|
|
257
|
+
readonly kind: "mongo-clustered-collection-options";
|
|
258
|
+
readonly name?: string;
|
|
259
|
+
readonly key: MongoClusteredCollectionKey;
|
|
260
|
+
readonly unique: boolean;
|
|
261
|
+
constructor(options: MongoClusteredCollectionOptionsInput);
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/ir/mongo-index-option-defaults.d.ts
|
|
265
|
+
interface MongoIndexOptionDefaultsInput {
|
|
266
|
+
readonly storageEngine?: MongoJsonObject;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Collection-level default index options (the `indexOptionDefaults`
|
|
270
|
+
* collection-creation field on Mongo's `createCollection`). Lifted from
|
|
271
|
+
* a `type =` data shape to an AST class extending `IRNodeBase` per
|
|
272
|
+
* FR18 (Mongo Contract IR fully unified under the AST-class pattern).
|
|
273
|
+
*
|
|
274
|
+
* Carries `storageEngine` only — the underlying MongoDB option set is
|
|
275
|
+
* intentionally narrow at this layer; per-engine richer option vocabularies
|
|
276
|
+
* are out of scope for this project.
|
|
277
|
+
*/
|
|
278
|
+
declare class MongoIndexOptionDefaults extends IRNodeBase {
|
|
279
|
+
readonly kind: "mongo-index-option-defaults";
|
|
280
|
+
readonly storageEngine?: MongoJsonObject;
|
|
281
|
+
constructor(options?: MongoIndexOptionDefaultsInput);
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/ir/mongo-time-series-collection-options.d.ts
|
|
285
|
+
type MongoTimeSeriesGranularity = 'seconds' | 'minutes' | 'hours';
|
|
286
|
+
interface MongoTimeSeriesCollectionOptionsInput {
|
|
287
|
+
readonly timeField: string;
|
|
288
|
+
readonly metaField?: string;
|
|
289
|
+
readonly granularity?: MongoTimeSeriesGranularity;
|
|
290
|
+
readonly bucketMaxSpanSeconds?: number;
|
|
291
|
+
readonly bucketRoundingSeconds?: number;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Time-series collection options. Lifted from a `type =` data shape to
|
|
295
|
+
* an AST class extending `IRNodeBase` per FR18.
|
|
296
|
+
*
|
|
297
|
+
* MongoDB requires `timeField` for any time-series collection; the
|
|
298
|
+
* constructor enforces presence by type signature (`timeField: string`
|
|
299
|
+
* is required on the input).
|
|
300
|
+
*/
|
|
301
|
+
declare class MongoTimeSeriesCollectionOptions extends IRNodeBase {
|
|
302
|
+
readonly kind: "mongo-time-series-collection-options";
|
|
303
|
+
readonly timeField: string;
|
|
304
|
+
readonly metaField?: string;
|
|
305
|
+
readonly granularity?: MongoTimeSeriesGranularity;
|
|
306
|
+
readonly bucketMaxSpanSeconds?: number;
|
|
307
|
+
readonly bucketRoundingSeconds?: number;
|
|
308
|
+
constructor(options: MongoTimeSeriesCollectionOptionsInput);
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/ir/mongo-collection-options.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* Storage-shape sub-shape: only `name` is persisted on the storage
|
|
314
|
+
* `clusteredIndex` field. The richer authoring vocabulary
|
|
315
|
+
* (`MongoClusteredCollectionOptions.key`, `…unique`) is intentionally
|
|
316
|
+
* not round-tripped through the on-disk JSON envelope — those fields
|
|
317
|
+
* are application-side configuration that informs collection creation
|
|
318
|
+
* but does not survive into the persisted collection options.
|
|
319
|
+
*/
|
|
320
|
+
interface MongoStorageClusteredIndexShape {
|
|
321
|
+
readonly name?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Storage-shape sub-shape: `capped` collections persist `size` (required)
|
|
325
|
+
* and optionally `max` document count. The authoring DSL surface uses a
|
|
326
|
+
* flat `capped: boolean` + separate `size` / `max` fields; builders
|
|
327
|
+
* translate that authoring vocabulary into this nested storage form
|
|
328
|
+
* before constructing {@link MongoCollectionOptions}.
|
|
329
|
+
*/
|
|
330
|
+
interface MongoStorageCappedShape {
|
|
331
|
+
readonly size: number;
|
|
332
|
+
readonly max?: number;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Hydration / construction input shape for {@link MongoCollectionOptions}.
|
|
336
|
+
* Mirrors the on-disk storage JSON envelope exactly (nested `capped`,
|
|
337
|
+
* `clusteredIndex`, …) so the family-base serializer's hydration walker
|
|
338
|
+
* can hand an arktype-validated object literal straight to `new`.
|
|
339
|
+
* Nested IR-class fields may be supplied as either plain data literals
|
|
340
|
+
* (typical for JSON-derived input) or already-constructed class
|
|
341
|
+
* instances (typical when re-wrapping during a partial walk).
|
|
342
|
+
*/
|
|
343
|
+
interface MongoCollectionOptionsInput {
|
|
344
|
+
readonly capped?: MongoStorageCappedShape;
|
|
345
|
+
readonly storageEngine?: MongoJsonObject;
|
|
346
|
+
readonly indexOptionDefaults?: MongoIndexOptionDefaults | MongoIndexOptionDefaultsInput;
|
|
347
|
+
readonly collation?: MongoCollationOptions | MongoCollationOptionsInput;
|
|
348
|
+
readonly timeseries?: MongoTimeSeriesCollectionOptions | MongoTimeSeriesCollectionOptionsInput;
|
|
349
|
+
readonly clusteredIndex?: MongoStorageClusteredIndexShape;
|
|
350
|
+
readonly expireAfterSeconds?: number;
|
|
351
|
+
readonly changeStreamPreAndPostImages?: MongoChangeStreamPreAndPostImagesOptions | MongoChangeStreamPreAndPostImagesOptionsInput;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Authoring-side flat vocabulary accepted by the contract-ts builder
|
|
355
|
+
* DSL (e.g. `capped: boolean` + separate `size` / `max` scalars). The
|
|
356
|
+
* builder translates this surface into a {@link MongoCollectionOptionsInput}
|
|
357
|
+
* before constructing {@link MongoCollectionOptions}. Kept as a
|
|
358
|
+
* standalone type so authoring DSL ergonomics do not leak into the
|
|
359
|
+
* storage IR construction contract.
|
|
360
|
+
*/
|
|
361
|
+
interface MongoCollectionOptionsAuthoringInput {
|
|
362
|
+
readonly capped?: boolean;
|
|
363
|
+
readonly size?: number;
|
|
364
|
+
readonly max?: number;
|
|
365
|
+
readonly storageEngine?: MongoJsonObject;
|
|
366
|
+
readonly indexOptionDefaults?: MongoIndexOptionDefaults | MongoIndexOptionDefaultsInput;
|
|
367
|
+
readonly collation?: MongoCollationOptions | MongoCollationOptionsInput;
|
|
368
|
+
readonly timeseries?: MongoTimeSeriesCollectionOptions | MongoTimeSeriesCollectionOptionsInput;
|
|
369
|
+
readonly clusteredIndex?: MongoClusteredCollectionOptions | MongoClusteredCollectionOptionsInput;
|
|
370
|
+
readonly expireAfterSeconds?: number;
|
|
371
|
+
readonly changeStreamPreAndPostImages?: MongoChangeStreamPreAndPostImagesOptions | MongoChangeStreamPreAndPostImagesOptionsInput;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Mongo Contract IR node for collection-level creation options (the
|
|
375
|
+
* second argument to `db.createCollection(name, options)`). Lifted from
|
|
376
|
+
* the pre-M2R2 `MongoStorageCollectionOptions` storage interface to a
|
|
377
|
+
* class extending `IRNodeBase` per FR18.
|
|
378
|
+
*
|
|
379
|
+
* Single concrete family-layer class (no target subclass). The
|
|
380
|
+
* constructor accepts the storage JSON envelope shape ({@link
|
|
381
|
+
* MongoCollectionOptionsInput}) so the family-base hydration walker
|
|
382
|
+
* can pass arktype-validated objects directly to `new`. Authoring
|
|
383
|
+
* vocabulary is translated to this shape upstream in the contract-ts
|
|
384
|
+
* builder.
|
|
385
|
+
*
|
|
386
|
+
* Nested IR sub-shapes (collation, timeseries, …) are normalised to
|
|
387
|
+
* their respective IR class instances inside the constructor so
|
|
388
|
+
* downstream walks see a uniform AST regardless of whether the input
|
|
389
|
+
* was a JSON literal or an already-constructed class.
|
|
390
|
+
*/
|
|
391
|
+
declare class MongoCollectionOptions extends IRNodeBase {
|
|
392
|
+
readonly kind: "mongo-collection-options";
|
|
393
|
+
readonly capped?: MongoStorageCappedShape;
|
|
394
|
+
readonly storageEngine?: MongoJsonObject;
|
|
395
|
+
readonly indexOptionDefaults?: MongoIndexOptionDefaults;
|
|
396
|
+
readonly collation?: MongoCollationOptions;
|
|
397
|
+
readonly timeseries?: MongoTimeSeriesCollectionOptions;
|
|
398
|
+
readonly clusteredIndex?: MongoStorageClusteredIndexShape;
|
|
399
|
+
readonly expireAfterSeconds?: number;
|
|
400
|
+
readonly changeStreamPreAndPostImages?: MongoChangeStreamPreAndPostImagesOptions;
|
|
401
|
+
constructor(input?: MongoCollectionOptionsInput);
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/ir/mongo-index.d.ts
|
|
405
|
+
/**
|
|
406
|
+
* Hydration / construction input shape for {@link MongoIndex}. Mirrors
|
|
407
|
+
* the on-disk storage JSON envelope exactly so the family-base
|
|
408
|
+
* serializer's hydration walker can hand an arktype-validated literal
|
|
409
|
+
* straight to `new`.
|
|
410
|
+
*/
|
|
411
|
+
interface MongoIndexInput {
|
|
412
|
+
readonly keys: ReadonlyArray<MongoIndexKey>;
|
|
413
|
+
readonly unique?: boolean;
|
|
414
|
+
readonly sparse?: boolean;
|
|
415
|
+
readonly expireAfterSeconds?: number;
|
|
416
|
+
readonly partialFilterExpression?: Record<string, unknown>;
|
|
417
|
+
readonly wildcardProjection?: Record<string, 0 | 1>;
|
|
418
|
+
readonly collation?: CollationOptions;
|
|
419
|
+
readonly weights?: Record<string, number>;
|
|
420
|
+
readonly default_language?: string;
|
|
421
|
+
readonly language_override?: string;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Mongo Contract IR node for a single collection index entry (one
|
|
425
|
+
* element of `MongoCollection.indexes`). Lifted from the
|
|
426
|
+
* pre-M2R2 `MongoStorageIndex` storage interface to a class extending
|
|
427
|
+
* `IRNodeBase` per FR18.
|
|
428
|
+
*
|
|
429
|
+
* Single concrete family-layer class (no target subclass). The spec's
|
|
430
|
+
* `MongoTargetIndex extends MongoIndex` pattern remains additive — a
|
|
431
|
+
* future Mongo target with target-specific index extensions is free to
|
|
432
|
+
* subclass; for the single Mongo target shipped today a concrete
|
|
433
|
+
* family-layer class is enough and avoids a target-import layering
|
|
434
|
+
* violation from the contract-ts builder.
|
|
435
|
+
*/
|
|
436
|
+
declare class MongoIndex extends IRNodeBase {
|
|
437
|
+
readonly kind: "mongo-index";
|
|
438
|
+
readonly keys: ReadonlyArray<MongoIndexKey>;
|
|
439
|
+
readonly unique?: boolean;
|
|
440
|
+
readonly sparse?: boolean;
|
|
441
|
+
readonly expireAfterSeconds?: number;
|
|
442
|
+
readonly partialFilterExpression?: Record<string, unknown>;
|
|
443
|
+
readonly wildcardProjection?: Record<string, 0 | 1>;
|
|
444
|
+
readonly collation?: CollationOptions;
|
|
445
|
+
readonly weights?: Record<string, number>;
|
|
446
|
+
readonly default_language?: string;
|
|
447
|
+
readonly language_override?: string;
|
|
448
|
+
constructor(input: MongoIndexInput);
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/ir/mongo-validator.d.ts
|
|
452
|
+
type MongoValidatorValidationLevel = 'strict' | 'moderate';
|
|
453
|
+
type MongoValidatorValidationAction = 'error' | 'warn';
|
|
454
|
+
interface MongoValidatorInput {
|
|
455
|
+
readonly jsonSchema: Record<string, unknown>;
|
|
456
|
+
readonly validationLevel: MongoValidatorValidationLevel;
|
|
457
|
+
readonly validationAction: MongoValidatorValidationAction;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Mongo Contract IR node for collection-level document validators (the
|
|
461
|
+
* `validator` field on Mongo's `createCollection`). Lifted from the
|
|
462
|
+
* pre-M2R2 `MongoStorageValidator` storage interface to a class extending
|
|
463
|
+
* `IRNodeBase` per FR18.
|
|
464
|
+
*
|
|
465
|
+
* Concrete at the family layer (no target subclass). The spec's
|
|
466
|
+
* abstract-family + target-concrete pattern (`MongoTargetValidator
|
|
467
|
+
* extends MongoValidator`) becomes meaningful when a second Mongo target
|
|
468
|
+
* introduces target-specific validator extensions (Atlas search rules,
|
|
469
|
+
* DocumentDB-specific levels, …); for the single Mongo target shipped
|
|
470
|
+
* today, a concrete family-layer class lets the PSL JSON-Schema deriver
|
|
471
|
+
* and the contract-ts builder construct instances directly without a
|
|
472
|
+
* target-import layering violation. Target subclassing remains additive
|
|
473
|
+
* — a future `MongoTargetValidator extends MongoValidator` is an
|
|
474
|
+
* additive change, not a breaking one.
|
|
475
|
+
*/
|
|
476
|
+
declare class MongoValidator extends IRNodeBase {
|
|
477
|
+
readonly kind: "mongo-validator";
|
|
478
|
+
readonly jsonSchema: Record<string, unknown>;
|
|
479
|
+
readonly validationLevel: MongoValidatorValidationLevel;
|
|
480
|
+
readonly validationAction: MongoValidatorValidationAction;
|
|
481
|
+
constructor(input: MongoValidatorInput);
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/ir/mongo-collection.d.ts
|
|
485
|
+
/**
|
|
486
|
+
* Hydration / construction input shape for {@link MongoCollection}.
|
|
487
|
+
* Mirrors the on-disk storage JSON envelope exactly (the value held at
|
|
488
|
+
* `contract.storage.namespaces[<namespaceId>].entries.collection[<name>]`) so the family-base
|
|
489
|
+
* serializer's hydration walker can hand an arktype-validated literal
|
|
490
|
+
* straight to `new`. Nested IR-class fields may be supplied as either
|
|
491
|
+
* plain data literals (typical for JSON-derived input) or
|
|
492
|
+
* already-constructed class instances.
|
|
493
|
+
*/
|
|
494
|
+
interface MongoCollectionInput {
|
|
495
|
+
readonly indexes?: ReadonlyArray<MongoIndex | MongoIndexInput>;
|
|
496
|
+
readonly validator?: MongoValidator | MongoValidatorInput;
|
|
497
|
+
readonly options?: MongoCollectionOptions | MongoCollectionOptionsInput;
|
|
498
|
+
readonly control?: ControlPolicy;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Mongo Contract IR node for a single collection entry in a namespace's
|
|
502
|
+
* `collections` map. Lifted from the pre-M2R2
|
|
503
|
+
* `MongoStorageCollection` storage interface to a class extending
|
|
504
|
+
* `IRNodeBase` per FR18.
|
|
505
|
+
*
|
|
506
|
+
* Concrete at the family layer (no target subclass). The spec's
|
|
507
|
+
* `MongoTargetCollection extends MongoCollection` pattern remains
|
|
508
|
+
* additive: a future Mongo target with target-specific extensions is
|
|
509
|
+
* free to subclass without breaking the family-layer construction
|
|
510
|
+
* sites.
|
|
511
|
+
*
|
|
512
|
+
* The unprefixed name `MongoCollection` is now the contract IR class.
|
|
513
|
+
* Note that `@prisma-next/mongo-orm` also exports a (different)
|
|
514
|
+
* `MongoCollection<TContract, ModelName>` generic for the user-facing
|
|
515
|
+
* ORM query builder; the two live in separate packages and are
|
|
516
|
+
* resolved by import path. A source file that needs both should alias
|
|
517
|
+
* one (e.g. `import { MongoCollection as MongoContractCollection }
|
|
518
|
+
* from '@prisma-next/mongo-contract'`).
|
|
519
|
+
*/
|
|
520
|
+
declare class MongoCollection extends IRNodeBase {
|
|
521
|
+
readonly kind: "mongo-collection";
|
|
522
|
+
readonly indexes?: ReadonlyArray<MongoIndex>;
|
|
523
|
+
readonly validator?: MongoValidator;
|
|
524
|
+
readonly options?: MongoCollectionOptions;
|
|
525
|
+
readonly control?: ControlPolicy;
|
|
526
|
+
constructor(input?: MongoCollectionInput);
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
529
|
+
export { MongoCollationMaxVariable as $, MongoContractWithTypeMaps as A, MongoModelStorage as B, MongoChangeStreamPreAndPostImagesOptionsInput as C, ExtractMongoTypeMaps as D, ExtractMongoFieldOutputTypes as E, MongoIndexKeyDirection as F, MongoUnboundFieldInputTypes as G, MongoStorageShape as H, MongoJsonObject as I, RootModelName as J, MongoUnboundFieldOutputTypes as K, MongoJsonPrimitive as L, MongoIndexFieldValue as M, MongoIndexFields as N, InferModelRow as O, MongoIndexKey as P, MongoCollationCaseFirst as Q, MongoJsonValue as R, MongoChangeStreamPreAndPostImagesOptions as S, ExtractMongoFieldInputTypes as T, MongoTypeMaps as U, MongoModelsMap as V, MongoTypeMapsPhantomKey as W, MongoIndexOptionsInput as X, MongoIndexOptions as Y, MongoCollationAlternate as Z, MongoIndexOptionDefaults as _, MongoValidatorValidationAction as a, MongoClusteredCollectionOptions as b, MongoIndexInput as c, MongoCollectionOptionsInput as d, MongoCollationOptions as et, MongoStorageCappedShape as f, MongoTimeSeriesGranularity as g, MongoTimeSeriesCollectionOptionsInput as h, MongoValidatorInput as i, MongoIndexAuthoringInput as j, MongoContract as k, MongoCollectionOptions as l, MongoTimeSeriesCollectionOptions as m, MongoCollectionInput as n, MongoCollationStrength as nt, MongoValidatorValidationLevel as o, MongoStorageClusteredIndexShape as p, MongoWildcardProjection as q, MongoValidator as r, MongoIndex as s, MongoCollection as t, MongoCollationOptionsInput as tt, MongoCollectionOptionsAuthoringInput as u, MongoIndexOptionDefaultsInput as v, ExtractMongoCodecTypes as w, MongoClusteredCollectionOptionsInput as x, MongoClusteredCollectionKey as y, MongoModelDefinition as z };
|
|
530
|
+
//# sourceMappingURL=mongo-collection-BCi-Bq_a.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-collection-BCi-Bq_a.d.mts","names":[],"sources":["../src/ir/mongo-collation-options.ts","../src/ir/mongo-index-options.ts","../src/contract-types.ts","../src/ir/mongo-change-stream-pre-and-post-images-options.ts","../src/ir/mongo-clustered-collection-options.ts","../src/ir/mongo-index-option-defaults.ts","../src/ir/mongo-time-series-collection-options.ts","../src/ir/mongo-collection-options.ts","../src/ir/mongo-index.ts","../src/ir/mongo-validator.ts","../src/ir/mongo-collection.ts"],"mappings":";;;;;KAEY,uBAAA;AAAA,KACA,sBAAA;AAAA,KACA,uBAAA;AAAA,KACA,yBAAA;AAHZ;;;;AAAmC;AACnC;;AADA,UAYiB,0BAAA;EAAA,SACN,MAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA,GAAY,uBAAA;EAAA,SACZ,QAAA,GAAW,sBAAA;EAAA,SACX,eAAA;EAAA,SACA,SAAA,GAAY,uBAAA;EAAA,SACZ,WAAA,GAAc,yBAAA;EAAA,SACd,SAAA;EAAA,SACA,aAAA;AAAA;;AAlB0B;AASrC;;;;;;;;;;;;cA0Ba,qBAAA,SAA8B,UAAA;EAAA,SAChC,IAAA;EAAA,SACA,MAAA;EAAA,SACQ,SAAA;EAAA,SACA,SAAA,GAAY,uBAAA;EAAA,SACZ,QAAA,GAAW,sBAAA;EAAA,SACX,eAAA;EAAA,SACA,SAAA,GAAY,uBAAA;EAAA,SACZ,WAAA,GAAc,yBAAA;EAAA,SACd,SAAA;EAAA,SACA,aAAA;cAEL,OAAA,EAAS,0BAAA;AAAA;;;;;AAlDvB;;;;UCQiB,sBAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,uBAAA,GAA0B,eAAA;EAAA,SAC1B,MAAA;EAAA,SACA,kBAAA;EAAA,SACA,OAAA,GAAU,QAAA,CAAS,MAAA;EAAA,SACnB,gBAAA;EAAA,SACA,iBAAA;EAAA,SACA,gBAAA;EAAA,SACA,sBAAA;EAAA,SACA,IAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA,GAAY,qBAAA,GAAwB,0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iB,oBAAA;EAAA,SACN,OAAA,GAAU,aAAA,CAAc,UAAA,GAAa,eAAA;EAAA,SACrC,SAAA,GAAY,cAAA,GAAiB,mBAAA;EAAA,SAC7B,OAAA,GAAU,sBAAA,GAAyB,2BAAA;EAAA,SACnC,OAAA,GAAU,aAAA;AAAA;AVjBrB;;;;AAAqC;AASrC;;;;;;;;;;;;;;;AATA,cUwCa,eAAA,SAAwB,UAAA;EAAA,SAC1B,IAAA;EAAA,SACQ,OAAA,GAAU,aAAA,CAAc,UAAA;EAAA,SACxB,SAAA,GAAY,cAAA;EAAA,SACZ,OAAA,GAAU,sBAAA;EAAA,SACV,OAAA,GAAU,aAAA;cAEf,KAAA,GAAO,oBAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-contract",
|
|
3
|
-
"version": "0.13.0-dev.
|
|
3
|
+
"version": "0.13.0-dev.35",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Contract types and validation for Prisma Next MongoDB support",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.13.0-dev.
|
|
10
|
-
"@prisma-next/framework-components": "0.13.0-dev.
|
|
11
|
-
"@prisma-next/mongo-value": "0.13.0-dev.
|
|
12
|
-
"@prisma-next/utils": "0.13.0-dev.
|
|
9
|
+
"@prisma-next/contract": "0.13.0-dev.35",
|
|
10
|
+
"@prisma-next/framework-components": "0.13.0-dev.35",
|
|
11
|
+
"@prisma-next/mongo-value": "0.13.0-dev.35",
|
|
12
|
+
"@prisma-next/utils": "0.13.0-dev.35",
|
|
13
13
|
"arktype": "^2.2.0",
|
|
14
14
|
"mongodb": "^7.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@prisma-next/test-utils": "0.13.0-dev.
|
|
18
|
-
"@prisma-next/tsconfig": "0.13.0-dev.
|
|
19
|
-
"@prisma-next/tsdown": "0.13.0-dev.
|
|
17
|
+
"@prisma-next/test-utils": "0.13.0-dev.35",
|
|
18
|
+
"@prisma-next/tsconfig": "0.13.0-dev.35",
|
|
19
|
+
"@prisma-next/tsdown": "0.13.0-dev.35",
|
|
20
20
|
"tsdown": "0.22.1",
|
|
21
21
|
"typescript": "5.9.3",
|
|
22
22
|
"vitest": "4.1.8"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"exports": {
|
|
38
38
|
".": "./dist/index.mjs",
|
|
39
39
|
"./canonicalization-hooks": "./dist/canonicalization-hooks.mjs",
|
|
40
|
+
"./entity-kinds": "./dist/entity-kinds.mjs",
|
|
40
41
|
"./package.json": "./package.json"
|
|
41
42
|
},
|
|
42
43
|
"engines": {
|
package/src/contract-schema.ts
CHANGED
|
@@ -312,7 +312,7 @@ const MongoCollectionOptionsSchema = type({
|
|
|
312
312
|
'clusteredIndex?': ClusteredIndexSchema,
|
|
313
313
|
});
|
|
314
314
|
|
|
315
|
-
const StorageCollectionSchema = type({
|
|
315
|
+
export const StorageCollectionSchema = type({
|
|
316
316
|
'+': 'reject',
|
|
317
317
|
'kind?': "'mongo-collection'",
|
|
318
318
|
'indexes?': MongoStorageIndexSchema.array(),
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyEntityKindDescriptor,
|
|
3
|
+
EntityKindDescriptor,
|
|
4
|
+
} from '@prisma-next/framework-components/ir';
|
|
5
|
+
import { StorageCollectionSchema } from './contract-schema';
|
|
6
|
+
import { MongoCollection, type MongoCollectionInput } from './ir/mongo-collection';
|
|
7
|
+
|
|
8
|
+
export const collectionEntityKind: EntityKindDescriptor<MongoCollectionInput, MongoCollection> = {
|
|
9
|
+
kind: 'collection',
|
|
10
|
+
schema: StorageCollectionSchema,
|
|
11
|
+
construct: (input) => new MongoCollection(input),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Assembles the `kind → descriptor` registry for Mongo namespaces: the built-in
|
|
16
|
+
* `collection` kind plus any target `packKinds`. This builds the lookup table —
|
|
17
|
+
* it does not touch contract data. `hydrateNamespaceEntities` later consumes
|
|
18
|
+
* this registry to turn a namespace's raw entries into IR instances. Throws on
|
|
19
|
+
* a duplicate kind.
|
|
20
|
+
*/
|
|
21
|
+
export function composeMongoEntityKinds(
|
|
22
|
+
packKinds: readonly AnyEntityKindDescriptor[] = [],
|
|
23
|
+
): ReadonlyMap<string, AnyEntityKindDescriptor> {
|
|
24
|
+
const kinds = new Map<string, AnyEntityKindDescriptor>([['collection', collectionEntityKind]]);
|
|
25
|
+
for (const descriptor of packKinds) {
|
|
26
|
+
if (kinds.has(descriptor.kind)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`composeMongoEntityKinds: duplicate entity kind "${descriptor.kind}" — each kind may be registered only once`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
kinds.set(descriptor.kind, descriptor);
|
|
32
|
+
}
|
|
33
|
+
return kinds;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { collectionEntityKind, composeMongoEntityKinds } from '../entity-kinds';
|