import type { google } from '@gcf/firestore-protos'; /** * Firestore-compatible predicate evaluation for `StructuredQuery.FieldFilter`. * * This utility mirrors Firestore server semantics for equality, range, membership, * and array operators. Important nuances captured here: * * - **Presence vs. undefined:** Missing/undefined fields are not equal to anything and * are excluded from most operators (with specific exceptions noted below). * - **NaN equality:** `NaN` is only equal to `NaN`; for `!=`, `NaN != NaN` is **false**. * - **Range comparability:** Only certain kinds participate in `<`, `<=`, `>`, `>=`. * - **NOT_IN / IN:** Expected values are arrays; equality uses Firestore canonical * comparison (`compareValues`) and requires presence unless otherwise stated. * - **Arrays:** `array-contains` and `array-contains-any` compare elements using * Firestore equality, not JS strict equality. */ export declare class Operators { /** * Kinds that Firestore meaningfully supports for **range** predicates. * (Array/Map are not range-comparable; Boolean is typically disallowed by validation.) * @internal */ private static readonly RANGE_KINDS; /** * Equality with Firestore semantics (includes special `NaN` handling). * Excludes `Undefined` (missing fields never equal anything). * * @param actual - The field value (may be missing). * @param expected - The query operand. * @returns `true` if equal, otherwise `false`. * @internal */ private static eq; /** * Inequality with Firestore semantics. * * Rules: * - Missing/undefined fields are **included** by `!=` (return `true`). * - Type mismatch with a present `actual` counts as not equal. * - `NaN != NaN` is **false** (since `NaN` equals `NaN` for Firestore equality). * * @param actual - The field value (may be missing). * @param expected - The query operand. * @returns `true` if not equal, otherwise `false`. * @internal */ private static neq; /** Gate for range operators: presence, same-kind, allowed kind, and non-NaN/non-null. */ /** * Guard for range operators: requires presence, same kind, allowed kinds, * and excludes `null` and `NaN`. * * @param actual - The field value. * @param expected - The query operand. * @returns `true` if range comparison is permitted. * @internal */ private static rangeComparable; /** * Firestore `<` comparison. * @returns `true` when `actual < expected`, otherwise `false`. */ static lessThan(actual: unknown, expected: unknown): boolean; /** * Firestore `<=` comparison. * @returns `true` when `actual <= expected`, otherwise `false`. */ static lessThanOrEqual(actual: unknown, expected: unknown): boolean; /** * Firestore `>` comparison. * @returns `true` when `actual > expected`, otherwise `false`. */ static greaterThan(actual: unknown, expected: unknown): boolean; /** * Firestore `>=` comparison. * @returns `true` when `actual >= expected`, otherwise `false`. */ static greaterThanOrEqual(actual: unknown, expected: unknown): boolean; /** * Firestore `==` (EQUAL) comparison. * @returns `true` when equal under Firestore semantics. */ static equal(actual: unknown, expected: unknown): boolean; /** * Firestore `!=` (NOT_EQUAL) comparison. * @returns `true` when not equal under Firestore semantics. */ static notEqual(actual: unknown, expected: unknown): boolean; /** * Firestore `in` membership test. * * Rules: * - `expected` must be an array (defensively checked here). * - Missing/undefined `actual` is **not** included. * - Uses Firestore equality to match any element. * * @returns `true` if `actual` equals any element in `expected`. */ static in(actual: unknown, expected: unknown): boolean; /** * Firestore `not-in` membership test. * * Rules: * - `expected` must be an array (defensively checked). * - Missing/undefined and `null` **do not** match (return `false`). * - `NaN` is **included** (returns `true`). * - Otherwise returns `true` iff `actual` is present and unequal to every element. */ static notIn(actual: unknown, expected: unknown): boolean; /** * Firestore `array-contains` operator. * Returns `true` when `actual` is an array and contains an element equal to `expected` * under Firestore equality. */ static arrayContains(actual: unknown, expected: unknown): boolean; /** * Firestore `array-contains-any` operator. * Returns `true` when `actual` is an array and it contains **any** element equal to * **any** value in `expected` (which must be an array), using Firestore equality. */ static arrayContainsAny(actual: unknown, expected: unknown): boolean; /** * Dispatches the provided GAPIC operator to the appropriate implementation. * * @param operator - GAPIC `FieldFilter.Operator` enum value. * @param actual - The field value from the document. * @param expected - The operand supplied in the filter. * @returns The boolean result of the predicate. * @throws {Error} If the operator is not supported. */ static eval(operator: google.firestore.v1.StructuredQuery.FieldFilter.Operator, actual: unknown, expected: unknown): boolean; } //# sourceMappingURL=operators.d.ts.map