@bitfab/sdk 0.63.1 → 0.63.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.
@@ -7,7 +7,7 @@ import {
7
7
  flushTraces,
8
8
  parseRetryAfterMs,
9
9
  serializePayloadBody
10
- } from "./chunk-ZNQXQRQF.js";
10
+ } from "./chunk-QX7DDM5W.js";
11
11
  import "./chunk-MT36GJMW.js";
12
12
  export {
13
13
  BitfabError,
@@ -19,4 +19,4 @@ export {
19
19
  parseRetryAfterMs,
20
20
  serializePayloadBody
21
21
  };
22
- //# sourceMappingURL=http-SG4N6LAX.js.map
22
+ //# sourceMappingURL=http-2RFS44TM.js.map
@@ -7,7 +7,7 @@ import {
7
7
  flushTraces,
8
8
  parseRetryAfterMs,
9
9
  serializePayloadBody
10
- } from "./chunk-YV2AMMAU.js";
10
+ } from "./chunk-Y2FSK4DW.js";
11
11
  export {
12
12
  BitfabError,
13
13
  HttpClient,
@@ -18,4 +18,4 @@ export {
18
18
  parseRetryAfterMs,
19
19
  serializePayloadBody
20
20
  };
21
- //# sourceMappingURL=http-QOBGV3FG.js.map
21
+ //# sourceMappingURL=http-7I6CVZJO.js.map
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var __version__, __packageName__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.63.1";
45
+ __version__ = "0.63.2";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -2895,7 +2895,7 @@ var init_http = __esm({
2895
2895
  * Start a replay session by fetching historical traces.
2896
2896
  * Blocking call - creates an experiment and returns lightweight item references.
2897
2897
  */
2898
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, skipAssertionJudging, experimentalSelectiveReplay, notes, metadata) {
2898
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions, skipAssertionJudging, experimentalSelectiveReplay, notes, metadata, dryRun) {
2899
2899
  const payload = { traceFunctionKey };
2900
2900
  if (experimentalSelectiveReplay !== void 0) {
2901
2901
  payload.experimentalSelectiveReplay = experimentalSelectiveReplay;
@@ -2953,6 +2953,9 @@ var init_http = __esm({
2953
2953
  if (skipAssertionJudging !== true) {
2954
2954
  payload.judgeAssertions = true;
2955
2955
  }
2956
+ if (dryRun) {
2957
+ payload.dryRun = true;
2958
+ }
2956
2959
  const git = await resolvedGitState();
2957
2960
  if (git && !isEmptyGitState(git)) {
2958
2961
  payload.git = git;
@@ -2966,7 +2969,10 @@ var init_http = __esm({
2966
2969
  const { testRunId, testRunUrl, ...rest } = response;
2967
2970
  const experimentId = response.experimentId ?? testRunId;
2968
2971
  const experimentUrl = response.experimentUrl ?? testRunUrl;
2969
- if (experimentId === void 0 || experimentUrl === void 0) {
2972
+ if (dryRun && response.experimentId === null) {
2973
+ return { ...rest, experimentId: null, experimentUrl: null };
2974
+ }
2975
+ if (experimentId === void 0 || experimentId === null || experimentUrl === void 0 || experimentUrl === null) {
2970
2976
  throw new BitfabError(
2971
2977
  "Replay start response is missing the experiment ID or URL."
2972
2978
  );
@@ -4302,7 +4308,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4302
4308
  const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
4303
4309
  const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
4304
4310
  try {
4305
- if (includeDbBranchLease && !lease && !leaseError) {
4311
+ if (includeDbBranchLease && experimentId !== null && !lease && !leaseError) {
4306
4312
  let resolved2;
4307
4313
  try {
4308
4314
  resolved2 = await httpClient.resolveDbBranchLease(
@@ -4396,7 +4402,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4396
4402
  }
4397
4403
  return pending;
4398
4404
  } : void 0;
4399
- if (dryRun) {
4405
+ if (dryRun || experimentId === null) {
4400
4406
  return {
4401
4407
  traceId: null,
4402
4408
  originalTraceId,
@@ -4684,7 +4690,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4684
4690
  options?.skipAssertionJudging === true || options?.judgeAssertions === false,
4685
4691
  options?.experimentalSelectiveReplay,
4686
4692
  options?.notes,
4687
- options?.metadata
4693
+ options?.metadata,
4694
+ options?.dryRun === true
4688
4695
  );
4689
4696
  if (started.items.length === 0) {
4690
4697
  try {
@@ -4714,6 +4721,22 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4714
4721
  );
4715
4722
  }
4716
4723
  const { experimentId } = session;
4724
+ if (experimentId === null || session.experimentUrl === null) {
4725
+ return runReplaySession(
4726
+ httpClient,
4727
+ fn,
4728
+ session,
4729
+ null,
4730
+ maxConcurrency,
4731
+ () => {
4732
+ },
4733
+ () => {
4734
+ },
4735
+ () => false,
4736
+ options,
4737
+ registeredOverrides
4738
+ );
4739
+ }
4717
4740
  const fullExperimentUrl = `${serviceUrl}${session.experimentUrl}`;
4718
4741
  const heartbeat = startReplayHeartbeat(
4719
4742
  () => httpClient.heartbeatReplay(experimentId)
@@ -4775,12 +4798,14 @@ function throwIfInterrupted(interrupted, items, experimentId, experimentUrl) {
4775
4798
  async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxConcurrency, stopInterruptingOnSignal, markCompleteReturned, interrupted, options, registeredOverrides) {
4776
4799
  const { experimentId, attempts } = session;
4777
4800
  const mockStrategy = options?.mock ?? "marked";
4778
- try {
4779
- options?.onExperimentStart?.({
4780
- experimentId,
4781
- experimentUrl: fullExperimentUrl
4782
- });
4783
- } catch {
4801
+ if (experimentId !== null && fullExperimentUrl !== null) {
4802
+ try {
4803
+ options?.onExperimentStart?.({
4804
+ experimentId,
4805
+ experimentUrl: fullExperimentUrl
4806
+ });
4807
+ } catch {
4808
+ }
4784
4809
  }
4785
4810
  const resolvedOverrides = [
4786
4811
  ...normalizeMockOverrides(options?.mockOverride),
@@ -4922,17 +4947,18 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4922
4947
  interrupted
4923
4948
  );
4924
4949
  const resultItems = [...carriedOverItems, ...ranItems];
4925
- throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4926
- if (options?.dryRun === true) {
4927
- throwIfInterrupted(
4928
- interrupted,
4929
- resultItems,
4930
- experimentId,
4931
- fullExperimentUrl
4932
- );
4933
- stopInterruptingOnSignal();
4934
- await httpClient.completeReplay(experimentId).catch(() => void 0);
4935
- markCompleteReturned();
4950
+ if (options?.dryRun === true || experimentId === null || fullExperimentUrl === null) {
4951
+ if (experimentId !== null && fullExperimentUrl !== null) {
4952
+ throwIfInterrupted(
4953
+ interrupted,
4954
+ resultItems,
4955
+ experimentId,
4956
+ fullExperimentUrl
4957
+ );
4958
+ stopInterruptingOnSignal();
4959
+ await httpClient.completeReplay(experimentId).catch(() => void 0);
4960
+ markCompleteReturned();
4961
+ }
4936
4962
  const dryResult = {
4937
4963
  items: resultItems,
4938
4964
  experimentId,
@@ -4944,6 +4970,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4944
4970
  await writeReplayResultFile(dryResult);
4945
4971
  return dryResult;
4946
4972
  }
4973
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4947
4974
  const deliveredTraceIds = await preserveReplayFailure(
4948
4975
  () => waitForReplayPersistence(httpClient, experimentId, replayedTraceIds),
4949
4976
  resultItems,