@bitfab/sdk 0.36.1 → 0.36.2

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-6ZBZBR5K.js";
19
+ } from "./chunk-4IY5SZYR.js";
20
20
 
21
21
  // src/processorPayload.ts
22
22
  var SERIALIZATION_DEGRADED_STEP = "serialization_degraded";
@@ -3337,7 +3337,7 @@ var Bitfab = class {
3337
3337
  `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.`
3338
3338
  );
3339
3339
  }
3340
- const { replay: doReplay } = await import("./replay-ZR4KIZIB.js");
3340
+ const { replay: doReplay } = await import("./replay-UGABWDPP.js");
3341
3341
  return doReplay(
3342
3342
  this.httpClient,
3343
3343
  this.serviceUrl,
@@ -3554,4 +3554,4 @@ export {
3554
3554
  BitfabFunction,
3555
3555
  finalizers
3556
3556
  };
3557
- //# sourceMappingURL=chunk-HD4DRDRE.js.map
3557
+ //# sourceMappingURL=chunk-XZKYSTWH.js.map
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var __version__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.36.1";
45
+ __version__ = "0.36.2";
46
46
  }
47
47
  });
48
48
 
@@ -1521,9 +1521,11 @@ var init_http = __esm({
1521
1521
  /**
1522
1522
  * Fetch an external span by ID.
1523
1523
  * Blocking GET request.
1524
+ * The replay view limits rawData to input/output serialization fields.
1524
1525
  */
1525
- async getExternalSpan(spanId) {
1526
- const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}`;
1526
+ async getExternalSpan(spanId, options) {
1527
+ const query = options?.view === "replay" ? "?view=replay" : "";
1528
+ const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}${query}`;
1527
1529
  const controller = new AbortController();
1528
1530
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
1529
1531
  try {
@@ -1561,9 +1563,18 @@ var init_http = __esm({
1561
1563
  * Pass `includeOutputs: false` for a payload-free tree (structure +
1562
1564
  * `externalSpanId` only), so recorded outputs are fetched lazily per mocked
1563
1565
  * span instead of all up front. Omit it (default eager) for `mock: "all"`.
1566
+ * Pass `includeRootOutput: false` when the root was already fetched.
1564
1567
  */
1565
1568
  async getSpanTree(externalSpanId, options) {
1566
- const query = options?.includeOutputs === false ? "?includeOutputs=false" : "";
1569
+ const searchParams = new URLSearchParams();
1570
+ if (options?.includeOutputs === false) {
1571
+ searchParams.set("includeOutputs", "false");
1572
+ }
1573
+ if (options?.includeRootOutput === false) {
1574
+ searchParams.set("includeRootOutput", "false");
1575
+ }
1576
+ const encodedQuery = searchParams.toString();
1577
+ const query = encodedQuery ? `?${encodedQuery}` : "";
1567
1578
  const url = `${this.serviceUrl}/api/sdk/replay/spanTree/${externalSpanId}${query}`;
1568
1579
  const controller = new AbortController();
1569
1580
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
@@ -2146,7 +2157,9 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2146
2157
  `Replay requested a database branch for trace ${originalTraceId} but it could not be resolved (${leaseError.code}): ${leaseError.message}. The function was not run, because replaying it against the live database would produce a result that looks valid but did not use the historical data you asked for.`
2147
2158
  );
2148
2159
  }
2149
- const span = await httpClient.getExternalSpan(originalSpanId);
2160
+ const span = await httpClient.getExternalSpan(originalSpanId, {
2161
+ view: "replay"
2162
+ });
2150
2163
  const spanData = span.rawData?.span_data ?? {};
2151
2164
  inputs = deserializeInputs(spanData);
2152
2165
  originalOutput = deserializeOutput(spanData);
@@ -2166,7 +2179,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2166
2179
  if (needTree) {
2167
2180
  try {
2168
2181
  const treeResponse = await httpClient.getSpanTree(originalSpanId, {
2169
- includeOutputs
2182
+ includeOutputs,
2183
+ includeRootOutput: false
2170
2184
  });
2171
2185
  if (treeResponse.root) {
2172
2186
  mockTree = buildMockTree(treeResponse.root);
@@ -2188,7 +2202,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2188
2202
  const fetchSpanOutput = mockTree && !includeOutputs ? (externalSpanId) => {
2189
2203
  let pending = outputCache.get(externalSpanId);
2190
2204
  if (!pending) {
2191
- pending = httpClient.getExternalSpan(externalSpanId).then(
2205
+ pending = httpClient.getExternalSpan(externalSpanId, { view: "replay" }).then(
2192
2206
  (s) => deserializeOutput(
2193
2207
  s.rawData?.span_data ?? {}
2194
2208
  )