import { type QueryDocumentSnapshot, type SnapshotOptions } from 'firebase/firestore'; import { type FBConverter } from './converter.js'; export interface CreateConverterOptions { /** * Property name on `T` to assign the Firestore document ID (`snapshot.id`). * Set to `false` to disable automatic document ID injection. * Default: `'id'`. */ idField?: keyof T | string | false; /** * Whether to exclude the `idField` when writing to Firestore via `toFirestore`. * Default: `false`. */ excludeIdOnWrite?: boolean; /** * List of property paths (including nested dot-notation paths) that should * automatically convert from `Date` (in JavaScript) to `Timestamp` (in Firestore) * on write, and from `Timestamp` back to `Date` on read. */ dateFields?: (keyof T | string)[]; /** * Whether to automatically strip `undefined` properties during `toFirestore` * using `cleanFirestoreData`. * Default: `true`. */ cleanUndefined?: boolean; /** * Optional custom transformation function invoked during `toFirestore`. * Run before date field conversion and undefined cleaning. */ toFirestore?: (data: T) => any; /** * Optional custom transformation function invoked during `fromFirestore`. * Run after ID injection and date field conversion. * Useful for instantiating custom class instances (e.g. `new MyModel(data)`). */ fromFirestore?: (data: any, snapshot: QueryDocumentSnapshot, options: SnapshotOptions) => T; } /** * Creates a strongly typed `FBConverter` compatible with Firestore's `withConverter()`. * * Provides out-of-the-box support for: * - Automatic document ID injection on read. * - Bidirectional `Date` <-> `Timestamp` conversion for specified date fields. * - Automatic `undefined` stripping to prevent runtime Firestore errors. * - Custom instantiation hooks for domain model classes. * * @example * ```typescript * export interface CampInfo { * id: string; * name: string; * startOn: Date; * endOn: Date; * retail?: { isOvernight?: boolean }; * } * * export const campConverter = createConverter({ * idField: 'id', * dateFields: ['startOn', 'endOn'], * cleanUndefined: true, * }); * ``` */ export declare function createConverter(options?: CreateConverterOptions): FBConverter; //# sourceMappingURL=create-converter.d.ts.map