@salesforce/core-bundle 8.16.0 → 8.17.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 +43 -1
- package/lib/index.js +31 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
@@ -1698,6 +1698,7 @@ declare module '@salesforce/core-bundle/index' {
|
|
1698
1698
|
export { ScratchOrgCache } from '@salesforce/core-bundle/org/scratchOrgCache';
|
1699
1699
|
export { default as ScratchOrgSettingsGenerator } from '@salesforce/core-bundle/org/scratchOrgSettingsGenerator';
|
1700
1700
|
export * from '@salesforce/core-bundle/util/sfdc';
|
1701
|
+
export * from '@salesforce/core-bundle/util/mutex';
|
1701
1702
|
export * from '@salesforce/core-bundle/testSetup';
|
1702
1703
|
|
1703
1704
|
}
|
@@ -6387,11 +6388,52 @@ declare module '@salesforce/core-bundle/util/mapKeys' {
|
|
6387
6388
|
}
|
6388
6389
|
declare module '@salesforce/core-bundle/util/mutex' {
|
6389
6390
|
/**
|
6390
|
-
*
|
6391
|
+
* A mutual exclusion (mutex) class that ensures only one asynchronous operation
|
6392
|
+
* can execute at a time, providing thread-safe execution of critical sections.
|
6393
|
+
*
|
6394
|
+
* @example
|
6395
|
+
* ```typescript
|
6396
|
+
* const mutex = new Mutex();
|
6397
|
+
*
|
6398
|
+
* // Only one of these will execute at a time
|
6399
|
+
* mutex.lock(async () => {
|
6400
|
+
* // Critical section code here
|
6401
|
+
* return someAsyncOperation();
|
6402
|
+
* });
|
6403
|
+
* ```
|
6391
6404
|
*/
|
6392
6405
|
export class Mutex {
|
6406
|
+
/**
|
6407
|
+
* Internal promise chain that maintains the mutex state.
|
6408
|
+
* Each new lock acquisition is chained to this promise.
|
6409
|
+
*
|
6410
|
+
* @private
|
6411
|
+
*/
|
6393
6412
|
private mutex;
|
6413
|
+
/**
|
6414
|
+
* Acquires the mutex lock and executes the provided function.
|
6415
|
+
* The function will not execute until all previously queued operations complete.
|
6416
|
+
*
|
6417
|
+
* @template T - The return type of the function
|
6418
|
+
* @param fn - The function to execute while holding the mutex lock. Can be synchronous or asynchronous.
|
6419
|
+
* @returns A promise that resolves with the result of the function execution
|
6420
|
+
*
|
6421
|
+
* @example
|
6422
|
+
* ```typescript
|
6423
|
+
* const result = await mutex.lock(async () => {
|
6424
|
+
* // This code is guaranteed to run exclusively
|
6425
|
+
* return await someAsyncOperation();
|
6426
|
+
* });
|
6427
|
+
* ```
|
6428
|
+
*/
|
6394
6429
|
lock<T>(fn: () => Promise<T> | T): Promise<T>;
|
6430
|
+
/**
|
6431
|
+
* Acquires the mutex by waiting for the current promise chain to resolve
|
6432
|
+
* and returns a release function to unlock the mutex.
|
6433
|
+
*
|
6434
|
+
* @private
|
6435
|
+
* @returns A promise that resolves to a function that releases the mutex lock
|
6436
|
+
*/
|
6395
6437
|
private acquire;
|
6396
6438
|
}
|
6397
6439
|
|
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.17.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",
|
@@ -15858,7 +15858,29 @@ var require_mutex = __commonJS({
|
|
15858
15858
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
15859
15859
|
exports2.Mutex = void 0;
|
15860
15860
|
var Mutex = class {
|
15861
|
+
/**
|
15862
|
+
* Internal promise chain that maintains the mutex state.
|
15863
|
+
* Each new lock acquisition is chained to this promise.
|
15864
|
+
*
|
15865
|
+
* @private
|
15866
|
+
*/
|
15861
15867
|
mutex = Promise.resolve();
|
15868
|
+
/**
|
15869
|
+
* Acquires the mutex lock and executes the provided function.
|
15870
|
+
* The function will not execute until all previously queued operations complete.
|
15871
|
+
*
|
15872
|
+
* @template T - The return type of the function
|
15873
|
+
* @param fn - The function to execute while holding the mutex lock. Can be synchronous or asynchronous.
|
15874
|
+
* @returns A promise that resolves with the result of the function execution
|
15875
|
+
*
|
15876
|
+
* @example
|
15877
|
+
* ```typescript
|
15878
|
+
* const result = await mutex.lock(async () => {
|
15879
|
+
* // This code is guaranteed to run exclusively
|
15880
|
+
* return await someAsyncOperation();
|
15881
|
+
* });
|
15882
|
+
* ```
|
15883
|
+
*/
|
15862
15884
|
async lock(fn) {
|
15863
15885
|
const unlock = await this.acquire();
|
15864
15886
|
try {
|
@@ -15867,6 +15889,13 @@ var require_mutex = __commonJS({
|
|
15867
15889
|
unlock();
|
15868
15890
|
}
|
15869
15891
|
}
|
15892
|
+
/**
|
15893
|
+
* Acquires the mutex by waiting for the current promise chain to resolve
|
15894
|
+
* and returns a release function to unlock the mutex.
|
15895
|
+
*
|
15896
|
+
* @private
|
15897
|
+
* @returns A promise that resolves to a function that releases the mutex lock
|
15898
|
+
*/
|
15870
15899
|
async acquire() {
|
15871
15900
|
let release;
|
15872
15901
|
const promise = new Promise((resolve) => {
|
@@ -123365,6 +123394,7 @@ Object.defineProperty(exports, "ScratchOrgSettingsGenerator", { enumerable: true
|
|
123365
123394
|
return __importDefault2(scratchOrgSettingsGenerator_1).default;
|
123366
123395
|
} });
|
123367
123396
|
__exportStar2(require_sfdc(), exports);
|
123397
|
+
__exportStar2(require_mutex(), exports);
|
123368
123398
|
__exportStar2(require_testSetup(), exports);
|
123369
123399
|
/*! Bundled license information:
|
123370
123400
|
|