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:
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { adminProcedure, createTRPCRouter, invalidateRoleDefaultsCache, protectedProcedure } from "../trpc.js";
|
||||
import { createAuditEntry } from "../lib/audit.js";
|
||||
|
||||
export const systemRoleConfigRouter = createTRPCRouter({
|
||||
/** List all role configs (sorted by sortOrder) */
|
||||
@@ -21,6 +22,10 @@ export const systemRoleConfigRouter = createTRPCRouter({
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const existing = await ctx.db.systemRoleConfig.findUnique({
|
||||
where: { role: input.role as never },
|
||||
});
|
||||
|
||||
const data: Record<string, unknown> = {};
|
||||
if (input.label !== undefined) data.label = input.label;
|
||||
if (input.description !== undefined) data.description = input.description;
|
||||
@@ -35,6 +40,18 @@ export const systemRoleConfigRouter = createTRPCRouter({
|
||||
// Invalidate cached role defaults so changes take effect immediately
|
||||
invalidateRoleDefaultsCache();
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
entityType: "SystemRoleConfig",
|
||||
entityId: input.role,
|
||||
entityName: result.label,
|
||||
action: "UPDATE",
|
||||
userId: ctx.dbUser?.id,
|
||||
before: (existing ?? {}) as unknown as Record<string, unknown>,
|
||||
after: result as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return result;
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user