@bitfab/sdk 0.28.5 → 0.28.7

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
@@ -615,11 +615,35 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
615
615
  }
616
616
  }
617
617
  }
618
- return {
618
+ const replayResult = {
619
619
  items: resultItems,
620
620
  testRunId,
621
621
  testRunUrl: `${serviceUrl}${testRunUrl}`
622
622
  };
623
+ await writeReplayResultFile(replayResult);
624
+ return replayResult;
625
+ }
626
+ async function writeReplayResultFile(result) {
627
+ const resultPath = typeof process !== "undefined" ? process.env?.BITFAB_REPLAY_RESULT_PATH : void 0;
628
+ if (!resultPath) {
629
+ return;
630
+ }
631
+ try {
632
+ const [{ dirname }, { mkdir, writeFile }] = await Promise.all([
633
+ import("path"),
634
+ import("fs/promises")
635
+ ]);
636
+ await mkdir(dirname(resultPath), { recursive: true });
637
+ await writeFile(resultPath, `${JSON.stringify(result, null, 2)}
638
+ `);
639
+ } catch (err) {
640
+ try {
641
+ console.warn(
642
+ `Bitfab: failed to write replay result to BITFAB_REPLAY_RESULT_PATH (${resultPath}): ${err instanceof Error ? err.message : String(err)}`
643
+ );
644
+ } catch {
645
+ }
646
+ }
623
647
  }
624
648
  var BITFAB_PROGRESS_PREFIX;
625
649
  var init_replay = __esm({
@@ -659,7 +683,7 @@ __export(index_exports, {
659
683
  module.exports = __toCommonJS(index_exports);
660
684
 
661
685
  // src/version.generated.ts
662
- var __version__ = "0.28.5";
686
+ var __version__ = "0.28.7";
663
687
 
664
688
  // src/constants.ts
665
689
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -3310,6 +3334,8 @@ var noOpTrace = {
3310
3334
  setMetadata() {
3311
3335
  },
3312
3336
  addContext() {
3337
+ },
3338
+ drop() {
3313
3339
  }
3314
3340
  };
3315
3341
  function getCurrentSpan() {
@@ -3386,6 +3412,12 @@ function getCurrentTrace() {
3386
3412
  traceState.contexts.push(context);
3387
3413
  } catch {
3388
3414
  }
3415
+ },
3416
+ drop() {
3417
+ try {
3418
+ getOrCreateTraceState().dropped = true;
3419
+ } catch {
3420
+ }
3389
3421
  }
3390
3422
  };
3391
3423
  }
@@ -3975,6 +4007,7 @@ var Bitfab = class {
3975
4007
  testRunId: traceState?.testRunId,
3976
4008
  inputSourceTraceId: traceState?.inputSourceTraceId,
3977
4009
  dbSnapshotRef: traceState?.dbSnapshotRef,
4010
+ dropped: traceState?.dropped,
3978
4011
  // Built AFTER the wrapped fn finished, so `accessed` reflects
3979
4012
  // whether customer code obtained the branch URL during this
3980
4013
  // item. Omitted entirely when no lease was attached, so the
@@ -4220,6 +4253,7 @@ var Bitfab = class {
4220
4253
  traceFunctionKey: params.traceFunctionKey,
4221
4254
  externalTrace: rawTrace,
4222
4255
  completed: true,
4256
+ ...params.dropped && { dropped: true },
4223
4257
  ...params.sessionId && { sessionId: params.sessionId },
4224
4258
  ...params.testRunId && { testRunId: params.testRunId }
4225
4259
  });