Skip to main content

@idpass/data-collect-core / EventStore

Interface: EventStore

Defined in: interfaces/types.ts:289

Event store interface for managing form submissions and audit logs.

Provides event sourcing capabilities with Merkle tree integrity verification. All changes to entities flow through this store as immutable events.

Methods

initialize()

initialize(): Promise<void>

Defined in: interfaces/types.ts:291

Initialize the event store (create tables, indexes, etc.)

Returns

Promise<void>


saveEvent()

saveEvent(form): Promise<string>

Defined in: interfaces/types.ts:293

Save a single event and return its ID

Parameters

form

FormSubmission

Returns

Promise<string>


getEvents()

getEvents(): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:295

Get events with optional filtering

Returns

Promise<FormSubmission[]>


getAllEvents()

getAllEvents(): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:297

Get all events in the store

Returns

Promise<FormSubmission[]>


getLatestHash()

getLatestHash(): string

Defined in: interfaces/types.ts:299

Get the latest hash in the hash chain for integrity verification

Returns

string


verifyHashChain()

verifyHashChain(): Promise<boolean>

Defined in: interfaces/types.ts:301

Verify the integrity of the entire event hash chain

Returns

Promise<boolean>


logAuditEntry()

logAuditEntry(entry): Promise<void>

Defined in: interfaces/types.ts:303

Log a single audit entry

Parameters

entry

AuditLogEntry

Returns

Promise<void>


saveAuditLogs()

saveAuditLogs(entries): Promise<void>

Defined in: interfaces/types.ts:305

Save multiple audit log entries

Parameters

entries

AuditLogEntry[]

Returns

Promise<void>


updateEventSyncLevel()

updateEventSyncLevel(id, syncLevel): Promise<void>

Defined in: interfaces/types.ts:307

Update the sync level of an event

Parameters

id

string

syncLevel

SyncLevel

Returns

Promise<void>


updateAuditLogSyncLevel()

updateAuditLogSyncLevel(id, syncLevel): Promise<void>

Defined in: interfaces/types.ts:309

Update the sync level of an audit log entry

Parameters

id

string

syncLevel

SyncLevel

Returns

Promise<void>


getAuditLogsSince()

getAuditLogsSince(timestamp): Promise<AuditLogEntry[]>

Defined in: interfaces/types.ts:311

Get audit logs created since a specific timestamp

Parameters

timestamp

string

Returns

Promise<AuditLogEntry[]>


getEventsSince()

getEventsSince(timestamp): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:313

Get events created since a specific timestamp

Parameters

timestamp

string | Date

Returns

Promise<FormSubmission[]>


getEventsSincePagination()

getEventsSincePagination(timestamp, limit): Promise<{ events: FormSubmission[]; nextCursor: string | Date | null; }>

Defined in: interfaces/types.ts:315

Get events since timestamp with pagination support (10 events/page default)

Parameters

timestamp

string | Date

limit

number

Returns

Promise<{ events: FormSubmission[]; nextCursor: string | Date | null; }>


updateSyncLevelFromEvents()

updateSyncLevelFromEvents(events): Promise<void>

Defined in: interfaces/types.ts:323

Update sync levels for multiple events

Parameters

events

FormSubmission[]

Returns

Promise<void>


getLastRemoteSyncTimestamp()

getLastRemoteSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:325

Get the timestamp of the last remote sync

Returns

Promise<string>


setLastRemoteSyncTimestamp()

setLastRemoteSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:327

Set the timestamp of the last remote sync

Parameters

timestamp

string

Returns

Promise<void>


getLastLocalSyncTimestamp()

getLastLocalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:329

Get the timestamp of the last local sync

Returns

Promise<string>


setLastLocalSyncTimestamp()

setLastLocalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:331

Set the timestamp of the last local sync

Parameters

timestamp

string

Returns

Promise<void>


getLastPullExternalSyncTimestamp()

getLastPullExternalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:333

Get the timestamp of the last external sync pull

Returns

Promise<string>


setLastPullExternalSyncTimestamp()

setLastPullExternalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:335

Set the timestamp of the last external sync pull

Parameters

timestamp

string

Returns

Promise<void>


getLastPushExternalSyncTimestamp()

getLastPushExternalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:337

Get the timestamp of the last external sync push

Returns

Promise<string>


setLastPushExternalSyncTimestamp()

setLastPushExternalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:339

Set the timestamp of the last external sync push

Parameters

timestamp

string

Returns

Promise<void>


getLastScopeHash()

getLastScopeHash(): Promise<string | null>

Defined in: interfaces/types.ts:341

Get the last advertised scope hash from the server, or null if never seen.

Returns

Promise<string | null>


setLastScopeHash()

setLastScopeHash(hash): Promise<void>

Defined in: interfaces/types.ts:343

Persist the latest scope hash (called after a successful pull).

Parameters

hash

string

Returns

Promise<void>


getLastScope()

getLastScope(): Promise<EffectiveScopeBody | null>

Defined in: interfaces/types.ts:348

Get the last persisted effective scope body (areaIds/entityTypes/timeWindow + hash), or null if no body has been observed yet. Client-only.

Returns

Promise<EffectiveScopeBody | null>


setLastScope()

setLastScope(scope): Promise<void>

Defined in: interfaces/types.ts:353

Persist the effective scope body advertised by the server (called after a successful pull alongside setLastScopeHash). Client-only.

Parameters

scope

EffectiveScopeBody

Returns

Promise<void>


deleteEventsForEntity()

deleteEventsForEntity(entityGuid): Promise<number>

Defined in: interfaces/types.ts:359

Delete all events whose entityGuid matches the given guid. Used during client-side scope-purge — see EventStorageAdapter.deleteEventsForEntity. Returns the number of events deleted.

Parameters

entityGuid

string

Returns

Promise<number>


isEventExisted()

isEventExisted(guid): Promise<boolean>

Defined in: interfaces/types.ts:361

Check if an event with the given GUID exists

Parameters

guid

string

Returns

Promise<boolean>


getAuditTrailByEntityGuid()

getAuditTrailByEntityGuid(entityGuid): Promise<AuditLogEntry[]>

Defined in: interfaces/types.ts:363

Get complete audit trail for a specific entity

Parameters

entityGuid

string

Returns

Promise<AuditLogEntry[]>


clearStore()

clearStore(): Promise<void>

Defined in: interfaces/types.ts:365

Clear all data from the store (for testing)

Returns

Promise<void>


closeConnection()

closeConnection(): Promise<void>

Defined in: interfaces/types.ts:367

Close database connections and cleanup resources

Returns

Promise<void>


getMetadataValue()

getMetadataValue(key): Promise<string | null>

Defined in: interfaces/types.ts:373

Generic key-value metadata accessor scoped to this adapter's tenant. Stored alongside scope-hash / push-watermark metadata in the same backing store. Returns null when the key is absent.

Parameters

key

string

Returns

Promise<string | null>


setMetadataValue()

setMetadataValue(key, value): Promise<void>

Defined in: interfaces/types.ts:375

Persist a metadata value under key. Upsert semantics.

Parameters

key

string

value

string

Returns

Promise<void>


deleteMetadataValue()

deleteMetadataValue(key): Promise<void>

Defined in: interfaces/types.ts:377

Delete the metadata row for key. No-op if absent.

Parameters

key

string

Returns

Promise<void>


listMetadataKeys()

listMetadataKeys(prefix): Promise<string[]>

Defined in: interfaces/types.ts:382

List metadata keys whose name starts with prefix (tenant-scoped). Used for namespaced scans (e.g. cr: change-request records).

Parameters

prefix

string

Returns

Promise<string[]>