import type { google } from '@gcf/firestore-protos'; /** * Validates request-level invariants common to both `RunQuery` and * `RunAggregationQuery`. * * Enforced rules: * - `explainOptions` are **not supported** by the mock (kept unsupported for fidelity). * - Exactly one of `readTime`, `transaction`, or `newTransaction` may be set * (mutually exclusive pairs are checked). * - If `transaction` is present, it must be a non-empty `Uint8Array`. * * @param request - A GAPIC `IRunQueryRequest` or `IRunAggregationQueryRequest`. * @throws {GoogleError} (`INVALID_ARGUMENT` / `UNIMPLEMENTED`) if validation fails. */ export declare function validateCommonQueryRequest(request: google.firestore.v1.IRunQueryRequest | google.firestore.v1.IRunAggregationQueryRequest): void; /** Shortcut alias for `StructuredQuery.Direction`. */ export type Dir = google.firestore.v1.StructuredQuery.Direction; /** Shortcut alias for `StructuredQuery.FieldFilter.Operator`. */ export type Op = google.firestore.v1.StructuredQuery.FieldFilter.Operator; /** * Pre-parsed details for array-valued operands used by `IN`, `NOT_IN`, * and `ARRAY_CONTAINS_ANY`. */ export interface ArrayOperandInfo { op: 'IN' | 'NOT_IN' | 'ARRAY_CONTAINS_ANY'; vals: google.firestore.v1.IValue[]; size: number; hasNull: boolean; hasNaN: boolean; typeTags: Set<'null' | 'nan' | 'number' | 'string' | 'boolean' | 'timestamp' | 'reference' | 'geo' | 'bytes' | 'map' | 'array'>; refDbKeys: Set; hasStructured: boolean; } /** * Aggregate view of a StructuredQuery used for validation and later planning. */ export interface QueryValidationData { /** All operators observed in `where` (set). */ ops: Set; /** Per-operator counts used for simple cardinality checks. */ opCounts: { IN: number; NOT_IN: number; ARRAY_CONTAINS_ANY: number; ARRAY_CONTAINS: number; NOT_EQUAL: number; LT: number; LTE: number; GT: number; GTE: number; }; /** Whether any `IN` operator is present. */ hasIn: boolean; /** Whether any `NOT_IN` operator is present. */ hasNotIn: boolean; /** Whether any `!=` operator is present. */ hasNotEqual: boolean; /** Whether any bounded inequality (`<`, `<=`, `>`, `>=`) exists. */ hasBoundedInequality: boolean; /** Whether any inequality exists (`bounded` OR `!=` OR `NOT_IN`). */ hasAnyInequality: boolean; /** Distinct fields appearing in inequalities (sorted). */ inequalityFields: string[]; /** Fields listed in client-specified `orderBy`. */ orderByFields: string[]; /** First client-specified orderBy field, if any. */ firstOrderByField?: string; /** `true` if any orderBy was provided. */ hasOrderBy: boolean; /** Last explicit direction encountered (ignores `DIRECTION_UNSPECIFIED`). */ lastExplicitDirection: Dir; /** `true` if any orderBy item specified a direction. */ orderByHasExplicitDirection: boolean; /** One entry per array-valued operand encountered. */ arrayOperands: ArrayOperandInfo[]; /** `true` if any array operand is empty. */ anyArrayOpEmpty: boolean; /** `true` if any array operand exceeds 10 elements. */ anyArrayOpTooLarge: boolean; /** `true` if any array operand contains `null` or `NaN`. */ anyArrayHasNullOrNaN: boolean; /** Field path targeted by `findNearest.vectorField`. */ vectorFieldPath?: string; /** Shape audit for `findNearest.queryVector` (length & numeric checks). */ vectorQueryShape?: { length: number; hasNaN: boolean; hasNull: boolean; /** `true` if all elements are finite numbers (ints/doubles, no NaN). */ valid: boolean; }; /** Distance measure specified (enum string). */ distanceMeasure?: string; /** `true` if `distanceMeasure` is recognized/supported (or unspecified). */ hasValidDistanceMeasure: boolean; /** Optional non-negative threshold. */ distanceThreshold?: number; /** Optional field path to write the distance score into. */ distanceResultField?: string; /** `true` if `findNearest` is present. */ hasFindNearest: boolean; /** `true` if query-vector length exceeds 2048. */ vectorLengthExceeded?: boolean; /** `true` if `findNearest.limit` exceeds 1000. */ vectorLimitExceeded?: boolean; } /** * Extracts and summarizes validation-relevant info from a StructuredQuery. * Produces counts, flags, field sets, and audits for array operands and * `findNearest` options to enable precise error messaging elsewhere. * * This function does **not** throw; callers should apply dedicated validators. * * @param query - The StructuredQuery to analyze. * @returns A populated {@link QueryValidationData}. */ export declare function buildQueryValidationData(query: google.firestore.v1.IStructuredQuery): QueryValidationData; /** * Validates the `where` clause of a query against Firestore-like constraints. * * Checks include: * - Operator coexistence and cardinality (`IN`/`NOT_IN`/`ARRAY_CONTAINS_ANY`, * `ARRAY_CONTAINS`, `NOT_EQUAL`, range operators). * - Array operand constraints (non-empty, ≤10 elements, no `null`/`NaN`, * same-type requirements, same-DB references, etc.). * * @param query - The StructuredQuery (used for feature presence checks). * @param validationData - The precomputed audit from {@link buildQueryValidationData}. * @throws {GoogleError} with `INVALID_ARGUMENT` on violations. */ export declare function validateWhereFilterCompatibility(query: google.firestore.v1.IStructuredQuery, validationData: QueryValidationData): void; /** * Validates a `findNearest` clause (vector search) for shape and compatibility. * * Enforced rules (subset): * - `vectorField` and `queryVector` are required. * - `queryVector` elements must be finite numbers (no `null`/`NaN`), length ≤ 2048. * - `limit` must be ≤ 1000. * - `distanceMeasure` must be one of: `EUCLIDEAN`, `COSINE`, `DOT_PRODUCT` (or unspecified). * - `distanceThreshold` (if provided) must be a finite, non-negative number. * - Cannot be combined with `orderBy` (results are implicitly distance-ordered). * - `vectorField` cannot also be used in an inequality filter. * * @param validationData - The precomputed audit from {@link buildQueryValidationData}. * @throws {GoogleError} with `INVALID_ARGUMENT` on violations. */ export declare function validateFindNearestFilter(validationData: QueryValidationData): void; /** * Optional early validation that enforces an orderBy presence constraint * when inequalities exist **and** the client provided an orderBy clause. * * Rule: * - If any inequality exists and an orderBy is present, the **first** orderBy * must explicitly target one of the inequality fields. * * @param d - The precomputed audit. * @throws {GoogleError} with `INVALID_ARGUMENT` on violations. */ export declare function validateOrderByPresenceForInequalities(d: QueryValidationData): void; //# sourceMappingURL=query-validation.d.ts.map