44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { z } from "zod";
|
|
import { createTRPCRouter, controllerProcedure, type TRPCContext } from "../trpc.js";
|
|
import { createComputationGraphDetailProcedures } from "./computation-graph-detail.js";
|
|
import { readProjectGraphSnapshot } from "./computation-graph-project.js";
|
|
import { readResourceGraphSnapshot } from "./computation-graph-resource.js";
|
|
import { type GraphLink, type GraphNode } from "./computation-graph-shared.js";
|
|
export type { GraphLink, GraphNode } from "./computation-graph-shared.js";
|
|
|
|
const resourceGraphInputSchema = z.object({
|
|
resourceId: z.string(),
|
|
month: z.string().regex(/^\d{4}-\d{2}$/),
|
|
});
|
|
|
|
const projectGraphInputSchema = z.object({
|
|
projectId: z.string(),
|
|
});
|
|
|
|
const computationGraphDetailProcedures = createComputationGraphDetailProcedures({
|
|
resourceGraphInputSchema,
|
|
projectGraphInputSchema,
|
|
readResourceGraphSnapshot,
|
|
readProjectGraphSnapshot,
|
|
});
|
|
|
|
// ─── Router ─────────────────────────────────────────────────────────────────
|
|
|
|
export const computationGraphRouter = createTRPCRouter({
|
|
...computationGraphDetailProcedures,
|
|
/**
|
|
* Resource View: SAH, Allocation, Rules, Chargeability, Budget
|
|
* for a single resource in a single month.
|
|
*/
|
|
getResourceData: controllerProcedure
|
|
.input(resourceGraphInputSchema)
|
|
.query(({ ctx, input }) => readResourceGraphSnapshot(ctx, input)),
|
|
|
|
/**
|
|
* Project View: Estimate, Commercial, Experience, Effort, Spread, Budget
|
|
*/
|
|
getProjectData: controllerProcedure
|
|
.input(projectGraphInputSchema)
|
|
.query(({ ctx, input }) => readProjectGraphSnapshot(ctx, input)),
|
|
});
|