@bitfab/sdk 0.50.0 → 0.52.0

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.
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-W5P5JAH7.js";
9
+ } from "./chunk-KXBXRR4I.js";
10
10
  export {
11
11
  BitfabError,
12
12
  HttpClient,
@@ -16,4 +16,4 @@ export {
16
16
  parseRetryAfterMs,
17
17
  serializePayloadBody
18
18
  };
19
- //# sourceMappingURL=http-W2YPLY7H.js.map
19
+ //# sourceMappingURL=http-4A2JEPBD.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-XZDYNFI5.js";
9
+ } from "./chunk-4EOEBN3M.js";
10
10
  import "./chunk-H6LZRFMN.js";
11
11
  export {
12
12
  BitfabError,
@@ -17,4 +17,4 @@ export {
17
17
  parseRetryAfterMs,
18
18
  serializePayloadBody
19
19
  };
20
- //# sourceMappingURL=http-PFP2EQVE.js.map
20
+ //# sourceMappingURL=http-W6SXQA3Q.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.50.0";
45
+ __version__ = "0.52.0";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -1847,7 +1847,7 @@ var init_http = __esm({
1847
1847
  * Start a replay session by fetching historical traces.
1848
1848
  * Blocking call - creates a test run and returns lightweight item references.
1849
1849
  */
1850
- async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1850
+ async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetIds, graderIds, dbBranchSettings, attempts, includeOriginalMetadata, onlyWithAssertions) {
1851
1851
  const payload = { traceFunctionKey };
1852
1852
  if (limit !== void 0) {
1853
1853
  payload.limit = limit;
@@ -1871,8 +1871,12 @@ var init_http = __esm({
1871
1871
  if (experimentGroupId !== void 0) {
1872
1872
  payload.experimentGroupId = experimentGroupId;
1873
1873
  }
1874
- if (datasetId !== void 0) {
1875
- payload.datasetId = datasetId;
1874
+ if (datasetIds !== void 0) {
1875
+ if (datasetIds.length === 1) {
1876
+ payload.datasetId = datasetIds[0];
1877
+ } else {
1878
+ payload.datasetIds = datasetIds;
1879
+ }
1876
1880
  }
1877
1881
  if (graderIds !== void 0) {
1878
1882
  payload.graderIds = graderIds;
@@ -2474,6 +2478,23 @@ function resolveAttempts(attempts) {
2474
2478
  }
2475
2479
  return attempts;
2476
2480
  }
2481
+ function resolveDatasetIds(options) {
2482
+ if (options?.datasetId !== void 0 && options?.datasetIds !== void 0) {
2483
+ throw new BitfabError(
2484
+ "datasetId and datasetIds are the same selector: pass one dataset through datasetId, or several through datasetIds."
2485
+ );
2486
+ }
2487
+ if (options?.datasetId !== void 0) {
2488
+ return [options.datasetId];
2489
+ }
2490
+ if (options?.datasetIds === void 0) {
2491
+ return void 0;
2492
+ }
2493
+ if (options.datasetIds.length === 0) {
2494
+ throw new BitfabError("datasetIds must contain at least one dataset ID.");
2495
+ }
2496
+ return [...new Set(options.datasetIds)];
2497
+ }
2477
2498
  function dbBranchEnabled(dbBranch) {
2478
2499
  return dbBranch !== void 0 && dbBranch !== false;
2479
2500
  }
@@ -2906,9 +2927,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2906
2927
  );
2907
2928
  }
2908
2929
  }
2909
- if (options?.traceIds !== void 0 && options?.datasetId !== void 0) {
2930
+ const datasetIds = resolveDatasetIds(options);
2931
+ if (options?.traceIds !== void 0 && datasetIds !== void 0) {
2910
2932
  throw new BitfabError(
2911
- "traceIds and datasetId select different replay sources and cannot be used together."
2933
+ "traceIds and datasetIds select different replay sources and cannot be used together."
2912
2934
  );
2913
2935
  }
2914
2936
  if (options?.limit !== void 0 && options?.traceIds !== void 0) {
@@ -2950,7 +2972,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2950
2972
  // before it could report its resolved inputs.
2951
2973
  dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true,
2952
2974
  options?.experimentGroupId,
2953
- options?.datasetId,
2975
+ datasetIds,
2954
2976
  options?.graderIds,
2955
2977
  resolveDbBranchSettings(options?.dbBranch),
2956
2978
  attempts,
@@ -3294,7 +3316,8 @@ __export(index_exports, {
3294
3316
  module.exports = __toCommonJS(index_exports);
3295
3317
 
3296
3318
  // src/assertions.ts
3297
- function expectationsPath(traceId, suffix = "") {
3319
+ var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
3320
+ function traceAssertionsPath(traceId, suffix = "") {
3298
3321
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
3299
3322
  }
3300
3323
  var TracesClient = class {
@@ -3302,18 +3325,29 @@ var TracesClient = class {
3302
3325
  this.httpClient = httpClient;
3303
3326
  }
3304
3327
  async getAssertions(traceId) {
3305
- return this.httpClient.get(expectationsPath(traceId));
3328
+ return this.httpClient.get(
3329
+ traceAssertionsPath(traceId)
3330
+ );
3306
3331
  }
3307
3332
  async saveAssertions(params) {
3308
- const response = await this.httpClient.request(expectationsPath(params.traceId), {
3309
- assertions: params.assertions,
3333
+ return this.saveAssertionsAll({
3334
+ updates: [{ traceId: params.traceId, assertions: params.assertions }],
3335
+ source: params.source
3336
+ });
3337
+ }
3338
+ async saveAssertionsAll(params) {
3339
+ if (params.updates.length === 0) {
3340
+ return [];
3341
+ }
3342
+ const response = await this.httpClient.request(ASSERTIONS_PATH, {
3343
+ updates: params.updates,
3310
3344
  source: params.source ?? "agent"
3311
3345
  });
3312
3346
  return response.assertions;
3313
3347
  }
3314
3348
  async archiveAssertions(params) {
3315
3349
  const response = await this.httpClient.request(
3316
- expectationsPath(params.traceId, "/archive"),
3350
+ traceAssertionsPath(params.traceId, "/archive"),
3317
3351
  { assertionIds: params.assertionIds }
3318
3352
  );
3319
3353
  return response.archived;