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

dread-steed

v0.1.1

Published

Module that helps handle a salesforce connection and all the fun mess that comes with salesforce

Downloads

4

Readme

dread-steed

Module that helps handle a salesforce connection and all the fun mess that comes with salesforce.

Installation

npm install dread-steed --save

Configuration

pass this config object into dread steed

    var config = {
      maxConnDuration:10.000,
      maxRetries:2,
      silent:true, // silence dreadsteed log messages Defaults to false
      errorTypes:['INVALID_SESSION_ID','INVALID_LOGIN','DUPLICATE_VALUE','SERVER_UNAVAILABLE','REQUEST_LIMIT_EXCEEDED'],
      maxEventListeners:100,
      salesforce: {
        Username:        '[email protected]',
        Password:        'salesforcepassword',
        Endpoint:        'https://test.salesforce.com',//login.salesforce.com
        SecurityToken:   'thisisasecuritytoken',
      }
    };

For handling of multiple saleforce connections.
NOTE: Api user will switch if it hits an api limit and throws REQUEST_LIMIT_EXCEEDED or SERVER_UNAVAILABLE otherwise it will just use the 1 api user

    var config = {
      maxConnDuration:10.000,
      maxRetries:2,
      silent:true, // silence dreadsteed log messages Defaults to false
      errorTypes:['INVALID_SESSION_ID','INVALID_LOGIN','DUPLICATE_VALUE','SERVER_UNAVAILABLE','REQUEST_LIMIT_EXCEEDED'],
      maxEventListeners:100,
      salesforce: [
        {
            Username:        '[email protected]',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        '[email protected]',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        '[email protected]',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        '[email protected]',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        }
      ]
    };

Error Handling

Optional if you want to handle errors and or log then in your own way

    var errorCallback = function(err){
        //err - object
    };

Optional callbacks

If you want to use callbacks for more than just error handling, you can optionally pass in an object with a callback for error handling and a callback for when the salesforce connection is established or re-established.

    var errorCallback = function(err){
        //err - object
    };

    var connectionCallback = function(conn){
        //conn - jsforce connection object
    }

    var callbacks = {
        onError: errorCallback,
        onConnection: connectionCallback
    };

Usage

    var DreadSteed = require('dread-steed');
    var dreadSteed = new DreadSteed(config, errorCallback); //OR new DreadSteed(config, callbacks);
    var yourSalesForceQueryHere = "SELECT id, Name FROM Things WHERE id = '1' ";

Public functions

queryAsync

    getAllTheThings = function(id){
        return dreadSteed.getConnection().then(function(conn){
            //use the connection!
            return conn.queryAsync(yourSalesForceQueryHere);
        }).catch(function(err){
            log.error(err);
            throw err;
        });
    }

updateAsync

    updateAllTheThings = function( updateObj, name ) {
      return dreadSteed.getConnection().then(function(conn){
        return conn.updateAsync( name, updateObj ).then(function( res ){
          return res;
        }).catch(function( err ){
          log.error(err);
          throw err;
        });
      }).catch(function(err){
        log.error(err);
        throw err;
      });
    }

createAsync

    createAllTheThings = function( newObj, name ) {
      return dreadSteed.getConnection().then(function(conn){
        return conn.createAsync(name, newObj).then(function(res) {
          return res;
        }).catch(function(err) {
          log.error(err);
          throw err;
        });
      }).catch(function(err) {
        log.error(err);
        throw err;
      });
    }

deleteAsync

    deleteTheThing = function ( Id ) {
      return dreadSteed.getConnection()
        .then(function ( conn ) {
          return conn.deleteAsync( 'Things', Id );
        }).catch(function(err) {
           log.error(err);
           throw err;
        });
    };

Tests

Release History

  • 0.0.1 Initial release
  • 0.0.2
  • 0.0.3
  • 0.0.4 Config changes
  • 0.0.5 copyright added updated readme
  • 0.0.6 error handle callback
  • 0.0.7 removed unused salesforce config from README.md
  • 0.0.8 allow optional callback for successful salesforce connections/re-connections
  • 0.0.9 allow multiple api users to switch to when api limits are hit or server unavailable happens
  • 0.0.10 Code cleanup and package json updates
  • 0.0.11 changed to MIT license added LICENSE file
  • 0.1.0 added a silent option to ignore console logs
  • 0.1.1 Removed MomentJS dependency, Removed Lodash library. Moved to individual needed functions. Add Row lock error to retry logic on queries.