import { Document, MongoValue } from "@prisma-next/mongo-value"; import { QueryPlan } from "@prisma-next/framework-components/runtime"; //#region src/ast-node.d.ts declare abstract class MongoAstNode { abstract readonly kind: string; protected freeze(): void; } //#endregion //#region src/stages.d.ts type MongoGroupId = null | MongoAggExpr | Readonly>; type MongoProjectionValue = 0 | 1 | MongoAggExpr; declare abstract class MongoStageNode extends MongoAstNode { abstract accept(visitor: MongoStageVisitor): R; abstract rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoMatchStage extends MongoStageNode { readonly kind: "match"; readonly filter: MongoFilterExpr; constructor(filter: MongoFilterExpr); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoProjectStage extends MongoStageNode { readonly kind: "project"; readonly projection: Readonly>; constructor(projection: Record); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSortStage extends MongoStageNode { readonly kind: "sort"; readonly sort: Readonly>; constructor(sort: Record); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoLimitStage extends MongoStageNode { readonly kind: "limit"; readonly limit: number; constructor(limit: number); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSkipStage extends MongoStageNode { readonly kind: "skip"; readonly skip: number; constructor(skip: number); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoLookupStage extends MongoStageNode { readonly kind: "lookup"; readonly from: string; readonly localField: string | undefined; readonly foreignField: string | undefined; readonly as: string; readonly pipeline: ReadonlyArray | undefined; readonly let_: Readonly> | undefined; constructor(options: { from: string; localField?: string; foreignField?: string; as: string; pipeline?: ReadonlyArray; let_?: Record; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoUnwindStage extends MongoStageNode { readonly kind: "unwind"; readonly path: string; readonly preserveNullAndEmptyArrays: boolean; readonly includeArrayIndex: string | undefined; constructor(path: string, preserveNullAndEmptyArrays: boolean, includeArrayIndex?: string); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoGroupStage extends MongoStageNode { readonly kind: "group"; readonly groupId: MongoGroupId; readonly accumulators: Readonly>; constructor(groupId: MongoGroupId, accumulators: Record); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoAddFieldsStage extends MongoStageNode { readonly kind: "addFields"; readonly fields: Readonly>; constructor(fields: Record); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoReplaceRootStage extends MongoStageNode { readonly kind: "replaceRoot"; readonly newRoot: MongoAggExpr; constructor(newRoot: MongoAggExpr); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoCountStage extends MongoStageNode { readonly kind: "count"; readonly field: string; constructor(field: string); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSortByCountStage extends MongoStageNode { readonly kind: "sortByCount"; readonly expr: MongoAggExpr; constructor(expr: MongoAggExpr); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSampleStage extends MongoStageNode { readonly kind: "sample"; readonly size: number; constructor(size: number); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoRedactStage extends MongoStageNode { readonly kind: "redact"; readonly expr: MongoAggExpr; constructor(expr: MongoAggExpr); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoOutStage extends MongoStageNode { readonly kind: "out"; readonly collection: string; readonly db: string | undefined; constructor(collection: string, db?: string); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoUnionWithStage extends MongoStageNode { readonly kind: "unionWith"; readonly collection: string; readonly pipeline: ReadonlyArray | undefined; constructor(collection: string, pipeline?: ReadonlyArray); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoBucketStage extends MongoStageNode { readonly kind: "bucket"; readonly groupBy: MongoAggExpr; readonly boundaries: ReadonlyArray; readonly default_: unknown; readonly output: Readonly> | undefined; constructor(options: { groupBy: MongoAggExpr; boundaries: ReadonlyArray; default_?: unknown; output?: Record; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoBucketAutoStage extends MongoStageNode { readonly kind: "bucketAuto"; readonly groupBy: MongoAggExpr; readonly buckets: number; readonly output: Readonly> | undefined; readonly granularity: string | undefined; constructor(options: { groupBy: MongoAggExpr; buckets: number; output?: Record; granularity?: string; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoGeoNearStage extends MongoStageNode { readonly kind: "geoNear"; readonly near: unknown; readonly distanceField: string; readonly spherical: boolean | undefined; readonly maxDistance: number | undefined; readonly minDistance: number | undefined; readonly query: MongoFilterExpr | undefined; readonly key: string | undefined; readonly distanceMultiplier: number | undefined; readonly includeLocs: string | undefined; constructor(options: { near: unknown; distanceField: string; spherical?: boolean; maxDistance?: number; minDistance?: number; query?: MongoFilterExpr; key?: string; distanceMultiplier?: number; includeLocs?: string; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoFacetStage extends MongoStageNode { readonly kind: "facet"; readonly facets: Readonly>>; constructor(facets: Record>); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoGraphLookupStage extends MongoStageNode { readonly kind: "graphLookup"; readonly from: string; readonly startWith: MongoAggExpr; readonly connectFromField: string; readonly connectToField: string; readonly as: string; readonly maxDepth: number | undefined; readonly depthField: string | undefined; readonly restrictSearchWithMatch: MongoFilterExpr | undefined; constructor(options: { from: string; startWith: MongoAggExpr; connectFromField: string; connectToField: string; as: string; maxDepth?: number; depthField?: string; restrictSearchWithMatch?: MongoFilterExpr; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoMergeStage extends MongoStageNode { readonly kind: "merge"; readonly into: string | { readonly db: string; readonly coll: string; }; readonly on: string | ReadonlyArray | undefined; readonly whenMatched: string | ReadonlyArray | undefined; readonly whenNotMatched: string | undefined; constructor(options: { into: string | { db: string; coll: string; }; on?: string | ReadonlyArray; whenMatched?: string | ReadonlyArray; whenNotMatched?: string; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } interface MongoWindowField { readonly operator: MongoAggExpr; readonly window?: { readonly documents?: readonly [number, number]; readonly range?: { readonly start: unknown; readonly end: unknown; readonly unit?: string; }; }; } declare class MongoSetWindowFieldsStage extends MongoStageNode { readonly kind: "setWindowFields"; readonly partitionBy: MongoAggExpr | undefined; readonly sortBy: Readonly> | undefined; readonly output: Readonly>; constructor(options: { partitionBy?: MongoAggExpr; sortBy?: Record; output: Record; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } interface MongoDensifyRange { readonly step: number; readonly unit?: string; readonly bounds: 'full' | 'partition' | readonly [unknown, unknown]; } declare class MongoDensifyStage extends MongoStageNode { readonly kind: "densify"; readonly field: string; readonly partitionByFields: ReadonlyArray | undefined; readonly range: MongoDensifyRange; constructor(options: { field: string; partitionByFields?: ReadonlyArray; range: MongoDensifyRange; }); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } interface MongoFillOutput { readonly method?: string; readonly value?: MongoAggExpr; } declare class MongoFillStage extends MongoStageNode { readonly kind: "fill"; readonly partitionBy: MongoAggExpr | undefined; readonly partitionByFields: ReadonlyArray | undefined; readonly sortBy: Readonly> | undefined; readonly output: Readonly>; constructor(options: { partitionBy?: MongoAggExpr; partitionByFields?: ReadonlyArray; sortBy?: Record; output: Record; }); accept(visitor: MongoStageVisitor): R; rewrite(context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSearchStage extends MongoStageNode { readonly kind: "search"; readonly index: string | undefined; readonly config: Readonly>; constructor(config: Record, index?: string); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoSearchMetaStage extends MongoStageNode { readonly kind: "searchMeta"; readonly index: string | undefined; readonly config: Readonly>; constructor(config: Record, index?: string); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } declare class MongoVectorSearchStage extends MongoStageNode { readonly kind: "vectorSearch"; readonly index: string; readonly path: string; readonly queryVector: ReadonlyArray; readonly numCandidates: number; readonly limit: number; readonly filter: Readonly> | undefined; constructor(options: { index: string; path: string; queryVector: ReadonlyArray; numCandidates: number; limit: number; filter?: Record; }); accept(visitor: MongoStageVisitor): R; rewrite(_context: MongoStageRewriterContext): MongoPipelineStage; } type MongoUpdatePipelineStage = MongoAddFieldsStage | MongoProjectStage | MongoReplaceRootStage; type MongoPipelineStage = MongoMatchStage | MongoProjectStage | MongoSortStage | MongoLimitStage | MongoSkipStage | MongoLookupStage | MongoUnwindStage | MongoGroupStage | MongoAddFieldsStage | MongoReplaceRootStage | MongoCountStage | MongoSortByCountStage | MongoSampleStage | MongoRedactStage | MongoOutStage | MongoUnionWithStage | MongoBucketStage | MongoBucketAutoStage | MongoGeoNearStage | MongoFacetStage | MongoGraphLookupStage | MongoMergeStage | MongoSetWindowFieldsStage | MongoDensifyStage | MongoFillStage | MongoSearchStage | MongoSearchMetaStage | MongoVectorSearchStage; //#endregion //#region src/visitors.d.ts interface MongoAggExprVisitor { fieldRef(expr: MongoAggFieldRef): R; literal(expr: MongoAggLiteral): R; operator(expr: MongoAggOperator): R; accumulator(expr: MongoAggAccumulator): R; cond(expr: MongoAggCond): R; switch_(expr: MongoAggSwitch): R; filter(expr: MongoAggArrayFilter): R; map(expr: MongoAggMap): R; reduce(expr: MongoAggReduce): R; let_(expr: MongoAggLet): R; mergeObjects(expr: MongoAggMergeObjects): R; } interface MongoAggExprRewriter { fieldRef?(expr: MongoAggFieldRef): MongoAggExpr; literal?(expr: MongoAggLiteral): MongoAggExpr; operator?(expr: MongoAggOperator): MongoAggExpr; accumulator?(expr: MongoAggAccumulator): MongoAggExpr; cond?(expr: MongoAggCond): MongoAggExpr; switch_?(expr: MongoAggSwitch): MongoAggExpr; filter?(expr: MongoAggArrayFilter): MongoAggExpr; map?(expr: MongoAggMap): MongoAggExpr; reduce?(expr: MongoAggReduce): MongoAggExpr; let_?(expr: MongoAggLet): MongoAggExpr; mergeObjects?(expr: MongoAggMergeObjects): MongoAggExpr; } interface MongoFilterVisitor { field(expr: MongoFieldFilter): R; and(expr: MongoAndExpr): R; or(expr: MongoOrExpr): R; not(expr: MongoNotExpr): R; exists(expr: MongoExistsExpr): R; expr(expr: MongoExprFilter): R; } interface MongoFilterRewriter { field?(expr: MongoFieldFilter): MongoFilterExpr; and?(expr: MongoAndExpr): MongoFilterExpr; or?(expr: MongoOrExpr): MongoFilterExpr; not?(expr: MongoNotExpr): MongoFilterExpr; exists?(expr: MongoExistsExpr): MongoFilterExpr; expr?(expr: MongoExprFilter): MongoFilterExpr; } interface MongoStageRewriterContext { filter?: MongoFilterRewriter; aggExpr?: MongoAggExprRewriter; } interface MongoStageVisitor { match(stage: MongoMatchStage): R; project(stage: MongoProjectStage): R; sort(stage: MongoSortStage): R; limit(stage: MongoLimitStage): R; skip(stage: MongoSkipStage): R; lookup(stage: MongoLookupStage): R; unwind(stage: MongoUnwindStage): R; group(stage: MongoGroupStage): R; addFields(stage: MongoAddFieldsStage): R; replaceRoot(stage: MongoReplaceRootStage): R; count(stage: MongoCountStage): R; sortByCount(stage: MongoSortByCountStage): R; sample(stage: MongoSampleStage): R; redact(stage: MongoRedactStage): R; out(stage: MongoOutStage): R; unionWith(stage: MongoUnionWithStage): R; bucket(stage: MongoBucketStage): R; bucketAuto(stage: MongoBucketAutoStage): R; geoNear(stage: MongoGeoNearStage): R; facet(stage: MongoFacetStage): R; graphLookup(stage: MongoGraphLookupStage): R; merge(stage: MongoMergeStage): R; setWindowFields(stage: MongoSetWindowFieldsStage): R; densify(stage: MongoDensifyStage): R; fill(stage: MongoFillStage): R; search(stage: MongoSearchStage): R; searchMeta(stage: MongoSearchMetaStage): R; vectorSearch(stage: MongoVectorSearchStage): R; } //#endregion //#region src/aggregation-expressions.d.ts type AggRecordArgs = Readonly>>; declare function isExprArray(args: MongoAggExpr | ReadonlyArray | AggRecordArgs): args is ReadonlyArray; declare function isRecordArgs(args: MongoAggExpr | ReadonlyArray | AggRecordArgs): args is AggRecordArgs; declare abstract class MongoAggExprNode extends MongoAstNode { abstract accept(visitor: MongoAggExprVisitor): R; abstract rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggFieldRef extends MongoAggExprNode { readonly kind: "fieldRef"; readonly path: string; constructor(path: string); static of(path: string): MongoAggFieldRef; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggLiteral extends MongoAggExprNode { readonly kind: "literal"; readonly value: unknown; constructor(value: unknown); static of(value: unknown): MongoAggLiteral; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggOperator extends MongoAggExprNode { readonly kind: "operator"; readonly op: string; readonly args: MongoAggExpr | ReadonlyArray | AggRecordArgs; constructor(op: string, args: MongoAggExpr | ReadonlyArray | AggRecordArgs); static of(op: string, args: MongoAggExpr | ReadonlyArray | AggRecordArgs): MongoAggOperator; static add(...args: ReadonlyArray): MongoAggOperator; static subtract(left: MongoAggExpr, right: MongoAggExpr): MongoAggOperator; static multiply(...args: ReadonlyArray): MongoAggOperator; static divide(dividend: MongoAggExpr, divisor: MongoAggExpr): MongoAggOperator; static concat(...args: ReadonlyArray): MongoAggOperator; static toLower(expr: MongoAggExpr): MongoAggOperator; static toUpper(expr: MongoAggExpr): MongoAggOperator; static size(expr: MongoAggExpr): MongoAggOperator; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggAccumulator extends MongoAggExprNode { readonly kind: "accumulator"; readonly op: string; readonly arg: MongoAggExpr | AggRecordArgs | null; constructor(op: string, arg: MongoAggExpr | AggRecordArgs | null); static of(op: string, arg: MongoAggExpr | AggRecordArgs | null): MongoAggAccumulator; static sum(expr: MongoAggExpr): MongoAggAccumulator; static avg(expr: MongoAggExpr): MongoAggAccumulator; static min(expr: MongoAggExpr): MongoAggAccumulator; static max(expr: MongoAggExpr): MongoAggAccumulator; static first(expr: MongoAggExpr): MongoAggAccumulator; static last(expr: MongoAggExpr): MongoAggAccumulator; static push(expr: MongoAggExpr): MongoAggAccumulator; static addToSet(expr: MongoAggExpr): MongoAggAccumulator; static count(): MongoAggAccumulator; static stdDevPop(expr: MongoAggExpr): MongoAggAccumulator; static stdDevSamp(expr: MongoAggExpr): MongoAggAccumulator; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggCond extends MongoAggExprNode { readonly kind: "cond"; readonly condition: MongoAggExpr; readonly then_: MongoAggExpr; readonly else_: MongoAggExpr; constructor(condition: MongoAggExpr, then_: MongoAggExpr, else_: MongoAggExpr); static of(condition: MongoAggExpr, then_: MongoAggExpr, else_: MongoAggExpr): MongoAggCond; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } interface MongoAggSwitchBranch { readonly case_: MongoAggExpr; readonly then_: MongoAggExpr; } declare class MongoAggSwitch extends MongoAggExprNode { readonly kind: "switch"; readonly branches: ReadonlyArray; readonly default_: MongoAggExpr; constructor(branches: ReadonlyArray, default_: MongoAggExpr); static of(branches: ReadonlyArray, default_: MongoAggExpr): MongoAggSwitch; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggArrayFilter extends MongoAggExprNode { readonly kind: "filter"; readonly input: MongoAggExpr; readonly cond: MongoAggExpr; readonly as: string; constructor(input: MongoAggExpr, cond: MongoAggExpr, as: string); static of(input: MongoAggExpr, cond: MongoAggExpr, as: string): MongoAggArrayFilter; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggMap extends MongoAggExprNode { readonly kind: "map"; readonly input: MongoAggExpr; readonly in_: MongoAggExpr; readonly as: string; constructor(input: MongoAggExpr, in_: MongoAggExpr, as: string); static of(input: MongoAggExpr, in_: MongoAggExpr, as: string): MongoAggMap; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggReduce extends MongoAggExprNode { readonly kind: "reduce"; readonly input: MongoAggExpr; readonly initialValue: MongoAggExpr; readonly in_: MongoAggExpr; constructor(input: MongoAggExpr, initialValue: MongoAggExpr, in_: MongoAggExpr); static of(input: MongoAggExpr, initialValue: MongoAggExpr, in_: MongoAggExpr): MongoAggReduce; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggLet extends MongoAggExprNode { readonly kind: "let"; readonly vars: Readonly>; readonly in_: MongoAggExpr; constructor(vars: Record, in_: MongoAggExpr); static of(vars: Record, in_: MongoAggExpr): MongoAggLet; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } declare class MongoAggMergeObjects extends MongoAggExprNode { readonly kind: "mergeObjects"; readonly exprs: ReadonlyArray; constructor(exprs: ReadonlyArray); static of(exprs: ReadonlyArray): MongoAggMergeObjects; accept(visitor: MongoAggExprVisitor): R; rewrite(rewriter: MongoAggExprRewriter): MongoAggExpr; } type MongoAggExpr = MongoAggFieldRef | MongoAggLiteral | MongoAggOperator | MongoAggAccumulator | MongoAggCond | MongoAggSwitch | MongoAggArrayFilter | MongoAggMap | MongoAggReduce | MongoAggLet | MongoAggMergeObjects; //#endregion //#region src/filter-expressions.d.ts declare function isMongoFilterExpr(value: unknown): value is MongoFilterExpr; declare abstract class MongoFilterExpression extends MongoAstNode { abstract accept(visitor: MongoFilterVisitor): R; abstract rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; not(this: MongoFilterExpr): MongoNotExpr; and(this: MongoFilterExpr, other: MongoFilterExpr): MongoAndExpr; } declare class MongoFieldFilter extends MongoFilterExpression { readonly kind: "field"; readonly field: string; readonly op: string; readonly value: MongoValue; constructor(field: string, op: string, value: MongoValue); static of(field: string, op: string, value: MongoValue): MongoFieldFilter; static eq(field: string, value: MongoValue): MongoFieldFilter; static neq(field: string, value: MongoValue): MongoFieldFilter; static gt(field: string, value: MongoValue): MongoFieldFilter; static lt(field: string, value: MongoValue): MongoFieldFilter; static gte(field: string, value: MongoValue): MongoFieldFilter; static lte(field: string, value: MongoValue): MongoFieldFilter; static in(field: string, values: ReadonlyArray): MongoFieldFilter; static nin(field: string, values: ReadonlyArray): MongoFieldFilter; static isNull(field: string): MongoFieldFilter; static isNotNull(field: string): MongoFieldFilter; accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } declare class MongoAndExpr extends MongoFilterExpression { readonly kind: "and"; readonly exprs: ReadonlyArray; constructor(exprs: ReadonlyArray); static of(exprs: ReadonlyArray): MongoAndExpr; accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } declare class MongoOrExpr extends MongoFilterExpression { readonly kind: "or"; readonly exprs: ReadonlyArray; constructor(exprs: ReadonlyArray); static of(exprs: ReadonlyArray): MongoOrExpr; accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } declare class MongoNotExpr extends MongoFilterExpression { readonly kind: "not"; readonly expr: MongoFilterExpr; constructor(expr: MongoFilterExpr); accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } declare class MongoExistsExpr extends MongoFilterExpression { readonly kind: "exists"; readonly field: string; readonly exists: boolean; constructor(field: string, exists: boolean); static exists(field: string): MongoExistsExpr; static notExists(field: string): MongoExistsExpr; accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } declare class MongoExprFilter extends MongoFilterExpression { readonly kind: "expr"; readonly aggExpr: MongoAggExpr; constructor(aggExpr: MongoAggExpr); static of(aggExpr: MongoAggExpr): MongoExprFilter; accept(visitor: MongoFilterVisitor): R; rewrite(rewriter: MongoFilterRewriter): MongoFilterExpr; } type MongoFilterExpr = MongoFieldFilter | MongoAndExpr | MongoOrExpr | MongoNotExpr | MongoExistsExpr | MongoExprFilter; //#endregion //#region src/raw-commands.d.ts declare class RawAggregateCommand extends MongoAstNode { readonly kind: "rawAggregate"; readonly collection: string; readonly pipeline: ReadonlyArray; constructor(collection: string, pipeline: ReadonlyArray); } declare class RawInsertOneCommand extends MongoAstNode { readonly kind: "rawInsertOne"; readonly collection: string; readonly document: Document; constructor(collection: string, document: Document); } declare class RawInsertManyCommand extends MongoAstNode { readonly kind: "rawInsertMany"; readonly collection: string; readonly documents: ReadonlyArray; constructor(collection: string, documents: ReadonlyArray); } declare class RawUpdateOneCommand extends MongoAstNode { readonly kind: "rawUpdateOne"; readonly collection: string; readonly filter: Document; readonly update: Document | ReadonlyArray; constructor(collection: string, filter: Document, update: Document | ReadonlyArray); } declare class RawUpdateManyCommand extends MongoAstNode { readonly kind: "rawUpdateMany"; readonly collection: string; readonly filter: Document; readonly update: Document | ReadonlyArray; constructor(collection: string, filter: Document, update: Document | ReadonlyArray); } declare class RawDeleteOneCommand extends MongoAstNode { readonly kind: "rawDeleteOne"; readonly collection: string; readonly filter: Document; constructor(collection: string, filter: Document); } declare class RawDeleteManyCommand extends MongoAstNode { readonly kind: "rawDeleteMany"; readonly collection: string; readonly filter: Document; constructor(collection: string, filter: Document); } declare class RawFindOneAndUpdateCommand extends MongoAstNode { readonly kind: "rawFindOneAndUpdate"; readonly collection: string; readonly filter: Document; readonly update: Document | ReadonlyArray; readonly upsert: boolean; readonly sort: Record | undefined; /** * When `undefined`, the option is omitted from the wire command and the * MongoDB driver applies its documented default (return the pre-image * document). Set explicitly to `'before'` or `'after'` to override. */ readonly returnDocument: 'before' | 'after' | undefined; constructor(collection: string, filter: Document, update: Document | ReadonlyArray, upsert?: boolean, sort?: Record, returnDocument?: 'before' | 'after'); } declare class RawFindOneAndDeleteCommand extends MongoAstNode { readonly kind: "rawFindOneAndDelete"; readonly collection: string; readonly filter: Document; readonly sort: Record | undefined; constructor(collection: string, filter: Document, sort?: Record); } type RawMongoCommand = RawAggregateCommand | RawInsertOneCommand | RawInsertManyCommand | RawUpdateOneCommand | RawUpdateManyCommand | RawDeleteOneCommand | RawDeleteManyCommand | RawFindOneAndUpdateCommand | RawFindOneAndDeleteCommand; //#endregion //#region src/commands.d.ts type MongoUpdateSpec = Record | ReadonlyArray; declare class InsertOneCommand extends MongoAstNode { readonly kind: "insertOne"; readonly collection: string; readonly document: Record; constructor(collection: string, document: Record); } declare class UpdateOneCommand extends MongoAstNode { readonly kind: "updateOne"; readonly collection: string; readonly filter: MongoFilterExpr; readonly update: MongoUpdateSpec; /** * When true, the wire command becomes an upsert: if no document matches * `filter`, a new document is inserted, derived from the filter's * equality fields plus the update spec. Defaults to false. */ readonly upsert: boolean; constructor(collection: string, filter: MongoFilterExpr, update: MongoUpdateSpec, upsert?: boolean); } declare class DeleteOneCommand extends MongoAstNode { readonly kind: "deleteOne"; readonly collection: string; readonly filter: MongoFilterExpr; constructor(collection: string, filter: MongoFilterExpr); } declare class InsertManyCommand extends MongoAstNode { readonly kind: "insertMany"; readonly collection: string; readonly documents: ReadonlyArray>; constructor(collection: string, documents: ReadonlyArray>); } declare class UpdateManyCommand extends MongoAstNode { readonly kind: "updateMany"; readonly collection: string; readonly filter: MongoFilterExpr; readonly update: MongoUpdateSpec; /** * Upsert flag — see `UpdateOneCommand.upsert`. For `updateMany`, Mongo * inserts at most one document when no match exists (driver-side * constraint). */ readonly upsert: boolean; constructor(collection: string, filter: MongoFilterExpr, update: MongoUpdateSpec, upsert?: boolean); } declare class DeleteManyCommand extends MongoAstNode { readonly kind: "deleteMany"; readonly collection: string; readonly filter: MongoFilterExpr; constructor(collection: string, filter: MongoFilterExpr); } declare class FindOneAndUpdateCommand extends MongoAstNode { readonly kind: "findOneAndUpdate"; readonly collection: string; readonly filter: MongoFilterExpr; readonly update: MongoUpdateSpec; readonly upsert: boolean; readonly sort: Record | undefined; readonly returnDocument: 'before' | 'after'; constructor(collection: string, filter: MongoFilterExpr, update: MongoUpdateSpec, upsert?: boolean, sort?: Record, returnDocument?: 'before' | 'after'); } declare class FindOneAndDeleteCommand extends MongoAstNode { readonly kind: "findOneAndDelete"; readonly collection: string; readonly filter: MongoFilterExpr; readonly sort: Record | undefined; constructor(collection: string, filter: MongoFilterExpr, sort?: Record); } declare class AggregateCommand extends MongoAstNode { readonly kind: "aggregate"; readonly collection: string; readonly pipeline: ReadonlyArray; constructor(collection: string, pipeline: ReadonlyArray); } type AnyMongoCommand = InsertOneCommand | InsertManyCommand | UpdateOneCommand | UpdateManyCommand | DeleteOneCommand | DeleteManyCommand | FindOneAndUpdateCommand | FindOneAndDeleteCommand | AggregateCommand | RawMongoCommand; //#endregion //#region src/result-shape.d.ts type MongoResultShape = { readonly kind: 'document'; readonly fields: Readonly>; } | { readonly kind: 'unknown'; }; type MongoFieldShape = { readonly kind: 'leaf'; readonly codecId: string; readonly nullable: boolean; } | { readonly kind: 'document'; readonly nullable: boolean; readonly fields: Readonly>; } | { readonly kind: 'array'; readonly nullable: boolean; readonly element: MongoFieldShape; } | { readonly kind: 'unknown'; }; declare function freezeMongoFieldShape(shape: MongoFieldShape): MongoFieldShape; declare function freezeMongoResultShape(shape: MongoResultShape): MongoResultShape; //#endregion //#region src/query-plan.d.ts declare const __mongoQueryPlanRow: unique symbol; /** * Mongo-domain query plan produced by lanes before lowering. * * Extends the framework-level `QueryPlan` marker (`meta + _row`) and * adds Mongo-specific fields (`collection`, `command`). The unique-symbol * phantom is retained alongside the inherited `_row` for backwards * compatibility with anything that may have relied on it. */ interface MongoQueryPlan extends QueryPlan { readonly collection: string; readonly command: Command; readonly resultShape?: MongoResultShape; readonly [__mongoQueryPlanRow]?: Row; } //#endregion export { MongoFilterRewriter as $, MongoFieldFilter as A, MongoSkipStage as At, MongoAggFieldRef as B, RawInsertOneCommand as C, MongoProjectionValue as Ct, MongoAndExpr as D, MongoSearchMetaStage as Dt, RawUpdateOneCommand as E, MongoSampleStage as Et, AggRecordArgs as F, MongoUpdatePipelineStage as Ft, MongoAggOperator as G, MongoAggLiteral as H, MongoAggAccumulator as I, MongoVectorSearchStage as It, MongoAggSwitchBranch as J, MongoAggReduce as K, MongoAggArrayFilter as L, MongoWindowField as Lt, MongoNotExpr as M, MongoSortStage as Mt, MongoOrExpr as N, MongoUnionWithStage as Nt, MongoExistsExpr as O, MongoSearchStage as Ot, isMongoFilterExpr as P, MongoUnwindStage as Pt, MongoAggExprVisitor as Q, MongoAggCond as R, MongoAstNode as Rt, RawInsertManyCommand as S, MongoProjectStage as St, RawUpdateManyCommand as T, MongoReplaceRootStage as Tt, MongoAggMap as U, MongoAggLet as V, MongoAggMergeObjects as W, isRecordArgs as X, isExprArray as Y, MongoAggExprRewriter as Z, RawAggregateCommand as _, MongoLookupStage as _t, freezeMongoResultShape as a, MongoBucketStage as at, RawFindOneAndDeleteCommand as b, MongoOutStage as bt, DeleteManyCommand as c, MongoDensifyStage as ct, FindOneAndUpdateCommand as d, MongoFillStage as dt, MongoFilterVisitor as et, InsertManyCommand as f, MongoGeoNearStage as ft, UpdateOneCommand as g, MongoLimitStage as gt, UpdateManyCommand as h, MongoGroupStage as ht, freezeMongoFieldShape as i, MongoBucketAutoStage as it, MongoFilterExpr as j, MongoSortByCountStage as jt, MongoExprFilter as k, MongoSetWindowFieldsStage as kt, DeleteOneCommand as l, MongoFacetStage as lt, MongoUpdateSpec as m, MongoGroupId as mt, MongoFieldShape as n, MongoStageVisitor as nt, AggregateCommand as o, MongoCountStage as ot, InsertOneCommand as p, MongoGraphLookupStage as pt, MongoAggSwitch as q, MongoResultShape as r, MongoAddFieldsStage as rt, AnyMongoCommand as s, MongoDensifyRange as st, MongoQueryPlan as t, MongoStageRewriterContext as tt, FindOneAndDeleteCommand as u, MongoFillOutput as ut, RawDeleteManyCommand as v, MongoMatchStage as vt, RawMongoCommand as w, MongoRedactStage as wt, RawFindOneAndUpdateCommand as x, MongoPipelineStage as xt, RawDeleteOneCommand as y, MongoMergeStage as yt, MongoAggExpr as z }; //# sourceMappingURL=query-plan-mVohmpSo.d.mts.map