bitfab 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
@@ -422,13 +422,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
422
422
  dbSnapshotRef: serverItem.dbSnapshotRef ?? null
423
423
  };
424
424
  }
425
- async function mapWithConcurrency(tasks, maxConcurrency) {
425
+ async function mapWithConcurrency(tasks, maxConcurrency, onSettled) {
426
426
  const results = new Array(tasks.length);
427
427
  let nextIndex = 0;
428
428
  async function worker() {
429
429
  while (nextIndex < tasks.length) {
430
430
  const index = nextIndex++;
431
- results[index] = await tasks[index]();
431
+ const result = await tasks[index]();
432
+ results[index] = result;
433
+ onSettled?.(result, index);
432
434
  }
433
435
  }
434
436
  const workers = Array.from(
@@ -488,7 +490,26 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
488
490
  options?.adaptInputs
489
491
  )
490
492
  );
491
- const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
493
+ const total = tasks.length;
494
+ let completed = 0;
495
+ let succeeded = 0;
496
+ let errored = 0;
497
+ const resultItems = await mapWithConcurrency(
498
+ tasks,
499
+ maxConcurrency,
500
+ options?.onProgress ? (item) => {
501
+ completed += 1;
502
+ if (item.error === null) {
503
+ succeeded += 1;
504
+ } else {
505
+ errored += 1;
506
+ }
507
+ try {
508
+ options?.onProgress?.({ completed, total, succeeded, errored });
509
+ } catch {
510
+ }
511
+ } : void 0
512
+ );
492
513
  const completeResult = await httpClient.completeReplay(testRunId);
493
514
  const serverTraceIds = completeResult.traceIds;
494
515
  const replayTokens = completeResult.tokens;
@@ -575,7 +596,7 @@ __export(index_exports, {
575
596
  module.exports = __toCommonJS(index_exports);
576
597
 
577
598
  // src/version.generated.ts
578
- var __version__ = "0.24.1";
599
+ var __version__ = "0.25.0";
579
600
 
580
601
  // src/constants.ts
581
602
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";