import type { Transaction } from '@/services/transaction-sync'; import type { Account, AccountBalance, Bank } from '@/types/account'; import type { AutomationRule } from '@/types/automation-rule'; import type { Category } from '@/types/category'; import Dexie, { type EntityTable } from 'dexie'; export interface SyncMetadata { key: string; value: string; } export interface PendingChange { id?: number; store: string; operation: 'create' | 'update' | 'delete'; data: Record; timestamp: string; } const db = new Dexie('whisper_money') as Dexie & { transactions: EntityTable; accounts: EntityTable; categories: EntityTable; banks: EntityTable; automation_rules: EntityTable; account_balances: EntityTable; sync_metadata: EntityTable; pending_changes: EntityTable; }; db.version(5).stores({ transactions: 'id, user_id, account_id, updated_at', accounts: 'id, user_id, bank_id, updated_at', categories: 'id, user_id, updated_at', banks: 'id, user_id, updated_at', automation_rules: 'id, user_id, priority, updated_at', account_balances: 'id, account_id, balance_date, updated_at', sync_metadata: 'key', pending_changes: '++id, store, timestamp', }); export { db };