import { type DocumentReference, type WriteBatch as FirebaseFirestoreWriteBatch } from 'firebase/firestore'; import { type FirestoreDocumentContext, type UpdateData, type DocumentData, type WithFieldValue, FirestoreDocumentContextType, type FirestoreDocumentDataAccessor, type FirestoreDocumentDataAccessorFactory, type SetOptions } from '../../common/firestore'; import { DefaultFirestoreDocumentDataAccessor } from './driver.accessor.default'; /** * Client-side {@link FirestoreDocumentDataAccessor} that queues write operations into a Firestore `WriteBatch`. * * Extends {@link DefaultFirestoreDocumentDataAccessor} to override `delete`, `set`, and `update` so they * add operations to the batch rather than executing immediately. Read operations (`get`, `stream`, `exists`) * still execute directly against Firestore. The batch must be committed separately after all operations are queued. */ export declare class WriteBatchFirestoreDocumentDataAccessor extends DefaultFirestoreDocumentDataAccessor implements FirestoreDocumentDataAccessor { private readonly _batch; constructor(batch: FirebaseFirestoreWriteBatch, documentRef: DocumentReference); get batch(): FirebaseFirestoreWriteBatch; delete(): Promise; set(data: WithFieldValue, options?: SetOptions): Promise; update(data: UpdateData): Promise; } /** * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces {@link WriteBatchFirestoreDocumentDataAccessor} * instances bound to the given `WriteBatch`. All write operations from these accessors are queued * into the same batch. * * @param writeBatch - the Firestore `WriteBatch` to queue operations into * @returns a factory that creates write-batch-backed document data accessors for any document reference * * @example * ```ts * const batch = writeBatch(firestore); * const factory = writeBatchAccessorFactory(batch); * const accessor = factory.accessorFor(docRef); * await accessor.set(data); * await batch.commit(); * ``` */ export declare function writeBatchAccessorFactory(writeBatch: FirebaseFirestoreWriteBatch): FirestoreDocumentDataAccessorFactory; /** * Client-side {@link FirestoreDocumentContext} that groups all document operations into a single `WriteBatch`. * * Provides accessors with {@link FirestoreDocumentContextType.BATCH} semantics — writes are queued * and only applied when the batch is committed. */ export declare class WriteBatchFirestoreDocumentContext implements FirestoreDocumentContext { private readonly _batch; readonly contextType = FirestoreDocumentContextType.BATCH; readonly accessorFactory: FirestoreDocumentDataAccessorFactory; constructor(batch: FirebaseFirestoreWriteBatch); get batch(): FirebaseFirestoreWriteBatch; } /** * Factory function that creates a {@link WriteBatchFirestoreDocumentContext} for the given batch. * * @param batch - the Firestore `WriteBatch` to use for all document operations * @returns a new {@link WriteBatchFirestoreDocumentContext} bound to the given batch * * @example * ```ts * const batch = writeBatch(firestore); * const context = writeBatchDocumentContext(batch); * ``` */ export declare function writeBatchDocumentContext(batch: FirebaseFirestoreWriteBatch): WriteBatchFirestoreDocumentContext;