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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iimransarwar/salesforce-operations-sdk

v1.0.14

Published

Core SDK for Salesforce operations - provides business logic layer between MCP tools and JSForce

Downloads

458

Readme

@salesforce-operations/core

Core SDK for Salesforce operations providing business logic layer between MCP tools and JSForce.

Purpose

This SDK extracts all complex business logic from MCP tool files, allowing:

  • 90% reduction in token usage for LLMs (tools become 50-100 lines instead of 1000+)
  • Better separation of concerns
  • Reusable across different contexts (not just MCP)
  • Easier to test and maintain

Architecture

MCP Tools (50-100 lines) → SDK (this package) → JSForce → Salesforce API

Installation

npm install @salesforce-operations/core jsforce

Usage

Query Operations

import { SalesforceSDK } from '@salesforce-operations/core';
import jsforce from 'jsforce';

const conn = new jsforce.Connection({
  instanceUrl: process.env.SALESFORCE_INSTANCE_URL,
  accessToken: process.env.SALESFORCE_ACCESS_TOKEN
});

// Execute a query
const result = await SalesforceSDK.query(conn, {
  objectName: 'Account',
  fields: ['Id', 'Name', 'Industry'],
  whereClause: 'Industry = ?',
  parameters: ['Technology'],
  limit: 10
});

console.log(`Found ${result.totalSize} records in ${result.executionTime}ms`);

Query Builder (Fluent API)

const result = await SalesforceSDK.createQuery('Account')
  .select('Id', 'Name', 'Industry')
  .where('Industry = ?', 'Technology')
  .and('AnnualRevenue > ?', 1000000)
  .orderBy('Name ASC')
  .limit(10)
  .execute(conn);

Advanced Features

Circuit Breaker

const result = await SalesforceSDK.query(conn, {
  objectName: 'Account',
  fields: ['Id', 'Name'],
  circuitBreakerOptions: {
    failureThreshold: 5,
    resetTimeout: 60000
  }
});

Retry with Exponential Backoff

const result = await SalesforceSDK.query(conn, {
  objectName: 'Account',
  fields: ['Id', 'Name'],
  retryOptions: {
    maxRetries: 3,
    initialDelay: 1000,
    maxDelay: 10000,
    retryableErrors: ['UNABLE_TO_LOCK_ROW', 'QUERY_TIMEOUT']
  }
});

Field Masking

const result = await SalesforceSDK.query(conn, {
  objectName: 'Contact',
  fields: ['Id', 'Name', 'Email', 'Phone'],
  maskFields: ['Email', 'Phone']
});

// Output: Email will be "em***@example.com", Phone will be "55***7890"

Features

  • SQL Injection Prevention: Automatic parameter sanitization
  • Circuit Breaker: Prevent cascading failures
  • Retry Logic: Exponential backoff for transient errors
  • Field Masking: PII protection for sensitive data
  • Query Builder: Fluent API for complex queries
  • Auto Pagination: Fetch all records automatically
  • Performance Monitoring: Track execution times

API Reference

executeQuery(conn, options)

Execute a SOQL query with full feature support.

Parameters:

  • conn: JSForce connection instance
  • options: Query options object
    • objectName: Salesforce object API name (required)
    • fields: Array of field names to select (required)
    • whereClause: WHERE clause (optional)
    • parameters: Parameter values for ? placeholders (optional)
    • orderBy: ORDER BY clause (optional)
    • groupBy: GROUP BY clause (optional)
    • having: HAVING clause (optional)
    • limit: Maximum number of records (optional)
    • offset: Number of records to skip (optional)
    • autoFetchAll: Fetch all pages automatically (optional)
    • maskFields: Array of fields to mask (optional)
    • retryOptions: Retry configuration (optional)
    • circuitBreakerOptions: Circuit breaker configuration (optional)

Returns: QueryResult object with:

  • records: Array of records
  • totalSize: Total number of records
  • done: Whether all records were fetched
  • executionTime: Execution time in milliseconds
  • query: Final SOQL query that was executed

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run watch

# Clean
npm run clean

License

MIT