From 12a8391944155bb74fb705b98f682d5b862b5f62 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 11 May 2026 16:11:30 +0200 Subject: [PATCH] feat(core-audit): IAuditLog interface + AUDIT_SYMBOLS Co-Authored-By: Claude Sonnet 4.6 --- .../core-audit/src/audit-log.interface.ts | 22 +++++++++++++++++++ packages/core-audit/src/di/symbols.ts | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 packages/core-audit/src/audit-log.interface.ts create mode 100644 packages/core-audit/src/di/symbols.ts diff --git a/packages/core-audit/src/audit-log.interface.ts b/packages/core-audit/src/audit-log.interface.ts new file mode 100644 index 0000000..a4b8abd --- /dev/null +++ b/packages/core-audit/src/audit-log.interface.ts @@ -0,0 +1,22 @@ +import type { AuditLogProtocol } from "@repo/core-shared/di/bind-protocols"; +import type { AuditEntry } from "@repo/core-shared/audit"; + +/** + * Full audit log interface. Extends the minimal `AuditLogProtocol` from + * core-shared with the privileged `eraseSubject` op for GDPR erasure. + * + * Feature binders that receive `ctx.auditLog` see only `AuditLogProtocol` + * (record). Admin-path code that needs erasure imports this full interface. + * + * The `extends` link forces typecheck failure if either side narrows below + * the protocol surface — same safety net as IEventBus, IRealtimeBroadcaster, + * IRealtimeHandlerRegistry, IMetrics. + */ +export interface IAuditLog extends AuditLogProtocol { + // record(entry: AuditEntry): Promise — inherited from protocol + eraseSubject(actorId: string, mode: "pseudonymize" | "delete"): Promise; +} + +// Re-export AuditEntry for convenience (so consumers don't always need +// to dual-import from @repo/core-shared/audit). +export type { AuditEntry }; diff --git a/packages/core-audit/src/di/symbols.ts b/packages/core-audit/src/di/symbols.ts new file mode 100644 index 0000000..badb48a --- /dev/null +++ b/packages/core-audit/src/di/symbols.ts @@ -0,0 +1,3 @@ +export const AUDIT_SYMBOLS = { + IAuditLog: Symbol.for("core-audit:IAuditLog"), +} as const;