bitfab 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.d.cts CHANGED
@@ -735,7 +735,7 @@ declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
735
735
  * It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
736
736
  * plugin polls to report live progress while the replay runs in the background,
737
737
  * so scripts never hand-format the wire protocol.
738
- * stdout is left untouched for the ReplayResult JSON. Outside Node (no
738
+ * stdout is left untouched for direct-run ReplayResult JSON. Outside Node (no
739
739
  * `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
740
740
  * swallowed so progress can never crash a run.
741
741
  */
@@ -1014,6 +1014,15 @@ interface CurrentTrace {
1014
1014
  * Context entries are stored in rawData.contexts as [{key, value}, ...].
1015
1015
  */
1016
1016
  addContext(context: Record<string, unknown>): void;
1017
+ /**
1018
+ * Flag this trace to be dropped. When the trace completes, the server scrubs
1019
+ * its payloads (trace, external trace, and all spans) and marks it `dropped`
1020
+ * instead of `completed`, retaining only a skeleton audit record. Use this to
1021
+ * discard runs you never want stored (e.g. health checks, or a run you know
1022
+ * contains sensitive data). Takes effect at trace completion; a trace that is
1023
+ * flagged but never completes is not scrubbed.
1024
+ */
1025
+ drop(): void;
1017
1026
  }
1018
1027
  /**
1019
1028
  * Get a handle to the current active span.
@@ -1603,7 +1612,7 @@ declare class BitfabFunction {
1603
1612
  /**
1604
1613
  * SDK version from package.json (injected at build time)
1605
1614
  */
1606
- declare const __version__ = "0.28.5";
1615
+ declare const __version__ = "0.28.7";
1607
1616
 
1608
1617
  /**
1609
1618
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -735,7 +735,7 @@ declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
735
735
  * It writes one `@@bitfab:progress` line per trace to stderr, which the Bitfab
736
736
  * plugin polls to report live progress while the replay runs in the background,
737
737
  * so scripts never hand-format the wire protocol.
738
- * stdout is left untouched for the ReplayResult JSON. Outside Node (no
738
+ * stdout is left untouched for direct-run ReplayResult JSON. Outside Node (no
739
739
  * `process.stderr`, e.g. a browser) it is a no-op, and a write failure is
740
740
  * swallowed so progress can never crash a run.
741
741
  */
@@ -1014,6 +1014,15 @@ interface CurrentTrace {
1014
1014
  * Context entries are stored in rawData.contexts as [{key, value}, ...].
1015
1015
  */
1016
1016
  addContext(context: Record<string, unknown>): void;
1017
+ /**
1018
+ * Flag this trace to be dropped. When the trace completes, the server scrubs
1019
+ * its payloads (trace, external trace, and all spans) and marks it `dropped`
1020
+ * instead of `completed`, retaining only a skeleton audit record. Use this to
1021
+ * discard runs you never want stored (e.g. health checks, or a run you know
1022
+ * contains sensitive data). Takes effect at trace completion; a trace that is
1023
+ * flagged but never completes is not scrubbed.
1024
+ */
1025
+ drop(): void;
1017
1026
  }
1018
1027
  /**
1019
1028
  * Get a handle to the current active span.
@@ -1603,7 +1612,7 @@ declare class BitfabFunction {
1603
1612
  /**
1604
1613
  * SDK version from package.json (injected at build time)
1605
1614
  */
1606
- declare const __version__ = "0.28.5";
1615
+ declare const __version__ = "0.28.7";
1607
1616
 
1608
1617
  /**
1609
1618
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -23,12 +23,12 @@ import {
23
23
  flushTraces,
24
24
  getCurrentSpan,
25
25
  getCurrentTrace
26
- } from "./chunk-7UU5L64L.js";
26
+ } from "./chunk-TIMBGA3A.js";
27
27
  import {
28
28
  BITFAB_PROGRESS_PREFIX,
29
29
  BitfabError,
30
30
  reportReplayProgress
31
- } from "./chunk-SAGZ674W.js";
31
+ } from "./chunk-5E4BUIYA.js";
32
32
  export {
33
33
  BITFAB_PROGRESS_PREFIX,
34
34
  Bitfab,
package/dist/node.cjs CHANGED
@@ -631,11 +631,35 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
631
631
  }
632
632
  }
633
633
  }
634
- return {
634
+ const replayResult = {
635
635
  items: resultItems,
636
636
  testRunId,
637
637
  testRunUrl: `${serviceUrl}${testRunUrl}`
638
638
  };
639
+ await writeReplayResultFile(replayResult);
640
+ return replayResult;
641
+ }
642
+ async function writeReplayResultFile(result) {
643
+ const resultPath = typeof process !== "undefined" ? process.env?.BITFAB_REPLAY_RESULT_PATH : void 0;
644
+ if (!resultPath) {
645
+ return;
646
+ }
647
+ try {
648
+ const [{ dirname }, { mkdir, writeFile }] = await Promise.all([
649
+ import("path"),
650
+ import("fs/promises")
651
+ ]);
652
+ await mkdir(dirname(resultPath), { recursive: true });
653
+ await writeFile(resultPath, `${JSON.stringify(result, null, 2)}
654
+ `);
655
+ } catch (err) {
656
+ try {
657
+ console.warn(
658
+ `Bitfab: failed to write replay result to BITFAB_REPLAY_RESULT_PATH (${resultPath}): ${err instanceof Error ? err.message : String(err)}`
659
+ );
660
+ } catch {
661
+ }
662
+ }
639
663
  }
640
664
  var BITFAB_PROGRESS_PREFIX;
641
665
  var init_replay = __esm({
@@ -682,7 +706,7 @@ registerAsyncLocalStorageClass(
682
706
  );
683
707
 
684
708
  // src/version.generated.ts
685
- var __version__ = "0.28.5";
709
+ var __version__ = "0.28.7";
686
710
 
687
711
  // src/constants.ts
688
712
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -3333,6 +3357,8 @@ var noOpTrace = {
3333
3357
  setMetadata() {
3334
3358
  },
3335
3359
  addContext() {
3360
+ },
3361
+ drop() {
3336
3362
  }
3337
3363
  };
3338
3364
  function getCurrentSpan() {
@@ -3409,6 +3435,12 @@ function getCurrentTrace() {
3409
3435
  traceState.contexts.push(context);
3410
3436
  } catch {
3411
3437
  }
3438
+ },
3439
+ drop() {
3440
+ try {
3441
+ getOrCreateTraceState().dropped = true;
3442
+ } catch {
3443
+ }
3412
3444
  }
3413
3445
  };
3414
3446
  }
@@ -3998,6 +4030,7 @@ var Bitfab = class {
3998
4030
  testRunId: traceState?.testRunId,
3999
4031
  inputSourceTraceId: traceState?.inputSourceTraceId,
4000
4032
  dbSnapshotRef: traceState?.dbSnapshotRef,
4033
+ dropped: traceState?.dropped,
4001
4034
  // Built AFTER the wrapped fn finished, so `accessed` reflects
4002
4035
  // whether customer code obtained the branch URL during this
4003
4036
  // item. Omitted entirely when no lease was attached, so the
@@ -4243,6 +4276,7 @@ var Bitfab = class {
4243
4276
  traceFunctionKey: params.traceFunctionKey,
4244
4277
  externalTrace: rawTrace,
4245
4278
  completed: true,
4279
+ ...params.dropped && { dropped: true },
4246
4280
  ...params.sessionId && { sessionId: params.sessionId },
4247
4281
  ...params.testRunId && { testRunId: params.testRunId }
4248
4282
  });