Skip to main content

@idpass/data-collect-core / DuplicateDetectionService

Class: DuplicateDetectionService

Defined in: services/DuplicateDetectionService.ts:55

Constructors​

Constructor​

new DuplicateDetectionService(entityStore, eventStore): DuplicateDetectionService

Defined in: services/DuplicateDetectionService.ts:65

Creates a new DuplicateDetectionService.

Parameters​

entityStore​

EntityStore

Store for managing current entity state.

eventStore​

EventStore

Store for logging audit entries.

Returns​

DuplicateDetectionService

Accessors​

queueLength​

Get Signature​

get queueLength(): number

Defined in: services/DuplicateDetectionService.ts:92

Returns the number of items currently waiting in the queue.

Primarily used for testing and monitoring.

Returns​

number

Methods​

enqueue()​

enqueue(entityGuid, eventGuid): void

Defined in: services/DuplicateDetectionService.ts:79

Enqueues an entity for asynchronous duplicate detection.

Returns immediately. The actual duplicate scan runs in the background via setTimeout so the caller is never blocked.

Parameters​

entityGuid​

string

GUID of the entity to check for duplicates.

eventGuid​

string

GUID of the event that created or updated the entity.

Returns​

void


flush()​

flush(): Promise<void>

Defined in: services/DuplicateDetectionService.ts:102

Waits for all currently queued items to finish processing.

Primarily intended for testing, so callers can assert on the results of duplicate detection after enqueuing items.

Returns​

Promise<void>


checkForDuplicates()​

checkForDuplicates(entityGuid, eventGuid): Promise<void>

Defined in: services/DuplicateDetectionService.ts:159

Performs the duplicate scan for a single entity.

Searches the entity store for other entities sharing the same searchable field values. When a match is found (excluding the entity itself), the pair is saved to potentialDuplicates and an audit entry is logged.

Parameters​

entityGuid​

string

GUID of the entity to check.

eventGuid​

string

GUID of the triggering event, used in the audit log.

Returns​

Promise<void>