From a065bc0b8c9225723af293f155efc48fb8fa2c0c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 27 Feb 2026 17:24:00 +0100 Subject: [PATCH] feat(mql-typescript): support generics on agg expressions --- packages/mql-typescript/mql-specifications | 2 +- packages/mql-typescript/out/schema.d.ts | 1517 +++++++++-------- packages/mql-typescript/src/cli.ts | 2 +- .../driverSchema/driver-schema-generator.ts | 12 +- packages/mql-typescript/src/metaschema.ts | 535 ++++-- .../mql-typescript/src/schema-generator.ts | 175 +- .../src/testGenerator/test-generator.ts | 43 +- 7 files changed, 1334 insertions(+), 952 deletions(-) diff --git a/packages/mql-typescript/mql-specifications b/packages/mql-typescript/mql-specifications index 67983635..0b6743db 160000 --- a/packages/mql-typescript/mql-specifications +++ b/packages/mql-typescript/mql-specifications @@ -1 +1 @@ -Subproject commit 679836355dd5671b50b4a010698b659eb7e7107b +Subproject commit 0b6743dbbdc37877bcc09ebeee950d8d10d4fade diff --git a/packages/mql-typescript/out/schema.d.ts b/packages/mql-typescript/out/schema.d.ts index 1335457a..1564664c 100644 --- a/packages/mql-typescript/out/schema.d.ts +++ b/packages/mql-typescript/out/schema.d.ts @@ -19,18 +19,20 @@ type RecordWithStaticFields, TValue> = T & { // TBD: Nested fields type AFieldPath = KeysOfAType & string; -type FieldExpression = { [k: string]: FieldPath }; +type FieldExpression = { [k: string]: FieldPath }; -type MultiAnalyzerSpec = { - value: KeysOfAType; +type MultiAnalyzerSpec = { + value: KeysOfAType; multi: string; }; + +type ArrayOnly = T extends ReadonlyArray ? U[] : never; export namespace Aggregation.Accumulator { /** * A type describing the `$accumulator` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/} */ - export interface $accumulator { + export interface $accumulator { /** * Defines a custom accumulator function. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/} @@ -77,7 +79,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$addToSet` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/} */ - export interface $addToSet { + export interface $addToSet { /** * Returns an array of unique expression values for each group. Order of the array elements is undefined. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -90,7 +92,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$avg` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/} */ - export interface $avg { + export interface $avg { /** * Returns an average of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -103,7 +105,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$bottom` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/} */ - export interface $bottom { + export interface $bottom { /** * Returns the bottom element within a group according to the specified sort order. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/} @@ -125,7 +127,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$bottomN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/} */ - export interface $bottomN { + export interface $bottomN { /** * Returns an aggregation of the bottom n elements within a group, according to the specified sort order. If the group contains fewer than n elements, $bottomN returns all elements in the group. * Available in the $group and $setWindowFields stages. @@ -153,7 +155,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$concatArrays` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/} */ - export interface $concatArrays { + export interface $concatArrays { /** * Concatenates arrays to return the concatenated array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/} @@ -171,7 +173,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$count` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/} */ - export interface $count { + export interface $count { /** * Returns the number of documents in the group or window. * Distinct from the $count pipeline stage. @@ -184,7 +186,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$covariancePop` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/} */ - export interface $covariancePop { + export interface $covariancePop { /** * Returns the population covariance of two numeric expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/} @@ -199,7 +201,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$covarianceSamp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/} */ - export interface $covarianceSamp { + export interface $covarianceSamp { /** * Returns the sample covariance of two numeric expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/} @@ -214,7 +216,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$denseRank` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/} */ - export interface $denseRank { + export interface $denseRank { /** * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/} @@ -226,7 +228,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$derivative` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/} */ - export interface $derivative { + export interface $derivative { /** * Returns the average rate of change within the specified window. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/} @@ -246,7 +248,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$documentNumber` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/} */ - export interface $documentNumber { + export interface $documentNumber { /** * Returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/} @@ -258,7 +260,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$expMovingAvg` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/} */ - export interface $expMovingAvg { + export interface $expMovingAvg { /** * Returns the exponential moving average for the numeric expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/} @@ -285,7 +287,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$first` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/} */ - export interface $first { + export interface $first { /** * Returns the result of an expression for the first document in a group or window. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -298,7 +300,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$firstN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/} */ - export interface $firstN { + export interface $firstN { /** * Returns an aggregation of the first n elements within a group. * The elements returned are meaningful only if in a specified sort order. @@ -322,7 +324,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$integral` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/} */ - export interface $integral { + export interface $integral { /** * Returns the approximation of the area under a curve. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/} @@ -342,7 +344,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$last` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/} */ - export interface $last { + export interface $last { /** * Returns the result of an expression for the last document in a group or window. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -355,7 +357,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$lastN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/} */ - export interface $lastN { + export interface $lastN { /** * Returns an aggregation of the last n elements within a group. * The elements returned are meaningful only if in a specified sort order. @@ -379,7 +381,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$linearFill` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/} */ - export interface $linearFill { + export interface $linearFill { /** * Fills null and missing fields in a window using linear interpolation based on surrounding field values. * Available in the $setWindowFields stage. @@ -392,7 +394,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$locf` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/} */ - export interface $locf { + export interface $locf { /** * Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field. * Available in the $setWindowFields stage. @@ -405,7 +407,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$max` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/} */ - export interface $max { + export interface $max { /** * Returns the maximum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -418,7 +420,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$maxN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/} */ - export interface $maxN { + export interface $maxN { /** * Returns the n largest values in an array. Distinct from the $maxN accumulator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/} @@ -440,7 +442,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$median` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/} */ - export interface $median { + export interface $median { /** * Returns an approximation of the median, the 50th percentile, as a scalar value. * This operator is available as an accumulator in these stages: @@ -466,7 +468,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$mergeObjects` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/} */ - export interface $mergeObjects { + export interface $mergeObjects { /** * Combines multiple documents into a single document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/} @@ -478,7 +480,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$min` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/} */ - export interface $min { + export interface $min { /** * Returns the minimum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -491,7 +493,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$minN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/} */ - export interface $minN { + export interface $minN { /** * Returns the n smallest values in an array. Distinct from the $minN accumulator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/} @@ -513,7 +515,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$percentile` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/} */ - export interface $percentile { + export interface $percentile { /** * Returns an array of scalar values that correspond to specified percentile values. * This operator is available as an accumulator in these stages: @@ -545,7 +547,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$push` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/} */ - export interface $push { + export interface $push { /** * Returns an array of values that result from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -558,7 +560,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$rank` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/} */ - export interface $rank { + export interface $rank { /** * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/} @@ -570,7 +572,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$setUnion` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/} */ - export interface $setUnion { + export interface $setUnion { /** * Takes two or more arrays and returns an array containing the elements that appear in any input array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/} @@ -587,7 +589,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$shift` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/} */ - export interface $shift { + export interface $shift { /** * Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/} @@ -620,7 +622,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$stdDevPop` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/} */ - export interface $stdDevPop { + export interface $stdDevPop { /** * Calculates the population standard deviation of the input values. Use if the values encompass the entire population of data you want to represent and do not wish to generalize about a larger population. $stdDevPop ignores non-numeric values. * If the values represent only a sample of a population of data from which to generalize about the population, use $stdDevSamp instead. @@ -634,7 +636,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$stdDevSamp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/} */ - export interface $stdDevSamp { + export interface $stdDevSamp { /** * Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values. * If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. @@ -648,7 +650,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$sum` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/} */ - export interface $sum { + export interface $sum { /** * Returns a sum of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -661,7 +663,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$top` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/} */ - export interface $top { + export interface $top { /** * Returns the top element within a group according to the specified sort order. * Available in the $group and $setWindowFields stages. @@ -684,7 +686,7 @@ export namespace Aggregation.Accumulator { * A type describing the `$topN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/} */ - export interface $topN { + export interface $topN { /** * Returns an aggregation of the top n fields within a group, according to the specified sort order. * Available in the $group and $setWindowFields stages. @@ -713,7 +715,7 @@ export namespace Aggregation.Expression { * A type describing the `$abs` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/} */ - export interface $abs { + export interface $abs { /** * Returns the absolute value of a number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/} @@ -725,7 +727,7 @@ export namespace Aggregation.Expression { * A type describing the `$acos` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/} */ - export interface $acos { + export interface $acos { /** * Returns the inverse cosine (arc cosine) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/} @@ -737,7 +739,7 @@ export namespace Aggregation.Expression { * A type describing the `$acosh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/} */ - export interface $acosh { + export interface $acosh { /** * Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/} @@ -749,7 +751,7 @@ export namespace Aggregation.Expression { * A type describing the `$add` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/} */ - export interface $add { + export interface $add { /** * Adds numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/} @@ -766,7 +768,7 @@ export namespace Aggregation.Expression { * A type describing the `$allElementsTrue` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/} */ - export interface $allElementsTrue { + export interface $allElementsTrue { /** * Returns true if no element of a set evaluates to false, otherwise, returns false. Accepts a single argument expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/} @@ -778,7 +780,7 @@ export namespace Aggregation.Expression { * A type describing the `$and` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/} */ - export interface $and { + export interface $and { /** * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/} @@ -798,7 +800,7 @@ export namespace Aggregation.Expression { * A type describing the `$anyElementTrue` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/} */ - export interface $anyElementTrue { + export interface $anyElementTrue { /** * Returns true if any elements of a set evaluate to true; otherwise, returns false. Accepts a single argument expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/} @@ -810,31 +812,31 @@ export namespace Aggregation.Expression { * A type describing the `$arrayElemAt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/} */ - export interface $arrayElemAt { + export interface $arrayElemAt { /** * Returns the element at the specified array index. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/} */ - $arrayElemAt: [array: ResolvesToArray, idx: ResolvesToInt]; + $arrayElemAt: [array: ResolvesToArray, idx: ResolvesToInt]; } /** * A type describing the `$arrayToObject` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/} */ - export interface $arrayToObject { + export interface $arrayToObject { /** * Converts an array of key value pairs to a document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/} */ - $arrayToObject: [array: ResolvesToArray]; + $arrayToObject: [array: ResolvesToArray]; } /** * A type describing the `$asin` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/} */ - export interface $asin { + export interface $asin { /** * Returns the inverse sin (arc sine) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/} @@ -846,7 +848,7 @@ export namespace Aggregation.Expression { * A type describing the `$asinh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/} */ - export interface $asinh { + export interface $asinh { /** * Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/} @@ -858,7 +860,7 @@ export namespace Aggregation.Expression { * A type describing the `$atan` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/} */ - export interface $atan { + export interface $atan { /** * Returns the inverse tangent (arc tangent) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/} @@ -870,7 +872,7 @@ export namespace Aggregation.Expression { * A type describing the `$atan2` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/} */ - export interface $atan2 { + export interface $atan2 { /** * Returns the inverse tangent (arc tangent) of y / x in radians, where y and x are the first and second values passed to the expression respectively. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/} @@ -890,7 +892,7 @@ export namespace Aggregation.Expression { * A type describing the `$atanh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/} */ - export interface $atanh { + export interface $atanh { /** * Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/} @@ -902,7 +904,7 @@ export namespace Aggregation.Expression { * A type describing the `$avg` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/} */ - export interface $avg { + export interface $avg { /** * Returns an average of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -915,7 +917,7 @@ export namespace Aggregation.Expression { * A type describing the `$binarySize` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/} */ - export interface $binarySize { + export interface $binarySize { /** * Returns the size of a given string or binary data value's content in bytes. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/} @@ -927,7 +929,7 @@ export namespace Aggregation.Expression { * A type describing the `$bitAnd` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/} */ - export interface $bitAnd { + export interface $bitAnd { /** * Returns the result of a bitwise and operation on an array of int or long values. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/} @@ -939,7 +941,7 @@ export namespace Aggregation.Expression { * A type describing the `$bitNot` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/} */ - export interface $bitNot { + export interface $bitNot { /** * Returns the result of a bitwise not operation on a single argument or an array that contains a single int or long value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/} @@ -951,7 +953,7 @@ export namespace Aggregation.Expression { * A type describing the `$bitOr` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/} */ - export interface $bitOr { + export interface $bitOr { /** * Returns the result of a bitwise or operation on an array of int or long values. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/} @@ -963,7 +965,7 @@ export namespace Aggregation.Expression { * A type describing the `$bitXor` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/} */ - export interface $bitXor { + export interface $bitXor { /** * Returns the result of a bitwise xor (exclusive or) operation on an array of int and long values. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/} @@ -975,7 +977,7 @@ export namespace Aggregation.Expression { * A type describing the `$bsonSize` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/} */ - export interface $bsonSize { + export interface $bsonSize { /** * Returns the size in bytes of a given document (i.e. BSON type Object) when encoded as BSON. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/} @@ -987,7 +989,7 @@ export namespace Aggregation.Expression { * A type describing the `$case` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/} */ - export interface $case { + export interface $case { /** * Represents a single case in a $switch expression * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/} @@ -1001,7 +1003,7 @@ export namespace Aggregation.Expression { /** * Can be any valid expression. */ - then: Expression; + then: Expression; }; } @@ -1009,7 +1011,7 @@ export namespace Aggregation.Expression { * A type describing the `$ceil` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/} */ - export interface $ceil { + export interface $ceil { /** * Returns the smallest integer greater than or equal to the specified number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/} @@ -1021,7 +1023,7 @@ export namespace Aggregation.Expression { * A type describing the `$cmp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/} */ - export interface $cmp { + export interface $cmp { /** * Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/} @@ -1033,7 +1035,7 @@ export namespace Aggregation.Expression { * A type describing the `$concat` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/} */ - export interface $concat { + export interface $concat { /** * Concatenates any number of strings. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/} @@ -1045,19 +1047,21 @@ export namespace Aggregation.Expression { * A type describing the `$concatArrays` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/} */ - export interface $concatArrays { - /** - * Concatenates arrays to return the concatenated array. - * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/} - */ - $concatArrays: [...ResolvesToArray[]]; - } + export type $concatArrays = U extends (infer T)[] + ? { + /** + * Concatenates arrays to return the concatenated array. + * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/} + */ + $concatArrays: [...ResolvesToArray[]]; + } + : never; /** * A type describing the `$cond` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/} */ - export interface $cond { + export interface $cond { /** * A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. Accepts either three expressions in an ordered list or three named parameters. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/} @@ -1069,7 +1073,7 @@ export namespace Aggregation.Expression { * A type describing the `$convert` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/} */ - export interface $convert { + export interface $convert { /** * Converts a value to a specified type. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/} @@ -1096,7 +1100,7 @@ export namespace Aggregation.Expression { * A type describing the `$cos` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/} */ - export interface $cos { + export interface $cos { /** * Returns the cosine of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/} @@ -1108,7 +1112,7 @@ export namespace Aggregation.Expression { * A type describing the `$cosh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/} */ - export interface $cosh { + export interface $cosh { /** * Returns the hyperbolic cosine of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/} @@ -1120,7 +1124,7 @@ export namespace Aggregation.Expression { * A type describing the `$createObjectId` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/createObjectId/} */ - export interface $createObjectId { + export interface $createObjectId { /** * Returns a random object ID * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/createObjectId/} @@ -1132,7 +1136,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateAdd` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/} */ - export interface $dateAdd { + export interface $dateAdd { /** * Adds a number of time units to a date object. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/} @@ -1163,7 +1167,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateDiff` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/} */ - export interface $dateDiff { + export interface $dateDiff { /** * Returns the difference between two dates. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/} @@ -1206,7 +1210,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateFromParts` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/} */ - export interface $dateFromParts { + export interface $dateFromParts { /** * Constructs a BSON Date object given the date's constituent parts. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/} @@ -1273,7 +1277,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateFromString` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/} */ - export interface $dateFromString { + export interface $dateFromString { /** * Converts a date/time string to a date object. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/} @@ -1313,7 +1317,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateSubtract` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/} */ - export interface $dateSubtract { + export interface $dateSubtract { /** * Subtracts a number of time units from a date object. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/} @@ -1344,7 +1348,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateToParts` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/} */ - export interface $dateToParts { + export interface $dateToParts { /** * Returns a document containing the constituent parts of a date. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/} @@ -1371,7 +1375,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateToString` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/} */ - export interface $dateToString { + export interface $dateToString { /** * Returns the date as a formatted string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/} @@ -1405,7 +1409,7 @@ export namespace Aggregation.Expression { * A type describing the `$dateTrunc` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/} */ - export interface $dateTrunc { + export interface $dateTrunc { /** * Truncates a date. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/} @@ -1445,7 +1449,7 @@ export namespace Aggregation.Expression { * A type describing the `$dayOfMonth` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/} */ - export interface $dayOfMonth { + export interface $dayOfMonth { /** * Returns the day of the month for a date as a number between 1 and 31. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/} @@ -1467,7 +1471,7 @@ export namespace Aggregation.Expression { * A type describing the `$dayOfWeek` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/} */ - export interface $dayOfWeek { + export interface $dayOfWeek { /** * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/} @@ -1489,7 +1493,7 @@ export namespace Aggregation.Expression { * A type describing the `$dayOfYear` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/} */ - export interface $dayOfYear { + export interface $dayOfYear { /** * Returns the day of the year for a date as a number between 1 and 366 (leap year). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/} @@ -1511,7 +1515,7 @@ export namespace Aggregation.Expression { * A type describing the `$degreesToRadians` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/} */ - export interface $degreesToRadians { + export interface $degreesToRadians { /** * Converts a value from degrees to radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/} @@ -1523,7 +1527,7 @@ export namespace Aggregation.Expression { * A type describing the `$divide` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/} */ - export interface $divide { + export interface $divide { /** * Returns the result of dividing the first number by the second. Accepts two argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/} @@ -1541,7 +1545,7 @@ export namespace Aggregation.Expression { * A type describing the `$eq` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/} */ - export interface $eq { + export interface $eq { /** * Returns true if the values are equivalent. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/} @@ -1553,7 +1557,7 @@ export namespace Aggregation.Expression { * A type describing the `$exp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/} */ - export interface $exp { + export interface $exp { /** * Raises e to the specified exponent. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/} @@ -1565,13 +1569,13 @@ export namespace Aggregation.Expression { * A type describing the `$filter` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/} */ - export interface $filter { + export interface $filter { /** * Selects a subset of the array to return an array with only the elements that match the filter condition. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/} */ $filter: { - input: ResolvesToArray; + input: ResolvesToArray; /** * An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as. @@ -1595,19 +1599,19 @@ export namespace Aggregation.Expression { * A type describing the `$first` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/} */ - export interface $first { + export interface $first { /** * Returns the result of an expression for the first document in an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/} */ - $first: ResolvesToArray; + $first: ResolvesToArray; } /** * A type describing the `$firstN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/} */ - export interface $firstN { + export interface $firstN { /** * Returns a specified number of elements from the beginning of an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/} @@ -1621,7 +1625,7 @@ export namespace Aggregation.Expression { /** * An expression that resolves to the array from which to return n elements. */ - input: ResolvesToArray; + input: ResolvesToArray; }; } @@ -1629,7 +1633,7 @@ export namespace Aggregation.Expression { * A type describing the `$floor` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/} */ - export interface $floor { + export interface $floor { /** * Returns the largest integer less than or equal to the specified number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/} @@ -1641,7 +1645,7 @@ export namespace Aggregation.Expression { * A type describing the `$function` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/} */ - export interface $function { + export interface $function { /** * Defines a custom function. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/} @@ -1665,7 +1669,7 @@ export namespace Aggregation.Expression { * A type describing the `$getField` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/} */ - export interface $getField { + export interface $getField { /** * Returns the value of a specified field from a document. You can use $getField to retrieve the value of fields with names that contain periods (.) or start with dollar signs ($). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/} @@ -1689,7 +1693,7 @@ export namespace Aggregation.Expression { * A type describing the `$gt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/} */ - export interface $gt { + export interface $gt { /** * Returns true if the first value is greater than the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/} @@ -1701,7 +1705,7 @@ export namespace Aggregation.Expression { * A type describing the `$gte` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/} */ - export interface $gte { + export interface $gte { /** * Returns true if the first value is greater than or equal to the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/} @@ -1713,7 +1717,7 @@ export namespace Aggregation.Expression { * A type describing the `$hour` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/} */ - export interface $hour { + export interface $hour { /** * Returns the hour for a date as a number between 0 and 23. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/} @@ -1735,7 +1739,7 @@ export namespace Aggregation.Expression { * A type describing the `$ifNull` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/} */ - export interface $ifNull { + export interface $ifNull { /** * Returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. Accepts two expressions as arguments. The result of the second expression can be null. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/} @@ -1747,7 +1751,7 @@ export namespace Aggregation.Expression { * A type describing the `$in` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/} */ - export interface $in { + export interface $in { /** * Returns a boolean indicating whether a specified value is in an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/} @@ -1769,7 +1773,7 @@ export namespace Aggregation.Expression { * A type describing the `$indexOfArray` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/} */ - export interface $indexOfArray { + export interface $indexOfArray { /** * Searches an array for an occurrence of a specified value and returns the array index of the first occurrence. Array indexes start at zero. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/} @@ -1801,7 +1805,7 @@ export namespace Aggregation.Expression { * A type describing the `$indexOfBytes` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/} */ - export interface $indexOfBytes { + export interface $indexOfBytes { /** * Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first occurrence. If the substring is not found, returns -1. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/} @@ -1837,7 +1841,7 @@ export namespace Aggregation.Expression { * A type describing the `$indexOfCP` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/} */ - export interface $indexOfCP { + export interface $indexOfCP { /** * Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence. If the substring is not found, returns -1 * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/} @@ -1873,7 +1877,7 @@ export namespace Aggregation.Expression { * A type describing the `$isArray` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/} */ - export interface $isArray { + export interface $isArray { /** * Determines if the operand is an array. Returns a boolean. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/} @@ -1885,7 +1889,7 @@ export namespace Aggregation.Expression { * A type describing the `$isNumber` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/} */ - export interface $isNumber { + export interface $isNumber { /** * Returns boolean true if the specified expression resolves to an integer, decimal, double, or long. * Returns boolean false if the expression resolves to any other BSON type, null, or a missing field. @@ -1898,7 +1902,7 @@ export namespace Aggregation.Expression { * A type describing the `$isoDayOfWeek` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/} */ - export interface $isoDayOfWeek { + export interface $isoDayOfWeek { /** * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/} @@ -1920,7 +1924,7 @@ export namespace Aggregation.Expression { * A type describing the `$isoWeek` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/} */ - export interface $isoWeek { + export interface $isoWeek { /** * Returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/} @@ -1942,7 +1946,7 @@ export namespace Aggregation.Expression { * A type describing the `$isoWeekYear` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/} */ - export interface $isoWeekYear { + export interface $isoWeekYear { /** * Returns the year number in ISO 8601 format. The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/} @@ -1964,19 +1968,19 @@ export namespace Aggregation.Expression { * A type describing the `$last` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/} */ - export interface $last { + export interface $last { /** * Returns the result of an expression for the last document in an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/} */ - $last: ResolvesToArray; + $last: ResolvesToArray; } /** * A type describing the `$lastN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/} */ - export interface $lastN { + export interface $lastN { /** * Returns a specified number of elements from the end of an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/} @@ -1990,7 +1994,7 @@ export namespace Aggregation.Expression { /** * An expression that resolves to the array from which to return n elements. */ - input: ResolvesToArray; + input: ResolvesToArray; }; } @@ -1998,7 +2002,7 @@ export namespace Aggregation.Expression { * A type describing the `$let` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/} */ - export interface $let { + export interface $let { /** * Defines variables for use within the scope of a subexpression and returns the result of the subexpression. Accepts named parameters. * Accepts any number of argument expressions. @@ -2022,7 +2026,7 @@ export namespace Aggregation.Expression { * A type describing the `$literal` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/} */ - export interface $literal { + export interface $literal { /** * Return a value without parsing. Use for values that the aggregation pipeline may interpret as an expression. For example, use a $literal expression to a string that starts with a dollar sign ($) to avoid parsing as a field path. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/} @@ -2034,7 +2038,7 @@ export namespace Aggregation.Expression { * A type describing the `$ln` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/} */ - export interface $ln { + export interface $ln { /** * Calculates the natural log of a number. * $ln is equivalent to $log: [ , Math.E ] expression, where Math.E is a JavaScript representation for Euler's number e. @@ -2047,7 +2051,7 @@ export namespace Aggregation.Expression { * A type describing the `$log` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/} */ - export interface $log { + export interface $log { /** * Calculates the log of a number in the specified base. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/} @@ -2069,7 +2073,7 @@ export namespace Aggregation.Expression { * A type describing the `$log10` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/} */ - export interface $log10 { + export interface $log10 { /** * Calculates the log base 10 of a number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/} @@ -2081,7 +2085,7 @@ export namespace Aggregation.Expression { * A type describing the `$lt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/} */ - export interface $lt { + export interface $lt { /** * Returns true if the first value is less than the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/} @@ -2093,7 +2097,7 @@ export namespace Aggregation.Expression { * A type describing the `$lte` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/} */ - export interface $lte { + export interface $lte { /** * Returns true if the first value is less than or equal to the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/} @@ -2105,7 +2109,7 @@ export namespace Aggregation.Expression { * A type describing the `$ltrim` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/} */ - export interface $ltrim { + export interface $ltrim { /** * Removes whitespace or the specified characters from the beginning of a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/} @@ -2129,7 +2133,7 @@ export namespace Aggregation.Expression { * A type describing the `$map` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/} */ - export interface $map { + export interface $map { /** * Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/} @@ -2156,7 +2160,7 @@ export namespace Aggregation.Expression { * A type describing the `$max` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/} */ - export interface $max { + export interface $max { /** * Returns the maximum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -2169,7 +2173,7 @@ export namespace Aggregation.Expression { * A type describing the `$maxN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/} */ - export interface $maxN { + export interface $maxN { /** * Returns the n largest values in an array. Distinct from the $maxN accumulator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/} @@ -2178,7 +2182,7 @@ export namespace Aggregation.Expression { /** * An expression that resolves to the array from which to return the maximal n elements. */ - input: ResolvesToArray; + input: ResolvesToArray; /** * An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. @@ -2191,7 +2195,7 @@ export namespace Aggregation.Expression { * A type describing the `$median` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/} */ - export interface $median { + export interface $median { /** * Returns an approximation of the median, the 50th percentile, as a scalar value. * This operator is available as an accumulator in these stages: @@ -2217,7 +2221,7 @@ export namespace Aggregation.Expression { * A type describing the `$mergeObjects` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/} */ - export interface $mergeObjects { + export interface $mergeObjects { /** * Combines multiple documents into a single document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/} @@ -2234,7 +2238,7 @@ export namespace Aggregation.Expression { * A type describing the `$meta` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/} */ - export interface $meta { + export interface $meta { /** * Access available per-document metadata related to the aggregation operation. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/} @@ -2246,7 +2250,7 @@ export namespace Aggregation.Expression { * A type describing the `$millisecond` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/} */ - export interface $millisecond { + export interface $millisecond { /** * Returns the milliseconds of a date as a number between 0 and 999. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/} @@ -2268,7 +2272,7 @@ export namespace Aggregation.Expression { * A type describing the `$min` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/} */ - export interface $min { + export interface $min { /** * Returns the minimum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -2281,7 +2285,7 @@ export namespace Aggregation.Expression { * A type describing the `$minN` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/} */ - export interface $minN { + export interface $minN { /** * Returns the n smallest values in an array. Distinct from the $minN accumulator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/} @@ -2290,7 +2294,7 @@ export namespace Aggregation.Expression { /** * An expression that resolves to the array from which to return the maximal n elements. */ - input: ResolvesToArray; + input: ResolvesToArray; /** * An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. @@ -2303,7 +2307,7 @@ export namespace Aggregation.Expression { * A type describing the `$minute` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/} */ - export interface $minute { + export interface $minute { /** * Returns the minute for a date as a number between 0 and 59. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/} @@ -2325,7 +2329,7 @@ export namespace Aggregation.Expression { * A type describing the `$mod` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/} */ - export interface $mod { + export interface $mod { /** * Returns the remainder of the first number divided by the second. Accepts two argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/} @@ -2343,7 +2347,7 @@ export namespace Aggregation.Expression { * A type describing the `$month` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/} */ - export interface $month { + export interface $month { /** * Returns the month for a date as a number between 1 (January) and 12 (December). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/} @@ -2365,7 +2369,7 @@ export namespace Aggregation.Expression { * A type describing the `$multiply` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/} */ - export interface $multiply { + export interface $multiply { /** * Multiplies numbers to return the product. Accepts any number of argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/} @@ -2383,7 +2387,7 @@ export namespace Aggregation.Expression { * A type describing the `$ne` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/} */ - export interface $ne { + export interface $ne { /** * Returns true if the values are not equivalent. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/} @@ -2395,7 +2399,7 @@ export namespace Aggregation.Expression { * A type describing the `$not` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/} */ - export interface $not { + export interface $not { /** * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/} @@ -2407,19 +2411,24 @@ export namespace Aggregation.Expression { * A type describing the `$objectToArray` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/} */ - export interface $objectToArray { - /** - * Converts a document to an array of documents representing key-value pairs. - * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/} - */ - $objectToArray: ResolvesToObject; - } + export type $objectToArray = U extends [ + keyof (infer T), + (infer T)[keyof (infer T)], + ][] + ? { + /** + * Converts a document to an array of documents representing key-value pairs. + * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/} + */ + $objectToArray: ResolvesToObject; + } + : never; /** * A type describing the `$or` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/} */ - export interface $or { + export interface $or { /** * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/} @@ -2431,7 +2440,7 @@ export namespace Aggregation.Expression { * A type describing the `$percentile` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/} */ - export interface $percentile { + export interface $percentile { /** * Returns an array of scalar values that correspond to specified percentile values. * This operator is available as an accumulator in these stages: @@ -2463,7 +2472,7 @@ export namespace Aggregation.Expression { * A type describing the `$pow` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/} */ - export interface $pow { + export interface $pow { /** * Raises a number to the specified exponent. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/} @@ -2475,7 +2484,7 @@ export namespace Aggregation.Expression { * A type describing the `$radiansToDegrees` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/} */ - export interface $radiansToDegrees { + export interface $radiansToDegrees { /** * Converts a value from radians to degrees. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/} @@ -2487,7 +2496,7 @@ export namespace Aggregation.Expression { * A type describing the `$rand` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/} */ - export interface $rand { + export interface $rand { /** * Returns a random float between 0 and 1 * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/} @@ -2499,7 +2508,7 @@ export namespace Aggregation.Expression { * A type describing the `$range` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/} */ - export interface $range { + export interface $range { /** * Outputs an array containing a sequence of integers according to user-defined inputs. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/} @@ -2526,7 +2535,7 @@ export namespace Aggregation.Expression { * A type describing the `$reduce` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/} */ - export interface $reduce { + export interface $reduce { /** * Applies an expression to each element in an array and combines them into a single value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/} @@ -2570,7 +2579,7 @@ export namespace Aggregation.Expression { * A type describing the `$regexFind` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/} */ - export interface $regexFind { + export interface $regexFind { /** * Applies a regular expression (regex) to a string and returns information on the first matched substring. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/} @@ -2593,7 +2602,7 @@ export namespace Aggregation.Expression { * A type describing the `$regexFindAll` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/} */ - export interface $regexFindAll { + export interface $regexFindAll { /** * Applies a regular expression (regex) to a string and returns information on the all matched substrings. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/} @@ -2616,7 +2625,7 @@ export namespace Aggregation.Expression { * A type describing the `$regexMatch` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/} */ - export interface $regexMatch { + export interface $regexMatch { /** * Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/} @@ -2639,7 +2648,7 @@ export namespace Aggregation.Expression { * A type describing the `$replaceAll` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/} */ - export interface $replaceAll { + export interface $replaceAll { /** * Replaces all instances of a search string in an input string with a replacement string. * $replaceAll is both case-sensitive and diacritic-sensitive, and ignores any collation present on a collection. @@ -2667,7 +2676,7 @@ export namespace Aggregation.Expression { * A type describing the `$replaceOne` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/} */ - export interface $replaceOne { + export interface $replaceOne { /** * Replaces the first instance of a matched string in a given input. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/} @@ -2694,7 +2703,7 @@ export namespace Aggregation.Expression { * A type describing the `$reverseArray` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/} */ - export interface $reverseArray { + export interface $reverseArray { /** * Returns an array with the elements in reverse order. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/} @@ -2706,7 +2715,7 @@ export namespace Aggregation.Expression { * A type describing the `$round` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/} */ - export interface $round { + export interface $round { /** * Rounds a number to a whole integer or to a specified decimal place. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/} @@ -2729,7 +2738,7 @@ export namespace Aggregation.Expression { * A type describing the `$rtrim` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/} */ - export interface $rtrim { + export interface $rtrim { /** * Removes whitespace characters, including null, or the specified characters from the end of a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/} @@ -2753,7 +2762,7 @@ export namespace Aggregation.Expression { * A type describing the `$second` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/} */ - export interface $second { + export interface $second { /** * Returns the seconds for a date as a number between 0 and 60 (leap seconds). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/} @@ -2775,7 +2784,7 @@ export namespace Aggregation.Expression { * A type describing the `$setDifference` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/} */ - export interface $setDifference { + export interface $setDifference { /** * Returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. Accepts exactly two argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/} @@ -2784,12 +2793,12 @@ export namespace Aggregation.Expression { /** * The arguments can be any valid expression as long as they each resolve to an array. */ - expression1: ResolvesToArray, + expression1: ResolvesToArray, /** * The arguments can be any valid expression as long as they each resolve to an array. */ - expression2: ResolvesToArray, + expression2: ResolvesToArray, ]; } @@ -2797,7 +2806,7 @@ export namespace Aggregation.Expression { * A type describing the `$setEquals` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/} */ - export interface $setEquals { + export interface $setEquals { /** * Returns true if the input sets have the same distinct elements. Accepts two or more argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/} @@ -2809,7 +2818,7 @@ export namespace Aggregation.Expression { * A type describing the `$setField` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/} */ - export interface $setField { + export interface $setField { /** * Adds, updates, or removes a specified field in a document. You can use $setField to add, update, or remove fields with names that contain periods (.) or start with dollar signs ($). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/} @@ -2837,19 +2846,19 @@ export namespace Aggregation.Expression { * A type describing the `$setIntersection` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/} */ - export interface $setIntersection { + export interface $setIntersection { /** * Returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/} */ - $setIntersection: [...ResolvesToArray[]]; + $setIntersection: [...ResolvesToArray[]]; } /** * A type describing the `$setIsSubset` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/} */ - export interface $setIsSubset { + export interface $setIsSubset { /** * Returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. Accepts exactly two argument expressions. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/} @@ -2864,7 +2873,7 @@ export namespace Aggregation.Expression { * A type describing the `$setUnion` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/} */ - export interface $setUnion { + export interface $setUnion { /** * Returns a set with elements that appear in any of the input sets. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/} @@ -2876,7 +2885,7 @@ export namespace Aggregation.Expression { * A type describing the `$sin` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/} */ - export interface $sin { + export interface $sin { /** * Returns the sine of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/} @@ -2888,7 +2897,7 @@ export namespace Aggregation.Expression { * A type describing the `$sinh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/} */ - export interface $sinh { + export interface $sinh { /** * Returns the hyperbolic sine of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/} @@ -2900,7 +2909,7 @@ export namespace Aggregation.Expression { * A type describing the `$size` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/} */ - export interface $size { + export interface $size { /** * Returns the number of elements in the array. Accepts a single expression as argument. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/} @@ -2912,7 +2921,7 @@ export namespace Aggregation.Expression { * A type describing the `$slice` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/} */ - export interface $slice { + export interface $slice { /** * Returns a subset of an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/} @@ -2957,7 +2966,7 @@ export namespace Aggregation.Expression { * A type describing the `$sortArray` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/} */ - export interface $sortArray { + export interface $sortArray { /** * Sorts the elements of an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/} @@ -2968,7 +2977,7 @@ export namespace Aggregation.Expression { * The result is null if the expression: is missing, evaluates to null, or evaluates to undefined * If the expression evaluates to any other non-array value, the document returns an error. */ - input: ResolvesToArray; + input: ResolvesToArray; /** * The document specifies a sort ordering. @@ -2981,7 +2990,7 @@ export namespace Aggregation.Expression { * A type describing the `$split` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/} */ - export interface $split { + export interface $split { /** * Splits a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/} @@ -3003,7 +3012,7 @@ export namespace Aggregation.Expression { * A type describing the `$sqrt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/} */ - export interface $sqrt { + export interface $sqrt { /** * Calculates the square root. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/} @@ -3015,7 +3024,7 @@ export namespace Aggregation.Expression { * A type describing the `$stdDevPop` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/} */ - export interface $stdDevPop { + export interface $stdDevPop { /** * Calculates the population standard deviation of the input values. Use if the values encompass the entire population of data you want to represent and do not wish to generalize about a larger population. $stdDevPop ignores non-numeric values. * If the values represent only a sample of a population of data from which to generalize about the population, use $stdDevSamp instead. @@ -3029,7 +3038,7 @@ export namespace Aggregation.Expression { * A type describing the `$stdDevSamp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/} */ - export interface $stdDevSamp { + export interface $stdDevSamp { /** * Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values. * If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. @@ -3042,7 +3051,7 @@ export namespace Aggregation.Expression { * A type describing the `$strLenBytes` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/} */ - export interface $strLenBytes { + export interface $strLenBytes { /** * Returns the number of UTF-8 encoded bytes in a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/} @@ -3054,7 +3063,7 @@ export namespace Aggregation.Expression { * A type describing the `$strLenCP` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/} */ - export interface $strLenCP { + export interface $strLenCP { /** * Returns the number of UTF-8 code points in a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/} @@ -3066,7 +3075,7 @@ export namespace Aggregation.Expression { * A type describing the `$strcasecmp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/} */ - export interface $strcasecmp { + export interface $strcasecmp { /** * Performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/} @@ -3081,7 +3090,7 @@ export namespace Aggregation.Expression { * A type describing the `$substr` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/} */ - export interface $substr { + export interface $substr { /** * Deprecated. Use $substrBytes or $substrCP. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/} @@ -3105,7 +3114,7 @@ export namespace Aggregation.Expression { * A type describing the `$substrBytes` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/} */ - export interface $substrBytes { + export interface $substrBytes { /** * Returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/} @@ -3129,7 +3138,7 @@ export namespace Aggregation.Expression { * A type describing the `$substrCP` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/} */ - export interface $substrCP { + export interface $substrCP { /** * Returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/} @@ -3153,7 +3162,7 @@ export namespace Aggregation.Expression { * A type describing the `$subtract` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/} */ - export interface $subtract { + export interface $subtract { /** * Returns the result of subtracting the second value from the first. If the two values are numbers, return the difference. If the two values are dates, return the difference in milliseconds. If the two values are a date and a number in milliseconds, return the resulting date. Accepts two argument expressions. If the two values are a date and a number, specify the date argument first as it is not meaningful to subtract a date from a number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/} @@ -3168,7 +3177,7 @@ export namespace Aggregation.Expression { * A type describing the `$sum` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/} */ - export interface $sum { + export interface $sum { /** * Returns a sum of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. @@ -3181,7 +3190,7 @@ export namespace Aggregation.Expression { * A type describing the `$switch` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/} */ - export interface $switch { + export interface $switch { /** * Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/} @@ -3207,7 +3216,7 @@ export namespace Aggregation.Expression { * A type describing the `$tan` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/} */ - export interface $tan { + export interface $tan { /** * Returns the tangent of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/} @@ -3219,7 +3228,7 @@ export namespace Aggregation.Expression { * A type describing the `$tanh` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/} */ - export interface $tanh { + export interface $tanh { /** * Returns the hyperbolic tangent of a value that is measured in radians. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/} @@ -3231,7 +3240,7 @@ export namespace Aggregation.Expression { * A type describing the `$toBool` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/} */ - export interface $toBool { + export interface $toBool { /** * Converts value to a boolean. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/} @@ -3243,7 +3252,7 @@ export namespace Aggregation.Expression { * A type describing the `$toDate` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/} */ - export interface $toDate { + export interface $toDate { /** * Converts value to a Date. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/} @@ -3255,7 +3264,7 @@ export namespace Aggregation.Expression { * A type describing the `$toDecimal` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/} */ - export interface $toDecimal { + export interface $toDecimal { /** * Converts value to a Decimal128. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/} @@ -3267,7 +3276,7 @@ export namespace Aggregation.Expression { * A type describing the `$toDouble` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/} */ - export interface $toDouble { + export interface $toDouble { /** * Converts value to a double. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/} @@ -3279,7 +3288,7 @@ export namespace Aggregation.Expression { * A type describing the `$toHashedIndexKey` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/} */ - export interface $toHashedIndexKey { + export interface $toHashedIndexKey { /** * Computes and returns the hash value of the input expression using the same hash function that MongoDB uses to create a hashed index. A hash function maps a key or string to a fixed-size numeric value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/} @@ -3291,7 +3300,7 @@ export namespace Aggregation.Expression { * A type describing the `$toInt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/} */ - export interface $toInt { + export interface $toInt { /** * Converts value to an integer. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/} @@ -3303,7 +3312,7 @@ export namespace Aggregation.Expression { * A type describing the `$toLong` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/} */ - export interface $toLong { + export interface $toLong { /** * Converts value to a long. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/} @@ -3315,7 +3324,7 @@ export namespace Aggregation.Expression { * A type describing the `$toLower` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/} */ - export interface $toLower { + export interface $toLower { /** * Converts a string to lowercase. Accepts a single argument expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/} @@ -3327,7 +3336,7 @@ export namespace Aggregation.Expression { * A type describing the `$toObjectId` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/} */ - export interface $toObjectId { + export interface $toObjectId { /** * Converts value to an ObjectId. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/} @@ -3339,7 +3348,7 @@ export namespace Aggregation.Expression { * A type describing the `$toString` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/} */ - export interface $toString { + export interface $toString { /** * Converts value to a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/} @@ -3351,7 +3360,7 @@ export namespace Aggregation.Expression { * A type describing the `$toUpper` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/} */ - export interface $toUpper { + export interface $toUpper { /** * Converts a string to uppercase. Accepts a single argument expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/} @@ -3363,7 +3372,7 @@ export namespace Aggregation.Expression { * A type describing the `$trim` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/} */ - export interface $trim { + export interface $trim { /** * Removes whitespace or the specified characters from the beginning and end of a string. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/} @@ -3387,7 +3396,7 @@ export namespace Aggregation.Expression { * A type describing the `$trunc` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/} */ - export interface $trunc { + export interface $trunc { /** * Truncates a number to a whole integer or to a specified decimal place. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/} @@ -3410,7 +3419,7 @@ export namespace Aggregation.Expression { * A type describing the `$tsIncrement` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/} */ - export interface $tsIncrement { + export interface $tsIncrement { /** * Returns the incrementing ordinal from a timestamp as a long. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/} @@ -3422,7 +3431,7 @@ export namespace Aggregation.Expression { * A type describing the `$tsSecond` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/} */ - export interface $tsSecond { + export interface $tsSecond { /** * Returns the seconds from a timestamp as a long. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/} @@ -3434,7 +3443,7 @@ export namespace Aggregation.Expression { * A type describing the `$type` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/} */ - export interface $type { + export interface $type { /** * Return the BSON data type of the field. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/} @@ -3446,7 +3455,7 @@ export namespace Aggregation.Expression { * A type describing the `$unsetField` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/} */ - export interface $unsetField { + export interface $unsetField { /** * You can use $unsetField to remove fields with names that contain periods (.) or that start with dollar signs ($). * $unsetField is an alias for $setField using $$REMOVE to remove fields. @@ -3469,7 +3478,7 @@ export namespace Aggregation.Expression { * A type describing the `$week` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/} */ - export interface $week { + export interface $week { /** * Returns the week number for a date as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (leap year). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/} @@ -3491,7 +3500,7 @@ export namespace Aggregation.Expression { * A type describing the `$year` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/} */ - export interface $year { + export interface $year { /** * Returns the year for a date as a number (e.g. 2014). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/} @@ -3513,7 +3522,7 @@ export namespace Aggregation.Expression { * A type describing the `$zip` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/} */ - export interface $zip { + export interface $zip { /** * Merge two arrays together. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/} @@ -3541,12 +3550,47 @@ export namespace Aggregation.Expression { }; } } +export namespace Aggregation.Pipeline { + /** + * A type describing the `pipeline` operator. + * @see {@link https://www.mongodb.com/docs/manual/core/aggregation-pipeline/} + */ + export interface Pipeline { + /** + * An aggregation pipeline consists of one or more stages that process documents. These documents can come from a collection, a view, or a specially designed stage. + * @see {@link https://www.mongodb.com/docs/manual/core/aggregation-pipeline/} + */ + pipeline: [ + /** + * A list of stages + */ + ...Stage[], + ]; + } + + /** + * A type describing the `updatePipeline` operator. + * @see {@link https://www.mongodb.com/docs/manual/tutorial/update-documents-with-aggregation-pipeline/} + */ + export interface UpdatePipeline { + /** + * Use aggregation pipelines to perform update operations. + * @see {@link https://www.mongodb.com/docs/manual/tutorial/update-documents-with-aggregation-pipeline/} + */ + updatePipeline: [ + /** + * A list of stages + */ + ...UpdateStage[], + ]; + } +} export namespace Aggregation.Query { /** * A type describing the `$all` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/all/} */ - export interface $all { + export interface $all { /** * Matches arrays that contain all elements specified in the query. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/all/} @@ -3558,7 +3602,7 @@ export namespace Aggregation.Query { * A type describing the `$and` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/and/} */ - export interface $and { + export interface $and { /** * Joins query clauses with a logical AND returns all documents that match the conditions of both clauses. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/and/} @@ -3570,7 +3614,7 @@ export namespace Aggregation.Query { * A type describing the `$bitsAllClear` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/} */ - export interface $bitsAllClear { + export interface $bitsAllClear { /** * Matches numeric or binary values in which a set of bit positions all have a value of 0. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/} @@ -3582,7 +3626,7 @@ export namespace Aggregation.Query { * A type describing the `$bitsAllSet` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/} */ - export interface $bitsAllSet { + export interface $bitsAllSet { /** * Matches numeric or binary values in which a set of bit positions all have a value of 1. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/} @@ -3594,7 +3638,7 @@ export namespace Aggregation.Query { * A type describing the `$bitsAnyClear` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/} */ - export interface $bitsAnyClear { + export interface $bitsAnyClear { /** * Matches numeric or binary values in which any bit from a set of bit positions has a value of 0. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/} @@ -3606,7 +3650,7 @@ export namespace Aggregation.Query { * A type describing the `$bitsAnySet` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/} */ - export interface $bitsAnySet { + export interface $bitsAnySet { /** * Matches numeric or binary values in which any bit from a set of bit positions has a value of 1. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/} @@ -3618,7 +3662,7 @@ export namespace Aggregation.Query { * A type describing the `$box` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/box/} */ - export interface $box { + export interface $box { /** * Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries. The 2d index supports $box. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/box/} @@ -3630,7 +3674,7 @@ export namespace Aggregation.Query { * A type describing the `$center` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/center/} */ - export interface $center { + export interface $center { /** * Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. The 2d index supports $center. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/center/} @@ -3642,7 +3686,7 @@ export namespace Aggregation.Query { * A type describing the `$centerSphere` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/} */ - export interface $centerSphere { + export interface $centerSphere { /** * Specifies a circle using either legacy coordinate pairs or GeoJSON format for $geoWithin queries when using spherical geometry. The 2dsphere and 2d indexes support $centerSphere. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/} @@ -3654,7 +3698,7 @@ export namespace Aggregation.Query { * A type describing the `$comment` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/comment/} */ - export interface $comment { + export interface $comment { /** * Adds a comment to a query predicate. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/comment/} @@ -3666,7 +3710,7 @@ export namespace Aggregation.Query { * A type describing the `$elemMatch` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/} */ - export interface $elemMatch { + export interface $elemMatch { /** * The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/} @@ -3678,7 +3722,7 @@ export namespace Aggregation.Query { * A type describing the `$eq` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/eq/} */ - export interface $eq { + export interface $eq { /** * Matches values that are equal to a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/eq/} @@ -3690,7 +3734,7 @@ export namespace Aggregation.Query { * A type describing the `$exists` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/exists/} */ - export interface $exists { + export interface $exists { /** * Matches documents that have the specified field. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/exists/} @@ -3702,7 +3746,7 @@ export namespace Aggregation.Query { * A type describing the `$expr` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/expr/} */ - export interface $expr { + export interface $expr { /** * Allows use of aggregation expressions within the query language. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/expr/} @@ -3714,7 +3758,7 @@ export namespace Aggregation.Query { * A type describing the `$geoIntersects` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/} */ - export interface $geoIntersects { + export interface $geoIntersects { /** * Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/} @@ -3726,7 +3770,7 @@ export namespace Aggregation.Query { * A type describing the `$geoWithin` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/} */ - export interface $geoWithin { + export interface $geoWithin { /** * Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/} @@ -3738,7 +3782,7 @@ export namespace Aggregation.Query { * A type describing the `$geometry` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geometry/} */ - export interface $geometry { + export interface $geometry { /** * Specifies a geometry in GeoJSON format to geospatial query operators. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/geometry/} @@ -3754,7 +3798,7 @@ export namespace Aggregation.Query { * A type describing the `$gt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/gt/} */ - export interface $gt { + export interface $gt { /** * Matches values that are greater than a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/gt/} @@ -3766,7 +3810,7 @@ export namespace Aggregation.Query { * A type describing the `$gte` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/gte/} */ - export interface $gte { + export interface $gte { /** * Matches values that are greater than or equal to a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/gte/} @@ -3778,7 +3822,7 @@ export namespace Aggregation.Query { * A type describing the `$in` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/in/} */ - export interface $in { + export interface $in { /** * Matches any of the values specified in an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/in/} @@ -3790,7 +3834,7 @@ export namespace Aggregation.Query { * A type describing the `$jsonSchema` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/} */ - export interface $jsonSchema { + export interface $jsonSchema { /** * Validate documents against the given JSON Schema. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/} @@ -3802,7 +3846,7 @@ export namespace Aggregation.Query { * A type describing the `$lt` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/lt/} */ - export interface $lt { + export interface $lt { /** * Matches values that are less than a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/lt/} @@ -3814,7 +3858,7 @@ export namespace Aggregation.Query { * A type describing the `$lte` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/lte/} */ - export interface $lte { + export interface $lte { /** * Matches values that are less than or equal to a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/lte/} @@ -3826,7 +3870,7 @@ export namespace Aggregation.Query { * A type describing the `$maxDistance` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/maxDistance/} */ - export interface $maxDistance { + export interface $maxDistance { /** * Specifies a maximum distance to limit the results of $near and $nearSphere queries. The 2dsphere and 2d indexes support $maxDistance. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/maxDistance/} @@ -3838,7 +3882,7 @@ export namespace Aggregation.Query { * A type describing the `$minDistance` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/minDistance/} */ - export interface $minDistance { + export interface $minDistance { /** * Specifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/minDistance/} @@ -3850,7 +3894,7 @@ export namespace Aggregation.Query { * A type describing the `$mod` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/mod/} */ - export interface $mod { + export interface $mod { /** * Performs a modulo operation on the value of a field and selects documents with a specified result. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/mod/} @@ -3862,7 +3906,7 @@ export namespace Aggregation.Query { * A type describing the `$ne` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/ne/} */ - export interface $ne { + export interface $ne { /** * Matches all values that are not equal to a specified value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/ne/} @@ -3874,7 +3918,7 @@ export namespace Aggregation.Query { * A type describing the `$near` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/near/} */ - export interface $near { + export interface $near { /** * Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/near/} @@ -3896,7 +3940,7 @@ export namespace Aggregation.Query { * A type describing the `$nearSphere` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/} */ - export interface $nearSphere { + export interface $nearSphere { /** * Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/} @@ -3918,7 +3962,7 @@ export namespace Aggregation.Query { * A type describing the `$nin` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nin/} */ - export interface $nin { + export interface $nin { /** * Matches none of the values specified in an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nin/} @@ -3930,7 +3974,7 @@ export namespace Aggregation.Query { * A type describing the `$nor` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nor/} */ - export interface $nor { + export interface $nor { /** * Joins query clauses with a logical NOR returns all documents that fail to match both clauses. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/nor/} @@ -3942,7 +3986,7 @@ export namespace Aggregation.Query { * A type describing the `$not` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/not/} */ - export interface $not { + export interface $not { /** * Inverts the effect of a query expression and returns documents that do not match the query expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/not/} @@ -3954,7 +3998,7 @@ export namespace Aggregation.Query { * A type describing the `$or` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/or/} */ - export interface $or { + export interface $or { /** * Joins query clauses with a logical OR returns all documents that match the conditions of either clause. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/or/} @@ -3966,7 +4010,7 @@ export namespace Aggregation.Query { * A type describing the `$polygon` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/polygon/} */ - export interface $polygon { + export interface $polygon { /** * Specifies a polygon to using legacy coordinate pairs for $geoWithin queries. The 2d index supports $center. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/polygon/} @@ -3978,7 +4022,7 @@ export namespace Aggregation.Query { * A type describing the `$rand` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/rand/} */ - export interface $rand { + export interface $rand { /** * Generates a random float between 0 and 1. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/rand/} @@ -3990,7 +4034,7 @@ export namespace Aggregation.Query { * A type describing the `$regex` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/regex/} */ - export interface $regex { + export interface $regex { /** * Selects documents where values match a specified regular expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/regex/} @@ -4002,7 +4046,7 @@ export namespace Aggregation.Query { * A type describing the `$sampleRate` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/} */ - export interface $sampleRate { + export interface $sampleRate { /** * Randomly select documents at a given rate. Although the exact number of documents selected varies on each run, the quantity chosen approximates the sample rate expressed as a percentage of the total number of documents. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/} @@ -4014,7 +4058,7 @@ export namespace Aggregation.Query { * A type describing the `$size` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/size/} */ - export interface $size { + export interface $size { /** * Selects documents if the array field is a specified size. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/size/} @@ -4026,7 +4070,7 @@ export namespace Aggregation.Query { * A type describing the `$text` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/text/} */ - export interface $text { + export interface $text { /** * Performs text search. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/text/} @@ -4060,7 +4104,7 @@ export namespace Aggregation.Query { * A type describing the `$type` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/type/} */ - export interface $type { + export interface $type { /** * Selects documents if a field is of the specified type. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/type/} @@ -4072,7 +4116,7 @@ export namespace Aggregation.Query { * A type describing the `$where` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/where/} */ - export interface $where { + export interface $where { /** * Matches documents that satisfy a JavaScript expression. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/query/where/} @@ -4085,7 +4129,7 @@ export namespace Aggregation.Search { * A type describing the `autocomplete` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/} */ - export interface Autocomplete { + export interface Autocomplete { /** * The autocomplete operator performs a search for a word or phrase that * contains a sequence of characters from an incomplete input string. The @@ -4106,7 +4150,7 @@ export namespace Aggregation.Search { * A type describing the `compound` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/compound/} */ - export interface Compound { + export interface Compound { /** * The compound operator combines two or more operators into a single query. * Each element of a compound query is called a clause, and each clause @@ -4127,7 +4171,7 @@ export namespace Aggregation.Search { * A type describing the `embeddedDocument` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/} */ - export interface EmbeddedDocument { + export interface EmbeddedDocument { /** * The embeddedDocument operator is similar to $elemMatch operator. * It constrains multiple query predicates to be satisfied from a single @@ -4146,7 +4190,7 @@ export namespace Aggregation.Search { * A type describing the `equals` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/equals/} */ - export interface Equals { + export interface Equals { /** * The equals operator checks whether a field matches a value you specify. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/equals/} @@ -4169,7 +4213,7 @@ export namespace Aggregation.Search { * A type describing the `exists` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/exists/} */ - export interface Exists { + export interface Exists { /** * The exists operator tests if a path to a specified indexed field name exists in a document. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/exists/} @@ -4181,7 +4225,7 @@ export namespace Aggregation.Search { * A type describing the `facet` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/facet/} */ - export interface Facet { + export interface Facet { /** * The facet collector groups results by values or ranges in the specified * faceted fields and returns the count for each of those groups. @@ -4194,7 +4238,7 @@ export namespace Aggregation.Search { * A type describing the `geoShape` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/geoShape/} */ - export interface GeoShape { + export interface GeoShape { /** * The geoShape operator supports querying shapes with a relation to a given * geometry if indexShapes is set to true in the index definition. @@ -4212,7 +4256,7 @@ export namespace Aggregation.Search { * A type describing the `geoWithin` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/} */ - export interface GeoWithin { + export interface GeoWithin { /** * The geoWithin operator supports querying geographic points within a given * geometry. Only points are returned, even if indexShapes value is true in @@ -4232,7 +4276,7 @@ export namespace Aggregation.Search { * A type describing the `in` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/in/} */ - export interface In { + export interface In { /** * The in operator performs a search for an array of BSON values in a field. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/in/} @@ -4244,7 +4288,7 @@ export namespace Aggregation.Search { * A type describing the `moreLikeThis` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/moreLikeThis/} */ - export interface MoreLikeThis { + export interface MoreLikeThis { /** * The moreLikeThis operator returns documents similar to input documents. * The moreLikeThis operator allows you to build features for your applications @@ -4261,7 +4305,7 @@ export namespace Aggregation.Search { * A type describing the `near` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/near/} */ - export interface Near { + export interface Near { /** * The near operator supports querying and scoring numeric, date, and GeoJSON point values. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/near/} @@ -4278,7 +4322,7 @@ export namespace Aggregation.Search { * A type describing the `phrase` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/phrase/} */ - export interface Phrase { + export interface Phrase { /** * The phrase operator performs search for documents containing an ordered sequence of terms using the analyzer specified in the index configuration. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/phrase/} @@ -4296,7 +4340,7 @@ export namespace Aggregation.Search { * A type describing the `queryString` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/queryString/} */ - export interface QueryString { + export interface QueryString { queryString: { defaultPath: SearchPath; query: string }; } @@ -4304,7 +4348,7 @@ export namespace Aggregation.Search { * A type describing the `range` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/range/} */ - export interface Range { + export interface Range { /** * The range operator supports querying and scoring numeric, date, and string values. * You can use this operator to find results that are within a given numeric, date, objectId, or letter (from the English alphabet) range. @@ -4324,7 +4368,7 @@ export namespace Aggregation.Search { * A type describing the `regex` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/regex/} */ - export interface Regex { + export interface Regex { /** * regex interprets the query field as a regular expression. * regex is a term-level operator, meaning that the query field isn't analyzed. @@ -4342,7 +4386,7 @@ export namespace Aggregation.Search { * A type describing the `text` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/text/} */ - export interface Text { + export interface Text { /** * The text operator performs a full-text search using the analyzer that you specify in the index configuration. * If you omit an analyzer, the text operator uses the default standard analyzer. @@ -4362,7 +4406,7 @@ export namespace Aggregation.Search { * A type describing the `wildcard` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/wildcard/} */ - export interface Wildcard { + export interface Wildcard { /** * The wildcard operator enables queries which use special characters in the search string that can match any character. * @see {@link https://www.mongodb.com/docs/atlas/atlas-search/wildcard/} @@ -4380,7 +4424,7 @@ export namespace Aggregation.Stage { * A type describing the `$addFields` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/} */ - export interface $addFields { + export interface $addFields { /** * Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/} @@ -4396,7 +4440,7 @@ export namespace Aggregation.Stage { * A type describing the `$bucket` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/} */ - export interface $bucket { + export interface $bucket { /** * Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/} @@ -4435,7 +4479,7 @@ export namespace Aggregation.Stage { * A type describing the `$bucketAuto` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/} */ - export interface $bucketAuto { + export interface $bucketAuto { /** * Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/} @@ -4469,7 +4513,7 @@ export namespace Aggregation.Stage { * A type describing the `$changeStream` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/} */ - export interface $changeStream { + export interface $changeStream { /** * Returns a Change Stream cursor for the collection or database. This stage can only occur once in an aggregation pipeline and it must occur as the first stage. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/} @@ -4516,7 +4560,7 @@ export namespace Aggregation.Stage { * A type describing the `$changeStreamSplitLargeEvent` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/} */ - export interface $changeStreamSplitLargeEvent { + export interface $changeStreamSplitLargeEvent { /** * Splits large change stream events that exceed 16 MB into smaller fragments returned in a change stream cursor. * You can only use $changeStreamSplitLargeEvent in a $changeStream pipeline and it must be the final stage in the pipeline. @@ -4529,7 +4573,7 @@ export namespace Aggregation.Stage { * A type describing the `$collStats` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/} */ - export interface $collStats { + export interface $collStats { /** * Returns statistics regarding a collection or view. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/} @@ -4546,7 +4590,7 @@ export namespace Aggregation.Stage { * A type describing the `$count` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/} */ - export interface $count { + export interface $count { /** * Returns a count of the number of documents at this stage of the aggregation pipeline. * Distinct from the $count aggregation accumulator. @@ -4559,7 +4603,7 @@ export namespace Aggregation.Stage { * A type describing the `$currentOp` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/} */ - export interface $currentOp { + export interface $currentOp { /** * Returns information on active and/or dormant operations for the MongoDB deployment. To run, use the db.aggregate() method. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/} @@ -4577,7 +4621,7 @@ export namespace Aggregation.Stage { * A type describing the `$densify` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/} */ - export interface $densify { + export interface $densify { /** * Creates new documents in a sequence of documents where certain values in a field are missing. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/} @@ -4606,7 +4650,7 @@ export namespace Aggregation.Stage { * A type describing the `$documents` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/} */ - export interface $documents { + export interface $documents { /** * Returns literal documents from input values. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/} @@ -4618,7 +4662,7 @@ export namespace Aggregation.Stage { * A type describing the `$facet` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/} */ - export interface $facet { + export interface $facet { /** * Processes multiple aggregation pipelines within a single stage on the same set of input documents. Enables the creation of multi-faceted aggregations capable of characterizing data across multiple dimensions, or facets, in a single stage. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/} @@ -4630,7 +4674,7 @@ export namespace Aggregation.Stage { * A type describing the `$fill` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/} */ - export interface $fill { + export interface $fill { /** * Populates null and missing field values within documents. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/} @@ -4667,7 +4711,7 @@ export namespace Aggregation.Stage { * A type describing the `$geoNear` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/} */ - export interface $geoNear { + export interface $geoNear { /** * Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/} @@ -4730,7 +4774,7 @@ export namespace Aggregation.Stage { * A type describing the `$graphLookup` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/} */ - export interface $graphLookup { + export interface $graphLookup { /** * Performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/} @@ -4783,7 +4827,7 @@ export namespace Aggregation.Stage { * A type describing the `$group` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/} */ - export interface $group { + export interface $group { /** * Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/} @@ -4806,7 +4850,7 @@ export namespace Aggregation.Stage { * A type describing the `$indexStats` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/} */ - export interface $indexStats { + export interface $indexStats { /** * Returns statistics regarding the use of each index for the collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/} @@ -4818,7 +4862,7 @@ export namespace Aggregation.Stage { * A type describing the `$limit` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/} */ - export interface $limit { + export interface $limit { /** * Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/} @@ -4830,7 +4874,7 @@ export namespace Aggregation.Stage { * A type describing the `$listLocalSessions` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/} */ - export interface $listLocalSessions { + export interface $listLocalSessions { /** * Lists all active sessions recently in use on the currently connected mongos or mongod instance. These sessions may have not yet propagated to the system.sessions collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/} @@ -4852,7 +4896,7 @@ export namespace Aggregation.Stage { * A type describing the `$listSampledQueries` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/} */ - export interface $listSampledQueries { + export interface $listSampledQueries { /** * Lists sampled queries for all collections or a specific collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/} @@ -4864,7 +4908,7 @@ export namespace Aggregation.Stage { * A type describing the `$listSearchIndexes` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/} */ - export interface $listSearchIndexes { + export interface $listSearchIndexes { /** * Returns information about existing Atlas Search indexes on a specified collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/} @@ -4886,7 +4930,7 @@ export namespace Aggregation.Stage { * A type describing the `$listSessions` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/} */ - export interface $listSessions { + export interface $listSessions { /** * Lists all sessions that have been active long enough to propagate to the system.sessions collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/} @@ -4908,7 +4952,7 @@ export namespace Aggregation.Stage { * A type describing the `$lookup` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/} */ - export interface $lookup { + export interface $lookup { /** * Performs a left outer join to another collection in the same database to filter in documents from the "joined" collection for processing. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/} @@ -4954,7 +4998,7 @@ export namespace Aggregation.Stage { * A type describing the `$match` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/} */ - export interface $match { + export interface $match { /** * Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/} @@ -4966,7 +5010,7 @@ export namespace Aggregation.Stage { * A type describing the `$merge` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/} */ - export interface $merge { + export interface $merge { /** * Writes the resulting documents of the aggregation pipeline to a collection. The stage can incorporate (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) the results into an output collection. To use the $merge stage, it must be the last stage in the pipeline. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/} @@ -4990,7 +5034,7 @@ export namespace Aggregation.Stage { /** * The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s). */ - whenMatched?: WhenMatched | Pipeline; + whenMatched?: WhenMatched | UpdatePipeline; /** * The behavior of $merge if a result document does not match an existing document in the out collection. @@ -5003,7 +5047,7 @@ export namespace Aggregation.Stage { * A type describing the `$out` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/} */ - export interface $out { + export interface $out { /** * Writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/} @@ -5015,7 +5059,7 @@ export namespace Aggregation.Stage { * A type describing the `$planCacheStats` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/} */ - export interface $planCacheStats { + export interface $planCacheStats { /** * Returns plan cache information for a collection. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/} @@ -5027,7 +5071,7 @@ export namespace Aggregation.Stage { * A type describing the `$project` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/} */ - export interface $project { + export interface $project { /** * Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/} @@ -5039,7 +5083,7 @@ export namespace Aggregation.Stage { * A type describing the `$redact` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/} */ - export interface $redact { + export interface $redact { /** * Reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/} @@ -5051,7 +5095,7 @@ export namespace Aggregation.Stage { * A type describing the `$replaceRoot` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/} */ - export interface $replaceRoot { + export interface $replaceRoot { /** * Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/} @@ -5063,7 +5107,7 @@ export namespace Aggregation.Stage { * A type describing the `$replaceWith` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/} */ - export interface $replaceWith { + export interface $replaceWith { /** * Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. * Alias for $replaceRoot. @@ -5076,7 +5120,7 @@ export namespace Aggregation.Stage { * A type describing the `$sample` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/} */ - export interface $sample { + export interface $sample { /** * Randomly selects the specified number of documents from its input. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/} @@ -5093,7 +5137,7 @@ export namespace Aggregation.Stage { * A type describing the `$scoreFusion` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/scoreFusion/} */ - export interface $scoreFusion { + export interface $scoreFusion { /** * Combines multiple pipelines using relative score fusion to create hybrid search results. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/scoreFusion/} @@ -5125,7 +5169,7 @@ export namespace Aggregation.Stage { * A type describing the `$search` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/} */ - export interface $search { + export interface $search { /** * Performs a full-text search of the field or fields in an Atlas collection. * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. @@ -5190,7 +5234,7 @@ export namespace Aggregation.Stage { * A type describing the `$searchMeta` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/} */ - export interface $searchMeta { + export interface $searchMeta { /** * Returns different types of metadata result documents for the Atlas Search query against an Atlas collection. * NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. @@ -5213,7 +5257,7 @@ export namespace Aggregation.Stage { * A type describing the `$set` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/} */ - export interface $set { + export interface $set { /** * Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. * Alias for $addFields. @@ -5226,7 +5270,7 @@ export namespace Aggregation.Stage { * A type describing the `$setWindowFields` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/} */ - export interface $setWindowFields { + export interface $setWindowFields { /** * Groups documents into windows and applies one or more operators to the documents in each window. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/} @@ -5254,7 +5298,7 @@ export namespace Aggregation.Stage { * A type describing the `$shardedDataDistribution` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/} */ - export interface $shardedDataDistribution { + export interface $shardedDataDistribution { /** * Provides data and size distribution information on sharded collections. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/} @@ -5266,7 +5310,7 @@ export namespace Aggregation.Stage { * A type describing the `$skip` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/} */ - export interface $skip { + export interface $skip { /** * Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/} @@ -5278,7 +5322,7 @@ export namespace Aggregation.Stage { * A type describing the `$sort` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/} */ - export interface $sort { + export interface $sort { /** * Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/} @@ -5290,7 +5334,7 @@ export namespace Aggregation.Stage { * A type describing the `$sortByCount` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/} */ - export interface $sortByCount { + export interface $sortByCount { /** * Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/} @@ -5302,7 +5346,7 @@ export namespace Aggregation.Stage { * A type describing the `$unionWith` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/} */ - export interface $unionWith { + export interface $unionWith { /** * Performs a union of two collections; i.e. combines pipeline results from two collections into a single result set. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/} @@ -5325,7 +5369,7 @@ export namespace Aggregation.Stage { * A type describing the `$unset` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/} */ - export interface $unset { + export interface $unset { /** * Removes or excludes fields from documents. * Alias for $project stage that removes or excludes fields. @@ -5338,7 +5382,7 @@ export namespace Aggregation.Stage { * A type describing the `$unwind` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/} */ - export interface $unwind { + export interface $unwind { /** * Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/} @@ -5367,7 +5411,7 @@ export namespace Aggregation.Stage { * A type describing the `$vectorSearch` operator. * @see {@link https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/} */ - export interface $vectorSearch { + export interface $vectorSearch { /** * The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. * @see {@link https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/} @@ -5416,7 +5460,7 @@ export namespace Aggregation.Update { * A type describing the `$addToSet` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/addToSet/} */ - export interface $addToSet { + export interface $addToSet { /** * Adds a value to an array unless the value is already present. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/addToSet/} @@ -5428,7 +5472,7 @@ export namespace Aggregation.Update { * A type describing the `$bit` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/bit/} */ - export interface $bit { + export interface $bit { /** * Performs bitwise updates of integer values. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/bit/} @@ -5445,7 +5489,7 @@ export namespace Aggregation.Update { * A type describing the `$currentDate` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/currentDate/} */ - export interface $currentDate { + export interface $currentDate { /** * Sets the value of a field to the current date as either a Date or Timestamp. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/currentDate/} @@ -5463,7 +5507,7 @@ export namespace Aggregation.Update { * A type describing the `$inc` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/inc/} */ - export interface $inc { + export interface $inc { /** * Increments a field by the specified numeric amount. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/inc/} @@ -5475,7 +5519,7 @@ export namespace Aggregation.Update { * A type describing the `$max` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/max/} */ - export interface $max { + export interface $max { /** * Updates a field only if the specified value is greater than the current field value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/max/} @@ -5487,7 +5531,7 @@ export namespace Aggregation.Update { * A type describing the `$min` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/min/} */ - export interface $min { + export interface $min { /** * Updates a field only if the specified value is less than the current field value. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/min/} @@ -5499,7 +5543,7 @@ export namespace Aggregation.Update { * A type describing the `$mul` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/mul/} */ - export interface $mul { + export interface $mul { /** * Multiplies the value of a field by the specified number. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/mul/} @@ -5511,7 +5555,7 @@ export namespace Aggregation.Update { * A type describing the `$pop` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pop/} */ - export interface $pop { + export interface $pop { /** * Removes the first or last element of an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pop/} @@ -5523,7 +5567,7 @@ export namespace Aggregation.Update { * A type describing the `$pull` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pull/} */ - export interface $pull { + export interface $pull { /** * Removes all array elements that match a specified value or condition. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pull/} @@ -5535,7 +5579,7 @@ export namespace Aggregation.Update { * A type describing the `$pullAll` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pullAll/} */ - export interface $pullAll { + export interface $pullAll { /** * Removes all matching values from an array. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/pullAll/} @@ -5547,7 +5591,7 @@ export namespace Aggregation.Update { * A type describing the `$push` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/push/} */ - export interface $push { + export interface $push { /** * Appends a specified value to an array, with optional modifiers. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/push/} @@ -5559,7 +5603,7 @@ export namespace Aggregation.Update { * A type describing the `$rename` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/rename/} */ - export interface $rename { + export interface $rename { /** * Renames a field. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/rename/} @@ -5571,7 +5615,7 @@ export namespace Aggregation.Update { * A type describing the `$set` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/set/} */ - export interface $set { + export interface $set { /** * Sets the value of a field. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/set/} @@ -5583,7 +5627,7 @@ export namespace Aggregation.Update { * A type describing the `$setOnInsert` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/setOnInsert/} */ - export interface $setOnInsert { + export interface $setOnInsert { /** * Sets the value of a field if an update with upsert creates a new document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/setOnInsert/} @@ -5595,7 +5639,7 @@ export namespace Aggregation.Update { * A type describing the `$unset` operator. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/unset/} */ - export interface $unset { + export interface $unset { /** * Removes the specified field from a document. * @see {@link https://www.mongodb.com/docs/manual/reference/operator/update/unset/} @@ -5613,7 +5657,7 @@ export type Regex = | { pattern: string; options?: string }; export type Long = bigint | bson.Long | { $numberLong: string }; export type Javascript = bson.Code | Function | string; -export type Geometry = +export type Geometry = | { type: 'Point'; coordinates: number[] } | { type: 'MultiPoint'; coordinates: number[][] } | { type: 'LineString'; coordinates: number[][] } @@ -5637,7 +5681,7 @@ export type BsonPrimitive = | Regex | Javascript | bson.Timestamp; -export type SearchPath = +export type SearchPath = | UnprefixedFieldPath | UnprefixedFieldPath[] | { wildcard: string }; @@ -5667,17 +5711,17 @@ export type TimeUnit = export type OutCollection = unknown; export type WhenMatched = string; export type WhenNotMatched = string; -export type Expression = - | ExpressionOperator - | FieldPath +export type Expression = + | ExpressionOperator + | FieldPath | BsonPrimitive - | FieldExpression + | FieldExpression | FieldPath[]; -export type ExpressionMap = { - [k: string]: Expression | ExpressionMap; +export type ExpressionMap = { + [k: string]: Expression | ExpressionMap; }; -export type Stage = - | StageOperator +export type Stage = + | StageOperator | Aggregation.Stage.$addFields | Aggregation.Stage.$bucket | Aggregation.Stage.$bucketAuto @@ -5722,9 +5766,20 @@ export type Stage = | Aggregation.Stage.$unset | Aggregation.Stage.$unwind | Aggregation.Stage.$vectorSearch; -export type Pipeline = Stage[]; +export type UpdateStage = + | Aggregation.Stage.$addFields + | Aggregation.Stage.$project + | Aggregation.Stage.$replaceRoot + | Aggregation.Stage.$replaceWith + | Aggregation.Stage.$set + | Aggregation.Stage.$unset; +export type Pipeline = + | Stage[] + | Aggregation.Pipeline.Pipeline + | Aggregation.Pipeline.UpdatePipeline; +export type UpdatePipeline = UpdatePipeline[]; export type UntypedPipeline = Pipeline; -export type Query = +export type Query = | QueryOperator | Partial<{ [k in keyof S]: Condition }> | Aggregation.Query.$and @@ -5736,7 +5791,7 @@ export type Query = | Aggregation.Query.$sampleRate | Aggregation.Query.$text | Aggregation.Query.$where; -export type Accumulator = +export type Accumulator = | Aggregation.Accumulator.$accumulator | Aggregation.Accumulator.$addToSet | Aggregation.Accumulator.$avg @@ -5762,7 +5817,7 @@ export type Accumulator = | Aggregation.Accumulator.$sum | Aggregation.Accumulator.$top | Aggregation.Accumulator.$topN; -export type SearchHighlight = { +export type SearchHighlight = { path: | UnprefixedFieldPath | UnprefixedFieldPath[] @@ -5774,26 +5829,32 @@ export type SearchHighlight = { maxCharsToExamine?: number; maxNumPassages?: number; }; -export type FieldPath = `$${AFieldPath}`; -export type UnprefixedFieldPath = AFieldPath; -export type NumberFieldPath = `$${AFieldPath}`; -export type DoubleFieldPath = `$${AFieldPath}`; -export type StringFieldPath = `$${AFieldPath}`; -export type ObjectFieldPath = `$${AFieldPath>}`; -export type ArrayFieldPath = `$${AFieldPath}`; -export type BinDataFieldPath = `$${AFieldPath}`; -export type ObjectIdFieldPath = `$${AFieldPath}`; -export type BoolFieldPath = `$${AFieldPath}`; -export type DateFieldPath = `$${AFieldPath}`; -export type NullFieldPath = `$${AFieldPath}`; -export type RegexFieldPath = `$${AFieldPath}`; -export type JavascriptFieldPath = `$${AFieldPath}`; -export type IntFieldPath = `$${AFieldPath}`; -export type TimestampFieldPath = `$${AFieldPath}`; -export type LongFieldPath = `$${AFieldPath}`; -export type DecimalFieldPath = `$${AFieldPath}`; -export type ResolvesToNumber = - | ResolvesToAny +export type FieldPath = `$${AFieldPath}`; +export type UnprefixedFieldPath = AFieldPath; +export type NumberFieldPath = `$${AFieldPath}`; +export type DoubleFieldPath = `$${AFieldPath}`; +export type StringFieldPath = `$${AFieldPath}`; +export type ObjectFieldPath< + S, + T = any, +> = `$${AFieldPath>}`; +export type ArrayFieldPath = `$${AFieldPath}`; +export type BinDataFieldPath = `$${AFieldPath}`; +export type ObjectIdFieldPath = `$${AFieldPath}`; +export type BoolFieldPath = `$${AFieldPath}`; +export type DateFieldPath = `$${AFieldPath}`; +export type NullFieldPath = `$${AFieldPath}`; +export type RegexFieldPath = `$${AFieldPath}`; +export type JavascriptFieldPath = `$${AFieldPath}`; +export type IntFieldPath = `$${AFieldPath}`; +export type TimestampFieldPath< + S, + T = any, +> = `$${AFieldPath}`; +export type LongFieldPath = `$${AFieldPath}`; +export type DecimalFieldPath = `$${AFieldPath}`; +export type ResolvesToNumber = + | ResolvesToAny | NumberFieldPath | Number | ResolvesToInt @@ -5804,8 +5865,8 @@ export type ResolvesToNumber = | Aggregation.Expression.$avg | Aggregation.Expression.$pow | Aggregation.Expression.$sum; -export type ResolvesToDouble = - | ResolvesToAny +export type ResolvesToDouble = + | ResolvesToAny | DoubleFieldPath | Double | Aggregation.Expression.$acos @@ -5838,8 +5899,8 @@ export type ResolvesToDouble = | Aggregation.Expression.$tanh | Aggregation.Expression.$toDouble | Aggregation.Query.$rand; -export type ResolvesToString = - | ResolvesToAny +export type ResolvesToString = + | ResolvesToAny | StringFieldPath | string | Aggregation.Expression.$concat @@ -5857,54 +5918,54 @@ export type ResolvesToString = | Aggregation.Expression.$trim | Aggregation.Expression.$trunc | Aggregation.Expression.$type; -export type ResolvesToObject = +export type ResolvesToObject = | '$$ROOT' - | ResolvesToAny - | ObjectFieldPath + | ResolvesToAny> + | ObjectFieldPath | Record - | Aggregation.Expression.$arrayToObject + | Aggregation.Expression.$arrayToObject | Aggregation.Expression.$dateToParts | Aggregation.Expression.$mergeObjects | Aggregation.Expression.$regexFind | Aggregation.Expression.$setField | Aggregation.Expression.$unsetField; -export type ResolvesToArray = - | ResolvesToAny +export type ResolvesToArray = + | ResolvesToAny> | ArrayFieldPath - | unknown[] + | ArrayOnly | Aggregation.Accumulator.$concatArrays | Aggregation.Accumulator.$setUnion - | Aggregation.Expression.$concatArrays - | Aggregation.Expression.$filter - | Aggregation.Expression.$firstN - | Aggregation.Expression.$lastN + | Aggregation.Expression.$concatArrays + | Aggregation.Expression.$filter + | Aggregation.Expression.$firstN + | Aggregation.Expression.$lastN | Aggregation.Expression.$map - | Aggregation.Expression.$maxN - | Aggregation.Expression.$minN - | Aggregation.Expression.$objectToArray + | Aggregation.Expression.$maxN + | Aggregation.Expression.$minN + | Aggregation.Expression.$objectToArray | Aggregation.Expression.$percentile | Aggregation.Expression.$range | Aggregation.Expression.$regexFindAll | Aggregation.Expression.$reverseArray - | Aggregation.Expression.$setDifference - | Aggregation.Expression.$setIntersection + | Aggregation.Expression.$setDifference + | Aggregation.Expression.$setIntersection | Aggregation.Expression.$setUnion | Aggregation.Expression.$slice - | Aggregation.Expression.$sortArray + | Aggregation.Expression.$sortArray | Aggregation.Expression.$split | Aggregation.Expression.$zip; -export type ResolvesToBinData = - | ResolvesToAny +export type ResolvesToBinData = + | ResolvesToAny | BinDataFieldPath | bson.Binary; -export type ResolvesToObjectId = - | ResolvesToAny +export type ResolvesToObjectId = + | ResolvesToAny | ObjectIdFieldPath | bson.ObjectId | Aggregation.Expression.$createObjectId | Aggregation.Expression.$toObjectId; -export type ResolvesToBool = - | ResolvesToAny +export type ResolvesToBool = + | ResolvesToAny | BoolFieldPath | boolean | Aggregation.Expression.$allElementsTrue @@ -5925,9 +5986,9 @@ export type ResolvesToBool = | Aggregation.Expression.$setEquals | Aggregation.Expression.$setIsSubset | Aggregation.Expression.$toBool; -export type ResolvesToDate = +export type ResolvesToDate = | '$$NOW' - | ResolvesToAny + | ResolvesToAny | DateFieldPath | Date | Aggregation.Expression.$add @@ -5938,14 +5999,20 @@ export type ResolvesToDate = | Aggregation.Expression.$dateTrunc | Aggregation.Expression.$subtract | Aggregation.Expression.$toDate; -export type ResolvesToNull = ResolvesToAny | NullFieldPath | null; -export type ResolvesToRegex = ResolvesToAny | RegexFieldPath | Regex; -export type ResolvesToJavascript = - | ResolvesToAny +export type ResolvesToNull = + | ResolvesToAny + | NullFieldPath + | null; +export type ResolvesToRegex = + | ResolvesToAny + | RegexFieldPath + | Regex; +export type ResolvesToJavascript = + | ResolvesToAny | JavascriptFieldPath | Javascript; -export type ResolvesToInt = - | ResolvesToAny +export type ResolvesToInt = + | ResolvesToAny | IntFieldPath | Int | Aggregation.Expression.$add @@ -5983,13 +6050,13 @@ export type ResolvesToInt = | Aggregation.Expression.$toInt | Aggregation.Expression.$week | Aggregation.Expression.$year; -export type ResolvesToTimestamp = - | ResolvesToAny +export type ResolvesToTimestamp = + | ResolvesToAny | TimestampFieldPath | bson.Timestamp | '$clusterTime'; -export type ResolvesToLong = - | ResolvesToAny +export type ResolvesToLong = + | ResolvesToAny | LongFieldPath | Long | Aggregation.Expression.$add @@ -6003,8 +6070,8 @@ export type ResolvesToLong = | Aggregation.Expression.$toLong | Aggregation.Expression.$tsIncrement | Aggregation.Expression.$tsSecond; -export type ResolvesToDecimal = - | ResolvesToAny +export type ResolvesToDecimal = + | ResolvesToAny | DecimalFieldPath | Decimal | Aggregation.Expression.$acos @@ -6027,44 +6094,44 @@ export type ResolvesToDecimal = | Aggregation.Expression.$tan | Aggregation.Expression.$tanh | Aggregation.Expression.$toDecimal; -export type AccumulatorOperator = - | Aggregation.Accumulator.$accumulator - | Aggregation.Accumulator.$addToSet - | Aggregation.Accumulator.$avg - | Aggregation.Accumulator.$bottom - | Aggregation.Accumulator.$bottomN - | Aggregation.Accumulator.$concatArrays - | Aggregation.Accumulator.$count - | Aggregation.Accumulator.$covariancePop - | Aggregation.Accumulator.$covarianceSamp - | Aggregation.Accumulator.$denseRank - | Aggregation.Accumulator.$derivative - | Aggregation.Accumulator.$documentNumber - | Aggregation.Accumulator.$expMovingAvg - | Aggregation.Accumulator.$first - | Aggregation.Accumulator.$firstN - | Aggregation.Accumulator.$integral - | Aggregation.Accumulator.$last - | Aggregation.Accumulator.$lastN - | Aggregation.Accumulator.$linearFill - | Aggregation.Accumulator.$locf - | Aggregation.Accumulator.$max - | Aggregation.Accumulator.$maxN - | Aggregation.Accumulator.$median - | Aggregation.Accumulator.$mergeObjects - | Aggregation.Accumulator.$min - | Aggregation.Accumulator.$minN - | Aggregation.Accumulator.$percentile - | Aggregation.Accumulator.$push - | Aggregation.Accumulator.$rank - | Aggregation.Accumulator.$setUnion - | Aggregation.Accumulator.$shift - | Aggregation.Accumulator.$stdDevPop - | Aggregation.Accumulator.$stdDevSamp - | Aggregation.Accumulator.$sum - | Aggregation.Accumulator.$top - | Aggregation.Accumulator.$topN; -export type Window = +export type AccumulatorOperator = + | Aggregation.Accumulator.$accumulator + | Aggregation.Accumulator.$addToSet + | Aggregation.Accumulator.$avg + | Aggregation.Accumulator.$bottom + | Aggregation.Accumulator.$bottomN + | Aggregation.Accumulator.$concatArrays + | Aggregation.Accumulator.$count + | Aggregation.Accumulator.$covariancePop + | Aggregation.Accumulator.$covarianceSamp + | Aggregation.Accumulator.$denseRank + | Aggregation.Accumulator.$derivative + | Aggregation.Accumulator.$documentNumber + | Aggregation.Accumulator.$expMovingAvg + | Aggregation.Accumulator.$first + | Aggregation.Accumulator.$firstN + | Aggregation.Accumulator.$integral + | Aggregation.Accumulator.$last + | Aggregation.Accumulator.$lastN + | Aggregation.Accumulator.$linearFill + | Aggregation.Accumulator.$locf + | Aggregation.Accumulator.$max + | Aggregation.Accumulator.$maxN + | Aggregation.Accumulator.$median + | Aggregation.Accumulator.$mergeObjects + | Aggregation.Accumulator.$min + | Aggregation.Accumulator.$minN + | Aggregation.Accumulator.$percentile + | Aggregation.Accumulator.$push + | Aggregation.Accumulator.$rank + | Aggregation.Accumulator.$setUnion + | Aggregation.Accumulator.$shift + | Aggregation.Accumulator.$stdDevPop + | Aggregation.Accumulator.$stdDevSamp + | Aggregation.Accumulator.$sum + | Aggregation.Accumulator.$top + | Aggregation.Accumulator.$topN; +export type Window = | Aggregation.Accumulator.$addToSet | Aggregation.Accumulator.$avg | Aggregation.Accumulator.$bottom @@ -6097,169 +6164,169 @@ export type Window = | Aggregation.Accumulator.$stdDevPop | Aggregation.Accumulator.$stdDevSamp | Aggregation.Accumulator.$sum; -export type ExpressionOperator = - | Aggregation.Expression.$abs - | Aggregation.Expression.$acos - | Aggregation.Expression.$acosh - | Aggregation.Expression.$add - | Aggregation.Expression.$allElementsTrue - | Aggregation.Expression.$and - | Aggregation.Expression.$anyElementTrue - | Aggregation.Expression.$arrayElemAt - | Aggregation.Expression.$arrayToObject - | Aggregation.Expression.$asin - | Aggregation.Expression.$asinh - | Aggregation.Expression.$atan - | Aggregation.Expression.$atan2 - | Aggregation.Expression.$atanh - | Aggregation.Expression.$avg - | Aggregation.Expression.$binarySize - | Aggregation.Expression.$bitAnd - | Aggregation.Expression.$bitNot - | Aggregation.Expression.$bitOr - | Aggregation.Expression.$bitXor - | Aggregation.Expression.$bsonSize - | Aggregation.Expression.$case - | Aggregation.Expression.$ceil - | Aggregation.Expression.$cmp - | Aggregation.Expression.$concat - | Aggregation.Expression.$concatArrays +export type ExpressionOperator = + | Aggregation.Expression.$abs + | Aggregation.Expression.$acos + | Aggregation.Expression.$acosh + | Aggregation.Expression.$add + | Aggregation.Expression.$allElementsTrue + | Aggregation.Expression.$and + | Aggregation.Expression.$anyElementTrue + | Aggregation.Expression.$arrayElemAt + | Aggregation.Expression.$arrayToObject + | Aggregation.Expression.$asin + | Aggregation.Expression.$asinh + | Aggregation.Expression.$atan + | Aggregation.Expression.$atan2 + | Aggregation.Expression.$atanh + | Aggregation.Expression.$avg + | Aggregation.Expression.$binarySize + | Aggregation.Expression.$bitAnd + | Aggregation.Expression.$bitNot + | Aggregation.Expression.$bitOr + | Aggregation.Expression.$bitXor + | Aggregation.Expression.$bsonSize + | Aggregation.Expression.$case + | Aggregation.Expression.$ceil + | Aggregation.Expression.$cmp + | Aggregation.Expression.$concat + | Aggregation.Expression.$concatArrays + | Aggregation.Expression.$cond + | Aggregation.Expression.$convert + | Aggregation.Expression.$cos + | Aggregation.Expression.$cosh + | Aggregation.Expression.$createObjectId + | Aggregation.Expression.$dateAdd + | Aggregation.Expression.$dateDiff + | Aggregation.Expression.$dateFromParts + | Aggregation.Expression.$dateFromString + | Aggregation.Expression.$dateSubtract + | Aggregation.Expression.$dateToParts + | Aggregation.Expression.$dateToString + | Aggregation.Expression.$dateTrunc + | Aggregation.Expression.$dayOfMonth + | Aggregation.Expression.$dayOfWeek + | Aggregation.Expression.$dayOfYear + | Aggregation.Expression.$degreesToRadians + | Aggregation.Expression.$divide + | Aggregation.Expression.$eq + | Aggregation.Expression.$exp + | Aggregation.Expression.$filter + | Aggregation.Expression.$first + | Aggregation.Expression.$firstN + | Aggregation.Expression.$floor + | Aggregation.Expression.$function + | Aggregation.Expression.$getField + | Aggregation.Expression.$gt + | Aggregation.Expression.$gte + | Aggregation.Expression.$hour + | Aggregation.Expression.$ifNull + | Aggregation.Expression.$in + | Aggregation.Expression.$indexOfArray + | Aggregation.Expression.$indexOfBytes + | Aggregation.Expression.$indexOfCP + | Aggregation.Expression.$isArray + | Aggregation.Expression.$isNumber + | Aggregation.Expression.$isoDayOfWeek + | Aggregation.Expression.$isoWeek + | Aggregation.Expression.$isoWeekYear + | Aggregation.Expression.$last + | Aggregation.Expression.$lastN + | Aggregation.Expression.$let + | Aggregation.Expression.$literal + | Aggregation.Expression.$ln + | Aggregation.Expression.$log + | Aggregation.Expression.$log10 + | Aggregation.Expression.$lt + | Aggregation.Expression.$lte + | Aggregation.Expression.$ltrim + | Aggregation.Expression.$map + | Aggregation.Expression.$max + | Aggregation.Expression.$maxN + | Aggregation.Expression.$median + | Aggregation.Expression.$mergeObjects + | Aggregation.Expression.$meta + | Aggregation.Expression.$millisecond + | Aggregation.Expression.$min + | Aggregation.Expression.$minN + | Aggregation.Expression.$minute + | Aggregation.Expression.$mod + | Aggregation.Expression.$month + | Aggregation.Expression.$multiply + | Aggregation.Expression.$ne + | Aggregation.Expression.$not + | Aggregation.Expression.$objectToArray + | Aggregation.Expression.$or + | Aggregation.Expression.$percentile + | Aggregation.Expression.$pow + | Aggregation.Expression.$radiansToDegrees + | Aggregation.Expression.$rand + | Aggregation.Expression.$range + | Aggregation.Expression.$reduce + | Aggregation.Expression.$regexFind + | Aggregation.Expression.$regexFindAll + | Aggregation.Expression.$regexMatch + | Aggregation.Expression.$replaceAll + | Aggregation.Expression.$replaceOne + | Aggregation.Expression.$reverseArray + | Aggregation.Expression.$round + | Aggregation.Expression.$rtrim + | Aggregation.Expression.$second + | Aggregation.Expression.$setDifference + | Aggregation.Expression.$setEquals + | Aggregation.Expression.$setField + | Aggregation.Expression.$setIntersection + | Aggregation.Expression.$setIsSubset + | Aggregation.Expression.$setUnion + | Aggregation.Expression.$sin + | Aggregation.Expression.$sinh + | Aggregation.Expression.$size + | Aggregation.Expression.$slice + | Aggregation.Expression.$sortArray + | Aggregation.Expression.$split + | Aggregation.Expression.$sqrt + | Aggregation.Expression.$stdDevPop + | Aggregation.Expression.$stdDevSamp + | Aggregation.Expression.$strLenBytes + | Aggregation.Expression.$strLenCP + | Aggregation.Expression.$strcasecmp + | Aggregation.Expression.$substr + | Aggregation.Expression.$substrBytes + | Aggregation.Expression.$substrCP + | Aggregation.Expression.$subtract + | Aggregation.Expression.$sum + | Aggregation.Expression.$switch + | Aggregation.Expression.$tan + | Aggregation.Expression.$tanh + | Aggregation.Expression.$toBool + | Aggregation.Expression.$toDate + | Aggregation.Expression.$toDecimal + | Aggregation.Expression.$toDouble + | Aggregation.Expression.$toHashedIndexKey + | Aggregation.Expression.$toInt + | Aggregation.Expression.$toLong + | Aggregation.Expression.$toLower + | Aggregation.Expression.$toObjectId + | Aggregation.Expression.$toString + | Aggregation.Expression.$toUpper + | Aggregation.Expression.$trim + | Aggregation.Expression.$trunc + | Aggregation.Expression.$tsIncrement + | Aggregation.Expression.$tsSecond + | Aggregation.Expression.$type + | Aggregation.Expression.$unsetField + | Aggregation.Expression.$week + | Aggregation.Expression.$year + | Aggregation.Expression.$zip; +export type ResolvesToAny = + | Aggregation.Expression.$arrayElemAt | Aggregation.Expression.$cond | Aggregation.Expression.$convert - | Aggregation.Expression.$cos - | Aggregation.Expression.$cosh - | Aggregation.Expression.$createObjectId - | Aggregation.Expression.$dateAdd - | Aggregation.Expression.$dateDiff - | Aggregation.Expression.$dateFromParts - | Aggregation.Expression.$dateFromString - | Aggregation.Expression.$dateSubtract - | Aggregation.Expression.$dateToParts - | Aggregation.Expression.$dateToString - | Aggregation.Expression.$dateTrunc - | Aggregation.Expression.$dayOfMonth - | Aggregation.Expression.$dayOfWeek - | Aggregation.Expression.$dayOfYear - | Aggregation.Expression.$degreesToRadians - | Aggregation.Expression.$divide - | Aggregation.Expression.$eq - | Aggregation.Expression.$exp - | Aggregation.Expression.$filter - | Aggregation.Expression.$first - | Aggregation.Expression.$firstN - | Aggregation.Expression.$floor + | Aggregation.Expression.$first | Aggregation.Expression.$function | Aggregation.Expression.$getField - | Aggregation.Expression.$gt - | Aggregation.Expression.$gte - | Aggregation.Expression.$hour | Aggregation.Expression.$ifNull - | Aggregation.Expression.$in - | Aggregation.Expression.$indexOfArray - | Aggregation.Expression.$indexOfBytes - | Aggregation.Expression.$indexOfCP - | Aggregation.Expression.$isArray - | Aggregation.Expression.$isNumber - | Aggregation.Expression.$isoDayOfWeek - | Aggregation.Expression.$isoWeek - | Aggregation.Expression.$isoWeekYear - | Aggregation.Expression.$last - | Aggregation.Expression.$lastN - | Aggregation.Expression.$let - | Aggregation.Expression.$literal - | Aggregation.Expression.$ln - | Aggregation.Expression.$log - | Aggregation.Expression.$log10 - | Aggregation.Expression.$lt - | Aggregation.Expression.$lte - | Aggregation.Expression.$ltrim - | Aggregation.Expression.$map - | Aggregation.Expression.$max - | Aggregation.Expression.$maxN - | Aggregation.Expression.$median - | Aggregation.Expression.$mergeObjects - | Aggregation.Expression.$meta - | Aggregation.Expression.$millisecond - | Aggregation.Expression.$min - | Aggregation.Expression.$minN - | Aggregation.Expression.$minute - | Aggregation.Expression.$mod - | Aggregation.Expression.$month - | Aggregation.Expression.$multiply - | Aggregation.Expression.$ne - | Aggregation.Expression.$not - | Aggregation.Expression.$objectToArray - | Aggregation.Expression.$or - | Aggregation.Expression.$percentile - | Aggregation.Expression.$pow - | Aggregation.Expression.$radiansToDegrees - | Aggregation.Expression.$rand - | Aggregation.Expression.$range - | Aggregation.Expression.$reduce - | Aggregation.Expression.$regexFind - | Aggregation.Expression.$regexFindAll - | Aggregation.Expression.$regexMatch - | Aggregation.Expression.$replaceAll - | Aggregation.Expression.$replaceOne - | Aggregation.Expression.$reverseArray - | Aggregation.Expression.$round - | Aggregation.Expression.$rtrim - | Aggregation.Expression.$second - | Aggregation.Expression.$setDifference - | Aggregation.Expression.$setEquals - | Aggregation.Expression.$setField - | Aggregation.Expression.$setIntersection - | Aggregation.Expression.$setIsSubset - | Aggregation.Expression.$setUnion - | Aggregation.Expression.$sin - | Aggregation.Expression.$sinh - | Aggregation.Expression.$size - | Aggregation.Expression.$slice - | Aggregation.Expression.$sortArray - | Aggregation.Expression.$split - | Aggregation.Expression.$sqrt - | Aggregation.Expression.$stdDevPop - | Aggregation.Expression.$stdDevSamp - | Aggregation.Expression.$strLenBytes - | Aggregation.Expression.$strLenCP - | Aggregation.Expression.$strcasecmp - | Aggregation.Expression.$substr - | Aggregation.Expression.$substrBytes - | Aggregation.Expression.$substrCP - | Aggregation.Expression.$subtract - | Aggregation.Expression.$sum - | Aggregation.Expression.$switch - | Aggregation.Expression.$tan - | Aggregation.Expression.$tanh - | Aggregation.Expression.$toBool - | Aggregation.Expression.$toDate - | Aggregation.Expression.$toDecimal - | Aggregation.Expression.$toDouble - | Aggregation.Expression.$toHashedIndexKey - | Aggregation.Expression.$toInt - | Aggregation.Expression.$toLong - | Aggregation.Expression.$toLower - | Aggregation.Expression.$toObjectId - | Aggregation.Expression.$toString - | Aggregation.Expression.$toUpper - | Aggregation.Expression.$trim - | Aggregation.Expression.$trunc - | Aggregation.Expression.$tsIncrement - | Aggregation.Expression.$tsSecond - | Aggregation.Expression.$type - | Aggregation.Expression.$unsetField - | Aggregation.Expression.$week - | Aggregation.Expression.$year - | Aggregation.Expression.$zip; -export type ResolvesToAny = - | Aggregation.Expression.$arrayElemAt - | Aggregation.Expression.$cond - | Aggregation.Expression.$convert - | Aggregation.Expression.$first - | Aggregation.Expression.$function - | Aggregation.Expression.$getField - | Aggregation.Expression.$ifNull - | Aggregation.Expression.$last + | Aggregation.Expression.$last | Aggregation.Expression.$let | Aggregation.Expression.$literal | Aggregation.Expression.$max @@ -6267,8 +6334,11 @@ export type ResolvesToAny = | Aggregation.Expression.$min | Aggregation.Expression.$reduce | Aggregation.Expression.$switch; -export type SwitchBranch = Aggregation.Expression.$case; -export type FieldQuery = +export type SwitchBranch = Aggregation.Expression.$case; +export type PipelineOperator = + | Aggregation.Pipeline.Pipeline + | Aggregation.Pipeline.UpdatePipeline; +export type FieldQuery = | Aggregation.Query.$all | Aggregation.Query.$bitsAllClear | Aggregation.Query.$bitsAllSet @@ -6295,128 +6365,129 @@ export type FieldQuery = | Aggregation.Query.$regex | Aggregation.Query.$size | Aggregation.Query.$type; -export type QueryOperator = - | Aggregation.Query.$all - | Aggregation.Query.$and - | Aggregation.Query.$bitsAllClear - | Aggregation.Query.$bitsAllSet - | Aggregation.Query.$bitsAnyClear - | Aggregation.Query.$bitsAnySet - | Aggregation.Query.$box - | Aggregation.Query.$center - | Aggregation.Query.$centerSphere - | Aggregation.Query.$comment - | Aggregation.Query.$elemMatch - | Aggregation.Query.$eq - | Aggregation.Query.$exists - | Aggregation.Query.$expr - | Aggregation.Query.$geoIntersects - | Aggregation.Query.$geoWithin - | Aggregation.Query.$geometry - | Aggregation.Query.$gt - | Aggregation.Query.$gte - | Aggregation.Query.$in - | Aggregation.Query.$jsonSchema - | Aggregation.Query.$lt - | Aggregation.Query.$lte - | Aggregation.Query.$maxDistance - | Aggregation.Query.$minDistance - | Aggregation.Query.$mod - | Aggregation.Query.$ne - | Aggregation.Query.$near - | Aggregation.Query.$nearSphere - | Aggregation.Query.$nin - | Aggregation.Query.$nor - | Aggregation.Query.$not - | Aggregation.Query.$or - | Aggregation.Query.$polygon - | Aggregation.Query.$rand - | Aggregation.Query.$regex - | Aggregation.Query.$sampleRate - | Aggregation.Query.$size - | Aggregation.Query.$text - | Aggregation.Query.$type - | Aggregation.Query.$where; -export type SearchOperator = +export type QueryOperator = + | Aggregation.Query.$all + | Aggregation.Query.$and + | Aggregation.Query.$bitsAllClear + | Aggregation.Query.$bitsAllSet + | Aggregation.Query.$bitsAnyClear + | Aggregation.Query.$bitsAnySet + | Aggregation.Query.$box + | Aggregation.Query.$center + | Aggregation.Query.$centerSphere + | Aggregation.Query.$comment + | Aggregation.Query.$elemMatch + | Aggregation.Query.$eq + | Aggregation.Query.$exists + | Aggregation.Query.$expr + | Aggregation.Query.$geoIntersects + | Aggregation.Query.$geoWithin + | Aggregation.Query.$geometry + | Aggregation.Query.$gt + | Aggregation.Query.$gte + | Aggregation.Query.$in + | Aggregation.Query.$jsonSchema + | Aggregation.Query.$lt + | Aggregation.Query.$lte + | Aggregation.Query.$maxDistance + | Aggregation.Query.$minDistance + | Aggregation.Query.$mod + | Aggregation.Query.$ne + | Aggregation.Query.$near + | Aggregation.Query.$nearSphere + | Aggregation.Query.$nin + | Aggregation.Query.$nor + | Aggregation.Query.$not + | Aggregation.Query.$or + | Aggregation.Query.$polygon + | Aggregation.Query.$rand + | Aggregation.Query.$regex + | Aggregation.Query.$sampleRate + | Aggregation.Query.$size + | Aggregation.Query.$text + | Aggregation.Query.$type + | Aggregation.Query.$where; +export type SearchOperator = | Aggregation.Search.Autocomplete + | Aggregation.Search.Autocomplete | Aggregation.Search.Compound + | Aggregation.Search.Compound | Aggregation.Search.EmbeddedDocument + | Aggregation.Search.EmbeddedDocument | Aggregation.Search.Equals + | Aggregation.Search.Equals | Aggregation.Search.Exists + | Aggregation.Search.Exists | Aggregation.Search.Facet + | Aggregation.Search.Facet | Aggregation.Search.GeoShape + | Aggregation.Search.GeoShape | Aggregation.Search.GeoWithin + | Aggregation.Search.GeoWithin | Aggregation.Search.In + | Aggregation.Search.In | Aggregation.Search.MoreLikeThis + | Aggregation.Search.MoreLikeThis | Aggregation.Search.Near + | Aggregation.Search.Near | Aggregation.Search.Phrase + | Aggregation.Search.Phrase | Aggregation.Search.QueryString + | Aggregation.Search.QueryString | Aggregation.Search.Range + | Aggregation.Search.Range | Aggregation.Search.Regex + | Aggregation.Search.Regex | Aggregation.Search.Text - | Aggregation.Search.Wildcard; -export type StageOperator = - | Aggregation.Stage.$addFields - | Aggregation.Stage.$bucket - | Aggregation.Stage.$bucketAuto - | Aggregation.Stage.$changeStream - | Aggregation.Stage.$changeStreamSplitLargeEvent - | Aggregation.Stage.$collStats - | Aggregation.Stage.$count - | Aggregation.Stage.$currentOp - | Aggregation.Stage.$densify - | Aggregation.Stage.$documents - | Aggregation.Stage.$facet - | Aggregation.Stage.$fill - | Aggregation.Stage.$geoNear - | Aggregation.Stage.$graphLookup - | Aggregation.Stage.$group - | Aggregation.Stage.$indexStats - | Aggregation.Stage.$limit - | Aggregation.Stage.$listLocalSessions - | Aggregation.Stage.$listSampledQueries - | Aggregation.Stage.$listSearchIndexes - | Aggregation.Stage.$listSessions - | Aggregation.Stage.$lookup - | Aggregation.Stage.$match - | Aggregation.Stage.$merge - | Aggregation.Stage.$out - | Aggregation.Stage.$planCacheStats - | Aggregation.Stage.$project - | Aggregation.Stage.$redact - | Aggregation.Stage.$replaceRoot - | Aggregation.Stage.$replaceWith - | Aggregation.Stage.$sample - | Aggregation.Stage.$scoreFusion - | Aggregation.Stage.$search - | Aggregation.Stage.$searchMeta - | Aggregation.Stage.$set - | Aggregation.Stage.$setWindowFields - | Aggregation.Stage.$shardedDataDistribution - | Aggregation.Stage.$skip - | Aggregation.Stage.$sort - | Aggregation.Stage.$sortByCount - | Aggregation.Stage.$unionWith - | Aggregation.Stage.$unset - | Aggregation.Stage.$unwind - | Aggregation.Stage.$vectorSearch; -export type Update = - | Aggregation.Update.$addToSet - | Aggregation.Update.$bit - | Aggregation.Update.$currentDate - | Aggregation.Update.$inc - | Aggregation.Update.$max - | Aggregation.Update.$min - | Aggregation.Update.$mul - | Aggregation.Update.$pop - | Aggregation.Update.$pull - | Aggregation.Update.$pullAll - | Aggregation.Update.$push - | Aggregation.Update.$rename - | Aggregation.Update.$set - | Aggregation.Update.$setOnInsert - | Aggregation.Update.$unset; -export type UpdateOperator = + | Aggregation.Search.Text + | Aggregation.Search.Wildcard + | Aggregation.Search.Wildcard; +export type StageOperator = + | Aggregation.Stage.$addFields + | Aggregation.Stage.$bucket + | Aggregation.Stage.$bucketAuto + | Aggregation.Stage.$changeStream + | Aggregation.Stage.$changeStreamSplitLargeEvent + | Aggregation.Stage.$collStats + | Aggregation.Stage.$count + | Aggregation.Stage.$currentOp + | Aggregation.Stage.$densify + | Aggregation.Stage.$documents + | Aggregation.Stage.$facet + | Aggregation.Stage.$fill + | Aggregation.Stage.$geoNear + | Aggregation.Stage.$graphLookup + | Aggregation.Stage.$group + | Aggregation.Stage.$indexStats + | Aggregation.Stage.$limit + | Aggregation.Stage.$listLocalSessions + | Aggregation.Stage.$listSampledQueries + | Aggregation.Stage.$listSearchIndexes + | Aggregation.Stage.$listSessions + | Aggregation.Stage.$lookup + | Aggregation.Stage.$match + | Aggregation.Stage.$merge + | Aggregation.Stage.$out + | Aggregation.Stage.$planCacheStats + | Aggregation.Stage.$project + | Aggregation.Stage.$redact + | Aggregation.Stage.$replaceRoot + | Aggregation.Stage.$replaceWith + | Aggregation.Stage.$sample + | Aggregation.Stage.$scoreFusion + | Aggregation.Stage.$search + | Aggregation.Stage.$searchMeta + | Aggregation.Stage.$set + | Aggregation.Stage.$setWindowFields + | Aggregation.Stage.$shardedDataDistribution + | Aggregation.Stage.$skip + | Aggregation.Stage.$sort + | Aggregation.Stage.$sortByCount + | Aggregation.Stage.$unionWith + | Aggregation.Stage.$unset + | Aggregation.Stage.$unwind + | Aggregation.Stage.$vectorSearch; +export type Update = | Aggregation.Update.$addToSet | Aggregation.Update.$bit | Aggregation.Update.$currentDate @@ -6432,3 +6503,19 @@ export type UpdateOperator = | Aggregation.Update.$set | Aggregation.Update.$setOnInsert | Aggregation.Update.$unset; +export type UpdateOperator = + | Aggregation.Update.$addToSet + | Aggregation.Update.$bit + | Aggregation.Update.$currentDate + | Aggregation.Update.$inc + | Aggregation.Update.$max + | Aggregation.Update.$min + | Aggregation.Update.$mul + | Aggregation.Update.$pop + | Aggregation.Update.$pull + | Aggregation.Update.$pullAll + | Aggregation.Update.$push + | Aggregation.Update.$rename + | Aggregation.Update.$set + | Aggregation.Update.$setOnInsert + | Aggregation.Update.$unset; diff --git a/packages/mql-typescript/src/cli.ts b/packages/mql-typescript/src/cli.ts index b93ac444..6487468e 100644 --- a/packages/mql-typescript/src/cli.ts +++ b/packages/mql-typescript/src/cli.ts @@ -57,6 +57,6 @@ async function main() { } main().catch((err) => { - console.error(err); + console.dir(err, { depth: Infinity }); process.exit(1); }); diff --git a/packages/mql-typescript/src/driverSchema/driver-schema-generator.ts b/packages/mql-typescript/src/driverSchema/driver-schema-generator.ts index fb2a753e..45eff28b 100644 --- a/packages/mql-typescript/src/driverSchema/driver-schema-generator.ts +++ b/packages/mql-typescript/src/driverSchema/driver-schema-generator.ts @@ -14,9 +14,15 @@ export class DriverSchemaGenerator extends GeneratorBase { console.error(`No docs reference found for ${test.name}`); return '// TODO: No docs reference found'; } - if (!test.pipeline) { - console.error(`No pipeline found for ${test.name} at ${test.link}`); - return '// TODO: No pipeline found'; + if ( + (!('pipeline' in test) || !test.pipeline) && + (!('update' in test) || !test.update) && + (!('filter' in test) || !test.filter) + ) { + console.error( + `No pipeline, update, or filter found for ${test.name} at ${test.link}`, + ); + return '// TODO: No pipeline, update, or filter found'; } const docsCrawler = new DocsCrawler(test.link); diff --git a/packages/mql-typescript/src/metaschema.ts b/packages/mql-typescript/src/metaschema.ts index c680d316..d38cd5b0 100644 --- a/packages/mql-typescript/src/metaschema.ts +++ b/packages/mql-typescript/src/metaschema.ts @@ -3,37 +3,78 @@ import { z } from 'zod'; export const Operator = z .object({ name: z.string().regex(new RegExp('^\\$?[a-z][a-zA-Z0-9]*$')), - minVersion: z.string().regex(new RegExp('^[0-9]+\\.[0-9]+(\\.[0-9]+)?$')), + minVersion: z + .string() + .regex(new RegExp('^[0-9]+\\.[0-9]+(\\.[1-9][0-9]*)?$')), link: z.string().url().regex(new RegExp('^https://')), + generic: z.array(z.string()).optional(), type: z.array( - z.enum([ - 'accumulator', - 'stage', - 'query', - 'update', - 'fieldQuery', - 'filter', - 'window', - 'geometry', - 'switchBranch', - 'resolvesToAny', - 'resolvesToNumber', - 'resolvesToDouble', - 'resolvesToString', - 'resolvesToObject', - 'resolvesToArray', - 'resolvesToBinData', - 'resolvesToObjectId', - 'resolvesToBool', - 'resolvesToDate', - 'resolvesToNull', - 'resolvesToRegex', - 'resolvesToJavascript', - 'resolvesToInt', - 'resolvesToTimestamp', - 'resolvesToLong', - 'resolvesToDecimal', - 'searchOperator', + z.union([ + z.enum([ + 'pipeline', + 'accumulator', + 'stage', + 'updateStage', + 'query', + 'update', + 'fieldQuery', + 'filter', + 'window', + 'geometry', + 'switchBranch', + 'resolvesToAny', + 'resolvesToNumber', + 'resolvesToDouble', + 'resolvesToString', + 'resolvesToObject', + 'resolvesToArray', + 'resolvesToBinData', + 'resolvesToObjectId', + 'resolvesToBool', + 'resolvesToDate', + 'resolvesToNull', + 'resolvesToRegex', + 'resolvesToJavascript', + 'resolvesToInt', + 'resolvesToTimestamp', + 'resolvesToLong', + 'resolvesToDecimal', + 'searchOperator', + ]), + z.object({ + name: z.enum([ + 'pipeline', + 'accumulator', + 'stage', + 'updateStage', + 'query', + 'update', + 'fieldQuery', + 'filter', + 'window', + 'geometry', + 'switchBranch', + 'resolvesToAny', + 'resolvesToNumber', + 'resolvesToDouble', + 'resolvesToString', + 'resolvesToObject', + 'resolvesToArray', + 'resolvesToBinData', + 'resolvesToObjectId', + 'resolvesToBool', + 'resolvesToDate', + 'resolvesToNull', + 'resolvesToRegex', + 'resolvesToJavascript', + 'resolvesToInt', + 'resolvesToTimestamp', + 'resolvesToLong', + 'resolvesToDecimal', + 'searchOperator', + ]), + generic: z.string().optional(), + }), ]), ), encode: z.enum(['array', 'object', 'single']), @@ -46,85 +87,173 @@ export const Operator = z name: z.string().regex(new RegExp('^([_$]?[a-z][a-zA-Z0-9]*|N)$')), minVersion: z .string() - .regex(new RegExp('^[0-9]+\\.[0-9]+(\\.[0-9]+)?$')) + .regex(new RegExp('^[0-9]+\\.[0-9]+(\\.[1-9][0-9]*)?$')) .optional(), type: z.array( - z.enum([ - 'accumulator', - 'query', - 'fieldQuery', - 'pipeline', - 'window', - 'expression', - 'geometry', - 'unprefixedFieldPath', - 'timeUnit', - 'sortSpec', - 'granularity', - 'fullDocument', - 'fullDocumentBeforeChange', - 'accumulatorPercentile', - 'whenMatched', - 'whenNotMatched', - 'outCollection', - 'range', - 'sortBy', - 'geoPoint', - 'resolvesToAny', - 'fieldPath', - 'any', - 'resolvesToNumber', - 'numberFieldPath', - 'number', - 'resolvesToDouble', - 'doubleFieldPath', - 'double', - 'resolvesToString', - 'stringFieldPath', - 'string', - 'resolvesToObject', - 'objectFieldPath', - 'object', - 'resolvesToArray', - 'arrayFieldPath', - 'array', - 'resolvesToBinData', - 'binDataFieldPath', - 'binData', - 'resolvesToObjectId', - 'objectIdFieldPath', - 'objectId', - 'resolvesToBool', - 'boolFieldPath', - 'bool', - 'resolvesToDate', - 'dateFieldPath', - 'date', - 'resolvesToNull', - 'nullFieldPath', - 'null', - 'resolvesToRegex', - 'regexFieldPath', - 'regex', - 'resolvesToJavascript', - 'javascriptFieldPath', - 'javascript', - 'resolvesToInt', - 'intFieldPath', - 'int', - 'resolvesToTimestamp', - 'timestampFieldPath', - 'timestamp', - 'resolvesToLong', - 'longFieldPath', - 'long', - 'resolvesToDecimal', - 'decimalFieldPath', - 'decimal', - 'searchPath', - 'searchScore', - 'bitwiseOperation', - 'searchOperator', + z.union([ + z.enum([ + 'stage', + 'updateStage', + 'accumulator', + 'query', + 'fieldQuery', + 'pipeline', + 'updatePipeline', + 'window', + 'expression', + 'geometry', + 'unprefixedFieldPath', + 'timeUnit', + 'sortSpec', + 'granularity', + 'fullDocument', + 'fullDocumentBeforeChange', + 'accumulatorPercentile', + 'whenMatched', + 'whenNotMatched', + 'outCollection', + 'range', + 'sortBy', + 'geoPoint', + 'resolvesToAny', + 'fieldPath', + 'any', + 'resolvesToNumber', + 'numberFieldPath', + 'number', + 'resolvesToDouble', + 'doubleFieldPath', + 'double', + 'resolvesToString', + 'stringFieldPath', + 'string', + 'resolvesToObject', + 'objectFieldPath', + 'object', + 'resolvesToArray', + 'arrayFieldPath', + 'array', + 'resolvesToBinData', + 'binDataFieldPath', + 'binData', + 'resolvesToObjectId', + 'objectIdFieldPath', + 'objectId', + 'resolvesToBool', + 'boolFieldPath', + 'bool', + 'resolvesToDate', + 'dateFieldPath', + 'date', + 'resolvesToNull', + 'nullFieldPath', + 'null', + 'resolvesToRegex', + 'regexFieldPath', + 'regex', + 'resolvesToJavascript', + 'javascriptFieldPath', + 'javascript', + 'resolvesToInt', + 'intFieldPath', + 'int', + 'resolvesToTimestamp', + 'timestampFieldPath', + 'timestamp', + 'resolvesToLong', + 'longFieldPath', + 'long', + 'resolvesToDecimal', + 'decimalFieldPath', + 'decimal', + 'searchPath', + 'searchScore', + 'bitwiseOperation', + 'searchOperator', + ]), + z.object({ + name: z.enum([ + 'stage', + 'updateStage', + 'accumulator', + 'query', + 'fieldQuery', + 'pipeline', + 'updatePipeline', + 'window', + 'expression', + 'geometry', + 'unprefixedFieldPath', + 'timeUnit', + 'sortSpec', + 'granularity', + 'fullDocument', + 'fullDocumentBeforeChange', + 'accumulatorPercentile', + 'whenMatched', + 'whenNotMatched', + 'outCollection', + 'range', + 'sortBy', + 'geoPoint', + 'resolvesToAny', + 'fieldPath', + 'any', + 'resolvesToNumber', + 'numberFieldPath', + 'number', + 'resolvesToDouble', + 'doubleFieldPath', + 'double', + 'resolvesToString', + 'stringFieldPath', + 'string', + 'resolvesToObject', + 'objectFieldPath', + 'object', + 'resolvesToArray', + 'arrayFieldPath', + 'array', + 'resolvesToBinData', + 'binDataFieldPath', + 'binData', + 'resolvesToObjectId', + 'objectIdFieldPath', + 'objectId', + 'resolvesToBool', + 'boolFieldPath', + 'bool', + 'resolvesToDate', + 'dateFieldPath', + 'date', + 'resolvesToNull', + 'nullFieldPath', + 'null', + 'resolvesToRegex', + 'regexFieldPath', + 'regex', + 'resolvesToJavascript', + 'javascriptFieldPath', + 'javascript', + 'resolvesToInt', + 'intFieldPath', + 'int', + 'resolvesToTimestamp', + 'timestampFieldPath', + 'timestamp', + 'resolvesToLong', + 'longFieldPath', + 'long', + 'resolvesToDecimal', + 'decimalFieldPath', + 'decimal', + 'searchPath', + 'searchScore', + 'bitwiseOperation', + 'searchOperator', + ]), + generic: z.string().optional(), + }), ]), ), description: z.string().optional(), @@ -151,73 +280,137 @@ export const Operator = z .optional(), tests: z .array( - z - .object({ - name: z.string().optional(), - link: z.string().url().regex(new RegExp('^https://')).optional(), - pipeline: z.array(z.record(z.any())).optional(), - filter: z.record(z.any()).optional(), - update: z.record(z.any()).optional(), - schema: z - .union([ - z.record( + z.union([ + z + .object({ + name: z.string(), + link: z.string().url().regex(new RegExp('^https://')).optional(), + pipeline: z.array(z.record(z.any())), + schema: z + .union([ z.record( - z - .object({ - types: z.array( - z.union([ - z - .object({ - bsonType: z.enum([ - 'Array', - 'Binary', - 'Boolean', - 'Code', - 'CodeWScope', - 'Date', - 'Decimal128', - 'Double', - 'Int32', - 'Int64', - 'Long', - 'MaxKey', - 'MinKey', - 'Null', - 'ObjectId', - 'BSONRegExp', - 'String', - 'BSONSymbol', - 'Timestamp', - 'Undefined', - 'Document', - 'Number', - ]), - }) - .strict(), - z - .object({ - bsonType: z.literal('Array'), - types: z.array(z.record(z.any())), - }) - .strict(), - z - .object({ - bsonType: z.literal('Document'), - fields: z.record(z.record(z.any())), - }) - .strict(), - ]), - ), - }) - .strict(), + z.record( + z + .object({ + types: z.array( + z.union([ + z + .object({ + bsonType: z.enum([ + 'Array', + 'Binary', + 'Boolean', + 'Code', + 'CodeWScope', + 'Date', + 'Decimal128', + 'Double', + 'Int32', + 'Int64', + 'Long', + 'MaxKey', + 'MinKey', + 'Null', + 'ObjectId', + 'BSONRegExp', + 'String', + 'BSONSymbol', + 'Timestamp', + 'Undefined', + 'Document', + 'Number', + ]), + }) + .strict(), + z + .object({ + bsonType: z.literal('Array'), + types: z.array(z.record(z.any())), + }) + .strict(), + z + .object({ + bsonType: z.literal('Document'), + fields: z.record(z.record(z.any())), + }) + .strict(), + ]), + ), + }) + .strict(), + ), ), - ), - z.string(), - ]) - .optional(), - }) - .strict() - .and(z.union([z.any(), z.any()])), + z.string(), + ]) + .optional(), + }) + .strict(), + z + .object({ + name: z.string(), + link: z.string().url().regex(new RegExp('^https://')).optional(), + filter: z.record(z.any()), + update: z.record(z.any()), + schema: z + .union([ + z.record( + z.record( + z + .object({ + types: z.array( + z.union([ + z + .object({ + bsonType: z.enum([ + 'Array', + 'Binary', + 'Boolean', + 'Code', + 'CodeWScope', + 'Date', + 'Decimal128', + 'Double', + 'Int32', + 'Int64', + 'Long', + 'MaxKey', + 'MinKey', + 'Null', + 'ObjectId', + 'BSONRegExp', + 'String', + 'BSONSymbol', + 'Timestamp', + 'Undefined', + 'Document', + 'Number', + ]), + }) + .strict(), + z + .object({ + bsonType: z.literal('Array'), + types: z.array(z.record(z.any())), + }) + .strict(), + z + .object({ + bsonType: z.literal('Document'), + fields: z.record(z.record(z.any())), + }) + .strict(), + ]), + ), + }) + .strict(), + ), + ), + z.string(), + ]) + .optional(), + }) + .strict(), + ]), ) .optional(), }) diff --git a/packages/mql-typescript/src/schema-generator.ts b/packages/mql-typescript/src/schema-generator.ts index da008079..1c75e7b5 100644 --- a/packages/mql-typescript/src/schema-generator.ts +++ b/packages/mql-typescript/src/schema-generator.ts @@ -4,9 +4,18 @@ import { GeneratorBase } from './generator'; import { Operator } from './metaschema'; import { capitalize } from './utils'; -type ArgType = NonNullable< - typeof Operator._type.arguments ->[number]['type'][number]; +type ArgType = + | (NonNullable[number]['type'][number] & + string) + | (NonNullable[number] & string); + +function liftArgType(type: ArgType | { name: ArgType; generic?: string }): { + name: ArgType; + generic?: string; +} { + if (typeof type === 'string') return { name: type }; + return type; +} type SyntheticVariables = NonNullable< typeof Operator._type.arguments @@ -114,17 +123,19 @@ export class SchemaGenerator extends GeneratorBase { whenNotMatched: ['string'], expression_S: [ - this.toTypeName('ExpressionOperator'), - this.toTypeName('fieldPath'), + this.toTypeName('ExpressionOperator'), + this.toTypeName('fieldPath'), this.toTypeName('bsonPrimitive'), - 'FieldExpression', + 'FieldExpression', 'FieldPath[]', ], expressionMap_S: [ - `{ [k: string]: ${this.toTypeName('Expression')} | ${this.toTypeName('ExpressionMap')} }`, + `{ [k: string]: ${this.toTypeName('Expression')} | ${this.toTypeName('ExpressionMap')} }`, ], - stage_S: [this.toTypeName('StageOperator')], + stage_S: [this.toTypeName('StageOperator')], + updateStage_S: [], pipeline_S: [this.toTypeName('stage[]')], + updatePipeline_S: [this.toTypeName('UpdatePipeline[]')], untypedPipeline: [this.toTypeName('Pipeline')], query_S: [ this.toTypeName('QueryOperator'), @@ -147,8 +158,8 @@ export class SchemaGenerator extends GeneratorBase { ], // Need to be adjusted to match the real schema - fieldPath_S: ['`$${AFieldPath}`'], - unprefixedFieldPath_S: ['AFieldPath'], + fieldPath_S: ['`$${AFieldPath}`'], + unprefixedFieldPath_S: ['AFieldPath'], numberFieldPath_S: [this.toTypeFieldTypeName('number')], doubleFieldPath_S: [this.toTypeFieldTypeName('double')], stringFieldPath_S: [this.toTypeFieldTypeName('string')], @@ -167,7 +178,7 @@ export class SchemaGenerator extends GeneratorBase { decimalFieldPath_S: [this.toTypeFieldTypeName('decimal')], resolvesToNumber_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('numberFieldPath'), this.toTypeName('number'), this.toTypeName('resolvesToInt'), @@ -176,80 +187,80 @@ export class SchemaGenerator extends GeneratorBase { this.toTypeName('resolvesToDecimal'), ], resolvesToDouble_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('doubleFieldPath'), this.toTypeName('double'), ], resolvesToString_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('stringFieldPath'), this.toTypeName('string'), ], resolvesToObject_S: [ "'$$ROOT'", - this.toTypeName('resolvesToAny'), - this.toTypeName('objectFieldPath'), + this.toTypeName('resolvesToAny>'), + this.toTypeName('objectFieldPath'), this.toTypeName('object'), ], resolvesToArray_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny>'), this.toTypeName('arrayFieldPath'), - this.toTypeName('array'), + this.toTypeName('ArrayOnly'), ], resolvesToBinData_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('binDataFieldPath'), this.toTypeName('binData'), ], resolvesToObjectId_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('objectIdFieldPath'), this.toTypeName('objectId'), ], resolvesToBool_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('boolFieldPath'), this.toTypeName('bool'), ], resolvesToDate_S: [ "'$$NOW'", - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('dateFieldPath'), this.toTypeName('date'), ], resolvesToNull_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('nullFieldPath'), this.toTypeName('null'), ], resolvesToRegex_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('regexFieldPath'), this.toTypeName('regex'), ], resolvesToJavascript_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('javascriptFieldPath'), this.toTypeName('javascript'), ], resolvesToInt_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('intFieldPath'), this.toTypeName('int'), ], resolvesToTimestamp_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('timestampFieldPath'), this.toTypeName('timestamp'), "'$clusterTime'", ], resolvesToLong_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('longFieldPath'), this.toTypeName('long'), ], resolvesToDecimal_S: [ - this.toTypeName('resolvesToAny'), + this.toTypeName('resolvesToAny'), this.toTypeName('decimalFieldPath'), this.toTypeName('decimal'), ], @@ -278,24 +289,30 @@ export class SchemaGenerator extends GeneratorBase { // TBD: Nested fields type AFieldPath = KeysOfAType & string; - type FieldExpression = { [k: string]: FieldPath }; + type FieldExpression = { [k: string]: FieldPath }; - type MultiAnalyzerSpec = { - value: KeysOfAType; + type MultiAnalyzerSpec = { + value: KeysOfAType; multi: string; }; + + type ArrayOnly = T extends ReadonlyArray ? U[] : never; `); } private getArgumentTypeName( - type: ArgType, - syntheticVariables?: SyntheticVariables, + type: { name: ArgType; generic?: string }, + syntheticVariables: SyntheticVariables | undefined, ): string | undefined { - if (this.typeMappings[type]) { - return this.toTypeName(type); + if (this.typeMappings[type.name]) { + return this.toTypeName(type.name); + } + + if (type.generic && this.typeMappings[`${type.name}_S`]) { + return this.toTypeName(`${type.name}`); } - if (this.typeMappings[`${type}_S`]) { + if (this.typeMappings[`${type.name}_S`]) { let genericArg = 'S'; if (syntheticVariables) { @@ -306,11 +323,11 @@ export class SchemaGenerator extends GeneratorBase { genericArg = `S & { ${syntheticFields}; }`; } - return this.toTypeName(`${type}<${genericArg}>`); + return this.toTypeName(`${type.name}<${genericArg}>`); } - if (this.trivialTypeMappings[type]) { - return this.trivialTypeMappings[type]; + if (this.trivialTypeMappings[type.name]) { + return this.trivialTypeMappings[type.name]; } return undefined; @@ -324,13 +341,14 @@ export class SchemaGenerator extends GeneratorBase { this.emit(`${arg.name}${arg.optional ? '?' : ''}: `); } - const allowsArrays = arg.type.includes('array'); + const allowsArrays = arg.type.some((t) => liftArgType(t).name === 'array'); const argTypes = arg.type - .filter((t) => t !== 'array') + .filter((t) => liftArgType(t).name !== 'array') .map((type) => { - const name = this.getArgumentTypeName(type, arg.syntheticVariables); + const lifted = liftArgType(type); + const name = this.getArgumentTypeName(lifted, arg.syntheticVariables); if (!name) { - throw new Error(`Unknown type ${type}`); + throw new Error(`Unknown type ${lifted.name}`); } return name; }) @@ -433,19 +451,52 @@ export class SchemaGenerator extends GeneratorBase { `A type describing the \`${parsed.name}\` operator.`, parsed.link, ); - this.emit(`export interface ${ifaceName} {`); + let emittedTypeStart = false; + let typeFinalizingTag = ''; + if (parsed.generic) { + if (parsed.generic.length !== 1 || parsed.generic[0] !== 'T') { + throw new Error( + `Not currently supporting generics other than '[T]', received ${JSON.stringify(parsed.generic)}`, + ); + } + const genericSignatures = new Set( + parsed.type.map((t) => liftArgType(t).generic), + ); + if (genericSignatures.size !== 1) { + throw new Error( + `Not supporting matching on multiple different return types right now`, + ); + } + const [signature] = genericSignatures; + if (signature && signature !== 'T') { + this.emit( + `export type ${ifaceName} = U extends ${signature.replace(/\bT\b/g, '(infer T)')} ? {\n`, + ); + emittedTypeStart = true; + typeFinalizingTag = ' : never'; + } + } + if (!emittedTypeStart) + this.emit(`export interface ${ifaceName} {`); if (parsed.description) { this.emitComment(parsed.description, parsed.link); } this.emit(`${parsed.name}:`); - for (const type of parsed.type) { - (this.typeMappings[`${type}_S`] ??= []).push( - `${namespace}.${ifaceName}`, - ); + for (const _type of parsed.type) { + const type = liftArgType(_type); + if (type.generic) { + (this.typeMappings[`${type.name}_S`] ??= []).push( + `${namespace}.${ifaceName}`, + ); + } else { + (this.typeMappings[`${type.name}_S`] ??= []).push( + `${namespace}.${ifaceName}`, + ); + } } (this.typeMappings[`${file.category}Operator_S`] ??= []).push( - `${namespace}.${ifaceName}`, + `${namespace}.${ifaceName}`, ); if (!parsed.arguments) { @@ -524,7 +575,12 @@ export class SchemaGenerator extends GeneratorBase { `RecordWithStaticFields<${objectType}, ${this.toComment( arg.description, )} ${arg.type - .map((t) => this.getArgumentTypeName(t)) + .map((t) => { + return this.getArgumentTypeName( + liftArgType(t), + undefined, + ); + }) .join(' | ')}>`, ); } @@ -565,20 +621,23 @@ export class SchemaGenerator extends GeneratorBase { throw new Error(`unknown encode mode ${parsed.encode}`); } } - this.emit('};\n'); + this.emit(`} ${typeFinalizingTag};\n`); } this.emit('};\n'); } for (const [type, interfaces] of Object.entries(this.typeMappings)) { - const isTemplated = type.endsWith('_S'); - const name = isTemplated ? type.replace(/_S$/, '') : type; - this.emit( - `\nexport type ${this.toTypeName(name)}${ - isTemplated ? '' : '' - } = ${[...new Set(interfaces)].join('|')};`, - ); + if (type.endsWith('_S')) { + const name = type.replace(/_S$/, ''); + this.emit( + `\nexport type ${this.toTypeName(name)} = ${[...new Set(interfaces)].join('|')};`, + ); + } else { + this.emit( + `\nexport type ${this.toTypeName(type)} = ${[...new Set(interfaces)].join('|')};`, + ); + } } } } diff --git a/packages/mql-typescript/src/testGenerator/test-generator.ts b/packages/mql-typescript/src/testGenerator/test-generator.ts index 8d9ca707..e2e94af0 100644 --- a/packages/mql-typescript/src/testGenerator/test-generator.ts +++ b/packages/mql-typescript/src/testGenerator/test-generator.ts @@ -136,12 +136,12 @@ export class TestGenerator extends GeneratorBase { } } - private emitTestBody( + private emitTestBodyForPipeline( category: string, operator: string, test: TestType, ): void { - if (!test.pipeline) { + if (!('pipeline' in test) || !test.pipeline) { this.emit(`// TODO: No pipeline found for ${operator}.${test.name}\n`); return; } @@ -189,6 +189,39 @@ export class TestGenerator extends GeneratorBase { this.emit('];\n'); } + private emitTestBodyForUpdate( + category: string, + operator: string, + test: TestType, + ): void { + if (!('update' in test) || !test.update || !test.filter) { + this.emit( + `// TODO: No update/filter found for ${operator}.${test.name}\n`, + ); + return; + } + + if (!test.schema || typeof test.schema === 'string') { + this.emit( + `// TODO: no schema found for ${operator}.${test.name}${test.schema ? `: ${test.schema}` : ''}\n`, + ); + return; + } + + const collectionName = Object.keys(test.schema)[0]; + const schema = test.schema[collectionName] as SimplifiedSchema; + + this.emit( + `type ${collectionName} = ${this.simplifiedSchemaToTS(schema)}\n`, + ); + + this.emit(`const update: schema.Update<${collectionName}> = \n`); + this.emit(this.stageToTS(test.update)); + this.emit(`;\nconst filter: schema.Query<${collectionName}> = `); + this.emit(this.stageToTS(test.filter)); + this.emit(';\n'); + } + protected override async generateImpl(yamlFiles: YamlFiles): Promise { for await (const file of yamlFiles) { const namespace = `${capitalize(file.category)}Operators`; @@ -227,7 +260,11 @@ export class TestGenerator extends GeneratorBase { this.emit(`function test${i++}() {\n`); - this.emitTestBody(file.category, operatorName, test); + if ('pipeline' in test) { + this.emitTestBodyForPipeline(file.category, operatorName, test); + } else { + this.emitTestBodyForUpdate(file.category, operatorName, test); + } this.emit('}\n\n'); }