Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dread-steed

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dread-steed

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

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
3
Weekly downloads
 
Created
Source

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:        'salesforceapi@salesforce.com',
        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:        'salesforceapi@salesforce.com',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        'salesforceapi2@salesforce.com',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        'salesforceapi3@salesforce.com',
            Password:        'salesforcepassword',
            Endpoint:        'https://test.salesforce.com',//login.salesforce.com
            SecurityToken:   'thisisasecuritytoken',
        },
        {
            Username:        'salesforceapi4@salesforce.com',
            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.

Keywords

FAQs

Package last updated on 03 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc