mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-03 13:52:09 +03:00
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.
31 lines
782 B
TypeScript
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);
|
|
}
|
|
}
|
|
}
|