@bitfab/sdk 0.30.2 → 0.31.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.
- package/dist/{chunk-FLVQ7Q3I.js → chunk-6UJ3E3H5.js} +20 -2
- package/dist/chunk-6UJ3E3H5.js.map +1 -0
- package/dist/{chunk-CPEQSNVE.js → chunk-A7K5JOBV.js} +16 -5
- package/dist/chunk-A7K5JOBV.js.map +1 -0
- package/dist/index.cjs +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +32 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-YJI2SUSN.js → replay-JVURNX5Y.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-CPEQSNVE.js.map +0 -1
- package/dist/chunk-FLVQ7Q3I.js.map +0 -1
- /package/dist/{replay-YJI2SUSN.js.map → replay-JVURNX5Y.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -524,6 +524,17 @@ __export(replay_exports, {
|
|
|
524
524
|
replay: () => replay,
|
|
525
525
|
reportReplayProgress: () => reportReplayProgress
|
|
526
526
|
});
|
|
527
|
+
function resolveDbBranchSettings(dbBranch) {
|
|
528
|
+
if (!dbBranch) {
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
const settings = {
|
|
532
|
+
...dbBranch.minCu === void 0 ? {} : { minCu: dbBranch.minCu },
|
|
533
|
+
...dbBranch.maxCu === void 0 ? {} : { maxCu: dbBranch.maxCu },
|
|
534
|
+
...dbBranch.warmupSql === void 0 ? {} : { warmupSql: dbBranch.warmupSql }
|
|
535
|
+
};
|
|
536
|
+
return Object.keys(settings).length === 0 ? void 0 : settings;
|
|
537
|
+
}
|
|
527
538
|
function reportReplayProgress(progress) {
|
|
528
539
|
const stderr = typeof process !== "undefined" ? process.stderr : void 0;
|
|
529
540
|
if (!stderr) {
|
|
@@ -586,6 +597,7 @@ function buildMockTree(rootNode) {
|
|
|
586
597
|
}
|
|
587
598
|
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, environment, adaptInputs) {
|
|
588
599
|
const lease = environment ? serverItem.dbBranchLease : void 0;
|
|
600
|
+
const leaseError = environment ? serverItem.dbBranchLeaseError : void 0;
|
|
589
601
|
let inputs = [];
|
|
590
602
|
let originalOutput;
|
|
591
603
|
let result;
|
|
@@ -594,6 +606,11 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
594
606
|
const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
|
|
595
607
|
const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
|
|
596
608
|
try {
|
|
609
|
+
if (leaseError) {
|
|
610
|
+
throw new BitfabError(
|
|
611
|
+
`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.`
|
|
612
|
+
);
|
|
613
|
+
}
|
|
597
614
|
const span = await httpClient.getExternalSpan(originalSpanId);
|
|
598
615
|
const spanData = span.rawData?.span_data ?? {};
|
|
599
616
|
inputs = deserializeInputs(spanData);
|
|
@@ -767,7 +784,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
767
784
|
// includeDbBranchLease
|
|
768
785
|
options?.experimentGroupId,
|
|
769
786
|
options?.datasetId,
|
|
770
|
-
options?.graderIds
|
|
787
|
+
options?.graderIds,
|
|
788
|
+
resolveDbBranchSettings(options?.dbBranch)
|
|
771
789
|
);
|
|
772
790
|
const mockStrategy = options?.mock ?? "marked";
|
|
773
791
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
@@ -954,7 +972,7 @@ __export(index_exports, {
|
|
|
954
972
|
module.exports = __toCommonJS(index_exports);
|
|
955
973
|
|
|
956
974
|
// src/version.generated.ts
|
|
957
|
-
var __version__ = "0.
|
|
975
|
+
var __version__ = "0.31.0";
|
|
958
976
|
|
|
959
977
|
// src/constants.ts
|
|
960
978
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1313,7 +1331,7 @@ var HttpClient = class {
|
|
|
1313
1331
|
* Start a replay session by fetching historical traces.
|
|
1314
1332
|
* Blocking call - creates a test run and returns lightweight item references.
|
|
1315
1333
|
*/
|
|
1316
|
-
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds) {
|
|
1334
|
+
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings) {
|
|
1317
1335
|
const payload = { traceFunctionKey };
|
|
1318
1336
|
if (limit !== void 0) {
|
|
1319
1337
|
payload.limit = limit;
|
|
@@ -1342,6 +1360,9 @@ var HttpClient = class {
|
|
|
1342
1360
|
if (graderIds !== void 0) {
|
|
1343
1361
|
payload.graderIds = graderIds;
|
|
1344
1362
|
}
|
|
1363
|
+
if (dbBranchSettings !== void 0) {
|
|
1364
|
+
payload.dbBranchSettings = dbBranchSettings;
|
|
1365
|
+
}
|
|
1345
1366
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
1346
1367
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1347
1368
|
timeout
|
|
@@ -3072,6 +3093,13 @@ var ReplayEnvironment = class {
|
|
|
3072
3093
|
get readOnly() {
|
|
3073
3094
|
return this.require().readOnly;
|
|
3074
3095
|
}
|
|
3096
|
+
/**
|
|
3097
|
+
* The branch's region, e.g. `aws-us-east-1`. A compute runs in its project's
|
|
3098
|
+
* region, so a replay runner elsewhere pays that round trip on every query.
|
|
3099
|
+
*/
|
|
3100
|
+
get region() {
|
|
3101
|
+
return this.require().region;
|
|
3102
|
+
}
|
|
3075
3103
|
/** The historical trace ID that produced the input for this replay item. */
|
|
3076
3104
|
get traceId() {
|
|
3077
3105
|
return this.require().traceId;
|
|
@@ -3116,6 +3144,7 @@ var ReplayEnvironment = class {
|
|
|
3116
3144
|
expiresAt: lease.expiresAt,
|
|
3117
3145
|
providerConsoleUrl: lease.providerConsoleUrl,
|
|
3118
3146
|
readOnly: lease.readOnly,
|
|
3147
|
+
region: lease.region,
|
|
3119
3148
|
traceId
|
|
3120
3149
|
};
|
|
3121
3150
|
}
|