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

salesforce-helper

v1.0.2-beta.0

Published

A basic project for running some node.js code with tests

Downloads

3

Readme

Salesforce Helper

Installation

This package is currently in ALPHA stage development. It is not intended for outside use yet. You're welcome to use it but expect breaking changes at the patch level. This notice will be remov npm install salesforce-helper

Usage

The simplest possible way, which looks for production credentials in .env.json
You can find out more about credentials in the [[Authentication]] section

const Sf = require('salesforce-helper')
const usage = async ()=>{
  const salesforce =  await Sf().create() // default to .env.json and production credentials
  const result = await salesforce.query('SELECT ID, Name FROM Account LIMIT 10')
}
usage()

A more detailed example for the create() parameter

const Sf = require('salesforce-helper')
const usage = async ()=>{
  const salesforce =  await Sf().create({path:'pathtocredentials',type:Sf.PRODUCTION}) 
  const result = await salesforce.query('SELECT ID, Name FROM Account LIMIT 10')
}
usage()

Alternately, you can new up an instance in one step and later do the asynchronous authentication via a call to init(). The above create() call does this under the hood.

 const Sf = require('salesforce-helper')
 const salesforce = new Sf(path:'somePath',type:Sf.CRED_TYPE.DEVELOPMENT)

 const usage = async() =>{
   await salesforce.init()
   const result = await salesforce.query('SELECT ID, Name FROM Account LIMIT 10')
 }

Authentication

The librarly expects to find a .json file either in .env.json or at the file specified. You can store a set of production and development credentials in that file. It should have the following form:

{
  "sfHelperProduction": {
    "securityToken": "longsalphanumeric",
    "clientId": "longalphanumeric",
    "clientSecret": "longalphanumeric",,
    "username": "sf username",
    "password": "sf password"
  },
  "sfHelperDevelopment": {
    "securityToken": "longsalphanumeric",
    "clientId": "longalphanumeric",
    "clientSecret": "longalphanumeric",,
    "username": "sf username",
    "password": "sf password"
  }
}

The Salesforce class has a static enum property named `CRED_TYPE` with values for `PRODUCTION` and `DEVELOPMENT, that allows you to select which set of credentials will be used.  

Integration Tests

This project contains integration tests which are fragile. You will likely need to modify those. This is a good use for the the CRED_TYPE.DEVELOPMENT credentials. You can set up a free Salesforce Developer org and have deterministic data you can run the unit tests against. The normal npm test runs just the ounit tests. npm run test:int will run the integration tests. Integration tests have a suffix of .test.int.js unit tests use .test.js