Skip to content

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 ​

PrismaAuditClient

options? ​

PrismaAuditStoreOptions = {}

Returns ​

PrismaAuditStore

Methods ​

append() ​

> append(entry): Promise<void>

Defined in: audit-prisma/src/index.ts:160

Parameters ​

entry ​

AuditEntry

Returns ​

Promise<void>

Implementation of ​

AuditStore.append


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 ​

AuditStore.auditTenants


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 ​

AuditStore.chainHead


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 ​

AuditStore.chainTenants


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 ​

AuditStore.countUnchained


query() ​

> query(query): Promise<AuditEntry[]>

Defined in: audit-prisma/src/index.ts:265

Parameters ​

query ​

AuditQuery

Returns ​

Promise<AuditEntry[]>

Implementation of ​

AuditStore.query


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 ​

AuditChainRange

Returns ​

Promise&lt;AuditEntry[]&gt;

Implementation of ​

AuditStore.readChain


readUnchained() ​

> readUnchained(tenantId, range): Promise&lt;AuditEntry[]&gt;

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 ​

AuditUnchainedRange

Returns ​

Promise&lt;AuditEntry[]&gt;

Implementation of ​

AuditStore.readUnchained

Released under the MIT License.