type TimestampField = 'createdAt' | 'updatedAt' | 'archivedAt'; type TimestampFieldsOptions = { fields?: TimestampField[]; dates?: { createdAt?: Date; updatedAt?: Date; archivedAt?: Date; }; }; type TimestampFieldsMap = { createdAt: string; updatedAt: string; archivedAt: string; }; type WithTimestampResult = T & Pick; /** * Adds timestamp fields (createdAt, updatedAt, and/or archivedAt) to an object. * * @param data - The object to add timestamps to * @param options - Optional configuration object * @param options.fields - Array of timestamp fields to include. Defaults to ['createdAt', 'updatedAt'] * @param options.dates - Optional custom dates for specific timestamp fields * @returns A new object containing all properties from the input data plus the specified timestamp fields in ISO format * * @example * ```ts * // Add current timestamps (default: createdAt and updatedAt) * const result = withTimestamp({ id: 1, name: 'Test' }); * // Returns { id: 1, name: 'Test', updatedAt: '2025-10-21T10:00:00.000Z', createdAt: '2025-10-21T10:00:00.000Z' } * * // Only add updatedAt when updating data * const result = withTimestamp({ id: 1, name: 'Updated' }, { fields: ['updatedAt'] }); * // Returns { id: 1, name: 'Updated', updatedAt: '2025-10-21T10:00:00.000Z' } * * // Only add archivedAt when archiving data * const result = withTimestamp({ id: 1 }, { fields: ['archivedAt'] }); * // Returns { id: 1, archivedAt: '2025-10-21T10:00:00.000Z' } * * // Use custom dates * const customDate = new Date('2025-01-01'); * const result = withTimestamp({ id: 1 }, { * fields: ['createdAt', 'updatedAt'], * dates: { createdAt: customDate, updatedAt: customDate } * }); * // Returns { id: 1, updatedAt: '2025-01-01T00:00:00.000Z', createdAt: '2025-01-01T00:00:00.000Z' } * * // Add all three timestamps * const result = withTimestamp({ id: 1 }, { fields: ['createdAt', 'updatedAt', 'archivedAt'] }); * // Returns { id: 1, createdAt: '...', updatedAt: '...', archivedAt: '...' } * ``` */ export declare function withTimestamp>(data: T, options?: TimestampFieldsOptions): WithTimestampResult; export declare function withTimestamp, F extends TimestampField[]>(data: T, options: { fields: F; } & TimestampFieldsOptions): WithTimestampResult; export {}; //# sourceMappingURL=with-timestamp.d.ts.map