bitfab 0.36.0 → 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.
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.0";
54
+ __version__ = "0.36.2";
55
55
  }
56
56
  });
57
57
 
@@ -1530,9 +1530,11 @@ var init_http = __esm({
1530
1530
  /**
1531
1531
  * Fetch an external span by ID.
1532
1532
  * Blocking GET request.
1533
+ * The replay view limits rawData to input/output serialization fields.
1533
1534
  */
1534
- async getExternalSpan(spanId) {
1535
- const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}`;
1535
+ async getExternalSpan(spanId, options) {
1536
+ const query = options?.view === "replay" ? "?view=replay" : "";
1537
+ const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}${query}`;
1536
1538
  const controller = new AbortController();
1537
1539
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
1538
1540
  try {
@@ -1570,9 +1572,18 @@ var init_http = __esm({
1570
1572
  * Pass `includeOutputs: false` for a payload-free tree (structure +
1571
1573
  * `externalSpanId` only), so recorded outputs are fetched lazily per mocked
1572
1574
  * span instead of all up front. Omit it (default eager) for `mock: "all"`.
1575
+ * Pass `includeRootOutput: false` when the root was already fetched.
1573
1576
  */
1574
1577
  async getSpanTree(externalSpanId, options) {
1575
- const query = options?.includeOutputs === false ? "?includeOutputs=false" : "";
1578
+ const searchParams = new URLSearchParams();
1579
+ if (options?.includeOutputs === false) {
1580
+ searchParams.set("includeOutputs", "false");
1581
+ }
1582
+ if (options?.includeRootOutput === false) {
1583
+ searchParams.set("includeRootOutput", "false");
1584
+ }
1585
+ const encodedQuery = searchParams.toString();
1586
+ const query = encodedQuery ? `?${encodedQuery}` : "";
1576
1587
  const url = `${this.serviceUrl}/api/sdk/replay/spanTree/${externalSpanId}${query}`;
1577
1588
  const controller = new AbortController();
1578
1589
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
@@ -2155,7 +2166,9 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2155
2166
  `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.`
2156
2167
  );
2157
2168
  }
2158
- const span = await httpClient.getExternalSpan(originalSpanId);
2169
+ const span = await httpClient.getExternalSpan(originalSpanId, {
2170
+ view: "replay"
2171
+ });
2159
2172
  const spanData = span.rawData?.span_data ?? {};
2160
2173
  inputs = deserializeInputs(spanData);
2161
2174
  originalOutput = deserializeOutput(spanData);
@@ -2175,7 +2188,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2175
2188
  if (needTree) {
2176
2189
  try {
2177
2190
  const treeResponse = await httpClient.getSpanTree(originalSpanId, {
2178
- includeOutputs
2191
+ includeOutputs,
2192
+ includeRootOutput: false
2179
2193
  });
2180
2194
  if (treeResponse.root) {
2181
2195
  mockTree = buildMockTree(treeResponse.root);
@@ -2197,7 +2211,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2197
2211
  const fetchSpanOutput = mockTree && !includeOutputs ? (externalSpanId) => {
2198
2212
  let pending = outputCache.get(externalSpanId);
2199
2213
  if (!pending) {
2200
- pending = httpClient.getExternalSpan(externalSpanId).then(
2214
+ pending = httpClient.getExternalSpan(externalSpanId, { view: "replay" }).then(
2201
2215
  (s) => deserializeOutput(
2202
2216
  s.rawData?.span_data ?? {}
2203
2217
  )
@@ -4190,12 +4204,20 @@ var ReplayBranch = class {
4190
4204
  // context can ride along into a log line or a serialized payload.
4191
4205
  __privateAdd(this, _url);
4192
4206
  __privateAdd(this, _context);
4193
- this.expiresAt = lease.expiresAt;
4194
- this.providerConsoleUrl = lease.providerConsoleUrl;
4195
- this.readOnly = lease.readOnly;
4196
- this.region = lease.region;
4197
- this.traceId = traceId;
4198
- __privateSet(this, _url, lease.databaseUrl);
4207
+ const { databaseUrl, ...exposed } = lease;
4208
+ for (const [key, value] of Object.entries(exposed)) {
4209
+ Object.defineProperty(this, key, {
4210
+ value,
4211
+ enumerable: true,
4212
+ configurable: true
4213
+ });
4214
+ }
4215
+ Object.defineProperty(this, "traceId", {
4216
+ value: traceId,
4217
+ enumerable: true,
4218
+ configurable: true
4219
+ });
4220
+ __privateSet(this, _url, databaseUrl);
4199
4221
  __privateSet(this, _context, context);
4200
4222
  }
4201
4223
  /**
@@ -5535,6 +5557,7 @@ var Bitfab = class {
5535
5557
  dbSnapshotUsage: {
5536
5558
  neonBranchId: replayCtx.dbBranchLease.neonBranchId,
5537
5559
  snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
5560
+ region: replayCtx.dbBranchLease.region,
5538
5561
  originalTraceId: replayCtx.sourceBitfabTraceId,
5539
5562
  accessed: replayCtx.dbSnapshotAccessed === true
5540
5563
  }
@@ -5810,6 +5833,9 @@ var Bitfab = class {
5810
5833
  ...params.dbSnapshotUsage.snapshotTimestamp && {
5811
5834
  snapshot_timestamp: params.dbSnapshotUsage.snapshotTimestamp
5812
5835
  },
5836
+ ...params.dbSnapshotUsage.region && {
5837
+ region: params.dbSnapshotUsage.region
5838
+ },
5813
5839
  ...params.dbSnapshotUsage.originalTraceId && {
5814
5840
  original_trace_id: params.dbSnapshotUsage.originalTraceId,
5815
5841
  // Deprecated wire alias, kept so this SDK still reports usage