@bitfab/sdk 0.36.13 → 0.38.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
@@ -42,7 +42,7 @@ var __version__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.36.13";
45
+ __version__ = "0.38.0";
46
46
  }
47
47
  });
48
48
 
@@ -2525,12 +2525,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2525
2525
  let lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
2526
2526
  let leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
2527
2527
  let dbSnapshotRef = serverItem.dbSnapshotRef;
2528
+ let dbBranchTimings = includeDbBranchLease ? serverItem.dbBranchTimings : void 0;
2528
2529
  let inputs = [];
2529
2530
  let originalOutput;
2530
2531
  let result;
2531
2532
  let error = null;
2532
2533
  let traceError = null;
2533
2534
  let replayError = null;
2535
+ let replayDurationMs = null;
2536
+ let replayStarted = null;
2534
2537
  const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
2535
2538
  const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
2536
2539
  try {
@@ -2553,6 +2556,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2553
2556
  lease = resolved.lease ?? void 0;
2554
2557
  leaseError = resolved.leaseError ?? void 0;
2555
2558
  dbSnapshotRef = resolved.dbSnapshotRef ?? dbSnapshotRef;
2559
+ dbBranchTimings = resolved.timings ?? dbBranchTimings;
2556
2560
  }
2557
2561
  if (leaseError) {
2558
2562
  throw new DbBranchReplayError(
@@ -2613,6 +2617,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2613
2617
  return pending;
2614
2618
  } : void 0;
2615
2619
  try {
2620
+ replayStarted = performance.now();
2616
2621
  const maybePromise = runWithReplayContext(
2617
2622
  {
2618
2623
  testRunId,
@@ -2625,16 +2630,24 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2625
2630
  mockStrategy,
2626
2631
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
2627
2632
  fetchSpanOutput,
2628
- dbBranchLease: lease
2633
+ dbBranchLease: lease,
2634
+ dbBranchTimings
2629
2635
  },
2630
2636
  () => fn(...inputs)
2631
2637
  );
2632
2638
  result = maybePromise instanceof Promise ? await maybePromise : maybePromise;
2639
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2633
2640
  } catch (e) {
2641
+ if (replayStarted !== null) {
2642
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2643
+ }
2634
2644
  traceError = e;
2635
2645
  error = errorMessage(e);
2636
2646
  }
2637
2647
  } catch (e) {
2648
+ if (replayStarted !== null) {
2649
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2650
+ }
2638
2651
  replayError = e;
2639
2652
  error = replayItemErrorMessage(e);
2640
2653
  } finally {
@@ -2651,6 +2664,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2651
2664
  }
2652
2665
  }
2653
2666
  }
2667
+ const originalDurationMs = serverItem.originalDurationMs ?? serverItem.durationMs ?? null;
2668
+ const originalModel = serverItem.originalModel ?? serverItem.model ?? null;
2654
2669
  return {
2655
2670
  // Written in by replay() from the complete-replay response once the server
2656
2671
  // has minted this replay trace's row. Null until then: the client-side
@@ -2667,13 +2682,17 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2667
2682
  error,
2668
2683
  traceError,
2669
2684
  replayError,
2670
- durationMs: serverItem.durationMs ?? null,
2685
+ durationMs: replayDurationMs,
2686
+ originalDurationMs,
2687
+ originalTokens: serverItem.originalTokens ?? serverItem.tokens ?? null,
2688
+ originalModel,
2671
2689
  // Filled in by replay() from the complete-replay response once the
2672
2690
  // replay traces are persisted and their spans aggregated server-side.
2673
2691
  // Null here (and on older servers) means "replay tokens not known".
2674
2692
  tokens: null,
2675
- model: serverItem.model ?? null,
2676
- dbSnapshotRef: dbSnapshotRef ?? null
2693
+ model: originalModel,
2694
+ dbSnapshotRef: dbSnapshotRef ?? null,
2695
+ dbBranchTimings: dbBranchTimings ?? null
2677
2696
  };
2678
2697
  }
2679
2698
  async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds) {
@@ -2900,9 +2919,13 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2900
2919
  traceError: item.traceError,
2901
2920
  replayError: item.replayError,
2902
2921
  durationMs: item.durationMs,
2922
+ originalDurationMs: item.originalDurationMs,
2923
+ originalTokens: item.originalTokens,
2924
+ originalModel: item.originalModel,
2903
2925
  tokens: item.tokens,
2904
2926
  model: item.model,
2905
- dbSnapshotRef: item.dbSnapshotRef
2927
+ dbSnapshotRef: item.dbSnapshotRef,
2928
+ dbBranchTimings: item.dbBranchTimings
2906
2929
  }
2907
2930
  });
2908
2931
  } catch {
@@ -6081,7 +6104,8 @@ var Bitfab = class {
6081
6104
  snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
6082
6105
  region: replayCtx.dbBranchLease.region,
6083
6106
  originalTraceId: replayCtx.sourceBitfabTraceId,
6084
- accessed: replayCtx.dbSnapshotAccessed === true
6107
+ accessed: replayCtx.dbSnapshotAccessed === true,
6108
+ timings: replayCtx.dbBranchTimings
6085
6109
  }
6086
6110
  }
6087
6111
  });
@@ -6413,7 +6437,13 @@ var Bitfab = class {
6413
6437
  // against servers that predate the rename.
6414
6438
  source_trace_id: params.dbSnapshotUsage.originalTraceId
6415
6439
  },
6416
- accessed: params.dbSnapshotUsage.accessed
6440
+ accessed: params.dbSnapshotUsage.accessed,
6441
+ // Echoed verbatim (camelCase inside) rather than re-cased into this
6442
+ // record's snake_case: it is the server's own object coming back, and
6443
+ // a translation layer here is one more thing to drift.
6444
+ ...params.dbSnapshotUsage.timings && {
6445
+ timings: params.dbSnapshotUsage.timings
6446
+ }
6417
6447
  };
6418
6448
  }
6419
6449
  this.httpClient.sendExternalTrace({