@machina.ai/openapi-contract-tester 2.1.0

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 (431) hide show
  1. package/.env.example +91 -0
  2. package/README.md +472 -0
  3. package/dist/ai-engine/assertion-generator.d.ts +48 -0
  4. package/dist/ai-engine/assertion-generator.d.ts.map +1 -0
  5. package/dist/ai-engine/assertion-generator.js +166 -0
  6. package/dist/ai-engine/assertion-generator.js.map +1 -0
  7. package/dist/ai-engine/context-data-generator.d.ts +38 -0
  8. package/dist/ai-engine/context-data-generator.d.ts.map +1 -0
  9. package/dist/ai-engine/context-data-generator.js +146 -0
  10. package/dist/ai-engine/context-data-generator.js.map +1 -0
  11. package/dist/ai-engine/dataflow-detector.d.ts +53 -0
  12. package/dist/ai-engine/dataflow-detector.d.ts.map +1 -0
  13. package/dist/ai-engine/dataflow-detector.js +217 -0
  14. package/dist/ai-engine/dataflow-detector.js.map +1 -0
  15. package/dist/ai-engine/dependency-detector.d.ts +52 -0
  16. package/dist/ai-engine/dependency-detector.d.ts.map +1 -0
  17. package/dist/ai-engine/dependency-detector.js +241 -0
  18. package/dist/ai-engine/dependency-detector.js.map +1 -0
  19. package/dist/ai-engine/edge-case-suggester.d.ts +63 -0
  20. package/dist/ai-engine/edge-case-suggester.d.ts.map +1 -0
  21. package/dist/ai-engine/edge-case-suggester.js +177 -0
  22. package/dist/ai-engine/edge-case-suggester.js.map +1 -0
  23. package/dist/ai-engine/index.d.ts +13 -0
  24. package/dist/ai-engine/index.d.ts.map +1 -0
  25. package/dist/ai-engine/index.js +13 -0
  26. package/dist/ai-engine/index.js.map +1 -0
  27. package/dist/analyzers/ai-failure-analyzer.d.ts +41 -0
  28. package/dist/analyzers/ai-failure-analyzer.d.ts.map +1 -0
  29. package/dist/analyzers/ai-failure-analyzer.js +220 -0
  30. package/dist/analyzers/ai-failure-analyzer.js.map +1 -0
  31. package/dist/analyzers/comparison-utils.d.ts +31 -0
  32. package/dist/analyzers/comparison-utils.d.ts.map +1 -0
  33. package/dist/analyzers/comparison-utils.js +85 -0
  34. package/dist/analyzers/comparison-utils.js.map +1 -0
  35. package/dist/analyzers/context-analyzer.d.ts +49 -0
  36. package/dist/analyzers/context-analyzer.d.ts.map +1 -0
  37. package/dist/analyzers/context-analyzer.js +292 -0
  38. package/dist/analyzers/context-analyzer.js.map +1 -0
  39. package/dist/analyzers/dependency-analyzer.d.ts +44 -0
  40. package/dist/analyzers/dependency-analyzer.d.ts.map +1 -0
  41. package/dist/analyzers/dependency-analyzer.js +313 -0
  42. package/dist/analyzers/dependency-analyzer.js.map +1 -0
  43. package/dist/analyzers/failure-analyzer.d.ts +122 -0
  44. package/dist/analyzers/failure-analyzer.d.ts.map +1 -0
  45. package/dist/analyzers/failure-analyzer.js +140 -0
  46. package/dist/analyzers/failure-analyzer.js.map +1 -0
  47. package/dist/analyzers/failure-detectors/index.d.ts +33 -0
  48. package/dist/analyzers/failure-detectors/index.d.ts.map +1 -0
  49. package/dist/analyzers/failure-detectors/index.js +164 -0
  50. package/dist/analyzers/failure-detectors/index.js.map +1 -0
  51. package/dist/analyzers/failure-discrepancy-correlator.d.ts +111 -0
  52. package/dist/analyzers/failure-discrepancy-correlator.d.ts.map +1 -0
  53. package/dist/analyzers/failure-discrepancy-correlator.js +202 -0
  54. package/dist/analyzers/failure-discrepancy-correlator.js.map +1 -0
  55. package/dist/analyzers/index.d.ts +10 -0
  56. package/dist/analyzers/index.d.ts.map +1 -0
  57. package/dist/analyzers/index.js +10 -0
  58. package/dist/analyzers/index.js.map +1 -0
  59. package/dist/analyzers/semantic-matcher.d.ts +123 -0
  60. package/dist/analyzers/semantic-matcher.d.ts.map +1 -0
  61. package/dist/analyzers/semantic-matcher.js +297 -0
  62. package/dist/analyzers/semantic-matcher.js.map +1 -0
  63. package/dist/analyzers/source-comparator.d.ts +177 -0
  64. package/dist/analyzers/source-comparator.d.ts.map +1 -0
  65. package/dist/analyzers/source-comparator.js +225 -0
  66. package/dist/analyzers/source-comparator.js.map +1 -0
  67. package/dist/business-rules/business-rules-analyzer.d.ts +44 -0
  68. package/dist/business-rules/business-rules-analyzer.d.ts.map +1 -0
  69. package/dist/business-rules/business-rules-analyzer.js +363 -0
  70. package/dist/business-rules/business-rules-analyzer.js.map +1 -0
  71. package/dist/business-rules/business-rules-generator.d.ts +78 -0
  72. package/dist/business-rules/business-rules-generator.d.ts.map +1 -0
  73. package/dist/business-rules/business-rules-generator.js +357 -0
  74. package/dist/business-rules/business-rules-generator.js.map +1 -0
  75. package/dist/business-rules/extractors/rule-extractors.d.ts +50 -0
  76. package/dist/business-rules/extractors/rule-extractors.d.ts.map +1 -0
  77. package/dist/business-rules/extractors/rule-extractors.js +189 -0
  78. package/dist/business-rules/extractors/rule-extractors.js.map +1 -0
  79. package/dist/business-rules/value-generators.d.ts +70 -0
  80. package/dist/business-rules/value-generators.d.ts.map +1 -0
  81. package/dist/business-rules/value-generators.js +142 -0
  82. package/dist/business-rules/value-generators.js.map +1 -0
  83. package/dist/executor/auth-providers/auth-header-builder.d.ts +16 -0
  84. package/dist/executor/auth-providers/auth-header-builder.d.ts.map +1 -0
  85. package/dist/executor/auth-providers/auth-header-builder.js +47 -0
  86. package/dist/executor/auth-providers/auth-header-builder.js.map +1 -0
  87. package/dist/executor/auth-providers/oauth2-provider.d.ts +19 -0
  88. package/dist/executor/auth-providers/oauth2-provider.d.ts.map +1 -0
  89. package/dist/executor/auth-providers/oauth2-provider.js +114 -0
  90. package/dist/executor/auth-providers/oauth2-provider.js.map +1 -0
  91. package/dist/executor/http-client.d.ts +133 -0
  92. package/dist/executor/http-client.d.ts.map +1 -0
  93. package/dist/executor/http-client.js +172 -0
  94. package/dist/executor/http-client.js.map +1 -0
  95. package/dist/executor/http-request-builder.d.ts +69 -0
  96. package/dist/executor/http-request-builder.d.ts.map +1 -0
  97. package/dist/executor/http-request-builder.js +140 -0
  98. package/dist/executor/http-request-builder.js.map +1 -0
  99. package/dist/executor/http-response-parser.d.ts +28 -0
  100. package/dist/executor/http-response-parser.d.ts.map +1 -0
  101. package/dist/executor/http-response-parser.js +74 -0
  102. package/dist/executor/http-response-parser.js.map +1 -0
  103. package/dist/executor/response-handler.d.ts +66 -0
  104. package/dist/executor/response-handler.d.ts.map +1 -0
  105. package/dist/executor/response-handler.js +135 -0
  106. package/dist/executor/response-handler.js.map +1 -0
  107. package/dist/executor/result-processor.d.ts +27 -0
  108. package/dist/executor/result-processor.d.ts.map +1 -0
  109. package/dist/executor/result-processor.js +140 -0
  110. package/dist/executor/result-processor.js.map +1 -0
  111. package/dist/executor/result-utils.d.ts +21 -0
  112. package/dist/executor/result-utils.d.ts.map +1 -0
  113. package/dist/executor/result-utils.js +29 -0
  114. package/dist/executor/result-utils.js.map +1 -0
  115. package/dist/executor/test-executor.d.ts +49 -0
  116. package/dist/executor/test-executor.d.ts.map +1 -0
  117. package/dist/executor/test-executor.js +226 -0
  118. package/dist/executor/test-executor.js.map +1 -0
  119. package/dist/executor/test-runner.d.ts +85 -0
  120. package/dist/executor/test-runner.d.ts.map +1 -0
  121. package/dist/executor/test-runner.js +177 -0
  122. package/dist/executor/test-runner.js.map +1 -0
  123. package/dist/executor/token-detector/index.d.ts +7 -0
  124. package/dist/executor/token-detector/index.d.ts.map +1 -0
  125. package/dist/executor/token-detector/index.js +7 -0
  126. package/dist/executor/token-detector/index.js.map +1 -0
  127. package/dist/executor/token-detector/token-detector.d.ts +64 -0
  128. package/dist/executor/token-detector/token-detector.d.ts.map +1 -0
  129. package/dist/executor/token-detector/token-detector.js +140 -0
  130. package/dist/executor/token-detector/token-detector.js.map +1 -0
  131. package/dist/generators/business-rule-from-stories-generator.d.ts +30 -0
  132. package/dist/generators/business-rule-from-stories-generator.d.ts.map +1 -0
  133. package/dist/generators/business-rule-from-stories-generator.js +227 -0
  134. package/dist/generators/business-rule-from-stories-generator.js.map +1 -0
  135. package/dist/generators/data/ai-data-generator.d.ts +23 -0
  136. package/dist/generators/data/ai-data-generator.d.ts.map +1 -0
  137. package/dist/generators/data/ai-data-generator.js +41 -0
  138. package/dist/generators/data/ai-data-generator.js.map +1 -0
  139. package/dist/generators/data/base-generator.d.ts +121 -0
  140. package/dist/generators/data/base-generator.d.ts.map +1 -0
  141. package/dist/generators/data/base-generator.js +200 -0
  142. package/dist/generators/data/base-generator.js.map +1 -0
  143. package/dist/generators/data/heuristic-data-generator.d.ts +28 -0
  144. package/dist/generators/data/heuristic-data-generator.d.ts.map +1 -0
  145. package/dist/generators/data/heuristic-data-generator.js +49 -0
  146. package/dist/generators/data/heuristic-data-generator.js.map +1 -0
  147. package/dist/generators/data/index.d.ts +48 -0
  148. package/dist/generators/data/index.d.ts.map +1 -0
  149. package/dist/generators/data/index.js +201 -0
  150. package/dist/generators/data/index.js.map +1 -0
  151. package/dist/generators/data/schema-walker.d.ts +45 -0
  152. package/dist/generators/data/schema-walker.d.ts.map +1 -0
  153. package/dist/generators/data/schema-walker.js +103 -0
  154. package/dist/generators/data/schema-walker.js.map +1 -0
  155. package/dist/generators/data/type-strategies.d.ts +79 -0
  156. package/dist/generators/data/type-strategies.d.ts.map +1 -0
  157. package/dist/generators/data/type-strategies.js +394 -0
  158. package/dist/generators/data/type-strategies.js.map +1 -0
  159. package/dist/generators/data-generator.d.ts +11 -0
  160. package/dist/generators/data-generator.d.ts.map +1 -0
  161. package/dist/generators/data-generator.js +11 -0
  162. package/dist/generators/data-generator.js.map +1 -0
  163. package/dist/generators/edge-case-generator.d.ts +55 -0
  164. package/dist/generators/edge-case-generator.d.ts.map +1 -0
  165. package/dist/generators/edge-case-generator.js +327 -0
  166. package/dist/generators/edge-case-generator.js.map +1 -0
  167. package/dist/generators/edge-cases/boundary-analyzer.d.ts +26 -0
  168. package/dist/generators/edge-cases/boundary-analyzer.d.ts.map +1 -0
  169. package/dist/generators/edge-cases/boundary-analyzer.js +95 -0
  170. package/dist/generators/edge-cases/boundary-analyzer.js.map +1 -0
  171. package/dist/generators/error-case-generator.d.ts +11 -0
  172. package/dist/generators/error-case-generator.d.ts.map +1 -0
  173. package/dist/generators/error-case-generator.js +11 -0
  174. package/dist/generators/error-case-generator.js.map +1 -0
  175. package/dist/generators/errors/auth-error-strategy.d.ts +36 -0
  176. package/dist/generators/errors/auth-error-strategy.d.ts.map +1 -0
  177. package/dist/generators/errors/auth-error-strategy.js +118 -0
  178. package/dist/generators/errors/auth-error-strategy.js.map +1 -0
  179. package/dist/generators/errors/business-error-strategy.d.ts +44 -0
  180. package/dist/generators/errors/business-error-strategy.d.ts.map +1 -0
  181. package/dist/generators/errors/business-error-strategy.js +152 -0
  182. package/dist/generators/errors/business-error-strategy.js.map +1 -0
  183. package/dist/generators/errors/error-strategy-factory.d.ts +27 -0
  184. package/dist/generators/errors/error-strategy-factory.d.ts.map +1 -0
  185. package/dist/generators/errors/error-strategy-factory.js +47 -0
  186. package/dist/generators/errors/error-strategy-factory.js.map +1 -0
  187. package/dist/generators/errors/error-strategy.d.ts +62 -0
  188. package/dist/generators/errors/error-strategy.d.ts.map +1 -0
  189. package/dist/generators/errors/error-strategy.js +69 -0
  190. package/dist/generators/errors/error-strategy.js.map +1 -0
  191. package/dist/generators/errors/index.d.ts +23 -0
  192. package/dist/generators/errors/index.d.ts.map +1 -0
  193. package/dist/generators/errors/index.js +73 -0
  194. package/dist/generators/errors/index.js.map +1 -0
  195. package/dist/generators/errors/validation-error-strategy.d.ts +25 -0
  196. package/dist/generators/errors/validation-error-strategy.d.ts.map +1 -0
  197. package/dist/generators/errors/validation-error-strategy.js +214 -0
  198. package/dist/generators/errors/validation-error-strategy.js.map +1 -0
  199. package/dist/generators/happy-path-generator.d.ts +93 -0
  200. package/dist/generators/happy-path-generator.d.ts.map +1 -0
  201. package/dist/generators/happy-path-generator.js +275 -0
  202. package/dist/generators/happy-path-generator.js.map +1 -0
  203. package/dist/generators/test-enricher.d.ts +44 -0
  204. package/dist/generators/test-enricher.d.ts.map +1 -0
  205. package/dist/generators/test-enricher.js +109 -0
  206. package/dist/generators/test-enricher.js.map +1 -0
  207. package/dist/index.d.ts +9 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +14 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/llm/ai-cache.d.ts +123 -0
  212. package/dist/llm/ai-cache.d.ts.map +1 -0
  213. package/dist/llm/ai-cache.js +220 -0
  214. package/dist/llm/ai-cache.js.map +1 -0
  215. package/dist/llm/ai-client.d.ts +92 -0
  216. package/dist/llm/ai-client.d.ts.map +1 -0
  217. package/dist/llm/ai-client.js +386 -0
  218. package/dist/llm/ai-client.js.map +1 -0
  219. package/dist/llm/data-generator-ai.d.ts +84 -0
  220. package/dist/llm/data-generator-ai.d.ts.map +1 -0
  221. package/dist/llm/data-generator-ai.js +284 -0
  222. package/dist/llm/data-generator-ai.js.map +1 -0
  223. package/dist/llm/index.d.ts +7 -0
  224. package/dist/llm/index.d.ts.map +1 -0
  225. package/dist/llm/index.js +7 -0
  226. package/dist/llm/index.js.map +1 -0
  227. package/dist/mcp/handlers/base-handler.d.ts +72 -0
  228. package/dist/mcp/handlers/base-handler.d.ts.map +1 -0
  229. package/dist/mcp/handlers/base-handler.js +86 -0
  230. package/dist/mcp/handlers/base-handler.js.map +1 -0
  231. package/dist/mcp/handlers/compare-sources.d.ts +91 -0
  232. package/dist/mcp/handlers/compare-sources.d.ts.map +1 -0
  233. package/dist/mcp/handlers/compare-sources.js +182 -0
  234. package/dist/mcp/handlers/compare-sources.js.map +1 -0
  235. package/dist/mcp/handlers/export-results.d.ts +53 -0
  236. package/dist/mcp/handlers/export-results.d.ts.map +1 -0
  237. package/dist/mcp/handlers/export-results.js +132 -0
  238. package/dist/mcp/handlers/export-results.js.map +1 -0
  239. package/dist/mcp/handlers/export-to-postman.d.ts +65 -0
  240. package/dist/mcp/handlers/export-to-postman.d.ts.map +1 -0
  241. package/dist/mcp/handlers/export-to-postman.js +128 -0
  242. package/dist/mcp/handlers/export-to-postman.js.map +1 -0
  243. package/dist/mcp/handlers/generate-tests.d.ts +74 -0
  244. package/dist/mcp/handlers/generate-tests.d.ts.map +1 -0
  245. package/dist/mcp/handlers/generate-tests.js +519 -0
  246. package/dist/mcp/handlers/generate-tests.js.map +1 -0
  247. package/dist/mcp/handlers/index.d.ts +13 -0
  248. package/dist/mcp/handlers/index.d.ts.map +1 -0
  249. package/dist/mcp/handlers/index.js +12 -0
  250. package/dist/mcp/handlers/index.js.map +1 -0
  251. package/dist/mcp/handlers/run-tests.d.ts +89 -0
  252. package/dist/mcp/handlers/run-tests.d.ts.map +1 -0
  253. package/dist/mcp/handlers/run-tests.js +233 -0
  254. package/dist/mcp/handlers/run-tests.js.map +1 -0
  255. package/dist/mcp/handlers/types.d.ts +61 -0
  256. package/dist/mcp/handlers/types.d.ts.map +1 -0
  257. package/dist/mcp/handlers/types.js +9 -0
  258. package/dist/mcp/handlers/types.js.map +1 -0
  259. package/dist/mcp/server.d.ts +64 -0
  260. package/dist/mcp/server.d.ts.map +1 -0
  261. package/dist/mcp/server.js +200 -0
  262. package/dist/mcp/server.js.map +1 -0
  263. package/dist/mcp/services/file-service.d.ts +66 -0
  264. package/dist/mcp/services/file-service.d.ts.map +1 -0
  265. package/dist/mcp/services/file-service.js +143 -0
  266. package/dist/mcp/services/file-service.js.map +1 -0
  267. package/dist/mcp/services/llm-service.d.ts +70 -0
  268. package/dist/mcp/services/llm-service.d.ts.map +1 -0
  269. package/dist/mcp/services/llm-service.js +189 -0
  270. package/dist/mcp/services/llm-service.js.map +1 -0
  271. package/dist/mcp/services/postman-service.d.ts +128 -0
  272. package/dist/mcp/services/postman-service.d.ts.map +1 -0
  273. package/dist/mcp/services/postman-service.js +266 -0
  274. package/dist/mcp/services/postman-service.js.map +1 -0
  275. package/dist/mcp/services/report-service.d.ts +81 -0
  276. package/dist/mcp/services/report-service.d.ts.map +1 -0
  277. package/dist/mcp/services/report-service.js +210 -0
  278. package/dist/mcp/services/report-service.js.map +1 -0
  279. package/dist/mcp/services/spec-service.d.ts +58 -0
  280. package/dist/mcp/services/spec-service.d.ts.map +1 -0
  281. package/dist/mcp/services/spec-service.js +140 -0
  282. package/dist/mcp/services/spec-service.js.map +1 -0
  283. package/dist/parsers/endpoint-extractor.d.ts +32 -0
  284. package/dist/parsers/endpoint-extractor.d.ts.map +1 -0
  285. package/dist/parsers/endpoint-extractor.js +160 -0
  286. package/dist/parsers/endpoint-extractor.js.map +1 -0
  287. package/dist/parsers/openapi-parser.d.ts +120 -0
  288. package/dist/parsers/openapi-parser.d.ts.map +1 -0
  289. package/dist/parsers/openapi-parser.js +257 -0
  290. package/dist/parsers/openapi-parser.js.map +1 -0
  291. package/dist/parsers/visitors/auth-visitor.d.ts +28 -0
  292. package/dist/parsers/visitors/auth-visitor.d.ts.map +1 -0
  293. package/dist/parsers/visitors/auth-visitor.js +116 -0
  294. package/dist/parsers/visitors/auth-visitor.js.map +1 -0
  295. package/dist/prd/index.d.ts +10 -0
  296. package/dist/prd/index.d.ts.map +1 -0
  297. package/dist/prd/index.js +10 -0
  298. package/dist/prd/index.js.map +1 -0
  299. package/dist/prd/prd-reader.d.ts +124 -0
  300. package/dist/prd/prd-reader.d.ts.map +1 -0
  301. package/dist/prd/prd-reader.js +308 -0
  302. package/dist/prd/prd-reader.js.map +1 -0
  303. package/dist/prd/prd-storage.d.ts +232 -0
  304. package/dist/prd/prd-storage.d.ts.map +1 -0
  305. package/dist/prd/prd-storage.js +129 -0
  306. package/dist/prd/prd-storage.js.map +1 -0
  307. package/dist/repairers/test-auto-repairer.d.ts +61 -0
  308. package/dist/repairers/test-auto-repairer.d.ts.map +1 -0
  309. package/dist/repairers/test-auto-repairer.js +213 -0
  310. package/dist/repairers/test-auto-repairer.js.map +1 -0
  311. package/dist/reporters/comparison-report-generator.d.ts +58 -0
  312. package/dist/reporters/comparison-report-generator.d.ts.map +1 -0
  313. package/dist/reporters/comparison-report-generator.js +369 -0
  314. package/dist/reporters/comparison-report-generator.js.map +1 -0
  315. package/dist/reporters/gherkin-formatter.d.ts +34 -0
  316. package/dist/reporters/gherkin-formatter.d.ts.map +1 -0
  317. package/dist/reporters/gherkin-formatter.js +231 -0
  318. package/dist/reporters/gherkin-formatter.js.map +1 -0
  319. package/dist/reporters/html-report-generator.d.ts +174 -0
  320. package/dist/reporters/html-report-generator.d.ts.map +1 -0
  321. package/dist/reporters/html-report-generator.js +194 -0
  322. package/dist/reporters/html-report-generator.js.map +1 -0
  323. package/dist/reporters/report-charts.d.ts +23 -0
  324. package/dist/reporters/report-charts.d.ts.map +1 -0
  325. package/dist/reporters/report-charts.js +182 -0
  326. package/dist/reporters/report-charts.js.map +1 -0
  327. package/dist/reporters/report-sections.d.ts +34 -0
  328. package/dist/reporters/report-sections.d.ts.map +1 -0
  329. package/dist/reporters/report-sections.js +481 -0
  330. package/dist/reporters/report-sections.js.map +1 -0
  331. package/dist/reporters/report-styles.d.ts +12 -0
  332. package/dist/reporters/report-styles.d.ts.map +1 -0
  333. package/dist/reporters/report-styles.js +412 -0
  334. package/dist/reporters/report-styles.js.map +1 -0
  335. package/dist/reporters/report-test-details.d.ts +56 -0
  336. package/dist/reporters/report-test-details.d.ts.map +1 -0
  337. package/dist/reporters/report-test-details.js +328 -0
  338. package/dist/reporters/report-test-details.js.map +1 -0
  339. package/dist/reporters/report-utils.d.ts +40 -0
  340. package/dist/reporters/report-utils.d.ts.map +1 -0
  341. package/dist/reporters/report-utils.js +163 -0
  342. package/dist/reporters/report-utils.js.map +1 -0
  343. package/dist/types/ai-config.d.ts +63 -0
  344. package/dist/types/ai-config.d.ts.map +1 -0
  345. package/dist/types/ai-config.js +79 -0
  346. package/dist/types/ai-config.js.map +1 -0
  347. package/dist/types/business-rules.d.ts +235 -0
  348. package/dist/types/business-rules.d.ts.map +1 -0
  349. package/dist/types/business-rules.js +6 -0
  350. package/dist/types/business-rules.js.map +1 -0
  351. package/dist/types/config.d.ts +106 -0
  352. package/dist/types/config.d.ts.map +1 -0
  353. package/dist/types/config.js +6 -0
  354. package/dist/types/config.js.map +1 -0
  355. package/dist/types/core.d.ts +72 -0
  356. package/dist/types/core.d.ts.map +1 -0
  357. package/dist/types/core.js +6 -0
  358. package/dist/types/core.js.map +1 -0
  359. package/dist/types/index.d.ts +17 -0
  360. package/dist/types/index.d.ts.map +1 -0
  361. package/dist/types/index.js +10 -0
  362. package/dist/types/index.js.map +1 -0
  363. package/dist/types/openapi.d.ts +139 -0
  364. package/dist/types/openapi.d.ts.map +1 -0
  365. package/dist/types/openapi.js +6 -0
  366. package/dist/types/openapi.js.map +1 -0
  367. package/dist/types/pact.d.ts +101 -0
  368. package/dist/types/pact.d.ts.map +1 -0
  369. package/dist/types/pact.js +6 -0
  370. package/dist/types/pact.js.map +1 -0
  371. package/dist/types/reporting.d.ts +93 -0
  372. package/dist/types/reporting.d.ts.map +1 -0
  373. package/dist/types/reporting.js +6 -0
  374. package/dist/types/reporting.js.map +1 -0
  375. package/dist/types/test-case.d.ts +233 -0
  376. package/dist/types/test-case.d.ts.map +1 -0
  377. package/dist/types/test-case.js +6 -0
  378. package/dist/types/test-case.js.map +1 -0
  379. package/dist/types/test-execution.d.ts +80 -0
  380. package/dist/types/test-execution.d.ts.map +1 -0
  381. package/dist/types/test-execution.js +6 -0
  382. package/dist/types/test-execution.js.map +1 -0
  383. package/dist/utils/auth-generator.d.ts +30 -0
  384. package/dist/utils/auth-generator.d.ts.map +1 -0
  385. package/dist/utils/auth-generator.js +68 -0
  386. package/dist/utils/auth-generator.js.map +1 -0
  387. package/dist/utils/config.d.ts +181 -0
  388. package/dist/utils/config.d.ts.map +1 -0
  389. package/dist/utils/config.js +141 -0
  390. package/dist/utils/config.js.map +1 -0
  391. package/dist/utils/coverage-calculator.d.ts +81 -0
  392. package/dist/utils/coverage-calculator.d.ts.map +1 -0
  393. package/dist/utils/coverage-calculator.js +134 -0
  394. package/dist/utils/coverage-calculator.js.map +1 -0
  395. package/dist/utils/data-loader.d.ts +52 -0
  396. package/dist/utils/data-loader.d.ts.map +1 -0
  397. package/dist/utils/data-loader.js +192 -0
  398. package/dist/utils/data-loader.js.map +1 -0
  399. package/dist/utils/errors.d.ts +167 -0
  400. package/dist/utils/errors.d.ts.map +1 -0
  401. package/dist/utils/errors.js +257 -0
  402. package/dist/utils/errors.js.map +1 -0
  403. package/dist/utils/logger.d.ts +220 -0
  404. package/dist/utils/logger.d.ts.map +1 -0
  405. package/dist/utils/logger.js +325 -0
  406. package/dist/utils/logger.js.map +1 -0
  407. package/dist/utils/openapi-discovery.d.ts +31 -0
  408. package/dist/utils/openapi-discovery.d.ts.map +1 -0
  409. package/dist/utils/openapi-discovery.js +322 -0
  410. package/dist/utils/openapi-discovery.js.map +1 -0
  411. package/dist/utils/path-resolver.d.ts +101 -0
  412. package/dist/utils/path-resolver.d.ts.map +1 -0
  413. package/dist/utils/path-resolver.js +167 -0
  414. package/dist/utils/path-resolver.js.map +1 -0
  415. package/dist/utils/resilience.d.ts +181 -0
  416. package/dist/utils/resilience.d.ts.map +1 -0
  417. package/dist/utils/resilience.js +269 -0
  418. package/dist/utils/resilience.js.map +1 -0
  419. package/dist/validators/openapi-validator.d.ts +198 -0
  420. package/dist/validators/openapi-validator.d.ts.map +1 -0
  421. package/dist/validators/openapi-validator.js +349 -0
  422. package/dist/validators/openapi-validator.js.map +1 -0
  423. package/dist/validators/response-matcher.d.ts +84 -0
  424. package/dist/validators/response-matcher.d.ts.map +1 -0
  425. package/dist/validators/response-matcher.js +234 -0
  426. package/dist/validators/response-matcher.js.map +1 -0
  427. package/dist/validators/schema-validator.d.ts +174 -0
  428. package/dist/validators/schema-validator.d.ts.map +1 -0
  429. package/dist/validators/schema-validator.js +340 -0
  430. package/dist/validators/schema-validator.js.map +1 -0
  431. package/package.json +76 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * HTTP Client using Playwright
3
+ *
4
+ * Provides HTTP request/response capabilities using Playwright's APIRequestContext.
5
+ * Supports authentication, custom headers, timeouts, and detailed response capture.
6
+ *
7
+ * @module executor/http-client
8
+ */
9
+ import { request } from '@playwright/test';
10
+ import { TestExecutionError, ErrorCode } from '../utils/errors.js';
11
+ import { createLogger } from '../utils/logger.js';
12
+ import { config } from '../utils/config.js';
13
+ import { acquireOAuth2Token } from './auth-providers/oauth2-provider.js';
14
+ import { getAuthHeaders } from './auth-providers/auth-header-builder.js';
15
+ import { replacePathParams, buildPlaywrightOptions } from './http-request-builder.js';
16
+ import { classifyRequestError, parseResponseBody } from './http-response-parser.js';
17
+ const log = createLogger('http-client');
18
+ /**
19
+ * HTTP Client for making API requests
20
+ *
21
+ * Uses Playwright's APIRequestContext for reliable HTTP operations
22
+ * with built-in retry logic, timeout handling, and response validation.
23
+ */
24
+ export class HttpClient {
25
+ context = null;
26
+ environment;
27
+ /**
28
+ * Creates a new HTTP client instance
29
+ *
30
+ * @param environment - Environment configuration with base URL and auth
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const client = new HttpClient({
35
+ * name: 'local',
36
+ * baseUrl: 'http://localhost:8080',
37
+ * timeout: 5000,
38
+ * auth: { type: 'bearer', token: 'my-token' }
39
+ * });
40
+ *
41
+ * await client.initialize();
42
+ * const response = await client.request('GET', '/users');
43
+ * await client.dispose();
44
+ * ```
45
+ */
46
+ constructor(environment) {
47
+ this.environment = environment;
48
+ }
49
+ /**
50
+ * Initializes the HTTP client and creates the request context.
51
+ * Must be called before making any requests.
52
+ */
53
+ async initialize() {
54
+ if (this.environment.auth?.type === 'oauth2') {
55
+ await acquireOAuth2Token(this.environment.auth);
56
+ }
57
+ const headers = {
58
+ 'Accept': 'application/json, application/xml, text/plain, */*',
59
+ ...this.environment.headers,
60
+ };
61
+ if (this.environment.auth) {
62
+ Object.assign(headers, getAuthHeaders(this.environment.auth));
63
+ }
64
+ const timeout = this.environment.timeout || config.http.timeout;
65
+ log.debug('Initializing HTTP client', {
66
+ baseURL: this.environment.baseUrl,
67
+ timeout,
68
+ authType: this.environment.auth?.type,
69
+ });
70
+ this.context = await request.newContext({
71
+ baseURL: this.environment.baseUrl,
72
+ timeout,
73
+ extraHTTPHeaders: headers,
74
+ });
75
+ }
76
+ /**
77
+ * Makes an HTTP request.
78
+ *
79
+ * @param method - HTTP method (GET, POST, PUT, PATCH, DELETE, etc.)
80
+ * @param path - Request path (can include path parameters)
81
+ * @param options - Request options (body, query params, headers)
82
+ * @returns HTTP response with status, headers, and body
83
+ */
84
+ async request(method, path, options = {}) {
85
+ if (!this.context) {
86
+ throw new TestExecutionError(ErrorCode.HTTP_REQUEST_FAILED, 'HttpClient not initialized', 'HTTP client is not initialized. Please initialize before making requests.', { method, path });
87
+ }
88
+ log.debug('Making HTTP request', { method, path, queryParams: options.queryParams });
89
+ const startTime = Date.now();
90
+ const contentType = options.contentType || 'application/json';
91
+ const requestPath = replacePathParams(path, options.pathParams);
92
+ const requestOptions = buildPlaywrightOptions(options.body, options.queryParams, options.headers, this.environment.auth, contentType, options.requiresAuth, requestPath, method);
93
+ let playwrightResponse;
94
+ try {
95
+ switch (method) {
96
+ case 'GET':
97
+ playwrightResponse = await this.context.get(requestPath, requestOptions);
98
+ break;
99
+ case 'POST':
100
+ playwrightResponse = await this.context.post(requestPath, requestOptions);
101
+ break;
102
+ case 'PUT':
103
+ playwrightResponse = await this.context.put(requestPath, requestOptions);
104
+ break;
105
+ case 'PATCH':
106
+ playwrightResponse = await this.context.patch(requestPath, requestOptions);
107
+ break;
108
+ case 'DELETE':
109
+ playwrightResponse = await this.context.delete(requestPath, requestOptions);
110
+ break;
111
+ case 'HEAD':
112
+ playwrightResponse = await this.context.head(requestPath, requestOptions);
113
+ break;
114
+ case 'OPTIONS':
115
+ playwrightResponse = await this.context.fetch(requestPath, {
116
+ method: 'OPTIONS',
117
+ ...requestOptions,
118
+ });
119
+ break;
120
+ default:
121
+ throw new TestExecutionError(ErrorCode.HTTP_REQUEST_FAILED, `Unsupported HTTP method: ${method}`, `The HTTP method '${method}' is not supported.`, { method, path: requestPath });
122
+ }
123
+ }
124
+ catch (error) {
125
+ throw classifyRequestError(error, method, requestPath, this.environment.baseUrl);
126
+ }
127
+ const responseTime = Date.now() - startTime;
128
+ const status = playwrightResponse.status();
129
+ const statusText = playwrightResponse.statusText();
130
+ const headers = playwrightResponse.headers();
131
+ const body = await parseResponseBody(playwrightResponse);
132
+ log.debug('HTTP request completed', { method, path: requestPath, status, responseTime });
133
+ return { status, statusText, headers, body, responseTime };
134
+ }
135
+ /**
136
+ * Disposes the HTTP client and cleans up resources.
137
+ */
138
+ async dispose() {
139
+ if (this.context) {
140
+ await this.context.dispose();
141
+ this.context = null;
142
+ }
143
+ }
144
+ // ── Convenience shortcuts ──────────────────────────────────────────────────
145
+ async get(path, options) {
146
+ return this.request('GET', path, options);
147
+ }
148
+ async post(path, body, options) {
149
+ return this.request('POST', path, { ...options, body });
150
+ }
151
+ async put(path, body, options) {
152
+ return this.request('PUT', path, { ...options, body });
153
+ }
154
+ async patch(path, body, options) {
155
+ return this.request('PATCH', path, { ...options, body });
156
+ }
157
+ async delete(path, options) {
158
+ return this.request('DELETE', path, options);
159
+ }
160
+ }
161
+ /**
162
+ * Creates and initializes an HTTP client in one step.
163
+ *
164
+ * @param environment - Environment configuration
165
+ * @returns Initialized HTTP client
166
+ */
167
+ export async function createHttpClient(environment) {
168
+ const client = new HttpClient(environment);
169
+ await client.initialize();
170
+ return client;
171
+ }
172
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/executor/http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAqB,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC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I,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAAwB;IAC7D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * HTTP Request Builder
3
+ *
4
+ * Pure functions for constructing Playwright APIRequestContext options from
5
+ * test-case inputs: path-param substitution, body encoding, header assembly.
6
+ *
7
+ * Strategy pattern: buildRequestBody applies the correct encoding strategy
8
+ * based on the OpenAPI-declared content-type.
9
+ *
10
+ * @module executor/http-request-builder
11
+ */
12
+ import type { Environment } from '../types/index.js';
13
+ export interface PlaywrightRequestOptions {
14
+ data?: unknown;
15
+ form?: Record<string, string | number | boolean>;
16
+ params?: Record<string, string | number | boolean>;
17
+ headers?: Record<string, string>;
18
+ }
19
+ /**
20
+ * Replaces `{param}` placeholders in a URL path with concrete values.
21
+ *
22
+ * @param path - URL path potentially containing `{param}` placeholders
23
+ * @param pathParams - Map of parameter names to values
24
+ * @returns Path with all placeholders replaced
25
+ */
26
+ export declare function replacePathParams(path: string, pathParams?: Record<string, string | number>): string;
27
+ /**
28
+ * Encodes the request body according to the content-type.
29
+ *
30
+ * Strategies:
31
+ * - `application/x-www-form-urlencoded` → `form` field (Playwright handles encoding)
32
+ * - `multipart/form-data` → `form` field (Playwright handles boundary)
33
+ * - everything else → `data` field (JSON by default)
34
+ *
35
+ * @param body - Request body value
36
+ * @param contentType - MIME type from OpenAPI spec
37
+ * @param path - Request path (used for debug logging)
38
+ * @param method - HTTP method (used for debug logging)
39
+ * @returns Partial PlaywrightRequestOptions with the body set correctly
40
+ */
41
+ export declare function buildRequestBody(body: unknown, contentType: string, path: string, method: string): Pick<PlaywrightRequestOptions, 'data' | 'form'>;
42
+ /**
43
+ * Merges caller-supplied headers, auth headers, and the Content-Type header
44
+ * into a single record ready for Playwright.
45
+ *
46
+ * Auth headers are only injected when `requiresAuth` is not explicitly false
47
+ * and no Authorization header is already present in `callerHeaders`.
48
+ *
49
+ * @param callerHeaders - Headers from the test case
50
+ * @param auth - Environment auth configuration (may be undefined)
51
+ * @param contentType - MIME type (used to set Content-Type header for non-form bodies)
52
+ * @param hasBody - Whether the request has a body
53
+ * @param requiresAuth - Whether the endpoint requires authentication
54
+ * @returns Merged headers record (may be empty)
55
+ */
56
+ export declare function mergeRequestHeaders(callerHeaders: Record<string, string> | undefined, auth: Environment['auth'], contentType: string, hasBody: boolean, requiresAuth?: boolean): Record<string, string>;
57
+ /**
58
+ * Builds the complete PlaywrightRequestOptions object for a single request.
59
+ *
60
+ * @param body - Optional request body
61
+ * @param queryParams - Optional query string parameters
62
+ * @param callerHeaders - Optional caller-supplied headers
63
+ * @param auth - Environment auth configuration
64
+ * @param contentType - MIME type from OpenAPI spec
65
+ * @param requiresAuth - Whether the endpoint requires authentication
66
+ * @returns Ready-to-use options object for Playwright context methods
67
+ */
68
+ export declare function buildPlaywrightOptions(body: unknown, queryParams: Record<string, string | number | boolean> | undefined, callerHeaders: Record<string, string> | undefined, auth: Environment['auth'], contentType: string, requiresAuth: boolean | undefined, path: string, method: string): PlaywrightRequestOptions;
69
+ //# sourceMappingURL=http-request-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request-builder.d.ts","sourceRoot":"","sources":["../../src/executor/http-request-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjD,MA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TTP Request Builder
3
+ *
4
+ * Pure functions for constructing Playwright APIRequestContext options from
5
+ * test-case inputs: path-param substitution, body encoding, header assembly.
6
+ *
7
+ * Strategy pattern: buildRequestBody applies the correct encoding strategy
8
+ * based on the OpenAPI-declared content-type.
9
+ *
10
+ * @module executor/http-request-builder
11
+ */
12
+ import { createLogger } from '../utils/logger.js';
13
+ import { getAuthHeaders } from './auth-providers/auth-header-builder.js';
14
+ const log = createLogger('http-request-builder');
15
+ /**
16
+ * Replaces `{param}` placeholders in a URL path with concrete values.
17
+ *
18
+ * @param path - URL path potentially containing `{param}` placeholders
19
+ * @param pathParams - Map of parameter names to values
20
+ * @returns Path with all placeholders replaced
21
+ */
22
+ export function replacePathParams(path, pathParams) {
23
+ if (!pathParams)
24
+ return path;
25
+ let result = path;
26
+ for (const [key, value] of Object.entries(pathParams)) {
27
+ // Use a function as the replacement to prevent special $ patterns
28
+ // (e.g. $&, $1) in values from being interpreted by String.replace
29
+ result = result.replace(`{${key}}`, () => String(value));
30
+ }
31
+ return result;
32
+ }
33
+ /**
34
+ * Encodes the request body according to the content-type.
35
+ *
36
+ * Strategies:
37
+ * - `application/x-www-form-urlencoded` → `form` field (Playwright handles encoding)
38
+ * - `multipart/form-data` → `form` field (Playwright handles boundary)
39
+ * - everything else → `data` field (JSON by default)
40
+ *
41
+ * @param body - Request body value
42
+ * @param contentType - MIME type from OpenAPI spec
43
+ * @param path - Request path (used for debug logging)
44
+ * @param method - HTTP method (used for debug logging)
45
+ * @returns Partial PlaywrightRequestOptions with the body set correctly
46
+ */
47
+ export function buildRequestBody(body, contentType, path, method) {
48
+ if (body === undefined)
49
+ return {};
50
+ if (contentType === 'application/x-www-form-urlencoded') {
51
+ if (typeof body === 'string') {
52
+ throw new Error('Form-encoded bodies must be objects, not strings. Received string body with form-urlencoded content type.');
53
+ }
54
+ if (typeof body === 'object' && body !== null) {
55
+ const form = body;
56
+ log.debug('Using form-urlencoded body', { fields: Object.keys(form) });
57
+ return { form };
58
+ }
59
+ throw new Error(`Invalid body type for form-urlencoded: ${typeof body}`);
60
+ }
61
+ if (contentType === 'multipart/form-data') {
62
+ if (typeof body === 'object' && body !== null) {
63
+ const form = body;
64
+ log.debug('Using multipart/form-data body', { fields: Object.keys(form) });
65
+ return { form };
66
+ }
67
+ return { data: body };
68
+ }
69
+ // Default: JSON body
70
+ if (path.includes('/oauth') || path.includes('/auth') || path.includes('/login')) {
71
+ log.info('Request body for auth endpoint', {
72
+ path,
73
+ method,
74
+ contentType,
75
+ body: JSON.stringify(body).substring(0, 200),
76
+ });
77
+ }
78
+ return { data: body };
79
+ }
80
+ /**
81
+ * Merges caller-supplied headers, auth headers, and the Content-Type header
82
+ * into a single record ready for Playwright.
83
+ *
84
+ * Auth headers are only injected when `requiresAuth` is not explicitly false
85
+ * and no Authorization header is already present in `callerHeaders`.
86
+ *
87
+ * @param callerHeaders - Headers from the test case
88
+ * @param auth - Environment auth configuration (may be undefined)
89
+ * @param contentType - MIME type (used to set Content-Type header for non-form bodies)
90
+ * @param hasBody - Whether the request has a body
91
+ * @param requiresAuth - Whether the endpoint requires authentication
92
+ * @returns Merged headers record (may be empty)
93
+ */
94
+ export function mergeRequestHeaders(callerHeaders, auth, contentType, hasBody, requiresAuth) {
95
+ const headers = { ...callerHeaders };
96
+ // Set Content-Type for JSON bodies (Playwright sets it automatically for form)
97
+ if (hasBody &&
98
+ contentType !== 'application/x-www-form-urlencoded' &&
99
+ contentType !== 'multipart/form-data') {
100
+ headers['Content-Type'] = contentType;
101
+ }
102
+ // Inject auth headers if needed
103
+ if (auth && requiresAuth !== false && !headers['Authorization']) {
104
+ Object.assign(headers, getAuthHeaders(auth));
105
+ }
106
+ return headers;
107
+ }
108
+ /**
109
+ * Builds the complete PlaywrightRequestOptions object for a single request.
110
+ *
111
+ * @param body - Optional request body
112
+ * @param queryParams - Optional query string parameters
113
+ * @param callerHeaders - Optional caller-supplied headers
114
+ * @param auth - Environment auth configuration
115
+ * @param contentType - MIME type from OpenAPI spec
116
+ * @param requiresAuth - Whether the endpoint requires authentication
117
+ * @returns Ready-to-use options object for Playwright context methods
118
+ */
119
+ export function buildPlaywrightOptions(body, queryParams, callerHeaders, auth, contentType, requiresAuth, path, method) {
120
+ const opts = {};
121
+ // Encode body
122
+ if (body !== undefined) {
123
+ const encoded = buildRequestBody(body, contentType, path, method);
124
+ if (encoded.form !== undefined)
125
+ opts.form = encoded.form;
126
+ if (encoded.data !== undefined)
127
+ opts.data = encoded.data;
128
+ }
129
+ // Query params
130
+ if (queryParams) {
131
+ opts.params = queryParams;
132
+ }
133
+ // Headers
134
+ const headers = mergeRequestHeaders(callerHeaders, auth, contentType, body !== undefined, requiresAuth);
135
+ if (Object.keys(headers).length > 0) {
136
+ opts.headers = headers;
137
+ }
138
+ return opts;
139
+ }
140
+ //# sourceMappingURL=http-request-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request-builder.js","sourceRoot":"","sources":["../../src/executor/http-request-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGzE,MAAM,GAAG,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;AASjD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,UAA4C;IAE5C,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,kEAAkE;QAClE,mEAAmE;QACnE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,M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,OAAO,CAAC,IAAI,CAAC;QACzD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3D,CAAC;IAED,eAAe;IACf,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IAED,UAAU;IACV,MAAM,OAAO,GAAG,mBAAmB,CACjC,aAAa,EACb,IAAI,EACJ,WAAW,EACX,IAAI,KAAK,SAAS,EAClB,YAAY,CACb,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * HTTP Response Parser
3
+ *
4
+ * Classifies transport-level errors into typed TestExecutionErrors and
5
+ * parses Playwright APIResponse bodies based on Content-Type.
6
+ *
7
+ * @module executor/http-response-parser
8
+ */
9
+ import type { APIResponse } from '@playwright/test';
10
+ import { TestExecutionError } from '../utils/errors.js';
11
+ /**
12
+ * Classifies a caught error from a Playwright request into a TestExecutionError.
13
+ *
14
+ * @param error - The caught error (any type)
15
+ * @param method - HTTP method for context
16
+ * @param path - Request path for context
17
+ * @param baseUrl - Base URL for context
18
+ * @returns A typed TestExecutionError ready to be thrown
19
+ */
20
+ export declare function classifyRequestError(error: unknown, method: string, path: string, baseUrl: string): TestExecutionError;
21
+ /**
22
+ * Parses the body of a Playwright APIResponse based on Content-Type.
23
+ *
24
+ * @param response - The Playwright APIResponse object
25
+ * @returns The parsed body (object, string, or null)
26
+ */
27
+ export declare function parseResponseBody(response: APIResponse): Promise<unknown>;
28
+ //# sourceMappingURL=http-response-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-response-parser.d.ts","sourceRoot":"","sources":["../../src/executor/http-response-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAa,MAAM,oBAAoB,CAAC;AAKnE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,kBAAkB,CAiCpB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB/E"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * HTTP Response Parser
3
+ *
4
+ * Classifies transport-level errors into typed TestExecutionErrors and
5
+ * parses Playwright APIResponse bodies based on Content-Type.
6
+ *
7
+ * @module executor/http-response-parser
8
+ */
9
+ import { TestExecutionError, ErrorCode } from '../utils/errors.js';
10
+ import { createLogger } from '../utils/logger.js';
11
+ const log = createLogger('http-response-parser');
12
+ /**
13
+ * Classifies a caught error from a Playwright request into a TestExecutionError.
14
+ *
15
+ * @param error - The caught error (any type)
16
+ * @param method - HTTP method for context
17
+ * @param path - Request path for context
18
+ * @param baseUrl - Base URL for context
19
+ * @returns A typed TestExecutionError ready to be thrown
20
+ */
21
+ export function classifyRequestError(error, method, path, baseUrl) {
22
+ const errorMessage = error instanceof Error ? error.message : String(error);
23
+ const lowerMessage = errorMessage.toLowerCase();
24
+ let errorCode = ErrorCode.HTTP_REQUEST_FAILED;
25
+ let userMessage = 'HTTP request failed. Please check your connection and try again.';
26
+ let retryable = true;
27
+ if (lowerMessage.includes('timeout') || lowerMessage.includes('timed out')) {
28
+ errorCode = ErrorCode.TIMEOUT_ERROR;
29
+ userMessage = 'Request timed out. The server took too long to respond.';
30
+ }
31
+ else if (lowerMessage.includes('network') ||
32
+ lowerMessage.includes('econnrefused') ||
33
+ lowerMessage.includes('enotfound')) {
34
+ errorCode = ErrorCode.NETWORK_ERROR;
35
+ userMessage = 'Network error occurred. Please check your connection and server availability.';
36
+ }
37
+ else if (lowerMessage.includes('401') || lowerMessage.includes('unauthorized')) {
38
+ errorCode = ErrorCode.AUTH_ERROR;
39
+ userMessage = 'Authentication failed. Please check your credentials.';
40
+ retryable = false;
41
+ }
42
+ log.error('HTTP request failed', { method, path, error: errorMessage, errorCode });
43
+ return new TestExecutionError(errorCode, errorMessage, userMessage, { method, path, baseUrl, originalError: errorMessage }, retryable);
44
+ }
45
+ /**
46
+ * Parses the body of a Playwright APIResponse based on Content-Type.
47
+ *
48
+ * @param response - The Playwright APIResponse object
49
+ * @returns The parsed body (object, string, or null)
50
+ */
51
+ export async function parseResponseBody(response) {
52
+ const contentType = response.headers()['content-type'] || '';
53
+ try {
54
+ if (contentType.includes('application/json')) {
55
+ return await response.json();
56
+ }
57
+ if (contentType.includes('text/')) {
58
+ return await response.text();
59
+ }
60
+ // Other content types: buffer → string
61
+ const buffer = await response.body();
62
+ return buffer.toString();
63
+ }
64
+ catch {
65
+ // Fallback: try plain text
66
+ try {
67
+ return await response.text();
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ }
73
+ }
74
+ //# sourceMappingURL=http-response-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-response-parser.js","sourceRoot":"","sources":["../../src/executor/http-response-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,GAAG,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,MAAc,EACd,IAAY,EACZ,OAAe;IAEf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAA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AAC,QAAqB;IAC3D,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAE7D,IAAI,CAAC;QACH,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC7C,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,uCAAuC;QACvC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;QAC3B,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Response Handler
3
+ *
4
+ * Pure functions that operate on a completed HTTP response:
5
+ * - path-based value extraction (dataFlow)
6
+ * - agnostic token auto-detection
7
+ * - dataFlow value extraction
8
+ * - response validation (schema or matcher-based)
9
+ *
10
+ * @module executor/response-handler
11
+ */
12
+ import type { TestCase, ParsedEndpoint } from '../types/index.js';
13
+ export type HttpResponse = {
14
+ status: number;
15
+ body?: unknown;
16
+ headers?: Record<string, string>;
17
+ };
18
+ /**
19
+ * Extracts a value from a response object using a dot-notation path.
20
+ * Path must start with "response" (e.g. "response.body.access_token").
21
+ *
22
+ * @param response - The HTTP response object
23
+ * @param path - Dot-notation path starting with "response"
24
+ * @returns The extracted value, or undefined if not found
25
+ */
26
+ export declare function extractValueFromPath(response: HttpResponse, path: string): unknown;
27
+ /**
28
+ * Attempts to auto-detect an auth token in a successful response.
29
+ * Returns the token value if found, or null if the response is not a
30
+ * successful auth response or no token is detected.
31
+ *
32
+ * @param response - The HTTP response
33
+ * @param testCase - The test case that produced the response
34
+ * @param currentToken - Current auto-detected token (null if none yet)
35
+ * @returns Detected token string, or null if nothing new was found
36
+ */
37
+ export declare function handleTokenDetection(response: HttpResponse, testCase: TestCase, currentToken: string | null): string | null;
38
+ /**
39
+ * Extracts dataFlow values from a successful response and returns them
40
+ * as a plain object to be merged into the shared data context.
41
+ *
42
+ * @param response - The HTTP response
43
+ * @param testDataFlow - DataFlow config entry for this test
44
+ * @param testId - Test ID (for logging)
45
+ * @returns Object with extracted key-value pairs (may be empty)
46
+ */
47
+ export declare function extractDataFlowValues(response: HttpResponse, testDataFlow: {
48
+ extract?: Record<string, string>;
49
+ } | undefined, testId: string): Record<string, unknown>;
50
+ /**
51
+ * Validates the response against the endpoint schema or configured matchers.
52
+ *
53
+ * @param response - The HTTP response
54
+ * @param endpoint - Parsed endpoint definition (may be undefined)
55
+ * @param testCase - The test case
56
+ * @param validateSchemas - Whether schema validation is enabled
57
+ * @param useMatchers - Whether matcher-based validation is enabled
58
+ * @param matchers - Matcher configuration keyed by test ID or "*"
59
+ * @returns Array of schema errors (empty if valid)
60
+ */
61
+ export declare function validateTestResponse(response: HttpResponse, endpoint: ParsedEndpoint | undefined, testCase: TestCase, validateSchemas: boolean, useMatchers: boolean, matchers?: Record<string, Record<string, import('../types/index.js').ResponseMatcher>>): Array<{
62
+ field: string;
63
+ message: string;
64
+ code?: string;
65
+ }>;
66
+ //# sourceMappingURL=response-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-handler.d.ts","sourceRoot":"","sources":["../../src/executor/response-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQlE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;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