@testsmith/api-spector 0.8.0 → 0.8.2

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.
package/out/main/flow.js CHANGED
@@ -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.0"}`;
271
+ const version = `v${"0.8.2"}`;
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));
package/out/main/index.js CHANGED
@@ -1106,9 +1106,12 @@ const INSOMNIA_RULES = [
1106
1106
  [/\bcontext\.response\.getStatusCode\(\)/g, "sp.response.code"],
1107
1107
  [/\bcontext\.response\.getHeader\(/g, "sp.response.headers.get("]
1108
1108
  ];
1109
+ const COMMON_RULES = [
1110
+ [/\brequire\(\s*['"]moment['"]\s*\)/g, "dayjs"]
1111
+ ];
1109
1112
  function translateScript(source, format) {
1110
- const rules = format === "postman" ? POSTMAN_RULES : format === "bruno" ? BRUNO_RULES : INSOMNIA_RULES;
1111
- return rules.reduce((src, [pattern, replacement]) => src.replace(pattern, replacement), source);
1113
+ const formatRules = format === "postman" ? POSTMAN_RULES : format === "bruno" ? BRUNO_RULES : INSOMNIA_RULES;
1114
+ return [...formatRules, ...COMMON_RULES].reduce((src, [pattern, replacement]) => src.replace(pattern, replacement), source);
1112
1115
  }
1113
1116
  function parseHeaders$1(raw) {
1114
1117
  return (raw ?? []).map((h) => ({
@@ -1130,7 +1133,12 @@ function parseParams$1(urlObj) {
1130
1133
  function parseUrl(urlObj) {
1131
1134
  if (!urlObj) return "";
1132
1135
  if (typeof urlObj === "string") return urlObj;
1133
- return urlObj.raw ?? "";
1136
+ const raw = urlObj.raw ?? "";
1137
+ if (Array.isArray(urlObj.query) && urlObj.query.length) {
1138
+ const q = raw.indexOf("?");
1139
+ if (q !== -1) return raw.slice(0, q);
1140
+ }
1141
+ return raw;
1134
1142
  }
1135
1143
  function parseBody$1(body) {
1136
1144
  if (!body) return { mode: "none" };
@@ -1842,7 +1850,7 @@ function parseBruFile(content, fileName) {
1842
1850
  break;
1843
1851
  }
1844
1852
  }
1845
- const url = methodAttrs["url"] ?? "";
1853
+ let url = methodAttrs["url"] ?? "";
1846
1854
  const bodyMode = methodAttrs["body"] ?? "none";
1847
1855
  const authMode = methodAttrs["auth"] ?? "none";
1848
1856
  const headers = Object.entries(parseKv(extractBlock(content, "headers"))).map(([k, v]) => ({
@@ -1855,6 +1863,10 @@ function parseBruFile(content, fileName) {
1855
1863
  value: v,
1856
1864
  enabled: true
1857
1865
  }));
1866
+ if (params.length) {
1867
+ const q = url.indexOf("?");
1868
+ if (q !== -1) url = url.slice(0, q);
1869
+ }
1858
1870
  let body = { mode: "none" };
1859
1871
  if (bodyMode === "json") {
1860
1872
  const jsonContent = extractBlock(content, "body:json") ?? "";
@@ -7303,7 +7315,7 @@ function isNewer(a, b) {
7303
7315
  return a2 > b2;
7304
7316
  }
7305
7317
  async function checkForUpdate() {
7306
- const current = "0.8.0";
7318
+ const current = "0.8.2";
7307
7319
  try {
7308
7320
  const res = await fetch(REGISTRY_URL, { signal: AbortSignal.timeout(4e3) });
7309
7321
  if (!res.ok) return null;
package/out/main/perf.js CHANGED
@@ -191,7 +191,7 @@ async function main() {
191
191
  targetLabel = `flow: ${flow.name}`;
192
192
  }
193
193
  const load = perfRun.deriveLoad(plan);
194
- const version = `v${"0.8.0"}`;
194
+ const version = `v${"0.8.2"}`;
195
195
  console.log("");
196
196
  console.log(cliCommon.color(" API Performance" + (version ? ` ${version}` : ""), cliCommon.C.bold, cliCommon.C.white));
197
197
  console.log(cliCommon.color(` Plan: ${plan.name}`, cliCommon.C.gray));
@@ -551,7 +551,7 @@ async function main() {
551
551
  } else if (!envName && workspace.settings?.defaultEnvironment && !env) {
552
552
  console.warn(cliCommon.color(`Warning: default environment "${workspace.settings.defaultEnvironment}" not found. Running without environment.`, cliCommon.C.yellow));
553
553
  }
554
- const version = `v${"0.8.0"}`;
554
+ const version = `v${"0.8.2"}`;
555
555
  console.log("");
556
556
  console.log(cliCommon.color(" API Test Runner" + (version ? ` ${version}` : ""), cliCommon.C.bold, cliCommon.C.white));
557
557
  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, f as LRLanguage, s as styleTags, i as indentNodeProp, m as delimitedIndent, n as foldNodeProp, p as foldInside, S as StateField, q as LRParser, u as StateEffect, v as tags, a as reactExports, j as jsxRuntimeExports, d as ReactCodeMirror, o as oneDark, c as json } from "./codemirror-CdIFBPs2.js";
2
- import { u as useT, a as useStore, b as useActiveEnvironment, i as isSubscriptionQuery } from "./index-CpSTmcc1.js";
2
+ import { u as useT, a as useStore, b as useActiveEnvironment, i as isSubscriptionQuery } from "./index-CRFyHn2H.js";
3
3
  import "./ajv-CJPwFjiP.js";
4
4
  function devAssert(condition, message) {
5
5
  const booleanCondition = Boolean(condition);
@@ -1,5 +1,5 @@
1
1
  import { a as reactExports, j as jsxRuntimeExports, d as ReactCodeMirror, o as oneDark, x as xml } from "./codemirror-CdIFBPs2.js";
2
- import { u as useT, c as btnPrimaryCls, d as commentKeymap } from "./index-CpSTmcc1.js";
2
+ import { u as useT, c as btnPrimaryCls, d as commentKeymap } from "./index-CRFyHn2H.js";
3
3
  import "./ajv-CJPwFjiP.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";