Skip to main content

@idpass/data-collect-core / EventStore

Interface: EventStore

Defined in: interfaces/types.ts:287

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:289

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

Returns

Promise<void>


saveEvent()

saveEvent(form): Promise<string>

Defined in: interfaces/types.ts:291

Save a single event and return its ID

Parameters

form

FormSubmission

Returns

Promise<string>


getEvents()

getEvents(): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:293

Get events with optional filtering

Returns

Promise<FormSubmission[]>


getAllEvents()

getAllEvents(): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:295

Get all events in the store

Returns

Promise<FormSubmission[]>


getLatestHash()

getLatestHash(): string

Defined in: interfaces/types.ts:297

Get the latest hash in the hash chain for integrity verification

Returns

string


verifyHashChain()

verifyHashChain(): Promise<boolean>

Defined in: interfaces/types.ts:299

Verify the integrity of the entire event hash chain

Returns

Promise<boolean>


logAuditEntry()

logAuditEntry(entry): Promise<void>

Defined in: interfaces/types.ts:301

Log a single audit entry

Parameters

entry

AuditLogEntry

Returns

Promise<void>


saveAuditLogs()

saveAuditLogs(entries): Promise<void>

Defined in: interfaces/types.ts:303

Save multiple audit log entries

Parameters

entries

AuditLogEntry[]

Returns

Promise<void>


updateEventSyncLevel()

updateEventSyncLevel(id, syncLevel): Promise<void>

Defined in: interfaces/types.ts:305

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:307

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:309

Get audit logs created since a specific timestamp

Parameters

timestamp

string

Returns

Promise<AuditLogEntry[]>


getEventsSince()

getEventsSince(timestamp): Promise<FormSubmission[]>

Defined in: interfaces/types.ts:311

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:313

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:321

Update sync levels for multiple events

Parameters

events

FormSubmission[]

Returns

Promise<void>


getLastRemoteSyncTimestamp()

getLastRemoteSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:323

Get the timestamp of the last remote sync

Returns

Promise<string>


setLastRemoteSyncTimestamp()

setLastRemoteSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:325

Set the timestamp of the last remote sync

Parameters

timestamp

string

Returns

Promise<void>


getLastLocalSyncTimestamp()

getLastLocalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:327

Get the timestamp of the last local sync

Returns

Promise<string>


setLastLocalSyncTimestamp()

setLastLocalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:329

Set the timestamp of the last local sync

Parameters

timestamp

string

Returns

Promise<void>


getLastPullExternalSyncTimestamp()

getLastPullExternalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:331

Get the timestamp of the last external sync pull

Returns

Promise<string>


setLastPullExternalSyncTimestamp()

setLastPullExternalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:333

Set the timestamp of the last external sync pull

Parameters

timestamp

string

Returns

Promise<void>


getLastPushExternalSyncTimestamp()

getLastPushExternalSyncTimestamp(): Promise<string>

Defined in: interfaces/types.ts:335

Get the timestamp of the last external sync push

Returns

Promise<string>


setLastPushExternalSyncTimestamp()

setLastPushExternalSyncTimestamp(timestamp): Promise<void>

Defined in: interfaces/types.ts:337

Set the timestamp of the last external sync push

Parameters

timestamp

string

Returns

Promise<void>


isEventExisted()

isEventExisted(guid): Promise<boolean>

Defined in: interfaces/types.ts:339

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:341

Get complete audit trail for a specific entity

Parameters

entityGuid

string

Returns

Promise<AuditLogEntry[]>


clearStore()

clearStore(): Promise<void>

Defined in: interfaces/types.ts:343

Clear all data from the store (for testing)

Returns

Promise<void>


closeConnection()

closeConnection(): Promise<void>

Defined in: interfaces/types.ts:345

Close database connections and cleanup resources

Returns

Promise<void>