Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@salesforce/apex-node

Package Overview
Dependencies
Maintainers
0
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/apex-node

Salesforce JS library for Apex

  • 8.1.19
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
181K
increased by3.99%
Maintainers
0
Weekly downloads
 
Created

What is @salesforce/apex-node?

@salesforce/apex-node is an npm package that allows developers to interact with Salesforce Apex classes and methods from Node.js applications. It provides functionalities to execute Apex code, run tests, and retrieve test results programmatically.

What are @salesforce/apex-node's main functionalities?

Execute Anonymous Apex

This feature allows you to execute anonymous Apex code on a Salesforce instance. The code sample demonstrates how to log in to Salesforce and execute a simple Apex code snippet.

const { Connection, ExecuteAnonymousResponse } = require('@salesforce/apex-node');

async function executeAnonymousApex() {
  const conn = new Connection({ loginUrl: 'https://login.salesforce.com' });
  await conn.login('username', 'password');
  const apexCode = 'System.debug(\'Hello, World!\');';
  const result = await conn.tooling.executeAnonymous(apexCode);
  console.log(result);
}

executeAnonymousApex();

Run Apex Tests

This feature allows you to run Apex tests asynchronously. The code sample demonstrates how to log in to Salesforce and run tests for a specified list of test classes.

const { Connection, RunTestsAsynchronousResponse } = require('@salesforce/apex-node');

async function runApexTests() {
  const conn = new Connection({ loginUrl: 'https://login.salesforce.com' });
  await conn.login('username', 'password');
  const testClasses = ['MyTestClass'];
  const result = await conn.tooling.runTestsAsynchronous(testClasses);
  console.log(result);
}

runApexTests();

Retrieve Test Results

This feature allows you to retrieve the results of previously run Apex tests. The code sample demonstrates how to log in to Salesforce and query the ApexTestResult object to get test results.

const { Connection, QueryResult } = require('@salesforce/apex-node');

async function getTestResults() {
  const conn = new Connection({ loginUrl: 'https://login.salesforce.com' });
  await conn.login('username', 'password');
  const query = 'SELECT Id, Status, ApexClassId FROM ApexTestResult';
  const result = await conn.tooling.query(query);
  console.log(result.records);
}

getTestResults();

Other packages similar to @salesforce/apex-node

Keywords

FAQs

Package last updated on 01 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc