import { type Maybe } from '@dereekb/util'; import { type Transaction, type FirestoreDocumentSnapshotDataPair } from '../../common'; import { type NotificationBoxDocument, type NotificationFirestoreCollections, type NotificationLoggedEventDayDocument } from './notification'; import { type NotificationLoggedEventDayId, type NotificationTaskType, type NotificationTemplateType } from './notification.id'; import { type NotificationItem } from './notification.item'; /** * Configuration for {@link notificationLoggedEventLoader}. */ export interface NotificationLoggedEventLoaderConfig { readonly notificationFirestoreCollections: NotificationFirestoreCollections; readonly notificationBox: NotificationBoxDocument; readonly transaction?: Maybe; } /** * Input for {@link NotificationLoggedEventLoader.getItemsForDayRange}. */ export interface NotificationLoggedEventLoaderItemsForDayRangeInput { readonly from: Date; readonly to: Date; readonly type?: Maybe; } /** * Per-day result yielded by {@link NotificationLoggedEventLoader.forEachDayInRange}. */ export interface NotificationLoggedEventLoaderDayResult { readonly dayId: NotificationLoggedEventDayId; readonly items: NotificationItem[]; } /** * Input for {@link NotificationLoggedEventLoader.forEachDayInRange}. */ export interface NotificationLoggedEventLoaderForEachDayInRangeInput { readonly from: Date; readonly to: Date; readonly type?: Maybe; readonly maxParallelTasks?: Maybe; readonly handler: (input: NotificationLoggedEventLoaderDayResult) => Promise | void; } /** * Cached, range-aware reader for the {@link NotificationLoggedEventDay} archive of a single * {@link NotificationBoxDocument}. Mirrors the pattern of `regionalHeirarchyForRegionalObjectModelKeyLoader` * — request-scoped, deduplicates reads via promise caching, and exposes both per-day and * date-range methods. */ export interface NotificationLoggedEventLoader { readonly notificationBox: NotificationBoxDocument; /** * Loads (and caches) the {@link NotificationLoggedEventDay} wrapper document for the given day. */ getDay(dayId: NotificationLoggedEventDayId): Promise>; /** * Loads (and caches) every archived {@link NotificationItem} for the given day. */ getItemsForDay(dayId: NotificationLoggedEventDayId): Promise; /** * Loads items for the given day, filtered to those whose `t` matches the given type. * Reuses the underlying day cache; no extra Firestore reads. */ getItemsForDayWithType(dayId: NotificationLoggedEventDayId, type: NotificationTemplateType | NotificationTaskType): Promise; /** * Loads items across all days in `[from, to]` (inclusive), optionally filtered by type. * Days with no archive contribute zero items. */ getItemsForDayRange(input: NotificationLoggedEventLoaderItemsForDayRangeInput): Promise; /** * Streams items per-day across `[from, to]` (inclusive). Each day is loaded via the same cache * as the per-day getters and passed to `handler` exactly once. Concurrency is bounded by * `maxParallelTasks` (defaults to unbounded — same as {@link performTasksFromFactoryInParallelFunction}). */ forEachDayInRange(input: NotificationLoggedEventLoaderForEachDayInRangeInput): Promise; } /** * Creates a request-scoped {@link NotificationLoggedEventLoader} that caches both day wrapper * snapshots (via {@link limitedFirestoreDocumentAccessorSnapshotCache}) and the per-day merged * `NotificationItem[]` from the paged subcollection. * * Cache lifetime is the loader instance — create one per request/transaction; do not retain. * * @param config - Notification collections, the parent {@link NotificationBoxDocument}, optional transaction. * @returns The cached loader. */ export declare function notificationLoggedEventLoader(config: NotificationLoggedEventLoaderConfig): NotificationLoggedEventLoader;