/** * Helpers for the "store a Firestore `Timestamp`, read a milliseconds-since-epoch `number`" * pattern. * * FlintFire has no read/after-find lifecycle hook (hooks are write-only), so a repository's * `readConverter` (the `fromFirestore` half of a `FirestoreDataConverter`) is the single * read-transform seam. Repository converters are read-only — writes go through a raw ref — so the * recommended write path is to write native temporal values (a `Date` or * `FieldValue.serverTimestamp()`, both of which the Admin SDK stores as a `Timestamp` on every write * path) and to convert `Timestamp -> number` only on read. {@link createMillisTimestampConverter} * packages exactly that: a recursive `fromFirestore` read mapper, ready to pass as `readConverter`. */ import { Timestamp } from 'firebase-admin/firestore'; import type { FirestoreDataConverter } from 'firebase-admin/firestore'; /** * Converts a single Firestore `Timestamp` to milliseconds-since-epoch. * @throws {TypeError} if the value is not a `Timestamp` (has no `toMillis`). */ export declare function convertTimestampToMillis(value: unknown): number; /** * Converts a milliseconds-since-epoch `number` to a Firestore `Timestamp`. Imports `Timestamp` * from `firebase-admin/firestore` so callers do not pass the class in. * @throws {TypeError} if the value is not a finite number. */ export declare function convertMillisToTimestamp(ms: number): Timestamp; /** * Recursively converts every Firestore `Timestamp` inside a value (walking plain objects and * arrays) to a milliseconds-since-epoch `number`, returning a converted copy. Uses a structural * `toMillis` duck-check and never references `firebase-admin`, so the implementation is safe to * reuse in shared/browser code. Values without a `toMillis` (including a `VectorValue`) are left * untouched. */ export declare function convertTimestampsToMillis(data: unknown): T; /** * Builds a read-only converter (the `fromFirestore` half of a `FirestoreDataConverter`) that * converts stored `Timestamp`s to milliseconds-since-epoch `number`s on read. Pass the result as a * repository's `readConverter`; the repository builds the full converter internally and applies it * to reads only. * * Write native temporal values (`Date` / `FieldValue.serverTimestamp()`) — the Admin SDK stores * those as a `Timestamp` on every write path — and let this mapper convert `Timestamp -> number` on * read. The repository overlays the document `id` itself, so the returned data omits `id`. * * @param fields - When provided, only these top-level fields are converted (each recursively); * omit to convert the entire document recursively. */ export declare function createMillisTimestampConverter(fields?: string[]): FirestoreDataConverter['fromFirestore'];