basalt / audit-prisma/src / PrismaAuditStore
Class: PrismaAuditStore
Defined in: audit-prisma/src/index.ts:150
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 PrismaAuditStore(client, options?): PrismaAuditStore
Defined in: audit-prisma/src/index.ts:153
Parameters
client
options?
Returns
PrismaAuditStore
Methods
append()
> append(entry): Promise<void>
Defined in: audit-prisma/src/index.ts:160
Parameters
entry
Returns
Promise<void>
Implementation of
auditTenants()
> auditTenants(): Promise<(string | undefined)[]>
Defined in: audit-prisma/src/index.ts:260
Every tenant with at least one row, chained or not (undefined = rows without a tenant) — a SELECT DISTINCT "tenantId" (served by the [tenantId, at] 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-prisma/src/index.ts:194
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-prisma/src/index.ts:245
Tenants that have a chain (undefined = the system chain).
Returns
Promise<(string | undefined)[]>
Implementation of
countUnchained()
> countUnchained(tenantId): Promise<number>
Defined in: audit-prisma/src/index.ts:215
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-prisma/src/index.ts:265
Parameters
query
Returns
Promise<AuditEntry[]>
Implementation of
readChain()
> readChain(tenantId, range): Promise<AuditEntry[]>
Defined in: audit-prisma/src/index.ts:203
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-prisma/src/index.ts:228
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. Spelled with OR rather than NOT: SQL NOT (chain = x AND …) is NULL, not true, for a NULL chain, and would hide exactly the rows sought.
Parameters
tenantId
string | undefined
range
Returns
Promise<AuditEntry[]>