auth/audit_log_queries.ts view source
(): number Number of audit metadata validation failures observed since process start.
returns
number Audit log database queries.
Records and retrieves auth mutation events for security monitoring. The
canonical fire-and-forget entry point is AppDeps.audit.emit(ctx, input)
(see auth/audit_emitter.ts) — it closes over the pool so audit rows
persist even when the request transaction rolls back. This module only
exposes the in-transaction query_* primitives and the drift counters;
the bound emitter writes through query_audit_log against its captured
pool.
9 declarations
auth/audit_log_queries.ts view source
(): number Number of audit metadata validation failures observed since process start.
number auth/audit_log_queries.ts view source
(): number Number of audit unknown-event-type failures observed since process start.
number auth/audit_log_queries.ts view source
<T extends string>(deps: QueryDeps, input: AuditLogInput<T>, config?: AuditLogConfig): Promise<AuditLogEvent> Insert an audit log entry.
RETURNING * so callers receive DB-assigned fields (id, seq,
created_at). Validates metadata against config.metadata_schemas;
unknown event_type and metadata mismatches log + bump their counters
but write the row anyway. Consumers extend the recognized set via
create_audit_log_config({extra_events}).
In-transaction call site for query helpers that must atomically write the
row alongside other mutations (e.g. query_accept_offer). Fire-and-forget
call sites should reach for AppDeps.audit.emit instead — that wrapper
closes over the pool so audit rows persist when the parent transaction
rolls back.
depsquery dependencies
inputthe audit event to record
AuditLogInput<T>configaudit-log config. Defaults to BUILTIN_AUDIT_LOG_CONFIG.
BUILTIN_AUDIT_LOG_CONFIGPromise<AuditLogEvent> the inserted audit log row
auth/audit_log_queries.ts view source
(deps: QueryDeps, before: Date): Promise<number> Delete audit log entries older than the given date.
depsquery dependencies
beforedelete entries created before this date
DatePromise<number> the number of entries deleted
auth/audit_log_queries.ts view source
(deps: QueryDeps, options?: AuditLogListOptions | undefined): Promise<AuditLogEvent[]> List audit log entries, newest first.
depsquery dependencies
options?filters and pagination
AuditLogListOptions | undefinedPromise<AuditLogEvent[]> matching audit log entries
auth/audit_log_queries.ts view source
(deps: QueryDeps, limit?: number, offset?: number): Promise<{ id: string & $brand<"Uuid">; seq: number; event_type: string; outcome: "success" | "failure"; actor_id: (string & $brand<...>) | null; ... 7 more ...; target_username: string | null; }[]> List role_grant grant/revoke events with resolved usernames.
depsquery dependencies
limitmaximum entries to return
numberAUDIT_LOG_DEFAULT_LIMIToffsetnumber of entries to skip
number0Promise<{ id: string & $brand<"Uuid">; seq: number; event_type: string; outcome: "success" | "failure"; actor_id: (string & $brand<"Uuid">) | null; account_id: (string & $brand<...>) | null; ... 6 more ...; target_username: string | null; }[]> role_grant history events with username and target_username
auth/audit_log_queries.ts view source
(deps: QueryDeps, options?: AuditLogListOptions | undefined): Promise<{ id: string & $brand<"Uuid">; seq: number; event_type: string; outcome: "success" | "failure"; ... 8 more ...; target_username: string | null; }[]> List audit log entries with resolved usernames, newest first.
depsquery dependencies
options?filters and pagination
AuditLogListOptions | undefinedPromise<{ id: string & $brand<"Uuid">; seq: number; event_type: string; outcome: "success" | "failure"; actor_id: (string & $brand<"Uuid">) | null; account_id: (string & $brand<...>) | null; ... 6 more ...; target_username: string | null; }[]> matching audit log entries with username and target_username
auth/audit_log_queries.ts view source
(): void Reset the counter — for tests only.
void auth/audit_log_queries.ts view source
(): void Reset the counter — for tests only.
void