@firebase/firestore
Version:
The Cloud Firestore component of the Firebase JS SDK.
1,356 lines (1,337 loc) • 375 kB
Plain Text
// AUTO-GENERATED BY https://github.com/firebase/firebase-js-sdk/blob/main/packages/firestore/scripts/build-console-ui-types.ts
// DO NOT EDIT MANUALLY
//
//
// Purpose:
// This file provides TypeScript declarations (.d.ts) for the Firestore Pipelines
// API, tailored for use within the Firebase Console's Firestore UI code in Google3.
// It enables type checking, autocompletion, and a clear API contract for the UI
// components interacting with Firestore Pipelines.
//
// Structure:
// 1. Manual Definitions: The initial section of this file contains hand-crafted
// type definitions. These include:
// - A base `Firestore` interface exposing the `pipeline()` method.
// - Common Firestore data types (e.g., Timestamp, GeoPoint, VectorValue).
// - Stubs for types like `Query` and `DocumentReference` set to `never`
// to discourage their use in this context.
//
// 2. Auto-populated Pipelines Types: The section below the marker
// "// BEGIN PIPELINE TYPES" is automatically populated from the
// Firebase JavaScript SDK build.
interface Firestore {
pipeline(): PipelineSource<Pipeline>;
}
/**
* @type {Firestore}
*/
var db: Firestore;
/**
* Not supported in the query editor.
*/
type Query = never;
/**
* Not supported in the query editor.
*/
type DocumentReference = never;
/**
* A `FieldPath` refers to a field in a document. The path may consist of a
* single field name (referring to a top-level field in the document), or a
* list of field names (referring to a nested field in the document).
*
* Create a `FieldPath` by providing field names. If more than one field
* name is provided, the path will point to a nested field in a document.
*/
class FieldPath {
/**
* Creates a `FieldPath` from the provided field names. If more than one field
* name is provided, the path will point to a nested field in a document.
*
* @param fieldNames - A list of field names.
*/
constructor(...fieldNames: string[]);
/**
* Returns true if this `FieldPath` is equal to the provided one.
*
* @param other - The `FieldPath` to compare against.
* @returns true if this `FieldPath` is equal to the provided one.
*/
isEqual(other: FieldPath): boolean;
}
/**
* Creates a new `VectorValue` constructed with a copy of the given array of numbers.
*
* @param values - Create a `VectorValue` instance with a copy of this array of numbers.
*
* @returns A new `VectorValue` constructed with a copy of the given array of numbers.
*/
function vector(values?: number[]): VectorValue;
/**
* Represents a vector type in Firestore documents.
* Create an instance with <code>{@link vector}</code>.
*
* @class VectorValue
*/
class VectorValue {
/**
* Returns a copy of the raw number array form of the vector.
*/
toArray(): number[];
/**
* Returns `true` if the two `VectorValue` values have the same raw number arrays, returns `false` otherwise.
*/
isEqual(other: VectorValue): boolean;
/**
* Returns a JSON-serializable representation of this `VectorValue` instance.
*
* @returns a JSON representation of this object.
*/
toJSON(): object;
/**
* Builds a `VectorValue` instance from a JSON object created by {@link VectorValue.toJSON}.
*
* @param json a JSON object represention of a `VectorValue` instance.
* @returns an instance of {@link VectorValue} if the JSON object could be parsed. Throws a
* {@link FirestoreError} if an error occurs.
*/
static fromJSON(json: object): VectorValue;
}
/**
* An immutable object representing an array of bytes.
*/
class Bytes {
private constructor();
/**
* Creates a new `Bytes` object from the given Base64 string, converting it to
* bytes.
*
* @param base64 - The Base64 string used to create the `Bytes` object.
*/
static fromBase64String(base64: string): Bytes;
/**
* Creates a new `Bytes` object from the given Uint8Array.
*
* @param array - The Uint8Array used to create the `Bytes` object.
*/
static fromUint8Array(array: Uint8Array): Bytes;
/**
* Returns the underlying bytes as a Base64-encoded string.
*
* @returns The Base64-encoded string created from the `Bytes` object.
*/
toBase64(): string;
/**
* Returns the underlying bytes in a new `Uint8Array`.
*
* @returns The Uint8Array created from the `Bytes` object.
*/
toUint8Array(): Uint8Array;
/**
* Returns a string representation of the `Bytes` object.
*
* @returns A string representation of the `Bytes` object.
*/
toString(): string;
/**
* Returns true if this `Bytes` object is equal to the provided one.
*
* @param other - The `Bytes` object to compare against.
* @returns true if this `Bytes` object is equal to the provided one.
*/
isEqual(other: Bytes): boolean;
/**
* Returns a JSON-serializable representation of this `Bytes` instance.
*
* @returns a JSON representation of this object.
*/
toJSON(): object;
/**
* Builds a `Bytes` instance from a JSON object created by {@link Bytes.toJSON}.
*
* @param json a JSON object represention of a `Bytes` instance
* @returns an instance of {@link Bytes} if the JSON object could be parsed. Throws a
* {@link FirestoreError} if an error occurs.
*/
static fromJSON(json: object): Bytes;
}
/**
* A `Timestamp` represents a point in time independent of any time zone or
* calendar, represented as seconds and fractions of seconds at nanosecond
* resolution in UTC Epoch time.
*
* It is encoded using the Proleptic Gregorian Calendar which extends the
* Gregorian calendar backwards to year one. It is encoded assuming all minutes
* are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
* table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59.999999999Z.
*
* For examples and further specifications, refer to the
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
*/
class Timestamp {
/**
* The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
*/
readonly seconds: number;
/**
* The fractions of a second at nanosecond resolution.*
*/
readonly nanoseconds: number;
/**
* Creates a new timestamp with the current date, with millisecond precision.
*
* @returns a new timestamp representing the current date.
*/
static now(): Timestamp;
/**
* Creates a new timestamp from the given date.
*
* @param date - The date to initialize the `Timestamp` from.
* @returns A new `Timestamp` representing the same point in time as the given
* date.
*/
static fromDate(date: Date): Timestamp;
/**
* Creates a new timestamp from the given number of milliseconds.
*
* @param milliseconds - Number of milliseconds since Unix epoch
* 1970-01-01T00:00:00Z.
* @returns A new `Timestamp` representing the same point in time as the given
* number of milliseconds.
*/
static fromMillis(milliseconds: number): Timestamp;
/**
* Creates a new timestamp.
*
* @param seconds - The number of seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
* @param nanoseconds - The non-negative fractions of a second at nanosecond
* resolution. Negative second values with fractions must still have
* non-negative nanoseconds values that count forward in time. Must be
* from 0 to 999,999,999 inclusive.
*/
constructor(
/**
* The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
*/
seconds: number,
/**
* The fractions of a second at nanosecond resolution.*
*/
nanoseconds: number);
/**
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
* causes a loss of precision since `Date` objects only support millisecond
* precision.
*
* @returns JavaScript `Date` object representing the same point in time as
* this `Timestamp`, with millisecond precision.
*/
toDate(): Date;
/**
* Converts a `Timestamp` to a numeric timestamp (in milliseconds since
* epoch). This operation causes a loss of precision.
*
* @returns The point in time corresponding to this timestamp, represented as
* the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
*/
toMillis(): number;
/**
* Returns true if this `Timestamp` is equal to the provided one.
*
* @param other - The `Timestamp` to compare against.
* @returns true if this `Timestamp` is equal to the provided one.
*/
isEqual(other: Timestamp): boolean;
/** Returns a textual representation of this `Timestamp`. */
toString(): string;
/**
* Returns a JSON-serializable representation of this `Timestamp`.
*/
toJSON(): {
seconds: number;
nanoseconds: number;
type: string;
};
/**
* Builds a `Timestamp` instance from a JSON object created by {@link Timestamp.toJSON}.
*/
static fromJSON(json: object): Timestamp;
/**
* Converts this object to a primitive string, which allows `Timestamp` objects
* to be compared using the `>`, `<=`, `>=` and `>` operators.
*/
valueOf(): string;
}
/**
* An immutable object representing a geographic location in Firestore. The
* location is represented as latitude/longitude pair.
*
* Latitude values are in the range of [-90, 90].
* Longitude values are in the range of [-180, 180].
*/
class GeoPoint {
/**
* Creates a new immutable `GeoPoint` object with the provided latitude and
* longitude values.
* @param latitude - The latitude as number between -90 and 90.
* @param longitude - The longitude as number between -180 and 180.
*/
constructor(latitude: number, longitude: number);
/**
* The latitude of this `GeoPoint` instance.
*/
get latitude(): number;
/**
* The longitude of this `GeoPoint` instance.
*/
get longitude(): number;
/**
* Returns true if this `GeoPoint` is equal to the provided one.
*
* @param other - The `GeoPoint` to compare against.
* @returns true if this `GeoPoint` is equal to the provided one.
*/
isEqual(other: GeoPoint): boolean;
/**
* Returns a JSON-serializable representation of this `GeoPoint` instance.
*
* @returns a JSON representation of this object.
*/
toJSON(): {
latitude: number;
longitude: number;
type: string;
};
/**
* Builds a `GeoPoint` instance from a JSON object created by {@link GeoPoint.toJSON}.
*
* @param json a JSON object represention of a `GeoPoint` instance
* @returns an instance of {@link GeoPoint} if the JSON object could be parsed. Throws a
* {@link FirestoreError} if an error occurs.
*/
static fromJSON(json: object): GeoPoint;
}
type DocumentData = { [field: string]: any };
// ============================================================================
// BEGIN PIPELINE TYPES (Pruned from source)
// ============================================================================
/**
* Cloud Firestore
*
* @packageDocumentation
*/
/**
* Creates an expression that computes the absolute value of a numeric value.
*
* @param expr - The expression to compute the absolute value of.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the absolute value of the numeric value.
*/
function abs(expr: Expression): FunctionExpression;
/**
* Creates an expression that computes the absolute value of a numeric value.
*
* @param fieldName - The field to compute the absolute value of.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the absolute value of the numeric value.
*/
function abs(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that adds two expressions together.
*
* @example
* ```typescript
* // Add the value of the 'quantity' field and the 'reserve' field.
* add(field("quantity"), field("reserve"));
* ```
*
* @param first - The first expression to add.
* @param second - The second expression or literal to add.
* @param others - Optional other expressions or literals to add.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the addition operation.
*/
function add(first: Expression, second: Expression | unknown): FunctionExpression;
/**
*
* Creates an expression that adds a field's value to an expression.
*
* @example
* ```typescript
* // Add the value of the 'quantity' field and the 'reserve' field.
* add("quantity", field("reserve"));
* ```
*
* @param fieldName - The name of the field containing the value to add.
* @param second - The second expression or literal to add.
* @param others - Optional other expressions or literals to add.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the addition operation.
*/
function add(fieldName: string, second: Expression | unknown): FunctionExpression;
/**
* Options defining how an AddFieldsStage is evaluated. See {@link @firebase/firestore/pipelines#Pipeline.(addFields:1)}.
*/
type AddFieldsStageOptions = StageOptions & {
/**
* The fields to add to each document, specified as a {@link @firebase/firestore/pipelines#Selectable}.
* At least one field is required.
*/
fields: Selectable[];
};
/**
*
* A class that represents an aggregate function.
*/
class AggregateFunction {
private name;
private params;
exprType: ExpressionType;
/* Excluded from this release type: _methodName */
constructor(name: string, params: Expression[]);
/* Excluded from this release type: _create */
/**
* Assigns an alias to this AggregateFunction. The alias specifies the name that
* the aggregated value will have in the output document.
*
* @example
* ```typescript
* // Calculate the average price of all items and assign it the alias "averagePrice".
* firestore.pipeline().collection("items")
* .aggregate(field("price").average().as("averagePrice"));
* ```
*
* @param name - The alias to assign to this AggregateFunction.
* @returns A new {@link @firebase/firestore/pipelines#AliasedAggregate} that wraps this
* AggregateFunction and associates it with the provided alias.
*/
as(name: string): AliasedAggregate;
}
/**
* Options defining how an AggregateStage is evaluated. See {@link @firebase/firestore/pipelines#Pipeline.(aggregate:1)}.
*/
type AggregateStageOptions = StageOptions & {
/**
* The {@link @firebase/firestore/pipelines#AliasedAggregate} values specifying aggregate operations to
* perform on the input documents.
*/
accumulators: AliasedAggregate[];
/**
* The {@link @firebase/firestore/pipelines#Selectable} expressions or field names to consider when determining
* distinct value combinations (groups), which will be aggregated over.
*/
groups?: Array<string | Selectable>;
};
/**
*
* An AggregateFunction with alias.
*/
class AliasedAggregate {
readonly aggregate: AggregateFunction;
readonly alias: string;
constructor(aggregate: AggregateFunction, alias: string, _methodName: string | undefined);
}
class AliasedExpression implements Selectable {
readonly expr: Expression;
readonly alias: string;
exprType: ExpressionType;
selectable: true;
constructor(expr: Expression, alias: string, _methodName: string | undefined);
}
/**
*
* Creates an expression that performs a logical 'AND' operation on multiple filter conditions.
*
* @example
* ```typescript
* // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND
* // the 'status' field is "active"
* const condition = and(greaterThan("age", 18), equal("city", "London"), equal("status", "active"));
* ```
*
* @param first - The first filter condition.
* @param second - The second filter condition.
* @param more - Additional filter conditions to 'AND' together.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical 'AND' operation.
*/
function and(first: BooleanExpression, second: BooleanExpression, ...more: BooleanExpression[]): BooleanExpression;
/**
*
* Creates an expression that creates a Firestore array value from an input array.
*
* @example
* ```typescript
* // Create an array value from the input array and reference the 'baz' field value from the input document.
* array(['bar', field('baz')]).as('foo');
* ```
*
* @param elements - The input array to evaluate in the expression.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the array function.
*/
function array(elements: unknown[]): FunctionExpression;
/**
* Creates an aggregation that collects all values of an expression across multiple stage
* inputs into an array.
*
* @remarks
* If the expression resolves to an absent value, it is converted to `null`.
* The order of elements in the output array is not stable and shouldn't be relied upon.
*
* @example
* ```typescript
* // Collect all tags from books into an array
* arrayAgg(field("tags")).as("allTags");
* ```
*
* @param expression - The expression to collect values from.
* @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg' aggregation.
*/
function arrayAgg(expression: Expression): AggregateFunction;
/**
* Creates an aggregation that collects all values of a field across multiple stage inputs
* into an array.
*
* @remarks
* If the expression resolves to an absent value, it is converted to `null`.
* The order of elements in the output array is not stable and shouldn't be relied upon.
*
* @example
* ```typescript
* // Collect all tags from books into an array
* arrayAgg("tags").as("allTags");
* ```
*
* @param fieldName - The name of the field to collect values from.
* @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg' aggregation.
*/
function arrayAgg(fieldName: string): AggregateFunction;
/**
* Creates an aggregation that collects all distinct values of an expression across multiple stage
* inputs into an array.
*
* @remarks
* If the expression resolves to an absent value, it is converted to `null`.
* The order of elements in the output array is not stable and shouldn't be relied upon.
*
* @example
* ```typescript
* // Collect all distinct tags from books into an array
* arrayAggDistinct(field("tags")).as("allDistinctTags");
* ```
*
* @param expression - The expression to collect values from.
* @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg_distinct' aggregation.
*/
function arrayAggDistinct(expression: Expression): AggregateFunction;
/**
* Creates an aggregation that collects all distinct values of a field across multiple stage inputs
* into an array.
*
* @remarks
* If the expression resolves to an absent value, it is converted to `null`.
* The order of elements in the output array is not stable and shouldn't be relied upon.
*
* @example
* ```typescript
* // Collect all distinct tags from books into an array
* arrayAggDistinct("tags").as("allDistinctTags");
* ```
*
* @param fieldName - The name of the field to collect values from.
* @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg_distinct' aggregation.
*/
function arrayAggDistinct(fieldName: string): AggregateFunction;
/**
*
* Creates an expression that concatenates an array expression with other arrays.
*
* @example
* ```typescript
* // Combine the 'items' array with two new item arrays
* arrayConcat(field("items"), [field("newItems"), field("otherItems")]);
* ```
*
* @param firstArray - The first array expression to concatenate to.
* @param secondArray - The second array expression or array literal to concatenate to.
* @param otherArrays - Optional additional array expressions or array literals to concatenate.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated array.
*/
function arrayConcat(firstArray: Expression, secondArray: Expression | unknown[], ...otherArrays: Array<Expression | unknown[]>): FunctionExpression;
/**
*
* Creates an expression that concatenates a field's array value with other arrays.
*
* @example
* ```typescript
* // Combine the 'items' array with two new item arrays
* arrayConcat("items", [field("newItems"), field("otherItems")]);
* ```
*
* @param firstArrayField - The first array to concatenate to.
* @param secondArray - The second array expression or array literal to concatenate to.
* @param otherArrays - Optional additional array expressions or array literals to concatenate.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated array.
*/
function arrayConcat(firstArrayField: string, secondArray: Expression | unknown[], ...otherArrays: Array<Expression | unknown[]>): FunctionExpression;
/**
*
* Creates an expression that checks if an array expression contains a specific element.
*
* @example
* ```typescript
* // Check if the 'colors' array contains the value of field 'selectedColor'
* arrayContains(field("colors"), field("selectedColor"));
* ```
*
* @param array - The array expression to check.
* @param element - The element to search for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.
*/
function arrayContains(array: Expression, element: Expression): BooleanExpression;
/**
*
* Creates an expression that checks if an array expression contains a specific element.
*
* @example
* ```typescript
* // Check if the 'colors' array contains "red"
* arrayContains(field("colors"), "red");
* ```
*
* @param array - The array expression to check.
* @param element - The element to search for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.
*/
function arrayContains(array: Expression, element: unknown): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains a specific element.
*
* @example
* ```typescript
* // Check if the 'colors' array contains the value of field 'selectedColor'
* arrayContains("colors", field("selectedColor"));
* ```
*
* @param fieldName - The field name to check.
* @param element - The element to search for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.
*/
function arrayContains(fieldName: string, element: Expression): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains a specific value.
*
* @example
* ```typescript
* // Check if the 'colors' array contains "red"
* arrayContains("colors", "red");
* ```
*
* @param fieldName - The field name to check.
* @param element - The element to search for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.
*/
function arrayContains(fieldName: string, element: unknown): BooleanExpression;
/**
*
* Creates an expression that checks if an array expression contains all the specified elements.
*
* @example
* ```typescript
* // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1"
* arrayContainsAll(field("tags"), [field("tag1"), constant("SciFi"), "Adventure"]);
* ```
*
* @param array - The array expression to check.
* @param values - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.
*/
function arrayContainsAll(array: Expression, values: Array<Expression | unknown>): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains all the specified values or
* expressions.
*
* @example
* ```typescript
* // Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure"
* arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]);
* ```
*
* @param fieldName - The field name to check.
* @param values - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.
*/
function arrayContainsAll(fieldName: string, values: Array<Expression | unknown>): BooleanExpression;
/**
*
* Creates an expression that checks if an array expression contains all the specified elements.
*
* @example
* ```typescript
* // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1"
* arrayContainsAll(field("tags"), [field("tag1"), constant("SciFi"), "Adventure"]);
* ```
*
* @param array - The array expression to check.
* @param arrayExpression - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.
*/
function arrayContainsAll(array: Expression, arrayExpression: Expression): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains all the specified values or
* expressions.
*
* @example
* ```typescript
* // Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure"
* arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]);
* ```
*
* @param fieldName - The field name to check.
* @param arrayExpression - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.
*/
function arrayContainsAll(fieldName: string, arrayExpression: Expression): BooleanExpression;
/**
*
* Creates an expression that checks if an array expression contains any of the specified
* elements.
*
* @example
* ```typescript
* // Check if the 'categories' array contains either values from field "cate1" or "Science"
* arrayContainsAny(field("categories"), [field("cate1"), "Science"]);
* ```
*
* @param array - The array expression to check.
* @param values - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.
*/
function arrayContainsAny(array: Expression, values: Array<Expression | unknown>): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains any of the specified
* elements.
*
* @example
* ```typescript
* // Check if the 'groups' array contains either the value from the 'userGroup' field
* // or the value "guest"
* arrayContainsAny("categories", [field("cate1"), "Science"]);
* ```
*
* @param fieldName - The field name to check.
* @param values - The elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.
*/
function arrayContainsAny(fieldName: string, values: Array<Expression | unknown>): BooleanExpression;
/**
*
* Creates an expression that checks if an array expression contains any of the specified
* elements.
*
* @example
* ```typescript
* // Check if the 'categories' array contains either values from field "cate1" or "Science"
* arrayContainsAny(field("categories"), array([field("cate1"), "Science"]));
* ```
*
* @param array - The array expression to check.
* @param values - An expression that evaluates to an array, whose elements to check for in the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.
*/
function arrayContainsAny(array: Expression, values: Expression): BooleanExpression;
/**
*
* Creates an expression that checks if a field's array value contains any of the specified
* elements.
*
* @example
* ```typescript
* // Check if the 'groups' array contains either the value from the 'userGroup' field
* // or the value "guest"
* arrayContainsAny("categories", array([field("cate1"), "Science"]));
* ```
*
* @param fieldName - The field name to check.
* @param values - An expression that evaluates to an array, whose elements to check for in the array field.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.
*/
function arrayContainsAny(fieldName: string, values: Expression): BooleanExpression;
/**
*
* Creates an expression that filters an array using a provided alias and predicate expression.
*
* @example
* ```typescript
* // Get a filtered array of the 'scores' field containing only elements greater than 50.
* arrayFilter("scores", "score", greaterThan(variable("score"), 50));
* ```
*
* @param fieldName - The name of the field containing the array.
* @param alias - The variable name to use for each element.
* @param filter - The predicate boolean expression to evaluate for each element.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the filtered array.
*/
function arrayFilter(fieldName: string, alias: string, filter: BooleanExpression): FunctionExpression;
/**
* Creates an expression that filters an array using a provided alias and predicate expression.
*
* @example
* ```typescript
* // Filter "scores" to include only values greater than 50
* arrayFilter(field("scores"), "score", greaterThan(variable("score"), 50));
* ```
*
* @param arrayExpression - The expression representing the array.
* @param alias - The variable name to use for each element.
* @param filter - The predicate boolean expression to filter by.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the filtered array.
*/
function arrayFilter(arrayExpression: Expression, alias: string, filter: BooleanExpression): FunctionExpression;
/**
* Creates an expression that returns the first element of an array.
*
* @example
* ```typescript
* // Get the first tag from the 'tags' array field
* arrayFirst("tags");
* ```
*
* @param fieldName - The name of the field containing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first element.
*/
function arrayFirst(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that returns the first element of an array.
*
* @example
* ```typescript
* // Get the first tag from the 'tags' array field
* arrayFirst(field("tags"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first element.
*/
function arrayFirst(arrayExpression: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the first `n` elements of an array.
*
* @example
* ```typescript
* // Get the first 3 tags from the 'tags' array field
* arrayFirstN("tags", 3);
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first `n` elements.
*/
function arrayFirstN(fieldName: string, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the first `n` elements of an array.
*
* @example
* ```typescript
* // Get the first n tags from the 'tags' array field
* arrayFirstN("tags", field("count"));
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first `n` elements.
*/
function arrayFirstN(fieldName: string, n: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the first `n` elements of an array.
*
* @example
* ```typescript
* // Get the first 3 elements from an array expression
* arrayFirstN(field("tags"), 3);
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first `n` elements.
*/
function arrayFirstN(arrayExpression: Expression, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the first `n` elements of an array.
*
* @example
* ```typescript
* // Get the first n elements from an array expression
* arrayFirstN(field("tags"), field("count"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the first `n` elements.
*/
function arrayFirstN(arrayExpression: Expression, n: Expression): FunctionExpression;
/**
* Creates an expression that indexes into an array from the beginning or end
* and return the element. If the offset exceeds the array length, an error is
* returned. A negative offset, starts from the end.
*
* @example
* ```typescript
* // Return the value in the tags field array at index 1.
* arrayGet('tags', 1);
* ```
*
* @param arrayField - The name of the array field.
* @param offset - The index of the element to return.
* @returns A new `Expression` representing the 'arrayGet' operation.
*/
function arrayGet(arrayField: string, offset: number): FunctionExpression;
/**
* Creates an expression that indexes into an array from the beginning or end
* and return the element. If the offset exceeds the array length, an error is
* returned. A negative offset, starts from the end.
*
* @example
* ```typescript
* // Return the value in the tags field array at index specified by field
* // 'favoriteTag'.
* arrayGet('tags', field('favoriteTag'));
* ```
*
* @param arrayField - The name of the array field.
* @param offsetExpr - An `Expression` evaluating to the index of the element to return.
* @returns A new `Expression` representing the 'arrayGet' operation.
*/
function arrayGet(arrayField: string, offsetExpr: Expression): FunctionExpression;
/**
* Creates an expression that indexes into an array from the beginning or end
* and return the element. If the offset exceeds the array length, an error is
* returned. A negative offset, starts from the end.
*
* @example
* ```typescript
* // Return the value in the tags field array at index 1.
* arrayGet(field('tags'), 1);
* ```
*
* @param arrayExpression - An `Expression` evaluating to an array.
* @param offset - The index of the element to return.
* @returns A new `Expression` representing the 'arrayGet' operation.
*/
function arrayGet(arrayExpression: Expression, offset: number): FunctionExpression;
/**
* Creates an expression that indexes into an array from the beginning or end
* and return the element. If the offset exceeds the array length, an error is
* returned. A negative offset, starts from the end.
*
* @example
* ```typescript
* // Return the value in the tags field array at index specified by field
* // 'favoriteTag'.
* arrayGet(field('tags'), field('favoriteTag'));
* ```
*
* @param arrayExpression - An `Expression` evaluating to an array.
* @param offsetExpr - An `Expression` evaluating to the index of the element to return.
* @returns A new `Expression` representing the 'arrayGet' operation.
*/
function arrayGet(arrayExpression: Expression, offsetExpr: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the first index of the search value in an array.
* Returns -1 if the value is not found.
*
* @example
* ```typescript
* // Get the index of "politics" in the 'tags' array field
* arrayIndexOf("tags", "politics");
* ```
*
* @param fieldName - The name of the field containing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index.
*/
function arrayIndexOf(fieldName: string, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns the first index of the search value in an array.
* Returns -1 if the value is not found.
*
* @example
* ```typescript
* // Get the index of "politics" in the 'tags' array field
* arrayIndexOf(field("tags"), "politics");
* ```
*
* @param arrayExpression - The expression representing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index.
*/
function arrayIndexOf(arrayExpression: Expression, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns all indices of the search value in an array.
*
* @example
* ```typescript
* // Get all indices of 5 in the 'scores' array field
* arrayIndexOfAll("scores", 5);
* ```
*
* @param fieldName - The name of the field containing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the indices.
*/
function arrayIndexOfAll(fieldName: string, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns all indices of the search value in an array.
*
* @example
* ```typescript
* // Get all indices of 5 in the 'scores' array field
* arrayIndexOfAll(field("scores"), 5);
* ```
*
* @param arrayExpression - The expression representing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the indices.
*/
function arrayIndexOfAll(arrayExpression: Expression, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns the last element of an array.
*
* @example
* ```typescript
* // Get the last tag from the 'tags' array field
* arrayLast("tags");
* ```
*
* @param fieldName - The name of the field containing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last element.
*/
function arrayLast(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that returns the last element of an array.
*
* @example
* ```typescript
* // Get the last tag from the 'tags' array field
* arrayLast(field("tags"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last element.
*/
function arrayLast(arrayExpression: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the last index of the search value in an array.
* Returns -1 if the value is not found.
*
* @example
* ```typescript
* // Get the last index of "politics" in the 'tags' array field
* arrayLastIndexOf("tags", "politics");
* ```
*
* @param fieldName - The name of the field containing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index.
*/
function arrayLastIndexOf(fieldName: string, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns the last index of the search value in an array.
* Returns -1 if the value is not found.
*
* @example
* ```typescript
* // Get the last index of "politics" in the 'tags' array field
* arrayLastIndexOf(field("tags"), "politics");
* ```
*
* @param arrayExpression - The expression representing the array to search.
* @param search - The value to search for.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index.
*/
function arrayLastIndexOf(arrayExpression: Expression, search: unknown | Expression): FunctionExpression;
/**
*
* Creates an expression that returns the last `n` elements of an array.
*
* @example
* ```typescript
* // Get the last 3 tags from the 'tags' array field
* arrayLastN("tags", 3);
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last `n` elements.
*/
function arrayLastN(fieldName: string, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the last `n` elements of an array.
*
* @example
* ```typescript
* // Get the last n tags from the 'tags' array field
* arrayLastN("tags", field("count"));
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last `n` elements.
*/
function arrayLastN(fieldName: string, n: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the last `n` elements of an array.
*
* @example
* ```typescript
* // Get the last 3 elements from an array expression
* arrayLastN(field("tags"), 3);
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last `n` elements.
*/
function arrayLastN(arrayExpression: Expression, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the last `n` elements of an array.
*
* @example
* ```typescript
* // Get the last n elements from an array expression
* arrayLastN(field("tags"), field("count"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the last `n` elements.
*/
function arrayLastN(arrayExpression: Expression, n: Expression): FunctionExpression;
/**
*
* Creates an expression that calculates the length of an array in a specified field.
*
* @example
* ```typescript
* // Get the number of items in field 'cart'
* arrayLength('cart');
* ```
*
* @param fieldName - The name of the field containing an array to calculate the length of.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.
*/
function arrayLength(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that calculates the length of an array expression.
*
* @example
* ```typescript
* // Get the number of items in the 'cart' array
* arrayLength(field("cart"));
* ```
*
* @param array - The array expression to calculate the length of.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.
*/
function arrayLength(array: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the maximum value in an array.
*
* @example
* ```typescript
* // Get the maximum value from the 'scores' array field
* arrayMaximum("scores");
* ```
*
* @param fieldName - The name of the field containing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the maximum value.
*/
function arrayMaximum(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that returns the maximum value in an array.
*
* @example
* ```typescript
* // Get the maximum value from the 'scores' array field
* arrayMaximum(field("scores"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the maximum value.
*/
function arrayMaximum(arrayExpression: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the largest `n` elements of an array.
*
* Note: Returns the n largest non-null elements in the array, in descending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the top 3 scores from the 'scores' array field
* arrayMaximumN("scores", 3);
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the largest `n` elements.
*/
function arrayMaximumN(fieldName: string, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the largest `n` elements of an array.
*
* Note: Returns the n largest non-null elements in the array, in descending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the top n scores from the 'scores' array field
* arrayMaximumN("scores", field("count"));
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the largest `n` elements.
*/
function arrayMaximumN(fieldName: string, n: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the largest `n` elements of an array.
*
* Note: Returns the n largest non-null elements in the array, in descending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the top 3 elements from an array expression
* arrayMaximumN(field("scores"), 3);
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the largest `n` elements.
*/
function arrayMaximumN(arrayExpression: Expression, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the largest `n` elements of an array.
*
* Note: Returns the n largest non-null elements in the array, in descending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the top n elements from an array expression
* arrayMaximumN(field("scores"), field("count"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the largest `n` elements.
*/
function arrayMaximumN(arrayExpression: Expression, n: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the minimum value in an array.
*
* @example
* ```typescript
* // Get the minimum value from the 'scores' array field
* arrayMinimum("scores");
* ```
*
* @param fieldName - The name of the field containing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the minimum value.
*/
function arrayMinimum(fieldName: string): FunctionExpression;
/**
*
* Creates an expression that returns the minimum value in an array.
*
* @example
* ```typescript
* // Get the minimum value from the 'scores' array field
* arrayMinimum(field("scores"));
* ```
*
* @param arrayExpression - The expression representing the array.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the minimum value.
*/
function arrayMinimum(arrayExpression: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the smallest `n` elements of an array.
*
* Note: Returns the n smallest non-null elements in the array, in ascending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the bottom 3 scores from the 'scores' array field
* arrayMinimumN("scores", 3);
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - The number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the smallest `n` elements.
*/
function arrayMinimumN(fieldName: string, n: number): FunctionExpression;
/**
*
* Creates an expression that returns the smallest `n` elements of an array.
*
* Note: Returns the n smallest non-null elements in the array, in ascending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the bottom n scores from the 'scores' array field
* arrayMinimumN(field("scores"), field("count"));
* ```
*
* @param fieldName - The name of the field containing the array.
* @param n - An expression evaluating to the number of elements to return.
* @returns A new {@link @firebase/firestore/pipelines#Expression} representing the smallest `n` elements.
*/
function arrayMinimumN(fieldName: string, n: Expression): FunctionExpression;
/**
*
* Creates an expression that returns the smallest `n` elements of an array.
*
* Note: Returns the n smallest non-null elements in the array, in ascending
* order. This does not use a stable sort, meaning the order of equivalent
* elements is undefined.
*
* @example
* ```typescript
* // Get the bottom 3 scores