@bitfab/sdk 0.36.5 → 0.36.6

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.
@@ -16,7 +16,7 @@ import {
16
16
  toJsonSafe,
17
17
  toJsonSafeReport,
18
18
  warnOnce
19
- } from "./chunk-FLP6CNRE.js";
19
+ } from "./chunk-ENOQ2K2H.js";
20
20
 
21
21
  // src/processorPayload.ts
22
22
  var SERIALIZATION_DEGRADED_STEP = "serialization_degraded";
@@ -3371,7 +3371,7 @@ var Bitfab = class {
3371
3371
  `Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
3372
3372
  );
3373
3373
  }
3374
- const { replay: doReplay } = await import("./replay-JGMOJEW2.js");
3374
+ const { replay: doReplay } = await import("./replay-A757QXXM.js");
3375
3375
  return doReplay(
3376
3376
  this.httpClient,
3377
3377
  this.serviceUrl,
@@ -3609,4 +3609,4 @@ export {
3609
3609
  BitfabFunction,
3610
3610
  finalizers
3611
3611
  };
3612
- //# sourceMappingURL=chunk-IYHBVIPJ.js.map
3612
+ //# sourceMappingURL=chunk-BXWUPEC4.js.map
@@ -278,7 +278,7 @@ function encodeRequestBody(body) {
278
278
  }
279
279
 
280
280
  // src/version.generated.ts
281
- var __version__ = "0.36.5";
281
+ var __version__ = "0.36.6";
282
282
 
283
283
  // src/constants.ts
284
284
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -2255,12 +2255,13 @@ function sleep(ms) {
2255
2255
  unrefTimer(timer);
2256
2256
  });
2257
2257
  }
2258
- async function mapWithConcurrency2(tasks, maxConcurrency, onSettled) {
2258
+ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted) {
2259
2259
  const results = new Array(tasks.length);
2260
2260
  let nextIndex = 0;
2261
2261
  async function worker() {
2262
2262
  while (nextIndex < tasks.length) {
2263
2263
  const index = nextIndex++;
2264
+ onStarted?.(index);
2264
2265
  const result = await tasks[index]();
2265
2266
  results[index] = result;
2266
2267
  onSettled?.(result, index);
@@ -2347,13 +2348,15 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2347
2348
  )
2348
2349
  );
2349
2350
  const total = tasks.length;
2351
+ const onItemFinish = options?.onItemFinish ?? options?.onProgress;
2350
2352
  let completed = 0;
2353
+ let started = 0;
2351
2354
  let succeeded = 0;
2352
2355
  let errored = 0;
2353
2356
  const resultItems = await mapWithConcurrency2(
2354
2357
  tasks,
2355
2358
  maxConcurrency,
2356
- options?.onProgress ? (item) => {
2359
+ (item) => {
2357
2360
  completed += 1;
2358
2361
  if (item.error === null) {
2359
2362
  succeeded += 1;
@@ -2361,18 +2364,17 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2361
2364
  errored += 1;
2362
2365
  }
2363
2366
  try {
2364
- options?.onProgress?.({
2367
+ onItemFinish?.({
2365
2368
  testRunId,
2366
2369
  completed,
2367
2370
  total,
2368
2371
  succeeded,
2369
2372
  errored,
2370
2373
  item: {
2371
- // The server replay trace id isn't known until completeReplay
2372
- // runs (below), so it can't be reported mid-run and we never
2373
- // emit the client-side placeholder. originalTraceId (the
2374
- // historical trace) is known now and is what a UI keys on to
2375
- // identify what just settled.
2374
+ // The server replay trace id isn't known until completeReplay runs
2375
+ // (below), so it can't be reported mid-run and we never emit the
2376
+ // client-side placeholder. originalTraceId (the historical trace)
2377
+ // is known now and is what a UI keys on to identify what settled.
2376
2378
  traceId: null,
2377
2379
  originalTraceId: item.originalTraceId ?? null,
2378
2380
  originalSpanId: item.originalSpanId ?? null,
@@ -2393,6 +2395,30 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2393
2395
  });
2394
2396
  } catch {
2395
2397
  }
2398
+ },
2399
+ options?.onItemStart ? (index) => {
2400
+ started += 1;
2401
+ const serverItem = serverItems[index];
2402
+ const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
2403
+ const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
2404
+ try {
2405
+ options.onItemStart?.({
2406
+ type: "started",
2407
+ testRunId,
2408
+ started,
2409
+ completed,
2410
+ total,
2411
+ succeeded,
2412
+ errored,
2413
+ item: {
2414
+ originalTraceId,
2415
+ originalSpanId,
2416
+ sourceTraceId: originalTraceId,
2417
+ sourceSpanId: originalSpanId
2418
+ }
2419
+ });
2420
+ } catch {
2421
+ }
2396
2422
  } : void 0
2397
2423
  );
2398
2424
  await preserveReplayFailure(
@@ -2455,17 +2481,19 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2455
2481
  testRunUrl: fullTestRunUrl
2456
2482
  };
2457
2483
  await writeReplayResultFile(result);
2458
- try {
2459
- options?.onProgress?.({
2460
- type: "complete",
2461
- testRunId,
2462
- completed: total,
2463
- total,
2464
- succeeded,
2465
- errored,
2466
- result
2467
- });
2468
- } catch {
2484
+ if (!options?.onItemFinish) {
2485
+ try {
2486
+ options?.onProgress?.({
2487
+ type: "complete",
2488
+ testRunId,
2489
+ completed: total,
2490
+ total,
2491
+ succeeded,
2492
+ errored,
2493
+ result
2494
+ });
2495
+ } catch {
2496
+ }
2469
2497
  }
2470
2498
  return result;
2471
2499
  }
@@ -2521,4 +2549,4 @@ export {
2521
2549
  serializeReplayResult,
2522
2550
  replay
2523
2551
  };
2524
- //# sourceMappingURL=chunk-FLP6CNRE.js.map
2552
+ //# sourceMappingURL=chunk-ENOQ2K2H.js.map