@testsmith/api-spector-agent 0.8.9 → 0.9.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/index.cjs +14 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -74267,7 +74267,7 @@ async function buildDynamicVars() {
|
|
|
74267
74267
|
};
|
|
74268
74268
|
}
|
|
74269
74269
|
function interpolate(str, vars) {
|
|
74270
|
-
return str.replaceAll(/\{\{([^}]
|
|
74270
|
+
return str.replaceAll(/\{\{\s*((?:[^{}]|\{[^{}]*\})+?)\s*\}\}/g, (match, key) => {
|
|
74271
74271
|
const trimmed = key.trim();
|
|
74272
74272
|
if (trimmed in vars) return vars[trimmed];
|
|
74273
74273
|
if (_exprContext && (trimmed.includes(".") || trimmed.includes("("))) {
|
|
@@ -74287,7 +74287,7 @@ function resolveDataRow(row, scope) {
|
|
|
74287
74287
|
}
|
|
74288
74288
|
function buildUrl(baseUrl, params, vars) {
|
|
74289
74289
|
const templateTokens = /* @__PURE__ */ new Set();
|
|
74290
|
-
baseUrl.replaceAll(/\{\{([^}]
|
|
74290
|
+
baseUrl.replaceAll(/\{\{\s*((?:[^{}]|\{[^{}]*\})+?)\s*\}\}/g, (_m, name) => {
|
|
74291
74291
|
templateTokens.add(String(name).trim());
|
|
74292
74292
|
return "";
|
|
74293
74293
|
});
|
|
@@ -76318,10 +76318,11 @@ function buildAt(ctx, testResults, consoleOutput) {
|
|
|
76318
76318
|
fn2();
|
|
76319
76319
|
testResults.push({ name, passed: true });
|
|
76320
76320
|
} catch (err) {
|
|
76321
|
+
const line = scriptLineOf(err);
|
|
76321
76322
|
testResults.push({
|
|
76322
76323
|
name,
|
|
76323
76324
|
passed: false,
|
|
76324
|
-
error: err instanceof Error ? err.message : String(err)
|
|
76325
|
+
error: (err instanceof Error ? err.message : String(err)) + (line ? ` (line ${line})` : "")
|
|
76325
76326
|
});
|
|
76326
76327
|
}
|
|
76327
76328
|
},
|
|
@@ -76442,6 +76443,13 @@ function buildSandbox(scriptCtx, testResults, consoleOutput, faker) {
|
|
|
76442
76443
|
setInterval: void 0
|
|
76443
76444
|
};
|
|
76444
76445
|
}
|
|
76446
|
+
function scriptLineOf(err) {
|
|
76447
|
+
if (err instanceof Error && err.stack) {
|
|
76448
|
+
const m6 = err.stack.match(/script\.js:(\d+):\d+/);
|
|
76449
|
+
if (m6) return Number(m6[1]);
|
|
76450
|
+
}
|
|
76451
|
+
return void 0;
|
|
76452
|
+
}
|
|
76445
76453
|
async function runScript(code, ctx, timeoutMs = 5e3) {
|
|
76446
76454
|
const faker = await getFaker2();
|
|
76447
76455
|
const testResults = [];
|
|
@@ -76467,6 +76475,7 @@ async function runScript(code, ctx, timeoutMs = 5e3) {
|
|
|
76467
76475
|
try {
|
|
76468
76476
|
vm3.runInNewContext(code, sandbox, { timeout: timeoutMs, filename: "script.js" });
|
|
76469
76477
|
} catch (err) {
|
|
76478
|
+
const line = scriptLineOf(err);
|
|
76470
76479
|
const message = err instanceof Error ? err.message : String(err);
|
|
76471
76480
|
return {
|
|
76472
76481
|
testResults,
|
|
@@ -76476,7 +76485,7 @@ async function runScript(code, ctx, timeoutMs = 5e3) {
|
|
|
76476
76485
|
updatedGlobals: globalsCopy,
|
|
76477
76486
|
updatedLocalVars: localVarsCopy,
|
|
76478
76487
|
updatedFolderVars: folderCopy,
|
|
76479
|
-
error: message
|
|
76488
|
+
error: (line ? `Line ${line}: ` : "") + message
|
|
76480
76489
|
};
|
|
76481
76490
|
}
|
|
76482
76491
|
return {
|
|
@@ -81418,7 +81427,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
|
|
|
81418
81427
|
var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
|
|
81419
81428
|
var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
|
|
81420
81429
|
var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
|
|
81421
|
-
var VERSION = true ? "0.
|
|
81430
|
+
var VERSION = true ? "0.9.0" : "";
|
|
81422
81431
|
var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
|
|
81423
81432
|
async function postResult(m6, fields) {
|
|
81424
81433
|
await fetch(`${APP_URL}/api/monitor-runtime/${m6.id}/result`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testsmith/api-spector-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "API Spector private runner: monitor internal/local APIs the cloud cannot reach, with no inbound connections.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://api-spector.dev",
|