@hexmon_tech/audit-export-postgres
v2.0.0
Published
Export helpers for audit logs stored in Postgres.
Maintainers
Readme
@hexmon_tech/audit-export-postgres
Helpers to export audit logs from Postgres with safe, paginated queries.
Install
pnpm add @hexmon_tech/audit-export-postgres
npm install @hexmon_tech/audit-export-postgresCompatibility
- Node.js >= 18
- Postgres 15+ (includes
migrations/*.sqlfor the canonical audit table)
Usage
import { exportAuditLogs } from '@hexmon_tech/audit-export-postgres';
const result = await exportAuditLogs({
connectionString: process.env.DATABASE_URL,
from: '2024-01-01',
to: '2024-01-31',
tenantId: 'tenant-123',
format: 'json',
pageSize: 1000,
});
if (result.ok) {
console.log(result.data);
console.log('next cursor', result.nextCursor);
}Options
from/to: required time range (ISO or Postgres-compatible timestamps)tenantId: optional filter; required whenmultiTenantStrictis enabledactorId,action,outcome: optional filtersformat:jsonorcsvpageSize: default 1000 (max 10,000)cursor: continue after a previous export page
Notes
- Queries are keyset-paginated by
(occurred_at, event_id). multiTenantStricthelps prevent accidental cross-tenant export.
