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.d.cts CHANGED
@@ -266,9 +266,11 @@ interface ReplayContext {
266
266
  * obtains `databaseUrl` for this item. Reported on the trace completion inside
267
267
  * `db_snapshot_usage` so the server can distinguish "branch was
268
268
  * provisioned and exposed" from "branch URL was actually consumed".
269
- * Any future consumption path that hands the URL to customer code by
270
- * other means (e.g. a process-isolated runner writing an env overlay)
271
- * must also set this.
269
+ * Only an explicit `databaseUrl` read may set it. A path that hands the URL
270
+ * over by other means (e.g. a process-isolated runner writing an env
271
+ * overlay) must leave it alone: setting it there would make every such
272
+ * replay report `accessed` for free, and the flag would stop separating
273
+ * "branch was used" from "branch was offered".
272
274
  */
273
275
  dbSnapshotAccessed?: boolean;
274
276
  }
@@ -455,8 +457,11 @@ declare class HttpClient {
455
457
  /**
456
458
  * Fetch an external span by ID.
457
459
  * Blocking GET request.
460
+ * The replay view limits rawData to input/output serialization fields.
458
461
  */
459
- getExternalSpan(spanId: string): Promise<ExternalSpanResponse>;
462
+ getExternalSpan(spanId: string, options?: {
463
+ view?: "full" | "replay";
464
+ }): Promise<ExternalSpanResponse>;
460
465
  /**
461
466
  * Fetch the span tree for a root span.
462
467
  * Blocking GET request.
@@ -464,9 +469,11 @@ declare class HttpClient {
464
469
  * Pass `includeOutputs: false` for a payload-free tree (structure +
465
470
  * `externalSpanId` only), so recorded outputs are fetched lazily per mocked
466
471
  * span instead of all up front. Omit it (default eager) for `mock: "all"`.
472
+ * Pass `includeRootOutput: false` when the root was already fetched.
467
473
  */
468
474
  getSpanTree(externalSpanId: string, options?: {
469
475
  includeOutputs?: boolean;
476
+ includeRootOutput?: boolean;
470
477
  }): Promise<SpanTreeResponse>;
471
478
  /**
472
479
  * Read which of a replay run's traces the server has fully persisted.
@@ -1393,10 +1400,20 @@ interface ReplayResult<T> {
1393
1400
  * exposed directly here so customer code never sees the word.
1394
1401
  */
1395
1402
 
1396
- declare class ReplayBranch {
1403
+ declare class ReplayBranch implements Omit<DbBranchLease, "databaseUrl"> {
1397
1404
  #private;
1405
+ /** The provider's own id for this branch, e.g. for correlating with its console. */
1406
+ readonly neonBranchId: string;
1407
+ /** Env var name the customer's app reads, e.g. `DATABASE_URL`. */
1408
+ readonly envKey: string;
1398
1409
  /** When this branch's URL stops being valid. ISO-8601. */
1399
1410
  readonly expiresAt: string;
1411
+ /**
1412
+ * The instant this branch is pinned to: the source trace's wall clock, read
1413
+ * just before the traced function ran. Compare it against the trace you meant
1414
+ * to replay to confirm the branch is the right point in history.
1415
+ */
1416
+ readonly snapshotTimestamp?: string;
1400
1417
  /** Deep link to the branch in the provider console, if available. */
1401
1418
  readonly providerConsoleUrl?: string;
1402
1419
  /**
@@ -2336,7 +2353,7 @@ declare class BitfabFunction {
2336
2353
  /**
2337
2354
  * SDK version from package.json (injected at build time)
2338
2355
  */
2339
- declare const __version__ = "0.36.0";
2356
+ declare const __version__ = "0.36.2";
2340
2357
 
2341
2358
  /**
2342
2359
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -266,9 +266,11 @@ interface ReplayContext {
266
266
  * obtains `databaseUrl` for this item. Reported on the trace completion inside
267
267
  * `db_snapshot_usage` so the server can distinguish "branch was
268
268
  * provisioned and exposed" from "branch URL was actually consumed".
269
- * Any future consumption path that hands the URL to customer code by
270
- * other means (e.g. a process-isolated runner writing an env overlay)
271
- * must also set this.
269
+ * Only an explicit `databaseUrl` read may set it. A path that hands the URL
270
+ * over by other means (e.g. a process-isolated runner writing an env
271
+ * overlay) must leave it alone: setting it there would make every such
272
+ * replay report `accessed` for free, and the flag would stop separating
273
+ * "branch was used" from "branch was offered".
272
274
  */
273
275
  dbSnapshotAccessed?: boolean;
274
276
  }
@@ -455,8 +457,11 @@ declare class HttpClient {
455
457
  /**
456
458
  * Fetch an external span by ID.
457
459
  * Blocking GET request.
460
+ * The replay view limits rawData to input/output serialization fields.
458
461
  */
459
- getExternalSpan(spanId: string): Promise<ExternalSpanResponse>;
462
+ getExternalSpan(spanId: string, options?: {
463
+ view?: "full" | "replay";
464
+ }): Promise<ExternalSpanResponse>;
460
465
  /**
461
466
  * Fetch the span tree for a root span.
462
467
  * Blocking GET request.
@@ -464,9 +469,11 @@ declare class HttpClient {
464
469
  * Pass `includeOutputs: false` for a payload-free tree (structure +
465
470
  * `externalSpanId` only), so recorded outputs are fetched lazily per mocked
466
471
  * span instead of all up front. Omit it (default eager) for `mock: "all"`.
472
+ * Pass `includeRootOutput: false` when the root was already fetched.
467
473
  */
468
474
  getSpanTree(externalSpanId: string, options?: {
469
475
  includeOutputs?: boolean;
476
+ includeRootOutput?: boolean;
470
477
  }): Promise<SpanTreeResponse>;
471
478
  /**
472
479
  * Read which of a replay run's traces the server has fully persisted.
@@ -1393,10 +1400,20 @@ interface ReplayResult<T> {
1393
1400
  * exposed directly here so customer code never sees the word.
1394
1401
  */
1395
1402
 
1396
- declare class ReplayBranch {
1403
+ declare class ReplayBranch implements Omit<DbBranchLease, "databaseUrl"> {
1397
1404
  #private;
1405
+ /** The provider's own id for this branch, e.g. for correlating with its console. */
1406
+ readonly neonBranchId: string;
1407
+ /** Env var name the customer's app reads, e.g. `DATABASE_URL`. */
1408
+ readonly envKey: string;
1398
1409
  /** When this branch's URL stops being valid. ISO-8601. */
1399
1410
  readonly expiresAt: string;
1411
+ /**
1412
+ * The instant this branch is pinned to: the source trace's wall clock, read
1413
+ * just before the traced function ran. Compare it against the trace you meant
1414
+ * to replay to confirm the branch is the right point in history.
1415
+ */
1416
+ readonly snapshotTimestamp?: string;
1400
1417
  /** Deep link to the branch in the provider console, if available. */
1401
1418
  readonly providerConsoleUrl?: string;
1402
1419
  /**
@@ -2336,7 +2353,7 @@ declare class BitfabFunction {
2336
2353
  /**
2337
2354
  * SDK version from package.json (injected at build time)
2338
2355
  */
2339
- declare const __version__ = "0.36.0";
2356
+ declare const __version__ = "0.36.2";
2340
2357
 
2341
2358
  /**
2342
2359
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  getCurrentReplayBranch,
21
21
  getCurrentSpan,
22
22
  getCurrentTrace
23
- } from "./chunk-JECWMVJG.js";
23
+ } from "./chunk-XZKYSTWH.js";
24
24
  import {
25
25
  BITFAB_PROGRESS_PREFIX,
26
26
  BitfabError,
@@ -29,7 +29,7 @@ import {
29
29
  __version__,
30
30
  flushTraces,
31
31
  reportReplayProgress
32
- } from "./chunk-4YTIVUYX.js";
32
+ } from "./chunk-4IY5SZYR.js";
33
33
  export {
34
34
  BITFAB_PROGRESS_PREFIX,
35
35
  Bitfab,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.36.0";
100
+ __version__ = "0.36.2";
101
101
  }
102
102
  });
103
103
 
@@ -1537,9 +1537,11 @@ var init_http = __esm({
1537
1537
  /**
1538
1538
  * Fetch an external span by ID.
1539
1539
  * Blocking GET request.
1540
+ * The replay view limits rawData to input/output serialization fields.
1540
1541
  */
1541
- async getExternalSpan(spanId) {
1542
- const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}`;
1542
+ async getExternalSpan(spanId, options) {
1543
+ const query = options?.view === "replay" ? "?view=replay" : "";
1544
+ const url = `${this.serviceUrl}/api/sdk/externalSpans/${spanId}${query}`;
1543
1545
  const controller = new AbortController();
1544
1546
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
1545
1547
  try {
@@ -1577,9 +1579,18 @@ var init_http = __esm({
1577
1579
  * Pass `includeOutputs: false` for a payload-free tree (structure +
1578
1580
  * `externalSpanId` only), so recorded outputs are fetched lazily per mocked
1579
1581
  * span instead of all up front. Omit it (default eager) for `mock: "all"`.
1582
+ * Pass `includeRootOutput: false` when the root was already fetched.
1580
1583
  */
1581
1584
  async getSpanTree(externalSpanId, options) {
1582
- const query = options?.includeOutputs === false ? "?includeOutputs=false" : "";
1585
+ const searchParams = new URLSearchParams();
1586
+ if (options?.includeOutputs === false) {
1587
+ searchParams.set("includeOutputs", "false");
1588
+ }
1589
+ if (options?.includeRootOutput === false) {
1590
+ searchParams.set("includeRootOutput", "false");
1591
+ }
1592
+ const encodedQuery = searchParams.toString();
1593
+ const query = encodedQuery ? `?${encodedQuery}` : "";
1583
1594
  const url = `${this.serviceUrl}/api/sdk/replay/spanTree/${externalSpanId}${query}`;
1584
1595
  const controller = new AbortController();
1585
1596
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
@@ -2162,7 +2173,9 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2162
2173
  `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.`
2163
2174
  );
2164
2175
  }
2165
- const span = await httpClient.getExternalSpan(originalSpanId);
2176
+ const span = await httpClient.getExternalSpan(originalSpanId, {
2177
+ view: "replay"
2178
+ });
2166
2179
  const spanData = span.rawData?.span_data ?? {};
2167
2180
  inputs = deserializeInputs(spanData);
2168
2181
  originalOutput = deserializeOutput(spanData);
@@ -2182,7 +2195,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2182
2195
  if (needTree) {
2183
2196
  try {
2184
2197
  const treeResponse = await httpClient.getSpanTree(originalSpanId, {
2185
- includeOutputs
2198
+ includeOutputs,
2199
+ includeRootOutput: false
2186
2200
  });
2187
2201
  if (treeResponse.root) {
2188
2202
  mockTree = buildMockTree(treeResponse.root);
@@ -2204,7 +2218,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2204
2218
  const fetchSpanOutput = mockTree && !includeOutputs ? (externalSpanId) => {
2205
2219
  let pending = outputCache.get(externalSpanId);
2206
2220
  if (!pending) {
2207
- pending = httpClient.getExternalSpan(externalSpanId).then(
2221
+ pending = httpClient.getExternalSpan(externalSpanId, { view: "replay" }).then(
2208
2222
  (s) => deserializeOutput(
2209
2223
  s.rawData?.span_data ?? {}
2210
2224
  )
@@ -4204,12 +4218,20 @@ var ReplayBranch = class {
4204
4218
  // context can ride along into a log line or a serialized payload.
4205
4219
  __privateAdd(this, _url);
4206
4220
  __privateAdd(this, _context);
4207
- this.expiresAt = lease.expiresAt;
4208
- this.providerConsoleUrl = lease.providerConsoleUrl;
4209
- this.readOnly = lease.readOnly;
4210
- this.region = lease.region;
4211
- this.traceId = traceId;
4212
- __privateSet(this, _url, lease.databaseUrl);
4221
+ const { databaseUrl, ...exposed } = lease;
4222
+ for (const [key, value] of Object.entries(exposed)) {
4223
+ Object.defineProperty(this, key, {
4224
+ value,
4225
+ enumerable: true,
4226
+ configurable: true
4227
+ });
4228
+ }
4229
+ Object.defineProperty(this, "traceId", {
4230
+ value: traceId,
4231
+ enumerable: true,
4232
+ configurable: true
4233
+ });
4234
+ __privateSet(this, _url, databaseUrl);
4213
4235
  __privateSet(this, _context, context);
4214
4236
  }
4215
4237
  /**
@@ -5549,6 +5571,7 @@ var Bitfab = class {
5549
5571
  dbSnapshotUsage: {
5550
5572
  neonBranchId: replayCtx.dbBranchLease.neonBranchId,
5551
5573
  snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
5574
+ region: replayCtx.dbBranchLease.region,
5552
5575
  originalTraceId: replayCtx.sourceBitfabTraceId,
5553
5576
  accessed: replayCtx.dbSnapshotAccessed === true
5554
5577
  }
@@ -5824,6 +5847,9 @@ var Bitfab = class {
5824
5847
  ...params.dbSnapshotUsage.snapshotTimestamp && {
5825
5848
  snapshot_timestamp: params.dbSnapshotUsage.snapshotTimestamp
5826
5849
  },
5850
+ ...params.dbSnapshotUsage.region && {
5851
+ region: params.dbSnapshotUsage.region
5852
+ },
5827
5853
  ...params.dbSnapshotUsage.originalTraceId && {
5828
5854
  original_trace_id: params.dbSnapshotUsage.originalTraceId,
5829
5855
  // Deprecated wire alias, kept so this SDK still reports usage