@testsmith/api-spector 0.7.3 → 0.7.4

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.
@@ -197,6 +197,13 @@ function parseBody(body) {
197
197
  return body;
198
198
  }
199
199
  }
200
+ const MAX_CAPTURED_BODY = 2e4;
201
+ function clipBody(body) {
202
+ if (body == null) return { clipped: false };
203
+ if (body.length <= MAX_CAPTURED_BODY) return { text: body, clipped: false };
204
+ return { text: body.slice(0, MAX_CAPTURED_BODY) + `
205
+ … [truncated ${body.length - MAX_CAPTURED_BODY} more chars]`, clipped: true };
206
+ }
200
207
  async function runFlow(flow, deps, options = {}) {
201
208
  const startedAt = Date.now();
202
209
  const maxSteps = deps.maxSteps ?? 1e4;
@@ -396,6 +403,8 @@ async function runFlow(flow, deps, options = {}) {
396
403
  ctx.response = r.response;
397
404
  const ok = r.status === "passed" || r.status === "skipped";
398
405
  const reqStatus = r.status === "skipped" ? "done" : r.status === "pending" ? "running" : r.status;
406
+ const reqBody = clipBody(r.sentRequest?.body);
407
+ const resBody = clipBody(r.response?.body);
399
408
  record(block, reqStatus, {
400
409
  iteration,
401
410
  httpStatus: r.httpStatus,
@@ -403,7 +412,16 @@ async function runFlow(flow, deps, options = {}) {
403
412
  error: r.error,
404
413
  testResults: r.testResults,
405
414
  method: r.method,
406
- resolvedUrl: r.resolvedUrl
415
+ resolvedUrl: r.resolvedUrl,
416
+ http: {
417
+ reqHeaders: r.sentRequest?.headers,
418
+ reqBody: reqBody.text,
419
+ statusText: r.response?.statusText,
420
+ resHeaders: r.response?.headers,
421
+ resBody: resBody.text,
422
+ bodySize: r.response?.bodySize,
423
+ truncated: reqBody.clipped || resBody.clipped
424
+ }
407
425
  });
408
426
  return [ok ? "success" : "fail"];
409
427
  }
package/out/main/flow.js CHANGED
@@ -5,7 +5,7 @@ const path = require("node:path");
5
5
  const requestExec = require("./chunks/request-exec-CcLHtkwG.js");
6
6
  const requestCollection = require("./chunks/request-collection-KGPuvN7o.js");
7
7
  const environments = require("./chunks/environments-iM3SUM-4.js");
8
- const flowEngine = require("./chunks/flow-engine-DuO1iX7c.js");
8
+ const flowEngine = require("./chunks/flow-engine-BVzjz4lJ.js");
9
9
  const cliCommon = require("./chunks/cli-common-GnihVSjU.js");
10
10
  require("undici");
11
11
  require("fs/promises");
@@ -265,7 +265,7 @@ async function main() {
265
265
  const envName = args.environment ?? args.env;
266
266
  const env = environments.selectEnvironment(workspace, environments$1, envName);
267
267
  const verbose = Boolean(args.verbose);
268
- const version = `v${"0.7.3"}`;
268
+ const version = `v${"0.7.4"}`;
269
269
  console.log("");
270
270
  console.log(cliCommon.color(" API Flow Runner" + (version ? ` ${version}` : ""), cliCommon.C.bold, cliCommon.C.white));
271
271
  console.log(cliCommon.color(` Flow: ${flow.name}`, cliCommon.C.gray));
package/out/main/index.js CHANGED
@@ -35,7 +35,7 @@ const uuid = require("uuid");
35
35
  const jsYaml = require("js-yaml");
36
36
  const undici = require("undici");
37
37
  const requestCollection = require("./chunks/request-collection-KGPuvN7o.js");
38
- const flowEngine = require("./chunks/flow-engine-DuO1iX7c.js");
38
+ const flowEngine = require("./chunks/flow-engine-BVzjz4lJ.js");
39
39
  const mockServer = require("./chunks/mock-server-C4kTFkod.js");
40
40
  const http = require("node:http");
41
41
  const WebSocket = require("ws");
@@ -5877,7 +5877,19 @@ async function buildFlowDefinition(input) {
5877
5877
  requests[`${ref.collectionId}:${ref.requestId}`] = cloned;
5878
5878
  }
5879
5879
  }
5880
- return { flow: input.flow, flows: input.flows ?? [], requests, envVars, collectionVars, globals: input.globals ?? {} };
5880
+ return {
5881
+ flow: input.flow,
5882
+ flows: input.flows ?? [],
5883
+ requests,
5884
+ envVars,
5885
+ collectionVars,
5886
+ globals: input.globals ?? {},
5887
+ // Record which environment's values were baked (for the cloud UI). null when
5888
+ // no environment was active at push time — a common cause of "works locally,
5889
+ // fails in the cloud" when requests rely on environment variables.
5890
+ environmentName: input.environment?.name ?? null,
5891
+ envVarCount: Object.keys(envVars).length
5892
+ };
5881
5893
  }
5882
5894
  const CLOUD_TOKEN_REF = "cloud:token";
5883
5895
  const CLOUD_ENDPOINT = brokerClient.resolveCloudEndpoint();
@@ -6098,7 +6110,7 @@ function isNewer(a, b) {
6098
6110
  return a2 > b2;
6099
6111
  }
6100
6112
  async function checkForUpdate() {
6101
- const current = "0.7.3";
6113
+ const current = "0.7.4";
6102
6114
  try {
6103
6115
  const res = await fetch(REGISTRY_URL, { signal: AbortSignal.timeout(4e3) });
6104
6116
  if (!res.ok) return null;
package/out/main/lib.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const mockServer = require("./chunks/mock-server-C4kTFkod.js");
4
4
  const requestExec = require("./chunks/request-exec-CcLHtkwG.js");
5
- const flowEngine = require("./chunks/flow-engine-DuO1iX7c.js");
5
+ const flowEngine = require("./chunks/flow-engine-BVzjz4lJ.js");
6
6
  require("node:http");
7
7
  require("node:crypto");
8
8
  require("node:vm");
@@ -56,7 +56,13 @@ async function runFlowHeadless(input) {
56
56
  testResults: result.testResults,
57
57
  name: result.name,
58
58
  method: result.method,
59
- resolvedUrl: result.resolvedUrl
59
+ resolvedUrl: result.resolvedUrl,
60
+ sentRequest: {
61
+ method: result.method,
62
+ url: result.resolvedUrl,
63
+ headers: result.sentRequest?.headers ?? {},
64
+ body: result.sentRequest?.body
65
+ }
60
66
  };
61
67
  },
62
68
  runScript: async (code, i) => {
@@ -495,7 +495,7 @@ async function main() {
495
495
  } else if (!envName && workspace.settings?.defaultEnvironment && !env) {
496
496
  console.warn(cliCommon.color(`Warning: default environment "${workspace.settings.defaultEnvironment}" not found. Running without environment.`, cliCommon.C.yellow));
497
497
  }
498
- const version = `v${"0.7.3"}`;
498
+ const version = `v${"0.7.4"}`;
499
499
  console.log("");
500
500
  console.log(cliCommon.color(" API Test Runner" + (version ? ` ${version}` : ""), cliCommon.C.bold, cliCommon.C.white));
501
501
  console.log(cliCommon.color(` Workspace: ${wsPath}`, cliCommon.C.gray));
@@ -1,5 +1,5 @@
1
1
  import { l as linter, E as EditorView, L as LanguageSupport, e as LRLanguage, s as styleTags, i as indentNodeProp, f as delimitedIndent, m as foldNodeProp, n as foldInside, S as StateField, p as LRParser, q as StateEffect, u as tags, r as reactExports, j as jsxRuntimeExports, c as ReactCodeMirror, o as oneDark, b as json } from "./codemirror-F6m3Hm1M.js";
2
- import { u as useT, a as useStore, b as useActiveEnvironment } from "./index-aKbixApk.js";
2
+ import { u as useT, a as useStore, b as useActiveEnvironment } from "./index-Cy2EGsQK.js";
3
3
  import "./ajv-2MAg6kGF.js";
4
4
  function devAssert(condition, message) {
5
5
  const booleanCondition = Boolean(condition);
@@ -1,5 +1,5 @@
1
1
  import { r as reactExports, j as jsxRuntimeExports, c as ReactCodeMirror, o as oneDark, x as xml } from "./codemirror-F6m3Hm1M.js";
2
- import { u as useT, c as btnPrimaryCls, d as commentKeymap } from "./index-aKbixApk.js";
2
+ import { u as useT, c as btnPrimaryCls, d as commentKeymap } from "./index-Cy2EGsQK.js";
3
3
  import "./ajv-2MAg6kGF.js";
4
4
  const SOAP_11_CONTENT_TYPE = "text/xml; charset=utf-8";
5
5
  const SOAP_12_CONTENT_TYPE = "application/soap+xml; charset=utf-8";
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./GraphQLEditor-jCEopi26.js","./codemirror-F6m3Hm1M.js","./ajv-2MAg6kGF.js","./SoapEditor-PGdehf_W.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./GraphQLEditor-Ih9tb7XI.js","./codemirror-F6m3Hm1M.js","./ajv-2MAg6kGF.js","./SoapEditor-CwrFQmAx.js"])))=>i.map(i=>d[i]);
2
2
  import { r as reactExports, g as getDefaultExportFromCjs, R as React$4, a as autocompletion, h as hoverTooltip, j as jsxRuntimeExports, k as keymap, t as toggleComment, x as xml, b as json, c as ReactCodeMirror, o as oneDark, d as javascript } from "./codemirror-F6m3Hm1M.js";
3
3
  import { A as Ajv } from "./ajv-2MAg6kGF.js";
4
4
  var client = { exports: {} };
@@ -27830,8 +27830,8 @@ function jsonWithComments() {
27830
27830
  function xmlWithComments() {
27831
27831
  return [xml(), commentKeymap];
27832
27832
  }
27833
- const GraphQLEditor = reactExports.lazy(() => __vitePreload(() => import("./GraphQLEditor-jCEopi26.js"), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url).then((m) => ({ default: m.GraphQLEditor })));
27834
- const SoapEditor = reactExports.lazy(() => __vitePreload(() => import("./SoapEditor-PGdehf_W.js"), true ? __vite__mapDeps([3,1,2]) : void 0, import.meta.url).then((m) => ({ default: m.SoapEditor })));
27833
+ const GraphQLEditor = reactExports.lazy(() => __vitePreload(() => import("./GraphQLEditor-Ih9tb7XI.js"), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url).then((m) => ({ default: m.GraphQLEditor })));
27834
+ const SoapEditor = reactExports.lazy(() => __vitePreload(() => import("./SoapEditor-CwrFQmAx.js"), true ? __vite__mapDeps([3,1,2]) : void 0, import.meta.url).then((m) => ({ default: m.SoapEditor })));
27835
27835
  function BodyTab({ request: request2, onChange }) {
27836
27836
  const t = useT();
27837
27837
  const editorFallback = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 text-xs text-surface-500", children: t("Loading editor…") });
@@ -33018,7 +33018,7 @@ function WelcomeScreen() {
33018
33018
  )
33019
33019
  ] }),
33020
33020
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-surface-400 text-sm max-w-sm", children: t("Local-first API testing with Robot Framework & Playwright code generation. Secrets stay on your machine.") }),
33021
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[11px] mt-3", style: { color: "var(--text-muted)" }, children: t("version :version", { version: "0.7.3" }) })
33021
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[11px] mt-3", style: { color: "var(--text-muted)" }, children: t("version :version", { version: "0.7.4" }) })
33022
33022
  ] }),
33023
33023
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 w-64", children: [
33024
33024
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -52639,7 +52639,7 @@ function App() {
52639
52639
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
52640
52640
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
52641
52641
  "v",
52642
- "0.7.3"
52642
+ "0.7.4"
52643
52643
  ] }),
52644
52644
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
52645
52645
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -5,7 +5,7 @@
5
5
  <meta charset="UTF-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>API Spector</title>
8
- <script type="module" crossorigin src="./assets/index-aKbixApk.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-Cy2EGsQK.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/codemirror-F6m3Hm1M.js">
10
10
  <link rel="modulepreload" crossorigin href="./assets/ajv-2MAg6kGF.js">
11
11
  <link rel="stylesheet" crossorigin href="./assets/index-CkWcesWQ.css">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@testsmith/api-spector",
3
3
  "productName": "API Spector",
4
- "version": "0.7.3",
4
+ "version": "0.7.4",
5
5
  "description": "Local-first API testing tool to inspect, test and mock APIs",
6
6
  "repository": {
7
7
  "type": "git",