Skip to main content

@idpass/data-collect-core / ConflictService

Class: ConflictService

Defined in: services/ConflictService.ts:89

Service for detecting and managing entity conflicts during synchronization.

Provides conflict recording, retrieval, and resolution capabilities. Uses a pluggable ConflictStore for persistence.

Constructors

Constructor

new ConflictService(store): ConflictService

Defined in: services/ConflictService.ts:90

Parameters

store

ConflictStore

Returns

ConflictService

Methods

recordConflict()

recordConflict(params): Promise<string>

Defined in: services/ConflictService.ts:96

Record a detected conflict.

Parameters

params

RecordConflictParams

Returns

Promise<string>

The GUID of the created conflict record


getUnresolvedConflicts()

getUnresolvedConflicts(tenantId): Promise<ConflictRecord[]>

Defined in: services/ConflictService.ts:124

Get all unresolved conflicts for a tenant.

Parameters

tenantId

string

Returns

Promise<ConflictRecord[]>


getConflict()

getConflict(guid): Promise<ConflictRecord | null>

Defined in: services/ConflictService.ts:131

Get a specific conflict by GUID.

Parameters

guid

string

Returns

Promise<ConflictRecord | null>


resolveConflict()

resolveConflict(guid, resolution, resolvedBy, mergedData?): Promise<void>

Defined in: services/ConflictService.ts:143

Resolve a conflict with the given strategy.

Parameters

guid

string

The conflict GUID to resolve

resolution

The resolution strategy: 'local', 'remote', or 'merged'

"local" | "remote" | "merged"

resolvedBy

string

The user who resolved the conflict

mergedData?

Record<string, unknown>

The merged data (required when resolution is 'merged')

Returns

Promise<void>


getConflictCount()

getConflictCount(tenantId): Promise<number>

Defined in: services/ConflictService.ts:178

Get the count of unresolved conflicts for a tenant.

Parameters

tenantId

string

Returns

Promise<number>


detectConflict()

detectConflict(localData, remoteData): boolean

Defined in: services/ConflictService.ts:187

Detect whether two data objects are in conflict (differ from each other).

Performs a deep comparison of the two objects. Returns true if any values differ.

Parameters

localData

Record<string, unknown>

remoteData

Record<string, unknown>

Returns

boolean