ReferenceModels
audit-model
Browser-safe Zod schemas and inferred types for the audit log. Persistence is in
domains/audit-domain.
API
| Export | What it is |
|---|---|
auditEventSchema / AuditEvent | A stored event: id, at (ISO), optional workspaceId, actor snapshot, action, optional target, outcome, optional changes, context. |
auditEventInputSchema / AuditEventInput | What a caller records: the same without id and at. |
AUDIT_ACTIONS, auditActionSchema | The typed union of actions (member, invite, workspace, todo and account events). |
AUDIT_OUTCOMES, auditOutcomeSchema | success, denied or failed. |
AUDIT_CHANGE_FIELDS, pickAllowedChanges(action, changes) | The per-action allow-list of changes fields, and the function that drops everything else. |
auditEventViewSchema, auditPageViewSchema | What audit.list returns: an event whose context has no ip, spanId or traceId (those stay in the database for operators). |
auditListQuerySchema, auditPageSchema | The list input (workspaceId, action?, actorId?, cursor?, limit) and its { items, nextCursor? } output. |
actor is a snapshot (type, optional id, name, email), so a row stays readable after the user is renamed or deleted.
context carries requestId, service and, when a trace is active, traceId, spanId; ip and userAgent are optional.
Adding an action means adding it to AUDIT_ACTIONS and AUDIT_CHANGE_FIELDS (the spec fails if one is missing).
Commands
pnpm nx run audit-model:typecheck # type-check the package
pnpm nx run audit-model:test # run the Vitest suite