feat(core-audit): NoopAuditLog impl
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
packages/core-audit/src/noop-audit-log.test.ts
Normal file
29
packages/core-audit/src/noop-audit-log.test.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { NoopAuditLog } from "./noop-audit-log";
|
||||||
|
import type { AuditEntry } from "@repo/core-shared/audit";
|
||||||
|
|
||||||
|
describe("NoopAuditLog", () => {
|
||||||
|
const sample: AuditEntry = {
|
||||||
|
actorId: "user_1",
|
||||||
|
actorType: "user",
|
||||||
|
actorRoles: [],
|
||||||
|
action: "VIEW",
|
||||||
|
resource: { type: "articles", id: "1" },
|
||||||
|
at: new Date(),
|
||||||
|
scope: { feature: "blog", environment: "test", tenant: "default" },
|
||||||
|
from: { ipTruncated: "10.0.0.0", userAgent: "test" },
|
||||||
|
containsPii: false,
|
||||||
|
outcome: "success",
|
||||||
|
};
|
||||||
|
|
||||||
|
it("record() is a no-op that does not throw", async () => {
|
||||||
|
const log = new NoopAuditLog();
|
||||||
|
await expect(log.record(sample)).resolves.toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("eraseSubject() is a no-op that does not throw", async () => {
|
||||||
|
const log = new NoopAuditLog();
|
||||||
|
await expect(log.eraseSubject("user_1", "pseudonymize")).resolves.toBeUndefined();
|
||||||
|
await expect(log.eraseSubject("user_1", "delete")).resolves.toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
11
packages/core-audit/src/noop-audit-log.ts
Normal file
11
packages/core-audit/src/noop-audit-log.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { AuditEntry } from "@repo/core-shared/audit";
|
||||||
|
import type { IAuditLog } from "./audit-log.interface";
|
||||||
|
|
||||||
|
export class NoopAuditLog implements IAuditLog {
|
||||||
|
async record(_entry: AuditEntry): Promise<void> {
|
||||||
|
// intentional no-op
|
||||||
|
}
|
||||||
|
async eraseSubject(_actorId: string, _mode: "pseudonymize" | "delete"): Promise<void> {
|
||||||
|
// intentional no-op
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user