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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@coveo/push-api-client

v4.0.1

Published

Push API client

Downloads

15,943

Readme

@coveo/push-api-client.js

Coveo Push API client

Installation

npm i @coveo/push-api-client

Features

  • Upload data to both Push and Catalog sources
  • Pre-push document validation
  • Automatic custom field creation
  • Full catalog upload and incremental document update
  • Optimized for large payload uploads

Usage

import {PushSource, DocumentBuilder} from '@coveo/push-api-client';

async function main() {
  const source = new PushSource('my_api_key', 'my_coveo_organization_id');

  const myDocument = new DocumentBuilder(
    'https://my.document.uri',
    'My document title'
  ).withData('these words will be searchable');

  await source.addOrUpdateDocument('my_source_id', myDocument);
}

main();

You can also upload your data into a catalog source

async function main() {
  const source = new CatalogSource('my_api_key', 'my_coveo_organization_id');
  await source
    .batchStreamDocumentsFromFiles('my_source_id', ['path/to/file_or_folder'])
    .batch();
}

main();

See more examples in the ./samples folder.

Proxy configuration

You can use the HTTPS_PROXY or https_proxy environment variable for proxy configuration. Read more about it here.

Exponential backoff retry configuration

By default, the SDK leverages an exponential backoff retry mechanism. Exponential backoff allows for the SDK to make multiple attempts to resolve throttled requests, increasing the amount of time to wait for each subsequent attempt. Outgoing requests will retry when a 429 status code is returned from the platform.

The exponential backoff parameters are as follows:

  • retryAfter - The amount of time, in milliseconds, to wait between throttled request attempts.

    Optional, will default to 5,000.

  • maxRetries - The maximum number of times to retry throttled requests.

    Optional, will default to 10.

  • timeMultiple - The multiple by which to increase the wait time between each throttled request attempt.

    Optional, will default to 2.

You may configure the exponential backoff that will be applied to all outgoing requests. To do so, specify a PlatformOptions object when creating either a CatalogSource or PushSource object:

const catalogSource = new CatalogSource(
  'my_api_key',
  'my_coveo_organization_id',
  {maxRetries: 10, retryAfter: 2000, timeMultiple: 3}
);
const pushSource = new PushSource(
  'my_other_api_key',
  'my_other_coveo_organization_id',
  {maxRetries: 3, retryAfter: 600000}
);

By default, requests will retry a maximum of 10 times, waiting 5 seconds after the first attempt, with a time multiple of 2 (which will equate to a maximum execution time of roughly 1.5 hours).

Local development

  • npm i
  • Copy env.sample to .env, and replace the variables with proper values.
  • npm run dev to compile and run ./src/localtest.ts.
  • npm run test for unit tests.

Commit

Use npm run commit to get a properly formatted commit message which will help control the versioning and CHANGELOG generation.

Release

Run Github action named release, which will bump version, tag and publish to npm.