Files
OmniRoute/src/lib/db/stateReset.ts
diegosouzapw 052eb8d330 refactor: replace any types with generics and add Zod validation schemas
Eliminate `any` usage across the codebase by introducing proper generics,
typed interfaces (StatementLike, DbLike, PromptRow, etc.), and helper
conversion functions (toNumber, toString, parseVariables). Add
comprehensive Zod validation schemas for API endpoint inputs to enforce
runtime type safety alongside compile-time checks.
2026-03-04 18:59:27 -03:00

31 lines
782 B
TypeScript

/**
* Central registry for DB module state resetters.
* Used by restore flows to clear prepared statement caches without cross-module imports.
*/
type DbStateResetter = () => void;
const resetters = new Set<DbStateResetter>();
/**
* Register a module-level state resetter.
* Duplicate function references are deduplicated by Set semantics.
*/
export function registerDbStateResetter(resetter: DbStateResetter) {
resetters.add(resetter);
}
/**
* Invoke all registered state resetters.
* A failing resetter must not block execution of the remaining handlers.
*/
export function resetAllDbModuleState() {
for (const resetter of resetters) {
try {
resetter();
} catch (error) {
console.warn("[DB] Failed to reset module state:", error);
}
}
}