@redocly/respect-core 0.0.0-snapshot.1739898268

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 (423) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +25 -0
  3. package/lib/arazzo-schema.d.ts +2385 -0
  4. package/lib/arazzo-schema.d.ts.map +1 -0
  5. package/lib/arazzo-schema.js +372 -0
  6. package/lib/arazzo-schema.js.map +1 -0
  7. package/lib/handlers/generate.d.ts +3 -0
  8. package/lib/handlers/generate.d.ts.map +1 -0
  9. package/lib/handlers/generate.js +18 -0
  10. package/lib/handlers/generate.js.map +1 -0
  11. package/lib/handlers/index.d.ts +3 -0
  12. package/lib/handlers/index.d.ts.map +1 -0
  13. package/lib/handlers/index.js +19 -0
  14. package/lib/handlers/index.js.map +1 -0
  15. package/lib/handlers/run.d.ts +2 -0
  16. package/lib/handlers/run.d.ts.map +1 -0
  17. package/lib/handlers/run.js +67 -0
  18. package/lib/handlers/run.js.map +1 -0
  19. package/lib/index.d.ts +2 -0
  20. package/lib/index.d.ts.map +1 -0
  21. package/lib/index.js +7 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/modules/checks/checks.d.ts +9 -0
  24. package/lib/modules/checks/checks.d.ts.map +1 -0
  25. package/lib/modules/checks/checks.js +12 -0
  26. package/lib/modules/checks/checks.js.map +1 -0
  27. package/lib/modules/checks/index.d.ts +3 -0
  28. package/lib/modules/checks/index.d.ts.map +1 -0
  29. package/lib/modules/checks/index.js +19 -0
  30. package/lib/modules/checks/index.js.map +1 -0
  31. package/lib/modules/checks/severity.d.ts +9 -0
  32. package/lib/modules/checks/severity.d.ts.map +1 -0
  33. package/lib/modules/checks/severity.js +29 -0
  34. package/lib/modules/checks/severity.js.map +1 -0
  35. package/lib/modules/cli-output/calculate-tests-passed.d.ts +3 -0
  36. package/lib/modules/cli-output/calculate-tests-passed.d.ts.map +1 -0
  37. package/lib/modules/cli-output/calculate-tests-passed.js +67 -0
  38. package/lib/modules/cli-output/calculate-tests-passed.js.map +1 -0
  39. package/lib/modules/cli-output/display-checks.d.ts +3 -0
  40. package/lib/modules/cli-output/display-checks.d.ts.map +1 -0
  41. package/lib/modules/cli-output/display-checks.js +86 -0
  42. package/lib/modules/cli-output/display-checks.js.map +1 -0
  43. package/lib/modules/cli-output/display-errors.d.ts +3 -0
  44. package/lib/modules/cli-output/display-errors.d.ts.map +1 -0
  45. package/lib/modules/cli-output/display-errors.js +45 -0
  46. package/lib/modules/cli-output/display-errors.js.map +1 -0
  47. package/lib/modules/cli-output/display-files-summary-table.d.ts +11 -0
  48. package/lib/modules/cli-output/display-files-summary-table.d.ts.map +1 -0
  49. package/lib/modules/cli-output/display-files-summary-table.js +100 -0
  50. package/lib/modules/cli-output/display-files-summary-table.js.map +1 -0
  51. package/lib/modules/cli-output/display-summary.d.ts +7 -0
  52. package/lib/modules/cli-output/display-summary.d.ts.map +1 -0
  53. package/lib/modules/cli-output/display-summary.js +75 -0
  54. package/lib/modules/cli-output/display-summary.js.map +1 -0
  55. package/lib/modules/cli-output/index.d.ts +9 -0
  56. package/lib/modules/cli-output/index.d.ts.map +1 -0
  57. package/lib/modules/cli-output/index.js +25 -0
  58. package/lib/modules/cli-output/index.js.map +1 -0
  59. package/lib/modules/cli-output/json-logs.d.ts +3 -0
  60. package/lib/modules/cli-output/json-logs.d.ts.map +1 -0
  61. package/lib/modules/cli-output/json-logs.js +27 -0
  62. package/lib/modules/cli-output/json-logs.js.map +1 -0
  63. package/lib/modules/cli-output/mask-secrets.d.ts +5 -0
  64. package/lib/modules/cli-output/mask-secrets.d.ts.map +1 -0
  65. package/lib/modules/cli-output/mask-secrets.js +34 -0
  66. package/lib/modules/cli-output/mask-secrets.js.map +1 -0
  67. package/lib/modules/cli-output/verbose-logs.d.ts +3 -0
  68. package/lib/modules/cli-output/verbose-logs.d.ts.map +1 -0
  69. package/lib/modules/cli-output/verbose-logs.js +24 -0
  70. package/lib/modules/cli-output/verbose-logs.js.map +1 -0
  71. package/lib/modules/config-parser/get-value-from-context.d.ts +12 -0
  72. package/lib/modules/config-parser/get-value-from-context.d.ts.map +1 -0
  73. package/lib/modules/config-parser/get-value-from-context.js +183 -0
  74. package/lib/modules/config-parser/get-value-from-context.js.map +1 -0
  75. package/lib/modules/config-parser/handle-request-body-replacements.d.ts +3 -0
  76. package/lib/modules/config-parser/handle-request-body-replacements.d.ts.map +1 -0
  77. package/lib/modules/config-parser/handle-request-body-replacements.js +24 -0
  78. package/lib/modules/config-parser/handle-request-body-replacements.js.map +1 -0
  79. package/lib/modules/config-parser/index.d.ts +8 -0
  80. package/lib/modules/config-parser/index.d.ts.map +1 -0
  81. package/lib/modules/config-parser/index.js +24 -0
  82. package/lib/modules/config-parser/index.js.map +1 -0
  83. package/lib/modules/config-parser/map-header-params-and-cookie-to-object.d.ts +6 -0
  84. package/lib/modules/config-parser/map-header-params-and-cookie-to-object.d.ts.map +1 -0
  85. package/lib/modules/config-parser/map-header-params-and-cookie-to-object.js +22 -0
  86. package/lib/modules/config-parser/map-header-params-and-cookie-to-object.js.map +1 -0
  87. package/lib/modules/config-parser/parse-parameters.d.ts +10 -0
  88. package/lib/modules/config-parser/parse-parameters.d.ts.map +1 -0
  89. package/lib/modules/config-parser/parse-parameters.js +48 -0
  90. package/lib/modules/config-parser/parse-parameters.js.map +1 -0
  91. package/lib/modules/config-parser/parse-request-body.d.ts +8 -0
  92. package/lib/modules/config-parser/parse-request-body.d.ts.map +1 -0
  93. package/lib/modules/config-parser/parse-request-body.js +149 -0
  94. package/lib/modules/config-parser/parse-request-body.js.map +1 -0
  95. package/lib/modules/config-parser/resolve-reusable-component.d.ts +3 -0
  96. package/lib/modules/config-parser/resolve-reusable-component.d.ts.map +1 -0
  97. package/lib/modules/config-parser/resolve-reusable-component.js +8 -0
  98. package/lib/modules/config-parser/resolve-reusable-component.js.map +1 -0
  99. package/lib/modules/config-parser/resolve-reusable-object-reference.d.ts +5 -0
  100. package/lib/modules/config-parser/resolve-reusable-object-reference.d.ts.map +1 -0
  101. package/lib/modules/config-parser/resolve-reusable-object-reference.js +20 -0
  102. package/lib/modules/config-parser/resolve-reusable-object-reference.js.map +1 -0
  103. package/lib/modules/description-parser/bundle-openapi.d.ts +2 -0
  104. package/lib/modules/description-parser/bundle-openapi.d.ts.map +1 -0
  105. package/lib/modules/description-parser/bundle-openapi.js +41 -0
  106. package/lib/modules/description-parser/bundle-openapi.js.map +1 -0
  107. package/lib/modules/description-parser/extract-first-example.d.ts +2 -0
  108. package/lib/modules/description-parser/extract-first-example.d.ts.map +1 -0
  109. package/lib/modules/description-parser/extract-first-example.js +10 -0
  110. package/lib/modules/description-parser/extract-first-example.js.map +1 -0
  111. package/lib/modules/description-parser/get-operation-by-id.d.ts +3 -0
  112. package/lib/modules/description-parser/get-operation-by-id.d.ts.map +1 -0
  113. package/lib/modules/description-parser/get-operation-by-id.js +56 -0
  114. package/lib/modules/description-parser/get-operation-by-id.js.map +1 -0
  115. package/lib/modules/description-parser/get-operation-by-path.d.ts +7 -0
  116. package/lib/modules/description-parser/get-operation-by-path.d.ts.map +1 -0
  117. package/lib/modules/description-parser/get-operation-by-path.js +44 -0
  118. package/lib/modules/description-parser/get-operation-by-path.js.map +1 -0
  119. package/lib/modules/description-parser/get-operation-from-description.d.ts +18 -0
  120. package/lib/modules/description-parser/get-operation-from-description.d.ts.map +1 -0
  121. package/lib/modules/description-parser/get-operation-from-description.js +26 -0
  122. package/lib/modules/description-parser/get-operation-from-description.js.map +1 -0
  123. package/lib/modules/description-parser/get-request-body-schema.d.ts +3 -0
  124. package/lib/modules/description-parser/get-request-body-schema.d.ts.map +1 -0
  125. package/lib/modules/description-parser/get-request-body-schema.js +12 -0
  126. package/lib/modules/description-parser/get-request-body-schema.js.map +1 -0
  127. package/lib/modules/description-parser/get-request-data-from-openapi.d.ts +9 -0
  128. package/lib/modules/description-parser/get-request-data-from-openapi.d.ts.map +1 -0
  129. package/lib/modules/description-parser/get-request-data-from-openapi.js +63 -0
  130. package/lib/modules/description-parser/get-request-data-from-openapi.js.map +1 -0
  131. package/lib/modules/description-parser/get-response-schema.d.ts +6 -0
  132. package/lib/modules/description-parser/get-response-schema.d.ts.map +1 -0
  133. package/lib/modules/description-parser/get-response-schema.js +10 -0
  134. package/lib/modules/description-parser/get-response-schema.js.map +1 -0
  135. package/lib/modules/description-parser/index.d.ts +10 -0
  136. package/lib/modules/description-parser/index.d.ts.map +1 -0
  137. package/lib/modules/description-parser/index.js +26 -0
  138. package/lib/modules/description-parser/index.js.map +1 -0
  139. package/lib/modules/description-parser/remove-write-only-properties.d.ts +3 -0
  140. package/lib/modules/description-parser/remove-write-only-properties.d.ts.map +1 -0
  141. package/lib/modules/description-parser/remove-write-only-properties.js +41 -0
  142. package/lib/modules/description-parser/remove-write-only-properties.js.map +1 -0
  143. package/lib/modules/faker.d.ts +42 -0
  144. package/lib/modules/faker.d.ts.map +1 -0
  145. package/lib/modules/faker.js +36 -0
  146. package/lib/modules/faker.js.map +1 -0
  147. package/lib/modules/flow-runner/call-api-and-analyze-results.d.ts +30 -0
  148. package/lib/modules/flow-runner/call-api-and-analyze-results.d.ts.map +1 -0
  149. package/lib/modules/flow-runner/call-api-and-analyze-results.js +100 -0
  150. package/lib/modules/flow-runner/call-api-and-analyze-results.js.map +1 -0
  151. package/lib/modules/flow-runner/context/create-runtime-expression-ctx.d.ts +7 -0
  152. package/lib/modules/flow-runner/context/create-runtime-expression-ctx.d.ts.map +1 -0
  153. package/lib/modules/flow-runner/context/create-runtime-expression-ctx.js +56 -0
  154. package/lib/modules/flow-runner/context/create-runtime-expression-ctx.js.map +1 -0
  155. package/lib/modules/flow-runner/context/create-test-context.d.ts +5 -0
  156. package/lib/modules/flow-runner/context/create-test-context.d.ts.map +1 -0
  157. package/lib/modules/flow-runner/context/create-test-context.js +88 -0
  158. package/lib/modules/flow-runner/context/create-test-context.js.map +1 -0
  159. package/lib/modules/flow-runner/context/index.d.ts +5 -0
  160. package/lib/modules/flow-runner/context/index.d.ts.map +1 -0
  161. package/lib/modules/flow-runner/context/index.js +21 -0
  162. package/lib/modules/flow-runner/context/index.js.map +1 -0
  163. package/lib/modules/flow-runner/context/set-public-steps.d.ts +3 -0
  164. package/lib/modules/flow-runner/context/set-public-steps.d.ts.map +1 -0
  165. package/lib/modules/flow-runner/context/set-public-steps.js +11 -0
  166. package/lib/modules/flow-runner/context/set-public-steps.js.map +1 -0
  167. package/lib/modules/flow-runner/context/set-public-workflows.d.ts +7 -0
  168. package/lib/modules/flow-runner/context/set-public-workflows.d.ts.map +1 -0
  169. package/lib/modules/flow-runner/context/set-public-workflows.js +29 -0
  170. package/lib/modules/flow-runner/context/set-public-workflows.js.map +1 -0
  171. package/lib/modules/flow-runner/error-message-matcher.d.ts +4 -0
  172. package/lib/modules/flow-runner/error-message-matcher.d.ts.map +1 -0
  173. package/lib/modules/flow-runner/error-message-matcher.js +11 -0
  174. package/lib/modules/flow-runner/error-message-matcher.js.map +1 -0
  175. package/lib/modules/flow-runner/get-server-url.d.ts +12 -0
  176. package/lib/modules/flow-runner/get-server-url.d.ts.map +1 -0
  177. package/lib/modules/flow-runner/get-server-url.js +67 -0
  178. package/lib/modules/flow-runner/get-server-url.js.map +1 -0
  179. package/lib/modules/flow-runner/get-test-description-from-file.d.ts +20 -0
  180. package/lib/modules/flow-runner/get-test-description-from-file.d.ts.map +1 -0
  181. package/lib/modules/flow-runner/get-test-description-from-file.js +75 -0
  182. package/lib/modules/flow-runner/get-test-description-from-file.js.map +1 -0
  183. package/lib/modules/flow-runner/get-workflows-to-run.d.ts +3 -0
  184. package/lib/modules/flow-runner/get-workflows-to-run.d.ts.map +1 -0
  185. package/lib/modules/flow-runner/get-workflows-to-run.js +50 -0
  186. package/lib/modules/flow-runner/get-workflows-to-run.js.map +1 -0
  187. package/lib/modules/flow-runner/index.d.ts +16 -0
  188. package/lib/modules/flow-runner/index.d.ts.map +1 -0
  189. package/lib/modules/flow-runner/index.js +32 -0
  190. package/lib/modules/flow-runner/index.js.map +1 -0
  191. package/lib/modules/flow-runner/inputs/format-cli-inputs.d.ts +2 -0
  192. package/lib/modules/flow-runner/inputs/format-cli-inputs.d.ts.map +1 -0
  193. package/lib/modules/flow-runner/inputs/format-cli-inputs.js +45 -0
  194. package/lib/modules/flow-runner/inputs/format-cli-inputs.js.map +1 -0
  195. package/lib/modules/flow-runner/inputs/index.d.ts +3 -0
  196. package/lib/modules/flow-runner/inputs/index.d.ts.map +1 -0
  197. package/lib/modules/flow-runner/inputs/index.js +19 -0
  198. package/lib/modules/flow-runner/inputs/index.js.map +1 -0
  199. package/lib/modules/flow-runner/inputs/map-input-values-to-schema.d.ts +7 -0
  200. package/lib/modules/flow-runner/inputs/map-input-values-to-schema.d.ts.map +1 -0
  201. package/lib/modules/flow-runner/inputs/map-input-values-to-schema.js +29 -0
  202. package/lib/modules/flow-runner/inputs/map-input-values-to-schema.js.map +1 -0
  203. package/lib/modules/flow-runner/outputs/index.d.ts +2 -0
  204. package/lib/modules/flow-runner/outputs/index.d.ts.map +1 -0
  205. package/lib/modules/flow-runner/outputs/index.js +18 -0
  206. package/lib/modules/flow-runner/outputs/index.js.map +1 -0
  207. package/lib/modules/flow-runner/outputs/print-message.d.ts +7 -0
  208. package/lib/modules/flow-runner/outputs/print-message.d.ts.map +1 -0
  209. package/lib/modules/flow-runner/outputs/print-message.js +17 -0
  210. package/lib/modules/flow-runner/outputs/print-message.js.map +1 -0
  211. package/lib/modules/flow-runner/prepare-request.d.ts +15 -0
  212. package/lib/modules/flow-runner/prepare-request.d.ts.map +1 -0
  213. package/lib/modules/flow-runner/prepare-request.js +166 -0
  214. package/lib/modules/flow-runner/prepare-request.js.map +1 -0
  215. package/lib/modules/flow-runner/read-env-variables.d.ts +2 -0
  216. package/lib/modules/flow-runner/read-env-variables.d.ts.map +1 -0
  217. package/lib/modules/flow-runner/read-env-variables.js +44 -0
  218. package/lib/modules/flow-runner/read-env-variables.js.map +1 -0
  219. package/lib/modules/flow-runner/resolve-running-workflows.d.ts +2 -0
  220. package/lib/modules/flow-runner/resolve-running-workflows.d.ts.map +1 -0
  221. package/lib/modules/flow-runner/resolve-running-workflows.js +25 -0
  222. package/lib/modules/flow-runner/resolve-running-workflows.js.map +1 -0
  223. package/lib/modules/flow-runner/run-step.d.ts +12 -0
  224. package/lib/modules/flow-runner/run-step.d.ts.map +1 -0
  225. package/lib/modules/flow-runner/run-step.js +250 -0
  226. package/lib/modules/flow-runner/run-step.js.map +1 -0
  227. package/lib/modules/flow-runner/runner.d.ts +11 -0
  228. package/lib/modules/flow-runner/runner.d.ts.map +1 -0
  229. package/lib/modules/flow-runner/runner.js +225 -0
  230. package/lib/modules/flow-runner/runner.js.map +1 -0
  231. package/lib/modules/flow-runner/schema/index.d.ts +2 -0
  232. package/lib/modules/flow-runner/schema/index.d.ts.map +1 -0
  233. package/lib/modules/flow-runner/schema/index.js +18 -0
  234. package/lib/modules/flow-runner/schema/index.js.map +1 -0
  235. package/lib/modules/flow-runner/schema/schema-checker.d.ts +7 -0
  236. package/lib/modules/flow-runner/schema/schema-checker.d.ts.map +1 -0
  237. package/lib/modules/flow-runner/schema/schema-checker.js +124 -0
  238. package/lib/modules/flow-runner/schema/schema-checker.js.map +1 -0
  239. package/lib/modules/flow-runner/success-criteria/check-success-criteria.d.ts +8 -0
  240. package/lib/modules/flow-runner/success-criteria/check-success-criteria.d.ts.map +1 -0
  241. package/lib/modules/flow-runner/success-criteria/check-success-criteria.js +97 -0
  242. package/lib/modules/flow-runner/success-criteria/check-success-criteria.js.map +1 -0
  243. package/lib/modules/flow-runner/success-criteria/index.d.ts +3 -0
  244. package/lib/modules/flow-runner/success-criteria/index.d.ts.map +1 -0
  245. package/lib/modules/flow-runner/success-criteria/index.js +19 -0
  246. package/lib/modules/flow-runner/success-criteria/index.js.map +1 -0
  247. package/lib/modules/flow-runner/success-criteria/validate-success-criteria.d.ts +6 -0
  248. package/lib/modules/flow-runner/success-criteria/validate-success-criteria.d.ts.map +1 -0
  249. package/lib/modules/flow-runner/success-criteria/validate-success-criteria.js +63 -0
  250. package/lib/modules/flow-runner/success-criteria/validate-success-criteria.js.map +1 -0
  251. package/lib/modules/runtime-expressions/abnf-parser.d.ts +15 -0
  252. package/lib/modules/runtime-expressions/abnf-parser.d.ts.map +1 -0
  253. package/lib/modules/runtime-expressions/abnf-parser.js +2012 -0
  254. package/lib/modules/runtime-expressions/abnf-parser.js.map +1 -0
  255. package/lib/modules/runtime-expressions/evaluate.d.ts +9 -0
  256. package/lib/modules/runtime-expressions/evaluate.d.ts.map +1 -0
  257. package/lib/modules/runtime-expressions/evaluate.js +169 -0
  258. package/lib/modules/runtime-expressions/evaluate.js.map +1 -0
  259. package/lib/modules/runtime-expressions/index.d.ts +2 -0
  260. package/lib/modules/runtime-expressions/index.d.ts.map +1 -0
  261. package/lib/modules/runtime-expressions/index.js +18 -0
  262. package/lib/modules/runtime-expressions/index.js.map +1 -0
  263. package/lib/modules/runtime-expressions/lint.d.ts +2 -0
  264. package/lib/modules/runtime-expressions/lint.d.ts.map +1 -0
  265. package/lib/modules/runtime-expressions/lint.js +13 -0
  266. package/lib/modules/runtime-expressions/lint.js.map +1 -0
  267. package/lib/modules/runtime-expressions/replace-json-pointers.d.ts +2 -0
  268. package/lib/modules/runtime-expressions/replace-json-pointers.d.ts.map +1 -0
  269. package/lib/modules/runtime-expressions/replace-json-pointers.js +62 -0
  270. package/lib/modules/runtime-expressions/replace-json-pointers.js.map +1 -0
  271. package/lib/modules/test-config-generator/cleanup-test-description.d.ts +16 -0
  272. package/lib/modules/test-config-generator/cleanup-test-description.d.ts.map +1 -0
  273. package/lib/modules/test-config-generator/cleanup-test-description.js +28 -0
  274. package/lib/modules/test-config-generator/cleanup-test-description.js.map +1 -0
  275. package/lib/modules/test-config-generator/generate-example-value.d.ts +3 -0
  276. package/lib/modules/test-config-generator/generate-example-value.d.ts.map +1 -0
  277. package/lib/modules/test-config-generator/generate-example-value.js +17 -0
  278. package/lib/modules/test-config-generator/generate-example-value.js.map +1 -0
  279. package/lib/modules/test-config-generator/generate-test-config.d.ts +7 -0
  280. package/lib/modules/test-config-generator/generate-test-config.d.ts.map +1 -0
  281. package/lib/modules/test-config-generator/generate-test-config.js +117 -0
  282. package/lib/modules/test-config-generator/generate-test-config.js.map +1 -0
  283. package/lib/modules/test-config-generator/generate-test-data-from-json-schema.d.ts +2 -0
  284. package/lib/modules/test-config-generator/generate-test-data-from-json-schema.d.ts.map +1 -0
  285. package/lib/modules/test-config-generator/generate-test-data-from-json-schema.js +42 -0
  286. package/lib/modules/test-config-generator/generate-test-data-from-json-schema.js.map +1 -0
  287. package/lib/modules/test-config-generator/index.d.ts +5 -0
  288. package/lib/modules/test-config-generator/index.d.ts.map +1 -0
  289. package/lib/modules/test-config-generator/index.js +21 -0
  290. package/lib/modules/test-config-generator/index.js.map +1 -0
  291. package/lib/types.d.ts +241 -0
  292. package/lib/types.d.ts.map +1 -0
  293. package/lib/types.js +3 -0
  294. package/lib/types.js.map +1 -0
  295. package/lib/utils/ajv-errors.d.ts +3 -0
  296. package/lib/utils/ajv-errors.d.ts.map +1 -0
  297. package/lib/utils/ajv-errors.js +28 -0
  298. package/lib/utils/ajv-errors.js.map +1 -0
  299. package/lib/utils/api-fetcher.d.ts +27 -0
  300. package/lib/utils/api-fetcher.d.ts.map +1 -0
  301. package/lib/utils/api-fetcher.js +243 -0
  302. package/lib/utils/api-fetcher.js.map +1 -0
  303. package/lib/utils/check-circular-refs-in-schema.d.ts +2 -0
  304. package/lib/utils/check-circular-refs-in-schema.d.ts.map +1 -0
  305. package/lib/utils/check-circular-refs-in-schema.js +13 -0
  306. package/lib/utils/check-circular-refs-in-schema.js.map +1 -0
  307. package/lib/utils/clean-colors.d.ts +2 -0
  308. package/lib/utils/clean-colors.d.ts.map +1 -0
  309. package/lib/utils/clean-colors.js +8 -0
  310. package/lib/utils/clean-colors.js.map +1 -0
  311. package/lib/utils/cli-outputs.d.ts +18 -0
  312. package/lib/utils/cli-outputs.d.ts.map +1 -0
  313. package/lib/utils/cli-outputs.js +70 -0
  314. package/lib/utils/cli-outputs.js.map +1 -0
  315. package/lib/utils/delay.d.ts +2 -0
  316. package/lib/utils/delay.d.ts.map +1 -0
  317. package/lib/utils/delay.js +8 -0
  318. package/lib/utils/delay.js.map +1 -0
  319. package/lib/utils/env.d.ts +3 -0
  320. package/lib/utils/env.d.ts.map +1 -0
  321. package/lib/utils/env.js +13 -0
  322. package/lib/utils/env.js.map +1 -0
  323. package/lib/utils/file.d.ts +2 -0
  324. package/lib/utils/file.d.ts.map +1 -0
  325. package/lib/utils/file.js +7 -0
  326. package/lib/utils/file.js.map +1 -0
  327. package/lib/utils/get-nested-value.d.ts +2 -0
  328. package/lib/utils/get-nested-value.d.ts.map +1 -0
  329. package/lib/utils/get-nested-value.js +16 -0
  330. package/lib/utils/get-nested-value.js.map +1 -0
  331. package/lib/utils/get-reunite-url.d.ts +2 -0
  332. package/lib/utils/get-reunite-url.d.ts.map +1 -0
  333. package/lib/utils/get-reunite-url.js +18 -0
  334. package/lib/utils/get-reunite-url.js.map +1 -0
  335. package/lib/utils/har-logs/create-har-log.d.ts +2 -0
  336. package/lib/utils/har-logs/create-har-log.d.ts.map +1 -0
  337. package/lib/utils/har-logs/create-har-log.js +28 -0
  338. package/lib/utils/har-logs/create-har-log.js.map +1 -0
  339. package/lib/utils/har-logs/helpers/add-headers.d.ts +2 -0
  340. package/lib/utils/har-logs/helpers/add-headers.d.ts.map +1 -0
  341. package/lib/utils/har-logs/helpers/add-headers.js +20 -0
  342. package/lib/utils/har-logs/helpers/add-headers.js.map +1 -0
  343. package/lib/utils/har-logs/helpers/build-headers.d.ts +10 -0
  344. package/lib/utils/har-logs/helpers/build-headers.d.ts.map +1 -0
  345. package/lib/utils/har-logs/helpers/build-headers.js +35 -0
  346. package/lib/utils/har-logs/helpers/build-headers.js.map +1 -0
  347. package/lib/utils/har-logs/helpers/build-params.d.ts +2 -0
  348. package/lib/utils/har-logs/helpers/build-params.d.ts.map +1 -0
  349. package/lib/utils/har-logs/helpers/build-params.js +44 -0
  350. package/lib/utils/har-logs/helpers/build-params.js.map +1 -0
  351. package/lib/utils/har-logs/helpers/build-request-cookies.d.ts +2 -0
  352. package/lib/utils/har-logs/helpers/build-request-cookies.d.ts.map +1 -0
  353. package/lib/utils/har-logs/helpers/build-request-cookies.js +44 -0
  354. package/lib/utils/har-logs/helpers/build-request-cookies.js.map +1 -0
  355. package/lib/utils/har-logs/helpers/build-response-cookies.d.ts +2 -0
  356. package/lib/utils/har-logs/helpers/build-response-cookies.d.ts.map +1 -0
  357. package/lib/utils/har-logs/helpers/build-response-cookies.js +66 -0
  358. package/lib/utils/har-logs/helpers/build-response-cookies.js.map +1 -0
  359. package/lib/utils/har-logs/helpers/get-agent.d.ts +2 -0
  360. package/lib/utils/har-logs/helpers/get-agent.d.ts.map +1 -0
  361. package/lib/utils/har-logs/helpers/get-agent.js +115 -0
  362. package/lib/utils/har-logs/helpers/get-agent.js.map +1 -0
  363. package/lib/utils/har-logs/helpers/get-duration.d.ts +2 -0
  364. package/lib/utils/har-logs/helpers/get-duration.d.ts.map +1 -0
  365. package/lib/utils/har-logs/helpers/get-duration.js +9 -0
  366. package/lib/utils/har-logs/helpers/get-duration.js.map +1 -0
  367. package/lib/utils/har-logs/helpers/get-input-url.d.ts +2 -0
  368. package/lib/utils/har-logs/helpers/get-input-url.d.ts.map +1 -0
  369. package/lib/utils/har-logs/helpers/get-input-url.js +8 -0
  370. package/lib/utils/har-logs/helpers/get-input-url.js.map +1 -0
  371. package/lib/utils/har-logs/helpers/handle-request.d.ts +9 -0
  372. package/lib/utils/har-logs/helpers/handle-request.d.ts.map +1 -0
  373. package/lib/utils/har-logs/helpers/handle-request.js +202 -0
  374. package/lib/utils/har-logs/helpers/handle-request.js.map +1 -0
  375. package/lib/utils/har-logs/index.d.ts +3 -0
  376. package/lib/utils/har-logs/index.d.ts.map +1 -0
  377. package/lib/utils/har-logs/index.js +19 -0
  378. package/lib/utils/har-logs/index.js.map +1 -0
  379. package/lib/utils/har-logs/with-har.d.ts +6 -0
  380. package/lib/utils/har-logs/with-har.d.ts.map +1 -0
  381. package/lib/utils/har-logs/with-har.js +216 -0
  382. package/lib/utils/har-logs/with-har.js.map +1 -0
  383. package/lib/utils/is-empty.d.ts +2 -0
  384. package/lib/utils/is-empty.d.ts.map +1 -0
  385. package/lib/utils/is-empty.js +16 -0
  386. package/lib/utils/is-empty.js.map +1 -0
  387. package/lib/utils/is-json.d.ts +2 -0
  388. package/lib/utils/is-json.d.ts.map +1 -0
  389. package/lib/utils/is-json.js +13 -0
  390. package/lib/utils/is-json.js.map +1 -0
  391. package/lib/utils/is-url.d.ts +2 -0
  392. package/lib/utils/is-url.d.ts.map +1 -0
  393. package/lib/utils/is-url.js +16 -0
  394. package/lib/utils/is-url.js.map +1 -0
  395. package/lib/utils/logger/logger.d.ts +16 -0
  396. package/lib/utils/logger/logger.d.ts.map +1 -0
  397. package/lib/utils/logger/logger.js +33 -0
  398. package/lib/utils/logger/logger.js.map +1 -0
  399. package/lib/utils/mtls/create-mtls-client.d.ts +4 -0
  400. package/lib/utils/mtls/create-mtls-client.d.ts.map +1 -0
  401. package/lib/utils/mtls/create-mtls-client.js +22 -0
  402. package/lib/utils/mtls/create-mtls-client.js.map +1 -0
  403. package/lib/utils/mtls/resolve-mtls-certificates.d.ts +7 -0
  404. package/lib/utils/mtls/resolve-mtls-certificates.d.ts.map +1 -0
  405. package/lib/utils/mtls/resolve-mtls-certificates.js +69 -0
  406. package/lib/utils/mtls/resolve-mtls-certificates.js.map +1 -0
  407. package/lib/utils/sort.d.ts +2 -0
  408. package/lib/utils/sort.d.ts.map +1 -0
  409. package/lib/utils/sort.js +29 -0
  410. package/lib/utils/sort.js.map +1 -0
  411. package/lib/utils/time.d.ts +2 -0
  412. package/lib/utils/time.d.ts.map +1 -0
  413. package/lib/utils/time.js +10 -0
  414. package/lib/utils/time.js.map +1 -0
  415. package/lib/utils/url.d.ts +2 -0
  416. package/lib/utils/url.d.ts.map +1 -0
  417. package/lib/utils/url.js +9 -0
  418. package/lib/utils/url.js.map +1 -0
  419. package/lib/utils/yaml.d.ts +5 -0
  420. package/lib/utils/yaml.d.ts.map +1 -0
  421. package/lib/utils/yaml.js +23 -0
  422. package/lib/utils/yaml.js.map +1 -0
  423. package/package.json +68 -0
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTestFile = runTestFile;
4
+ exports.runWorkflow = runWorkflow;
5
+ exports.resolveWorkflowContext = resolveWorkflowContext;
6
+ const colorette_1 = require("colorette");
7
+ const node_path_1 = require("node:path");
8
+ const node_fs_1 = require("node:fs");
9
+ const har_logs_1 = require("../../utils/har-logs");
10
+ const api_fetcher_1 = require("../../utils/api-fetcher");
11
+ const create_test_context_1 = require("./context/create-test-context");
12
+ const config_parser_1 = require("../config-parser");
13
+ const get_workflows_to_run_1 = require("./get-workflows-to-run");
14
+ const run_step_1 = require("./run-step");
15
+ const cli_outputs_1 = require("../../utils/cli-outputs");
16
+ const get_test_description_from_file_1 = require("./get-test-description-from-file");
17
+ const checks_1 = require("../checks");
18
+ const context_1 = require("./context");
19
+ const runtime_expressions_1 = require("../runtime-expressions");
20
+ const cli_output_1 = require("../cli-output");
21
+ const resolve_running_workflows_1 = require("./resolve-running-workflows");
22
+ const logger_1 = require("../../utils/logger/logger");
23
+ const logger = logger_1.DefaultLogger.getInstance();
24
+ async function runTestFile(argv, output) {
25
+ const { file: filePath, workflow, verbose, input, skip, server, harOutput, jsonOutput, severity, } = argv;
26
+ const options = {
27
+ workflowPath: filePath, // filePath or documentPath
28
+ workflow,
29
+ skip,
30
+ verbose,
31
+ harOutput,
32
+ jsonOutput,
33
+ metadata: { ...argv },
34
+ input,
35
+ server,
36
+ severity,
37
+ mutualTls: {
38
+ clientCert: argv?.clientCert,
39
+ clientKey: argv?.clientKey,
40
+ caCert: argv?.caCert,
41
+ },
42
+ };
43
+ const bundledTestDescription = await (0, get_test_description_from_file_1.bundleArazzo)(filePath);
44
+ const descriptionCopy = JSON.parse(JSON.stringify(bundledTestDescription));
45
+ const { harLogs, jsonLogs, workflows, secretFields } = await runWorkflows(bundledTestDescription, options);
46
+ if (output?.harFile && Object.keys(harLogs).length) {
47
+ const parsedHarLogs = (0, cli_output_1.maskSecrets)(harLogs, secretFields || new Set());
48
+ (0, node_fs_1.writeFileSync)(output.harFile, JSON.stringify(parsedHarLogs, null, 2), 'utf-8');
49
+ logger.log((0, colorette_1.blue)(`Har logs saved in ${(0, colorette_1.green)(output.harFile)}`));
50
+ logger.printNewLine();
51
+ logger.printNewLine();
52
+ }
53
+ if (output?.jsonFile && jsonLogs) {
54
+ (0, node_fs_1.writeFileSync)(output.jsonFile, JSON.stringify(jsonLogs, null, 2), 'utf-8');
55
+ logger.log((0, colorette_1.blue)((0, cli_outputs_1.indent)(`JSON logs saved in ${(0, colorette_1.green)(output.jsonFile)}`, 2)));
56
+ logger.printNewLine();
57
+ logger.printNewLine();
58
+ }
59
+ return { workflows, parsedYaml: descriptionCopy };
60
+ }
61
+ async function runWorkflows(testDescription, options) {
62
+ const harLogs = options.metadata?.harOutput && (0, har_logs_1.createHarLog)();
63
+ const apiClient = new api_fetcher_1.ApiFetcher({
64
+ harLogs,
65
+ });
66
+ const ctx = await (0, create_test_context_1.createTestContext)(testDescription, options, apiClient);
67
+ const workflowsToRun = (0, resolve_running_workflows_1.resolveRunningWorkflows)(options.workflow);
68
+ const workflowsToSkip = (0, resolve_running_workflows_1.resolveRunningWorkflows)(options.skip);
69
+ const workflows = (0, get_workflows_to_run_1.getWorkflowsToRun)(ctx.workflows, workflowsToRun, workflowsToSkip);
70
+ for (const workflow of workflows) {
71
+ // run dependencies workflows first
72
+ if (workflow.dependsOn?.length) {
73
+ await handleDependsOn({ workflow, ctx });
74
+ }
75
+ await runWorkflow({
76
+ workflowInput: workflow.workflowId,
77
+ ctx,
78
+ });
79
+ }
80
+ // json logs should be composed after all workflows are run
81
+ const jsonLogs = options.jsonLogsFile ? (0, cli_output_1.composeJsonLogs)(ctx) : undefined;
82
+ return { ...ctx, harLogs, jsonLogs };
83
+ }
84
+ async function runWorkflow({ workflowInput, ctx, parentStepId, parentWorkflowId, fromStepId, }) {
85
+ const workflowStartTime = performance.now();
86
+ const fileBaseName = (0, node_path_1.basename)(ctx.options.workflowPath);
87
+ const workflow = typeof workflowInput === 'string'
88
+ ? ctx.workflows.find((w) => w.workflowId === workflowInput)
89
+ : workflowInput;
90
+ if (!workflow) {
91
+ throw new Error(`\n ${(0, colorette_1.blue)('Workflow')} ${workflowInput} ${(0, colorette_1.blue)('not found')} \n`);
92
+ }
93
+ const workflowName = workflow?.workflowId || parentWorkflowId;
94
+ if (parentWorkflowId && parentStepId) {
95
+ (0, cli_outputs_1.printStepWorkflowSeparator)(parentStepId, parentWorkflowId);
96
+ }
97
+ else if (parentWorkflowId) {
98
+ (0, cli_outputs_1.printDependentWorkflowSeparator)(parentWorkflowId);
99
+ }
100
+ else {
101
+ (0, cli_outputs_1.printWorkflowSeparator)(fileBaseName, workflowName);
102
+ }
103
+ const fromStepIndex = fromStepId
104
+ ? workflow.steps.findIndex((step) => step.stepId === fromStepId)
105
+ : 0;
106
+ const workflowSteps = workflow.steps.slice(fromStepIndex);
107
+ // clean $steps ctx before running workflow steps
108
+ ctx.$steps = {};
109
+ for (const step of workflowSteps) {
110
+ try {
111
+ const stepResults = await (0, run_step_1.runStep)({
112
+ step,
113
+ ctx,
114
+ workflowName,
115
+ parentWorkflowId,
116
+ parentStepId,
117
+ });
118
+ // When `end` action is used, we should not continue with the next steps
119
+ if (stepResults?.shouldEnd) {
120
+ break;
121
+ }
122
+ }
123
+ catch (err) {
124
+ const failedCall = {
125
+ name: checks_1.CHECKS.UNEXPECTED_ERROR,
126
+ message: err.message,
127
+ pass: false,
128
+ severity: ctx.severity['UNEXPECTED_ERROR'],
129
+ };
130
+ step.checks.push(failedCall);
131
+ return;
132
+ }
133
+ }
134
+ // workflow level outputs
135
+ if (workflow.outputs && workflowName) {
136
+ if (!ctx.$outputs) {
137
+ ctx.$outputs = {};
138
+ }
139
+ if (!ctx.$outputs[workflowName]) {
140
+ ctx.$outputs[workflowName] = {};
141
+ }
142
+ const runtimeExpressionContext = (0, context_1.createRuntimeExpressionCtx)({
143
+ ctx: {
144
+ ...ctx,
145
+ $inputs: {
146
+ ...(ctx.$inputs || {}),
147
+ ...(ctx.$workflows[workflowName]?.inputs || {}),
148
+ },
149
+ },
150
+ workflowId: workflowName,
151
+ });
152
+ for (const outputKey of Object.keys(workflow.outputs)) {
153
+ try {
154
+ if (workflow.outputs) {
155
+ workflow.outputs[outputKey] = (0, runtime_expressions_1.evaluateRuntimeExpressionPayload)({
156
+ payload: workflow.outputs[outputKey],
157
+ context: runtimeExpressionContext,
158
+ });
159
+ }
160
+ ctx.$outputs[workflowName].outputs = workflow.outputs;
161
+ ctx.$workflows[workflowName].outputs = workflow.outputs;
162
+ }
163
+ catch (error) {
164
+ throw new Error(`Failed to resolve outputs in workflow "${workflowName}": ${error.message}`);
165
+ }
166
+ }
167
+ }
168
+ workflow.time = Math.ceil(performance.now() - workflowStartTime);
169
+ logger.printNewLine();
170
+ return workflow;
171
+ }
172
+ async function handleDependsOn({ workflow, ctx }) {
173
+ if (!workflow.dependsOn?.length)
174
+ return;
175
+ const dependenciesWorkflows = await Promise.all(workflow.dependsOn.map(async (workflowId) => {
176
+ const resolvedWorkflow = (0, config_parser_1.getValueFromContext)(workflowId, ctx);
177
+ const workflowCtx = await resolveWorkflowContext(workflowId, resolvedWorkflow, ctx);
178
+ return runWorkflow({
179
+ workflowInput: resolvedWorkflow,
180
+ parentWorkflowId: workflow.workflowId,
181
+ ctx: workflowCtx,
182
+ });
183
+ }));
184
+ if (dependenciesWorkflows.some((w) => !w)) {
185
+ throw new Error('Dependent workflows failed');
186
+ }
187
+ const totals = (0, cli_output_1.calculateTotals)(dependenciesWorkflows);
188
+ const hasProblems = totals.steps.failed > 0;
189
+ if (hasProblems) {
190
+ throw new Error('Dependent workflows has failed steps');
191
+ }
192
+ }
193
+ async function resolveWorkflowContext(workflowId, resolvedWorkflow, ctx) {
194
+ const sourceDescriptionId = workflowId && workflowId.startsWith('$sourceDescriptions.') && workflowId.split('.')[1];
195
+ const testDescription = sourceDescriptionId && ctx.$sourceDescriptions[sourceDescriptionId];
196
+ // executing external workflow should not mutate the original context
197
+ // only outputs are transferred to the parent workflow
198
+ // creating the new ctx for the external workflow or recreate current ctx for local workflow
199
+ return testDescription
200
+ ? await (0, create_test_context_1.createTestContext)(testDescription, {
201
+ workflowPath: findSourceDescriptionUrl(sourceDescriptionId, ctx.sourceDescriptions, ctx.options),
202
+ workflow: [resolvedWorkflow.workflowId],
203
+ skip: undefined,
204
+ input: ctx.options.input || undefined,
205
+ server: ctx.options.server || undefined,
206
+ severity: ctx.options.severity || undefined,
207
+ }, ctx.apiClient)
208
+ : await (0, create_test_context_1.createTestContext)(JSON.parse(JSON.stringify(ctx.testDescription)), JSON.parse(JSON.stringify(ctx.options)), ctx.apiClient);
209
+ }
210
+ function findSourceDescriptionUrl(sourceDescriptionId, sourceDescriptions, options) {
211
+ const sourceDescription = sourceDescriptions && sourceDescriptions.find(({ name }) => name === sourceDescriptionId);
212
+ if (!sourceDescription) {
213
+ return '';
214
+ }
215
+ else if (sourceDescription.type === 'openapi') {
216
+ return sourceDescription.url;
217
+ }
218
+ else if (sourceDescription.type === 'arazzo') {
219
+ return (0, node_path_1.resolve)((0, node_path_1.dirname)(options.workflowPath), sourceDescription.url);
220
+ }
221
+ else {
222
+ throw new Error(`Unknown source description type ${sourceDescription.type}`);
223
+ }
224
+ }
225
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/modules/flow-runner/runner.ts"],"names":[],"mappings":";;AAoCA,kCAuDC;AAiCD,kCAuGC;AA8BD,wDAkCC;AAnSD,yCAAwC;AACxC,yCAAuD;AACvD,qCAAwC;AACxC,mDAAoD;AACpD,yD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AAED,SAAS,wBAAwB,CAC/B,mBAA2B,EAC3B,kBAAmD,EACnD,OAAmB;IAEnB,MAAM,iBAAiB,GACrB,kBAAkB,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC;IAE5F,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,IAAI,iBAAiB,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChD,OAAO,iBAAiB,CAAC,GAAG,CAAC;IAC/B,CAAC;SAAM,IAAI,iBAAiB,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,IAAA,mBAAO,EAAC,IAAA,mBAAO,EAAC,OAAO,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACvE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,mCAAoC,iBAAuC,CAAC,IAAI,EAAE,CACnF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './schema-checker';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schema-checker"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,7 @@
1
+ import { type Check, type StepCallContext, type TestContext } from '../../../types';
2
+ export declare function checkSchema({ stepCallCtx, descriptionOperation, ctx, }: {
3
+ stepCallCtx: StepCallContext;
4
+ descriptionOperation?: any;
5
+ ctx: TestContext;
6
+ }): Check[];
7
+ //# sourceMappingURL=schema-checker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-checker.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/schema-checker.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAwBxB,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,oBAAoB,EACpB,GAAG,GACJ,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,oBAAoB,CAAC,EAAE,GAAG,CAAC;IAC3B,GAAG,EAAE,WAAW,CAAC;CAClB,GAAG,KAAK,EAAE,CAkBV"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkSchema = checkSchema;
7
+ const _2020_1 = __importDefault(require("@redocly/ajv/dist/2020"));
8
+ const jest_diff_1 = require("jest-diff");
9
+ const colorette_1 = require("colorette");
10
+ const checks_1 = require("../../checks");
11
+ const ajv_errors_1 = require("../../../utils/ajv-errors");
12
+ const check_circular_refs_in_schema_1 = require("../../../utils/check-circular-refs-in-schema");
13
+ const description_parser_1 = require("../../description-parser");
14
+ const logger_1 = require("../../../utils/logger/logger");
15
+ const logger = logger_1.DefaultLogger.getInstance();
16
+ const ajvStrict = new _2020_1.default({
17
+ schemaId: '$id',
18
+ meta: true,
19
+ allErrors: true,
20
+ strictSchema: false,
21
+ inlineRefs: false,
22
+ validateSchema: false,
23
+ discriminator: true,
24
+ allowUnionTypes: true,
25
+ validateFormats: false,
26
+ logger: false,
27
+ verbose: true,
28
+ defaultUnevaluatedProperties: false,
29
+ });
30
+ function checkSchema({ stepCallCtx, descriptionOperation, ctx, }) {
31
+ const { $response } = stepCallCtx;
32
+ const checks = [];
33
+ // if no $response, that is a common case for executing dependsOn workflow steps of workflow inside
34
+ // the step - return checks
35
+ if (!$response || !descriptionOperation) {
36
+ return checks;
37
+ }
38
+ checkStatusCodeFromDescription({ checks, descriptionOperation, $response, ctx });
39
+ checkContentTypeFromDescription({ checks, descriptionOperation, $response, ctx });
40
+ checkSchemaFromDescription({ checks, descriptionOperation, $response, ctx });
41
+ return checks;
42
+ }
43
+ function checkSchemaFromDescription({ checks, descriptionOperation, $response, ctx, }) {
44
+ const { body: resultBody } = $response;
45
+ const descriptionResponseByCode = descriptionOperation?.responses[String($response?.statusCode)] ||
46
+ descriptionOperation?.responses['default'];
47
+ const schemaFromDescription = $response?.contentType
48
+ ? descriptionResponseByCode?.content?.[$response.contentType]?.schema
49
+ : undefined;
50
+ const isSchemaWithCircularRef = (0, check_circular_refs_in_schema_1.checkCircularRefsInSchema)(schemaFromDescription);
51
+ if (isSchemaWithCircularRef) {
52
+ logger.log(`${(0, colorette_1.yellow)('WARNING: schema have circular references')}`);
53
+ logger.printNewLine();
54
+ }
55
+ if (schemaFromDescription && !isSchemaWithCircularRef) {
56
+ try {
57
+ checks.push({
58
+ name: checks_1.CHECKS.SCHEMA_CHECK,
59
+ pass: ajvStrict.validate((0, description_parser_1.removeWriteOnlyProperties)(schemaFromDescription), resultBody),
60
+ message: ajvStrict.errors
61
+ ? (0, ajv_errors_1.printErrors)((0, description_parser_1.removeWriteOnlyProperties)(schemaFromDescription), resultBody, ajvStrict.errors)
62
+ : '',
63
+ severity: ctx.severity['SCHEMA_CHECK'],
64
+ });
65
+ }
66
+ catch (error) {
67
+ checks.push({
68
+ name: checks_1.CHECKS.SCHEMA_CHECK,
69
+ pass: false,
70
+ message: `Ajv error: ${error.message}`,
71
+ severity: ctx.severity['SCHEMA_CHECK'],
72
+ });
73
+ }
74
+ }
75
+ }
76
+ function checkStatusCodeFromDescription({ checks, descriptionOperation, $response, ctx, }) {
77
+ const responseStatusCode = $response?.statusCode;
78
+ const responseCodesFromDescription = Object.keys(descriptionOperation?.responses || {});
79
+ const matchesCodeFromDescription = responseStatusCode &&
80
+ responseCodesFromDescription
81
+ .map((item) => item.toString())
82
+ .includes(responseStatusCode.toString());
83
+ const matchesDefaultResponse = responseCodesFromDescription.includes('default');
84
+ const message = matchesCodeFromDescription
85
+ ? (0, colorette_1.dim)(`List of valid response codes are inferred from description \n\n`) +
86
+ (0, jest_diff_1.diffLinesUnified)(responseCodesFromDescription.map(String), [`${responseStatusCode}`])
87
+ : ''; // NOTE: we don't show any diff if response code hits default response
88
+ const pass = matchesCodeFromDescription || matchesDefaultResponse;
89
+ checks.push({
90
+ name: checks_1.CHECKS.STATUS_CODE_CHECK,
91
+ pass,
92
+ message,
93
+ ...(pass && {
94
+ additionalMessage: `Response code ${responseStatusCode} matches one of description codes: [${responseCodesFromDescription.join(', ')}]`,
95
+ }),
96
+ severity: ctx.severity['STATUS_CODE_CHECK'],
97
+ });
98
+ }
99
+ function checkContentTypeFromDescription({ checks, descriptionOperation, $response, ctx, }) {
100
+ const statusCode = $response?.statusCode;
101
+ const responseContentType = $response?.contentType;
102
+ const possibleContentTypesFromDescription = Object.keys(descriptionOperation?.responses[statusCode]?.content || {});
103
+ if (!possibleContentTypesFromDescription.length) {
104
+ return;
105
+ }
106
+ if (responseContentType && !possibleContentTypesFromDescription.includes(responseContentType)) {
107
+ checks.push({
108
+ name: checks_1.CHECKS.CONTENT_TYPE_CHECK,
109
+ pass: false,
110
+ message: `Content type ${(0, colorette_1.red)(responseContentType)} for ${(0, colorette_1.blue)(statusCode)} response is not described in the schema.
111
+ Expected content types: ${(0, colorette_1.blue)(possibleContentTypesFromDescription.join(', '))}.`,
112
+ severity: ctx.severity['CONTENT_TYPE_CHECK'],
113
+ });
114
+ }
115
+ else {
116
+ checks.push({
117
+ name: checks_1.CHECKS.CONTENT_TYPE_CHECK,
118
+ pass: true,
119
+ message: `Content type "${responseContentType}" is described in the schema.`,
120
+ severity: ctx.severity['CONTENT_TYPE_CHECK'],
121
+ });
122
+ }
123
+ }
124
+ //# sourceMappingURL=schema-checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-checker.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/schema-checker.ts"],"names":[],"mappings":";;;;;AAgCA,kCA0BC;AA1DD,mEAAkE;AAClE,yCAA6C;AAC7C,yCAAmD;AAOnD,yCAAsC;AACtC,0DAA0E;AAC1E,gGAAyF;AACzF,iEAAqE;AACrE,yDAA6D;AAE7D,MAAM,MAAM,GAAG,sBAAa,CAAC,WAAW,EAAE,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,eAAG,CAAC;IACxB,QAAQ,EAAE,KAAK;IACf,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,KAAK;IACjB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,KAAK;IACtB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,IAAI;IACb,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,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,CAAC,QAAQ,IAAA,gBAAI,EAC3D,UAAU,CACX;iCAC0B,IAAA,gBAAI,EAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG;YAClF,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,eAAM,CAAC,kBAAkB;YAC/B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,iBAAiB,mBAAmB,+BAA+B;YAC5E,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { TestContext, Check, Step, CriteriaObject } from '../../../types';
2
+ export declare function checkCriteria({ workflowId, step, criteria, ctx, }: {
3
+ workflowId?: string;
4
+ step: Step;
5
+ criteria?: CriteriaObject[];
6
+ ctx: TestContext;
7
+ }): Check[];
8
+ //# sourceMappingURL=check-success-criteria.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-success-criteria.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/check-success-criteria.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,WAAW,EACX,KAAK,EAEL,IAAI,EACJ,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,IAAI,EACJ,QAAa,EACb,GAAG,GACJ,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,GAAG,EAAE,WAAW,CAAC;CAClB,GAAG,KAAK,EAAE,CA8EV"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkCriteria = checkCriteria;
4
+ const jsonpath_plus_1 = require("jsonpath-plus");
5
+ const validate_success_criteria_1 = require("./validate-success-criteria");
6
+ const checks_1 = require("../../checks");
7
+ const runtime_expressions_1 = require("../../runtime-expressions");
8
+ const context_1 = require("../context");
9
+ function checkCriteria({ workflowId, step, criteria = [], ctx, }) {
10
+ (0, validate_success_criteria_1.validateSuccessCriteria)(criteria);
11
+ const checks = [];
12
+ if (!workflowId) {
13
+ checks.push({
14
+ name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
15
+ pass: false,
16
+ message: `Undefined workflowId for step ${step.stepId}`,
17
+ severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
18
+ });
19
+ return checks;
20
+ }
21
+ const criteriaContext = (0, context_1.createRuntimeExpressionCtx)({
22
+ ctx,
23
+ workflowId,
24
+ step,
25
+ });
26
+ criteria.forEach((criteria) => {
27
+ const { condition } = criteria;
28
+ try {
29
+ if ((0, validate_success_criteria_1.isRegexpSuccessCriteria)(criteria)) {
30
+ const regexParts = condition.match(/^\/(.*)\/([gimsuy]*)$/);
31
+ let regexPattern;
32
+ let flags;
33
+ if (regexParts) {
34
+ regexPattern = regexParts[1]; // Extract pattern between the first and last slash
35
+ flags = regexParts[2]; // Extract flags after the last slash
36
+ }
37
+ else {
38
+ regexPattern = condition; // If no slashes are present, treat the whole string as the pattern
39
+ flags = ''; // No flags in this case
40
+ }
41
+ const { context } = criteria;
42
+ const regex = new RegExp(regexPattern, flags);
43
+ checks.push({
44
+ name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
45
+ pass: regex.test((0, runtime_expressions_1.evaluateRuntimeExpression)(context, criteriaContext)),
46
+ message: `Checking regex criteria: ${JSON.stringify(criteria)}`,
47
+ severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
48
+ });
49
+ }
50
+ else if ((0, validate_success_criteria_1.isJSONPathSuccessCriteria)(criteria)) {
51
+ const { context, condition } = criteria;
52
+ const data = (0, runtime_expressions_1.evaluateRuntimeExpression)(context, criteriaContext);
53
+ checks.push({
54
+ name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
55
+ pass: evaluateJSONPAthCondition(condition, data),
56
+ message: `Checking jsonpath criteria: ${condition}`,
57
+ severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
58
+ });
59
+ }
60
+ else {
61
+ checks.push({
62
+ name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
63
+ pass: (0, runtime_expressions_1.evaluateRuntimeExpression)(condition, criteriaContext),
64
+ message: `Checking simple criteria: ${JSON.stringify(criteria)}`,
65
+ severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
66
+ });
67
+ }
68
+ }
69
+ catch (e) {
70
+ checks.push({
71
+ name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
72
+ pass: false,
73
+ message: `Failed to pass ${JSON.stringify(criteria)}: ${e.message}`,
74
+ severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
75
+ });
76
+ }
77
+ });
78
+ return checks;
79
+ }
80
+ function evaluateJSONPAthCondition(condition, context) {
81
+ // Extract JSONPath expressions from the string
82
+ const jsonpathMatches = condition.match(/\$\.[a-zA-Z0-9_]+/g) || [];
83
+ // Replace JSONPath expressions with their values
84
+ const replacedCondition = jsonpathMatches.reduce((acc, match) => {
85
+ const jsonpathResult = (0, jsonpath_plus_1.JSONPath)({ path: match, json: context });
86
+ const jsonpathResultValue = jsonpathResult[0] || null;
87
+ return acc.replace(match, JSON.stringify(jsonpathResultValue));
88
+ }, condition);
89
+ try {
90
+ const evaluateFn = new Function(`return ${replacedCondition};`);
91
+ return !!evaluateFn();
92
+ }
93
+ catch (_error) {
94
+ return false;
95
+ }
96
+ }
97
+ //# sourceMappingURL=check-success-criteria.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-success-criteria.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/check-success-criteria.ts"],"names":[],"mappings":";;AAkBA,sCAwFC;AA1GD,iDAAyC;AACzC,2E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":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./validate-success-criteria"), exports);
18
+ __exportStar(require("./check-success-criteria"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,2DAAyC"}
@@ -0,0 +1,6 @@
1
+ import type { CriteriaObject, RegexpSuccessCriteria, JsonPathSuccessCriteria } from '../../../types';
2
+ export declare function isRegexpSuccessCriteria(criteria: CriteriaObject): criteria is RegexpSuccessCriteria;
3
+ export declare function isJSONPathSuccessCriteria(criteria: CriteriaObject): criteria is JsonPathSuccessCriteria;
4
+ export declare const ALLOWED_EXPRESSION_KEYS: string[];
5
+ export declare function validateSuccessCriteria(successCriteria: CriteriaObject[]): void;
6
+ //# sourceMappingURL=validate-success-criteria.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-success-criteria.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/validate-success-criteria.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,QAAQ,IAAI,qBAAqB,CAEnC;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,cAAc,GACvB,QAAQ,IAAI,uBAAuB,CAMrC;AAED,eAAO,MAAM,uBAAuB,UAYnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,cAAc,EAAE,QAyCxE"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALLOWED_EXPRESSION_KEYS = void 0;
4
+ exports.isRegexpSuccessCriteria = isRegexpSuccessCriteria;
5
+ exports.isJSONPathSuccessCriteria = isJSONPathSuccessCriteria;
6
+ exports.validateSuccessCriteria = validateSuccessCriteria;
7
+ function isRegexpSuccessCriteria(criteria) {
8
+ return criteria.type === 'regex';
9
+ }
10
+ function isJSONPathSuccessCriteria(criteria) {
11
+ const typeValue = criteria?.type;
12
+ return (typeValue === 'jsonpath' || (typeof typeValue === 'object' && typeValue?.type === 'jsonpath'));
13
+ }
14
+ exports.ALLOWED_EXPRESSION_KEYS = [
15
+ '$url',
16
+ '$method',
17
+ '$statusCode',
18
+ '$request',
19
+ '$response',
20
+ '$inputs',
21
+ '$outputs',
22
+ '$steps',
23
+ '$workflows',
24
+ '$sourceDescriptions',
25
+ '$components',
26
+ ];
27
+ function validateSuccessCriteria(successCriteria) {
28
+ successCriteria.forEach((criteria) => {
29
+ const { condition } = criteria;
30
+ if (isRegexpSuccessCriteria(criteria)) {
31
+ const { context } = criteria;
32
+ const regex = /\$[a-zA-Z_]\w*/g;
33
+ const matches = context.match(regex);
34
+ if (!matches) {
35
+ throw new Error(`"${context}" does not contain any valid context.`);
36
+ }
37
+ const invalidKeys = matches.filter((key) => !exports.ALLOWED_EXPRESSION_KEYS.includes(key));
38
+ if (invalidKeys.length) {
39
+ throw new Error(`Success criteria context "${context}" is not allowed.`);
40
+ }
41
+ }
42
+ else if (isJSONPathSuccessCriteria(criteria)) {
43
+ if (!criteria.context) {
44
+ throw new Error(`jsonpath success criteria context is required.`);
45
+ }
46
+ if (!criteria.condition) {
47
+ throw new Error(`jsonpath success criteria condition is required.`);
48
+ }
49
+ }
50
+ else {
51
+ const regex = /\$[a-zA-Z_]\w*/g;
52
+ const matches = condition.match(regex);
53
+ if (!matches) {
54
+ return;
55
+ }
56
+ const invalidKeys = matches.filter((key) => !exports.ALLOWED_EXPRESSION_KEYS.includes(key));
57
+ if (invalidKeys.length) {
58
+ throw new Error(`Success criteria condition ${condition} is not allowed.`);
59
+ }
60
+ }
61
+ });
62
+ }
63
+ //# sourceMappingURL=validate-success-criteria.js.map