bitfab 0.64.1 → 0.64.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.
@@ -17,7 +17,7 @@ import {
17
17
  serializeValue,
18
18
  toJsonSafe,
19
19
  toJsonSafeReport
20
- } from "./chunk-WX5DWEZM.js";
20
+ } from "./chunk-2YDH4SPS.js";
21
21
  import {
22
22
  BitfabError,
23
23
  CONTENT_OFF_KEY,
@@ -36,7 +36,7 @@ import {
36
36
  readEnv,
37
37
  recordCallerTraceMetadata,
38
38
  retireTraceMetadata
39
- } from "./chunk-2Y4FK7ND.js";
39
+ } from "./chunk-JIPKI6RB.js";
40
40
  import {
41
41
  __privateAdd,
42
42
  __privateGet,
@@ -3906,6 +3906,22 @@ var BitfabVercelAiHandler = class {
3906
3906
  };
3907
3907
 
3908
3908
  // src/client.ts
3909
+ function markTracedFunction(target, traceFunctionKey, original) {
3910
+ Object.defineProperty(target, "_bitfabTraceFunctionKey", {
3911
+ value: traceFunctionKey
3912
+ });
3913
+ Object.defineProperty(target, "_bitfabWrappedFn", { value: original });
3914
+ Object.defineProperty(target, "bind", {
3915
+ value(thisArg, ...boundArgs) {
3916
+ return markTracedFunction(
3917
+ Function.prototype.bind.call(this, thisArg, ...boundArgs),
3918
+ traceFunctionKey,
3919
+ original
3920
+ );
3921
+ }
3922
+ });
3923
+ return target;
3924
+ }
3909
3925
  function resolveSpanExperimentId(options) {
3910
3926
  const { experimentId, testRunId } = options;
3911
3927
  if (experimentId !== void 0 && testRunId !== void 0 && experimentId !== testRunId) {
@@ -4756,11 +4772,7 @@ var Bitfab = class {
4756
4772
  }
4757
4773
  );
4758
4774
  };
4759
- Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
4760
- value: traceFunctionKey
4761
- });
4762
- Object.defineProperty(autoTraceRoot, "_bitfabWrappedFn", { value: fn });
4763
- return autoTraceRoot;
4775
+ return markTracedFunction(autoTraceRoot, traceFunctionKey, fn);
4764
4776
  }
4765
4777
  applySimulationPlan(payload, submit, drop) {
4766
4778
  this.simulationPlan.send(
@@ -5775,11 +5787,7 @@ var Bitfab = class {
5775
5787
  }
5776
5788
  return runWithSpanStack(newStack, executeWithContext);
5777
5789
  };
5778
- Object.defineProperty(wrappedFn, "_bitfabTraceFunctionKey", {
5779
- value: traceFunctionKey
5780
- });
5781
- Object.defineProperty(wrappedFn, "_bitfabWrappedFn", { value: fn });
5782
- return wrappedFn;
5790
+ return markTracedFunction(wrappedFn, traceFunctionKey, fn);
5783
5791
  }
5784
5792
  /**
5785
5793
  * Create a standard ECMAScript method decorator that records each invocation
@@ -6245,7 +6253,7 @@ var Bitfab = class {
6245
6253
  await runWithSeedContext({ traceId }, async () => target(...args));
6246
6254
  } finally {
6247
6255
  try {
6248
- const { flushTraces: flushTraces2 } = await import("./http-5F6I4E2K.js");
6256
+ const { flushTraces: flushTraces2 } = await import("./http-KBTWSYL7.js");
6249
6257
  await flushTraces2(3e4);
6250
6258
  } finally {
6251
6259
  unrecorded = activeTraceStates.delete(traceId);
@@ -6304,7 +6312,7 @@ var Bitfab = class {
6304
6312
  `Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
6305
6313
  );
6306
6314
  }
6307
- const { replay: doReplay } = await import("./replay-DA2IX4KM.js");
6315
+ const { replay: doReplay } = await import("./replay-PFHS24KV.js");
6308
6316
  return doReplay(
6309
6317
  this.httpClient,
6310
6318
  this.serviceUrl,
@@ -6574,8 +6582,34 @@ var finalizers = {
6574
6582
 
6575
6583
  // src/replayRegistry.ts
6576
6584
  function defineReplayRegistry(registry) {
6585
+ validateReplayRegistry(registry);
6577
6586
  return registry;
6578
6587
  }
6588
+ var REGISTRATION_FIELDS = /* @__PURE__ */ new Set([
6589
+ "client",
6590
+ "fn",
6591
+ "traceFunctionKey",
6592
+ "options",
6593
+ "optionsFactory"
6594
+ ]);
6595
+ function validateReplayRegistry(registry) {
6596
+ for (const [pipeline, registration] of Object.entries(registry)) {
6597
+ if (typeof registration !== "object" || registration === null) {
6598
+ throw new BitfabError(
6599
+ `Replay registry entry '${pipeline}' must be an object with client and fn.`
6600
+ );
6601
+ }
6602
+ const unknownFields = Object.keys(registration).filter(
6603
+ (field) => !REGISTRATION_FIELDS.has(field)
6604
+ );
6605
+ if (unknownFields.length > 0) {
6606
+ warnOnce(
6607
+ `replay-registry-unknown-fields:${pipeline}:${unknownFields.join(",")}`,
6608
+ `Replay registry entry '${pipeline}' has unknown field(s): ${unknownFields.join(", ")}. They are ignored. An entry takes client, fn, traceFunctionKey, options, and optionsFactory. Put replay options such as adaptInputs, mock, and mockOverride inside options. A later SDK release will reject unknown fields.`
6609
+ );
6610
+ }
6611
+ }
6612
+ }
6579
6613
  async function reseedFromRegistry(registry, pipeline, traceIds) {
6580
6614
  const registration = registry[pipeline];
6581
6615
  if (registration === void 0) {
@@ -6624,7 +6658,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
6624
6658
  sessionId: seedCase.sessionId
6625
6659
  })
6626
6660
  );
6627
- const { flushTraces: flushTraces2 } = await import("./http-5F6I4E2K.js");
6661
+ const { flushTraces: flushTraces2 } = await import("./http-KBTWSYL7.js");
6628
6662
  await flushTraces2(3e4);
6629
6663
  return { pipeline, traceFunctionKey, traceIds };
6630
6664
  }
@@ -6669,4 +6703,4 @@ export {
6669
6703
  reseedFromRegistry,
6670
6704
  seedFromRegistry
6671
6705
  };
6672
- //# sourceMappingURL=chunk-BBBAQPIW.js.map
6706
+ //# sourceMappingURL=chunk-UZU2PNO7.js.map