@bitfab/sdk 0.36.10 → 0.36.12

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
@@ -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.10";
45
+ __version__ = "0.36.12";
46
46
  }
47
47
  });
48
48
 
@@ -2260,7 +2260,7 @@ async function captureCodeChangeFromGit(cwd, label) {
2260
2260
  const tracked = await git(root, [
2261
2261
  "diff",
2262
2262
  "--name-status",
2263
- "--no-renames",
2263
+ "--find-renames",
2264
2264
  "-z",
2265
2265
  base,
2266
2266
  "--",
@@ -2276,23 +2276,23 @@ async function captureCodeChangeFromGit(cwd, label) {
2276
2276
  ]);
2277
2277
  const entries = [
2278
2278
  ...parseNameStatusZ(tracked ?? ""),
2279
- ...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({ status: "A", path }))
2279
+ ...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({ status: "A", beforePath: path, path }))
2280
2280
  ];
2281
2281
  if (entries.length === 0) {
2282
2282
  return null;
2283
2283
  }
2284
2284
  const files = [];
2285
2285
  let totalBytes = 0;
2286
- for (const { status, path } of entries) {
2286
+ for (const { status, beforePath, path } of entries) {
2287
2287
  if (files.length >= MAX_FILES) {
2288
2288
  break;
2289
2289
  }
2290
- const beforeBytes = status === "A" ? 0 : await blobBytes(base, path);
2290
+ const beforeBytes = status === "A" ? 0 : await blobBytes(base, beforePath);
2291
2291
  const afterBytes = status === "D" ? 0 : await workingBytes(path);
2292
2292
  if (beforeBytes > MAX_FILE_BYTES || afterBytes > MAX_FILE_BYTES) {
2293
2293
  continue;
2294
2294
  }
2295
- const before = (status === "A" ? "" : await git(root, ["show", `${base}:${path}`]) ?? "").replace(/\r\n/g, "\n");
2295
+ const before = (status === "A" ? "" : await git(root, ["show", `${base}:${beforePath}`]) ?? "").replace(/\r\n/g, "\n");
2296
2296
  const after = (status === "D" ? "" : await readWorkingFile(readFile, root, path)).replace(/\r\n/g, "\n");
2297
2297
  if (before === after) {
2298
2298
  continue;
@@ -2350,8 +2350,18 @@ async function readWorkingFile(readFile, root, path) {
2350
2350
  function parseNameStatusZ(raw) {
2351
2351
  const parts = raw.split(NUL).filter((p) => p.length > 0);
2352
2352
  const out = [];
2353
- for (let i = 0; i + 1 < parts.length; i += 2) {
2354
- out.push({ status: parts[i].charAt(0), path: parts[i + 1] });
2353
+ let i = 0;
2354
+ while (i + 1 < parts.length) {
2355
+ const status = parts[i].charAt(0);
2356
+ i += 1;
2357
+ const beforePath = parts[i];
2358
+ i += 1;
2359
+ if ((status === "R" || status === "C") && i < parts.length) {
2360
+ out.push({ status, beforePath, path: parts[i] });
2361
+ i += 1;
2362
+ } else {
2363
+ out.push({ status, beforePath, path: beforePath });
2364
+ }
2355
2365
  }
2356
2366
  return out;
2357
2367
  }
@@ -6091,14 +6101,19 @@ var Bitfab = class {
6091
6101
  counters.set(counterKey, callIndex + 1);
6092
6102
  const mockKey = `${counterKey}:${callIndex}`;
6093
6103
  const mockSpan = replayCtxForMock.mockTree.spans.get(mockKey);
6094
- const emitMock = (output) => {
6095
- void sendSpan({ result: output, mocked: true });
6104
+ const emitMock = (output, mockSource) => {
6105
+ void sendSpan({
6106
+ result: output,
6107
+ mocked: true,
6108
+ mockTarget: "output",
6109
+ mockSource
6110
+ });
6096
6111
  if (fnReturnsPromise) {
6097
6112
  return Promise.resolve(output);
6098
6113
  }
6099
6114
  return output;
6100
6115
  };
6101
- const emitMockAsync = (pending) => {
6116
+ const emitMockAsync = (pending, mockSource) => {
6102
6117
  if (!fnReturnsPromise) {
6103
6118
  throw new BitfabError(
6104
6119
  `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.`
@@ -6106,7 +6121,12 @@ var Bitfab = class {
6106
6121
  }
6107
6122
  return (async () => {
6108
6123
  const output = await pending;
6109
- void sendSpan({ result: output, mocked: true });
6124
+ void sendSpan({
6125
+ result: output,
6126
+ mocked: true,
6127
+ mockTarget: "output",
6128
+ mockSource
6129
+ });
6110
6130
  return output;
6111
6131
  })();
6112
6132
  };
@@ -6148,18 +6168,18 @@ var Bitfab = class {
6148
6168
  getOriginalOutput: () => Promise.resolve(resolveRecordedOutput())
6149
6169
  });
6150
6170
  if (injected instanceof Promise) {
6151
- return emitMockAsync(injected);
6171
+ return emitMockAsync(injected, "override");
6152
6172
  }
6153
- return emitMock(injected);
6173
+ return emitMock(injected, "override");
6154
6174
  }
6155
6175
  }
6156
6176
  const shouldMock = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
6157
6177
  if (shouldMock && mockSpan) {
6158
6178
  const recorded = resolveRecordedOutput();
6159
6179
  if (recorded instanceof Promise) {
6160
- return emitMockAsync(recorded);
6180
+ return emitMockAsync(recorded, "recorded");
6161
6181
  }
6162
- return emitMock(recorded);
6182
+ return emitMock(recorded, "recorded");
6163
6183
  }
6164
6184
  }
6165
6185
  const recordSpan = (result) => {
@@ -6459,7 +6479,9 @@ var Bitfab = class {
6459
6479
  traceFunctionKey: params.traceFunctionKey,
6460
6480
  rawSpan: externalSpan,
6461
6481
  ...params.testRunId && { testRunId: params.testRunId },
6462
- ...params.mocked && { mocked: true }
6482
+ ...params.mocked && { mocked: true },
6483
+ ...params.mockTarget && { mockTarget: params.mockTarget },
6484
+ ...params.mockSource && { mockSource: params.mockSource }
6463
6485
  });
6464
6486
  }
6465
6487
  registerMockOverride(overrideOrMatch, value) {