GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sdk-js/packages/epilot-sdk-v2/docs/deduplication.md at main · epilot-dev/sdk-js

Expand file tree

/

deduplication.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
1281 lines (1084 loc) · 24.5 KB
/

deduplication.md

Copy path

File metadata and controls

1281 lines (1084 loc) · 24.5 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Deduplication API

  • Base URL: https://deduplication.sls.epilot.io
  • Full API Docs: https://docs.epilot.io/api/deduplication

Usage

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.deduplication.deduplicate(...)

Tree-shakeable import

import { getClient, authorize } from '@epilot/sdk/deduplication'

const deduplicationClient = getClient()
authorize(deduplicationClient, () => '<token>')
const { data } = await deduplicationClient.deduplicate(...)

Operations

  • deduplicate
  • deduplicateAsync
  • getDeduplicationJob
  • detectDuplicates
  • resolveDuplicates
  • dismissDuplicates
  • listUniquenessCriteria
  • createUniquenessCriteria
  • getUniquenessCriteria
  • updateUniquenessCriteria
  • deleteUniquenessCriteria
  • getUniquenessCriteriaById
  • updateUniquenessCriteriaById
  • deleteUniquenessCriteriaById
  • setGlobalUniquenessCriteria
  • registerUniquenessCriteriaUsage
  • unregisterUniquenessCriteriaUsage

Schemas

  • DeduplicateRequestBody
  • DeduplicateRequestResponse
  • Entity
  • DeduplicateAsyncResponse
  • JobStatus
  • DeduplicationJob
  • DetectDuplicatesRequestBody
  • DetectDuplicatesResponse
  • DetectedDuplicateMatch
  • ResolveDuplicatesRequestBody
  • ResolutionMode
  • ResolveDuplicatesResponse
  • ResolutionCandidate
  • RuleStrength
  • DismissDuplicatesRequestBody
  • DismissDuplicatesResponse
  • UniquenessCriteriaListResponse
  • UniquenessCriteria
  • MatchRule
  • MatchAttribute
  • MatchMode
  • RuleSetUsage
  • UniquenessCriteriaCreateBody
  • RuleSetConflict
  • UniquenessCriteriaUpdateBody
  • RuleSetUsageBody

deduplicate

Deduplicates Entities

POST /v1/deduplicate

const { data } = await client.deduplicate(
  null,
  [
    {
      toKeep: 'string',
      toDelete: ['string']
    }
  ],
)
Response
{
  "deduplicatedEntities": [
    {
      "_id": "string",
      "_org": "string",
      "_schema": "string",
      "_created_at": "1970-01-01T00:00:00.000Z",
      "_updated_at": "1970-01-01T00:00:00.000Z",
      "_created_by": "string",
      "created_by": "string",
      "_tags": ["string"],
      "_acl": {},
      "_owners": [
        {
          "org_id": "string",
          "user_id": "string"
        }
      ],
      "type": "string"
    }
  ]
}

deduplicateAsync

Submits an async deduplication job. Returns a job ID immediately. Poll GET /v1/deduplicate/jobs/{jobId} for status.

POST /v1/deduplicate/job

const { data } = await client.deduplicateAsync(
  null,
  [
    {
      toKeep: 'string',
      toDelete: ['string']
    }
  ],
)

getDeduplicationJob

Returns the current status of an async deduplication job

GET /v1/deduplicate/jobs/{jobId}

const { data } = await client.getDeduplicationJob({
  jobId: 'example',
})
Response
{
  "jobId": "string",
  "status": "pending",
  "message": "string",
  "result": [
    {
      "_id": "string",
      "_org": "string",
      "_schema": "string",
      "_created_at": "1970-01-01T00:00:00.000Z",
      "_updated_at": "1970-01-01T00:00:00.000Z",
      "_created_by": "string",
      "created_by": "string",
      "_tags": ["string"],
      "_acl": {},
      "_owners": [
        {
          "org_id": "string",
          "user_id": "string"
        }
      ],
      "type": "string"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

detectDuplicates

Detects potential duplicate entities for the given entity using the schema's prioritized uniqueness rules. Returns matches with a confidence score. Used by entity-mapping-api while the self-contained

POST /v1/detect-duplicates

const { data } = await client.detectDuplicates(
  null,
  {
    schema: 'string',
    entity: {}
  },
)
Response
{
  "matches": [
    {
      "entity": {
        "_id": "string",
        "_org": "string",
        "_schema": "string",
        "_created_at": "1970-01-01T00:00:00.000Z",
        "_updated_at": "1970-01-01T00:00:00.000Z",
        "_created_by": "string",
        "created_by": "string",
        "_tags": ["string"],
        "_acl": {},
        "_owners": [
          {
            "org_id": "string",
            "user_id": "string"
          }
        ],
        "type": "string"
      },
      "confidence": 0,
      "matched_attributes": ["string"],
      "fuzzy_attributes": ["string"]
    }
  ]
}

resolveDuplicates

Answers 'is this payload an existing record, and which one?' as an action the caller executes: update that entity, create, or ask the user. The action follows from the matching rule's strength and the

POST /v1/duplicates/resolve

const { data } = await client.resolveDuplicates(
  null,
  {
    schema: 'string',
    entity: {},
    mode: 'automated',
    criteria_id: '3fa85f64-5717-4562-b3fc-2c963f66afa6'
  },
)
Response
{
  "action": "update",
  "entity": {
    "_id": "string",
    "_org": "string",
    "_schema": "string",
    "_created_at": "1970-01-01T00:00:00.000Z",
    "_updated_at": "1970-01-01T00:00:00.000Z",
    "_created_by": "string",
    "created_by": "string",
    "_tags": ["string"],
    "_acl": {},
    "_owners": [
      {
        "org_id": "string",
        "user_id": "string"
      }
    ],
    "type": "string"
  },
  "rule_name": "string",
  "matched_attributes": ["string"]
}

dismissDuplicates

Confirms entities as NOT duplicates. Every pair among them is remembered as dismissed, so no later flagging pass raises it again, and the entries they hold about each other are removed from their dupl

POST /v1/duplicates/dismiss

const { data } = await client.dismissDuplicates(
  null,
  {
    schema: 'string',
    entityIds: ['string']
  },
)
Response
{
  "dismissed": ["string"]
}

listUniquenessCriteria

Lists the rule sets of the requesting organization, optionally one schema's, each with its usages.

GET /v1/uniqueness-criteria

const { data } = await client.listUniquenessCriteria({
  schema: 'example',
})
Response
{
  "items": [
    {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "orgId": "string",
      "schema": "string",
      "name": "string",
      "global": true,
      "matchRules": [
        {
          "name": "string",
          "attributes": [
            {
              "attribute": "string",
              "match": "exact"
            }
          ],
          "strength": "certain",
          "confidence": 0
        }
      ],
      "usages": [
        {
          "consumer": "string",
          "ref": "string",
          "label": "string",
          "registeredAt": "1970-01-01T00:00:00.000Z"
        }
      ],
      "createdAt": "1970-01-01T00:00:00.000Z",
      "updatedAt": "1970-01-01T00:00:00.000Z"
    }
  ]
}

createUniquenessCriteria

Creates a rule set. The first set of a schema becomes its global set unless 'global' is false.

POST /v1/uniqueness-criteria

const { data } = await client.createUniquenessCriteria(
  null,
  {
    schema: 'string',
    name: 'string',
    global: true,
    matchRules: [
      {
        name: 'string',
        attributes: [
          {
            attribute: 'string',
            match: 'exact'
          }
        ],
        strength: 'certain',
        confidence: 0
      }
    ]
  },
)
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

getUniquenessCriteria

The schema's global rule set.

GET /v1/uniqueness-criteria/{schema}

const { data } = await client.getUniquenessCriteria({
  schema: 'example',
})
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

updateUniquenessCriteria

Replaces the rules, and the name when given, of the schema's global rule set.

PUT /v1/uniqueness-criteria/{schema}

const { data } = await client.updateUniquenessCriteria(
  {
    schema: 'example',
  },
  {
    name: 'string',
    matchRules: [
      {
        name: 'string',
        attributes: [
          {
            attribute: 'string',
            match: 'exact'
          }
        ],
        strength: 'certain',
        confidence: 0
      }
    ]
  },
)
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

deleteUniquenessCriteria

Deletes the schema's global rule set. Refused while it is referenced or while the schema has other rule sets.

DELETE /v1/uniqueness-criteria/{schema}

const { data } = await client.deleteUniquenessCriteria({
  schema: 'example',
})

getUniquenessCriteriaById

One rule set by id.

GET /v1/uniqueness-criteria/{schema}/{id}

const { data } = await client.getUniquenessCriteriaById({
  schema: 'example',
  id: '123e4567-e89b-12d3-a456-426614174000',
})
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

updateUniquenessCriteriaById

Replaces the rules, and the name when given, of a rule set.

PUT /v1/uniqueness-criteria/{schema}/{id}

const { data } = await client.updateUniquenessCriteriaById(
  {
    schema: 'example',
    id: '123e4567-e89b-12d3-a456-426614174000',
  },
  {
    name: 'string',
    matchRules: [
      {
        name: 'string',
        attributes: [
          {
            attribute: 'string',
            match: 'exact'
          }
        ],
        strength: 'certain',
        confidence: 0
      }
    ]
  },
)
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

deleteUniquenessCriteriaById

Deletes a rule set. Refused with the usages while a consumer references it, and while it is the global set of a schema that has other rule sets.

DELETE /v1/uniqueness-criteria/{schema}/{id}

const { data } = await client.deleteUniquenessCriteriaById({
  schema: 'example',
  id: '123e4567-e89b-12d3-a456-426614174000',
})

setGlobalUniquenessCriteria

Makes the rule set the schema's global one. The previous global set becomes a custom set.

POST /v1/uniqueness-criteria/{schema}/{id}/global

const { data } = await client.setGlobalUniquenessCriteria({
  schema: 'example',
  id: '123e4567-e89b-12d3-a456-426614174000',
})
Response
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "orgId": "string",
  "schema": "string",
  "name": "string",
  "global": true,
  "matchRules": [
    {
      "name": "string",
      "attributes": [
        {
          "attribute": "string",
          "match": "exact"
        }
      ],
      "strength": "certain",
      "confidence": 0
    }
  ],
  "usages": [
    {
      "consumer": "string",
      "ref": "string",
      "label": "string",
      "registeredAt": "1970-01-01T00:00:00.000Z"
    }
  ],
  "createdAt": "1970-01-01T00:00:00.000Z",
  "updatedAt": "1970-01-01T00:00:00.000Z"
}

registerUniquenessCriteriaUsage

Records that a consumer configuration references the rule set. Idempotent. A referenced rule set cannot be deleted.

PUT /v1/uniqueness-criteria/{schema}/{id}/usages/{consumer}/{ref}

const { data } = await client.registerUniquenessCriteriaUsage(
  {
    schema: 'example',
    id: '123e4567-e89b-12d3-a456-426614174000',
    consumer: 'example',
    ref: 'example',
  },
  {
    label: 'string'
  },
)
Response
{
  "consumer": "string",
  "ref": "string",
  "label": "string",
  "registeredAt": "1970-01-01T00:00:00.000Z"
}

unregisterUniquenessCriteriaUsage

Removes a consumer configuration's reference to the rule set.

DELETE /v1/uniqueness-criteria/{schema}/{id}/usages/{consumer}/{ref}

const { data } = await client.unregisterUniquenessCriteriaUsage({
  schema: 'example',
  id: '123e4567-e89b-12d3-a456-426614174000',
  consumer: 'example',
  ref: 'example',
})

Schemas

DeduplicateRequestBody

type DeduplicateRequestBody = Array<{
  toKeep: string
  toDelete: string[]
}>

DeduplicateRequestResponse

type DeduplicateRequestResponse = {
  deduplicatedEntities: Array<{
    _id: string
    _org?: string
    _schema?: string
    _created_at?: string // date-time
    _updated_at?: string // date-time
    _created_by?: string | number
    created_by?: string | number
    _tags?: string[]
    _acl?: Record<string, string[]>
    _owners?: Array<{
      org_id: { ... }
      user_id: { ... }
    }>
    type?: string
  }>
}

Entity

Base Entity schema

type Entity = {
  _id: string
  _org?: string
  _schema?: string
  _created_at?: string // date-time
  _updated_at?: string // date-time
  _created_by?: string | number
  created_by?: string | number
  _tags?: string[]
  _acl?: Record<string, string[]>
  _owners?: Array<{
    org_id: string
    user_id: string
  }>
  type?: string
}

DeduplicateAsyncResponse

Response returned immediately when a deduplication job is submitted

type DeduplicateAsyncResponse = {
  jobId: string
  status: "pending" | "processing" | "completed" | "failed"
  message: string
}

JobStatus

type JobStatus = "pending" | "processing" | "completed" | "failed"

DeduplicationJob

Represents an async deduplication job

type DeduplicationJob = {
  jobId: string
  status: "pending" | "processing" | "completed" | "failed"
  message?: string
  result?: Array<{
    _id: string
    _org?: string
    _schema?: string
    _created_at?: string // date-time
    _updated_at?: string // date-time
    _created_by?: string | number
    created_by?: string | number
    _tags?: string[]
    _acl?: Record<string, string[]>
    _owners?: Array<{
      org_id: { ... }
      user_id: { ... }
    }>
    type?: string
  }>
  createdAt: string // date-time
  updatedAt: string // date-time
}

DetectDuplicatesRequestBody

type DetectDuplicatesRequestBody = {
  schema: string
  entity: Record<string, unknown>
}

DetectDuplicatesResponse

type DetectDuplicatesResponse = {
  matches: Array<{
    entity: {
      _id: { ... }
      _org?: { ... }
      _schema?: { ... }
      _created_at?: { ... }
      _updated_at?: { ... }
      _created_by?: { ... }
      created_by?: { ... }
      _tags?: { ... }
      _acl?: { ... }
      _owners?: { ... }
      type?: { ... }
    }
    confidence: number
    matched_attributes: string[]
    fuzzy_attributes?: string[]
  }>
}

DetectedDuplicateMatch

type DetectedDuplicateMatch = {
  entity: {
    _id: string
    _org?: string
    _schema?: string
    _created_at?: string // date-time
    _updated_at?: string // date-time
    _created_by?: string | number
    created_by?: string | number
    _tags?: string[]
    _acl?: Record<string, string[]>
    _owners?: Array<{
      org_id: { ... }
      user_id: { ... }
    }>
    type?: string
  }
  confidence: number
  matched_attributes: string[]
  fuzzy_attributes?: string[]
}

ResolveDuplicatesRequestBody

type ResolveDuplicatesRequestBody = {
  schema: string
  entity: Record<string, unknown>
  mode: "automated" | "interactive"
  criteria_id?: string // uuid
}

ResolutionMode

'automated' when no human is present (automations, integrations): certain matches are acted on, probable ones only flagged. 'interactive' when a person is filling in a form: every match is put in front of them.

type ResolutionMode = "automated" | "interactive"

ResolveDuplicatesResponse

type ResolveDuplicatesResponse = {
  action: "update"
  entity: {
    _id: string
    _org?: string
    _schema?: string
    _created_at?: string // date-time
    _updated_at?: string // date-time
    _created_by?: string | number
    created_by?: string | number
    _tags?: string[]
    _acl?: Record<string, string[]>
    _owners?: Array<{
      org_id: { ... }
      user_id: { ... }
    }>
    type?: string
  }
  rule_name?: string
  matched_attributes: string[]
} | {
  action: "create"
  reason: "no_match" | "ambiguous" | "probable_only"
} | {
  action: "ask"
  candidates: Array<{
    entity: {
      _id: { ... }
      _org?: { ... }
      _schema?: { ... }
      _created_at?: { ... }
      _updated_at?: { ... }
      _created_by?: { ... }
      created_by?: { ... }
      _tags?: { ... }
      _acl?: { ... }
      _owners?: { ... }
      type?: { ... }
    }
    strength: "certain" | "probable"
    rule_name?: string
    matched_attributes: string[]
    fuzzy_attributes?: string[]
  }>
}

ResolutionCandidate

type ResolutionCandidate = {
  entity: {
    _id: string
    _org?: string
    _schema?: string
    _created_at?: string // date-time
    _updated_at?: string // date-time
    _created_by?: string | number
    created_by?: string | number
    _tags?: string[]
    _acl?: Record<string, string[]>
    _owners?: Array<{
      org_id: { ... }
      user_id: { ... }
    }>
    type?: string
  }
  strength: "certain" | "probable"
  rule_name?: string
  matched_attributes: string[]
  fuzzy_attributes?: string[]
}

RuleStrength

How sure a match on the rule is. 'certain': the attributes identify one record. 'probable': the records are likely the same and a person should decide.

type RuleStrength = "certain" | "probable"

DismissDuplicatesRequestBody

type DismissDuplicatesRequestBody = {
  schema: string
  entityIds: string[]
}

DismissDuplicatesResponse

type DismissDuplicatesResponse = {
  dismissed: string[]
}

UniquenessCriteriaListResponse

type UniquenessCriteriaListResponse = {
  items: Array<{
    id: string // uuid
    orgId: string
    schema: string
    name: string
    global: boolean
    matchRules: Array<{
      name?: { ... }
      attributes: { ... }
      strength?: { ... }
      confidence?: { ... }
    }>
    usages: Array<{
      consumer: { ... }
      ref: { ... }
      label?: { ... }
      registeredAt: { ... }
    }>
    createdAt: string // date-time
    updatedAt: string // date-time
  }>
}

UniquenessCriteria

A named rule set defining what makes an entity of a schema the same record. An org can have several per schema, at most one of them global.

type UniquenessCriteria = {
  id: string // uuid
  orgId: string
  schema: string
  name: string
  global: boolean
  matchRules: Array<{
    name?: string
    attributes: Array<{
      attribute: { ... }
      match?: { ... }
    }>
    strength?: "certain" | "probable"
    confidence?: number
  }>
  usages: Array<{
    consumer: string
    ref: string
    label?: string
    registeredAt: string // date-time
  }>
  createdAt: string // date-time
  updatedAt: string // date-time
}

MatchRule

One way to identify the same entity. Evaluated in order; first rule whose attributes are all available and that returns hits wins.

type MatchRule = {
  name?: string
  attributes: Array<{
    attribute: string
    match?: object
  }>
  strength?: "certain" | "probable"
  confidence?: number
}

MatchAttribute

One attribute participating in a match rule.

type MatchAttribute = {
  attribute: string
  match?: object
}

MatchMode

How an attribute's values are compared. 'exact': the same value, ignoring case and surrounding whitespace. 'fuzzy': also ignoring doubled spaces and umlaut transcription (Müller / Mueller), and allowing a typo or two, scaled by the value's length. Fuzzy applies to text-like attributes (string, text,

type MatchMode = "exact" | "fuzzy"

RuleSetUsage

A consumer configuration that references a rule set. A referenced rule set cannot be deleted.

type RuleSetUsage = {
  consumer: string
  ref: string
  label?: string
  registeredAt: string // date-time
}

UniquenessCriteriaCreateBody

type UniquenessCriteriaCreateBody = {
  schema: string
  name?: string
  global?: boolean
  matchRules: Array<{
    name?: string
    attributes: Array<{
      attribute: { ... }
      match?: { ... }
    }>
    strength?: "certain" | "probable"
    confidence?: number
  }>
}

RuleSetConflict

type RuleSetConflict = {
  message: string
  usages: Array<{
    consumer: string
    ref: string
    label?: string
    registeredAt: string // date-time
  }>
}

UniquenessCriteriaUpdateBody

type UniquenessCriteriaUpdateBody = {
  name?: string
  matchRules: Array<{
    name?: string
    attributes: Array<{
      attribute: { ... }
      match?: { ... }
    }>
    strength?: "certain" | "probable"
    confidence?: number
  }>
}

RuleSetUsageBody

type RuleSetUsageBody = {
  label?: string
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.