import { controllerProcedure, createTRPCRouter } from "../trpc.js";
import {
  detectAnomalies,
  generateProjectNarrative,
  getAnomalyDetail,
  getCachedNarrative,
  getInsightsSummary,
  projectNarrativeInputSchema,
} from "./insights-procedure-support.js";

export const insightsRouter = createTRPCRouter({
  getAnomalyDetail: controllerProcedure.query(({ ctx }) => getAnomalyDetail(ctx)),

  generateProjectNarrative: controllerProcedure
    .input(projectNarrativeInputSchema)
    .mutation(({ ctx, input }) => generateProjectNarrative(ctx, input)),

  detectAnomalies: controllerProcedure.query(({ ctx }) => detectAnomalies(ctx)),

  getInsightsSummary: controllerProcedure.query(({ ctx }) => getInsightsSummary(ctx)),

  getCachedNarrative: controllerProcedure
    .input(projectNarrativeInputSchema)
    .query(({ ctx, input }) => getCachedNarrative(ctx, input)),
});
