Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/services/id-generation

lib/services/id-generation

Provides a service for generating unique identifiers for events.

This service is responsible for creating consistent and unique IDs for event records based on a dataset’s configured ID strategy. It supports several strategies:

  • external: Uses a unique ID provided in the source data.
  • computed: Generates a hash from a specified set of fields in the data.
  • auto: Generates a unique ID and a content hash for duplicate detection.
  • hybrid: Attempts to use an external ID first and falls back to a computed ID.

The service includes helpers for extracting values from nested objects and sanitizing IDs.

Classes

IdGenerationService

Constructors

Constructor

new IdGenerationService(): IdGenerationService

Returns

IdGenerationService

Methods

generateEventId()

static generateEventId(data, dataset): object

Parameters
data

unknown

dataset

Dataset

Returns

object

uniqueId

uniqueId: string

sourceId?

optional sourceId: string

contentHash?

optional contentHash: string

strategy

strategy: string

error?

optional error: string

Functions

generateUniqueId()

generateUniqueId(data, idStrategy): string

Parameters

data

unknown

idStrategy

undefined |

{ type: "external" | "computed" | "auto" | "hybrid"; externalIdPath?: null | string; computedIdFields?: null | object[]; duplicateStrategy?: null | "skip" | "update" | "version"; }

type

"external" | "computed" | "auto" | "hybrid"

How to generate unique IDs for events

externalIdPath?

null | string

JSON path to ID field (e.g., ‘id’ or ‘metadata.uuid’)

computedIdFields?

null | object[]

Fields to combine for unique hash

duplicateStrategy?

null | "skip" | "update" | "version"

What to do when duplicate is found

Returns

string

Last updated on