import type { google } from '@gcf/firestore-protos'; import { Precondition } from 'firebase-admin/firestore'; import { NormalizedWrite } from '../../data-accessor.js'; import { GapicContext } from '../gapic-context.js'; /** * Result of normalizing and transforming a single GAPIC Write. * * - `normalized` is the internal write shape that the mock/engine understands. * - `transformResults` (when present) contains encoded proto `Value`s produced * by field transforms, in the same order as the request’s transforms. These * are later surfaced as `WriteResult.transformResults`. */ export interface TransformedWrite { normalized: NormalizedWrite; transformResults?: google.firestore.v1.IValue[] | null; } /** * Converts an array of GAPIC `Write` messages into normalized internal writes, * applying Firestore Admin SDK semantics and preparing transform results. * * Supported operations: * - **Delete** (`write.delete`): cannot be combined with `update` or transforms. * - **Update/Set** (`write.update`) with optional `updateMask` and * `updateTransforms`: * - Decodes `update.fields` into POJO data. * - When an `updateMask` is present: * - Builds a sparse object containing only masked fields. * - For fields listed in the mask but missing from `update.fields`, inserts * a deletion sentinel (implemented as a thunk) to mark field deletion. * - Sets merge granularity to: * - `'node'` if any masked path is nested (multi-segment), * - otherwise `'branch'` (top-level only). * - Without `updateMask`, the operation is treated as a full-document set with * merge granularity `'root'`. * - `updateTransforms` are converted to {@link FieldTransformFunction}s and * written into the outgoing data at their respective field paths. Any values * they produce are appended to `transformResults` (proto-encoded). * * Validation & errors: * - `write.transform` (top-level transform-only writes) are **not supported** * by the Admin SDK: throws `INVALID_ARGUMENT`. * - A write specifying `delete` **and** `update`/**transforms** is invalid: * throws `INVALID_ARGUMENT`. * - A write that specifies none of `update`, `delete`, or transforms: throws * `INVALID_ARGUMENT`. * - Nested arrays (an array directly containing an array) are rejected to mirror * Firestore’s error: throws `INVALID_ARGUMENT`. * - Field transform kinds outside the supported set result in `UNIMPLEMENTED`. * * @param context - GAPIC context with serializer and path conversion. * @param writes - Array of GAPIC `IWrite` messages. * @returns Array of {@link TransformedWrite} in request order. */ export declare function transformWrites(context: GapicContext, writes: google.firestore.v1.IWrite[]): TransformedWrite[]; /** * Converts a GAPIC `Precondition` to an internal `Precondition`. * * Mapping: * - `updateTime` → `{ lastUpdateTime: Timestamp }` * - `exists` → `{ exists: boolean }` * - Absent or unrecognized fields → `undefined` * * @param source - GAPIC precondition or `null`/`undefined`. * @returns Internal precondition or `undefined`. */ export declare function toPrecondition(source: google.firestore.v1.IPrecondition | null | undefined): Precondition | undefined; /** * (Duplicate type preserved for compatibility in this module.) * * Result of normalizing and transforming a single GAPIC Write. */ export interface TransformedWrite { normalized: NormalizedWrite; transformResults?: google.firestore.v1.IValue[] | null; } //# sourceMappingURL=convert.d.ts.map