@testsmith/api-spector-agent 0.8.4 → 0.8.5

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 +62 -3
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -74342,6 +74342,65 @@ function mergeVars(envVars, collectionVars, globals2, localVars = {}, dynamicVar
74342
74342
  return out;
74343
74343
  }
74344
74344
 
74345
+ // src/shared/strip-json-comments.ts
74346
+ function jsonCommentRanges(input) {
74347
+ const ranges = [];
74348
+ const n5 = input.length;
74349
+ let i79 = 0;
74350
+ let inString = false;
74351
+ while (i79 < n5) {
74352
+ const c8 = input[i79];
74353
+ if (inString) {
74354
+ if (c8 === "\\") {
74355
+ i79 += 2;
74356
+ continue;
74357
+ }
74358
+ if (c8 === '"') inString = false;
74359
+ i79++;
74360
+ continue;
74361
+ }
74362
+ if (c8 === '"') {
74363
+ inString = true;
74364
+ i79++;
74365
+ continue;
74366
+ }
74367
+ const next = input[i79 + 1];
74368
+ if (c8 === "/" && next === "/") {
74369
+ const from = i79;
74370
+ i79 += 2;
74371
+ while (i79 < n5 && input[i79] !== "\n") i79++;
74372
+ ranges.push({ from, to: i79, type: "line" });
74373
+ continue;
74374
+ }
74375
+ if (c8 === "/" && next === "*") {
74376
+ const from = i79;
74377
+ i79 += 2;
74378
+ while (i79 < n5 && !(input[i79] === "*" && input[i79 + 1] === "/")) i79++;
74379
+ i79 = Math.min(i79 + 2, n5);
74380
+ ranges.push({ from, to: i79, type: "block" });
74381
+ continue;
74382
+ }
74383
+ i79++;
74384
+ }
74385
+ return ranges;
74386
+ }
74387
+ function stripJsonComments(input) {
74388
+ const ranges = jsonCommentRanges(input);
74389
+ if (!ranges.length) return input;
74390
+ let out = "";
74391
+ let pos = 0;
74392
+ for (const r63 of ranges) {
74393
+ out += input.slice(pos, r63.from);
74394
+ if (r63.type === "block") {
74395
+ const seg = input.slice(r63.from, r63.to);
74396
+ for (let k2 = 0; k2 < seg.length; k2++) if (seg[k2] === "\n") out += "\n";
74397
+ }
74398
+ pos = r63.to;
74399
+ }
74400
+ out += input.slice(pos);
74401
+ return out;
74402
+ }
74403
+
74345
74404
  // src/main/script-runner.ts
74346
74405
  var vm3 = __toESM(require("node:vm"));
74347
74406
  var crypto = __toESM(require("node:crypto"));
@@ -80790,7 +80849,7 @@ async function buildDispatcher(proxy, tls) {
80790
80849
  function buildBodyAndApplyHeaders(req, vars, headers) {
80791
80850
  let body;
80792
80851
  if (req.body.mode === "json" && req.body.json) {
80793
- body = interpolate(req.body.json, vars);
80852
+ body = interpolate(stripJsonComments(req.body.json), vars);
80794
80853
  if (!headers.has("content-type")) headers.set("Content-Type", "application/json");
80795
80854
  } else if (req.body.mode === "form" && req.body.form) {
80796
80855
  body = req.body.form.filter((p6) => p6.enabled && p6.key).map((p6) => `${encodeURIComponent(interpolate(p6.key, vars))}=${encodeURIComponent(interpolate(p6.value, vars))}`).join("&");
@@ -80804,7 +80863,7 @@ function buildBodyAndApplyHeaders(req, vars, headers) {
80804
80863
  const rawVars = gql.variables?.trim();
80805
80864
  if (rawVars) {
80806
80865
  try {
80807
- gqlBody.variables = JSON.parse(interpolate(rawVars, vars));
80866
+ gqlBody.variables = JSON.parse(interpolate(stripJsonComments(rawVars), vars));
80808
80867
  } catch {
80809
80868
  }
80810
80869
  }
@@ -81375,7 +81434,7 @@ var APP_URL = (process.env.APP_URL || "").replace(/\/+$/, "");
81375
81434
  var AGENT_TOKEN = process.env.AGENT_TOKEN || "";
81376
81435
  var RUNTIME_TOKEN = process.env.RUNTIME_TOKEN || "";
81377
81436
  var POLL_MS = Number(process.env.POLL_INTERVAL_MS || 5e3);
81378
- var VERSION = true ? "0.8.4" : "";
81437
+ var VERSION = true ? "0.8.5" : "";
81379
81438
  var authHeaders = AGENT_TOKEN ? { Authorization: `Bearer ${AGENT_TOKEN}` } : RUNTIME_TOKEN ? { "X-Runtime-Token": RUNTIME_TOKEN } : {};
81380
81439
  async function postResult(m6, fields) {
81381
81440
  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.8.4",
3
+ "version": "0.8.5",
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",