bitfab 0.38.1 → 0.38.3

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.
@@ -0,0 +1,59 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+
9
+ // src/asyncStorage.ts
10
+ var AsyncLocalStorageClass = null;
11
+ var initDone = false;
12
+ function registerAsyncLocalStorageClass(cls) {
13
+ if (!AsyncLocalStorageClass) {
14
+ AsyncLocalStorageClass = cls;
15
+ }
16
+ initDone = true;
17
+ }
18
+ function assertAsyncStorageRegistered() {
19
+ if (!AsyncLocalStorageClass) {
20
+ console.warn(
21
+ "Bitfab: AsyncLocalStorage not available - nested span context will not propagate."
22
+ );
23
+ }
24
+ }
25
+ var asyncStorageReady = (typeof process !== "undefined" && process.versions?.node ? (
26
+ // The join trick hides "node:async_hooks" from static analysis so
27
+ // bundlers that ban Node.js built-ins don't fail at build time.
28
+ // webpackIgnore tells webpack/turbopack to emit a native import()
29
+ // so Node.js can resolve the module at runtime.
30
+ import(
31
+ /* webpackIgnore: true */
32
+ ["node", "async_hooks"].join(":")
33
+ ).then(
34
+ (mod) => {
35
+ registerAsyncLocalStorageClass(mod.AsyncLocalStorage);
36
+ }
37
+ ).catch(() => {
38
+ })
39
+ ) : Promise.resolve()).then(() => {
40
+ initDone = true;
41
+ });
42
+ function isAsyncStorageInitDone() {
43
+ return initDone;
44
+ }
45
+ function createAsyncLocalStorage() {
46
+ return AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
47
+ }
48
+
49
+ export {
50
+ __privateGet,
51
+ __privateAdd,
52
+ __privateSet,
53
+ registerAsyncLocalStorageClass,
54
+ assertAsyncStorageRegistered,
55
+ asyncStorageReady,
56
+ isAsyncStorageInitDone,
57
+ createAsyncLocalStorage
58
+ };
59
+ //# sourceMappingURL=chunk-H6LZRFMN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncStorage.ts"],"sourcesContent":["/**\n * Shared AsyncLocalStorage loader.\n *\n * Provides two ways to initialize AsyncLocalStorage:\n *\n * 1. **Synchronous registration** (preferred for Node.js):\n * `asyncStorageNode.ts` calls `registerAsyncLocalStorageClass()` at module\n * evaluation time, so the class is available immediately - no async gap.\n * The `node.ts` entry point imports it before anything else.\n *\n * 2. **Async dynamic import** (fallback for the default entry point):\n * Loads `node:async_hooks` via a bundler-safe dynamic import. This is used\n * by the default `index.ts` entry point so the SDK works in browsers\n * (where the import silently fails) and in Node.js when imported via the\n * default entry point.\n *\n * ## Why the dynamic import looks like this\n *\n * We need to handle three environments:\n *\n * 1. **Pure Node.js** - `import(\"node:async_hooks\")` works natively.\n * 2. **Webpack/Turbopack (Next.js server)** - The bundler processes\n * `import()` calls at build time. The `webpackIgnore` magic comment tells\n * webpack (and turbopack) to emit a native `import()` call instead of\n * trying to resolve it, so Node.js handles it at runtime.\n * 3. **Browsers / Edge** - The `process.versions?.node` guard prevents\n * execution entirely. If it somehow runs, `.catch(() => {})` swallows\n * the failure.\n */\n\nexport interface AsyncLocalStorageLike<T> {\n getStore(): T | undefined\n run<R>(store: T, fn: () => R): R\n}\n\nlet AsyncLocalStorageClass: (new () => AsyncLocalStorageLike<unknown>) | null =\n null\nlet initDone = false\n\n/**\n * Register the AsyncLocalStorage class synchronously.\n *\n * Called by `asyncStorageNode.ts` at module evaluation time so the class\n * is available before any span is created - no async gap, no race condition.\n *\n * Safe to call multiple times; subsequent calls are no-ops.\n */\nexport function registerAsyncLocalStorageClass(\n cls: new () => AsyncLocalStorageLike<unknown>,\n): void {\n if (!AsyncLocalStorageClass) {\n AsyncLocalStorageClass = cls\n }\n initDone = true\n}\n\n/**\n * Assert that AsyncLocalStorage was registered successfully.\n *\n * Called by `node.ts` after importing `asyncStorageNode.ts` to catch\n * import-order bugs at startup rather than silently degrading to the\n * browser fallback (flat spans with no nesting).\n *\n * This should ONLY be called from the Node.js entry point where we\n * know `node:async_hooks` must be available.\n */\nexport function assertAsyncStorageRegistered(): void {\n if (!AsyncLocalStorageClass) {\n console.warn(\n \"Bitfab: AsyncLocalStorage not available - nested span context will not propagate.\",\n )\n }\n}\n\nexport const asyncStorageReady: Promise<void> = (\n typeof process !== \"undefined\" && process.versions?.node\n ? // The join trick hides \"node:async_hooks\" from static analysis so\n // bundlers that ban Node.js built-ins don't fail at build time.\n // webpackIgnore tells webpack/turbopack to emit a native import()\n // so Node.js can resolve the module at runtime.\n import(\n /* webpackIgnore: true */\n [\"node\", \"async_hooks\"].join(\":\")\n )\n .then(\n (mod: {\n AsyncLocalStorage: new () => AsyncLocalStorageLike<unknown>\n }) => {\n registerAsyncLocalStorageClass(mod.AsyncLocalStorage)\n },\n )\n .catch(() => {})\n : Promise.resolve()\n).then(() => {\n initDone = true\n})\n\nexport function isAsyncStorageInitDone(): boolean {\n return initDone\n}\n\nexport function createAsyncLocalStorage<T>(): AsyncLocalStorageLike<T> | null {\n return AsyncLocalStorageClass\n ? (new AsyncLocalStorageClass() as AsyncLocalStorageLike<T>)\n : null\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAI,yBACF;AACF,IAAI,WAAW;AAUR,SAAS,+BACd,KACM;AACN,MAAI,CAAC,wBAAwB;AAC3B,6BAAyB;AAAA,EAC3B;AACA,aAAW;AACb;AAYO,SAAS,+BAAqC;AACnD,MAAI,CAAC,wBAAwB;AAC3B,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,qBACX,OAAO,YAAY,eAAe,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhD;AAAA;AAAA,IAEE,CAAC,QAAQ,aAAa,EAAE,KAAK,GAAG;AAAA,IAE/B;AAAA,IACC,CAAC,QAEK;AACJ,qCAA+B,IAAI,iBAAiB;AAAA,IACtD;AAAA,EACF,EACC,MAAM,MAAM;AAAA,EAAC,CAAC;AAAA,IACjB,QAAQ,QAAQ,GACpB,KAAK,MAAM;AACX,aAAW;AACb,CAAC;AAEM,SAAS,yBAAkC;AAChD,SAAO;AACT;AAEO,SAAS,0BAA8D;AAC5E,SAAO,yBACF,IAAI,uBAAuB,IAC5B;AACN;","names":[]}
@@ -1,10 +1,7 @@
1
- var __typeError = (msg) => {
2
- throw TypeError(msg);
3
- };
4
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1
+ import {
2
+ asyncStorageReady,
3
+ createAsyncLocalStorage
4
+ } from "./chunk-H6LZRFMN.js";
8
5
 
9
6
  // src/codeChange.ts
10
7
  var MAX_FILES = 60;
@@ -314,52 +311,12 @@ function encodeRequestBody(body) {
314
311
  }
315
312
 
316
313
  // src/version.generated.ts
317
- var __version__ = "0.38.1";
314
+ var __version__ = "0.38.3";
318
315
  var __packageName__ = "bitfab";
319
316
 
320
317
  // src/constants.ts
321
318
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
322
319
 
323
- // src/asyncStorage.ts
324
- var AsyncLocalStorageClass = null;
325
- var initDone = false;
326
- function registerAsyncLocalStorageClass(cls) {
327
- if (!AsyncLocalStorageClass) {
328
- AsyncLocalStorageClass = cls;
329
- }
330
- initDone = true;
331
- }
332
- function assertAsyncStorageRegistered() {
333
- if (!AsyncLocalStorageClass) {
334
- console.warn(
335
- "Bitfab: AsyncLocalStorage not available - nested span context will not propagate."
336
- );
337
- }
338
- }
339
- var asyncStorageReady = (typeof process !== "undefined" && process.versions?.node ? (
340
- // The join trick hides "node:async_hooks" from static analysis so
341
- // bundlers that ban Node.js built-ins don't fail at build time.
342
- // webpackIgnore tells webpack/turbopack to emit a native import()
343
- // so Node.js can resolve the module at runtime.
344
- import(
345
- /* webpackIgnore: true */
346
- ["node", "async_hooks"].join(":")
347
- ).then(
348
- (mod) => {
349
- registerAsyncLocalStorageClass(mod.AsyncLocalStorage);
350
- }
351
- ).catch(() => {
352
- })
353
- ) : Promise.resolve()).then(() => {
354
- initDone = true;
355
- });
356
- function isAsyncStorageInitDone() {
357
- return initDone;
358
- }
359
- function createAsyncLocalStorage() {
360
- return AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
361
- }
362
-
363
320
  // src/replayContext.ts
364
321
  var replayContextStorage = null;
365
322
  var REPLAY_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.replayContextStorage");
@@ -683,7 +640,7 @@ var MAX_REQUEST_BYTES_ENV = "BITFAB_OTEL_MAX_REQUEST_BYTES";
683
640
  var EXPORT_CONCURRENCY_ENV = "BITFAB_OTEL_EXPORT_CONCURRENCY";
684
641
  var MAX_QUEUE_SIZE = 8192;
685
642
  var DIRECT_MAX_EXPORT_BATCH_SIZE = 512;
686
- var DIRECT_MAX_REQUEST_BATCH_SIZE = 8;
643
+ var DIRECT_MAX_REQUEST_BATCH_SIZE = 128;
687
644
  var DEFAULT_EXPORT_CONCURRENCY = 32;
688
645
  var MAX_EXPORT_CONCURRENCY = 64;
689
646
  var SCHEDULE_DELAY_MILLIS = 5e3;
@@ -1782,6 +1739,12 @@ var HttpClient = class {
1782
1739
  async lookupFunction(name) {
1783
1740
  return this.request("/api/sdk/functions/lookup", { name });
1784
1741
  }
1742
+ async getAutoTracePolicy(traceFunctionKey, protocol) {
1743
+ return this.request("/api/sdk/auto-trace/policy", {
1744
+ traceFunctionKey,
1745
+ protocol
1746
+ });
1747
+ }
1785
1748
  async getTraceSpan(traceId, lookup) {
1786
1749
  const searchParams = new URLSearchParams();
1787
1750
  if (lookup.id !== void 0) {
@@ -2658,6 +2621,11 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2658
2621
  );
2659
2622
  }
2660
2623
  }
2624
+ if (options?.traceIds !== void 0 && options?.datasetId !== void 0) {
2625
+ throw new BitfabError(
2626
+ "traceIds and datasetId select different replay sources and cannot be used together."
2627
+ );
2628
+ }
2661
2629
  if (options?.limit !== void 0 && options?.traceIds !== void 0) {
2662
2630
  try {
2663
2631
  console.warn(
@@ -2933,17 +2901,9 @@ async function writeReplayResultFile(result) {
2933
2901
  }
2934
2902
 
2935
2903
  export {
2936
- __privateGet,
2937
- __privateAdd,
2938
- __privateSet,
2939
2904
  __version__,
2940
2905
  DEFAULT_SERVICE_URL,
2941
2906
  BitfabError,
2942
- registerAsyncLocalStorageClass,
2943
- assertAsyncStorageRegistered,
2944
- asyncStorageReady,
2945
- isAsyncStorageInitDone,
2946
- createAsyncLocalStorage,
2947
2907
  getReplayContext,
2948
2908
  warnOnce,
2949
2909
  flushTraces,
@@ -2963,4 +2923,4 @@ export {
2963
2923
  sleepForReplayPersistence,
2964
2924
  replay
2965
2925
  };
2966
- //# sourceMappingURL=chunk-DUEN22MC.js.map
2926
+ //# sourceMappingURL=chunk-QNPM27RY.js.map