@testsmith/api-spector 0.8.4 → 0.8.6

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.
@@ -3,7 +3,7 @@ const promises = require("node:fs/promises");
3
3
  const path = require("node:path");
4
4
  const crypto = require("node:crypto");
5
5
  const undici = require("undici");
6
- const requestExec = require("./request-exec-SKbmXjo-.js");
6
+ const requestExec = require("./request-exec-BI4sXJop.js");
7
7
  const Ajv = require("ajv");
8
8
  const jsYaml = require("js-yaml");
9
9
  require("node:http");
@@ -283,6 +283,8 @@ const IPC = {
283
283
  },
284
284
  // ─── Cloud (API Spector Cloud integration) ──────────────────────────────────
285
285
  cloud: {
286
+ /** One-click connect: browser consent + PKCE, returns a fresh token. */
287
+ connect: "cloud:connect",
286
288
  /** Verify the endpoint + token (GET /api/me). */
287
289
  test: "cloud:test",
288
290
  /** Push a mock server definition (POST /api/mocks). */
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const uuid = require("uuid");
4
- const soapHandler = require("./soap-handler-LmMvd8e1.js");
5
- require("./handle-COrktzST.js");
4
+ const soapHandler = require("./soap-handler-BF5ii0UV.js");
5
+ require("./handle-_4XMUlwm.js");
6
6
  require("node:https");
7
7
  require("node:http");
8
8
  require("@xmldom/xmldom");
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const requestExec = require("./request-exec-SKbmXjo-.js");
2
+ const requestExec = require("./request-exec-BI4sXJop.js");
3
3
  const grpc = require("@grpc/grpc-js");
4
4
  const protoLoader = require("@grpc/proto-loader");
5
5
  const fs = require("node:fs");
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  const undici = require("undici");
25
25
  const promises$1 = require("fs/promises");
26
26
  const nodeTls = require("tls");
27
- const handle = require("./handle-COrktzST.js");
27
+ const handle = require("./handle-_4XMUlwm.js");
28
28
  const fs = require("node:fs");
29
29
  const os = require("node:os");
30
30
  const path = require("node:path");
@@ -934,7 +934,7 @@ async function resolveInlineSecretRefs(text) {
934
934
  }
935
935
  function mergeVars(envVars, collectionVars, globals2, localVars = {}, dynamicVars = {}, folderVars = {}) {
936
936
  const out = {};
937
- for (const src of [dynamicVars, globals2, collectionVars, folderVars, envVars, localVars]) {
937
+ for (const src of [dynamicVars, globals2, collectionVars, envVars, folderVars, localVars]) {
938
938
  for (const [k, v] of Object.entries(src ?? {})) {
939
939
  if (v == null) continue;
940
940
  out[k] = v;
@@ -1564,6 +1564,63 @@ async function readStream(body, kind, startMs, opts = {}) {
1564
1564
  }
1565
1565
  return { events, text, close, firstEventMs: Math.max(firstEventMs, 0) };
1566
1566
  }
1567
+ function jsonCommentRanges(input) {
1568
+ const ranges = [];
1569
+ const n = input.length;
1570
+ let i = 0;
1571
+ let inString = false;
1572
+ while (i < n) {
1573
+ const c = input[i];
1574
+ if (inString) {
1575
+ if (c === "\\") {
1576
+ i += 2;
1577
+ continue;
1578
+ }
1579
+ if (c === '"') inString = false;
1580
+ i++;
1581
+ continue;
1582
+ }
1583
+ if (c === '"') {
1584
+ inString = true;
1585
+ i++;
1586
+ continue;
1587
+ }
1588
+ const next = input[i + 1];
1589
+ if (c === "/" && next === "/") {
1590
+ const from = i;
1591
+ i += 2;
1592
+ while (i < n && input[i] !== "\n") i++;
1593
+ ranges.push({ from, to: i, type: "line" });
1594
+ continue;
1595
+ }
1596
+ if (c === "/" && next === "*") {
1597
+ const from = i;
1598
+ i += 2;
1599
+ while (i < n && !(input[i] === "*" && input[i + 1] === "/")) i++;
1600
+ i = Math.min(i + 2, n);
1601
+ ranges.push({ from, to: i, type: "block" });
1602
+ continue;
1603
+ }
1604
+ i++;
1605
+ }
1606
+ return ranges;
1607
+ }
1608
+ function stripJsonComments(input) {
1609
+ const ranges = jsonCommentRanges(input);
1610
+ if (!ranges.length) return input;
1611
+ let out = "";
1612
+ let pos = 0;
1613
+ for (const r of ranges) {
1614
+ out += input.slice(pos, r.from);
1615
+ if (r.type === "block") {
1616
+ const seg = input.slice(r.from, r.to);
1617
+ for (let k = 0; k < seg.length; k++) if (seg[k] === "\n") out += "\n";
1618
+ }
1619
+ pos = r.to;
1620
+ }
1621
+ out += input.slice(pos);
1622
+ return out;
1623
+ }
1567
1624
  async function runMqttTest(cfg) {
1568
1625
  const messages = [];
1569
1626
  const collectMs = Math.max(0, Math.min(6e4, Math.floor(cfg.collectMs ?? 2e3)));
@@ -2465,7 +2522,7 @@ async function buildDispatcher(proxy, tls) {
2465
2522
  function buildBodyAndApplyHeaders(req, vars, headers) {
2466
2523
  let body;
2467
2524
  if (req.body.mode === "json" && req.body.json) {
2468
- body = interpolate(req.body.json, vars);
2525
+ body = interpolate(stripJsonComments(req.body.json), vars);
2469
2526
  if (!headers.has("content-type")) headers.set("Content-Type", "application/json");
2470
2527
  } else if (req.body.mode === "form" && req.body.form) {
2471
2528
  body = req.body.form.filter((p) => p.enabled && p.key).map((p) => `${encodeURIComponent(interpolate(p.key, vars))}=${encodeURIComponent(interpolate(p.value, vars))}`).join("&");
@@ -2479,7 +2536,7 @@ function buildBodyAndApplyHeaders(req, vars, headers) {
2479
2536
  const rawVars = gql.variables?.trim();
2480
2537
  if (rawVars) {
2481
2538
  try {
2482
- gqlBody.variables = JSON.parse(interpolate(rawVars, vars));
2539
+ gqlBody.variables = JSON.parse(interpolate(stripJsonComments(rawVars), vars));
2483
2540
  } catch {
2484
2541
  }
2485
2542
  }
@@ -2957,4 +3014,5 @@ exports.runSocketIoTest = runSocketIoTest;
2957
3014
  exports.runWsTest = runWsTest;
2958
3015
  exports.setGlobals = setGlobals;
2959
3016
  exports.setSecretsConfig = setSecretsConfig;
3017
+ exports.stripJsonComments = stripJsonComments;
2960
3018
  exports.syntheticHttpFailure = syntheticHttpFailure;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const handle = require("./handle-COrktzST.js");
2
+ const handle = require("./handle-_4XMUlwm.js");
3
3
  const https = require("node:https");
4
4
  const http = require("node:http");
5
5
  const xmldom = require("@xmldom/xmldom");
@@ -324,7 +324,7 @@ function registerSoapHandlers(ipc) {
324
324
  handle.handleIpc(ipc, handle.IPC.wsdl.import, async (_event, opts) => {
325
325
  const { validateWsdlImport } = await Promise.resolve().then(() => require("./ipc-validate-sqUFqRmE.js"));
326
326
  validateWsdlImport(opts);
327
- const { importWsdl } = await Promise.resolve().then(() => require("./import-BmZaS9zL.js"));
327
+ const { importWsdl } = await Promise.resolve().then(() => require("./import-ujxXe3Uu.js"));
328
328
  const wsdlText = opts.xml ?? (opts.url ? await fetchUrl(opts.url) : "");
329
329
  if (!wsdlText) throw new Error("wsdl:import requires either `url` or `xml`");
330
330
  return importWsdl(wsdlText, { name: opts.name, existingMockPorts: opts.existingMockPorts });
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  const promises = require("node:fs/promises");
4
4
  const path = require("node:path");
5
- const brokerClient = require("./chunks/broker-client-BMV6WVVG.js");
5
+ const brokerClient = require("./chunks/broker-client-Bp9YId3a.js");
6
6
  const escape = require("./chunks/escape-DDVAlOvZ.js");
7
7
  const crypto = require("node:crypto");
8
8
  const undici = require("undici");
@@ -11,10 +11,10 @@ const cliCommon = require("./chunks/cli-common-GnihVSjU.js");
11
11
  const node_child_process = require("node:child_process");
12
12
  const jsYaml = require("js-yaml");
13
13
  const environments = require("./chunks/environments-iM3SUM-4.js");
14
- require("./chunks/request-exec-SKbmXjo-.js");
14
+ require("./chunks/request-exec-BI4sXJop.js");
15
15
  require("fs/promises");
16
16
  require("tls");
17
- require("./chunks/handle-COrktzST.js");
17
+ require("./chunks/handle-_4XMUlwm.js");
18
18
  require("node:fs");
19
19
  require("dayjs");
20
20
  require("node:vm");
package/out/main/flow.js CHANGED
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  const promises = require("node:fs/promises");
4
4
  const path = require("node:path");
5
- const requestExec = require("./chunks/request-exec-SKbmXjo-.js");
5
+ const requestExec = require("./chunks/request-exec-BI4sXJop.js");
6
6
  const requestCollection = require("./chunks/request-collection-gkOYlWml.js");
7
7
  const environments = require("./chunks/environments-iM3SUM-4.js");
8
8
  const flowEngine = require("./chunks/flow-engine-BxwjEy37.js");
@@ -10,7 +10,7 @@ const cliCommon = require("./chunks/cli-common-GnihVSjU.js");
10
10
  require("undici");
11
11
  require("fs/promises");
12
12
  require("tls");
13
- require("./chunks/handle-COrktzST.js");
13
+ require("./chunks/handle-_4XMUlwm.js");
14
14
  require("node:fs");
15
15
  require("node:os");
16
16
  require("node:crypto");
@@ -268,7 +268,7 @@ async function main() {
268
268
  const envName = args.environment ?? args.env;
269
269
  const env = environments.selectEnvironment(workspace, environments$1, envName);
270
270
  const verbose = Boolean(args.verbose);
271
- const version = `v${"0.8.4"}`;
271
+ const version = `v${"0.8.6"}`;
272
272
  console.log("");
273
273
  console.log(cliCommon.color(" API Flow Runner" + (version ? ` ${version}` : ""), cliCommon.C.bold, cliCommon.C.white));
274
274
  console.log(cliCommon.color(` Flow: ${flow.name}`, cliCommon.C.gray));