@testsmith/api-spector 0.6.3 → 0.6.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 (29) hide show
  1. package/out/main/agents.js +5 -5
  2. package/out/main/chunks/{broker-client-WEymdqAK.js → broker-client-CvRuiX3o.js} +26 -23
  3. package/out/main/chunks/{cli-common-vASoDfQH.js → cli-common-Cq_cphpZ.js} +4 -4
  4. package/out/main/chunks/{coverage-C54mZEh_.js → coverage-C0U4QM83.js} +8 -10
  5. package/out/main/chunks/{data-files-Br2h3Dt2.js → data-files-BYqhsoPe.js} +4 -4
  6. package/out/main/chunks/escape-DDVAlOvZ.js +9 -0
  7. package/out/main/chunks/{import-DdXhO56X.js → import-DYssQzex.js} +4 -4
  8. package/out/main/chunks/{mock-server-BxiXhP1m.js → mock-server-C4kTFkod.js} +9 -11
  9. package/out/main/chunks/{recorder-0Ij921El.js → recorder-BkO8G_mB.js} +2 -2
  10. package/out/main/chunks/{request-collection-GzK4QgvT.js → request-collection-KGPuvN7o.js} +2 -2
  11. package/out/main/chunks/{request-exec-DAFA6Fap.js → request-exec-BRmVweue.js} +41 -41
  12. package/out/main/chunks/{soap-handler-BAPCALkN.js → soap-handler-BznuMFIP.js} +7 -9
  13. package/out/main/compare.js +10 -10
  14. package/out/main/contract.js +18 -20
  15. package/out/main/coverage.js +7 -7
  16. package/out/main/generate-tests.js +9 -9
  17. package/out/main/index.js +163 -263
  18. package/out/main/lib.js +6 -7
  19. package/out/main/mock.js +8 -8
  20. package/out/main/record.js +9 -9
  21. package/out/main/runner.js +14 -15
  22. package/out/main/wsdl.js +9 -9
  23. package/out/preload/index.js +1 -1
  24. package/out/renderer/assets/{GraphQLEditor-MImdgXb4.js → GraphQLEditor-u5atf7vH.js} +6 -6
  25. package/out/renderer/assets/{SoapEditor-rxb3heue.js → SoapEditor-D8MpL0vd.js} +3 -3
  26. package/out/renderer/assets/{index-ByGIqJ2H.js → index-C0kKFo3R.js} +380 -269
  27. package/out/renderer/index.html +1 -1
  28. package/package.json +1 -1
  29. package/out/main/chunks/escape-BwPM4Tf6.js +0 -9
@@ -22,21 +22,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  const undici = require("undici");
25
- const promises = require("fs/promises");
25
+ const promises$1 = require("fs/promises");
26
26
  const nodeTls = require("tls");
27
27
  const handle = require("./handle-CL-nWtYA.js");
28
28
  const fs = require("node:fs");
29
29
  const os = require("node:os");
30
- const path$1 = require("node:path");
31
- const node_crypto = require("node:crypto");
32
- const crypto = require("crypto");
33
- const path = require("path");
30
+ const path = require("node:path");
31
+ const crypto = require("node:crypto");
32
+ const promises = require("node:fs/promises");
34
33
  const dayjs = require("dayjs");
35
- const vm = require("vm");
34
+ const vm = require("node:vm");
36
35
  const tv4 = require("tv4");
37
36
  const jsonpathPlus = require("jsonpath-plus");
38
37
  const xmldom = require("@xmldom/xmldom");
39
- const http = require("http");
38
+ const http = require("node:http");
40
39
  const Ajv = require("ajv");
41
40
  function _interopNamespaceDefault(e) {
42
41
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -135,7 +134,7 @@ function resolveConn$3() {
135
134
  if (!address) {
136
135
  throw new Error("Vault is not configured: set VAULT_ADDR (or settings.secrets.vault.address)");
137
136
  }
138
- const token = env$3("VAULT_TOKEN", "API_SPECTOR_VAULT_TOKEN") ?? readFileTrim(path$1.join(os.homedir(), ".vault-token"));
137
+ const token = env$3("VAULT_TOKEN", "API_SPECTOR_VAULT_TOKEN") ?? readFileTrim(path.join(os.homedir(), ".vault-token"));
139
138
  const roleId = env$3("VAULT_ROLE_ID", "API_SPECTOR_VAULT_ROLE_ID") ?? cfg.roleId;
140
139
  const secretId = env$3("VAULT_SECRET_ID", "API_SPECTOR_VAULT_SECRET_ID");
141
140
  const jwt = env$3("VAULT_JWT", "API_SPECTOR_VAULT_JWT") ?? (env$3("VAULT_JWT_PATH", "API_SPECTOR_VAULT_JWT_PATH") ? readFileTrim(env$3("VAULT_JWT_PATH", "API_SPECTOR_VAULT_JWT_PATH")) : void 0);
@@ -264,19 +263,19 @@ const vaultProvider = {
264
263
  resolve: (refBody) => readSecret(refBody)
265
264
  };
266
265
  function hmac(key, data) {
267
- return node_crypto.createHmac("sha256", key).update(data, "utf8").digest();
266
+ return crypto.createHmac("sha256", key).update(data, "utf8").digest();
268
267
  }
269
268
  function sha256hex(data) {
270
- return node_crypto.createHash("sha256").update(data, "utf8").digest("hex");
269
+ return crypto.createHash("sha256").update(data, "utf8").digest("hex");
271
270
  }
272
271
  function signSigV4(input) {
273
- const amzDate = input.now.toISOString().replace(/[:-]|\.\d{3}/g, "");
272
+ const amzDate = input.now.toISOString().replaceAll(/[:-]|\.\d{3}/g, "");
274
273
  const dateStamp = amzDate.slice(0, 8);
275
274
  const headers = { ...input.headers, host: input.host, "x-amz-date": amzDate };
276
275
  if (input.sessionToken) headers["x-amz-security-token"] = input.sessionToken;
277
276
  const lower = {};
278
- for (const k of Object.keys(headers)) lower[k.toLowerCase()] = headers[k].trim().replace(/\s+/g, " ");
279
- const sortedKeys = Object.keys(lower).sort();
277
+ for (const k of Object.keys(headers)) lower[k.toLowerCase()] = headers[k].trim().replaceAll(/\s+/g, " ");
278
+ const sortedKeys = Object.keys(lower).sort((a, b) => a.localeCompare(b));
280
279
  const canonicalHeaders = sortedKeys.map((k) => `${k}:${lower[k]}
281
280
  `).join("");
282
281
  const signedHeaders = sortedKeys.join(";");
@@ -288,7 +287,7 @@ function signSigV4(input) {
288
287
  const kRegion = hmac(kDate, input.region);
289
288
  const kService = hmac(kRegion, input.service);
290
289
  const kSigning = hmac(kService, "aws4_request");
291
- const signature = node_crypto.createHmac("sha256", kSigning).update(stringToSign, "utf8").digest("hex");
290
+ const signature = crypto.createHmac("sha256", kSigning).update(stringToSign, "utf8").digest("hex");
292
291
  return {
293
292
  ...headers,
294
293
  Authorization: `AWS4-HMAC-SHA256 Credential=${input.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
@@ -529,7 +528,7 @@ async function resolve(refBody) {
529
528
  if (!sectionLabel) return true;
530
529
  return String(f?.section?.label ?? "").toLowerCase() === sectionLabel.toLowerCase();
531
530
  });
532
- if (!match || match.value === void 0) {
531
+ if (match?.value === void 0) {
533
532
  throw new Error(`1Password: field '${fieldLabel}' not found on item '${item}'`);
534
533
  }
535
534
  return String(match.value);
@@ -576,7 +575,7 @@ function registerSecretHandlers(ipc) {
576
575
  });
577
576
  handle.handleIpc(ipc, handle.IPC.secret.set, async (_e, ref, value) => {
578
577
  const ss = getSafeStorage();
579
- if (!ss || !ss.isEncryptionAvailable()) {
578
+ if (!ss?.isEncryptionAvailable()) {
580
579
  throw new Error("OS encryption is not available - set the secret via environment variable instead");
581
580
  }
582
581
  secretStore[ref] = ss.encryptString(value).toString("base64");
@@ -597,8 +596,8 @@ function decryptSecret(encrypted, salt, iv, password) {
597
596
  const ivBuf = Buffer.from(iv, "base64");
598
597
  const encBuf = Buffer.from(encrypted, "base64");
599
598
  const key = crypto.pbkdf2Sync(password, saltBuf, 1e5, 32, "sha256");
600
- const authTag = encBuf.subarray(encBuf.length - 16);
601
- const ciphertext = encBuf.subarray(0, encBuf.length - 16);
599
+ const authTag = encBuf.subarray(-16);
600
+ const ciphertext = encBuf.subarray(0, -16);
602
601
  const decipher = crypto.createDecipheriv("aes-256-gcm", key, ivBuf);
603
602
  decipher.setAuthTag(authTag);
604
603
  return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
@@ -610,7 +609,7 @@ async function getSecret(ref) {
610
609
  const stored = secretStore[ref];
611
610
  if (stored) {
612
611
  const ss = getSafeStorage();
613
- if (ss && ss.isEncryptionAvailable()) {
612
+ if (ss?.isEncryptionAvailable()) {
614
613
  try {
615
614
  return ss.decryptString(Buffer.from(stored, "base64"));
616
615
  } catch {
@@ -621,7 +620,7 @@ async function getSecret(ref) {
621
620
  }
622
621
  let _fakerCache$1 = null;
623
622
  async function getFaker$1() {
624
- if (!_fakerCache$1) _fakerCache$1 = await import("@faker-js/faker");
623
+ _fakerCache$1 ??= await import("@faker-js/faker");
625
624
  return _fakerCache$1.faker;
626
625
  }
627
626
  let _exprContext = null;
@@ -650,7 +649,7 @@ async function buildDynamicVars() {
650
649
  };
651
650
  }
652
651
  function interpolate(str, vars) {
653
- return str.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
652
+ return str.replaceAll(/\{\{([^}]+)\}\}/g, (match, key) => {
654
653
  const trimmed = key.trim();
655
654
  if (trimmed in vars) return vars[trimmed];
656
655
  if (_exprContext && (trimmed.includes(".") || trimmed.includes("("))) {
@@ -670,7 +669,7 @@ function resolveDataRow(row, scope) {
670
669
  }
671
670
  function buildUrl(baseUrl, params, vars) {
672
671
  const templateTokens = /* @__PURE__ */ new Set();
673
- baseUrl.replace(/\{\{([^}]+)\}\}/g, (_m, name) => {
672
+ baseUrl.replaceAll(/\{\{([^}]+)\}\}/g, (_m, name) => {
674
673
  templateTokens.add(String(name).trim());
675
674
  return "";
676
675
  });
@@ -698,7 +697,7 @@ function rebaseUrl(fullUrl, baseUrl) {
698
697
  const orig = new URL(fullUrl, "http://placeholder.invalid");
699
698
  const base = new URL(baseUrl);
700
699
  const basePath = base.pathname.replace(/\/$/, "");
701
- base.pathname = (basePath + orig.pathname).replace(/\/{2,}/g, "/");
700
+ base.pathname = (basePath + orig.pathname).replaceAll(/\/{2,}/g, "/");
702
701
  base.search = orig.search;
703
702
  return base.toString();
704
703
  } catch {
@@ -755,14 +754,14 @@ function xmlFindAll(node, tag, nth) {
755
754
  }
756
755
  function xmlQuerySelector(root, selector) {
757
756
  const parts = selector.trim().split(/\s*>\s*/);
758
- const m0 = parts[0].match(/^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/);
757
+ const m0 = /^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/.exec(parts[0]);
759
758
  if (!m0) return null;
760
- let candidates = xmlFindAll(root, m0[1], m0[2] ? parseInt(m0[2]) - 1 : 0);
759
+ let candidates = xmlFindAll(root, m0[1], m0[2] ? Number.parseInt(m0[2]) - 1 : 0);
761
760
  for (let i = 1; i < parts.length; i++) {
762
- const m = parts[i].match(/^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/);
761
+ const m = /^([A-Za-z0-9_:.-]+?)(?::nth-of-type\((\d+)\))?$/.exec(parts[i]);
763
762
  if (!m) return null;
764
763
  const tag = m[1];
765
- const idx = m[2] ? parseInt(m[2]) - 1 : 0;
764
+ const idx = m[2] ? Number.parseInt(m[2]) - 1 : 0;
766
765
  const next = [];
767
766
  for (const node of candidates) {
768
767
  const children = Array.from(node.childNodes).filter((c) => c.nodeType === 1 && c.tagName === tag);
@@ -783,7 +782,7 @@ function makeSandboxDOMParser() {
783
782
  }
784
783
  let _fakerCache = null;
785
784
  async function getFaker() {
786
- if (!_fakerCache) _fakerCache = await import("@faker-js/faker");
785
+ _fakerCache ??= await import("@faker-js/faker");
787
786
  return _fakerCache.faker;
788
787
  }
789
788
  function makeAsserter(value, negated = false) {
@@ -982,7 +981,7 @@ function buildAt(ctx, testResults, consoleOutput) {
982
981
  const period = options?.period ?? 30;
983
982
  const algorithm = options?.algorithm ?? "sha1";
984
983
  const base32chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
985
- const cleaned = secret.replace(/[\s=-]/g, "").toUpperCase();
984
+ const cleaned = secret.replaceAll(/[\s=-]/g, "").toUpperCase();
986
985
  let bits = "";
987
986
  for (const c of cleaned) {
988
987
  const val = base32chars.indexOf(c);
@@ -991,7 +990,7 @@ function buildAt(ctx, testResults, consoleOutput) {
991
990
  }
992
991
  const keyBytes = Buffer.alloc(Math.floor(bits.length / 8));
993
992
  for (let i = 0; i < keyBytes.length; i++) {
994
- keyBytes[i] = parseInt(bits.slice(i * 8, i * 8 + 8), 2);
993
+ keyBytes[i] = Number.parseInt(bits.slice(i * 8, i * 8 + 8), 2);
995
994
  }
996
995
  const counter = Math.floor(Date.now() / 1e3 / period);
997
996
  const counterBuf = Buffer.alloc(8);
@@ -1070,8 +1069,9 @@ async function runScript(code, ctx, timeoutMs = 5e3) {
1070
1069
  JSON,
1071
1070
  Math,
1072
1071
  Date,
1073
- parseInt,
1074
- parseFloat,
1072
+ parseInt: Number.parseInt,
1073
+ parseFloat: Number.parseFloat,
1074
+ // isNaN/isFinite intentionally expose the global (coercing) semantics user scripts expect
1075
1075
  isNaN,
1076
1076
  isFinite,
1077
1077
  encodeURIComponent,
@@ -1148,7 +1148,7 @@ class StreamFramer {
1148
1148
  carry = "";
1149
1149
  /** Feed a decoded text chunk; returns the frames that completed. */
1150
1150
  push(text) {
1151
- this.carry += text.replace(/\r\n?/g, "\n");
1151
+ this.carry += text.replaceAll(/\r\n?/g, "\n");
1152
1152
  return this.mode === "sse" ? this.drainSse() : this.drainNdjson();
1153
1153
  }
1154
1154
  /** Emit whatever remains once the stream closes (a last line/block with no
@@ -1211,7 +1211,7 @@ class StreamFramer {
1211
1211
  function toEvent(frame, kind, seq, tMs) {
1212
1212
  let json;
1213
1213
  const trimmed = frame.data.trim();
1214
- if (trimmed && (trimmed[0] === "{" || trimmed[0] === "[")) {
1214
+ if (trimmed && (trimmed.startsWith("{") || trimmed.startsWith("["))) {
1215
1215
  try {
1216
1216
  json = JSON.parse(trimmed);
1217
1217
  } catch {
@@ -1305,7 +1305,7 @@ async function readStream(body, kind, startMs, opts = {}) {
1305
1305
  } catch {
1306
1306
  }
1307
1307
  }
1308
- return { events, text, close, firstEventMs: firstEventMs < 0 ? 0 : firstEventMs };
1308
+ return { events, text, close, firstEventMs: Math.max(firstEventMs, 0) };
1309
1309
  }
1310
1310
  const SIGNATURE = Buffer.from("NTLMSSP\0", "latin1");
1311
1311
  const F_UNICODE = 1;
@@ -1756,11 +1756,11 @@ function maskObject(obj, patterns) {
1756
1756
  }
1757
1757
  function maskHeaders(headers, patterns) {
1758
1758
  if (!patterns.length) return headers;
1759
- const alwaysMask = ["authorization", "cookie", "set-cookie"];
1759
+ const alwaysMask = /* @__PURE__ */ new Set(["authorization", "cookie", "set-cookie"]);
1760
1760
  const result = {};
1761
1761
  for (const [k, v] of Object.entries(headers)) {
1762
1762
  const lower = k.toLowerCase();
1763
- if (alwaysMask.includes(lower) || patterns.some((p) => lower.includes(p.toLowerCase()))) {
1763
+ if (alwaysMask.has(lower) || patterns.some((p) => lower.includes(p.toLowerCase()))) {
1764
1764
  result[k] = "[REDACTED]";
1765
1765
  } else {
1766
1766
  result[k] = v;
@@ -1853,7 +1853,7 @@ function applyRequestDefaults(req) {
1853
1853
  }
1854
1854
  let _defaultAgent;
1855
1855
  function defaultAgent() {
1856
- if (!_defaultAgent) _defaultAgent = new undici.Agent({ allowH2: true });
1856
+ _defaultAgent ??= new undici.Agent({ allowH2: true });
1857
1857
  return _defaultAgent;
1858
1858
  }
1859
1859
  async function buildDispatcher(proxy, tls) {
@@ -1867,19 +1867,19 @@ async function buildDispatcher(proxy, tls) {
1867
1867
  }
1868
1868
  if (tls.caCertPath) {
1869
1869
  try {
1870
- connectOpts["ca"] = await promises.readFile(tls.caCertPath);
1870
+ connectOpts["ca"] = await promises$1.readFile(tls.caCertPath);
1871
1871
  } catch {
1872
1872
  }
1873
1873
  }
1874
1874
  if (tls.clientCertPath) {
1875
1875
  try {
1876
- connectOpts["cert"] = await promises.readFile(tls.clientCertPath);
1876
+ connectOpts["cert"] = await promises$1.readFile(tls.clientCertPath);
1877
1877
  } catch {
1878
1878
  }
1879
1879
  }
1880
1880
  if (tls.clientKeyPath) {
1881
1881
  try {
1882
- connectOpts["key"] = await promises.readFile(tls.clientKeyPath);
1882
+ connectOpts["key"] = await promises$1.readFile(tls.clientKeyPath);
1883
1883
  } catch {
1884
1884
  }
1885
1885
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const handle = require("./handle-CL-nWtYA.js");
3
- const https = require("https");
4
- const http = require("http");
3
+ const https = require("node:https");
4
+ const http = require("node:http");
5
5
  const xmldom = require("@xmldom/xmldom");
6
6
  function fetchUrl(url, headers = {}) {
7
7
  return new Promise((resolveP, rejectP) => {
@@ -26,9 +26,7 @@ function isElement(node) {
26
26
  }
27
27
  function nodeListToArray(list) {
28
28
  if (!list || typeof list.length !== "number") return [];
29
- const out = [];
30
- for (let i = 0; i < list.length; i++) out.push(list[i]);
31
- return out;
29
+ return Array.from(list);
32
30
  }
33
31
  function children(node) {
34
32
  return nodeListToArray(node.childNodes).filter(isElement);
@@ -113,7 +111,7 @@ function indent(level) {
113
111
  }
114
112
  function renderParams(params, level) {
115
113
  return params.map((p) => {
116
- if (p.children && p.children.length) {
114
+ if (p.children?.length) {
117
115
  return `${indent(level)}<tns:${p.name}>
118
116
  ${renderParams(p.children, level + 1)}
119
117
  ${indent(level)}</tns:${p.name}>`;
@@ -246,7 +244,7 @@ function parseWsdl(wsdlText) {
246
244
  const soapActionByName = {};
247
245
  const blockRx = /<(?:wsdl:)?operation\s+name\s*=\s*["']([^"']+)["'][^>]*>([\s\S]*?)<\/(?:wsdl:)?operation>/g;
248
246
  while ((m = blockRx.exec(wsdlText)) !== null) {
249
- const sa = m[2].match(/soapAction\s*=\s*["']([^"']*)["']/);
247
+ const sa = /soapAction\s*=\s*["']([^"']*)["']/.exec(m[2]);
250
248
  if (sa) soapActionByName[m[1]] = sa[1];
251
249
  }
252
250
  for (const name of seen) {
@@ -283,7 +281,7 @@ const ct = (metadata && metadata.soapVersion === '1.2')
283
281
  : 'text/xml; charset=utf-8';
284
282
 
285
283
  const headers = request.headers || {};
286
- const sa = String(headers['soapaction'] || headers['SOAPAction'] || '').replace(/"/g, '');
284
+ const sa = String(headers['soapaction'] || headers['SOAPAction'] || '').replaceAll('"', '');
287
285
  const body = request.body || '';
288
286
 
289
287
  let opName = null;
@@ -315,7 +313,7 @@ function registerSoapHandlers(ipc) {
315
313
  handle.handleIpc(ipc, handle.IPC.wsdl.import, async (_event, opts) => {
316
314
  const { validateWsdlImport } = await Promise.resolve().then(() => require("./ipc-validate-sqUFqRmE.js"));
317
315
  validateWsdlImport(opts);
318
- const { importWsdl } = await Promise.resolve().then(() => require("./import-DdXhO56X.js"));
316
+ const { importWsdl } = await Promise.resolve().then(() => require("./import-DYssQzex.js"));
319
317
  const wsdlText = opts.xml ?? (opts.url ? await fetchUrl(opts.url) : "");
320
318
  if (!wsdlText) throw new Error("wsdl:import requires either `url` or `xml`");
321
319
  return importWsdl(wsdlText, { name: opts.name, existingMockPorts: opts.existingMockPorts });
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const promises = require("fs/promises");
3
+ const promises = require("node:fs/promises");
4
4
  const jsYaml = require("js-yaml");
5
5
  const undici = require("undici");
6
- const coverage = require("./chunks/coverage-C54mZEh_.js");
7
- const cliCommon = require("./chunks/cli-common-vASoDfQH.js");
8
- require("path");
9
- require("./chunks/data-files-Br2h3Dt2.js");
10
- require("crypto");
11
- const HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
6
+ const coverage = require("./chunks/coverage-C0U4QM83.js");
7
+ const cliCommon = require("./chunks/cli-common-Cq_cphpZ.js");
8
+ require("node:path");
9
+ require("./chunks/data-files-BYqhsoPe.js");
10
+ require("node:crypto");
11
+ const HTTP_METHODS = /* @__PURE__ */ new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
12
12
  function resolveRef(spec, ref) {
13
13
  const parts = ref.replace(/^#\//, "").split("/");
14
- return parts.reduce((o, k) => o?.[decodeURIComponent(k.replace(/~1/g, "/").replace(/~0/g, "~"))], spec);
14
+ return parts.reduce((o, k) => o?.[decodeURIComponent(k.replaceAll("~1", "/").replaceAll("~0", "~"))], spec);
15
15
  }
16
16
  function deref(spec, node, depth = 0, seen = /* @__PURE__ */ new Set()) {
17
17
  if (!node || typeof node !== "object" || depth > 8) return node;
@@ -52,7 +52,7 @@ function requestSchema(spec, op) {
52
52
  }
53
53
  function successResponseSchema(spec, op) {
54
54
  const responses = op?.responses ?? {};
55
- const code = Object.keys(responses).filter((c) => /^2\d\d$/.test(c)).sort()[0];
55
+ const code = Object.keys(responses).filter((c) => /^2\d\d$/.test(c)).sort((a, b) => a.localeCompare(b))[0];
56
56
  return code ? deref(spec, responses[code])?.content?.["application/json"]?.schema : void 0;
57
57
  }
58
58
  function paramRequired(spec, pathItem, op) {
@@ -66,7 +66,7 @@ function operations(spec) {
66
66
  for (const [path, item] of Object.entries(spec?.paths ?? {})) {
67
67
  if (!item || typeof item !== "object") continue;
68
68
  for (const [method, op] of Object.entries(item)) {
69
- if (!HTTP_METHODS.includes(method.toLowerCase())) continue;
69
+ if (!HTTP_METHODS.has(method.toLowerCase())) continue;
70
70
  map.set(`${method.toUpperCase()} ${path}`, { method: method.toUpperCase(), path, pathItem: item, op });
71
71
  }
72
72
  }
@@ -1,31 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const promises = require("fs/promises");
4
- const path = require("path");
5
- const brokerClient = require("./chunks/broker-client-WEymdqAK.js");
6
- const escape = require("./chunks/escape-BwPM4Tf6.js");
7
- const crypto = require("crypto");
3
+ const promises = require("node:fs/promises");
4
+ const path = require("node:path");
5
+ const brokerClient = require("./chunks/broker-client-CvRuiX3o.js");
6
+ const escape = require("./chunks/escape-DDVAlOvZ.js");
7
+ const crypto = require("node:crypto");
8
8
  const undici = require("undici");
9
- const os = require("os");
10
- const cliCommon = require("./chunks/cli-common-vASoDfQH.js");
11
- const child_process = require("child_process");
9
+ const os = require("node:os");
10
+ const cliCommon = require("./chunks/cli-common-Cq_cphpZ.js");
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-DAFA6Fap.js");
14
+ require("./chunks/request-exec-BRmVweue.js");
15
+ require("fs/promises");
15
16
  require("tls");
16
17
  require("./chunks/handle-CL-nWtYA.js");
17
18
  require("node:fs");
18
- require("node:os");
19
- require("node:path");
20
- require("node:crypto");
21
19
  require("dayjs");
22
- require("vm");
20
+ require("node:vm");
23
21
  require("tv4");
24
22
  require("jsonpath-plus");
25
23
  require("@xmldom/xmldom");
26
- require("http");
24
+ require("node:http");
27
25
  require("ajv");
28
- require("./chunks/data-files-Br2h3Dt2.js");
26
+ require("./chunks/data-files-BYqhsoPe.js");
29
27
  function caseXml(r) {
30
28
  const name = escape.escapeXml(`${r.method} ${r.requestName}`);
31
29
  const time = ((r.durationMs ?? 0) / 1e3).toFixed(3);
@@ -99,7 +97,7 @@ function applyPendingSemantics(report, requests, store, now) {
99
97
  }
100
98
  const WEBHOOKS_FILE = "contracts/webhooks.json";
101
99
  function substituteEnv(value, env) {
102
- return value.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_, name) => env[name] ?? "");
100
+ return value.replaceAll(/\$([A-Z_][A-Z0-9_]*)/g, (_, name) => env[name] ?? "");
103
101
  }
104
102
  async function loadWebhookConfig(dir) {
105
103
  let raw;
@@ -137,7 +135,7 @@ function resolveVersion(override) {
137
135
  const env = process.env["GITHUB_SHA"] || process.env["CI_COMMIT_SHA"] || process.env["GIT_COMMIT"] || process.env["CIRCLE_SHA1"] || process.env["BUILD_SOURCEVERSION"] || process.env["BITBUCKET_COMMIT"];
138
136
  if (env) return env.trim();
139
137
  try {
140
- return child_process.execSync("git rev-parse HEAD", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
138
+ return node_child_process.execSync("git rev-parse HEAD", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
141
139
  } catch {
142
140
  throw new Error("Could not resolve a version. Pass --version <sha>, or run inside a git repo / CI.");
143
141
  }
@@ -147,10 +145,10 @@ function parseSelfVerification(text, path2) {
147
145
  const isXml = path2.toLowerCase().endsWith(".xml") || trimmed.startsWith("<");
148
146
  if (isXml) {
149
147
  const num = (tag, name) => {
150
- const m = tag.match(new RegExp(`\\b${name}="(\\d+(?:\\.\\d+)?)"`));
148
+ const m = new RegExp(`\\b${name}="(\\d+(?:\\.\\d+)?)"`).exec(tag);
151
149
  return m ? Math.round(Number(m[1])) : 0;
152
150
  };
153
- const agg = text.match(/<testsuites\b[^>]*>/);
151
+ const agg = /<testsuites\b[^>]*>/.exec(text);
154
152
  let tests = 0, failures = 0, errors = 0;
155
153
  if (agg) {
156
154
  tests = num(agg[0], "tests");
@@ -789,7 +787,7 @@ async function cmdCheck(args) {
789
787
  for (const c of checks.filter((c2) => !c2.passed)) {
790
788
  console.error(` ${c.interaction}`);
791
789
  for (const m of c.mismatches ?? []) console.error(` ${m.location}: consumer requires ${m.consumer}, provider ${m.provider}`);
792
- if ((!c.mismatches || !c.mismatches.length) && c.error) console.error(` ${c.error}`);
790
+ if (!c.mismatches?.length && c.error) console.error(` ${c.error}`);
793
791
  }
794
792
  process.exit(1);
795
793
  }
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const promises = require("fs/promises");
3
+ const promises = require("node:fs/promises");
4
4
  const jsYaml = require("js-yaml");
5
5
  const undici = require("undici");
6
- const coverage = require("./chunks/coverage-C54mZEh_.js");
7
- const cliCommon = require("./chunks/cli-common-vASoDfQH.js");
8
- require("path");
9
- require("./chunks/data-files-Br2h3Dt2.js");
10
- require("crypto");
6
+ const coverage = require("./chunks/coverage-C0U4QM83.js");
7
+ const cliCommon = require("./chunks/cli-common-Cq_cphpZ.js");
8
+ require("node:path");
9
+ require("./chunks/data-files-BYqhsoPe.js");
10
+ require("node:crypto");
11
11
  async function loadObservations(path) {
12
12
  const report = JSON.parse(await promises.readFile(path, "utf8"));
13
13
  const out = [];
@@ -87,7 +87,7 @@ function toHtml(report) {
87
87
  <td><code>${op.path}</code></td>
88
88
  <td>${op.declaredStatuses.length ? `${op.coveredStatuses.length}/${op.declaredStatuses.length}` : "-"}</td>
89
89
  <td>${op.tested ? op.hasNegativeTest ? "yes" : '<span class="warn">missing</span>' : "-"}</td>
90
- <td>${op.requests.map((r) => r.replace(/</g, "&lt;")).join("<br>") || "-"}</td>
90
+ <td>${op.requests.map((r) => r.replaceAll("<", "&lt;")).join("<br>") || "-"}</td>
91
91
  </tr>`).join("");
92
92
  const title = (report.spec.title ?? "API") + (report.spec.version ? ` v${report.spec.version}` : "");
93
93
  return `<!doctype html><meta charset="utf-8"><title>${title} coverage</title>
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const promises = require("fs/promises");
3
+ const promises = require("node:fs/promises");
4
4
  const jsYaml = require("js-yaml");
5
5
  const undici = require("undici");
6
6
  const uuid = require("uuid");
7
- const coverage = require("./chunks/coverage-C54mZEh_.js");
8
- const cliCommon = require("./chunks/cli-common-vASoDfQH.js");
9
- require("path");
10
- require("./chunks/data-files-Br2h3Dt2.js");
11
- require("crypto");
12
- const HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
7
+ const coverage = require("./chunks/coverage-C0U4QM83.js");
8
+ const cliCommon = require("./chunks/cli-common-Cq_cphpZ.js");
9
+ require("node:path");
10
+ require("./chunks/data-files-BYqhsoPe.js");
11
+ require("node:crypto");
12
+ const HTTP_METHODS = /* @__PURE__ */ new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
13
13
  function resolveRef(spec, ref) {
14
14
  const parts = ref.replace(/^#\//, "").split("/");
15
- return parts.reduce((o, k) => o?.[decodeURIComponent(k.replace(/~1/g, "/").replace(/~0/g, "~"))], spec);
15
+ return parts.reduce((o, k) => o?.[decodeURIComponent(k.replaceAll("~1", "/").replaceAll("~0", "~"))], spec);
16
16
  }
17
17
  function deref(spec, node, depth = 0, seen = /* @__PURE__ */ new Set()) {
18
18
  if (!node || typeof node !== "object" || depth > 8) return node;
@@ -185,7 +185,7 @@ function generateTests(spec, options = {}) {
185
185
  for (const [path, item] of Object.entries(doc.paths ?? {})) {
186
186
  if (!item || typeof item !== "object") continue;
187
187
  for (const [method, op] of Object.entries(item)) {
188
- if (!HTTP_METHODS.includes(method.toLowerCase())) continue;
188
+ if (!HTTP_METHODS.has(method.toLowerCase())) continue;
189
189
  if (!op || typeof op !== "object") continue;
190
190
  if (opts.only.size && !opts.only.has(`${method.toUpperCase()} ${path}`)) continue;
191
191
  out.push(...generateForOperation(doc, method.toUpperCase(), path, item, op, opts));