Class: AuditEngine
Defined in: src/audit/AuditEngine.ts:12
Engine that builds and persists AuditLogEntry rows to the audit changelog table.
This class is used internally by DbSet — it should not be instantiated directly
by application code. All writes occur within the same transaction as the originating
mutation, guaranteeing atomicity.
Constructors
Constructor
new AuditEngine():
AuditEngine
Returns
AuditEngine
Methods
shouldLog()
staticshouldLog(target):boolean
Defined in: src/audit/AuditEngine.ts:17
Returns true if the given entity class is decorated with @Auditable
and has changelog: true.
Parameters
| Parameter | Type |
|---|---|
target | Function |
Returns
boolean
getOptions()
staticgetOptions(target):AuditOptions|undefined
Defined in: src/audit/AuditEngine.ts:25
Returns the audit options for the given entity class, or undefined.
Parameters
| Parameter | Type |
|---|---|
target | Function |
Returns
AuditOptions | undefined
buildEntry()
staticbuildEntry(operation,entityName,entityKey,newSnapshot,oldSnapshot,currentUser?,includeOld?):AuditLogEntry
Defined in: src/audit/AuditEngine.ts:33
Builds an AuditLogEntry object without persisting it.
Used to preview or buffer audit rows.
Parameters
| Parameter | Type | Default value |
|---|---|---|
operation | "UPDATE" | "INSERT" | "DELETE" | undefined |
entityName | string | undefined |
entityKey | unknown | undefined |
newSnapshot | Record<string, unknown> | undefined | undefined |
oldSnapshot | Record<string, unknown> | undefined | undefined |
currentUser? | string | undefined |
includeOld? | boolean | true |
Returns
write()
staticwrite(entry,adapter,auditTable?,transaction?):Promise<void>
Defined in: src/audit/AuditEngine.ts:70
Persists a single AuditLogEntry to the audit log table using the
provided database adapter and optional transaction.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
entry | AuditLogEntry | undefined | The audit log entry to write. |
adapter | IDbAdapter | undefined | The database adapter to execute the INSERT against. |
auditTable | string | '_audit_log' | Target table name (defaults to _audit_log). |
transaction? | DbTransaction | undefined | Optional active transaction to enlist the INSERT in. |
Returns
Promise<void>
snapshot()
staticsnapshot(entity):Record<string,unknown>
Defined in: src/audit/AuditEngine.ts:121
Takes a snapshot of an entity's own (non-relation, non-function) properties
for storage as old_values / new_values in the audit log.
Parameters
| Parameter | Type |
|---|---|
entity | any |
Returns
Record<string, unknown>