bitfab 0.18.1 → 0.18.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
@@ -335,6 +335,14 @@ declare class ReplayEnvironment {
335
335
  get active(): boolean;
336
336
  /** Non-throwing variant for callers that handle the inactive case. */
337
337
  snapshot(): ReplayEnvironmentSnapshot | null;
338
+ /**
339
+ * Record on the replay context that customer code obtained the branch
340
+ * URL. Only `databaseUrl` and `snapshot()` count — `active`, `readOnly`
341
+ * and friends inspect the lease without exposing the connection string,
342
+ * so they don't prove the replayed code could have connected to the
343
+ * branch.
344
+ */
345
+ private markAccessed;
338
346
  private read;
339
347
  private require;
340
348
  }
@@ -1055,7 +1063,7 @@ declare class BitfabFunction {
1055
1063
  /**
1056
1064
  * SDK version from package.json (injected at build time)
1057
1065
  */
1058
- declare const __version__ = "0.18.1";
1066
+ declare const __version__ = "0.18.2";
1059
1067
 
1060
1068
  /**
1061
1069
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -335,6 +335,14 @@ declare class ReplayEnvironment {
335
335
  get active(): boolean;
336
336
  /** Non-throwing variant for callers that handle the inactive case. */
337
337
  snapshot(): ReplayEnvironmentSnapshot | null;
338
+ /**
339
+ * Record on the replay context that customer code obtained the branch
340
+ * URL. Only `databaseUrl` and `snapshot()` count — `active`, `readOnly`
341
+ * and friends inspect the lease without exposing the connection string,
342
+ * so they don't prove the replayed code could have connected to the
343
+ * branch.
344
+ */
345
+ private markAccessed;
338
346
  private read;
339
347
  private require;
340
348
  }
@@ -1055,7 +1063,7 @@ declare class BitfabFunction {
1055
1063
  /**
1056
1064
  * SDK version from package.json (injected at build time)
1057
1065
  */
1058
- declare const __version__ = "0.18.1";
1066
+ declare const __version__ = "0.18.2";
1059
1067
 
1060
1068
  /**
1061
1069
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -20,10 +20,10 @@ import {
20
20
  flushTraces,
21
21
  getCurrentSpan,
22
22
  getCurrentTrace
23
- } from "./chunk-ILIUTS5D.js";
23
+ } from "./chunk-UTVFKV2Z.js";
24
24
  import {
25
25
  BitfabError
26
- } from "./chunk-QT7HWOKU.js";
26
+ } from "./chunk-PY6V4FE3.js";
27
27
  export {
28
28
  Bitfab,
29
29
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -456,7 +456,7 @@ registerAsyncLocalStorageClass(
456
456
  );
457
457
 
458
458
  // src/version.generated.ts
459
- var __version__ = "0.18.1";
459
+ var __version__ = "0.18.2";
460
460
 
461
461
  // src/constants.ts
462
462
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -2171,7 +2171,9 @@ var ReplayEnvironment = class {
2171
2171
  * Throws if read outside a replay item.
2172
2172
  */
2173
2173
  get databaseUrl() {
2174
- return this.require().databaseUrl;
2174
+ const snapshot = this.require();
2175
+ this.markAccessed();
2176
+ return snapshot.databaseUrl;
2175
2177
  }
2176
2178
  /** When the per-trace branch URL stops being valid. ISO-8601. */
2177
2179
  get expiresAt() {
@@ -2199,7 +2201,24 @@ var ReplayEnvironment = class {
2199
2201
  }
2200
2202
  /** Non-throwing variant for callers that handle the inactive case. */
2201
2203
  snapshot() {
2202
- return this.read();
2204
+ const snapshot = this.read();
2205
+ if (snapshot) {
2206
+ this.markAccessed();
2207
+ }
2208
+ return snapshot;
2209
+ }
2210
+ /**
2211
+ * Record on the replay context that customer code obtained the branch
2212
+ * URL. Only `databaseUrl` and `snapshot()` count — `active`, `readOnly`
2213
+ * and friends inspect the lease without exposing the connection string,
2214
+ * so they don't prove the replayed code could have connected to the
2215
+ * branch.
2216
+ */
2217
+ markAccessed() {
2218
+ const ctx = getReplayContext();
2219
+ if (ctx?.dbBranchLease) {
2220
+ ctx.dbSnapshotAccessed = true;
2221
+ }
2203
2222
  }
2204
2223
  read() {
2205
2224
  const ctx = getReplayContext();
@@ -3131,7 +3150,19 @@ var Bitfab = class {
3131
3150
  contexts: traceState?.contexts ?? [],
3132
3151
  testRunId: traceState?.testRunId,
3133
3152
  inputSourceTraceId: traceState?.inputSourceTraceId,
3134
- dbSnapshotRef: traceState?.dbSnapshotRef
3153
+ dbSnapshotRef: traceState?.dbSnapshotRef,
3154
+ // Built AFTER the wrapped fn finished, so `accessed` reflects
3155
+ // whether customer code obtained the branch URL during this
3156
+ // item. Omitted entirely when no lease was attached, so the
3157
+ // server can distinguish "no branch" from "branch ignored".
3158
+ ...replayCtx?.dbBranchLease && {
3159
+ dbSnapshotUsage: {
3160
+ neonBranchId: replayCtx.dbBranchLease.neonBranchId,
3161
+ snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
3162
+ sourceTraceId: replayCtx.sourceBitfabTraceId,
3163
+ accessed: replayCtx.dbSnapshotAccessed === true
3164
+ }
3165
+ }
3135
3166
  });
3136
3167
  activeTraceStates.delete(traceId);
3137
3168
  if (persistenceCollector) {
@@ -3303,6 +3334,18 @@ var Bitfab = class {
3303
3334
  if (params.dbSnapshotRef) {
3304
3335
  rawTrace.db_snapshot_ref = params.dbSnapshotRef;
3305
3336
  }
3337
+ if (params.dbSnapshotUsage) {
3338
+ rawTrace.db_snapshot_usage = {
3339
+ neon_branch_id: params.dbSnapshotUsage.neonBranchId,
3340
+ ...params.dbSnapshotUsage.snapshotTimestamp && {
3341
+ snapshot_timestamp: params.dbSnapshotUsage.snapshotTimestamp
3342
+ },
3343
+ ...params.dbSnapshotUsage.sourceTraceId && {
3344
+ source_trace_id: params.dbSnapshotUsage.sourceTraceId
3345
+ },
3346
+ accessed: params.dbSnapshotUsage.accessed
3347
+ };
3348
+ }
3306
3349
  return this.httpClient.sendExternalTrace({
3307
3350
  type: "sdk-function",
3308
3351
  source: "typescript-sdk-function",