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

@salesforce/apex-node

Package Overview
Dependencies
Maintainers
48
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/apex-node - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

5

lib/src/index.d.ts
export { ExecuteService, ExecuteAnonymousResponse, ApexExecuteOptions } from './execute';
export { LogService, ApexLogGetOptions } from './logs';
export { LogService, ApexLogGetOptions, LogRecord } from './logs';
export { JUnitReporter, TapReporter } from './reporters';
export { TestService } from './tests';
export { ApexTestResultData, ApexTestResultOutcome, AsyncTestArrayConfiguration, AsyncTestConfiguration, CodeCoverageResult, SyncTestConfiguration, TestItem, TestResult, TestService } from './tests';
export { Row, Table } from './utils';

3

lib/src/index.js

@@ -17,3 +17,6 @@ "use strict";

var tests_1 = require("./tests");
exports.ApexTestResultOutcome = tests_1.ApexTestResultOutcome;
exports.TestService = tests_1.TestService;
var utils_1 = require("./utils");
exports.Table = utils_1.Table;
//# sourceMappingURL=index.js.map
export { LogService } from './logService';
export { ApexLogGetOptions } from './types';
export { ApexLogGetOptions, LogRecord } from './types';

@@ -20,4 +20,4 @@ import { Connection } from '@salesforce/core';

private isValidTestRunID;
handler(message: TestResultMessage): Promise<ApexTestQueueItem>;
handler(message?: TestResultMessage, runId?: string): Promise<ApexTestQueueItem>;
private getCompletedTestRun;
}

@@ -113,3 +113,3 @@ "use strict";

}
isValidTestRunID(testRunId) {
isValidTestRunID(testRunId, subscribedId) {
if (testRunId.length !== 15 && testRunId.length !== 18) {

@@ -119,9 +119,12 @@ return false;

const testRunId15char = testRunId.substring(0, 14);
const subscribedTestRunId15char = this.subscribedTestRunId.substring(0, 14);
return subscribedTestRunId15char === testRunId15char;
if (subscribedId) {
const subscribedTestRunId15char = subscribedId.substring(0, 14);
return subscribedTestRunId15char === testRunId15char;
}
return true;
}
handler(message) {
handler(message, runId) {
return __awaiter(this, void 0, void 0, function* () {
const testRunId = message.sobject.Id;
if (!this.isValidTestRunID(testRunId)) {
const testRunId = runId || message.sobject.Id;
if (!this.isValidTestRunID(testRunId, this.subscribedTestRunId)) {
return null;

@@ -128,0 +131,0 @@ }

export { TestService } from './testService';
export { SyncTestConfiguration } from './types';
export { AsyncTestConfiguration, AsyncTestArrayConfiguration, SyncTestConfiguration, OutputDirConfig, ApexTestResultData, ApexTestResultOutcome, CodeCoverageResult, TestItem, TestResult } from './types';

@@ -11,2 +11,4 @@ "use strict";

exports.TestService = testService_1.TestService;
var types_1 = require("./types");
exports.ApexTestResultOutcome = types_1.ApexTestResultOutcome;
//# sourceMappingURL=index.js.map
import { Connection } from '@salesforce/core';
import { SyncTestConfiguration, AsyncTestConfiguration, AsyncTestArrayConfiguration, ApexTestResult, ApexTestQueueItem, CodeCoverageResult, TestResult, PerTestCoverage } from './types';
import { SyncTestConfiguration, AsyncTestConfiguration, AsyncTestArrayConfiguration, ApexTestResult, ApexTestQueueItem, CodeCoverageResult, TestResult, PerTestCoverage, OutputDirConfig } from './types';
export declare class TestService {

@@ -10,2 +10,3 @@ readonly connection: Connection;

runTestAsynchronous(options: AsyncTestConfiguration | AsyncTestArrayConfiguration, codeCoverage?: boolean): Promise<TestResult>;
reportAsyncResults(testRunId: string, codeCoverage?: boolean): Promise<TestResult>;
formatAsyncResults(testQueueResult: ApexTestQueueItem, testRunId: string, commandStartTime: number, codeCoverage?: boolean): Promise<TestResult>;

@@ -21,5 +22,7 @@ getAsyncTestResults(testQueueResult: ApexTestQueueItem): Promise<ApexTestResult[]>;

}>;
writeResultFiles(result: TestResult, outputDirConfig: OutputDirConfig, codeCoverage?: boolean): Promise<string[]>;
private calculatePercentage;
private addIdToQuery;
stringify(jsonObj: object): string;
private getTestRunRequestAction;
}

@@ -16,2 +16,5 @@ "use strict";

const utils_1 = require("../utils");
const path_1 = require("path");
const reporters_1 = require("../reporters");
const fileSystemHandler_1 = require("../utils/fileSystemHandler");
// Tooling API query char limit is 100,000 after v48; REST API limit for uri + headers is 16,348 bytes

@@ -147,2 +150,9 @@ // local testing shows query char limit to be closer to ~12,400

}
reportAsyncResults(testRunId, codeCoverage = false) {
return __awaiter(this, void 0, void 0, function* () {
const sClient = new streaming_1.StreamingClient(this.connection);
const queueResult = yield sClient.handler(undefined, testRunId);
return yield this.formatAsyncResults(queueResult, testRunId, utils_1.getCurrentTime(), codeCoverage);
});
}
formatAsyncResults(testQueueResult, testRunId, commandStartTime, codeCoverage = false) {

@@ -363,2 +373,56 @@ return __awaiter(this, void 0, void 0, function* () {

}
writeResultFiles(result, outputDirConfig, codeCoverage = false) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const { dirPath, resultFormat, fileInfos } = outputDirConfig;
const fileMap = [];
fileMap.push({
path: path_1.join(dirPath, 'test-run-id.txt'),
content: result.summary.testRunId
});
switch (resultFormat) {
case 'json':
fileMap.push({
path: path_1.join(dirPath, `test-result-${result.summary.testRunId}.json`),
content: this.stringify(result)
});
break;
case 'tap':
const tapResult = new reporters_1.TapReporter().format(result);
fileMap.push({
path: path_1.join(dirPath, `test-result-${result.summary.testRunId}-tap.txt`),
content: tapResult
});
break;
case 'junit':
const junitResult = new reporters_1.JUnitReporter().format(result);
fileMap.push({
path: path_1.join(dirPath, `test-result-${result.summary.testRunId}-junit.xml`),
content: junitResult
});
break;
}
if (codeCoverage) {
const coverageRecords = result.tests.map(record => {
return record.perTestCoverage;
});
fileMap.push({
path: path_1.join(dirPath, `test-result-${result.summary.testRunId}-codecoverage.json`),
content: this.stringify(coverageRecords)
});
}
(_a = fileInfos) === null || _a === void 0 ? void 0 : _a.forEach(fileInfo => {
fileMap.push({
path: path_1.join(dirPath, fileInfo.filename),
content: typeof fileInfo.content !== 'string'
? this.stringify(fileInfo.content)
: fileInfo.content
});
});
fileSystemHandler_1.createFiles(fileMap);
return fileMap.map(file => {
return file.path;
});
});
}
calculatePercentage(dividend, divisor) {

@@ -375,2 +439,5 @@ let percentage = '0%';

}
stringify(jsonObj) {
return JSON.stringify(jsonObj, null, 2);
}
getTestRunRequestAction(options) {

@@ -377,0 +444,0 @@ const requestTestRun = () => __awaiter(this, void 0, void 0, function* () {

@@ -43,2 +43,10 @@ export declare const enum TestLevel {

};
export declare type OutputDirConfig = {
dirPath: string;
resultFormat?: 'tap' | 'junit' | 'json';
fileInfos?: {
filename: string;
content: string | object;
}[];
};
/**

@@ -45,0 +53,0 @@ * array of objects that represent Apex test classes

@@ -11,1 +11,9 @@ import { AnyJson } from '@salesforce/ts-types';

export declare function createFile(filePath: string, fileContent: AnyJson): void;
/**
* Method to save multiple files on disk
* @param fileMap key = filePath, value = file contents
*/
export declare function createFiles(fileMap: {
path: string;
content: string;
}[]): Promise<void>;

@@ -8,2 +8,11 @@ "use strict";

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -37,2 +46,28 @@ const fs = require("fs");

exports.createFile = createFile;
function streamPromise(stream) {
return new Promise((resolve, reject) => {
stream.on('end', () => {
resolve();
});
stream.on('error', error => {
reject(error);
});
});
}
/**
* Method to save multiple files on disk
* @param fileMap key = filePath, value = file contents
*/
function createFiles(fileMap) {
return __awaiter(this, void 0, void 0, function* () {
const writePromises = fileMap.map(file => {
ensureFileExists(file.path);
const writeStream = fs.createWriteStream(file.path);
writeStream.write(file.content);
return streamPromise(writeStream);
});
yield Promise.all(writePromises);
});
}
exports.createFiles = createFiles;
//# sourceMappingURL=fileSystemHandler.js.map
{
"name": "@salesforce/apex-node",
"description": "Salesforce js library for Apex",
"version": "0.1.7",
"version": "0.1.8",
"author": "Salesforce",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/forcedotcom/salesforcedx-apex/issues",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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