@testsmith/api-spector-agent 0.7.8 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.cjs +22 -14
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -74286,6 +74286,10 @@ function buildUrl(baseUrl, params, vars) {
74286
74286
  templateTokens.add(String(name).trim());
74287
74287
  return "";
74288
74288
  });
74289
+ baseUrl.replaceAll(/\[([A-Za-z_]\w*)\]/g, (_m, name) => {
74290
+ templateTokens.add(String(name));
74291
+ return "";
74292
+ });
74289
74293
  const enabled = (params ?? []).filter((p6) => p6.enabled && p6.key);
74290
74294
  const pathRows = [];
74291
74295
  const queryRows = [];
@@ -74298,12 +74302,27 @@ function buildUrl(baseUrl, params, vars) {
74298
74302
  ...vars,
74299
74303
  ...Object.fromEntries(pathRows.map((p6) => [p6.key, interpolate(p6.value, vars)]))
74300
74304
  } : vars;
74301
- const url2 = interpolate(baseUrl, mergedVars);
74305
+ let url2 = interpolate(baseUrl, mergedVars);
74306
+ url2 = url2.replaceAll(/\[([A-Za-z_]\w*)\]/g, (m6, name) => name in mergedVars ? mergedVars[name] : m6);
74302
74307
  if (!queryRows.length) return url2;
74303
74308
  const sep = url2.includes("?") ? "&" : "?";
74304
74309
  const qs = queryRows.map((p6) => `${encodeURIComponent(interpolate(p6.key, vars))}=${encodeURIComponent(interpolate(p6.value, vars))}`).join("&");
74305
74310
  return url2 + sep + qs;
74306
74311
  }
74312
+ async function resolveInlineSecretRefs(text) {
74313
+ const refs = /* @__PURE__ */ new Set();
74314
+ for (const m6 of text.matchAll(/\{\{\s*([^}]+?)\s*\}\}/g)) {
74315
+ const inner = m6[1].trim();
74316
+ if (hasSecretScheme(inner)) refs.add(inner);
74317
+ }
74318
+ if (refs.size === 0) return {};
74319
+ const out = {};
74320
+ await Promise.all([...refs].map(async (ref) => {
74321
+ const value2 = await resolveExternalSecret(ref);
74322
+ if (value2 !== null) out[ref] = value2;
74323
+ }));
74324
+ return out;
74325
+ }
74307
74326
  function mergeVars(envVars, collectionVars, globals2, localVars = {}, dynamicVars = {}, folderVars = {}) {
74308
74327
  const out = {};
74309
74328
  for (const src of [dynamicVars, globals2, collectionVars, folderVars, envVars, localVars]) {
@@ -80921,18 +80940,7 @@ async function resolveInlineSecrets(req) {
80921
80940
  req.preRequestScript ?? "",
80922
80941
  req.postRequestScript ?? ""
80923
80942
  ].join("\n");
80924
- const refs = /* @__PURE__ */ new Set();
80925
- for (const m6 of haystack.matchAll(/\{\{\s*([^}]+?)\s*\}\}/g)) {
80926
- const inner = m6[1].trim();
80927
- if (hasSecretScheme(inner)) refs.add(inner);
80928
- }
80929
- if (refs.size === 0) return {};
80930
- const out = {};
80931
- await Promise.all([...refs].map(async (ref) => {
80932
- const value2 = await resolveExternalSecret(ref);
80933
- if (value2 !== null) out[ref] = value2;
80934
- }));
80935
- return out;
80943
+ return resolveInlineSecretRefs(haystack);
80936
80944
  }
80937
80945
  async function executeRunnerRequest(opts) {
80938
80946
  const { req, collectionVars, envVars, globals: globals2, dispatcher, piiMaskPatterns, proxy, tls, onScriptOutput } = opts;
@@ -81356,7 +81364,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
81356
81364
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
81357
81365
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
81358
81366
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
81359
- var VERSION = true ? "0.7.8" : "";
81367
+ var VERSION = true ? "0.8.0" : "";
81360
81368
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
81361
81369
  async function postResult(m6, fields) {
81362
81370
  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.7.8",
3
+ "version": "0.8.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",