@salesforce/core-bundle 8.15.0 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +27 -1
- package/lib/index.js +79 -18
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
@@ -368,8 +368,9 @@ declare module '@salesforce/core-bundle/config/configAggregator' {
|
|
368
368
|
* ```
|
369
369
|
*/
|
370
370
|
export class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggregator.Options> {
|
371
|
-
protected static instance: AsyncOptionalCreatable;
|
372
371
|
protected static encrypted: boolean;
|
372
|
+
protected static instance: AsyncOptionalCreatable | undefined;
|
373
|
+
private static readonly mutex;
|
373
374
|
private allowedProperties;
|
374
375
|
private readonly localConfig?;
|
375
376
|
private readonly globalConfig;
|
@@ -382,6 +383,12 @@ declare module '@salesforce/core-bundle/config/configAggregator' {
|
|
382
383
|
constructor(options?: ConfigAggregator.Options);
|
383
384
|
private get config();
|
384
385
|
static create<P extends ConfigAggregator.Options, T extends AsyncOptionalCreatable<P>>(this: new (options?: P) => T, options?: P): Promise<T>;
|
386
|
+
/**
|
387
|
+
* Clear the cache to force reading from disk.
|
388
|
+
*
|
389
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
390
|
+
*/
|
391
|
+
static clearInstance(): Promise<void>;
|
385
392
|
/**
|
386
393
|
* Get the info for a given key. If the ConfigAggregator was not asynchronously created OR
|
387
394
|
* the {@link ConfigAggregator.reload} was not called, the config value may be encrypted.
|
@@ -5151,6 +5158,7 @@ declare module '@salesforce/core-bundle/stateAggregator/stateAggregator' {
|
|
5151
5158
|
import { SandboxAccessor } from '@salesforce/core-bundle/stateAggregator/accessors/sandboxAccessor';
|
5152
5159
|
export class StateAggregator extends AsyncOptionalCreatable {
|
5153
5160
|
private static instanceMap;
|
5161
|
+
private static readonly mutex;
|
5154
5162
|
aliases: AliasAccessor;
|
5155
5163
|
orgs: OrgAccessor;
|
5156
5164
|
sandboxes: SandboxAccessor;
|
@@ -5164,8 +5172,15 @@ declare module '@salesforce/core-bundle/stateAggregator/stateAggregator' {
|
|
5164
5172
|
* Clear the cache to force reading from disk.
|
5165
5173
|
*
|
5166
5174
|
* *NOTE: Only call this method if you must and you know what you are doing.*
|
5175
|
+
* *NOTE: This call is NOT thread-safe, so it should only be called when no other threads are using the StateAggregator.*
|
5167
5176
|
*/
|
5168
5177
|
static clearInstance(path?: string): void;
|
5178
|
+
/**
|
5179
|
+
* Clear the cache to force reading from disk in a thread-safe manner.
|
5180
|
+
*
|
5181
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
5182
|
+
*/
|
5183
|
+
static clearInstanceAsync(path?: string): Promise<void>;
|
5169
5184
|
protected init(): Promise<void>;
|
5170
5185
|
}
|
5171
5186
|
|
@@ -6369,6 +6384,17 @@ declare module '@salesforce/core-bundle/util/mapKeys' {
|
|
6369
6384
|
*/
|
6370
6385
|
export default function mapKeys<T>(obj: T, converter: (key: string) => string, deep?: boolean): Record<string, unknown>;
|
6371
6386
|
|
6387
|
+
}
|
6388
|
+
declare module '@salesforce/core-bundle/util/mutex' {
|
6389
|
+
/**
|
6390
|
+
* Simple mutex implementation using promises
|
6391
|
+
*/
|
6392
|
+
export class Mutex {
|
6393
|
+
private mutex;
|
6394
|
+
lock<T>(fn: () => Promise<T> | T): Promise<T>;
|
6395
|
+
private acquire;
|
6396
|
+
}
|
6397
|
+
|
6372
6398
|
}
|
6373
6399
|
declare module '@salesforce/core-bundle/util/sfdc' {
|
6374
6400
|
/**
|
package/lib/index.js
CHANGED
@@ -12336,7 +12336,7 @@ var require_package2 = __commonJS({
|
|
12336
12336
|
"package.json"(exports2, module2) {
|
12337
12337
|
module2.exports = {
|
12338
12338
|
name: "@salesforce/core-bundle",
|
12339
|
-
version: "8.
|
12339
|
+
version: "8.16.0",
|
12340
12340
|
description: "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
12341
12341
|
main: "lib/index",
|
12342
12342
|
types: "lib/index.d.ts",
|
@@ -15851,6 +15851,37 @@ var require_envVars = __commonJS({
|
|
15851
15851
|
}
|
15852
15852
|
});
|
15853
15853
|
|
15854
|
+
// lib/util/mutex.js
|
15855
|
+
var require_mutex = __commonJS({
|
15856
|
+
"lib/util/mutex.js"(exports2) {
|
15857
|
+
"use strict";
|
15858
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
15859
|
+
exports2.Mutex = void 0;
|
15860
|
+
var Mutex = class {
|
15861
|
+
mutex = Promise.resolve();
|
15862
|
+
async lock(fn) {
|
15863
|
+
const unlock = await this.acquire();
|
15864
|
+
try {
|
15865
|
+
return await fn();
|
15866
|
+
} finally {
|
15867
|
+
unlock();
|
15868
|
+
}
|
15869
|
+
}
|
15870
|
+
async acquire() {
|
15871
|
+
let release;
|
15872
|
+
const promise = new Promise((resolve) => {
|
15873
|
+
release = resolve;
|
15874
|
+
});
|
15875
|
+
const currentMutex = this.mutex;
|
15876
|
+
this.mutex = this.mutex.then(() => promise);
|
15877
|
+
await currentMutex;
|
15878
|
+
return release;
|
15879
|
+
}
|
15880
|
+
};
|
15881
|
+
exports2.Mutex = Mutex;
|
15882
|
+
}
|
15883
|
+
});
|
15884
|
+
|
15854
15885
|
// lib/stateAggregator/accessors/aliasAccessor.js
|
15855
15886
|
var require_aliasAccessor = __commonJS({
|
15856
15887
|
"lib/stateAggregator/accessors/aliasAccessor.js"(exports2) {
|
@@ -16394,11 +16425,13 @@ var require_stateAggregator = __commonJS({
|
|
16394
16425
|
exports2.StateAggregator = void 0;
|
16395
16426
|
var kit_1 = require_lib2();
|
16396
16427
|
var global_12 = require_global();
|
16428
|
+
var mutex_1 = require_mutex();
|
16397
16429
|
var aliasAccessor_1 = require_aliasAccessor();
|
16398
16430
|
var orgAccessor_1 = require_orgAccessor();
|
16399
16431
|
var sandboxAccessor_1 = require_sandboxAccessor();
|
16400
16432
|
var StateAggregator = class _StateAggregator extends kit_1.AsyncOptionalCreatable {
|
16401
16433
|
static instanceMap = /* @__PURE__ */ new Map();
|
16434
|
+
static mutex = new mutex_1.Mutex();
|
16402
16435
|
aliases;
|
16403
16436
|
orgs;
|
16404
16437
|
sandboxes;
|
@@ -16408,19 +16441,32 @@ var require_stateAggregator = __commonJS({
|
|
16408
16441
|
* HomeDir might be stubbed in tests
|
16409
16442
|
*/
|
16410
16443
|
static async getInstance() {
|
16411
|
-
|
16412
|
-
_StateAggregator.instanceMap.
|
16413
|
-
|
16414
|
-
|
16444
|
+
return _StateAggregator.mutex.lock(async () => {
|
16445
|
+
if (!_StateAggregator.instanceMap.has(global_12.Global.DIR)) {
|
16446
|
+
_StateAggregator.instanceMap.set(global_12.Global.DIR, await _StateAggregator.create());
|
16447
|
+
}
|
16448
|
+
return _StateAggregator.instanceMap.get(global_12.Global.DIR);
|
16449
|
+
});
|
16415
16450
|
}
|
16416
16451
|
/**
|
16417
16452
|
* Clear the cache to force reading from disk.
|
16418
16453
|
*
|
16419
16454
|
* *NOTE: Only call this method if you must and you know what you are doing.*
|
16455
|
+
* *NOTE: This call is NOT thread-safe, so it should only be called when no other threads are using the StateAggregator.*
|
16420
16456
|
*/
|
16421
16457
|
static clearInstance(path = global_12.Global.DIR) {
|
16422
16458
|
_StateAggregator.instanceMap.delete(path);
|
16423
16459
|
}
|
16460
|
+
/**
|
16461
|
+
* Clear the cache to force reading from disk in a thread-safe manner.
|
16462
|
+
*
|
16463
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
16464
|
+
*/
|
16465
|
+
static async clearInstanceAsync(path = global_12.Global.DIR) {
|
16466
|
+
return _StateAggregator.mutex.lock(() => {
|
16467
|
+
_StateAggregator.clearInstance(path);
|
16468
|
+
});
|
16469
|
+
}
|
16424
16470
|
async init() {
|
16425
16471
|
this.orgs = await orgAccessor_1.OrgAccessor.create();
|
16426
16472
|
this.sandboxes = await sandboxAccessor_1.SandboxAccessor.create();
|
@@ -84686,12 +84732,14 @@ var require_configAggregator = __commonJS({
|
|
84686
84732
|
var ts_types_1 = require_lib();
|
84687
84733
|
var messages_12 = require_messages();
|
84688
84734
|
var lifecycleEvents_12 = require_lifecycleEvents();
|
84735
|
+
var mutex_1 = require_mutex();
|
84689
84736
|
var envVars_12 = require_envVars();
|
84690
84737
|
var config_12 = require_config();
|
84691
84738
|
var messages = new messages_12.Messages("@salesforce/core-bundle", "config", /* @__PURE__ */ new Map([["unknownConfigKey", "Unknown config name: %s."], ["deprecatedConfigKey", "Deprecated config name: %s. Please use %s instead."], ["invalidWrite", "The writeSync method is not allowed on SfdxConfig. Use the async write method instead."], ["invalidConfigValue", "Invalid config value: %s."], ["invalidInstanceUrl", "Specify a valid Salesforce instance URL."], ["invalidApiVersion", "Specify a valid Salesforce API version, for example, 42.0."], ["invalidCustomOrgMetadataTemplates", "Specify a valid repository URL or directory for the custom org metadata templates."], ["invalidIsvDebuggerSid", "Specify a valid Debugger SID."], ["invalidIsvDebuggerUrl", "Specify a valid Debugger URL."], ["invalidNumberConfigValue", "Specify a valid positive integer, for example, 150000."], ["invalidBooleanConfigValue", "The config value can only be set to true or false."], ["invalidProjectWorkspace", "This directory does not contain a valid Salesforce DX project."], ["schemaValidationError", 'The config file "%s" is not schema valid.\nDue to: %s'], ["schemaValidationError.actions", ["Fix the invalid entries at %s."]], ["missingDefaultPath", 'In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ "path": "packageDirectory1", "default": true }, { "path": "packageDirectory2" }]`'], ["missingPackageDirectory", 'The path "%s", specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root.'], ["invalidPackageDirectory", 'The path "%s", specified in sfdx-project.json, must be indicated as a relative path to the project root.'], ["multipleDefaultPaths", "In sfdx-project.json, indicate only one package directory (path) as the default."], ["singleNonDefaultPackage", 'The sfdx-project.json file must include one, and only one, default package directory (path). Because your sfdx-project.json file contains only one package directory, it must be the default. Remove the `"default": false` key and try again.'], ["target-org", "Username or alias of the org that all commands run against by default. (sf only)"], ["target-dev-hub", "Username or alias of your default Dev Hub org. (sf only)"], ["defaultUsername", "Username or alias of the org that all commands run against by default. (sfdx only)"], ["defaultDevHubUsername", "Username or alias of your default Dev Hub org. (sfdx only)"], ["isvDebuggerSid", "ISV debugger SID (sfdx only)"], ["isvDebuggerUrl", "ISV debugger URL (sfdx only)"], ["org-isv-debugger-sid", "ISV debugger SID."], ["org-isv-debugger-url", "ISV debugger URL."], ["apiVersion", "API version of your project. Default: API version of your Dev Hub org. (sfdx only)"], ["org-api-version", "API version of your project. Default: API version of your Dev Hub org."], ["disableTelemetry", "Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)"], ["disable-telemetry", "Disables the collection of usage and user environment information, etc. Default: false."], ["maxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)"], ["org-max-query-limit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000."], ["restDeploy", "Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)"], ["instanceUrl", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)"], ["org-instance-url", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com."], ["customOrgMetadataTemplates", "A valid repository URL or directory for the custom org metadata templates."], ["org-custom-metadata-templates", "A valid repository URL or directory for the custom org metadata templates."], ["org-capitalize-record-types", "Whether record types are capitalized on scratch org creation."], ["invalidId", "The given id %s is not a valid 15 or 18 character Salesforce ID."]]));
|
84692
84739
|
var ConfigAggregator = class _ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
84693
|
-
static instance;
|
84694
84740
|
static encrypted = true;
|
84741
|
+
static instance;
|
84742
|
+
static mutex = new mutex_1.Mutex();
|
84695
84743
|
// Initialized in loadProperties
|
84696
84744
|
allowedProperties;
|
84697
84745
|
localConfig;
|
@@ -84720,18 +84768,31 @@ var require_configAggregator = __commonJS({
|
|
84720
84768
|
// Use typing from AsyncOptionalCreatable to support extending ConfigAggregator.
|
84721
84769
|
// We really don't want ConfigAggregator extended but typescript doesn't support a final.
|
84722
84770
|
static async create(options) {
|
84723
|
-
|
84724
|
-
|
84725
|
-
|
84726
|
-
|
84727
|
-
|
84728
|
-
|
84729
|
-
|
84730
|
-
|
84731
|
-
|
84732
|
-
|
84733
|
-
|
84734
|
-
|
84771
|
+
return _ConfigAggregator.mutex.lock(async () => {
|
84772
|
+
let config = _ConfigAggregator.instance;
|
84773
|
+
if (!config) {
|
84774
|
+
config = _ConfigAggregator.instance = new this(options);
|
84775
|
+
await config.init();
|
84776
|
+
}
|
84777
|
+
if (_ConfigAggregator.encrypted) {
|
84778
|
+
await config.loadProperties();
|
84779
|
+
}
|
84780
|
+
if (options?.customConfigMeta) {
|
84781
|
+
config_12.Config.addAllowedProperties(options.customConfigMeta);
|
84782
|
+
}
|
84783
|
+
return _ConfigAggregator.instance;
|
84784
|
+
});
|
84785
|
+
}
|
84786
|
+
/**
|
84787
|
+
* Clear the cache to force reading from disk.
|
84788
|
+
*
|
84789
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
84790
|
+
*/
|
84791
|
+
static async clearInstance() {
|
84792
|
+
return _ConfigAggregator.mutex.lock(() => {
|
84793
|
+
_ConfigAggregator.instance = void 0;
|
84794
|
+
_ConfigAggregator.encrypted = true;
|
84795
|
+
});
|
84735
84796
|
}
|
84736
84797
|
/**
|
84737
84798
|
* Get the info for a given key. If the ConfigAggregator was not asynchronously created OR
|