feat : copy buzzy audit logs
CI / Verify (push) Successful in 2m2s
CI / Build immutable images and deploy (push) Successful in 2m47s

This commit is contained in:
2026-09-27 17:00:25 +07:00 Unverified
parent 8ddb5896b6
commit 188cec9bda
10 changed files with 152 additions and 353 deletions
+8 -2
View File
@@ -44,6 +44,7 @@ import {
writeAuditLog,
type AuditAction,
type AuditActor,
type AuditMetadata,
} from "@/lib/audit-log";
const DEFAULT_SECTIONS = [
@@ -77,6 +78,7 @@ async function auditGuide(
action: AuditAction,
guide: { id: string; name: string; characterKey: string; version: number },
scope?: AdminEditorScope,
metadata: AuditMetadata = {},
) {
await writeAuditLog(tx, context.actor, {
action,
@@ -88,6 +90,7 @@ async function auditGuide(
guideName: guide.name,
characterKey: guide.characterKey,
...(context.overwrite ? { overwrite: true } : {}),
...metadata,
},
});
}
@@ -484,7 +487,8 @@ export async function reorderExtraSections(
const existing = await tx
.select({ id: guideSections.id })
.from(guideSections)
.where(and(eq(guideSections.guideId, guideId), eq(guideSections.kind, "extra")));
.where(and(eq(guideSections.guideId, guideId), eq(guideSections.kind, "extra")))
.orderBy(asc(guideSections.sortOrder));
const existingIds = new Set(existing.map((section) => section.id));
if (
existingIds.size !== data.sectionIds.length ||
@@ -500,7 +504,9 @@ export async function reorderExtraSections(
.set({ sortOrder: 4 + index })
.where(eq(guideSections.id, sectionId));
}
await auditGuide(tx, context, "guide.extra.reordered", updated, "extras:list");
await auditGuide(tx, context, "guide.extra.reordered", updated, "extras:list", {
sectionIds: data.sectionIds,
});
return updated;
});
}