@salesforce/apex-node
Advanced tools
Comparing version 0.0.2 to 0.0.3
import { Connection } from '@salesforce/core'; | ||
import { JsonCollection } from '@salesforce/ts-types'; | ||
import { SoapResponse, RequestData } from '../types/execute'; | ||
@@ -11,3 +12,3 @@ import { ExecuteAnonymousResponse, ApexExecuteOptions } from '../types'; | ||
connectionRequest(requestData: RequestData): Promise<SoapResponse>; | ||
refreshAuth(connection: Connection): Promise<import("@salesforce/ts-types").JsonCollection>; | ||
refreshAuth(connection: Connection): Promise<JsonCollection>; | ||
} |
@@ -24,4 +24,5 @@ "use strict"; | ||
if (options.apexFilePath) { | ||
if (!fs_1.existsSync(options.apexFilePath)) | ||
if (!fs_1.existsSync(options.apexFilePath)) { | ||
throw new Error(i18n_1.nls.localize('file_not_found_error', options.apexFilePath)); | ||
} | ||
data = fs_1.readFileSync(options.apexFilePath, 'utf8'); | ||
@@ -28,0 +29,0 @@ } |
@@ -11,2 +11,7 @@ "use strict"; | ||
const util = require("util"); | ||
function escapeXml(data) { | ||
return data.replace(/[<>&'"]/g, char => { | ||
return execute_1.xmlCharMap[char]; | ||
}); | ||
} | ||
function encodeBody(accessToken, data) { | ||
@@ -20,7 +25,2 @@ const escapedData = escapeXml(data); | ||
exports.encodeBody = encodeBody; | ||
function escapeXml(data) { | ||
return data.replace(/[<>&'"]/g, char => { | ||
return execute_1.xmlCharMap[char]; | ||
}); | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -7,4 +7,5 @@ import { Connection } from '@salesforce/core'; | ||
getLogs(options: ApexLogGetOptions): Promise<string[]>; | ||
writeLog(outputDir: string, logRecord: string, id: string): Promise<void>; | ||
getLogIds(numberOfLogs: number): Promise<string[]>; | ||
connectionRequest(url: string): Promise<string>; | ||
toolingRequest(url: string): Promise<string>; | ||
} |
"use strict"; | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -19,2 +13,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
const i18n_1 = require("../i18n"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const MAX_NUM_LOGS = 25; | ||
@@ -25,6 +21,7 @@ class LogService { | ||
} | ||
// readableStream cannot be used until updates are made in jsforce and sfdx-core | ||
getLogs(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let logIdList = []; | ||
if (options.numberOfLogs) { | ||
if (typeof options.numberOfLogs === 'number') { | ||
logIdList = yield this.getLogIds(options.numberOfLogs); | ||
@@ -35,9 +32,25 @@ } | ||
} | ||
const connectionRequests = logIdList.map(id => { | ||
const connectionRequests = logIdList.map((id) => __awaiter(this, void 0, void 0, function* () { | ||
const url = `${this.connection.tooling._baseUrl()}/sobjects/ApexLog/${id}/Body`; | ||
return this.connectionRequest(url); | ||
}); | ||
return yield Promise.all(connectionRequests); | ||
const logRecord = yield this.toolingRequest(url); | ||
if (options.outputDir) { | ||
this.writeLog(options.outputDir, logRecord, id); | ||
} | ||
return logRecord; | ||
})); | ||
const result = yield Promise.all(connectionRequests); | ||
return result; | ||
}); | ||
} | ||
writeLog(outputDir, logRecord, id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!fs.existsSync(outputDir)) { | ||
fs.mkdirSync(outputDir, { recursive: true }); | ||
} | ||
const filePath = path.join(`${outputDir}`, `${id}.txt`); | ||
const stream = fs.createWriteStream(filePath); | ||
stream.write(logRecord); | ||
stream.end(); | ||
}); | ||
} | ||
getLogIds(numberOfLogs) { | ||
@@ -54,5 +67,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
connectionRequest(url) { | ||
toolingRequest(url) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const log = yield this.connection.request(url); | ||
const log = yield this.connection.tooling.request(url); | ||
return JSON.stringify(log); | ||
@@ -59,0 +72,0 @@ }); |
@@ -22,7 +22,7 @@ /// <reference types="node" /> | ||
[soapBody]: { | ||
executeAnonymousResponse: execAnonResult; | ||
executeAnonymousResponse: ExecAnonResult; | ||
}; | ||
}; | ||
} | ||
export interface execAnonResult { | ||
export interface ExecAnonResult { | ||
result: { | ||
@@ -29,0 +29,0 @@ column: number; |
@@ -5,2 +5,3 @@ import { CommonOptions } from './common'; | ||
logId?: string; | ||
outputDir?: string; | ||
}; |
{ | ||
"name": "@salesforce/apex-node", | ||
"description": "Salesforce js library for Apex", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Salesforce", | ||
@@ -13,2 +13,3 @@ "bugs": "https://github.com/forcedotcom/salesforcedx-apex/issues", | ||
"@salesforce/ts-sinon": "^1.1.2", | ||
"@salesforce/ts-types": "1.2.2", | ||
"@types/chai": "^4", | ||
@@ -22,3 +23,7 @@ "@types/mocha": "^5", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-jsdoc": "^19.1.0", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"husky": "4.2.5", | ||
"lint-staged": "10.2.11", | ||
"mocha": "^5", | ||
@@ -45,6 +50,16 @@ "nyc": "^14.1.1", | ||
"build": "shx rm -rf lib && tsc -b", | ||
"format": "prettier --config ../../.prettierrc --write './**/*.{ts,js,json}'", | ||
"format": "prettier --config ../../.prettierrc --write './{src,test,scripts}/**/*.{ts,js,json}'", | ||
"lint": "eslint -c .eslintrc.json --ext .ts ./src ./test", | ||
"test": "mocha --recursive \"./test/**/*.test.ts\" --full-trace" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"./{src,test}/**/*.{ts,js}": [ | ||
"eslint -c .eslintrc.json --fix" | ||
] | ||
}, | ||
"license": "BSD-3-Clause", | ||
@@ -51,0 +66,0 @@ "engines": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
41529
764
0
22
3