Record, query, and export tenant audit events. Bearer required.
import { GatekeeperCore, AuditService } from '@orkait/sdk';
const audit = new AuditService(core, { defaultFormat: 'ndjson' });Config#
| Option | Default | Effect |
|---|---|---|
defaultFormat | 'ndjson' | format used by export when none is passed (ndjson | csv) |
Methods#
| Method | Returns | Notes |
|---|---|---|
record(input) | void | RecordAuditEventInput |
query(tenantId, filters?) | Page<AuditEvent> | { actorId?, actionPrefix?, startTimestamp?, endTimestamp?, cursor?, limit? } |
export(tenantId, format?) | string | raw body; format falls back to defaultFormat |
Example#
await audit.record({
tenantId: 't1', actorId: 'usr_1', actorType: 'user',
action: 'login', resourceType: 'session', resourceId: 's1',
});
const events = await audit.query('t1', { actionPrefix: 'login', limit: 50 });
const csv = await audit.export('t1', 'csv');