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

javascript-salesforce-connector

v1.1.2

Published

Salesforce ORM-like module with ActiveRecord-style interface

Readme

Publish to NPM Test

⚠️ DEPRECATION NOTICE: The string-based Model class and QueryBuilder are deprecated and will be removed in v2.0.0. Please migrate to LambdaModel for type-safe queries with closure variable support. See Migration Guide.

Salesforce ORM

A TypeScript ORM library for Salesforce with lambda-based queries, full type inference, and closure variable support.

📚 Full Documentation | 🆕 LambdaModel Guide | 🔄 Migration Guide

✨ Core Features

🎯 Type-Safe Lambda Queries

Write queries with full IntelliSense and compile-time type checking:

// Define your model
class Account extends LambdaModel<AccountData> {
  protected static objectName = 'Account';
}

// Query with type safety
const accounts = await Account
  .select(x => ({
    Id: x.Id,           // ✓ IntelliSense works!
    Name: x.Name,       // ✓ Typos caught at compile time
    Industry: x.Industry
  }))
  .limit(10)
  .get();

🔗 Closure Variable Support

Use variables from outer scope naturally:

const industry = 'Technology';
const minRevenue = 1000000;

const accounts = await Account
  .select(x => ({ Id: x.Id, Name: x.Name }))
  .where(x => x.Industry === industry && x.AnnualRevenue > minRevenue)
  .get();

📋 WHERE IN Queries

Array membership with automatic WHERE IN detection:

const industries = ['Technology', 'Finance', 'Healthcare'];

const accounts = await Account
  .select(x => ({ Id: x.Id, Name: x.Name }))
  .where(x => x.Industry.includes(industries))
  .get();
// SOQL: WHERE Industry IN ('Technology', 'Finance', 'Healthcare')

🌳 Relationship Queries with Closures

Query subqueries with full closure support:

const activeStatus = true;

const accounts = await Account
  .select(x => ({
    Name: x.Name,
    ActiveContacts: x.Contacts
      .select(c => ({ Name: c.Name, Email: c.Email }))
      .where(c => c.Active__c === activeStatus)  // ✓ Closures work in subqueries!
  }))
  .get();

🔧 Automatic Model Generation

Generate TypeScript models from Salesforce metadata:

# Initialize configuration
npx sfc init

# Generate models with full type safety
npx sfc scaffold Account Contact Opportunity

🪝 Lifecycle Hooks (Observers)

React to model events without modifying model classes:

class AuditLogObserver implements Observer<Account> {
  async afterCreate(account: Account) {
    console.log(`Account created: ${account.Id}`);
  }
}

Account.observe(new AuditLogObserver());

📄 Smart Pagination

Built-in pagination with metadata:

const { records, totalSize, hasNextPage } = await Account
  .select(x => ({ Id: x.Id, Name: x.Name }))
  .where(x => x.Industry === 'Technology')
  .paginate(1, 20);  // Page 1, 20 per page

Quick Start

Installation

npm install javascript-salesforce-connector

Basic Usage

import { SalesforceConfig, LambdaModel } from 'javascript-salesforce-connector';
import { Account } from './models/Account';

// Configure connection
SalesforceConfig.initialize({
  instanceUrl: 'https://your-instance.salesforce.com',
  apiVersion: 'v59.0'
});
SalesforceConfig.setAccessToken('your-access-token');

// Query with type safety
const industry = 'Technology';
const accounts = await Account
  .select(x => ({ Id: x.Id, Name: x.Name, Industry: x.Industry }))
  .where(x => x.Industry === industry)
  .limit(10)
  .get();

// Create a record
const account = await Account.create({
  Name: 'Acme Corporation',
  Industry: 'Technology'
});

// Update a record
account.Industry = 'Finance';
await account.save();

// Delete a record
await account.delete();

Documentation

📚 View Full Documentation

Getting Started

Models

Querying

CRUD Operations

Advanced

CLI

Important Notes

⚠️ Governor Limits: This library does NOT automatically handle Salesforce governor limits. Always use .limit() and proper filtering.

⚠️ Observers vs Salesforce Triggers: Observers are JavaScript/TypeScript hooks that run in your application. They are NOT Salesforce Triggers, Process Builder, or Flows.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Links