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:10000 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:10000 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 { //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 { //err - object }; var { //conn - jsforce connection object } var callbacks = onError: errorCallback onConnection: connectionCallback ;
Usage
var DreadSteed = ; var dreadSteed = config errorCallback; //OR new DreadSteed(config, callbacks); var yourSalesForceQueryHere = "SELECT id, Name FROM Things WHERE id = '1' ";
Public functions
queryAsync
{ return dreadSteed; }
updateAsync
{ return dreadSteed; }
createAsync
{ return dreadSteed; }
deleteAsync
{ return dreadSteed ; };
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.