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

@devrev-grow/snap-in-utils

v5.1.1

Published

Collection of helper functions for devrev snap-ins

Downloads

32

Readme

Overview

This package is a collection of helper functions we share between DevRev snap-ins

NOTE: Depreciated APIs

In the 4.x release, we've depreciated the old DevRev and Outreach clients. These clients were created with the createDevRevClient() and createOutreachClient() functions. Please use the new DevRevAPI object instead (created with new DevRevAPI(token))

Installation

npm i -S @devrev-growth/snap-in-utils

Upgrading

npm update @devrev-growth/snap-in-utils

Usage

Each of the remote destinations supported have their own client that requires configuration before use.

BigQuery

import { createBQClient } from '@devrev-growth/snap-in-utils';

const client = createBqClient(GOOGLE_API_KEY, PROJECT_ID);

const query =
  'SELECT * FROM `bigquery-public-data.covid19_nyt.us_counties` LIMIT 10';

const results = await client.executeQuery(query);

The executeQuery method will also format the data, returning a list of objects where the keys are the values of the columns in the query. You can also use executeQueryRaw and formatData if you wish to handle this on your own

DevRev

import { createDevRevClient } fromn '@devrev-growth/snap-in-utils';

const client = createDevRevClient(DEVREV_API_TOKEN);

const contact = client.getContactById(CONTACT_ID);

const {contact, account} = client.getContactAndAccount(EMAIL_ADDRESS);

By default, the client will have a 40000ms timeout on requests and be limited to 10 requests per second. It also uses the prod api https://api.devrev.ai by default. You can override these with the timeout maxRequests and baseURL options

const client = createDevRevClient(DEVREV_API_TOKEN, {
  timeout: 60000,
  maxRequests: 4,
  baseURL: 'https://api.dev.devrev-eng.ai',
});

If you need to get all of something, you can use the special getAll method. This will handle pagination for you and return a list of all the results, using the API name

const allAccounts = client.getAll('accounts');

// Some API endpoints have an extra bit in the path, like rev-users.all.
// This will be handled properly by the code
const allRevUsers = client.getAll('rev-users.all');

The most important functions are the getContactAndAccount and the getOrCreateContactAndAccount. This will handle Contact and Account resolution for you, just provide whatever info you can will do the rest. The major difference is that getOrCreateContactAndAccount will create a new Contact and Account if one does not exist. It accepts an optional object at the end to provide additional information to create the Contact and Account

const { contact, account } = client.getContactAndAccount(EMAIL_ADDRESS);
const { contact, account } = client.getContactAndAccount(EMAIL_ADDRESS, DOMAIN);
const { contact, account } = client.getOrCreateContactAndAccount(EMAIL_ADDRESS);
const { contact, account } = client.getOrCreateContactAndAccount(
  EMAIL_ADDRESS,
  DOMAIN
);
const { contact, account } = client.getOrCreateContactAndAccount(
  EMAIL_ADDRESS,
  DOMAIN,
  { full_name: NAME, company: COMPANY }
);

Beyond these special functions, there should be get and create for all the major workflows we need (and if not we should add them)

getAccountsByDomain,
getAccountById,
getContactById,
getRevOrgById,
getRevOrgsByAccount,
getContactsByEmail,
getDevUserById,
getDevUsersByEmail,
getEngagementById,
getEngagementsByExternalRef,
getContactsByRevOrg,
getContactsByAccount,
getContactAndAccount,
getOrCreateContactAndAccount,
deleteContact,
deleteAccount,
deleteEngagement,
getAll,
updateRevOrg,
updateContact,
updateAccount,
updateEngagement,
createEngagement,