import { type DomainError, type Encounter, isDomainError, redo, } from "@initiative/domain"; import type { EncounterStore, UndoRedoStore } from "./ports.js"; export function redoUseCase( encounterStore: EncounterStore, undoRedoStore: UndoRedoStore, ): Encounter | DomainError { const current = encounterStore.get(); const state = undoRedoStore.get(); const result = redo(state, current); if (isDomainError(result)) { return result; } encounterStore.save(result.encounter); undoRedoStore.save(result.state); return result.encounter; }