@prisma-next/mongo-query-builder 0.12.0-dev.6 → 0.12.0-dev.61

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.
@@ -0,0 +1,586 @@
1
+ import { MongoAggAccumulator, MongoAggExpr, MongoFilterExpr, MongoUpdatePipelineStage } from "@prisma-next/mongo-query-ast/execution";
2
+ import { ContractValueObjectDefinitions } from "@prisma-next/contract/types";
3
+ import { MongoValue } from "@prisma-next/mongo-value";
4
+ import { ExtractMongoTypeMaps, InferModelRow, MongoContract, MongoContractWithTypeMaps, MongoModelsMap, MongoTypeMaps } from "@prisma-next/mongo-contract";
5
+
6
+ //#region src/types.d.ts
7
+ interface DocField {
8
+ readonly codecId: string;
9
+ readonly nullable: boolean;
10
+ }
11
+ type NumericField = {
12
+ readonly codecId: 'mongo/double@1';
13
+ readonly nullable: false;
14
+ };
15
+ type NullableNumericField = {
16
+ readonly codecId: 'mongo/double@1';
17
+ readonly nullable: true;
18
+ };
19
+ type StringField = {
20
+ readonly codecId: 'mongo/string@1';
21
+ readonly nullable: false;
22
+ };
23
+ type ArrayField = {
24
+ readonly codecId: 'mongo/array@1';
25
+ readonly nullable: false;
26
+ };
27
+ type BooleanField = {
28
+ readonly codecId: 'mongo/bool@1';
29
+ readonly nullable: false;
30
+ };
31
+ type DateField = {
32
+ readonly codecId: 'mongo/date@1';
33
+ readonly nullable: false;
34
+ };
35
+ type NullableDocField = {
36
+ readonly codecId: string;
37
+ readonly nullable: true;
38
+ };
39
+ type LiteralValue<F extends DocField> = F extends StringField ? string : F extends NumericField ? number : F extends BooleanField ? boolean : F extends DateField ? Date : unknown;
40
+ type DocShape = Record<string, DocField>;
41
+ type ExtractCodecId<F> = F extends {
42
+ type: {
43
+ kind: 'scalar';
44
+ codecId: infer C;
45
+ };
46
+ } ? C : F extends {
47
+ codecId: infer C extends string;
48
+ } ? C : string;
49
+ type ModelToDocShape<TContract extends MongoContract, ModelName extends string & keyof MongoModelsMap<TContract>> = { [K in keyof MongoModelsMap<TContract>[ModelName]['fields'] & string]: {
50
+ readonly codecId: ExtractCodecId<MongoModelsMap<TContract>[ModelName]['fields'][K]>;
51
+ readonly nullable: MongoModelsMap<TContract>[ModelName]['fields'][K]['nullable'];
52
+ } } & ModelOriginBranded<ModelName>;
53
+ /**
54
+ * Per-field resolver. Walks `Shape`'s string keys, routing
55
+ * `ModelArrayField` (the lookup marker) through `InferModelRow` and
56
+ * everything else through the codec-lookup branch.
57
+ *
58
+ * Internal helper — public callers should use `ResolveRow`, which adds
59
+ * the model-origin brand detection on top.
60
+ */
61
+ type ResolveFields<Shape extends DocShape, CodecTypes extends Record<string, {
62
+ readonly output: unknown;
63
+ }>, TContract extends MongoContract> = { -readonly [K in keyof Shape & string]: Shape[K] extends ModelArrayField<infer ModelName> ? IsConcreteContract<TContract> extends true ? TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps> ? ModelName extends string & keyof MongoModelsMap<TContract> ? Array<InferModelRow<TContract, ModelName>> : unknown[] : unknown[] : unknown[] : Shape[K]['codecId'] extends keyof CodecTypes ? Shape[K]['nullable'] extends true ? CodecTypes[Shape[K]['codecId']]['output'] | null : CodecTypes[Shape[K]['codecId']]['output'] : unknown };
64
+ /**
65
+ * Resolve a `DocShape` to a concrete row object type.
66
+ *
67
+ * The optional `TContract` parameter exists so the resolver can:
68
+ *
69
+ * 1. Detect the `ModelOriginBrand` on `Shape` — the phantom symbol
70
+ * placed by `ModelToDocShape`. When present (and the contract has
71
+ * type maps), the row is resolved via `InferModelRow<TC, M>` from
72
+ * `@prisma-next/mongo-contract`, which walks scalar / valueObject /
73
+ * union field kinds (handling nested value-objects and `many: true`).
74
+ * This makes entry-point reads (`q.from('users').build()`) and
75
+ * shape-extending stages (`match`, `addFields`) resolve value-object
76
+ * fields to their concrete nested types instead of `unknown`.
77
+ *
78
+ * 2. Detect the per-field `ModelArrayField<ModelName>` marker produced
79
+ * by `lookup()` and resolve it to `Array<InferModelRow<TC, M>>` so
80
+ * lookup rows carry the same fully-typed foreign rows.
81
+ *
82
+ * When the contract is not threaded through (or lacks the type-map
83
+ * phantom), both branches fall back to `unknown` / `unknown[]` —
84
+ * preserving the legacy resolver shape for call sites that do not need
85
+ * model-row resolution.
86
+ */
87
+ /**
88
+ * Flatten an intersection `A & B` into a single object literal so callers
89
+ * (and `expectTypeOf().toEqualTypeOf<…>()`) see one homogeneous record
90
+ * rather than the intersection form. Vitest's strict equality check
91
+ * treats `A & B` as distinct from the structurally-equivalent flat
92
+ * record, even when assignability is bidirectional, so the
93
+ * `ResolveRow` brand-positive branch normalises its result through this.
94
+ */
95
+ type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
96
+ /**
97
+ * Decide whether to route a brand-positive `ResolveRow` through
98
+ * `InferModelRow`. The default `MongoContract` (no concrete models)
99
+ * still satisfies `MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>`
100
+ * because the phantom key is optional, but `InferModelRow<MongoContract, …>`
101
+ * collapses to an empty/unknown row. Gate on the presence of the
102
+ * type-maps phantom: a concrete contract attaches concrete `TestTypeMaps`-
103
+ * shaped maps, while the default `MongoContract` has no phantom and
104
+ * `ExtractMongoTypeMaps` resolves to `never`.
105
+ */
106
+ type IsConcreteContract<TContract> = [ExtractMongoTypeMaps<TContract>] extends [never] ? false : true;
107
+ type ResolveRow<Shape extends DocShape, CodecTypes extends Record<string, {
108
+ readonly output: unknown;
109
+ }>, TContract extends MongoContract = MongoContract> = Shape extends {
110
+ readonly [ModelOriginBrand]?: infer ModelName extends string;
111
+ } ? IsConcreteContract<TContract> extends true ? TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps> ? ModelName extends string & keyof MongoModelsMap<TContract> ? Flatten<InferModelRow<TContract, ModelName> & Omit<ResolveFields<Shape, CodecTypes, TContract>, keyof InferModelRow<TContract, ModelName>>> : ResolveFields<Shape, CodecTypes, TContract> : ResolveFields<Shape, CodecTypes, TContract> : ResolveFields<Shape, CodecTypes, TContract> : ResolveFields<Shape, CodecTypes, TContract>;
112
+ interface TypedAggExpr<F extends DocField> {
113
+ readonly _field: F;
114
+ readonly node: MongoAggExpr;
115
+ }
116
+ interface TypedAccumulatorExpr<F extends DocField> {
117
+ readonly _field: F;
118
+ readonly node: MongoAggAccumulator;
119
+ }
120
+ type ExtractDocShape<T extends Record<string, TypedAggExpr<DocField>>> = { [K in keyof T & string]: T[K]['_field'] };
121
+ type SortSpec<S extends DocShape> = Partial<Record<keyof S & string, 1 | -1>>;
122
+ type ProjectedShape<Shape extends DocShape, Spec extends Record<string, 1 | TypedAggExpr<DocField>>> = { [K in keyof Spec & string]: Spec[K] extends 1 ? K extends keyof Shape ? Shape[K] : DocField : Spec[K] extends TypedAggExpr<infer F> ? F : DocField } & ('_id' extends keyof Shape ? '_id' extends keyof Spec ? Record<keyof never, never> : Pick<Shape, '_id'> : Record<keyof never, never>);
123
+ type GroupSpec = {
124
+ _id: TypedAggExpr<DocField> | null;
125
+ [key: string]: TypedAggExpr<DocField> | TypedAccumulatorExpr<DocField> | null;
126
+ };
127
+ type GroupedDocShape<Spec extends GroupSpec> = { [K in keyof Spec & string]: Spec[K] extends TypedAggExpr<infer F> ? F : Spec[K] extends TypedAccumulatorExpr<infer F> ? F : Spec[K] extends null ? {
128
+ readonly codecId: 'mongo/null@1';
129
+ readonly nullable: true;
130
+ } : DocField };
131
+ /**
132
+ * Intentionally identity — full array element type extraction is deferred.
133
+ * Used by `UnwoundShape` so the unwind result shape can be refined later
134
+ * without changing the public API.
135
+ */
136
+ type UnwrapArrayDocField<F extends DocField> = F;
137
+ /**
138
+ * `$unwind` reshapes the array slot but leaves the rest of the document
139
+ * structurally intact. The mapped iteration is keyed on `keyof S & string`,
140
+ * which discards the symbol-keyed `ModelOriginBrand` carried by
141
+ * model-rooted shapes. Preserve the brand explicitly so post-unwind
142
+ * `ResolveRow` still routes through `InferModelRow` and value-object
143
+ * fields keep their concrete nested types.
144
+ */
145
+ type UnwoundShape<S extends DocShape, K extends keyof S & string> = { [P in keyof S & string]: P extends K ? UnwrapArrayDocField<S[P]> : S[P] } & (S extends ModelOriginBranded<infer ModelName extends string> ? ModelOriginBranded<ModelName> : unknown);
146
+ //#endregion
147
+ //#region src/resolve-path.d.ts
148
+ /**
149
+ * Marker `DocField` variant representing a non-leaf (value-object) path in
150
+ * a [NestedDocShape]. Extends `DocField` with a `fields` property carrying
151
+ * the sub-shape so the pipeline builder can recurse into it.
152
+ *
153
+ * `codecId` is the reserved literal `'prisma/object@1'`; the accessor's
154
+ * runtime implementation does not serialize it — the codec id is a purely
155
+ * type-level sentinel used by `Expression<F>` to select the reduced
156
+ * operator surface for non-leaf paths.
157
+ *
158
+ * `nullable` tracks whether the value object itself may be absent/null on
159
+ * the parent document. The callable form currently does not propagate the
160
+ * parent's `nullable` flag onto leaves beneath it (path traversal under a
161
+ * nullable parent resolves to the leaf's own `nullable` — matching how
162
+ * MongoDB treats missing intermediate documents).
163
+ */
164
+ interface ObjectField<N extends NestedDocShape> extends DocField {
165
+ readonly codecId: 'prisma/object@1';
166
+ readonly nullable: boolean;
167
+ readonly fields: N;
168
+ }
169
+ /**
170
+ * Marker `DocField` variant representing "an array of foreign-model rows"
171
+ * — the result of a `$lookup` whose foreign side was selected via the
172
+ * typed `col` accessor. `ModelName` is the literal foreign model name
173
+ * (e.g. `'User'`), preserved in the type so `ResolveRow` can resolve the
174
+ * field to `ResolveRow<ModelToDocShape<TC, ModelName>, …>[]` rather than
175
+ * the opaque `unknown[]` produced by the legacy `mongo/array@1` sentinel.
176
+ *
177
+ * Like `ObjectField`, the codec id is a purely type-level sentinel —
178
+ * there is no runtime codec entry for `'prisma/modelArray@1'`. The
179
+ * surrounding pipeline emits the standard `MongoLookupStage` whose
180
+ * runtime shape is unchanged; the marker exists solely to thread the
181
+ * foreign element type through the result-row resolver.
182
+ */
183
+ interface ModelArrayField<ModelName extends string> extends DocField {
184
+ readonly codecId: 'prisma/modelArray@1';
185
+ readonly nullable: false;
186
+ readonly model: ModelName;
187
+ }
188
+ /**
189
+ * Phantom-symbol brand placed on `ModelToDocShape`'s output (and inherited
190
+ * through shape-extending stages like `addFields`, `match`, `lookup`) so
191
+ * `ResolveRow` can route value-object resolution through `InferModelRow`
192
+ * — which walks the contract's `valueObjects` registry and resolves
193
+ * nested types — instead of falling through the codec-lookup branch to
194
+ * `unknown`.
195
+ *
196
+ * The brand is keyed on a `unique symbol` rather than a string so it is
197
+ * invisible to every `keyof Shape & string` walk in the package
198
+ * (`SortSpec`, `ProjectedShape`, `GroupedDocShape`, the field accessor's
199
+ * `Object.keys` iteration, etc.). Field accessors do not surface a
200
+ * `__modelOrigin` autocomplete entry; sorts cannot key on it; projections
201
+ * cannot reference it.
202
+ *
203
+ * Shape-extending stages preserve the brand because intersection types
204
+ * (`Shape & NewFields`) carry through symbol-keyed properties. Shape-
205
+ * replacing stages (`replaceRoot`, `group`, `project`) construct fresh
206
+ * `DocShape`s from scratch, naturally dropping the brand — which is the
207
+ * intended behaviour, since those stages legitimately leave model
208
+ * territory.
209
+ */
210
+ declare const ModelOriginBrand: unique symbol;
211
+ type ModelOriginBrand = typeof ModelOriginBrand;
212
+ /**
213
+ * Brand carrier — a Shape whose row type should be resolved via
214
+ * `InferModelRow<TContract, ModelName>` rather than the per-field codec
215
+ * walk. Use as `ModelToDocShape<TC, ModelName> & ModelOriginBranded<ModelName>`.
216
+ */
217
+ type ModelOriginBranded<ModelName extends string> = {
218
+ readonly [ModelOriginBrand]?: ModelName;
219
+ };
220
+ /**
221
+ * Document shape that carries nested value-object sub-shapes.
222
+ *
223
+ * Structurally identical to a flat `DocShape` (`Record<string, DocField>`),
224
+ * but individual values may be `ObjectField<SubShape>` carrying a nested
225
+ * `NestedDocShape` sub-tree. The pipeline builder threads a
226
+ * `NestedDocShape` alongside the flat `DocShape` so the callable
227
+ * `f('a.b.c')` form can validate dot-paths at the type level.
228
+ *
229
+ * When a stage transforms the root shape in a way that invalidates nested
230
+ * paths (e.g. `$group`, `$project`, `$replaceRoot`), the thread is reset
231
+ * to the empty shape `Record<string, never>` — which makes `ValidPaths`
232
+ * resolve to `never` and so disables the callable form downstream.
233
+ */
234
+ type NestedDocShape = Record<string, DocField>;
235
+ type FieldToLeaf<F> = F extends {
236
+ readonly type: {
237
+ readonly kind: 'scalar';
238
+ readonly codecId: infer C extends string;
239
+ };
240
+ readonly nullable: infer N extends boolean;
241
+ } ? {
242
+ readonly codecId: C;
243
+ readonly nullable: N;
244
+ } : F extends {
245
+ readonly many: true;
246
+ readonly nullable: infer N extends boolean;
247
+ } ? {
248
+ readonly codecId: 'mongo/array@1';
249
+ readonly nullable: N;
250
+ } : DocField;
251
+ /**
252
+ * Translate a single contract field to its nested-shape form. Scalars
253
+ * become `DocField` leaves; value-object fields become
254
+ * `ObjectField<Sub>`; `many: true` stops at a leaf; anything else falls
255
+ * through to the opaque `DocField` base.
256
+ *
257
+ * Kept as a per-field helper (rather than a `Fields → NestedShape` helper
258
+ * that maps over keys internally) so the parent mapped type stays
259
+ * homomorphic over the model/value-object `fields` record. Homomorphic
260
+ * mapped types preserve the literal keys of their source object through
261
+ * TypeScript's intersection-collapsing machinery, which keeps
262
+ * `ModelNestedShape` hover output and `keyof`/indexed-access resolution
263
+ * concrete instead of collapsing to `{ [x: string]: … }`.
264
+ */
265
+ type TranslateField<TContract extends MongoContract, F> = F extends {
266
+ readonly many: true;
267
+ } ? FieldToLeaf<F> : F extends {
268
+ readonly type: {
269
+ readonly kind: 'valueObject';
270
+ readonly name: infer VOName extends string;
271
+ };
272
+ readonly nullable: infer Null extends boolean;
273
+ } ? ObjectField<VONestedShape<TContract, VOName>> & {
274
+ readonly nullable: Null;
275
+ } : F extends {
276
+ readonly type: {
277
+ readonly kind: 'scalar';
278
+ readonly codecId: string;
279
+ };
280
+ } ? FieldToLeaf<F> : DocField;
281
+ /**
282
+ * Resolve a named value object from the contract into its own
283
+ * `NestedDocShape`. The mapped iteration is inlined here (not delegated
284
+ * to a generic helper) so that the homomorphism over
285
+ * `VOs[VOName]['fields']` is preserved and the hover / indexed-access
286
+ * surface stays concrete at instantiation time.
287
+ */
288
+ type VONestedShape<TContract extends MongoContract, VOName extends string> = [ContractValueObjectDefinitions<TContract>] extends [infer VOs extends Record<string, {
289
+ readonly fields: Record<string, unknown>;
290
+ }>] ? VOName extends keyof VOs & string ? { readonly [K in keyof VOs[VOName]['fields'] & string]: TranslateField<TContract, VOs[VOName]['fields'][K]> } : never : never;
291
+ /**
292
+ * Build the `NestedDocShape` for a model. Scalar leaves resolve to their
293
+ * concrete codec id; value-object fields recurse into the referenced
294
+ * `valueObjects[VOName].fields` table, producing a tree that
295
+ * `ResolvePath` / `ValidPaths` can walk.
296
+ *
297
+ * The mapped iteration is inlined (not hidden behind a helper type that
298
+ * takes `Fields` as a generic) so TypeScript recognises the mapped type
299
+ * as homomorphic over `MongoModelsMap<TContract>[ModelName]['fields']`. That
300
+ * preserves the literal field-name keys at instantiation — without this,
301
+ * the intersection of `Record<string, ContractField>` and the specific
302
+ * literal field record collapses `keyof` to `string` and the result hover
303
+ * degrades to `{ readonly [x: string]: any }`.
304
+ */
305
+ type ModelNestedShape<TContract extends MongoContract, ModelName extends string & keyof MongoModelsMap<TContract>> = { readonly [K in keyof MongoModelsMap<TContract>[ModelName]['fields'] & string]: TranslateField<TContract, MongoModelsMap<TContract>[ModelName]['fields'][K]> };
306
+ /**
307
+ * Resolve a dot-path against a `NestedDocShape`. Returns:
308
+ * - the leaf `DocField` when `Path` terminates on a scalar/array leaf,
309
+ * - the `ObjectField<Sub>` when `Path` terminates on a value object (so
310
+ * the caller can operate on the whole sub-document),
311
+ * - `never` when the path is invalid (unknown segment, or a scalar
312
+ * segment followed by further traversal).
313
+ *
314
+ * Paired with the constrained callable `<P extends ValidPaths<N>>(path: P)
315
+ * => Expression<ResolvePath<N, P>>` so the IDE offers completions and
316
+ * rejects bad paths with a clear error instead of silently resolving to
317
+ * `never`.
318
+ */
319
+ type ResolvePath<N extends NestedDocShape, Path extends string> = Path extends `${infer Head}.${infer Rest}` ? Head extends keyof N & string ? N[Head] extends ObjectField<infer Sub> ? ResolvePath<Sub, Rest> : never : never : Path extends keyof N & string ? N[Path] : never;
320
+ /**
321
+ * Union of every valid dot-path within a `NestedDocShape`. Includes
322
+ * top-level keys (scalar leaves *and* value-object roots) and every
323
+ * recursive descent through `ObjectField` sub-shapes.
324
+ *
325
+ * Non-leaf paths are intentionally included — `f('address')` yields an
326
+ * `Expression<ObjectField<…>>` whose reduced operator surface (`set`,
327
+ * `unset`, `exists`, `eq(null)`, `ne(null)`) lets callers operate on the
328
+ * whole value object. Leaf paths like `f('address.city')` get the full
329
+ * leaf operator surface.
330
+ *
331
+ * The `string extends keyof N` guard short-circuits to `never` for
332
+ * open-ended index-signature shapes (e.g. the default
333
+ * `Record<string, never>` used to represent "no nested information" —
334
+ * notably downstream of replacement stages in the pipeline builder). An
335
+ * open-ended `keyof` cannot resolve a specific literal path, so the
336
+ * callable form must be disabled at the type level.
337
+ */
338
+ type ValidPaths<N extends NestedDocShape> = string extends keyof N ? never : { [K in keyof N & string]: N[K] extends ObjectField<infer Sub> ? K | `${K}.${ValidPaths<Sub>}` : K }[keyof N & string];
339
+ /**
340
+ * IDE-oriented alias for `ValidPaths`. Kept as a separate export so future
341
+ * refinements (e.g. ArkType-style lazy expansion for very deep shapes) can
342
+ * diverge from the strict `ValidPaths` constraint without breaking
343
+ * downstream consumers. For now the two are intentionally equivalent.
344
+ */
345
+ type PathCompletions<N extends NestedDocShape> = ValidPaths<N>;
346
+ //#endregion
347
+ //#region src/update-ops.d.ts
348
+ /**
349
+ * Per-field update operations produced by `Expression`'s update methods
350
+ * (`set`, `inc`, `push`, …). A write terminal folds an array of these into a
351
+ * `MongoUpdateSpec` record (`{ $set: { … }, $inc: { … }, … }`) before
352
+ * constructing the underlying `UpdateManyCommand` / `UpdateOneCommand` AST node.
353
+ *
354
+ * One `TypedUpdateOp` value corresponds to one Mongo update operator applied
355
+ * to one field path. The `op` string is the wire-level operator name (`$set`,
356
+ * `$inc`, …); the `path` is the dot-path to the field (or its top-level name).
357
+ */
358
+ type TypedUpdateOp = {
359
+ readonly op: '$set';
360
+ readonly path: string;
361
+ readonly value: MongoValue;
362
+ } | {
363
+ readonly op: '$unset';
364
+ readonly path: string;
365
+ } | {
366
+ readonly op: '$rename';
367
+ readonly path: string;
368
+ readonly newName: string;
369
+ } | {
370
+ readonly op: '$inc';
371
+ readonly path: string;
372
+ readonly amount: number;
373
+ } | {
374
+ readonly op: '$mul';
375
+ readonly path: string;
376
+ readonly factor: number;
377
+ } | {
378
+ readonly op: '$min';
379
+ readonly path: string;
380
+ readonly value: MongoValue;
381
+ } | {
382
+ readonly op: '$max';
383
+ readonly path: string;
384
+ readonly value: MongoValue;
385
+ } | {
386
+ readonly op: '$push';
387
+ readonly path: string;
388
+ readonly value: MongoValue;
389
+ } | {
390
+ readonly op: '$addToSet';
391
+ readonly path: string;
392
+ readonly value: MongoValue;
393
+ } | {
394
+ readonly op: '$pop';
395
+ readonly path: string;
396
+ readonly direction: 1 | -1;
397
+ } | {
398
+ readonly op: '$pull';
399
+ readonly path: string;
400
+ readonly value: MongoValue;
401
+ } | {
402
+ readonly op: '$pullAll';
403
+ readonly path: string;
404
+ readonly values: ReadonlyArray<MongoValue>;
405
+ } | {
406
+ readonly op: '$currentDate';
407
+ readonly path: string;
408
+ } | {
409
+ readonly op: '$setOnInsert';
410
+ readonly path: string;
411
+ readonly value: MongoValue;
412
+ };
413
+ /**
414
+ * The return type for updater callbacks. Typed as a union of homogeneous
415
+ * arrays so mixed-shape updaters (operator + pipeline stage in the same
416
+ * array) are a compile error. The runtime guard in `resolveUpdaterResult`
417
+ * remains as defence-in-depth.
418
+ */
419
+ type UpdaterResult = ReadonlyArray<TypedUpdateOp> | ReadonlyArray<MongoUpdatePipelineStage>;
420
+ //#endregion
421
+ //#region src/field-accessor.d.ts
422
+ /**
423
+ * Operator surface for leaf (scalar) paths — today's full set: filter,
424
+ * update, and aggregation operators. Returned by `Expression<F>` for any
425
+ * `F extends DocField` that is not an `ObjectField<…>` sub-tree.
426
+ *
427
+ * Operator surfaces are intentionally not trait-gated by codec in this
428
+ * revision — tracked on Linear as TML-2259 (scope extended to cover the
429
+ * query-builder's `Expression<F>`). Calling, e.g. `.inc(1)` on a
430
+ * string-typed expression compiles; the runtime relies on Mongo to
431
+ * surface the error. Trait-gating can be tightened in a follow-up
432
+ * without changing the accessor's public shape.
433
+ */
434
+ interface LeafExpression<F extends DocField> extends TypedAggExpr<F> {
435
+ readonly _path: string;
436
+ eq(value: MongoValue): MongoFilterExpr;
437
+ ne(value: MongoValue): MongoFilterExpr;
438
+ gt(value: MongoValue): MongoFilterExpr;
439
+ gte(value: MongoValue): MongoFilterExpr;
440
+ lt(value: MongoValue): MongoFilterExpr;
441
+ lte(value: MongoValue): MongoFilterExpr;
442
+ in(values: ReadonlyArray<MongoValue>): MongoFilterExpr;
443
+ nin(values: ReadonlyArray<MongoValue>): MongoFilterExpr;
444
+ exists(flag?: boolean): MongoFilterExpr;
445
+ /**
446
+ * `$type` filter: `{ field: { $type: bsonType } }`. Rides
447
+ * `MongoFieldFilter`'s generic `op` string — no dedicated AST node. The
448
+ * BSON type is expressed as Mongo's alias string (e.g. `'string'`) or
449
+ * numeric type code; an array selects any of several types.
450
+ */
451
+ type(bsonType: MongoValue): MongoFilterExpr;
452
+ set(value: MongoValue): TypedUpdateOp;
453
+ unset(): TypedUpdateOp;
454
+ rename(newName: string): TypedUpdateOp;
455
+ inc(amount: number): TypedUpdateOp;
456
+ mul(factor: number): TypedUpdateOp;
457
+ min(value: MongoValue): TypedUpdateOp;
458
+ max(value: MongoValue): TypedUpdateOp;
459
+ push(value: MongoValue): TypedUpdateOp;
460
+ addToSet(value: MongoValue): TypedUpdateOp;
461
+ pop(direction?: 1 | -1): TypedUpdateOp;
462
+ pull(value: MongoValue): TypedUpdateOp;
463
+ pullAll(values: ReadonlyArray<MongoValue>): TypedUpdateOp;
464
+ currentDate(): TypedUpdateOp;
465
+ setOnInsert(value: MongoValue): TypedUpdateOp;
466
+ }
467
+ /**
468
+ * Operator surface for non-leaf (value-object) paths — `f('address')`
469
+ * when `address` is a `ContractValueObject`. Intentionally minimal: the
470
+ * whole-value ops that make sense on a structured sub-document
471
+ * (`set`/`unset`/`exists`, null presence via `eq(null)`/`ne(null)`). Field-
472
+ * level ops belong on the constituent leaves (`f('address.city')`).
473
+ *
474
+ * The aggregation `node` is still present (`TypedAggExpr<ObjectField<N>>`)
475
+ * so the value object can be piped through `$addFields` /
476
+ * `$replaceRoot` / etc. as-is.
477
+ */
478
+ interface ObjectExpression<N extends NestedDocShape> extends TypedAggExpr<ObjectField<N>> {
479
+ readonly _path: string;
480
+ exists(flag?: boolean): MongoFilterExpr;
481
+ eq(value: null): MongoFilterExpr;
482
+ ne(value: null): MongoFilterExpr;
483
+ set(value: MongoValue): TypedUpdateOp;
484
+ unset(): TypedUpdateOp;
485
+ }
486
+ /**
487
+ * The unified field accessor expression returned by `FieldAccessor` (per
488
+ * [ADR 180](../../../../docs/architecture%20docs/adrs/ADR%20180%20-%20Dot-path%20field%20accessor.md)).
489
+ *
490
+ * Resolves to `ObjectExpression<Sub>` when `F` is an `ObjectField<Sub>`
491
+ * (non-leaf path), otherwise to `LeafExpression<F>` (the full operator
492
+ * surface). The conditional is driven off the `fields` marker that
493
+ * `ObjectField` adds to `DocField`, so existing code that uses plain
494
+ * `DocField` shapes continues to resolve to `LeafExpression`.
495
+ */
496
+ type Expression<F extends DocField> = F extends ObjectField<infer N> ? ObjectExpression<N> : LeafExpression<F>;
497
+ /**
498
+ * Emitters for MongoDB update-pipeline stages (`$addFields`/`$set`,
499
+ * `$project`/`$unset`, `$replaceRoot`/`$replaceWith`). These return
500
+ * `MongoUpdatePipelineStage` nodes and let an updater callback express
501
+ * the pipeline-form update as an alternative to the typed-operator form.
502
+ *
503
+ * The two forms are mutually exclusive per updater call: `resolveUpdaterResult`
504
+ * rejects arrays that mix `TypedUpdateOp` and `MongoUpdatePipelineStage`
505
+ * entries with a clear error — an updater callback must return either all
506
+ * typed ops or all pipeline stages. Pick the form that matches the update
507
+ * you want and commit to it for that call site.
508
+ *
509
+ * Accessible via `f.stage` on the `FieldAccessor`.
510
+ */
511
+ interface StageEmitters {
512
+ set(fields: Record<string, MongoAggExpr>): MongoUpdatePipelineStage;
513
+ unset(...paths: ReadonlyArray<string>): MongoUpdatePipelineStage;
514
+ replaceRoot(newRoot: MongoAggExpr): MongoUpdatePipelineStage;
515
+ replaceWith(newRoot: MongoAggExpr): MongoUpdatePipelineStage;
516
+ }
517
+ /**
518
+ * The unified `FieldAccessor` per ADR 180.
519
+ *
520
+ * - Property access (`f.status`) returns an `Expression<F>` whose codec
521
+ * comes from the current pipeline shape `S`.
522
+ * - Callable form (`f('address.city')`) returns an `Expression<ResolvePath<N, P>>`
523
+ * where `N` is the nested shape carrying value-object sub-shapes.
524
+ * Paths that don't exist in `N` are rejected with a compile-time error
525
+ * (via `P extends ValidPaths<N>`). Non-leaf paths like `f('address')`
526
+ * resolve to an `ObjectExpression` whose reduced surface covers the
527
+ * whole-value operations (`set`, `unset`, `exists`, `eq(null)`,
528
+ * `ne(null)`).
529
+ * - `f.rawPath('path')` is a deliberate escape hatch that skips path
530
+ * validation and returns a `LeafExpression<F>` for the given string.
531
+ * Intended for migration authoring where the target field is not yet
532
+ * part of the typed contract (e.g. a backfill writing a newly-added
533
+ * column before the contract hash rolls forward). The method name is
534
+ * deliberately `rawPath` rather than `raw` so it does not shadow a
535
+ * legitimate top-level `raw` field on a user model.
536
+ * - `f.stage` exposes pipeline-style update emitters (`$set`, `$unset`,
537
+ * `$replaceRoot`, `$replaceWith`).
538
+ *
539
+ * When `N` is `Record<string, never>` (the default — e.g. after a
540
+ * replacement stage like `$group` / `$project` / `$replaceRoot`),
541
+ * `ValidPaths<N>` is `never` and the callable form is effectively
542
+ * disabled at the type level. This keeps the builder sound downstream of
543
+ * stages that invalidate the original document's nested-path tree.
544
+ * `f.rawPath(...)` remains available in that state for callers that need
545
+ * an explicit unvalidated path.
546
+ */
547
+ type FieldAccessor<S extends DocShape, N extends NestedDocShape = Record<string, never>> = { readonly [K in keyof S & string]: Expression<S[K]> } & (<P extends ValidPaths<N>>(path: P) => Expression<ResolvePath<N, P>>) & {
548
+ readonly stage: StageEmitters;
549
+ /**
550
+ * Escape hatch: build a `LeafExpression<F>` for an unvalidated string
551
+ * path. Use only when the path is intentionally outside the typed
552
+ * model surface — data-migration authoring is the canonical case
553
+ * (e.g. backfilling a field that is not yet in the contract). Default
554
+ * `F` is the opaque `DocField`; callers can narrow via the explicit
555
+ * generic: `f.rawPath<StringField>("status").set("active")`.
556
+ *
557
+ * The method is named `rawPath` (not `raw`) so a user model with a
558
+ * top-level `raw` field still resolves `f.raw` to the field-expression
559
+ * property, not to this escape hatch. Does not participate in
560
+ * `ValidPaths<N>` / `ResolvePath<N, P>` — the path is passed through
561
+ * verbatim and no IDE autocomplete is offered.
562
+ */
563
+ rawPath<F extends DocField = DocField>(path: string): LeafExpression<F>;
564
+ };
565
+ /**
566
+ * Wrap a boolean aggregation expression as an `$expr` filter
567
+ * (`MongoExprFilter`). Lets a `$match` express an aggregation-expression
568
+ * predicate — e.g. comparing two field references via `fn.eq(a, b)` — in
569
+ * the typed AST rather than via a raw escape hatch. Pairs with `.type()`
570
+ * to express filters like `{ _id: { $type: 'string' }, $expr: { $eq: ['$_id', '$space'] } }`.
571
+ */
572
+ declare function expr(predicate: TypedAggExpr<DocField>): MongoFilterExpr;
573
+ /**
574
+ * Construct a unified `FieldAccessor<S, N>` proxy. Property access creates
575
+ * an `Expression` using the property name as the field path; callable
576
+ * form accepts a dot-path string validated against `N` at compile time.
577
+ *
578
+ * The proxy target is a function so the resulting object is both callable
579
+ * and indexable. Symbol-keyed accesses (e.g. `Symbol.toPrimitive`) return
580
+ * `undefined` to keep accidental coercion behaviour unsurprising —
581
+ * matching the previous `FieldProxy` / `FilterProxy` semantics.
582
+ */
583
+ declare function createFieldAccessor<S extends DocShape, N extends NestedDocShape = Record<string, never>>(): FieldAccessor<S, N>;
584
+ //#endregion
585
+ export { ResolveRow as A, GroupedDocShape as C, NullableNumericField as D, NullableDocField as E, UnwoundShape as F, StringField as M, TypedAccumulatorExpr as N, NumericField as O, TypedAggExpr as P, GroupSpec as S, ModelToDocShape as T, BooleanField as _, createFieldAccessor as a, DocShape as b, UpdaterResult as c, NestedDocShape as d, ObjectField as f, ArrayField as g, ValidPaths as h, ObjectExpression as i, SortSpec as j, ProjectedShape as k, ModelArrayField as l, ResolvePath as m, FieldAccessor as n, expr as o, PathCompletions as p, LeafExpression as r, TypedUpdateOp as s, Expression as t, ModelNestedShape as u, DateField as v, LiteralValue as w, ExtractDocShape as x, DocField as y };
586
+ //# sourceMappingURL=field-accessor-BmcQj0lD.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-accessor-BmcQj0lD.d.mts","names":[],"sources":["../src/types.ts","../src/resolve-path.ts","../src/update-ops.ts","../src/field-accessor.ts"],"mappings":";;;;;;UAWiB,QAAA;EAAA,SACN,OAAA;EAAA,SACA,QAAQ;AAAA;AAAA,KAGP,YAAA;EAAA,SAA0B,OAAA;EAAA,SAAoC,QAAQ;AAAA;AAAA,KACtE,oBAAA;EAAA,SAAkC,OAAA;EAAA,SAAoC,QAAQ;AAAA;AAAA,KAC9E,WAAA;EAAA,SAAyB,OAAA;EAAA,SAAoC,QAAQ;AAAA;AAAA,KACrE,UAAA;EAAA,SAAwB,OAAA;EAAA,SAAmC,QAAQ;AAAA;AAAA,KACnE,YAAA;EAAA,SAA0B,OAAA;EAAA,SAAkC,QAAQ;AAAA;AAAA,KACpE,SAAA;EAAA,SAAuB,OAAA;EAAA,SAAkC,QAAQ;AAAA;AAAA,KACjE,gBAAA;EAAA,SAA8B,OAAA;EAAA,SAA0B,QAAQ;AAAA;AAAA,KAEhE,YAAA,WAAuB,QAAA,IAAY,CAAA,SAAU,WAAA,YAErD,CAAA,SAAU,YAAA,YAER,CAAA,SAAU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