import { type QueryDocumentSnapshot, type QuerySnapshot } from '../types'; import { type IterateFirestoreDocumentSnapshotCheckpointsConfig, type IterateFirestoreDocumentSnapshotCheckpointsResult, type IterateFirestoreDocumentSnapshotPairBatchesConfig } from './query.iterate'; import { type FirestoreDocument } from '../accessor/document'; import { type FirestoreDocumentSnapshotDataPairWithData } from '../accessor/document.utility'; /** * Configuration for loading all document snapshots with their associated data as pairs. * * This interface defines the options for retrieving all document snapshots that match * specific criteria, along with their associated data, in a single batch operation. * It supports pagination via the checkpoint system for efficient handling of large result sets. * * @template T - The document data type * @template D - The FirestoreDocument implementation type (defaults to FirestoreDocument) */ export interface LoadAllFirestoreDocumentSnapshotPairsConfig = FirestoreDocument> extends Pick, 'documentAccessor' | 'queryFactory' | 'constraintsFactory' | 'dynamicConstraints' | 'totalSnapshotsLimit' | 'handleRepeatCursor' | 'filterCheckpointSnapshots' | 'limitPerCheckpoint'> { /** * Optional callback function to process each batch of snapshot pairs as they are loaded. * * This function is called once for each batch (checkpoint) of results, allowing for * batch processing of documents without waiting for all results to be collected. * * @param snapshotDataPairs - Array of document snapshots with their associated data * @param batchIndex - Zero-based index of the current batch * @returns A promise that resolves when batch processing is complete */ iterateSnapshotPairsBatch?(snapshotDataPairs: FirestoreDocumentSnapshotDataPairWithData[], batchIndex: number): Promise; } /** * Result of loading all document snapshots with their associated data as pairs. * * Contains the complete array of document snapshot pairs and metadata about the * query execution, such as the number of checkpoints processed and whether any * limits were reached. * * @template T - The document data type * @template D - The FirestoreDocument implementation type (defaults to FirestoreDocument) */ export interface LoadAllFirestoreDocumentSnapshotPairsResult = FirestoreDocument> extends Pick { /** * Array of all document snapshots with their associated data. * * Each item in the array contains both the Firestore document snapshot and * the data extracted from it, along with additional metadata. */ readonly snapshotPairs: FirestoreDocumentSnapshotDataPairWithData[]; } /** * Loads all document snapshots that match the specified criteria, along with their associated data, * into a single array. * * This function uses the paginated checkpoint system to efficiently retrieve potentially large * result sets in batches, then combines them into a single result array. It supports optional * batch processing while loading. * * @template T - The document data type * @template D - The FirestoreDocument implementation type (defaults to FirestoreDocument) * @param config - Configuration options for the loading operation * @returns Promise resolving to the result containing all matching document snapshot pairs * * @example * // Load all active user documents with their data * const result = await loadAllFirestoreDocumentSnapshotPairs({ * queryFactory: () => collection(firestore, 'users'), * constraintsFactory: () => [where('status', '==', 'active')], * documentAccessor: userAccessorFactory, * // Process batches as they load * iterateSnapshotPairsBatch: async (pairs, index) => { * console.log(`Processing batch ${index} with ${pairs.length} users`); * } * }); * * console.log(`Loaded ${result.snapshotPairs.length} user documents`); */ export declare function loadAllFirestoreDocumentSnapshotPairs = FirestoreDocument>(config: LoadAllFirestoreDocumentSnapshotPairsConfig): Promise>; /** * Configuration for loading all document snapshots that match specific criteria. * * This interface defines the options for retrieving all document snapshots in a single batch * operation, without their associated data. It supports pagination via the checkpoint system * for efficient handling of large result sets. * * @template T - The document data type */ export interface LoadAllFirestoreDocumentSnapshotsConfig extends Pick, 'queryFactory' | 'constraintsFactory' | 'dynamicConstraints' | 'totalSnapshotsLimit' | 'handleRepeatCursor' | 'filterCheckpointSnapshots' | 'limitPerCheckpoint'> { /** * Optional callback function to process each batch of snapshots as they are loaded. * * This function is called once for each batch (checkpoint) of results, allowing for * batch processing of documents without waiting for all results to be collected. * * @param snapshots - Array of document snapshots in the current batch * @param query - The complete query snapshot for the current batch * @returns A promise that resolves when batch processing is complete */ iterateSnapshotsForCheckpoint?(snapshots: QueryDocumentSnapshot[], query: QuerySnapshot): Promise; } /** * Result of loading all document snapshots that match specific criteria. * * Contains the complete array of document snapshots and metadata about the * query execution, such as the number of checkpoints processed and whether any * limits were reached. * * @template T - The document data type */ export interface LoadAllFirestoreDocumentSnapshotsResult extends Pick { /** * Array of all document snapshots that matched the query criteria. * * These snapshots can be used to access document data, IDs, and references. */ readonly snapshots: QueryDocumentSnapshot[]; } /** * Loads all document snapshots that match the specified criteria into a single array. * * This function uses the paginated checkpoint system to efficiently retrieve potentially large * result sets in batches, then combines them into a single result array. It supports optional * batch processing while loading. * * Unlike loadAllFirestoreDocumentSnapshotPairs, this function only retrieves the document * snapshots without automatically loading their associated data. * * @template T - The document data type * @param config - Configuration options for the loading operation * @returns Promise resolving to the result containing all matching document snapshots * * @example * // Load all documents created in the last 24 hours * const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000); * const result = await loadAllFirestoreDocumentSnapshot({ * queryFactory: () => collection(firestore, 'events'), * constraintsFactory: () => [where('createdAt', '>=', yesterday), orderBy('createdAt')], * totalSnapshotsLimit: 1000, // Stop after 1000 documents * // Process batches as they load * iterateSnapshotsForCheckpoint: async (snapshots, query) => { * console.log(`Processing batch with ${snapshots.length} events`); * } * }); * * console.log(`Loaded ${result.snapshots.length} event documents`); */ export declare function loadAllFirestoreDocumentSnapshot(config: LoadAllFirestoreDocumentSnapshotsConfig): Promise>;