@bitfab/sdk 0.53.3 → 0.53.5

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.
Files changed (41) hide show
  1. package/dist/autoTrace.cjs +10 -2
  2. package/dist/autoTrace.cjs.map +1 -1
  3. package/dist/autoTrace.js +2 -2
  4. package/dist/{chunk-YE53VBBW.js → chunk-BOXLWX73.js} +10 -4
  5. package/dist/chunk-BOXLWX73.js.map +1 -0
  6. package/dist/{chunk-E5BLYL5X.js → chunk-EGWJYCNT.js} +6 -5
  7. package/dist/chunk-EGWJYCNT.js.map +1 -0
  8. package/dist/{chunk-PVB4BGAS.js → chunk-IDQBDBNS.js} +3 -3
  9. package/dist/chunk-IDQBDBNS.js.map +1 -0
  10. package/dist/{chunk-EKIJ6QBA.js → chunk-PAL7VIWM.js} +11 -2
  11. package/dist/chunk-PAL7VIWM.js.map +1 -0
  12. package/dist/{chunk-HKRITKFY.js → chunk-Q7IB5VFZ.js} +39 -21
  13. package/dist/chunk-Q7IB5VFZ.js.map +1 -0
  14. package/dist/{chunk-W5GNZSKR.js → chunk-RMATODGT.js} +20 -2
  15. package/dist/chunk-RMATODGT.js.map +1 -0
  16. package/dist/{chunk-H6LZRFMN.js → chunk-VCRFFCLY.js} +20 -2
  17. package/dist/chunk-VCRFFCLY.js.map +1 -0
  18. package/dist/{http-DCZ44JXM.js → http-3WOABXYN.js} +3 -3
  19. package/dist/{http-NB6D7OIN.js → http-6F3OLGWX.js} +2 -2
  20. package/dist/index.cjs +70 -14
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +3 -3
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +5 -5
  25. package/dist/node.cjs +70 -14
  26. package/dist/node.cjs.map +1 -1
  27. package/dist/node.js +5 -5
  28. package/dist/{replay-FE2R4GRT.js → replay-HVLPMPVQ.js} +4 -4
  29. package/dist/replayCli.js +2 -2
  30. package/dist/seedCli.js +2 -2
  31. package/package.json +1 -1
  32. package/dist/chunk-E5BLYL5X.js.map +0 -1
  33. package/dist/chunk-EKIJ6QBA.js.map +0 -1
  34. package/dist/chunk-H6LZRFMN.js.map +0 -1
  35. package/dist/chunk-HKRITKFY.js.map +0 -1
  36. package/dist/chunk-PVB4BGAS.js.map +0 -1
  37. package/dist/chunk-W5GNZSKR.js.map +0 -1
  38. package/dist/chunk-YE53VBBW.js.map +0 -1
  39. /package/dist/{http-DCZ44JXM.js.map → http-3WOABXYN.js.map} +0 -0
  40. /package/dist/{http-NB6D7OIN.js.map → http-6F3OLGWX.js.map} +0 -0
  41. /package/dist/{replay-FE2R4GRT.js.map → replay-HVLPMPVQ.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1259,12 +1259,12 @@ declare class DatasetsClient {
1259
1259
  save(params: SaveDatasetParams): Promise<SaveDatasetResult>;
1260
1260
  /**
1261
1261
  * List datasets, scoped to one trace function when `traceFunctionKey` is
1262
- * given and organization-wide otherwise.
1262
+ * given and organization-wide otherwise. Fetches all pages automatically.
1263
1263
  */
1264
1264
  list(params?: ListDatasetsParams): Promise<Dataset[]>;
1265
1265
  /** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
1266
1266
  get(datasetId: string): Promise<Dataset>;
1267
- /** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
1267
+ /** Fetches all trace-ID pages, the same membership a replay with `datasetId` selects. */
1268
1268
  listTraces(datasetId: string): Promise<DatasetTraceIds>;
1269
1269
  /**
1270
1270
  * Add traces to the dataset (1 to 100 ids per call). Traces outside the
@@ -3344,7 +3344,7 @@ interface CommitRef {
3344
3344
  /**
3345
3345
  * SDK version from package.json (injected at build time)
3346
3346
  */
3347
- declare const __version__ = "0.53.3";
3347
+ declare const __version__ = "0.53.5";
3348
3348
 
3349
3349
  /**
3350
3350
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -1259,12 +1259,12 @@ declare class DatasetsClient {
1259
1259
  save(params: SaveDatasetParams): Promise<SaveDatasetResult>;
1260
1260
  /**
1261
1261
  * List datasets, scoped to one trace function when `traceFunctionKey` is
1262
- * given and organization-wide otherwise.
1262
+ * given and organization-wide otherwise. Fetches all pages automatically.
1263
1263
  */
1264
1264
  list(params?: ListDatasetsParams): Promise<Dataset[]>;
1265
1265
  /** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
1266
1266
  get(datasetId: string): Promise<Dataset>;
1267
- /** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
1267
+ /** Fetches all trace-ID pages, the same membership a replay with `datasetId` selects. */
1268
1268
  listTraces(datasetId: string): Promise<DatasetTraceIds>;
1269
1269
  /**
1270
1270
  * Add traces to the dataset (1 to 100 ids per call). Traces outside the
@@ -3344,7 +3344,7 @@ interface CommitRef {
3344
3344
  /**
3345
3345
  * SDK version from package.json (injected at build time)
3346
3346
  */
3347
- declare const __version__ = "0.53.3";
3347
+ declare const __version__ = "0.53.5";
3348
3348
 
3349
3349
  /**
3350
3350
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -19,8 +19,8 @@ import {
19
19
  getCurrentTrace,
20
20
  reseedFromRegistry,
21
21
  seedFromRegistry
22
- } from "./chunk-HKRITKFY.js";
23
- import "./chunk-E5BLYL5X.js";
22
+ } from "./chunk-Q7IB5VFZ.js";
23
+ import "./chunk-EGWJYCNT.js";
24
24
  import {
25
25
  BITFAB_PROGRESS_PREFIX,
26
26
  DbBranchReplayError,
@@ -28,7 +28,7 @@ import {
28
28
  ReplayError,
29
29
  reportReplayProgress,
30
30
  serializeReplayResult
31
- } from "./chunk-EKIJ6QBA.js";
31
+ } from "./chunk-PAL7VIWM.js";
32
32
  import {
33
33
  BitfabError,
34
34
  DEFAULT_SERVICE_URL,
@@ -36,8 +36,8 @@ import {
36
36
  MixedTracingError,
37
37
  __version__,
38
38
  flushTraces
39
- } from "./chunk-YE53VBBW.js";
40
- import "./chunk-H6LZRFMN.js";
39
+ } from "./chunk-BOXLWX73.js";
40
+ import "./chunk-VCRFFCLY.js";
41
41
  export {
42
42
  BITFAB_PROGRESS_PREFIX,
43
43
  Bitfab,
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.53.3";
91
+ __version__ = "0.53.5";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -265,6 +265,28 @@ var init_replayContext = __esm({
265
265
  }
266
266
  });
267
267
 
268
+ // src/captureSuppression.ts
269
+ function isCaptureSuppressed() {
270
+ return suppressionState.depth > 0;
271
+ }
272
+ function runWithCaptureSuppressed(fn) {
273
+ suppressionState.depth += 1;
274
+ try {
275
+ return fn();
276
+ } finally {
277
+ suppressionState.depth -= 1;
278
+ }
279
+ }
280
+ var suppressionGlobal, suppressionState;
281
+ var init_captureSuppression = __esm({
282
+ "src/captureSuppression.ts"() {
283
+ "use strict";
284
+ suppressionGlobal = globalThis;
285
+ suppressionState = suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 };
286
+ suppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState;
287
+ }
288
+ });
289
+
268
290
  // src/payloadBudget.ts
269
291
  function byteLength(value) {
270
292
  return textEncoder ? textEncoder.encode(value).length : value.length;
@@ -415,6 +437,11 @@ var init_warnOnce = __esm({
415
437
 
416
438
  // src/serializePayload.ts
417
439
  function serializePayloadBody(payload, maxCarrierBytes = MAX_SPAN_CARRIER_BYTES) {
440
+ return runWithCaptureSuppressed(
441
+ () => encodeWithinBudget(payload, maxCarrierBytes)
442
+ );
443
+ }
444
+ function encodeWithinBudget(payload, maxCarrierBytes) {
418
445
  const encoded = encodePayloadBody(payload);
419
446
  if (fitsCarrierBudget(encoded.body, maxCarrierBytes)) {
420
447
  return { body: encoded.body, dropped: encoded.dropped };
@@ -539,6 +566,7 @@ function encodePayloadBody(payload) {
539
566
  var init_serializePayload = __esm({
540
567
  "src/serializePayload.ts"() {
541
568
  "use strict";
569
+ init_captureSuppression();
542
570
  init_payloadBudget();
543
571
  init_warnOnce();
544
572
  }
@@ -2721,6 +2749,9 @@ function unserializableStub(value, reason) {
2721
2749
  return { json: summary };
2722
2750
  }
2723
2751
  function serializeValue(value) {
2752
+ return runWithCaptureSuppressed(() => serializeWithSuperjson(value));
2753
+ }
2754
+ function serializeWithSuperjson(value) {
2724
2755
  try {
2725
2756
  const { json, meta } = import_superjson.default.serialize(value);
2726
2757
  let size;
@@ -2754,6 +2785,9 @@ function toJsonSafe(value) {
2754
2785
  return toJsonSafeReport(value).safe;
2755
2786
  }
2756
2787
  function toJsonSafeReport(value) {
2788
+ return runWithCaptureSuppressed(() => jsonSafeReport(value));
2789
+ }
2790
+ function jsonSafeReport(value) {
2757
2791
  const dropped = [];
2758
2792
  const safe = toJsonSafeInner(value, 0, /* @__PURE__ */ new WeakSet(), dropped);
2759
2793
  try {
@@ -2839,6 +2873,7 @@ var init_serialize = __esm({
2839
2873
  "src/serialize.ts"() {
2840
2874
  "use strict";
2841
2875
  import_superjson = __toESM(require("superjson"), 1);
2876
+ init_captureSuppression();
2842
2877
  init_payloadBudget();
2843
2878
  init_warnOnce();
2844
2879
  MAX_SERIALIZED_BYTES = MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES;
@@ -4745,6 +4780,7 @@ init_asyncStorage();
4745
4780
 
4746
4781
  // src/autoTrace.ts
4747
4782
  init_asyncStorage();
4783
+ init_captureSuppression();
4748
4784
  var autoTraceGlobal = globalThis;
4749
4785
  var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
4750
4786
  storage: null,
@@ -4877,7 +4913,7 @@ function wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, source) {
4877
4913
  return wrapped;
4878
4914
  }
4879
4915
  function __bitfabAutoTraceActive() {
4880
- if (autoTraceState.activeRoots === 0) {
4916
+ if (autoTraceState.activeRoots === 0 || isCaptureSuppressed()) {
4881
4917
  return false;
4882
4918
  }
4883
4919
  return currentAutoTraceEntries().length > 0;
@@ -5207,6 +5243,9 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
5207
5243
  };
5208
5244
  }
5209
5245
 
5246
+ // src/client.ts
5247
+ init_captureSuppression();
5248
+
5210
5249
  // src/captureSurface.ts
5211
5250
  init_errors();
5212
5251
  var DEFAULT_SURFACE = "opt-in";
@@ -5500,14 +5539,24 @@ var DatasetsClient = class {
5500
5539
  }
5501
5540
  /**
5502
5541
  * List datasets, scoped to one trace function when `traceFunctionKey` is
5503
- * given and organization-wide otherwise.
5542
+ * given and organization-wide otherwise. Fetches all pages automatically.
5504
5543
  */
5505
5544
  async list(params = {}) {
5506
- const query = params.traceFunctionKey === void 0 ? "" : `?traceFunctionKey=${encodeURIComponent(params.traceFunctionKey)}`;
5507
- const response = await this.httpClient.get(
5508
- `/api/sdk/datasets${query}`
5509
- );
5510
- return response.datasets;
5545
+ const datasets = [];
5546
+ let cursor;
5547
+ do {
5548
+ const query = new URLSearchParams({ limit: "100" });
5549
+ if (params.traceFunctionKey !== void 0) {
5550
+ query.set("traceFunctionKey", params.traceFunctionKey);
5551
+ }
5552
+ if (cursor !== void 0) {
5553
+ query.set("cursor", cursor);
5554
+ }
5555
+ const response = await this.httpClient.get(`/api/sdk/datasets?${query}`);
5556
+ datasets.push(...response.datasets);
5557
+ cursor = response.nextCursor ?? void 0;
5558
+ } while (cursor !== void 0);
5559
+ return datasets;
5511
5560
  }
5512
5561
  /** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
5513
5562
  async get(datasetId) {
@@ -5516,11 +5565,18 @@ var DatasetsClient = class {
5516
5565
  );
5517
5566
  return response.dataset;
5518
5567
  }
5519
- /** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
5568
+ /** Fetches all trace-ID pages, the same membership a replay with `datasetId` selects. */
5520
5569
  async listTraces(datasetId) {
5521
- return this.httpClient.get(
5522
- datasetPath(datasetId, "/traces")
5523
- );
5570
+ const traceIds = [];
5571
+ const query = new URLSearchParams({ limit: "100" });
5572
+ for (; ; ) {
5573
+ const page = await this.httpClient.get(`${datasetPath(datasetId, "/traces")}?${query}`);
5574
+ traceIds.push(...page.traceIds);
5575
+ if (page.nextCursor === void 0 || page.nextCursor === null) {
5576
+ return { datasetId: page.datasetId, traceIds };
5577
+ }
5578
+ query.set("cursor", page.nextCursor);
5579
+ }
5524
5580
  }
5525
5581
  /**
5526
5582
  * Add traces to the dataset (1 to 100 ids per call). Traces outside the
@@ -7909,7 +7965,7 @@ var Bitfab = class {
7909
7965
  );
7910
7966
  const tracedRoot = buildTracedRoot(rootOptions);
7911
7967
  const autoTraceRoot = function(...args) {
7912
- if (!self.shouldRecord()) {
7968
+ if (!self.shouldRecord() || isCaptureSuppressed()) {
7913
7969
  return fn.apply(this, args);
7914
7970
  }
7915
7971
  const enclosing = currentAutoTraceEntries();
@@ -8486,7 +8542,7 @@ var Bitfab = class {
8486
8542
  }
8487
8543
  })();
8488
8544
  const wrappedFn = function(...args) {
8489
- if (!self.shouldRecord()) {
8545
+ if (!self.shouldRecord() || isCaptureSuppressed()) {
8490
8546
  return fn.apply(this, args);
8491
8547
  }
8492
8548
  initializeAsyncContext();