@salesforce/core
Advanced tools
Comparing version
@@ -57,4 +57,5 @@ import { AsyncOptionalCreatable } from '@salesforce/kit'; | ||
export declare class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggregator.Options> { | ||
protected static instance: AsyncOptionalCreatable; | ||
protected static encrypted: boolean; | ||
protected static instance: AsyncOptionalCreatable | undefined; | ||
private static readonly mutex; | ||
private allowedProperties; | ||
@@ -73,2 +74,8 @@ private readonly localConfig?; | ||
/** | ||
* Clear the cache to force reading from disk. | ||
* | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
*/ | ||
static clearInstance(): Promise<void>; | ||
/** | ||
* Get the info for a given key. If the ConfigAggregator was not asynchronously created OR | ||
@@ -75,0 +82,0 @@ * the {@link ConfigAggregator.reload} was not called, the config value may be encrypted. |
@@ -14,2 +14,3 @@ "use strict"; | ||
const lifecycleEvents_1 = require("../lifecycleEvents"); | ||
const mutex_1 = require("../util/mutex"); | ||
const envVars_1 = require("./envVars"); | ||
@@ -35,4 +36,5 @@ const config_1 = require("./config"); | ||
class ConfigAggregator extends kit_1.AsyncOptionalCreatable { | ||
static encrypted = true; | ||
static instance; | ||
static encrypted = true; | ||
static mutex = new mutex_1.Mutex(); | ||
// Initialized in loadProperties | ||
@@ -69,16 +71,30 @@ allowedProperties; | ||
static async create(options) { | ||
let config = ConfigAggregator.instance; | ||
if (!config) { | ||
config = ConfigAggregator.instance = new this(options); | ||
await config.init(); | ||
} | ||
if (ConfigAggregator.encrypted) { | ||
await config.loadProperties(); | ||
} | ||
if (options?.customConfigMeta) { | ||
config_1.Config.addAllowedProperties(options.customConfigMeta); | ||
} | ||
return ConfigAggregator.instance; | ||
return ConfigAggregator.mutex.lock(async () => { | ||
let config = ConfigAggregator.instance; | ||
if (!config) { | ||
config = ConfigAggregator.instance = new this(options); | ||
await config.init(); | ||
} | ||
if (ConfigAggregator.encrypted) { | ||
await config.loadProperties(); | ||
} | ||
if (options?.customConfigMeta) { | ||
config_1.Config.addAllowedProperties(options.customConfigMeta); | ||
} | ||
// console.log(ConfigAggregator.instance); | ||
return ConfigAggregator.instance; | ||
}); | ||
} | ||
/** | ||
* Clear the cache to force reading from disk. | ||
* | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
*/ | ||
static async clearInstance() { | ||
return ConfigAggregator.mutex.lock(() => { | ||
ConfigAggregator.instance = undefined; | ||
ConfigAggregator.encrypted = true; // Reset encryption flag as well | ||
}); | ||
} | ||
/** | ||
* Get the info for a given key. If the ConfigAggregator was not asynchronously created OR | ||
@@ -85,0 +101,0 @@ * the {@link ConfigAggregator.reload} was not called, the config value may be encrypted. |
@@ -262,4 +262,2 @@ import { AsyncOptionalCreatable } from '@salesforce/kit'; | ||
* Get the org front door (used for web based oauth flows) | ||
* | ||
* @deprecated Will be removed in the next major version. Use the `Org.getFrontDoorUrl()` method instead. | ||
*/ | ||
@@ -266,0 +264,0 @@ getOrgFrontDoorUrl(): string; |
@@ -548,4 +548,2 @@ "use strict"; | ||
* Get the org front door (used for web based oauth flows) | ||
* | ||
* @deprecated Will be removed in the next major version. Use the `Org.getFrontDoorUrl()` method instead. | ||
*/ | ||
@@ -552,0 +550,0 @@ getOrgFrontDoorUrl() { |
@@ -156,35 +156,2 @@ import { AsyncOptionalCreatable, Duration } from '@salesforce/kit'; | ||
/** | ||
* Generate a URL to a metadata UI builder/setup section in an org. | ||
* | ||
* Bot: open in Agentforce Builder | ||
* ApexPage: opens page | ||
* Flow: open in Flow Builder | ||
* FlexiPage: open in Lightning App Builder | ||
* CustomObject: open in Object Manager | ||
* ApexClass: open in Setup -> Apex Classes UI | ||
* | ||
* if you pass any other metadata type you'll get a path to Lightning App Builder | ||
* | ||
* @example | ||
* // use SDR resolver: | ||
* import { MetadataResolver } from '@salesforce/source-deploy-retrieve'; | ||
* | ||
* const metadataResolver = new MetadataResolver(); | ||
* const components = metadataResolver.getComponentsFromPath(filePath); | ||
* const typeName = components[0]?.type?.name; | ||
* | ||
* const metadataBuilderUrl = await org.getMetadataUIURL(typeName, filePath); | ||
* | ||
* @typeName Bot | ApexPage | Flow | FlexiPage | CustomObject | ApexClass | ||
* @file Absolute file path to the metadata file | ||
*/ | ||
getMetadataUIURL(typeName: string, file: string): Promise<string>; | ||
/** | ||
* Get a Frontdoor URL | ||
* | ||
* This uses the UI Bridge API to generate a single-use Frontdoor URL: | ||
* https://help.salesforce.com/s/articleView?id=xcloud.frontdoor_singleaccess.htm&type=5 | ||
*/ | ||
getFrontDoorUrl(redirectUri?: string): Promise<string>; | ||
/** | ||
* create a sandbox from a production org | ||
@@ -191,0 +158,0 @@ * 'this' needs to be a production org with sandbox licenses available |
@@ -7,2 +7,3 @@ import { AsyncOptionalCreatable } from '@salesforce/kit'; | ||
private static instanceMap; | ||
private static readonly mutex; | ||
aliases: AliasAccessor; | ||
@@ -21,5 +22,12 @@ orgs: OrgAccessor; | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
* *NOTE: This call is NOT thread-safe, so it should only be called when no other threads are using the StateAggregator.* | ||
*/ | ||
static clearInstance(path?: string): void; | ||
/** | ||
* Clear the cache to force reading from disk in a thread-safe manner. | ||
* | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
*/ | ||
static clearInstanceAsync(path?: string): Promise<void>; | ||
protected init(): Promise<void>; | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
const global_1 = require("../global"); | ||
const mutex_1 = require("../util/mutex"); | ||
const aliasAccessor_1 = require("./accessors/aliasAccessor"); | ||
@@ -18,2 +19,3 @@ const orgAccessor_1 = require("./accessors/orgAccessor"); | ||
static instanceMap = new Map(); | ||
static mutex = new mutex_1.Mutex(); | ||
aliases; | ||
@@ -28,7 +30,9 @@ orgs; | ||
static async getInstance() { | ||
if (!StateAggregator.instanceMap.has(global_1.Global.DIR)) { | ||
StateAggregator.instanceMap.set(global_1.Global.DIR, await StateAggregator.create()); | ||
} | ||
// TS assertion is valid because there either was one OR it was just now instantiated | ||
return StateAggregator.instanceMap.get(global_1.Global.DIR); | ||
return StateAggregator.mutex.lock(async () => { | ||
if (!StateAggregator.instanceMap.has(global_1.Global.DIR)) { | ||
StateAggregator.instanceMap.set(global_1.Global.DIR, await StateAggregator.create()); | ||
} | ||
// TS assertion is valid because there either was one OR it was just now instantiated | ||
return StateAggregator.instanceMap.get(global_1.Global.DIR); | ||
}); | ||
} | ||
@@ -39,2 +43,3 @@ /** | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
* *NOTE: This call is NOT thread-safe, so it should only be called when no other threads are using the StateAggregator.* | ||
*/ | ||
@@ -44,2 +49,12 @@ static clearInstance(path = global_1.Global.DIR) { | ||
} | ||
/** | ||
* Clear the cache to force reading from disk in a thread-safe manner. | ||
* | ||
* *NOTE: Only call this method if you must and you know what you are doing.* | ||
*/ | ||
static async clearInstanceAsync(path = global_1.Global.DIR) { | ||
return StateAggregator.mutex.lock(() => { | ||
StateAggregator.clearInstance(path); | ||
}); | ||
} | ||
async init() { | ||
@@ -46,0 +61,0 @@ this.orgs = await orgAccessor_1.OrgAccessor.create(); |
@@ -72,17 +72,1 @@ # notADevHub | ||
The sandbox %s cannot resume with status of %s. | ||
# FrontdoorURLError | ||
Failed to generate a frontdoor URL. | ||
# FlowIdNotFound | ||
ID not found for Flow %s. | ||
# CustomObjectIdNotFound | ||
ID not found for custom object %s. | ||
# ApexClassIdNotFound | ||
ID not found for Apex class %s. |
{ | ||
"name": "@salesforce/core", | ||
"version": "8.15.1-dev.0", | ||
"version": "8.16.0", | ||
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.", | ||
@@ -56,3 +56,3 @@ "main": "lib/index", | ||
"dependencies": { | ||
"@jsforce/jsforce-node": "^3.9.1", | ||
"@jsforce/jsforce-node": "^3.8.2", | ||
"@salesforce/kit": "^3.2.2", | ||
@@ -59,0 +59,0 @@ "@salesforce/schemas": "^1.9.0", |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
170
1.19%1
-50%1069689
-0.42%22708
-0.25%Updated