callman-core 1.8.6 → 1.8.8

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 (48) hide show
  1. package/dist/contract/contractValidator.d.ts.map +1 -1
  2. package/dist/contract/contractValidator.js +10 -1
  3. package/dist/contract/contractValidator.js.map +1 -1
  4. package/dist/contract/formats.d.ts +8 -0
  5. package/dist/contract/formats.d.ts.map +1 -0
  6. package/dist/contract/formats.js +235 -0
  7. package/dist/contract/formats.js.map +1 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/request/executeRequest.d.ts.map +1 -1
  13. package/dist/request/executeRequest.js +39 -3
  14. package/dist/request/executeRequest.js.map +1 -1
  15. package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts +1 -0
  16. package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts.map +1 -1
  17. package/dist/scenario-runner/adapters/helpers/request-helpers.js +34 -1
  18. package/dist/scenario-runner/adapters/helpers/request-helpers.js.map +1 -1
  19. package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -1
  20. package/dist/scenario-runner/adapters/request-executor.js +2 -0
  21. package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
  22. package/dist/scenario-runner/adapters/types.d.ts +2 -0
  23. package/dist/scenario-runner/adapters/types.d.ts.map +1 -1
  24. package/dist/scenario-runner/types.d.ts +4 -0
  25. package/dist/scenario-runner/types.d.ts.map +1 -1
  26. package/dist/script/types.d.ts +1 -0
  27. package/dist/script/types.d.ts.map +1 -1
  28. package/dist/types/index.d.ts +4 -0
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/dist/utils/xml.d.ts +22 -0
  31. package/dist/utils/xml.d.ts.map +1 -0
  32. package/dist/utils/xml.js +75 -0
  33. package/dist/utils/xml.js.map +1 -0
  34. package/dist-cjs/contract/contractValidator.js +10 -1
  35. package/dist-cjs/contract/contractValidator.js.map +1 -1
  36. package/dist-cjs/contract/formats.js +239 -0
  37. package/dist-cjs/contract/formats.js.map +1 -0
  38. package/dist-cjs/index.js +10 -1
  39. package/dist-cjs/index.js.map +1 -1
  40. package/dist-cjs/request/executeRequest.js +39 -3
  41. package/dist-cjs/request/executeRequest.js.map +1 -1
  42. package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js +36 -2
  43. package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js.map +1 -1
  44. package/dist-cjs/scenario-runner/adapters/request-executor.js +2 -0
  45. package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
  46. package/dist-cjs/utils/xml.js +81 -0
  47. package/dist-cjs/utils/xml.js.map +1 -0
  48. package/package.json +2 -1
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ // Shared XML helpers. We parse XML responses into a plain JS object (the
3
+ // same approach Postman uses for `xml2Json`) so the *entire* existing
4
+ // pipeline — contract validation (contractValidator/pathResolver),
5
+ // context flattening (templateResolver), response-root building — keeps
6
+ // working unchanged on a structured value instead of a raw string.
7
+ //
8
+ // Attributes become `@_`-prefixed keys, element text lands under `#text`
9
+ // when an element has both text and attributes/children, and CDATA is
10
+ // preserved under `#cdata`. JSONPath then addresses everything the same
11
+ // way it does for JSON, e.g. `$.users.user.@_id`.
12
+ //
13
+ // This module is intentionally dependency-light at the call site: it owns
14
+ // the single `XMLParser` configuration so both the core request path and
15
+ // the Electron main-process parser can import an identical setup.
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.parseXml = exports.looksLikeXml = exports.isXmlContentType = exports.XML_PARSER_OPTIONS = void 0;
18
+ const fast_xml_parser_1 = require("fast-xml-parser");
19
+ exports.XML_PARSER_OPTIONS = {
20
+ ignoreAttributes: false,
21
+ attributeNamePrefix: "@_",
22
+ textNodeName: "#text",
23
+ cdataPropName: "#cdata",
24
+ parseTagValue: true,
25
+ parseAttributeValue: true,
26
+ trimValues: true,
27
+ ignoreDeclaration: true,
28
+ ignorePiTags: true,
29
+ // Keep namespace prefixes (e.g. `soap:Body`) so SOAP/namespaced
30
+ // documents address their nodes faithfully via JSONPath.
31
+ removeNSPrefix: false,
32
+ };
33
+ // Matches `application/xml`, `text/xml`, and any `+xml` suffix
34
+ // (`application/soap+xml`, `application/atom+xml`, ...), tolerating a
35
+ // trailing `; charset=...`. Deliberately does NOT match `text/html`.
36
+ const isXmlContentType = (contentType) => {
37
+ if (!contentType) {
38
+ return false;
39
+ }
40
+ const ct = contentType.toLowerCase();
41
+ return (ct.includes("application/xml") ||
42
+ ct.includes("text/xml") ||
43
+ ct.includes("+xml"));
44
+ };
45
+ exports.isXmlContentType = isXmlContentType;
46
+ // Cheap structural sniff for when the content-type header is absent or
47
+ // generic (e.g. `application/octet-stream`). Avoids treating HTML as XML.
48
+ const looksLikeXml = (raw) => {
49
+ const trimmed = raw.trimStart();
50
+ if (!trimmed.startsWith("<")) {
51
+ return false;
52
+ }
53
+ return !/^<!doctype html/i.test(trimmed);
54
+ };
55
+ exports.looksLikeXml = looksLikeXml;
56
+ // Never throws — malformed XML resolves to `{ ok: false }` so callers can
57
+ // gracefully fall back to showing the raw text.
58
+ const parseXml = (raw) => {
59
+ if (!raw || !raw.trim()) {
60
+ return { ok: false };
61
+ }
62
+ // Gate on well-formedness first: fast-xml-parser is lenient and will
63
+ // happily "parse" unclosed/mismatched tags, but a malformed XML
64
+ // response should fall back to raw-text display, not a half-built tree.
65
+ if (fast_xml_parser_1.XMLValidator.validate(raw) !== true) {
66
+ return { ok: false };
67
+ }
68
+ try {
69
+ const parser = new fast_xml_parser_1.XMLParser(exports.XML_PARSER_OPTIONS);
70
+ const value = parser.parse(raw);
71
+ if (value === null || typeof value !== "object" || Object.keys(value).length === 0) {
72
+ return { ok: false };
73
+ }
74
+ return { ok: true, value };
75
+ }
76
+ catch {
77
+ return { ok: false };
78
+ }
79
+ };
80
+ exports.parseXml = parseXml;
81
+ //# sourceMappingURL=xml.js.map
@@ -0,0 +1 @@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AAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AAMF,0EAA0E;AAC1E,gDAAgD;AACzC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAkB,EAAE;IACtD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QACxB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,qEAAqE;IACrE,gEAAgE;IAChE,wEAAwE;IACxE,IAAI,8BAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,0BAAkB,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,QAAQ,YAoBnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "callman-core",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "main": "dist-cjs/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "ajv-formats": "^3.0.1",
30
30
  "axios": "^1.6.0",
31
31
  "crypto-js": "^4.2.0",
32
+ "fast-xml-parser": "^4.5.1",
32
33
  "lodash": "^4.18.1"
33
34
  },
34
35
  "devDependencies": {