feat(core-shared): extend audit action enum with consent and restriction types
Adds CONSENT_GRANT, CONSENT_WITHDRAW, RESTRICT, UNRESTRICT to the AuditAction closed enum per GDPR Art. 7 and Art. 18 requirements. core-consent and core-dsr optional cores (Epic B Stories 03/06) emit these action types via core-audit's IAuditLog channel; the values must exist in core-shared's enum before either optional core can be built. No change to IAuditLog's interface surface — new values flow through AuditEntry.action automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,16 +2,28 @@ import { describe, it, expectTypeOf } from "vitest";
|
||||
import type { AuditEntry, AuditAction, AuditFrom } from "./audit-entry";
|
||||
|
||||
describe("AuditAction", () => {
|
||||
it("is a closed enum of 6 values", () => {
|
||||
it("is a closed enum of 10 values", () => {
|
||||
expectTypeOf<AuditAction>().toEqualTypeOf<
|
||||
"VIEW" | "CREATE" | "UPDATE" | "DELETE" | "EXPORT" | "PERMISSION_CHANGE"
|
||||
| "VIEW"
|
||||
| "CREATE"
|
||||
| "UPDATE"
|
||||
| "DELETE"
|
||||
| "EXPORT"
|
||||
| "PERMISSION_CHANGE"
|
||||
| "CONSENT_GRANT"
|
||||
| "CONSENT_WITHDRAW"
|
||||
| "RESTRICT"
|
||||
| "UNRESTRICT"
|
||||
>();
|
||||
});
|
||||
});
|
||||
|
||||
describe("AuditFrom", () => {
|
||||
it("requires ipTruncated and userAgent", () => {
|
||||
expectTypeOf<AuditFrom>().toEqualTypeOf<{ ipTruncated: string; userAgent: string }>();
|
||||
expectTypeOf<AuditFrom>().toEqualTypeOf<{
|
||||
ipTruncated: string;
|
||||
userAgent: string;
|
||||
}>();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,7 +46,15 @@ describe("AuditEntry", () => {
|
||||
|
||||
it("makes optional fields actually optional", () => {
|
||||
type Entry = AuditEntry;
|
||||
type OptionalKeys = "changedFields" | "reason" | "correlationId" | "requestId" | "piiCategories" | "errorCode";
|
||||
expectTypeOf<Pick<Entry, OptionalKeys>>().toEqualTypeOf<Partial<Pick<Entry, OptionalKeys>>>();
|
||||
type OptionalKeys =
|
||||
| "changedFields"
|
||||
| "reason"
|
||||
| "correlationId"
|
||||
| "requestId"
|
||||
| "piiCategories"
|
||||
| "errorCode";
|
||||
expectTypeOf<Pick<Entry, OptionalKeys>>().toEqualTypeOf<
|
||||
Partial<Pick<Entry, OptionalKeys>>
|
||||
>();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,11 @@ export type AuditAction =
|
||||
| "UPDATE"
|
||||
| "DELETE"
|
||||
| "EXPORT"
|
||||
| "PERMISSION_CHANGE";
|
||||
| "PERMISSION_CHANGE"
|
||||
| "CONSENT_GRANT"
|
||||
| "CONSENT_WITHDRAW"
|
||||
| "RESTRICT"
|
||||
| "UNRESTRICT";
|
||||
|
||||
/**
|
||||
* `from_where` fragment per DPA. IP truncated to /24 (IPv4) or /48 (IPv6)
|
||||
|
||||
Reference in New Issue
Block a user