feat: complete audit coverage — comment, webhook, system-role, dispo, scenario
- comment.ts: create (body preview), resolve, delete - webhook.ts: create, update, delete, test (result in summary) - system-role-config.ts: update with before/after - dispo.ts: commitImportBatch (IMPORT with counts), cancelImportBatch - scenario.ts: applyScenario (CREATE with allocation count) Audit coverage now: 29/36 routers (81%). Remaining 7 are read-only (dashboard, staffing, chargeability-report, computation-graph, report, insights.detectAnomalies, notification read/dismiss). Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { z } from "zod";
|
||||
import { adminProcedure, createTRPCRouter } from "../trpc.js";
|
||||
import { createAuditEntry } from "../lib/audit.js";
|
||||
|
||||
// ─── Shared schemas ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -175,10 +176,23 @@ export const dispoRouter = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
|
||||
return ctx.db.importBatch.update({
|
||||
const cancelled = await ctx.db.importBatch.update({
|
||||
where: { id: input.id },
|
||||
data: { status: ImportBatchStatus.CANCELLED },
|
||||
});
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
entityType: "ImportBatch",
|
||||
entityId: input.id,
|
||||
action: "UPDATE",
|
||||
userId: ctx.dbUser?.id,
|
||||
summary: "Cancelled import batch",
|
||||
after: cancelled as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return cancelled;
|
||||
}),
|
||||
|
||||
// ── 6. listStagedResources ───────────────────────────────────────────────
|
||||
@@ -414,10 +428,25 @@ export const dispoRouter = createTRPCRouter({
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
return commitDispoImportBatch(ctx.db, {
|
||||
const result = await commitDispoImportBatch(ctx.db, {
|
||||
importBatchId: input.importBatchId,
|
||||
...(input.allowTbdUnresolved !== undefined ? { allowTbdUnresolved: input.allowTbdUnresolved } : {}),
|
||||
...(input.importTbdProjects !== undefined ? { importTbdProjects: input.importTbdProjects } : {}),
|
||||
});
|
||||
|
||||
const counts = result as unknown as Record<string, unknown>;
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
entityType: "ImportBatch",
|
||||
entityId: input.importBatchId,
|
||||
entityName: input.importBatchId,
|
||||
action: "IMPORT",
|
||||
userId: ctx.dbUser?.id,
|
||||
summary: `Committed import batch (${JSON.stringify(counts)})`,
|
||||
after: counts,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return result;
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user