basalt / audit-sqlite/src / SqliteAuditStore
Class: SqliteAuditStore
Defined in: audit-sqlite/src/index.ts:114
Append-only by contract: no update, no delete.
The chain methods are optional — a store without them works exactly as before, but cannot back integrity: 'hash-chain'. A store that implements them MUST also reject an append whose (auditChainKey(tenantId), seq) already exists with AuditChainConflictError (a unique constraint in SQL): that is what keeps concurrent writers on several replicas from forking a chain.
Implements
Constructors
Constructor
> new SqliteAuditStore(db): SqliteAuditStore
Defined in: audit-sqlite/src/index.ts:115
Parameters
db
DatabaseSync
Returns
SqliteAuditStore
Methods
append()
> append(entry): Promise<void>
Defined in: audit-sqlite/src/index.ts:117
Parameters
entry
Returns
Promise<void>
Implementation of
auditTenants()
> auditTenants(): Promise<(string | undefined)[]>
Defined in: audit-sqlite/src/index.ts:205
Every tenant with at least one row, chained or not (undefined = rows without a tenant) — one SELECT DISTINCT over the tenant index, so verifyAll() reaches chainless tenants without reading the whole trail.
Returns
Promise<(string | undefined)[]>
Implementation of
chainHead()
> chainHead(tenantId): Promise<AuditChainHead | undefined>
Defined in: audit-sqlite/src/index.ts:147
Latest chained entry of the tenant's chain (undefined tenant = system chain).
Parameters
tenantId
string | undefined
Returns
Promise<AuditChainHead | undefined>
Implementation of
chainTenants()
> chainTenants(): Promise<(string | undefined)[]>
Defined in: audit-sqlite/src/index.ts:193
Tenants that have a chain (undefined = the system chain).
Returns
Promise<(string | undefined)[]>
Implementation of
countUnchained()
> countUnchained(tenantId): Promise<number>
Defined in: audit-sqlite/src/index.ts:166
Rows of the tenant (undefined = no tenant) written without a chain (before integrity was on).
Parameters
tenantId
string | undefined
Returns
Promise<number>
Implementation of
query()
> query(query): Promise<AuditEntry[]>
Defined in: audit-sqlite/src/index.ts:212
Parameters
query
Returns
Promise<AuditEntry[]>
Implementation of
readChain()
> readChain(tenantId, range): Promise<AuditEntry[]>
Defined in: audit-sqlite/src/index.ts:154
Chained entries of one chain with fromSeq <= seq <= toSeq, ascending, at most limit.
Parameters
tenantId
string | undefined
range
Returns
Promise<AuditEntry[]>
Implementation of
readUnchained()
> readUnchained(tenantId, range): Promise<AuditEntry[]>
Defined in: audit-sqlite/src/index.ts:178
Rows of the tenant outside its chain: no seq, a seq below 1, or a chain other than the tenant's (NULL or a forged name). Those claiming a chain position are returned whatever their at — a legacy row has neither.
Parameters
tenantId
string | undefined
range
Returns
Promise<AuditEntry[]>