@bitfab/sdk 0.36.11 → 0.36.13

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.
@@ -16,7 +16,7 @@ import {
16
16
  toJsonSafe,
17
17
  toJsonSafeReport,
18
18
  warnOnce
19
- } from "./chunk-EKOAKLZC.js";
19
+ } from "./chunk-VOUV7ZTS.js";
20
20
 
21
21
  // src/processorPayload.ts
22
22
  var SERIALIZATION_DEGRADED_STEP = "serialization_degraded";
@@ -2978,14 +2978,19 @@ var Bitfab = class {
2978
2978
  counters.set(counterKey, callIndex + 1);
2979
2979
  const mockKey = `${counterKey}:${callIndex}`;
2980
2980
  const mockSpan = replayCtxForMock.mockTree.spans.get(mockKey);
2981
- const emitMock = (output) => {
2982
- void sendSpan({ result: output, mocked: true });
2981
+ const emitMock = (output, mockSource) => {
2982
+ void sendSpan({
2983
+ result: output,
2984
+ mocked: true,
2985
+ mockTarget: "output",
2986
+ mockSource
2987
+ });
2983
2988
  if (fnReturnsPromise) {
2984
2989
  return Promise.resolve(output);
2985
2990
  }
2986
2991
  return output;
2987
2992
  };
2988
- const emitMockAsync = (pending) => {
2993
+ const emitMockAsync = (pending, mockSource) => {
2989
2994
  if (!fnReturnsPromise) {
2990
2995
  throw new BitfabError(
2991
2996
  `Cannot mock synchronous span "${traceFunctionKey}" with an asynchronously-resolved value (lazy recorded-output fetch or an async value function). Make the wrapped function async, or use mock: "all" so recorded outputs are fetched eagerly.`
@@ -2993,7 +2998,12 @@ var Bitfab = class {
2993
2998
  }
2994
2999
  return (async () => {
2995
3000
  const output = await pending;
2996
- void sendSpan({ result: output, mocked: true });
3001
+ void sendSpan({
3002
+ result: output,
3003
+ mocked: true,
3004
+ mockTarget: "output",
3005
+ mockSource
3006
+ });
2997
3007
  return output;
2998
3008
  })();
2999
3009
  };
@@ -3035,18 +3045,23 @@ var Bitfab = class {
3035
3045
  getOriginalOutput: () => Promise.resolve(resolveRecordedOutput())
3036
3046
  });
3037
3047
  if (injected instanceof Promise) {
3038
- return emitMockAsync(injected);
3048
+ return emitMockAsync(injected, "override");
3039
3049
  }
3040
- return emitMock(injected);
3050
+ return emitMock(injected, "override");
3041
3051
  }
3042
3052
  }
3043
3053
  const shouldMock = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
3044
- if (shouldMock && mockSpan) {
3054
+ if (shouldMock && !mockSpan) {
3055
+ throw new BitfabError(
3056
+ `Replay selected span "${traceFunctionKey}:${baseSpanParams.spanName}" for mocking, but recorded occurrence ${callIndex + 1} is unavailable. The real span was not executed.`
3057
+ );
3058
+ }
3059
+ if (shouldMock) {
3045
3060
  const recorded = resolveRecordedOutput();
3046
3061
  if (recorded instanceof Promise) {
3047
- return emitMockAsync(recorded);
3062
+ return emitMockAsync(recorded, "recorded");
3048
3063
  }
3049
- return emitMock(recorded);
3064
+ return emitMock(recorded, "recorded");
3050
3065
  }
3051
3066
  }
3052
3067
  const recordSpan = (result) => {
@@ -3346,7 +3361,9 @@ var Bitfab = class {
3346
3361
  traceFunctionKey: params.traceFunctionKey,
3347
3362
  rawSpan: externalSpan,
3348
3363
  ...params.testRunId && { testRunId: params.testRunId },
3349
- ...params.mocked && { mocked: true }
3364
+ ...params.mocked && { mocked: true },
3365
+ ...params.mockTarget && { mockTarget: params.mockTarget },
3366
+ ...params.mockSource && { mockSource: params.mockSource }
3350
3367
  });
3351
3368
  }
3352
3369
  registerMockOverride(overrideOrMatch, value) {
@@ -3371,7 +3388,7 @@ var Bitfab = class {
3371
3388
  `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.`
3372
3389
  );
3373
3390
  }
3374
- const { replay: doReplay } = await import("./replay-TW3ONJ3W.js");
3391
+ const { replay: doReplay } = await import("./replay-WHZFV6OB.js");
3375
3392
  return doReplay(
3376
3393
  this.httpClient,
3377
3394
  this.serviceUrl,
@@ -3609,4 +3626,4 @@ export {
3609
3626
  BitfabFunction,
3610
3627
  finalizers
3611
3628
  };
3612
- //# sourceMappingURL=chunk-VDFPZYLH.js.map
3629
+ //# sourceMappingURL=chunk-XAQJOZMJ.js.map