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

@botmatic/js-redis-key-store

v1.0.0

Published

A module to manage id associations in @botmatic/js-contact in a redis database. It implements the KeyStore interface defined by @botmatic/js-contact

Downloads

6

Readme

JS Redis KeyStore

A module to manage id associations in @botmatic/js-contact in a redis database.
It implements the KeyStore interface defined by @botmatic/js-contact

Installation

npm install redis js-redis-key-store --save

Usage

Initialisation

const redis = require('redis')
const client = redis.createClient(your_client_options)

const keyStore = require('js-redis-key-store')(client)

Methods

As you'd typically use this module with js-contact, you'd normally do not have to call any of these methods directly.

saveIds(integrationId, botmaticId, externalId) -> Promise<boolean>

Saves a botmatic/external ids pair for an integration. Called when a CONTACT_CREATED event is received, when js-contact::createContact() or js-contact::importContacts() are called.
Returns a Promise which resolves to true if the save was successful, false if it fails.

Parameters

parameter | type | description --- | --- | --- integrationId | string | An identifier for the integration, makes this association unique botmaticId | string | The resource id on Botmatic externalId | string | The resource id on the external API

Example using async / await
const saved = await keyStore.saveIds(integrationId, botmaticId, externalId)
// saved == true if success, false if it fails
Example using Promises
  keyStore.saveIds(integrationId, botmaticId, externalId)
  .then(saved => {
    // saved == true if success, false if it fails
  })

getBotmaticId(integrationId, externalId) -> Promise<string | null>

Gives the resource id on Botmatic associated with the given integrationId and external id.
Called when js-contact::updateContact() is called.
Returns a Promise which resolves to the botmatic id or null if none is found.

Parameters

parameter | type | description --- | --- | --- integrationId | string | An identifier for the integration externalId | string | The resource id on the external API

Example using async / await
const botmaticId = await keyStore.getBotmaticId(integrationId, externalId)
Example using Promises
  keyStore.getBotmaticId(integrationId, externalId)
  .then(botmaticId => {
    //
  })

getExtId(integrationId, botmaticId) -> Promise<string | null>

Gives the external resource id associated with the given integrationId and botmatic id.
Called when a CONTACT_UPDATED is received.
Returns a Promise which resolves to the external id or null if none is found.

Parameters

parameter | type | description --- | --- | --- integrationId | string | An identifier for the integration botmaticId | string | The resource id on Botmatic

Example using async / await
const externalId = await keyStore.getExtId(integrationId, botmaticId)
Example using Promises
  keyStore.getExtId(integrationId, botmaticId)
  .then(externalId => {
    //
  })

deleteIds(integrationId, botmaticId, extId) -> Promise<boolean>

Remove a botmatic/external id pair for a given integration id.
Called when a CONTACT_DELETED event is received and when js-contact::deleteContact() is called.
Returns a Promise which resolves to true if the deletion was successful, false if it fails.

Parameters

parameter | type | description --- | --- | --- integrationId | string | An identifier for the integration botmaticId | string | The resource id on Botmatic externalId | string | The resource id on the external API

Example using async / await
const deleted = await keyStore.deleteIds(integrationId, botmaticId, externalId)
// deleted == true if success, false if it fails
Example using Promises
  keyStore.deleteIds(integrationId, botmaticId, externalId)
  .then(deleted => {
    // deleted == true if success, false if it fails
  })

deleteAllIds(integrationId) -> Promise<boolean>

Remove a botmatic/external id pair for a given integration id. Called when a UNINSTALL event is received.
Returns a Promise which resolves to true if the deletion was successful, false if it fails.

Parameters

parameter | type | description --- | --- | --- integrationId | string | An identifier for the integration

Example using async / await
const deleted = await keyStore.deleteAllIds(integrationId)
// deleted == true if success, false if it fails
Example using Promises
  keyStore.deleteAllIds(integrationId)
  .then(deleted => {
    // deleted == true if success, false if it fails
  })

quit()

Quits the redis client