Split shared RPC handler by domain

This commit is contained in:
2026-05-14 15:50:28 -04:00
parent df367756d0
commit 4aa3f7b362
18 changed files with 636 additions and 555 deletions

View File

@@ -0,0 +1,16 @@
import type { Db } from "../db/database.js";
import { getModel, updateModelCell } from "../db/queries.js";
import { ok } from "./result.js";
import type { RpcHandlers } from "./types.js";
export function modelHandlers(db: Db): RpcHandlers<"model.get" | "model.updateCell" | "model.runScenario"> {
return {
"model.get": ({ companyId, tab }) => ok("model.get", getModel(db, companyId, tab)),
"model.updateCell": ({ companyId, tab, row, col, value }) =>
ok("model.updateCell", updateModelCell(db, companyId, tab, row, col, value)),
"model.runScenario": ({ companyId }) => {
const model = getModel(db, companyId, "income");
return ok("model.runScenario", model);
},
};
}