bitfab 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.
- package/dist/{chunk-EKOAKLZC.js → chunk-VOUV7ZTS.js} +8 -11
- package/dist/chunk-VOUV7ZTS.js.map +1 -0
- package/dist/{chunk-VDFPZYLH.js → chunk-XAQJOZMJ.js} +30 -13
- package/dist/chunk-XAQJOZMJ.js.map +1 -0
- package/dist/index.cjs +34 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +2 -2
- package/dist/node.cjs +34 -20
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-TW3ONJ3W.js → replay-WHZFV6OB.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-EKOAKLZC.js.map +0 -1
- package/dist/chunk-VDFPZYLH.js.map +0 -1
- /package/dist/{replay-TW3ONJ3W.js.map → replay-WHZFV6OB.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __version__;
|
|
|
51
51
|
var init_version_generated = __esm({
|
|
52
52
|
"src/version.generated.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
__version__ = "0.36.
|
|
54
|
+
__version__ = "0.36.13";
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -2595,20 +2595,17 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
2595
2595
|
includeOutputs,
|
|
2596
2596
|
includeRootOutput: false
|
|
2597
2597
|
});
|
|
2598
|
-
if (treeResponse.root) {
|
|
2599
|
-
mockTree = buildMockTree(treeResponse.root);
|
|
2600
|
-
} else if (mockStrategy === "all" || hasOverrides) {
|
|
2598
|
+
if (!treeResponse.root) {
|
|
2601
2599
|
throw new BitfabError(
|
|
2602
2600
|
`Replay mock strategy "${mockStrategy}"${hasOverrides ? " with overrides" : ""} requires a span tree root for original span ${originalSpanId}.`
|
|
2603
2601
|
);
|
|
2604
|
-
} else {
|
|
2605
|
-
mockTree = void 0;
|
|
2606
2602
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2603
|
+
mockTree = buildMockTree(treeResponse.root);
|
|
2604
|
+
} catch (error2) {
|
|
2605
|
+
if (mockStrategy !== "marked" || hasOverrides) {
|
|
2606
|
+
throw error2;
|
|
2610
2607
|
}
|
|
2611
|
-
mockTree =
|
|
2608
|
+
mockTree = { spans: /* @__PURE__ */ new Map() };
|
|
2612
2609
|
}
|
|
2613
2610
|
}
|
|
2614
2611
|
const outputCache = /* @__PURE__ */ new Map();
|
|
@@ -6110,14 +6107,19 @@ var Bitfab = class {
|
|
|
6110
6107
|
counters.set(counterKey, callIndex + 1);
|
|
6111
6108
|
const mockKey = `${counterKey}:${callIndex}`;
|
|
6112
6109
|
const mockSpan = replayCtxForMock.mockTree.spans.get(mockKey);
|
|
6113
|
-
const emitMock = (output) => {
|
|
6114
|
-
void sendSpan({
|
|
6110
|
+
const emitMock = (output, mockSource) => {
|
|
6111
|
+
void sendSpan({
|
|
6112
|
+
result: output,
|
|
6113
|
+
mocked: true,
|
|
6114
|
+
mockTarget: "output",
|
|
6115
|
+
mockSource
|
|
6116
|
+
});
|
|
6115
6117
|
if (fnReturnsPromise) {
|
|
6116
6118
|
return Promise.resolve(output);
|
|
6117
6119
|
}
|
|
6118
6120
|
return output;
|
|
6119
6121
|
};
|
|
6120
|
-
const emitMockAsync = (pending) => {
|
|
6122
|
+
const emitMockAsync = (pending, mockSource) => {
|
|
6121
6123
|
if (!fnReturnsPromise) {
|
|
6122
6124
|
throw new BitfabError(
|
|
6123
6125
|
`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.`
|
|
@@ -6125,7 +6127,12 @@ var Bitfab = class {
|
|
|
6125
6127
|
}
|
|
6126
6128
|
return (async () => {
|
|
6127
6129
|
const output = await pending;
|
|
6128
|
-
void sendSpan({
|
|
6130
|
+
void sendSpan({
|
|
6131
|
+
result: output,
|
|
6132
|
+
mocked: true,
|
|
6133
|
+
mockTarget: "output",
|
|
6134
|
+
mockSource
|
|
6135
|
+
});
|
|
6129
6136
|
return output;
|
|
6130
6137
|
})();
|
|
6131
6138
|
};
|
|
@@ -6167,18 +6174,23 @@ var Bitfab = class {
|
|
|
6167
6174
|
getOriginalOutput: () => Promise.resolve(resolveRecordedOutput())
|
|
6168
6175
|
});
|
|
6169
6176
|
if (injected instanceof Promise) {
|
|
6170
|
-
return emitMockAsync(injected);
|
|
6177
|
+
return emitMockAsync(injected, "override");
|
|
6171
6178
|
}
|
|
6172
|
-
return emitMock(injected);
|
|
6179
|
+
return emitMock(injected, "override");
|
|
6173
6180
|
}
|
|
6174
6181
|
}
|
|
6175
6182
|
const shouldMock = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
|
|
6176
|
-
if (shouldMock && mockSpan) {
|
|
6183
|
+
if (shouldMock && !mockSpan) {
|
|
6184
|
+
throw new BitfabError(
|
|
6185
|
+
`Replay selected span "${traceFunctionKey}:${baseSpanParams.spanName}" for mocking, but recorded occurrence ${callIndex + 1} is unavailable. The real span was not executed.`
|
|
6186
|
+
);
|
|
6187
|
+
}
|
|
6188
|
+
if (shouldMock) {
|
|
6177
6189
|
const recorded = resolveRecordedOutput();
|
|
6178
6190
|
if (recorded instanceof Promise) {
|
|
6179
|
-
return emitMockAsync(recorded);
|
|
6191
|
+
return emitMockAsync(recorded, "recorded");
|
|
6180
6192
|
}
|
|
6181
|
-
return emitMock(recorded);
|
|
6193
|
+
return emitMock(recorded, "recorded");
|
|
6182
6194
|
}
|
|
6183
6195
|
}
|
|
6184
6196
|
const recordSpan = (result) => {
|
|
@@ -6478,7 +6490,9 @@ var Bitfab = class {
|
|
|
6478
6490
|
traceFunctionKey: params.traceFunctionKey,
|
|
6479
6491
|
rawSpan: externalSpan,
|
|
6480
6492
|
...params.testRunId && { testRunId: params.testRunId },
|
|
6481
|
-
...params.mocked && { mocked: true }
|
|
6493
|
+
...params.mocked && { mocked: true },
|
|
6494
|
+
...params.mockTarget && { mockTarget: params.mockTarget },
|
|
6495
|
+
...params.mockSource && { mockSource: params.mockSource }
|
|
6482
6496
|
});
|
|
6483
6497
|
}
|
|
6484
6498
|
registerMockOverride(overrideOrMatch, value) {
|