import { NodePgDatabase } from "drizzle-orm/node-postgres"; import type { EntityHistoryEntry } from "@rebasepro/types"; export type { RecordHistoryParams, FetchHistoryOptions, HistoryRetentionConfig } from "@rebasepro/types"; import type { RecordHistoryParams, FetchHistoryOptions, HistoryRetentionConfig } from "@rebasepro/types"; /** * A Postgres history row is already the wire shape — `updated_at` comes back * from the driver as a string. Kept as an alias because the name is used * throughout this package and in `PostgresBackendDriver`. */ export type HistoryEntry = EntityHistoryEntry; /** * Service for recording and querying row change history. * Stores history entries in the `rebase.entity_history` table. */ export declare class HistoryService { private db; retention: HistoryRetentionConfig; constructor(db: NodePgDatabase, retention?: Partial); /** * Record a history entry for an row change. * This is intentionally fire-and-forget safe — errors are logged but never * bubble up to block the main save/delete operation. * * After inserting, kicks off a non-blocking pruning pass for this row. */ recordHistory(params: RecordHistoryParams): Promise; /** * Fetch history entries for an row, ordered by most recent first. */ fetchHistory(tableName: string, id: string, options?: FetchHistoryOptions): Promise<{ data: HistoryEntry[]; total: number; }>; /** * Fetch a single history entry by ID. */ fetchHistoryEntry(historyId: string): Promise; /** * Prune history for a single row: enforce maxEntries and TTL. */ pruneEntity(tableName: string, id: string): Promise; /** * Global prune: enforce TTL across ALL rows in a single sweep. * Intended to be called periodically (e.g. once per hour or daily). */ pruneExpired(): Promise; } /** * Shallow comparison to find top-level keys that changed between two objects. */ export declare function findChangedFields(oldValues: Record, newValues: Record): string[] | null;