import type { UndoOperation, UndoStackEntry } from '../../shared/undo' import { UndoStackRepository } from '../db/repositories/undo.repo' import type { SqliteDb } from '../db/types' export class UndoStackService { constructor(private db: SqliteDb) {} push(chapterId: string, operation: UndoOperation): UndoStackEntry { return new UndoStackRepository(this.db).push(chapterId, operation) } list(chapterId: string): UndoStackEntry[] { return new UndoStackRepository(this.db).list(chapterId) } apply(entryId: number): UndoOperation | null { const entry = new UndoStackRepository(this.db).get(entryId) return entry?.operation ?? null } }