import { createTRPCRouter, controllerProcedure } from "../trpc.js";
import {
  computationGraphDetailProcedures,
  getProjectGraphData,
  getResourceGraphData,
  ProjectGraphInputSchema,
  ResourceGraphInputSchema,
} from "./computation-graph-procedure-support.js";
import { type GraphLink, type GraphNode } from "./computation-graph-shared.js";
export type { GraphLink, GraphNode } from "./computation-graph-shared.js";

// ─── 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 }) => getResourceGraphData(ctx, input)),

  /**
   * Project View: Estimate, Commercial, Experience, Effort, Spread, Budget
   */
  getProjectData: controllerProcedure
    .input(ProjectGraphInputSchema)
    .query(({ ctx, input }) => getProjectGraphData(ctx, input)),
});
