@salesforce/core-bundle 8.14.1 → 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 +41 -1
- package/lib/index.js +119 -19
- 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.
|
@@ -3070,6 +3077,11 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3070
3077
|
import { Connection } from '@salesforce/core-bundle/org/connection';
|
3071
3078
|
import { AuthFields, AuthInfo } from '@salesforce/core-bundle/org/authInfo';
|
3072
3079
|
import { ScratchOrgCreateOptions, ScratchOrgCreateResult } from '@salesforce/core-bundle/org/scratchOrgCreate';
|
3080
|
+
export type XOR<T, U> = (T & {
|
3081
|
+
[K in keyof U]?: never;
|
3082
|
+
}) | (U & {
|
3083
|
+
[K in keyof T]?: never;
|
3084
|
+
});
|
3073
3085
|
export type OrganizationInformation = {
|
3074
3086
|
Name: string;
|
3075
3087
|
InstanceName: string;
|
@@ -3124,6 +3136,7 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3124
3136
|
Description?: string;
|
3125
3137
|
ApexClassId?: string;
|
3126
3138
|
EndDate?: string;
|
3139
|
+
Features?: string[];
|
3127
3140
|
};
|
3128
3141
|
export type SandboxRequest = {
|
3129
3142
|
SandboxName: string;
|
@@ -3133,6 +3146,7 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3133
3146
|
Description?: string;
|
3134
3147
|
ApexClassId?: string;
|
3135
3148
|
ActivationUserGroupId?: string;
|
3149
|
+
Features?: string[];
|
3136
3150
|
};
|
3137
3151
|
export type ResumeSandboxRequest = {
|
3138
3152
|
SandboxName?: string;
|
@@ -3156,6 +3170,7 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3156
3170
|
SourceId?: string;
|
3157
3171
|
ActivationUserGroupId?: string;
|
3158
3172
|
CopyArchivedActivities?: boolean;
|
3173
|
+
Features?: string[];
|
3159
3174
|
};
|
3160
3175
|
export type ScratchOrgRequest = Omit<ScratchOrgCreateOptions, 'hubOrg'>;
|
3161
3176
|
export type SandboxFields = {
|
@@ -3167,6 +3182,11 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3167
3182
|
sandboxInfoId?: string;
|
3168
3183
|
timestamp?: string;
|
3169
3184
|
};
|
3185
|
+
export type SandboxInfoQueryFields = XOR<{
|
3186
|
+
name: string;
|
3187
|
+
}, {
|
3188
|
+
id: string;
|
3189
|
+
}>;
|
3170
3190
|
/**
|
3171
3191
|
* Provides a way to manage a locally authenticated Org.
|
3172
3192
|
*
|
@@ -3378,6 +3398,7 @@ declare module '@salesforce/core-bundle/org/org' {
|
|
3378
3398
|
* @returns org information
|
3379
3399
|
*/
|
3380
3400
|
retrieveOrganizationInformation(): Promise<OrganizationInformation>;
|
3401
|
+
querySandboxInfo(by: SandboxInfoQueryFields): Promise<SandboxInfo>;
|
3381
3402
|
/**
|
3382
3403
|
* Some organization information is locally cached, such as if the org name or if it is a scratch org.
|
3383
3404
|
* This method populates/updates the filesystem from information retrieved from the org.
|
@@ -5137,6 +5158,7 @@ declare module '@salesforce/core-bundle/stateAggregator/stateAggregator' {
|
|
5137
5158
|
import { SandboxAccessor } from '@salesforce/core-bundle/stateAggregator/accessors/sandboxAccessor';
|
5138
5159
|
export class StateAggregator extends AsyncOptionalCreatable {
|
5139
5160
|
private static instanceMap;
|
5161
|
+
private static readonly mutex;
|
5140
5162
|
aliases: AliasAccessor;
|
5141
5163
|
orgs: OrgAccessor;
|
5142
5164
|
sandboxes: SandboxAccessor;
|
@@ -5150,8 +5172,15 @@ declare module '@salesforce/core-bundle/stateAggregator/stateAggregator' {
|
|
5150
5172
|
* Clear the cache to force reading from disk.
|
5151
5173
|
*
|
5152
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.*
|
5153
5176
|
*/
|
5154
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>;
|
5155
5184
|
protected init(): Promise<void>;
|
5156
5185
|
}
|
5157
5186
|
|
@@ -6355,6 +6384,17 @@ declare module '@salesforce/core-bundle/util/mapKeys' {
|
|
6355
6384
|
*/
|
6356
6385
|
export default function mapKeys<T>(obj: T, converter: (key: string) => string, deep?: boolean): Record<string, unknown>;
|
6357
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
|
+
|
6358
6398
|
}
|
6359
6399
|
declare module '@salesforce/core-bundle/util/sfdc' {
|
6360
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
|
@@ -107779,7 +107840,27 @@ var require_org = __commonJS({
|
|
107779
107840
|
"SandboxOrganization",
|
107780
107841
|
"SourceId",
|
107781
107842
|
"Description",
|
107782
|
-
"EndDate"
|
107843
|
+
"EndDate",
|
107844
|
+
"Features"
|
107845
|
+
];
|
107846
|
+
var sandboxInfoFields = [
|
107847
|
+
"Id",
|
107848
|
+
"IsDeleted",
|
107849
|
+
"CreatedDate",
|
107850
|
+
"CreatedById",
|
107851
|
+
"LastModifiedDate",
|
107852
|
+
"LastModifiedById",
|
107853
|
+
"SandboxName",
|
107854
|
+
"LicenseType",
|
107855
|
+
"TemplateId",
|
107856
|
+
"HistoryDays",
|
107857
|
+
"CopyChatter",
|
107858
|
+
"AutoActivate",
|
107859
|
+
"ApexClassId",
|
107860
|
+
"Description",
|
107861
|
+
"SourceId",
|
107862
|
+
"ActivationUserGroupId",
|
107863
|
+
"Features"
|
107783
107864
|
];
|
107784
107865
|
var Org = class _Org extends kit_1.AsyncOptionalCreatable {
|
107785
107866
|
status = _Org.Status.UNKNOWN;
|
@@ -108224,6 +108305,25 @@ var require_org = __commonJS({
|
|
108224
108305
|
async retrieveOrganizationInformation() {
|
108225
108306
|
return this.getConnection().singleRecordQuery("SELECT Name, InstanceName, IsSandbox, TrialExpirationDate, NamespacePrefix FROM Organization");
|
108226
108307
|
}
|
108308
|
+
async querySandboxInfo(by) {
|
108309
|
+
if (by.id) {
|
108310
|
+
if (!(0, sfdc_1.validateSalesforceId)(by.id)) {
|
108311
|
+
throw new sfError_12.SfError(`Invalid Salesforce ID format: ${by.id}`, "InvalidSalesforceId");
|
108312
|
+
}
|
108313
|
+
}
|
108314
|
+
const whereClause = by.id ? `Id='${by.id}'` : `SandboxName='${by.name}'`;
|
108315
|
+
const soql = `SELECT ${sandboxInfoFields.join(",")} FROM SandboxInfo WHERE ${whereClause} ORDER BY CreatedDate DESC`;
|
108316
|
+
const result = (await this.connection.tooling.query(soql)).records.filter((item) => !item.IsDeleted);
|
108317
|
+
if (result.length === 0) {
|
108318
|
+
throw new sfError_12.SfError(`No record found for ${soql}`, connection_12.SingleRecordQueryErrors.NoRecords);
|
108319
|
+
}
|
108320
|
+
if (result.length > 1) {
|
108321
|
+
const err = new sfError_12.SfError("The query returned more than 1 record", connection_12.SingleRecordQueryErrors.MultipleRecords);
|
108322
|
+
err.data = result;
|
108323
|
+
throw err;
|
108324
|
+
}
|
108325
|
+
return result[0];
|
108326
|
+
}
|
108227
108327
|
/**
|
108228
108328
|
* Some organization information is locally cached, such as if the org name or if it is a scratch org.
|
108229
108329
|
* This method populates/updates the filesystem from information retrieved from the org.
|