Skip to main content

@idpass/data-collect-core / InternalSyncManager

Class: InternalSyncManager

Defined in: components/InternalSyncManager.ts:41

Manages bidirectional synchronization between local DataCollect instances and the remote sync server.

Thin wrapper around an XState actor that implements the sync statechart. The public API is preserved: sync(), isSyncing, setSelectiveSyncOptions(), hasUnsyncedEvents().

Constructors​

Constructor​

new InternalSyncManager(eventStore, entityStore, eventApplierService, syncServerUrl, authStorage, configId?, reauthenticate?, deviceId?, purgeOutOfScope?): InternalSyncManager

Defined in: components/InternalSyncManager.ts:68

Parameters​

eventStore​

EventStore

entityStore​

EntityStore

eventApplierService​

EventApplierService

syncServerUrl​

string

authStorage​

AuthStorageAdapter

configId?​

string = "default"

reauthenticate?​

ReauthenticateCallback

deviceId?​

string

purgeOutOfScope?​

PurgeOutOfScopeCallback

Returns​

InternalSyncManager

Accessors​

isSyncing​

Get Signature​

get isSyncing(): boolean

Defined in: components/InternalSyncManager.ts:63

Whether a sync operation is currently running (read-only accessor).

Returns​

boolean

Methods​

setSelectiveSyncOptions()​

setSelectiveSyncOptions(options): void

Defined in: components/InternalSyncManager.ts:134

Sets selective sync options for area-based and entity-based filtering.

Parameters​

options​

SelectiveSyncOptions

Returns​

void


getSelectiveSyncOptions()​

getSelectiveSyncOptions(): SelectiveSyncOptions

Defined in: components/InternalSyncManager.ts:141

Gets the current selective sync options.

Returns​

SelectiveSyncOptions


getUnsyncedEventsCount()​

getUnsyncedEventsCount(): Promise<number>

Defined in: components/InternalSyncManager.ts:153

Gets the count of events waiting to be synchronized with the server.

Only LOCAL events count as pending. REMOTE (pulled from /pull) and EXTERNAL (pulled from external adapter) events have already been delivered to the server, so including them inflates the count during first sync.

Returns​

Promise<number>


hasUnsyncedEvents()​

hasUnsyncedEvents(): Promise<boolean>

Defined in: components/InternalSyncManager.ts:162

Checks if there are any events waiting to be synchronized.

Returns​

Promise<boolean>


checkIfDuplicatesExist()​

checkIfDuplicatesExist(): Promise<boolean>

Defined in: components/InternalSyncManager.ts:172

Checks if there are any unresolved potential duplicates.

Returns​

Promise<boolean>


sync()​

sync(options?): Promise<void>

Defined in: components/InternalSyncManager.ts:180

Performs a complete bidirectional synchronization with the remote server.

Parameters​

options?​

SelectiveSyncOptions

Returns​

Promise<void>