Socket
Socket
Sign inDemoInstall

@salesforce/core

Package Overview
Dependencies
Maintainers
48
Versions
499
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/core - npm Package Compare versions

Comparing version 2.14.0 to 2.15.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.15.0](https://github.com/forcedotcom/sfdx-core/compare/v2.14.0...v2.15.0) (2020-10-30)
### Features
* allow adding property metas to allowedProperties on config ([2a264d3](https://github.com/forcedotcom/sfdx-core/commit/2a264d3ca3002c4c90c771beaa2036a06d331697))
## [2.14.0](https://github.com/forcedotcom/sfdx-core/compare/v2.13.0...v2.14.0) (2020-10-22)

@@ -7,0 +14,0 @@

10

lib/config/config.d.ts

@@ -81,5 +81,5 @@ import { ConfigFile } from './configFile';

static readonly MAX_QUERY_LIMIT = "maxQueryLimit";
private static get propertyConfigMap();
private static allowedProperties;
private static messages;
private static propertyConfigMap;
private crypto?;

@@ -94,6 +94,12 @@ constructor(options?: ConfigFile.Options);

/**
* Returns an object representing the supported allowed properties.
* Returns an array of objects representing the allowed config properties.
*/
static getAllowedProperties(): ConfigPropertyMeta[];
/**
* Add an array of allowed config properties.
*
* @param metas Array of objects to set as the allowed config properties.
*/
static addAllowedProperties(metas: ConfigPropertyMeta[]): void;
/**
* Gets default options.

@@ -100,0 +106,0 @@ *

176

lib/config/config.js

@@ -12,2 +12,3 @@ "use strict";

const ts_types_1 = require("@salesforce/ts-types");
const logger_1 = require("../logger");
const crypto_1 = require("../crypto");

@@ -18,2 +19,3 @@ const messages_1 = require("../messages");

const configFile_1 = require("./configFile");
const log = logger_1.Logger.childFromRoot('core:config');
const SFDX_CONFIG_FILE_NAME = 'sfdx-config.json';

@@ -39,69 +41,8 @@ /**

}
if (!Config.allowedProperties) {
Config.allowedProperties = [
{
key: 'instanceUrl',
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && sfdc_1.sfdc.isSalesforceDomain(value)),
failedMessage: Config.messages.getMessage('InvalidInstanceUrl'),
},
},
{
key: Config.API_VERSION,
hidden: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && sfdc_1.sfdc.validateApiVersion(value)),
failedMessage: Config.messages.getMessage('InvalidApiVersion'),
},
},
{ key: Config.DEFAULT_DEV_HUB_USERNAME },
{ key: Config.DEFAULT_USERNAME },
{
key: Config.ISV_DEBUGGER_SID,
encrypted: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || ts_types_1.isString(value),
failedMessage: Config.messages.getMessage('InvalidIsvDebuggerSid'),
},
},
{
key: Config.ISV_DEBUGGER_URL,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || ts_types_1.isString(value),
failedMessage: Config.messages.getMessage('InvalidIsvDebuggerUrl'),
},
},
{
key: Config.DISABLE_TELEMETRY,
input: {
validator: (value) => value == null || ['true', 'false'].includes(value.toString()),
failedMessage: Config.messages.getMessage('InvalidBooleanConfigValue'),
},
},
// This should be brought in by a plugin, but there isn't a way to do that right now.
{
key: 'restDeploy',
hidden: true,
input: {
validator: (value) => value != null && ['true', 'false'].includes(value.toString()),
failedMessage: Config.messages.getMessage('InvalidBooleanConfigValue'),
},
},
{
key: Config.MAX_QUERY_LIMIT,
input: {
validator: (value) => ts_types_1.isNumber(value),
failedMessage: Config.messages.getMessage('InvalidNumberConfigValue'),
},
},
];
}
Config.propertyConfigMap = kit_1.keyBy(Config.allowedProperties, 'key');
// Resolve the config path on creation.
this.getPath();
}
static get propertyConfigMap() {
return kit_1.keyBy(Config.allowedProperties, 'key');
}
/**

@@ -116,11 +57,23 @@ * Returns the default file name for a config file.

/**
* Returns an object representing the supported allowed properties.
* Returns an array of objects representing the allowed config properties.
*/
static getAllowedProperties() {
if (!Config.allowedProperties) {
throw new sfdxError_1.SfdxError('Config meta information has not been initialized. Use Config.create()');
}
return Config.allowedProperties;
}
/**
* Add an array of allowed config properties.
*
* @param metas Array of objects to set as the allowed config properties.
*/
static addAllowedProperties(metas) {
const currentMetaKeys = Object.keys(Config.propertyConfigMap);
metas.forEach((meta) => {
if (currentMetaKeys.includes(meta.key)) {
log.info(`Key ${meta.key} already exists in allowedProperties, skipping.`);
return;
}
Config.allowedProperties.push(meta);
});
}
/**
* Gets default options.

@@ -215,2 +168,3 @@ *

set(key, value) {
var _a;
const property = Config.allowedProperties.find((allowedProp) => allowedProp.key === key);

@@ -225,3 +179,5 @@ if (!property) {

else {
throw sfdxError_1.SfdxError.create('@salesforce/core', 'config', 'InvalidConfigValue', [property.input.failedMessage]);
throw sfdxError_1.SfdxError.create('@salesforce/core', 'config', 'InvalidConfigValue', [
(_a = property.input.failedMessage) !== null && _a !== void 0 ? _a : '',
]);
}

@@ -335,2 +291,84 @@ }

Config.MAX_QUERY_LIMIT = 'maxQueryLimit';
Config.allowedProperties = [
{
key: 'instanceUrl',
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && sfdc_1.sfdc.isSalesforceDomain(value)),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidInstanceUrl');
},
},
},
{
key: Config.API_VERSION,
hidden: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && sfdc_1.sfdc.validateApiVersion(value)),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidApiVersion');
},
},
},
{ key: Config.DEFAULT_DEV_HUB_USERNAME },
{ key: Config.DEFAULT_USERNAME },
{
key: Config.ISV_DEBUGGER_SID,
encrypted: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || ts_types_1.isString(value),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidIsvDebuggerSid');
},
},
},
{
key: Config.ISV_DEBUGGER_URL,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || ts_types_1.isString(value),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidIsvDebuggerUrl');
},
},
},
{
key: Config.DISABLE_TELEMETRY,
input: {
validator: (value) => value == null || ['true', 'false'].includes(value.toString()),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidBooleanConfigValue');
},
},
},
// This should be brought in by a plugin, but there isn't a way to do that right now.
{
key: 'restDeploy',
hidden: true,
input: {
validator: (value) => value != null && ['true', 'false'].includes(value.toString()),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidBooleanConfigValue');
},
},
},
{
key: Config.MAX_QUERY_LIMIT,
input: {
validator: (value) => ts_types_1.isNumber(value),
get failedMessage() {
var _a;
return (_a = Config.messages) === null || _a === void 0 ? void 0 : _a.getMessage('InvalidNumberConfigValue');
},
},
},
];
//# sourceMappingURL=config.js.map
{
"name": "@salesforce/core",
"version": "2.14.0",
"version": "2.15.0",
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",

@@ -5,0 +5,0 @@ "main": "lib/exported",

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