@testsmith/api-spector-agent 0.9.23 → 0.9.24

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.
Files changed (2) hide show
  1. package/dist/index.cjs +17 -12
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -105064,6 +105064,8 @@ async function executeRunnerRequest(opts) {
105064
105064
  const folderVars = opts.folderVars ?? {};
105065
105065
  const libraries = opts.libraries;
105066
105066
  const libraryRoot = opts.libraryRoot;
105067
+ const inheritedPreScripts = opts.inheritedPreScripts ?? [];
105068
+ const inheritedPostScripts = opts.inheritedPostScripts ?? [];
105067
105069
  const sendRequest = makeScriptSendRequest(proxy, tls);
105068
105070
  applyRequestDefaults(req);
105069
105071
  const base = {
@@ -105190,11 +105192,12 @@ async function executeRunnerRequest(opts) {
105190
105192
  };
105191
105193
  }
105192
105194
  if (Object.keys(inlineSecrets).length) vars = { ...vars, ...inlineSecrets };
105193
- if (req.preRequestScript?.trim()) {
105194
- const r63 = await runScript(interpolate(req.preRequestScript, vars), {
105195
- envVars: { ...envVars },
105196
- collectionVars: { ...collectionVars },
105197
- globals: { ...globals },
105195
+ const preScripts = [...inheritedPreScripts, req.preRequestScript].filter((s8) => Boolean(s8?.trim()));
105196
+ for (const script of preScripts) {
105197
+ const r63 = await runScript(interpolate(script, vars), {
105198
+ envVars: { ...updatedEnvVars },
105199
+ collectionVars: { ...updatedCollectionVars },
105200
+ globals: { ...updatedGlobals },
105198
105201
  localVars: { ...localVars },
105199
105202
  folderVars: { ...updatedFolderVars },
105200
105203
  piiMaskPatterns,
@@ -105202,7 +105205,7 @@ async function executeRunnerRequest(opts) {
105202
105205
  libraryRoot,
105203
105206
  sendRequest
105204
105207
  });
105205
- preScriptError = r63.error;
105208
+ preScriptError = preScriptError ?? r63.error;
105206
105209
  localVars = r63.updatedLocalVars;
105207
105210
  updatedEnvVars = r63.updatedEnvVars;
105208
105211
  updatedCollectionVars = r63.updatedCollectionVars;
@@ -105232,8 +105235,9 @@ async function executeRunnerRequest(opts) {
105232
105235
  let testResults = [...schemaTestResults, ...protocolFaultTests];
105233
105236
  let consoleOutput = [];
105234
105237
  let postScriptError;
105235
- if (req.postRequestScript?.trim()) {
105236
- const r63 = await runScript(interpolate(req.postRequestScript, vars), {
105238
+ const postScripts = [req.postRequestScript, ...inheritedPostScripts].filter((s8) => Boolean(s8?.trim()));
105239
+ for (const script of postScripts) {
105240
+ const r63 = await runScript(interpolate(script, vars), {
105237
105241
  envVars: updatedEnvVars,
105238
105242
  collectionVars: updatedCollectionVars,
105239
105243
  globals: updatedGlobals,
@@ -105245,15 +105249,16 @@ async function executeRunnerRequest(opts) {
105245
105249
  libraryRoot,
105246
105250
  sendRequest
105247
105251
  });
105248
- testResults = [...schemaTestResults, ...protocolFaultTests, ...r63.testResults];
105249
- consoleOutput = r63.consoleOutput;
105250
- postScriptError = r63.error;
105252
+ testResults = [...testResults, ...r63.testResults];
105253
+ consoleOutput = [...consoleOutput, ...r63.consoleOutput];
105254
+ postScriptError = postScriptError ?? r63.error;
105251
105255
  updatedEnvVars = r63.updatedEnvVars;
105252
105256
  updatedCollectionVars = r63.updatedCollectionVars;
105253
105257
  updatedGlobals = r63.updatedGlobals;
105254
105258
  updatedFolderVars = r63.updatedFolderVars;
105255
105259
  localVars = r63.updatedLocalVars;
105256
105260
  onScriptOutput?.("post", r63.consoleOutput, r63.error);
105261
+ vars = mergeVars(updatedEnvVars, updatedCollectionVars, updatedGlobals, localVars, dynamicVars, updatedFolderVars);
105257
105262
  }
105258
105263
  if (opts.expectStatus && opts.expectStatus.length > 0) {
105259
105264
  const tag = opts.owaspTag ? `[${opts.owaspTag}] ` : "";
@@ -105488,7 +105493,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
105488
105493
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
105489
105494
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
105490
105495
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
105491
- var VERSION = true ? "0.9.23" : "";
105496
+ var VERSION = true ? "0.9.24" : "";
105492
105497
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
105493
105498
  async function postResult(m6, fields) {
105494
105499
  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.9.23",
3
+ "version": "0.9.24",
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",