UNPKG

@firebase/firestore

Version:

The Cloud Firestore component of the Firebase JS SDK.

1,369 lines • 56.4 kB
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var commonDdSAB1Gt_node = require('./common-CqUiBvHi.node.cjs.js');
require('@firebase/app');
require('@firebase/util');
require('@firebase/webchannel-wrapper/bloom-blob');
require('@firebase/logger');
require('util');
require('crypto');
require('tslib');
require('@grpc/grpc-js');
require('@grpc/proto-loader');
require('re2js');

/**
 * @license
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 *
 * The Pipeline class provides a flexible and expressive framework for building complex data
 * transformation and query pipelines for Firestore.
 *
 * A pipeline takes data sources, such as Firestore collections or collection groups, and applies
 * a series of stages that are chained together. Each stage takes the output from the previous stage
 * (or the data source) and produces an output for the next stage (or as the final output of the
 * pipeline).
 *
 * Expressions can be used within each stage to filter and transform data through the stage.
 *
 * NOTE: The chained stages do not prescribe exactly how Firestore will execute the pipeline.
 * Instead, Firestore only guarantees that the result is the same as if the chained stages were
 * executed in order.
 *
 * @example
 * ```typescript
 * const db: Firestore; // Assumes a valid firestore instance.
 *
 * // Example 1: Select specific fields and rename 'rating' to 'bookRating'
 * const results1 = await execute(db.pipeline()
 *     .collection("books")
 *     .select("title", "author", field("rating").as("bookRating")));
 *
 * // Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950
 * const results2 = await execute(db.pipeline()
 *     .collection("books")
 *     .where(and(field("genre").equal("Science Fiction"), field("published").greaterThan(1950))));
 *
 * // Example 3: Calculate the average rating of books published after 1980
 * const results3 = await execute(db.pipeline()
 *     .collection("books")
 *     .where(field("published").greaterThan(1980))
 *     .aggregate(average(field("rating")).as("averageRating")));
 * ```
 */
let Pipeline$1 = class Pipeline {
    /**
     * @internal
     * @private
     * @param _db
     * @param userDataReader
     * @param _userDataWriter
     * @param stages
     */
    constructor(
    /**
     * @internal
     * @private
     */
    _db, 
    /**
     * @internal
     * @private
     */
    userDataReader, 
    /**
     * @internal
     * @private
     */
    _userDataWriter, 
    /**
     * @internal
     * @private
     */
    stages) {
        this._db = _db;
        this.userDataReader = userDataReader;
        this._userDataWriter = _userDataWriter;
        this.stages = stages;
    }
    _readUserData(context) {
        this.stages.forEach(stage => {
            const subContext = context.contextWith({
                methodName: stage._name
            });
            stage._readUserData(subContext);
        });
    }
    addFields(fieldOrOptions, ...additionalFields) {
        // Process argument union(s) from method overloads
        let fields;
        let options;
        if (commonDdSAB1Gt_node.isSelectable(fieldOrOptions)) {
            fields = [fieldOrOptions, ...additionalFields];
            options = {};
        }
        else {
            ({ fields, ...options } = fieldOrOptions);
        }
        // Convert user land convenience types to internal types
        const normalizedFields = commonDdSAB1Gt_node.selectablesToMap(fields);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.AddFields(normalizedFields, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    addWindowFields(windowOrOptions, field, ...additionalFields) {
        // Process argument union(s) from method overloads
        const usesOptions = commonDdSAB1Gt_node.isAddWindowFieldsStageOptions(windowOrOptions);
        // The whole options object is forwarded, including `window` and `fields`.
        // That is safe because `OptionsUtil` only serializes keys declared in the
        // stage's option definitions, and this stage declares none.
        const options = usesOptions ? windowOrOptions : {};
        const window = usesOptions
            ? windowOrOptions.window
            : windowOrOptions;
        const fields = usesOptions
            ? windowOrOptions.fields
            : [field, ...additionalFields];
        // Create stage object
        const stage = new commonDdSAB1Gt_node.AddWindowFields(new commonDdSAB1Gt_node.WindowSpecInternal(window), commonDdSAB1Gt_node.aliasedAggregateToMap(fields), options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    removeFields(fieldValueOrOptions, ...additionalFields) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isField(fieldValueOrOptions) || commonDdSAB1Gt_node.isString$1(fieldValueOrOptions)
            ? {}
            : fieldValueOrOptions;
        const fields = commonDdSAB1Gt_node.isField(fieldValueOrOptions) || commonDdSAB1Gt_node.isString$1(fieldValueOrOptions)
            ? [fieldValueOrOptions, ...additionalFields]
            : fieldValueOrOptions.fields;
        // Convert user land convenience types to internal types
        const convertedFields = fields.map(f => commonDdSAB1Gt_node.isString$1(f) ? commonDdSAB1Gt_node.field(f) : f);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.RemoveFields(convertedFields, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    define(aliasedExpressionOrOptions, ...additionalExpressions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isAliasedExpr(aliasedExpressionOrOptions)
            ? {}
            : aliasedExpressionOrOptions;
        const aliasedExpressions = commonDdSAB1Gt_node.isAliasedExpr(aliasedExpressionOrOptions)
            ? [aliasedExpressionOrOptions, ...additionalExpressions]
            : aliasedExpressionOrOptions.variables;
        const convertedExpressions = commonDdSAB1Gt_node.selectablesToMap(aliasedExpressions);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Define(convertedExpressions, options);
        return this._addStage(stage);
    }
    /**
     * Converts this Pipeline into an expression that evaluates to an array of results.
     *
     * <p>Result Unwrapping:</p>
     * <ul>
     *  <li>If the items have a single field, their values are unwrapped and returned directly in the array.</li>
     *  <li>If the items have multiple fields, they are returned as objects in the array</li>
     * </ul>
     *
     * @example
     * ```typescript
     * // Get a list of reviewers for each book
     * db.pipeline().collection("books")
     *     .define(field("id").as("book_id"))
     *     .addFields(
     *         db.pipeline().collection("reviews")
     *             .where(field("book_id").equal(variable("book_id")))
     *             .select(field("reviewer"))
     *             .toArrayExpression()
     *             .as("reviewers")
     *     )
     * ```
     *
     * Output:
     * ```json
     * [
     *   {
     *     "id": "1",
     *     "title": "1984",
     *     "reviewers": ["Alice", "Bob"]
     *   }
     * ]
     * ```
     *
     * Multiple Fields:
     * ```typescript
     * // Get a list of reviews (reviewer and rating) for each book
     * db.pipeline().collection("books")
     *     .define(field("id").as("book_id"))
     *     .addFields(
     *         db.pipeline().collection("reviews")
     *             .where(field("book_id").equal(variable("book_id")))
     *             .select(field("reviewer"), field("rating"))
     *             .toArrayExpression()
     *             .as("reviews"))
     * ```
     *
     * Output:
     * ```json
     * [
     *   {
     *     "id": "1",
     *     "title": "1984",
     *     "reviews": [
     *       { "reviewer": "Alice", "rating": 5 },
     *       { "reviewer": "Bob", "rating": 4 }
     *     ]
     *   }
     * ]
     * ```
     *
     * @returns An `Expression` representing the execution of this pipeline.
     */
    toArrayExpression() {
        return new commonDdSAB1Gt_node.FunctionExpression('array', [commonDdSAB1Gt_node.fieldOrExpression(this)]);
    }
    /**
     * Converts this Pipeline into an expression that evaluates to a single scalar result.
     *
     * <p><b>Runtime Validation:</b> The runtime validates that the result set contains zero or one item. If
     * zero items, it evaluates to `null`.</p>
     *
     * <p>Result Unwrapping:</p>
     * <ul>
     *  <li>If the item has a single field, its value is unwrapped and returned directly.</li>
     *  <li>If the item has multiple fields, they are returned as an object.</li>
     * </ul>
     *
     * @example
     * ```typescript
     * // Calculate average rating for a restaurant
     * db.pipeline().collection("restaurants").addFields(
     *   db.pipeline().collection("reviews")
     *     .where(field("restaurant_id").equal(variable("rid")))
     *     .aggregate(average("rating").as("avg"))
     *     // Unwraps the single "avg" field to a scalar double
     *     .toScalarExpression().as("average_rating")
     * )
     * ```
     *
     * Output:
     * ```json
     * {
     *   "name": "The Burger Joint",
     *   "average_rating": 4.5
     * }
     * ```
     *
     * Multiple Fields:
     * ```typescript
     * // Calculate average rating AND count for a restaurant
     * db.pipeline().collection("restaurants").addFields(
     *   db.pipeline().collection("reviews")
     *     .where(field("restaurant_id").equal(variable("rid")))
     *     .aggregate(
     *       average("rating").as("avg"),
     *       count().as("count")
     *     )
     *     // Returns an object with "avg" and "count" fields
     *     .toScalarExpression().as("stats")
     * )
     * ```
     *
     * Output:
     * ```json
     * {
     *   "name": "The Burger Joint",
     *   "stats": {
     *     "avg": 4.5,
     *     "count": 100
     *   }
     * }
     * ```
     *
     * @returns An `Expression` representing the execution of this pipeline.
     */
    toScalarExpression() {
        return new commonDdSAB1Gt_node.FunctionExpression('scalar', [commonDdSAB1Gt_node.fieldOrExpression(this)]);
    }
    select(selectionOrOptions, ...additionalSelections) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isSelectable(selectionOrOptions) || commonDdSAB1Gt_node.isString$1(selectionOrOptions)
            ? {}
            : selectionOrOptions;
        const selections = commonDdSAB1Gt_node.isSelectable(selectionOrOptions) || commonDdSAB1Gt_node.isString$1(selectionOrOptions)
            ? [selectionOrOptions, ...additionalSelections]
            : selectionOrOptions.selections;
        // Convert user land convenience types to internal types
        const normalizedSelections = commonDdSAB1Gt_node.selectablesToMap(selections);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Select(normalizedSelections, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    where(conditionOrOptions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isBooleanExpr(conditionOrOptions) ? {} : conditionOrOptions;
        const condition = commonDdSAB1Gt_node.isBooleanExpr(conditionOrOptions)
            ? conditionOrOptions
            : conditionOrOptions.condition;
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Where(condition, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    offset(offsetOrOptions) {
        // Process argument union(s) from method overloads
        let options;
        let offset;
        if (commonDdSAB1Gt_node.isNumber$1(offsetOrOptions)) {
            options = {};
            offset = offsetOrOptions;
        }
        else {
            options = offsetOrOptions;
            offset = offsetOrOptions.offset;
        }
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Offset(offset, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    limit(limitOrOptions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isNumber$1(limitOrOptions) ? {} : limitOrOptions;
        const limit = commonDdSAB1Gt_node.isNumber$1(limitOrOptions)
            ? limitOrOptions
            : limitOrOptions.limit;
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Limit(limit, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    distinct(groupOrOptions, ...additionalGroups) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isString$1(groupOrOptions) || commonDdSAB1Gt_node.isSelectable(groupOrOptions)
            ? {}
            : groupOrOptions;
        const groups = commonDdSAB1Gt_node.isString$1(groupOrOptions) || commonDdSAB1Gt_node.isSelectable(groupOrOptions)
            ? [groupOrOptions, ...additionalGroups]
            : groupOrOptions.groups;
        // Convert user land convenience types to internal types
        const convertedGroups = commonDdSAB1Gt_node.selectablesToMap(groups);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Distinct(convertedGroups, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    aggregate(targetOrOptions, ...rest) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isAliasedAggregate(targetOrOptions) ? {} : targetOrOptions;
        const accumulators = commonDdSAB1Gt_node.isAliasedAggregate(targetOrOptions)
            ? [targetOrOptions, ...rest]
            : targetOrOptions.accumulators;
        const groups = commonDdSAB1Gt_node.isAliasedAggregate(targetOrOptions)
            ? []
            : (targetOrOptions.groups ?? []);
        // Convert user land convenience types to internal types
        const convertedAccumulators = commonDdSAB1Gt_node.aliasedAggregateToMap(accumulators);
        const convertedGroups = commonDdSAB1Gt_node.selectablesToMap(groups);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Aggregate(convertedGroups, convertedAccumulators, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    /**
     * Performs a vector proximity search on the documents from the previous stage, returning the
     * K-nearest documents based on the specified query `vectorValue` and `distanceMeasure`. The
     * returned documents will be sorted in order from nearest to furthest from the query `vectorValue`.
     *
     * @example
     * ```typescript
     * // Find the 10 most similar books based on the book description.
     * const bookDescription = "Lorem ipsum...";
     * const queryVector: number[] = ...; // compute embedding of `bookDescription`
     *
     * firestore.pipeline().collection("books")
     *     .findNearest({
     *       field: 'embedding',
     *       vectorValue: queryVector,
     *       distanceMeasure: 'euclidean',
     *       limit: 10,                        // optional
     *       distanceField: 'computedDistance' // optional
     *     });
     * ```
     *
     * @param options - An object that specifies required and optional parameters for the stage.
     * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.
     */
    findNearest(options) {
        // Convert user land convenience types to internal types
        const field = commonDdSAB1Gt_node.toField(options.field);
        const vectorValue = commonDdSAB1Gt_node.vectorToExpr(options.vectorValue);
        const distanceField = options.distanceField
            ? commonDdSAB1Gt_node.toField(options.distanceField)
            : undefined;
        const internalOptions = {
            distanceField,
            limit: options.limit,
            rawOptions: options.rawOptions
        };
        // Create stage object
        const stage = new commonDdSAB1Gt_node.FindNearest(vectorValue, field, options.distanceMeasure, internalOptions);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    // TODO(search) link to external documentation citing list of supported
    // expressions, when that documentation is created. List is not maintained
    // in the SDK because the list will change as the backend enables support.
    /**
     * Add a search stage to the Pipeline. The search stage supports
     * full-text search and geo search expressions.
     *
     * @remarks
     * This must be the first stage of the pipeline. A limited set of expressions are supported in the search stage.
     *
     * @example
     * ```typescript
     * // Full-text search example
     * firestore.pipeline().collection("restaurants")
     * .search({
     *   query: documentMatches("waffles OR pancakes"),
     *   sort: [
     *     score().descending(),
     *   ],
     *   addFields: [
     *     score().as("searchScore"),
     *   ]
     * })
     * ```
     *
     * @example
     * ```typescript
     * // Geo distance search example
     * const queryLocation = new GeoPoint(0, 0);
     * db.pipeline().collection('restaurants').search({
     *   query: field('location').geoDistance(queryLocation).lessThanOrEqual(1000),
     *   sort: [
     *     score().descending(),
     *   ],
     * })
     * ```
     *
     * @param options - An object that specifies parameters for the stage.
     * @return A new `Pipeline` object with this stage appended to the stage list.
     */
    search(options) {
        // Convert user land convenience types to internal types
        const addFields = options.addFields
            ? commonDdSAB1Gt_node.selectablesToObject(options.addFields)
            : undefined;
        const query = commonDdSAB1Gt_node.isExpr(options.query)
            ? options.query
            : commonDdSAB1Gt_node.documentMatches(options.query);
        const sort = commonDdSAB1Gt_node.isOrdering(options.sort)
            ? [options.sort]
            : options.sort;
        const select = undefined;
        // TODO(search) enable with backend support
        // select = options.select
        //   ? selectablesToObject(options.select)
        //   : undefined;
        const internalOptions = {
            ...options,
            addFields,
            select,
            query,
            sort
        };
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Search(internalOptions);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    sort(orderingOrOptions, ...additionalOrderings) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isOrdering(orderingOrOptions) ? {} : orderingOrOptions;
        const orderings = commonDdSAB1Gt_node.isOrdering(orderingOrOptions)
            ? [orderingOrOptions, ...additionalOrderings]
            : orderingOrOptions.orderings;
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Sort(orderings, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    replaceWith(valueOrOptions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isString$1(valueOrOptions) || commonDdSAB1Gt_node.isExpr(valueOrOptions) ? {} : valueOrOptions;
        const fieldNameOrExpr = commonDdSAB1Gt_node.isString$1(valueOrOptions) || commonDdSAB1Gt_node.isExpr(valueOrOptions)
            ? valueOrOptions
            : valueOrOptions.map;
        // Convert user land convenience types to internal types
        const mapExpr = commonDdSAB1Gt_node.fieldOrExpression(fieldNameOrExpr);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Replace(mapExpr, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    sample(documentsOrOptions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isNumber$1(documentsOrOptions) ? {} : documentsOrOptions;
        let rate;
        let mode;
        if (commonDdSAB1Gt_node.isNumber$1(documentsOrOptions)) {
            rate = documentsOrOptions;
            mode = 'documents';
        }
        else if (commonDdSAB1Gt_node.isNumber$1(documentsOrOptions.documents)) {
            rate = documentsOrOptions.documents;
            mode = 'documents';
        }
        else {
            rate = documentsOrOptions.percentage;
            mode = 'percent';
        }
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Sample(rate, mode, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    union(otherOrOptions) {
        // Process argument union(s) from method overloads
        let options;
        let otherPipeline;
        if (isPipeline(otherOrOptions)) {
            options = {};
            otherPipeline = otherOrOptions;
        }
        else {
            ({ other: otherPipeline, ...options } = otherOrOptions);
        }
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Union(otherPipeline, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    unnest(selectableOrOptions, indexField) {
        // Process argument union(s) from method overloads
        let options;
        let selectable;
        let indexFieldName;
        if (commonDdSAB1Gt_node.isSelectable(selectableOrOptions)) {
            options = {};
            selectable = selectableOrOptions;
            indexFieldName = indexField;
        }
        else {
            ({
                selectable,
                indexField: indexFieldName,
                ...options
            } = selectableOrOptions);
        }
        // Convert user land convenience types to internal types
        const alias = selectable.alias;
        const expr = selectable.expr;
        if (commonDdSAB1Gt_node.isString$1(indexFieldName)) {
            options.indexField = commonDdSAB1Gt_node._field(indexFieldName, 'unnest');
        }
        // Create stage object
        const stage = new commonDdSAB1Gt_node.Unnest(alias, expr, options);
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    /**
     * Adds a raw stage to the pipeline.
     *
     * <p>This method provides a flexible way to extend the pipeline's functionality by adding custom
     * stages. Each raw stage is defined by a unique `name` and a set of `params` that control its
     * behavior.
     *
     * <p>Example (Assuming there is no 'where' stage available in SDK):
     *
     * @example
     * ```typescript
     * // Assume we don't have a built-in 'where' stage
     * firestore.pipeline().collection('books')
     *     .rawStage('where', [field('published').lessThan(1900)]) // Custom 'where' stage
     *     .select('title', 'author');
     * ```
     *
     * @param name - The unique name of the raw stage to add.
     * @param params - A list of parameters to configure the raw stage's behavior.
     * @param options - An object of key value pairs that specifies optional parameters for the stage.
     * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.
     */
    rawStage(name, params, options) {
        // Convert user land convenience types to internal types
        const expressionParams = params.map((value) => {
            if (value instanceof commonDdSAB1Gt_node.Expression) {
                return value;
            }
            else if (value instanceof commonDdSAB1Gt_node.AggregateFunction) {
                return value;
            }
            else if (commonDdSAB1Gt_node.isPlainObject(value)) {
                return commonDdSAB1Gt_node._mapValue(value);
            }
            else {
                return commonDdSAB1Gt_node._constant(value, 'rawStage');
            }
        });
        // Create stage object
        const stage = new commonDdSAB1Gt_node.RawStage(name, expressionParams, options ?? {});
        // Add stage to the pipeline
        return this._addStage(stage);
    }
    delete(options = {}) {
        return this._addStage(new commonDdSAB1Gt_node.Delete(options));
    }
    update(transformedFieldOrOptions, ...additionalFields) {
        let fields;
        let options = {};
        if (commonDdSAB1Gt_node.isAliasedExpr(transformedFieldOrOptions)) {
            fields = [transformedFieldOrOptions, ...additionalFields];
        }
        else if (transformedFieldOrOptions) {
            ({ transformedFields: fields, ...options } = transformedFieldOrOptions);
        }
        const mapped = fields && fields.length > 0 ? commonDdSAB1Gt_node.selectablesToMap(fields) : undefined;
        return this._addStage(new commonDdSAB1Gt_node.Update(mapped, options));
    }
    insert(options = {}) {
        this._validateCollectionReference(options.collection);
        return this._addStage(new commonDdSAB1Gt_node.Insert(options));
    }
    upsert(fieldOrOptions, ...additionalFields) {
        let options = {};
        if (commonDdSAB1Gt_node.isAliasedExpr(fieldOrOptions)) {
            options = {
                additionalFields: [fieldOrOptions, ...additionalFields]
            };
        }
        else if (fieldOrOptions) {
            options = fieldOrOptions;
        }
        this._validateCollectionReference(options.collection);
        return this._addStage(new commonDdSAB1Gt_node.Upsert(options));
    }
    /**
     * Validates that a user provided `CollectionReference` targets the same
     * Firestore database as this pipeline.
     */
    _validateCollectionReference(collection) {
        if (!this._db || !commonDdSAB1Gt_node.isCollectionReference(collection)) {
            return;
        }
        const refDbId = collection.firestore._databaseId;
        const pipelineDbId = this._db._databaseId;
        if (!refDbId.isEqual(pipelineDbId)) {
            throw new commonDdSAB1Gt_node.FirestoreError(commonDdSAB1Gt_node.Code.INVALID_ARGUMENT, `Invalid CollectionReference. ` +
                `The project ID ("${refDbId.projectId}") or the database ("${refDbId.database}") does not match ` +
                `the project ID ("${pipelineDbId.projectId}") and database ("${pipelineDbId.database}") of the target database of this Pipeline.`);
        }
    }
    /**
     * @internal
     * @private
     */
    _toProto(jsonProtoSerializer) {
        const stages = this.stages.map(stage => stage._toProto(jsonProtoSerializer));
        return { stages };
    }
    _addStage(stage) {
        const copy = this.stages.map(s => s);
        copy.push(stage);
        return this.newPipeline(this._db, copy);
    }
    /**
     * @internal
     * @private
     * @param db
     * @param userDataReader
     * @param userDataWriter
     * @param stages
     * @protected
     */
    newPipeline(db, stages) {
        return new Pipeline(db, this.userDataReader, this._userDataWriter, stages);
    }
};
function isPipeline(val) {
    return val instanceof Pipeline$1;
}

/**
 * @license
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Provides the entry point for defining the data source of a Firestore {@link @firebase/firestore/pipelines#Pipeline}.
 *
 * Use the methods of this class (e.g., {@link @firebase/firestore/pipelines#PipelineSource.(collection:1)}, {@link @firebase/firestore/pipelines#PipelineSource.(collectionGroup:1)},
 * {@link @firebase/firestore/pipelines#PipelineSource.(database:1)}, or {@link @firebase/firestore/pipelines#PipelineSource.(documents:1)}) to specify the initial data
 * for your pipeline, such as a collection, a collection group, the entire database, or a set of specific documents.
 */
class PipelineSource {
    /**
     * @internal
     * @private
     * @param databaseId
     * @param userDataReader
     * @param _createPipeline
     */
    constructor(databaseId, userDataReader, 
    /**
     * @internal
     * @private
     */
    _createPipeline) {
        this.databaseId = databaseId;
        this.userDataReader = userDataReader;
        this._createPipeline = _createPipeline;
    }
    collection(collectionOrOptions) {
        // Process argument union(s) from method overloads
        const options = commonDdSAB1Gt_node.isString$1(collectionOrOptions) ||
            commonDdSAB1Gt_node.isCollectionReference(collectionOrOptions)
            ? {}
            : collectionOrOptions;
        const collectionRefOrString = commonDdSAB1Gt_node.isString$1(collectionOrOptions) ||
            commonDdSAB1Gt_node.isCollectionReference(collectionOrOptions)
            ? collectionOrOptions
            : collectionOrOptions.collection;
        // Validate that a user provided reference is for the same Firestore DB
        if (commonDdSAB1Gt_node.isCollectionReference(collectionRefOrString)) {
            this._validateReference(collectionRefOrString);
        }
        // Convert user land convenience types to internal types
        const normalizedCollection = commonDdSAB1Gt_node.isString$1(collectionRefOrString)
            ? collectionRefOrString
            : collectionRefOrString.path;
        // Create stage object
        const stage = new commonDdSAB1Gt_node.CollectionSource(normalizedCollection, options);
        // User data must be read in the context of the API method to
        // provide contextual errors
        const parseContext = this.userDataReader.createContext(3 /* UserDataSource.Argument */, 'collection');
        stage._readUserData(parseContext);
        // Add stage to the pipeline
        return this._createPipeline([stage]);
    }
    collectionGroup(collectionIdOrOptions) {
        // Process argument union(s) from method overloads
        let collectionId;
        let options;
        if (commonDdSAB1Gt_node.isString$1(collectionIdOrOptions)) {
            collectionId = collectionIdOrOptions;
            options = {};
        }
        else {
            ({ collectionId, ...options } = collectionIdOrOptions);
        }
        // Create stage object
        const stage = new commonDdSAB1Gt_node.CollectionGroupSource(collectionId, options);
        // User data must be read in the context of the API method to
        // provide contextual errors
        const parseContext = this.userDataReader.createContext(3 /* UserDataSource.Argument */, 'collectionGroup');
        stage._readUserData(parseContext);
        // Add stage to the pipeline
        return this._createPipeline([stage]);
    }
    database(options) {
        // Process argument union(s) from method overloads
        options = options ?? {};
        // Create stage object
        const stage = new commonDdSAB1Gt_node.DatabaseSource(options);
        // User data must be read in the context of the API method to
        // provide contextual errors
        const parseContext = this.userDataReader.createContext(3 /* UserDataSource.Argument */, 'database');
        stage._readUserData(parseContext);
        // Add stage to the pipeline
        return this._createPipeline([stage]);
    }
    documents(docsOrOptions) {
        // Process argument union(s) from method overloads
        let options;
        let docs;
        if (Array.isArray(docsOrOptions)) {
            docs = docsOrOptions;
            options = {};
        }
        else {
            ({ docs, ...options } = docsOrOptions);
        }
        // Validate that all user provided references are for the same Firestore DB
        docs
            .filter(v => v instanceof commonDdSAB1Gt_node.DocumentReference)
            .forEach(dr => this._validateReference(dr));
        // Convert user land convenience types to internal types
        const normalizedDocs = docs.map(doc => commonDdSAB1Gt_node.isString$1(doc) ? doc : doc.path);
        // Create stage object
        const stage = new commonDdSAB1Gt_node.DocumentsSource(normalizedDocs, options);
        // User data must be read in the context of the API method to
        // provide contextual errors
        const parseContext = this.userDataReader.createContext(3 /* UserDataSource.Argument */, 'documents');
        stage._readUserData(parseContext);
        // Add stage to the pipeline
        return this._createPipeline([stage]);
    }
    literals(documentsOrOptions) {
        let documents;
        let options = {};
        if (Array.isArray(documentsOrOptions)) {
            documents = documentsOrOptions;
        }
        else if (commonDdSAB1Gt_node.isPlainObject(documentsOrOptions) &&
            Array.isArray(documentsOrOptions.documents)) {
            ({ documents, ...options } = documentsOrOptions);
        }
        else {
            throw new commonDdSAB1Gt_node.FirestoreError(commonDdSAB1Gt_node.Code.INVALID_ARGUMENT, 'Function literals() requires an array of document objects or a LiteralsStageOptions object with a documents array.');
        }
        const stage = new commonDdSAB1Gt_node.LiteralsSource(documents, options);
        const parseContext = this.userDataReader.createContext(3 /* UserDataSource.Argument */, 'literals');
        stage._readUserData(parseContext);
        return this._createPipeline([stage]);
    }
    /**
     * Convert the given Query into an equivalent Pipeline.
     *
     * @param query - A Query to be converted into a Pipeline.
     *
     * @throws `FirestoreError` Thrown if any of the provided DocumentReferences target a different project or database than the pipeline.
     */
    createFrom(query) {
        return this._createPipeline(commonDdSAB1Gt_node.toPipelineStages(query._query, query.firestore));
    }
    _validateReference(reference) {
        const refDbId = reference.firestore._databaseId;
        if (!refDbId.isEqual(this.databaseId)) {
            throw new commonDdSAB1Gt_node.FirestoreError(commonDdSAB1Gt_node.Code.INVALID_ARGUMENT, `Invalid ${reference instanceof commonDdSAB1Gt_node.CollectionReference
                ? 'CollectionReference'
                : 'DocumentReference'}. ` +
                `The project ID ("${refDbId.projectId}") or the database ("${refDbId.database}") does not match ` +
                `the project ID ("${this.databaseId.projectId}") and database ("${this.databaseId.database}") of the target database of this Pipeline.`);
        }
    }
}
function subcollection(pathOrOptions) {
    // Process argument union(s) from method overloads
    let path;
    let options;
    if (commonDdSAB1Gt_node.isString$1(pathOrOptions)) {
        path = pathOrOptions;
        options = {};
    }
    else {
        ({ path, ...options } = pathOrOptions);
    }
    // Create stage object
    const stage = new commonDdSAB1Gt_node.SubcollectionSource(path, options);
    return new Pipeline$1(undefined, undefined, undefined, [stage]);
}

/**
 * @license
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Represents the results of a Firestore pipeline execution.
 *
 * A `PipelineSnapshot` contains zero or more {@link @firebase/firestore/pipelines#PipelineResult} objects
 * representing the documents returned by a pipeline query. It provides methods
 * to iterate over the documents and access metadata about the query results.
 *
 * @example
 * ```typescript
 * const snapshot: PipelineSnapshot = await firestore
 *   .pipeline()
 *   .collection('myCollection')
 *   .where(field('value').greaterThan(10))
 *   .execute();
 *
 * snapshot.results.forEach(doc => {
 *   console.log(doc.id, '=>', doc.data());
 * });
 * ```
 */
class PipelineSnapshot {
    constructor(pipeline, results, executionTime) {
        this._pipeline = pipeline;
        this._executionTime = executionTime;
        this._results = results;
    }
    /**
     * An array of all the results in the `PipelineSnapshot`.
     */
    get results() {
        return this._results;
    }
    /**
     * The time at which the pipeline producing this result is executed.
     *
     * @readonly
     *
     */
    get executionTime() {
        if (this._executionTime === undefined) {
            throw new Error("'executionTime' is expected to exist, but it is undefined");
        }
        return this._executionTime;
    }
}
/**
 *
 * A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the
 * {@link @firebase/firestore/pipelines#PipelineResult.data} or {@link @firebase/firestore/pipelines#PipelineResult.(get:1)} methods.
 *
 * <p>If the PipelineResult represents a non-document result, `ref` will return a undefined
 * value.
 */
class PipelineResult {
    /**
     * @private
     * @internal
     *
     * @param userDataWriter - The serializer used to encode/decode protobuf.
     * @param fields - The fields of the Firestore `Document` Protobuf backing
     * this document.
     * @param ref - The reference to the document.
     * @param createTime - The time when the document was created if the result is a document, undefined otherwise.
     * @param updateTime - The time when the document was last updated if the result is a document, undefined otherwise.
     * @param metadata
     * @param listenOptions
     */
    constructor(userDataWriter, fields, ref, createTime, updateTime, metadata, listenOptions) {
        this._ref = ref;
        this._userDataWriter = userDataWriter;
        this._createTime = createTime;
        this._updateTime = updateTime;
        this._fields = fields;
        this._metadata = metadata;
        this._listenOptions = listenOptions;
    }
    /**
     * @private
     * @internal
     * @param userDataWriter
     * @param doc
     * @param ref
     * @param metadata
     * @param listenOptions
     */
    static fromDocument(userDataWriter, doc, ref, metadata, listenOptions) {
        return new PipelineResult(userDataWriter, doc.data, ref, doc.createTime.toTimestamp(), doc.version.toTimestamp(), metadata, listenOptions);
    }
    /**
     * The reference of the document, if it is a document; otherwise `undefined`.
     */
    get ref() {
        return this._ref;
    }
    /**
     * The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`.
     *
     * @readonly
     *
     */
    get id() {
        return this._ref?.id;
    }
    /**
     * The time the document was created. Undefined if this result is not a document.
     *
     * @readonly
     */
    get createTime() {
        return this._createTime;
    }
    /**
     * The time the document was last updated (at the time the snapshot was
     * generated). Undefined if this result is not a document.
     *
     * @readonly
     */
    get updateTime() {
        return this._updateTime;
    }
    /**
     * Retrieves all fields in the result as an object.
     *
     * @returns An object containing all fields in the document or
     * 'undefined' if the document doesn't exist.
     *
     * @example
     * ```
     * let p = firestore.pipeline().collection('col');
     *
     * p.execute().then(results => {
     *   let data = results[0].data();
     *   console.log(`Retrieved data: ${JSON.stringify(data)}`);
     * });
     * ```
     */
    data() {
        return this._userDataWriter.convertValue(this._fields.value, this._listenOptions?.serverTimestampBehavior);
    }
    /**
     * @internal
     * @private
     *
     * Retrieves all fields in the result as a proto value.
     *
     * @returns An `Object` containing all fields in the result.
     */
    _fieldsProto() {
        // Return a cloned value to prevent manipulation of the Snapshot's data
        return this._fields.clone().value.mapValue.fields;
    }
    /**
     * Retrieves the field specified by `field`.
     *
     * @param field - The field path
     * (e.g. 'foo' or 'foo.bar') to a specific field.
     * @returns The data at the specified field location or `undefined` if no
     * such field exists.
     *
     * @example
     * ```
     * let p = firestore.pipeline().collection('col');
     *
     * p.execute().then(results => {
     *   let field = results[0].get('a.b');
     *   console.log(`Retrieved field value: ${field}`);
     * });
     * ```
     */
    // We deliberately use `any` in the external API to not impose type-checking
    // on end users.
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    get(fieldPath) {
        if (this._fields === undefined) {
            return undefined;
        }
        if (commonDdSAB1Gt_node.isField(fieldPath)) {
            fieldPath = fieldPath.fieldName;
        }
        const value = this._fields.field(commonDdSAB1Gt_node.fieldPathFromArgument('DocumentSnapshot.get', fieldPath));
        if (value !== null) {
            return this._userDataWriter.convertValue(value, this._listenOptions?.serverTimestampBehavior);
        }
    }
}
/**
 * Test equality of two PipelineResults.
 * @param left - First PipelineResult to compare.
 * @param right - Second PipelineResult to compare.
 */
function pipelineResultEqual(left, right) {
    if (left === right) {
        return true;
    }
    return (commonDdSAB1Gt_node.isOptionalEqual(left._ref, right._ref, commonDdSAB1Gt_node.refEqual) &&
        commonDdSAB1Gt_node.isOptionalEqual(left._fields, right._fields, (l, r) => l.isEqual(r)));
}

/**
 * @license
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class Pipeline extends Pipeline$1 {
    /**
     * @internal
     * @private
     * @param db
     * @param userDataReader
     * @param userDataWriter
     * @param stages
     * @param converter
     * @protected
     */
    newPipeline(db, stages) {
        return new Pipeline(db, this.userDataReader, this._userDataWriter, stages);
    }
}

/**
 * @license
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function execute(pipelineOrOptions) {
    const options = !(pipelineOrOptions instanceof Pipeline$1)
        ? pipelineOrOptions
        : {
            pipeline: pipelineOrOptions
        };
    const { pipeline, rawOptions, atomic, ...rest } = options;
    if (!pipeline._db) {
        return Promise.reject(new commonDdSAB1Gt_node.FirestoreError(commonDdSAB1Gt_node.Code.FAILED_PRECONDITION, 'This pipeline was created without a database (e.g., as a subcollection pipeline) and cannot be executed directly. It can only be used as part of another pipeline.'));
    }
    const firestore = commonDdSAB1Gt_node.cast(pipeline._db, commonDdSAB1Gt_node.Firestore);
    const client = commonDdSAB1Gt_node.ensureFirestoreConfigured(firestore);
    const userDataReader = commonDdSAB1Gt_node.newUserDataReader(firestore);
    const context = userDataReader.createContext(3 /* UserDataSource.Argument */, 'execute');
    pipeline._readUserData(context);
    const userDataWriter = new commonDdSAB1Gt_node.ExpUserDataWriter(firestore);
    const structuredPipelineOptions = new commonDdSAB1Gt_node.StructuredPipelineOptions(rest, rawOptions);
    structuredPipelineOptions._readUserData(context);
    const structuredPipeline = new commonDdSAB1Gt_node.StructuredPipeline(pipeline, structuredPipelineOptions);
    return commonDdSAB1Gt_node.firestoreClientExecutePipeline(client, structuredPipeline, {
        atomic
    }).then(result => {
        // Get the execution time from the first result.
        // firestoreClientExecutePipeline returns at least one PipelineStreamElement
        // even if the returned document set is empty.
        const executionTime = result.length > 0 ? result[0].executionTime?.toTimestamp() : undefined;
        const docs = result
            // Currently ignore any response from ExecutePipeline that does
            // not contain any document data in the `fields` property.
            .filter(element => !!element.fields)
            .map(element => new PipelineResult(userDataWriter, element.fields, element.key?.path
            ? new commonDdSAB1Gt_node.DocumentReference(firestore, null, element.key)
            : undefined, element.createTime?.toTimestamp(), element.updateTime?.toTimestamp()));
        return new PipelineSnapshot(pipeline, docs, executionTime);
    });
}
/**
 * @beta
 * Creates and returns a new PipelineSource, which allows specifying the source stage of a {@link @firebase/firestore/pipelines#Pipeline}.
 *
 * @example
 * ```typescript
 * let myPipeline: Pipeline = firestore.pipeline().collection('books');
 * ```
 */
// Augment the Firestore class with the pipeline() factory method
commonDdSAB1Gt_node.Firestore.prototype.pipeline = function () {
    const userDataReader = commonDdSAB1Gt_node.newUserDataReader(this);
    return new PipelineSource(this._databaseId, userDataReader, (stages) => {
        return new Pipeline(this, userDataReader, new commonDdSAB1Gt_node.ExpUserDataWriter(this), stages);
    });
};

exports.AggregateFunction = commonDdSAB1Gt_node.AggregateFunction;
exports.AliasedAggregate = commonDdSAB1Gt_node.AliasedAggregate;
exports.AliasedExpression = commonDdSAB1Gt_node.AliasedExpression;
exports.AliasedWindowFunction = commonDdSAB1Gt_node.AliasedWindowFunction;
exports.BooleanExpression = commonDdSAB1Gt_node.BooleanExpression;
exports.Expression = commonDdSAB1Gt_node.Expression;
exports.Field = commonDdSAB1Gt_node.Field;
exports.FunctionExpression = commonDdSAB1Gt_node.FunctionExpression;
exports.Ordering = commonDdSAB1Gt_node.Ordering;
exports.WindowFunction = commonDdSAB1Gt_node.WindowFunction;
exports._internalPipelineToExecutePipelineRequestProto = commonDdSAB1Gt_node._internalPipelineToExecutePipelineRequestProto;
exports.abs = commonDdSAB1Gt_node.abs;
exports.add = commonDdSAB1Gt_node.add;
exports.and = commonDdSAB1Gt_node.and;
exports.array = commonDdSAB1Gt_node.array;
exports.arrayAgg = commonDdSAB1Gt_node.arrayAgg;
exports.arrayAggDistinct = commonDdSAB1Gt_node.arrayAggDistinct;
exports.arrayConcat = commonDdSAB1Gt_node.arrayConcat;
exports.arrayContains = commonDdSAB1Gt_node.arrayContains;
exports.arrayContainsAll = commonDdSAB1Gt_node.arrayContainsAll;
exports.arrayContainsAny = commonDdSAB1Gt_node.arrayContainsAny;
exports.arrayFilter = commonDdSAB1Gt_node.arrayFilter;
exports.arrayFirst = commonDdSAB1Gt_node.arrayFirst;
exports.arrayFirstN = commonDdSAB1Gt_node.arrayFirstN;
exports.arrayGet = commonDdSAB1Gt_node.arrayGet;
exports.arrayIndexOf = commonDdSAB1Gt_node.arrayIndexOf;
exports.arrayIndexOfAll = commonDdSAB1Gt_node.arrayIndexOfAll;
exports.arrayLast = commonDdSAB1Gt_node.arrayLast;
exports.arrayLastIndexOf = commonDdSAB1Gt_node.arrayLastIndexOf;
exports.arrayLastN = commonDdSAB1Gt_node.arrayLastN;
exports.arrayLength = commonDdSAB1Gt_node.arrayLength;
exports.arrayMaximum = commonDdSAB1Gt_node.arrayMaximum;
exports.arrayMaximumN = commonDdSAB1Gt_node.arrayMaximumN;
exports.arrayMinimum = commonDdSAB1Gt_node.arrayMinimum;
exports.arrayMinimumN = commonDdSAB1Gt_node.arrayMinimumN;
exports.arraySlice = commonDdSAB1Gt_node.arraySlice;
exports.arraySum = commonDdSAB1Gt_node.arraySum;
exports.arrayTransform = commonDdSAB1Gt_node.arrayTransform;
exports.arrayTransformWithIndex = commonDdSAB1Gt_node.arrayTransformWithIndex;
exports.ascending = commonDdSAB1Gt_node.ascending;
exports.average = commonDdSAB1Gt_node.average;
exports.byteLength = commonDdSAB1Gt_node.byteLength;
exports.ceil = commonDdSAB1Gt_node.ceil;
exports.charLength = commonDdSAB1Gt_node.charLength;
exports.coalesce = commonDdSAB1Gt_node.coalesce;
exports.collectionId = commonDdSAB1Gt_node.collectionId;
exports.concat = commonDdSAB1Gt_node.concat;
exports.conditional = commonDdSAB1Gt_node.conditional;
exports.constant = commonDdSAB1Gt_node.constant;
exports.cosineDistance = commonDdSAB1Gt_node.cosineDistance;
exports.count = commonDdSAB1Gt_node.count;
exports.countAll = commonDdSAB1Gt_node.countAll;
exports.countDistinct = commonDdSAB1Gt_node.countDistinct;
exports.countIf = commonDdSAB1Gt_node.countIf;
exports.currentDocument = commonDdSAB1Gt_node.currentDocument;
exports.currentTimestamp = commonDdSAB1Gt_node.currentTimestamp;
exports.descending = commonDdSAB1Gt_node.descending;
exports.divide = commonDdSAB1Gt_node.divide;
exports.documentId = commonDdSAB1Gt_node.documentId;
exports.documentMatches = commonDdSAB1Gt_node.documentMatches;
exports.dotProduct = commonDdSAB1Gt_node.dotProduct;
exports.endsWith = commonDdSAB1Gt_node.endsWith;
exports.equal = commonDdSAB1Gt_node.equal;
exports.equalAny = commonDdSAB1Gt_node.equalAny;
exports.euclideanDistance = commonDdSAB1Gt_node.euclideanDistance;
exports.exists = commonDdSAB1Gt_node.exists;
exports.exp = commonDdSAB1Gt_node.exp;
exports.field = commonDdSAB1Gt_node.field;
exports.first = commonDdSAB1Gt_node.first;
exports.floor = commonDdSAB1Gt_node.floor;
exports.geoDistance = commonDdSAB1Gt_node.geoDistance;
exports.greaterThan = commonDdSAB1Gt_node.greaterThan;
exports.greaterThanOrEqual = commonDdSAB1Gt_node.greaterThanOrEqual;
exports.ifAbsent = commonDdSAB1Gt_node.ifAbsent;
exports.ifError = commonDdSAB1Gt_node.ifError;
exports.ifNull = commonDdSAB1Gt_node.ifNull;
exports.isAbsent = commonDdSAB1Gt_node.isAbsent;
exports.isError = commonDdSAB1Gt_node.isError;
exports.isType = commonDdSAB1Gt_node.isType;
exports.join = commonDdSAB1Gt_node.join;
exports.last = commonDdSAB1Gt_node.last;
exports.length = commonDdSAB1Gt_node.length;
exports.lessThan = commonDdSAB1Gt_node.lessThan;
exports.lessThanOrEqual = commonDdSAB1Gt_node.lessThanOrEqual;
exports.like = commonDdSAB1Gt_node.like;
exports.ln = commonDdSAB1Gt_node.ln;
exports.log = commonDdSAB1Gt_node.log;
exports.log10 = commonDdSAB1Gt_node.log10;
exports.logicalMaximum = commonDdSAB1Gt_node.logicalMaximum;
exports.logicalMinimum = commonDdSAB1Gt_node.logicalMinimum;
exports.ltrim = commonDdSAB1Gt_node.ltrim;
exports.map = commonDdSAB1Gt_node.map;
exports.mapEntries = commonDdSAB1Gt_node.mapEntries;
exports.mapGet = commonDdSAB1Gt_node.mapGet;
exports.mapKeys = commonDdSAB1Gt_node.mapKeys;
exports.mapMerge = commonDdSAB1Gt_node.mapMerge;
exports.mapRemove = commonDdSAB1Gt_node.mapRemove;
exports.mapSet = commonDdSAB1Gt_node.mapSet;
exports.mapValues = commonDdSAB1Gt_node.mapValues;
exports.maximum = commonDdSAB1Gt_node.maximum;
exports.minimum = commonDdSAB1Gt_node.minimum;
exports.mod = commonDdSAB1Gt_node.mod;
exports.multiply = commonDdSAB1Gt_node.multiply;
exports.nor = commonDdSAB1Gt_node.nor;
exports.not = commonDdSAB1Gt_node.not;
exports.notEqual = commonDdSAB1Gt_node.notEqual;
exports.notEqualAny = commonDdSAB1Gt_node.notEqualAny;
exports.or = commonDdSAB1Gt_node.or;
exports.parent = commonDdSAB1Gt_node.parent;
exports.pow = commonDdSAB1Gt_node.pow;
exports.rand = commonDdSAB1Gt_node.rand;
exports.rank = commonDdSAB1Gt_node.rank;
exports.regexContains = commonDdSAB1Gt_node.regexContains;
exports.regexFind = commonDdSAB1Gt_node.regexFind;
exports.regexFindAll = commonDdSAB1Gt_node.regexFindAll;
exports.regexMatch = commonDdSAB1Gt_node.regexMatch;
exports.reverse = commonDdSAB1Gt_node.reverse;
exports.round = commonDdSAB1Gt_node.round;
exports.rtrim = commonDdSAB1Gt_node.rtrim;
exports.score = commonDdSAB1Gt_node.score;
exports.split = commonDdSAB1Gt_node.split;
exports.sqrt = commonDdSAB1Gt_node.sqrt;
exports.startsWith = commonDdSAB1Gt_node.startsWith;
exports.stringConcat = commonDdSAB1Gt_node.stringConcat;
exports.stringContains = commonDdSAB1Gt_node.stringContains;
exports.stringIndexOf = commonDdSAB1Gt_node.stringIndexOf;
exports.stringRepeat = commonDdSAB1Gt_node.stringRepeat;
exports.stringReplaceAll = commonDdSAB1Gt_node.stringReplaceAll;
exports.stringReplaceOne = commonDdSAB1Gt_node.stringReplaceOne;
exports.stringReverse = commonDdSAB1Gt_node.stringReverse;
exports.substring = commonDdSAB1Gt_node.substring;
exports.subtract = commonDdSAB1Gt_node.subtract;
exports.sum = commonDdSAB1Gt_node.sum;
exports.switchOn = commonDdSAB1Gt_node.switchOn;
exports.timestampAdd = commonDdSAB1Gt_node.timestampAdd;
exports.timestampDiff = commonDdSAB1Gt_node.timestampDiff;
exports.timestampExtract = commonDdSAB1Gt_node.timestampExtract;
exports.timestampSubtract = commonDdSAB1Gt_node.timestampSubtract;
exports.timestampToUnixMicros = commonDdSAB1Gt_node.timestampToUnixMicros;
exports.timestampToUnixMillis = commonDdSAB1Gt_node.timestampToUnixMillis;
exports.timestampToUnixSeconds = commonDdSAB1Gt_node.timestampToUnixSeconds;
exports.timestampTruncate = commonDdSAB1Gt_node.timestampTruncate;
exports.toLower = commonDdSAB1Gt_node.toLower;
exports.toUpper = commonDdSAB1Gt_node.toUpper;
exports.trim = commonDdSAB1Gt_node.trim;
exports.trunc = commonDdSAB1Gt_node.trunc;
exports.type = commonDdSAB1Gt_node.type;
exports.unixMicrosToTimestamp = commonDdSAB1Gt_node.unixMicrosToTimestamp;
exports.unixMillisToTimestamp = commonDdSAB1Gt_node.unixMillisToTimestamp;
exports.unixSecondsToTimestamp = commonDdSAB1Gt_node.unixSecondsToTimestamp;
exports.variable = commonDdSAB1Gt_node.variable;
exports.vectorLength = commonDdSAB1Gt_node.vectorLength;
exports.xor = commonDdSAB1Gt_node.xor;
exports.Pipeline = Pipeline;
exports.PipelineResult = PipelineResult;
exports.PipelineSnapshot = PipelineSnapshot;
exports.PipelineSource = PipelineSource;
exports.execute = execute;
exports.pipelineResultEqual = pipelineResultEqual;
exports.subcollection = subcollection;
//# sourceMappingURL=pipelines.node.cjs.js.map