@bitfab/sdk 0.24.1 → 0.25.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/dist/index.cjs CHANGED
@@ -413,13 +413,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
413
413
  dbSnapshotRef: serverItem.dbSnapshotRef ?? null
414
414
  };
415
415
  }
416
- async function mapWithConcurrency(tasks, maxConcurrency) {
416
+ async function mapWithConcurrency(tasks, maxConcurrency, onSettled) {
417
417
  const results = new Array(tasks.length);
418
418
  let nextIndex = 0;
419
419
  async function worker() {
420
420
  while (nextIndex < tasks.length) {
421
421
  const index = nextIndex++;
422
- results[index] = await tasks[index]();
422
+ const result = await tasks[index]();
423
+ results[index] = result;
424
+ onSettled?.(result, index);
423
425
  }
424
426
  }
425
427
  const workers = Array.from(
@@ -479,7 +481,26 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
479
481
  options?.adaptInputs
480
482
  )
481
483
  );
482
- const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
484
+ const total = tasks.length;
485
+ let completed = 0;
486
+ let succeeded = 0;
487
+ let errored = 0;
488
+ const resultItems = await mapWithConcurrency(
489
+ tasks,
490
+ maxConcurrency,
491
+ options?.onProgress ? (item) => {
492
+ completed += 1;
493
+ if (item.error === null) {
494
+ succeeded += 1;
495
+ } else {
496
+ errored += 1;
497
+ }
498
+ try {
499
+ options?.onProgress?.({ completed, total, succeeded, errored });
500
+ } catch {
501
+ }
502
+ } : void 0
503
+ );
483
504
  const completeResult = await httpClient.completeReplay(testRunId);
484
505
  const serverTraceIds = completeResult.traceIds;
485
506
  const replayTokens = completeResult.tokens;
@@ -566,7 +587,7 @@ __export(index_exports, {
566
587
  module.exports = __toCommonJS(index_exports);
567
588
 
568
589
  // src/version.generated.ts
569
- var __version__ = "0.24.1";
590
+ var __version__ = "0.25.0";
570
591
 
571
592
  // src/constants.ts
572
593
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";