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-restapi-made-easy

v1.0.5

Published

Node.js implementation of the salesforce's rest API.

Downloads

8

Readme

salesforce-restapi-made-easy

Node.js implementation of the salesforce's rest API.

Contents

Features

  • Escape special SOSL's characters: ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -
  • Escape special SOQL's characters: \ '
  • Configurable API version. Default v43.0
  • Fetch SOSL' search results.
    • Generate text-search criterion
  • Fetch SOQL's query results.
  • CRUD operations (coming soon)

Getting Started

Installation

> npm install --save salesforce-restapi-made-easy

Usage

Escape SOQL queries and SOSL searches

const {escapeSOSL, escapeSOQL} = require('salesforce-restapi-made-easy');

console.log(escapeSOQL(`Tom's cabin`)); // Tom\\'s cabin
console.log(escapeSOSL('{1+1}:2'));     // \\{1\\+1\\}\\:2

Create a text-search criteria for a SOSL search.

const {createSearchCriteria} = require('salesforce-restapi-made-easy');
console.log(createSearchCriteria(' tavern by   the sea  '));
//Output:
// "tavern by the sea" OR "by the sea" OR "the sea" OR sea OR "tavern by the" OR "tavern by" OR tavern

SOQL queries and SOSL searches

const {escapeSOSL, escapeSOQL, easyAPI} = require('salesforce-restapi-made-easy');

// Prerequisite: Fetch a token and an organization's url
//              from the Salesforce's OAuth2 API.
(async function() {
  try {
    let records;
    const token='62aC67bBquJkqLX8jXGhNhLwa3cbafU20jIZU5mMSw0MmyiDT7GPMEjucLfncgE0';
    const orgURL='https://cs13.salesforce.com';
    const API43 = easyAPI(orgURL, 'v43.0')(token);
    const soqlQuery=`Select Name from Account where Address='${escapeSOQL('Tom\'s rd')}'`;
    const soqlResults = await API43.SOQL(soqlQuery);
    // Process soqlResults

    const soslQuery = `FIND {${escapeSOSL(`O.A.K (2){3}`)}} IN NAME FIELDS RETURNING Account(Id, Name)`;
    const soslResults = await API43.SOSL(soslQuery);
    // Process soslResults

    //Return response
    return records;
  } catch (error) {
    throw error;
  }
})().then((records)=>console.log(records))
    .catch((error)=>console.error(error));

Get an Auth2 Token

const {getOauth2Token} = require('salesforce-restapi-made-easy');
getOauth2Token({
 client_id: 'your_client_id',
 client_secret: 'your_client_secret',
 username: 'your_username',
 passwordAndToken: 'yourPasswordFollowedByYourToken',
}, 'https://test.salesforce.com/services/oauth2/token')
   .then((tokenReponse)=>{
     const {success, message, data: {access_token, instance_url}} = tokenReponse;
     console.log(success, message, access_token, instance_url);
   });