@@ -48,7 +48,7 @@ import { VectorValue } from './vector_value';
4848 *
4949 * An interface that represents a selectable expression.
5050 */
51- export interface Selectable {
51+ export interface Selectable extends Expr {
5252 selectable : true ;
5353}
5454
@@ -57,7 +57,7 @@ export interface Selectable {
5757 *
5858 * An interface that represents a filter condition.
5959 */
60- export interface FilterCondition {
60+ export interface FilterCondition extends Expr {
6161 filterable : true ;
6262}
6363
@@ -66,7 +66,7 @@ export interface FilterCondition {
6666 *
6767 * An interface that represents an accumulator.
6868 */
69- export interface Accumulator {
69+ export interface Accumulator extends Expr {
7070 accumulator : true ;
7171 /**
7272 * @private
@@ -80,21 +80,7 @@ export interface Accumulator {
8080 *
8181 * An accumulator target, which is an expression with an alias that also implements the Accumulator interface.
8282 */
83- export type AccumulatorTarget = ExprWithAlias < Expr & Accumulator > ;
84-
85- /**
86- * @beta
87- *
88- * A filter expression, which is an expression that also implements the FilterCondition interface.
89- */
90- export type FilterExpr = Expr & FilterCondition ;
91-
92- /**
93- * @beta
94- *
95- * A selectable expression, which is an expression that also implements the Selectable interface.
96- */
97- export type SelectableExpr = Expr & Selectable ;
83+ export type AccumulatorTarget = ExprWithAlias < Accumulator > ;
9884
9985/**
10086 * @beta
@@ -126,6 +112,8 @@ export type ExprType =
126112 * method calls to create complex expressions.
127113 */
128114export abstract class Expr implements ProtoSerializable < ProtoValue > , UserData {
115+ abstract exprType : ExprType ;
116+
129117 /**
130118 * Creates an expression that adds this expression to another expression.
131119 *
@@ -666,21 +654,21 @@ export abstract class Expr implements ProtoSerializable<ProtoValue>, UserData {
666654 * @param arrays The array expressions to concatenate.
667655 * @return A new `Expr` representing the concatenated array.
668656 */
669- arrayConcat ( arrays : Expr [ ] ) : ArrayConcat ;
657+ arrayConcat ( ... arrays : Expr [ ] ) : ArrayConcat ;
670658
671659 /**
672- * Creates an expression that concatenates an array expression with one or more other arrays.
660+ * Creates an expression that concatenates an array with one or more other arrays.
673661 *
674662 * ```typescript
675663 * // Combine the 'tags' array with a new array and an array field
676664 * Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag"));
677665 * ```
678666 *
679- * @param arrays The array expressions or values to concatenate.
680- * @return A new `Expr` representing the concatenated array .
667+ * @param arrays The arrays to concatenate.
668+ * @return A new `Expr` representing the concatenated arrays .
681669 */
682- arrayConcat ( arrays : any [ ] ) : ArrayConcat ;
683- arrayConcat ( arrays : any [ ] ) : ArrayConcat {
670+ arrayConcat ( ... arrays : any [ ] [ ] ) : ArrayConcat ;
671+ arrayConcat ( ... arrays : any [ ] ) : ArrayConcat {
684672 const exprValues = arrays . map ( value =>
685673 value instanceof Expr ? value : Constant . of ( value )
686674 ) ;
@@ -1839,7 +1827,7 @@ export class ExprWithAlias<T extends Expr> extends Expr implements Selectable {
18391827 exprType : ExprType = 'ExprWithAlias' ;
18401828 selectable = true as const ;
18411829
1842- constructor ( public expr : T , public alias : string ) {
1830+ constructor ( readonly expr : T , readonly alias : string ) {
18431831 super ( ) ;
18441832 }
18451833
@@ -2557,7 +2545,7 @@ export class Not extends FirestoreFunction implements FilterCondition {
25572545 * @beta
25582546 */
25592547export class And extends FirestoreFunction implements FilterCondition {
2560- constructor ( private conditions : FilterExpr [ ] ) {
2548+ constructor ( private conditions : FilterCondition [ ] ) {
25612549 super ( 'and' , conditions ) ;
25622550 }
25632551
@@ -2568,7 +2556,7 @@ export class And extends FirestoreFunction implements FilterCondition {
25682556 * @beta
25692557 */
25702558export class Or extends FirestoreFunction implements FilterCondition {
2571- constructor ( private conditions : FilterExpr [ ] ) {
2559+ constructor ( private conditions : FilterCondition [ ] ) {
25722560 super ( 'or' , conditions ) ;
25732561 }
25742562 filterable = true as const ;
@@ -2578,7 +2566,7 @@ export class Or extends FirestoreFunction implements FilterCondition {
25782566 * @beta
25792567 */
25802568export class Xor extends FirestoreFunction implements FilterCondition {
2581- constructor ( private conditions : FilterExpr [ ] ) {
2569+ constructor ( private conditions : FilterCondition [ ] ) {
25822570 super ( 'xor' , conditions ) ;
25832571 }
25842572 filterable = true as const ;
@@ -2587,9 +2575,9 @@ export class Xor extends FirestoreFunction implements FilterCondition {
25872575/**
25882576 * @beta
25892577 */
2590- export class Cond extends FirestoreFunction implements FilterCondition {
2578+ export class Cond extends FirestoreFunction {
25912579 constructor (
2592- private condition : FilterExpr ,
2580+ private condition : FilterCondition ,
25932581 private thenExpr : Expr ,
25942582 private elseExpr : Expr
25952583 ) {
@@ -4321,8 +4309,8 @@ export function arrayContainsAny(
43214309 * Creates an expression that checks if an array expression contains all the specified elements.
43224310 *
43234311 * ```typescript
4324- * // Check if the ' tags' array contains both of the values from field 'tag1', 'tag2' and "tag3 "
4325- * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]);
4312+ * // Check if the " tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1 "
4313+ * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), Constant.of( "SciFi"), Constant.of( "Adventure") ]);
43264314 * ```
43274315 *
43284316 * @param array The array expression to check.
@@ -4337,7 +4325,7 @@ export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll;
43374325 * Creates an expression that checks if an array expression contains all the specified elements.
43384326 *
43394327 * ```typescript
4340- * // Check if the ' tags' array contains both of the values from field 'tag1', 'tag2' and "tag3 "
4328+ * // Check if the " tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1 "
43414329 * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]);
43424330 * ```
43434331 *
@@ -4583,7 +4571,7 @@ export function notEqAny(element: Expr | string, others: any[]): NotEqAny {
45834571 * @param right Additional filter conditions to 'XOR' together.
45844572 * @return A new {@code Expr} representing the logical 'XOR' operation.
45854573 */
4586- export function xor ( left : FilterExpr , ...right : FilterExpr [ ] ) : Xor {
4574+ export function xor ( left : FilterCondition , ...right : FilterCondition [ ] ) : Xor {
45874575 return new Xor ( [ left , ...right ] ) ;
45884576}
45894577
@@ -4605,7 +4593,7 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor {
46054593 * @return A new {@code Expr} representing the conditional expression.
46064594 */
46074595export function cond (
4608- condition : FilterExpr ,
4596+ condition : FilterCondition ,
46094597 thenExpr : Expr ,
46104598 elseExpr : Expr
46114599) : Cond {
@@ -4625,7 +4613,7 @@ export function cond(
46254613 * @param filter The filter condition to negate.
46264614 * @return A new {@code Expr} representing the negated filter condition.
46274615 */
4628- export function not ( filter : FilterExpr ) : Not {
4616+ export function not ( filter : FilterCondition ) : Not {
46294617 return new Not ( filter ) ;
46304618}
46314619
@@ -6691,7 +6679,10 @@ export function genericFunction(
66916679 * @param right Additional filter conditions to 'AND' together.
66926680 * @return A new {@code Expr} representing the logical 'AND' operation.
66936681 */
6694- export function andFunction ( left : FilterExpr , ...right : FilterExpr [ ] ) : And {
6682+ export function andFunction (
6683+ left : FilterCondition ,
6684+ ...right : FilterCondition [ ]
6685+ ) : And {
66956686 return new And ( [ left , ...right ] ) ;
66966687}
66976688
@@ -6710,7 +6701,10 @@ export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And {
67106701 * @param right Additional filter conditions to 'OR' together.
67116702 * @return A new {@code Expr} representing the logical 'OR' operation.
67126703 */
6713- export function orFunction ( left : FilterExpr , ...right : FilterExpr [ ] ) : Or {
6704+ export function orFunction (
6705+ left : FilterCondition ,
6706+ ...right : FilterCondition [ ]
6707+ ) : Or {
67146708 return new Or ( [ left , ...right ] ) ;
67156709}
67166710
@@ -6759,8 +6753,8 @@ export function descending(expr: Expr): Ordering {
67596753 */
67606754export class Ordering {
67616755 constructor (
6762- private expr : Expr ,
6763- private direction : 'ascending' | 'descending'
6756+ readonly expr : Expr ,
6757+ readonly direction : 'ascending' | 'descending'
67646758 ) { }
67656759
67666760 /**
0 commit comments