npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@or-sdk/contacts

v4.9.2

Published

OneReach SDK client for Contacts

Readme

Installation:

$ npm i @or-sdk/contacts

Contacts is a composition of separate Api entities.

Usage:

import { Contacts } from '@or-sdk/contacts'

// with direct api url
const contacts = new Contacts({
  token: 'my-account-token-string',
  contactsApiUrl: 'http://example.account-settings/endpoint'
});

// with service discovery(slower)
const contacts = new Contacts({
  token: 'my-account-token-string',
  discoveryUrl: 'http://example.account-settings/endpoint'
});

After when you initialize the Contacts Api, various entities are available at your service with which you can work (all entities presented in api folder )

Examples

Basic usage

Let's say you want to perform some CRUD operation on the contactBook entity All you need to do, it's just refer to contactBookApi(entity)

import { Contacts } from '@or-sdk/contacts'


const {contactBookApi, migrationsApi, ...rest} = new Contacts(...);
const migrationsStatus = migrationsApi.getMigrationState()
const book = contactBookApi.getContactsBook(id)
const newContactBook = contactBookApi.createContactBook(...)

Bulk create

import { Contacts } from '@or-sdk/contacts'

// always use 'withKeepAliveAgents' option for bulk create
const { bulkCreateApi } = new Contacts({
 contactsApiUrl: ..., 
 accountId: ..., 
 token: ...,
 withKeepAliveAgents: true
});

// since bulkCreateContacts is a time consuming operation,
// bulkName can be used for tracking the bulk progress
//
// usually 4000000 bytes as a maximum size of JSON payload sent to
// a single batch (the bulk operation, under its hood, consists of 
// some amount of batches) is quite enough to complete the bulk
// operation successfully, however, if bulk fails due to PostgreSQL
// server workload, you can try to decrease the batch size with the
// appropriated option
const { created, failed } = await bulkCreateApi.bulkCreateContacts(
 'some bulk name', // bulkName
 {
   contact_book: 'some book id', // optional
   contacts: [...] // it is recommended to provide 
                   // an unique (for the scope of a single bulk)
                   // contactKey for every contact, it will be used
                   // in the returned 'create' or 'failed' objects
                   // to indicate created contact id or failure 
                   // reason respectively
 }, // data
 { batchSize: 4000000 } // optional
);

Track bulk progress

import { Contacts } from '@or-sdk/contacts'

const { bulkCreateApi } = new Contacts({
  contactsApiUrl: ..., 
  accountId: ..., 
  token: ...,
  withKeepAliveAgents: true
});

for await (const bulkResults of bulkCreateApi.trackBulkCreateContacts('bulkName', data)) {
  if (bulkResults.type === 'progress') {
    const progress = bulkResults.results;
    // do progress related operations here
  } else {
    const results = bulkResults.results;
    // process final results here
  }

}

Tuning bulk

Create bulk consumes lots of resources, in terms of the quantity of launched lambdas (it's huge!), and in terms of created workload on the DB (DB server memory, CPU, connections to the DB). So basically it means that the more activities are taking place at particular point of time the higher is the probability of bulk failure. It is strongly recommended to execute the bulk create operation during non working hours!

Bulk provides some interface for tuning the workload by means of the options argument. With the default options, the bulk successfully completes 200k contacts for approximately 5 mins. Tuning options may result into the bulk operation performance degrade, however it might dramatically reduce workload on the system and turn failed bulk into successful one!

Here is the short description of the bulk create contacts mechanism to understand how to affect it by tuning options:

  • bulk examines the size of passed data and if it is more that 4000000 bytes the data is broken into array of data with the same type, however each element of this array is less than the allowed batchSize; each element of this array is called batch
  • bulk executes 4 (by default, might be tuned with the parallelBatchesAmount) batches in parallel - we call it batches series; executing here means sending the batch data to the server where contacts, actually, are created and inserted into DB
  • batch execution duration can't be determined and to avoid the gateway timeout error the execution results are poled. Every poling attempt are repeated in the amount of time specified by polingDuration
  • if batches series fails (it might happen due to DB server overload, for example), one more attempt is made after the amount of time specified with repeatFailedParallelBatchesIn
  • when all batches are executed, bulk results is formed

Here is the options:

{

 batchSize?: number; // default is 4000000 bytes.
                     // Reducing this number is the very first step you should try.
 parallelBatchesAmount?: number; // default is 4. Reducing it also improves bulk reliability, 
                                 // however it is making it slower.
 batchesToProcess?: number;  // default is ALL batches. If specified, executes only the number 
                             //of batches passed here.
 polingDuration?: number;  // default is 15000 milliseconds, 
                           //specifies the pause duration between poling batch process results
 repeatFailedParallelBatchesIn?: number; // default is 30000 milliseconds (30 seconds) - 
                                         // the amount of time bulk waits until repeating an attempt 
                                         // to execute again a failed series of batches
 logger?: BulkLogger; // logger, pass here an object that has log() function; 
                      // to be more precise, the log function should be of the following type:
                      // (message?: unknown, ...optionalParams: unknown[]) => void
};

Complete facade API reference

The Contacts client is a composition of focused API facades. All public facade methods and their TypeScript signatures are listed below; DTO shapes are exported from @or-sdk/contacts.

administrationApi — AdministrationApi

| Method | Returns | |---|---| | getIndicesStatus() | Promise<IndexStatusDto[]> | | isSystemBusy() | Promise<boolean> | | addIndex(dbIndex: DbIndicesDto) | Promise<boolean> | | dropIndex(dbIndex: DbIndicesDto) | Promise<boolean> | | getCountInTable(tableName: string) | Promise<number> | | reportDbSizes() | Promise<void> |

batchProcessApi — BatchProcessApi

| Method | Returns | |---|---| | getBatchProcess(id: string) | Promise<BatchProcessResponseDto> | | trackBatchProcess(id: string) | Promise<TrackBatchProcessResponse> | | getBatchProcessesGroup(groupId: string) | Promise<BatchProcessResponseDto[]> |

bulkCreateApi — BulkContactsCreateApi

| Method | Returns | |---|---| | bulkCreateContacts(bulkName: string, data: BulkCreateData, options: BulkOptions = {}) | Promise<BulkCreateResultsDto> | | trackBulkCreateContacts(bulkName: string, data: BulkCreateData, options: BulkOptions = {}) | AsyncGenerator<BulkGeneratorReturn> |

contactApi — ContactApi

| Method | Returns | |---|---| | getContact(id: string, params: ContactParamsDto = {}) | Promise<ContactResponseDto> | | listContact(params: FindAllParamsDto = {}) | Promise<List<ContactResponseDto>> | | listContacts(params: FindAllParamsDto = {}) | Promise<List<ContactResponseDto>> | | findContacts(params: FindAllParamsDto = {}) | Promise<ContactResponseDto[]> | | countContacts(params: FindAllParamsDto = {}) | Promise<number> | | findFirst(params: FindContactByValueDto) | Promise<ContactResponseDto \| null> | | updateContact(id: string, data: UpdateContactDto) | Promise<ContactResponseDto> | | deleteContact(id: string, data: DeleteContactParamsDto = {}) | Promise<void> | | deleteMulti(data: DeleteContactsData) | Promise<void> | | deleteContactsByBook(bookId: string, notifyEventProxy = false) | Promise<void> | | initDeleteBookContactsBulk(bookId: string, notifyEventProxy = false, limit = CONTACTS_DELETE_MAX_AMOUNT, withPoling = false) | Promise<void> | | createContact(data: CreateContactDto) | Promise<ContactResponseDto> | | mergeContacts(id: string, data: MergeContactParamsDto) | Promise<ContactResponseDto> | | linkContact(id: string, data: LinkContactParamsDto) | Promise<void> | | linkContactsMulti(data: LinkContactMultiParamsDto) | Promise<void> | | unlinkContact(id: string, data: UnlinkContactParamsDto) | Promise<void> | | unlinkContactsMulti(data: UnlinkContactMultiParamsDto) | Promise<void> | | getContactBooks(id: string) | Promise<string[]> | | isContactInBook(contactId: string, bookId: string) | Promise<boolean> |

contactBookApi — ContactBookApi

| Method | Returns | |---|---| | listContactBook(params: ContactBookParams = {}) | Promise<List<ContactBookResponseDto>> | | listContactBooks(params: ContactBookParams = {}) | Promise<List<ContactBookResponseDto>> | | getContactBook(id: string, params: GetContactBookQueryDto = {}) | Promise<ContactBookResponseDto> | | updateContactBook(id: string, data: UpdateContactBookDto) | Promise<ContactBookResponseDto> | | deleteContactBook(id: string, data: ContactBookDeleteParamsDto = {}) | Promise<void> | | createContactBook(data: CreateContactBookDto) | Promise<ContactBookResponseDto> | | shareContactBook(id: string, data: ShareContactBookParamsDto) | Promise<SharedBookResponseDto> | | restoreShareContactBook(id: string, shareMetaId: string) | Promise<SharedBookResponseDto> | | getSharedBookMeta(id: string) | Promise<SharedBookResponseDto[]> | | approveSharedBook(id: string) | Promise<void> | | rejectShareBook(id: string, data: ShareContactBookParamsDto) | Promise<void> |

fieldSchemaApi — FieldSchemaApi

| Method | Returns | |---|---| | getSchema(id: string) | Promise<FieldSchemaResponseDto> | | listSchemas(params: AdaptedListParams<FieldSchemaListParamsDto> = {}) | Promise<List<FieldSchemaResponseDto>> | | isMachineNameExist(machineName: string) | Promise<boolean> | | lockFields(fields: string[]) | Promise<void> | | unlockFields(fields: string[]) | Promise<void> | | updateSchema(id: string, data: UpdateFieldSchemaDto) | Promise<FieldSchemaResponseDto> | | deleteSchema(schemaIdentifier: string) | Promise<void> | | createSchema(params: CreateFieldSchemaParams) | Promise<FieldSchemaResponseDto> |

fieldValueApi — FieldValueApi

| Method | Returns | |---|---| | upsertByMachineName(data: UpsertFieldValueByMachineNameDto) | Promise<void> | | deleteByMachineName(data: DeleteFieldValueByMachineNameDto) | Promise<void> |

filterApi — FilterApi

| Method | Returns | |---|---| | getFilter(id: string) | Promise<FilterResponseDto> | | listFilters(params: AdaptedListParams<FilterListParamsDto> = {}) | Promise<List<FilterResponseDto>> | | updateFilter(id: string, data: UpdateFilterDto) | Promise<FilterResponseDto> | | deleteFilter(id: string) | Promise<void> | | createFilter(data: CreateFilterDto) | Promise<FilterResponseDto> |

migrationsApi — MigrationsApi

| Method | Returns | |---|---| | migrationsStatus() | Promise<boolean> | | getMigrationState() | Promise<MigrationState> | | migrationsRun() | Promise<void> | | launchMigration() | Promise<void> | | pollMigrationUntilDone(timeoutMs = 900000, stepMs = 1000, { debounceTimeout }: { debounceTimeout?: number; } = {}) | Promise<boolean> | | listMigrations() | Promise<MigrationListResponseDto[]> | | dropMigrationLockTable() | Promise<void> |

schemaPresetApi — SchemaPresetApi

| Method | Returns | |---|---| | getSchemaPreset(id: string) | Promise<SchemaPresetResponseDto> | | listSchemaPresets(params: PresetSearchParamsDto = {}) | Promise<List<SchemaPresetResponseDto>> | | updateSchemaPreset(id: string, data: UpdateSchemaPresetDto) | Promise<SchemaPresetResponseDto> | | deleteSchemaPreset(id: string, data: SchemaPresetDeleteParamsDto = {}) | Promise<void> | | createSchemaPreset(data: CreateSchemaPresetDto) | Promise<SchemaPresetResponseDto> |

sharedBookContactPermissionApi — SharedBookContactPermissionApi

| Method | Returns | |---|---| | getSharedBookContactPermission(id: string) | Promise<SharedBookContactPermissionParamsDto> | | listSharedBookContactPermission(params: AdaptedListParams<SharedBookContactPermissionParamsDto> = {}) | Promise<List<SharedBookContactPermissionParamsDto>> | | updateSharedBookContactPermission(id: string, data: UpdateSharedBookContactPermissionDto) | Promise<SharedBookContactPermissionListDto> | | deleteSharedBookContactPermission(id: string) | Promise<void> | | createSharedBookContactPermission(data: CreateSharedBookContactPermissionDto) | Promise<SharedBookContactPermissionResponseDto> |

Additional API reference

Methods below were missing from the package guide. Signatures and return types are taken directly from the exported source API.

Contacts

| Method | Returns | Purpose | |---|---|---| | callApi(params: CalApiParams) | Promise<T> | See the exported TypeScript signature for behavior and constraints. | | parseError(e: AxiosError) | Error | See the exported TypeScript signature for behavior and constraints. |

Exported utility reference

| Function | Returns | Purpose | |---|---|---| | debouncePromise(caller: () => Promise<T>, delay: number) | Promise<T> | Exported utility; see its TypeScript signature for behavior. |