22 lines
439 B
TypeScript
22 lines
439 B
TypeScript
import {
|
|
clearEncounter,
|
|
type DomainError,
|
|
type DomainEvent,
|
|
isDomainError,
|
|
} from "@initiative/domain";
|
|
import type { EncounterStore } from "./ports.js";
|
|
|
|
export function clearEncounterUseCase(
|
|
store: EncounterStore,
|
|
): DomainEvent[] | DomainError {
|
|
const encounter = store.get();
|
|
const result = clearEncounter(encounter);
|
|
|
|
if (isDomainError(result)) {
|
|
return result;
|
|
}
|
|
|
|
store.save(result.encounter);
|
|
return result.events;
|
|
}
|