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

@evokegroup/salesforce

v2.0.1

Published

Library for limited Salesforce integration

Downloads

19

Readme

@evokegroup/salesforce

Library for limited Salesforce integration

Class: Salesforce

Class: Salesforce.Api

constructor(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | authorizer | OAuth2.Authorizer | | | | clientId | string | | | | clientSecret | string | | | | subdomain | string | | | | authOrigin | string | auth.marketingcloudapis.com | | | restOrigin | string | rest.marketingcloudapis.com | | | timeout | number | 30000 | | | logger | Logger, | | A Logger to output logs to |

authenticate() => Promise<OAuth2.AccessToken>

Authenticates. Called automatically.

dataQuery(args)

Queries a data extension. The filter + fields query string character length must be <= 2048 characters when url encoded. See Utility.createDataQueryValueBatches to break large queries into batches.

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | dataExtension | string | | The name of the data extension to query | | filter | Salesforce.Api.FilterGroup, Salesforce.Api.Filter | | The query filter | | fields | Array<string> | | The fields to return | | output | Salesforce.Api.OutputFormat | Salesforce.Api.OutputFormat.Json | The output format | | transform | boolean | true | Transforms the data returned to match the fields given |

const Salesforce = require('@evokegroup/salesforce');
const sf = new Salesforce.Api({
  subdomain: 'abc123',
  clientId: 'qwer456',
  clientSecret: 'poiu0987'
});
sf.dataQuery({
  dataExtension: 'DE_Custom_Contact',
  filter: new Salesforce.Api.FilterGroup({
    type: Salesforce.Api.FilterGroupType.And,
    filters: [
      new Salesforce.Api.FilterGroup({
        type: Salesforce.Api.FilterGroupType.Or,
        filters: [
          new Salesforce.Api.Filter({
            key: 'Contact Key',
            value: 'guid-1'
          }),
          new Salesforce.Api.Filter({
            key: 'Contact Key',
            value: 'guid-2'
          })
        ]
      }),
      new Salesforce.Api.Filter({
        key: 'Custom Field Name',
        value: 'Evoke'
      })
    ]
  }),
  fields: ['Contact Key', 'Custom Field Name', 'Another Field']
})
.then((data) => {
  console.log(data);
  /*
    [{
      'Contact Key': 'guid-1',
      'Custom Field Name': 'Evoke',
      'Another Field': 'abc'
    }, {
      'Contact Key': 'guid-2',
      'Custom Field Name': 'Evoke',
      'Another Field': 'def'
    }]
  */
})
.catch((ex) => {
  console.log(ex);
});

dataInsertAsync(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | dataExtension | string | | The name of the data extension | | items | Array<object> | | The data items to insert | | output | Api.OutputFormat, Salesforce.Api.OutputFormat | Salesforce.Api.OutputFormat.Json | The output format |

dataUpsertAsync(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | dataExtension | string | | The name of the data extension | | items | object | | The data extension data to upsert | | output | Salesforce.Api.OutputFormat | Salesforce.Api.OutputFormat.Json | |

interactionEvent(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | contactKey | string | | The contact key | | eventDefinitionKey | string | | The event definition key | | data | object | | The event data | | output | Salesforce.Api.OutputFormat | Salesforce.Api.OutputFormat.Json | |

Class: Salesforce.Api.TokenAuthorizerV2 extends OAuth2.WebTokenAuthorizer

constructor({ subdomain, clientId, clientSecret, logger, authOrigin, timeout })

Class: Salesforce.Api.Filter

constructor(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | key | string | | This filter key (typically the field name) | | value | string | | The value to filter on | | comparison | string | Api.FilterComparison.Equals | The filter value comparison operator |

Properties

| Name | Type | Default | Description | | ---- | ---- | ------- | ----------- | | key | string | | This filter key (typically the field name) | | value | string | | The value to filter on | | comparison | string | Api.FilterComparison.Equals | The filter value comparison operator |

Methods

toQuerystring()

Class: Salesforce.Api.FilterEquals extends Salesforce.Api.Filter

constructor(key, value)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | key | string | | This filter key (typically the field name) | | value | string | | The value to filter on |

Class: Salesforce.Api.FilterGroup

constructor(args)

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | type | string | Api.FilterGroupType.And | The operator the join filters with | | filters | Array<object> | | An array containing Filters and/or FilterGroups |

Class: Salesforce.Api.FilterGroupAnd extends Salesforce.Api.FilterGroup

constructor(filters[, ...filter])

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | filter | Array<Salesforce.Api.Filter>, Salesforce.Api.Filter | | An array of Salesforce.Api.Filter or any number of filter paramters |

Class: Salesforce.Api.FilterGroupOr extends Salesforce.Api.FilterGroup

constructor(filters[, ...filter])

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | filter | Array<Salesforce.Api.Filter>, Salesforce.Api.Filter | | An array of Salesforce.Api.Filter or any number of filter paramters |

Enumeration: Salesforce.Api.FilterComparison

Enumeration: Salesforce.Api.FilterGroupType

Enumeration: Salesforce.Api.OutputFormat

Class: Salesforce.Constants

static DATA_QUERY_CHARACTER_LIMIT

The maximum number of characters allowed (2048) in a data queries filter and fields.

Class: Salesforce.Utility

static batchItems(items, { maxBytes, encoding })

Create item batches that are less than a given maximum byte size

static createDataQueryValueBatches({ filterKey, filterValues, fields, filterGroupType, filterComparisonType }) => Array<Array>

Separates large queries into batches which will be under the data query maximum character limit. Returns an array of arrays of unique filter values

| Parameter | Type | Default | Description | | --------- | ---- | ------- | ----------- | | filterKey | string | | The filter key | | filterValues | Array<string> | | The filter values | | fields | Array<string> | | The fields the query would return | | filterGroupType | Salesforce.Api.FilterGroupType.Or | | The filter group type | | filterComparisonType | Salesforce.Api.FilterComparison.Equals | | The filter comparison |

const values = [...]; // A large number of filter values
const batches = Salesforce.Api.createDataQueryValueBatches({ filterKey: 'Email', filterValues: values, fields: ['Email', 'First Name', 'Last Name'] });
/* batches = [
  [...],
  [...],
  [...]
] */