@api-client/core 0.9.21 → 0.9.23

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 (228) hide show
  1. package/build/browser.d.ts +11 -11
  2. package/build/browser.js +13 -16
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +11 -11
  5. package/build/index.js +13 -16
  6. package/build/index.js.map +1 -1
  7. package/build/src/data/DataExtractor.d.ts +66 -0
  8. package/build/src/data/DataExtractor.js +177 -0
  9. package/build/src/data/DataExtractor.js.map +1 -0
  10. package/build/src/data/RequestDataExtractor.d.ts +4 -1
  11. package/build/src/data/RequestDataExtractor.js +13 -26
  12. package/build/src/data/RequestDataExtractor.js.map +1 -1
  13. package/build/src/models/Request.d.ts +2 -2
  14. package/build/src/models/Request.js +1 -1
  15. package/build/src/models/Request.js.map +1 -1
  16. package/build/src/models/RequestLog.d.ts +1 -1
  17. package/build/src/models/{http-actions → http-flows}/AssertionError.d.ts +0 -0
  18. package/build/src/models/{http-actions → http-flows}/AssertionError.js +0 -0
  19. package/build/src/models/http-flows/AssertionError.js.map +1 -0
  20. package/build/src/models/{http-actions → http-flows}/HttpAssertion.d.ts +0 -0
  21. package/build/src/models/{http-actions → http-flows}/HttpAssertion.js +0 -0
  22. package/build/src/models/http-flows/HttpAssertion.js.map +1 -0
  23. package/build/src/models/{http-actions → http-flows}/HttpFlows.d.ts +5 -38
  24. package/build/src/models/{http-actions → http-flows}/HttpFlows.js +4 -0
  25. package/build/src/models/http-flows/HttpFlows.js.map +1 -0
  26. package/build/src/models/{http-actions → http-flows}/HttpStep.d.ts +0 -0
  27. package/build/src/models/{http-actions → http-flows}/HttpStep.js +0 -0
  28. package/build/src/models/http-flows/HttpStep.js.map +1 -0
  29. package/build/src/models/{http-actions → http-flows}/LegacyTranslator.d.ts +2 -2
  30. package/build/src/models/{http-actions → http-flows}/LegacyTranslator.js +92 -46
  31. package/build/src/models/http-flows/LegacyTranslator.js.map +1 -0
  32. package/build/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.d.ts +0 -0
  33. package/build/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.js +0 -0
  34. package/build/src/models/http-flows/steps/assertion/EqualAssertion.js.map +1 -0
  35. package/build/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.d.ts +0 -0
  36. package/build/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.js +0 -0
  37. package/build/src/models/http-flows/steps/assertion/GreaterThanAssertion.js.map +1 -0
  38. package/build/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.d.ts +0 -0
  39. package/build/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.js +0 -0
  40. package/build/src/models/http-flows/steps/assertion/IncludesAssertion.js.map +1 -0
  41. package/build/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.d.ts +0 -0
  42. package/build/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.js +0 -0
  43. package/build/src/models/http-flows/steps/assertion/IsEmptyAssertion.js.map +1 -0
  44. package/build/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.d.ts +0 -0
  45. package/build/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.js +0 -0
  46. package/build/src/models/http-flows/steps/assertion/IsNotEmptyAssertion.js.map +1 -0
  47. package/build/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.d.ts +0 -0
  48. package/build/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.js +0 -0
  49. package/build/src/models/http-flows/steps/assertion/LengthOfAssertion.js.map +1 -0
  50. package/build/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.d.ts +0 -0
  51. package/build/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.js +0 -0
  52. package/build/src/models/http-flows/steps/assertion/LessThanAssertion.js.map +1 -0
  53. package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.d.ts +0 -0
  54. package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.js +0 -0
  55. package/build/src/models/http-flows/steps/assertion/MatchesAssertion.js.map +1 -0
  56. package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.d.ts +0 -0
  57. package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.js +0 -0
  58. package/build/src/models/http-flows/steps/assertion/MatchesSchemaAssertion.js.map +1 -0
  59. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.d.ts +0 -0
  60. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.js +0 -0
  61. package/build/src/models/http-flows/steps/assertion/NotEqualAssertion.js.map +1 -0
  62. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.d.ts +0 -0
  63. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.js +0 -0
  64. package/build/src/models/http-flows/steps/assertion/NotIncludesAssertion.js.map +1 -0
  65. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.d.ts +0 -0
  66. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.js +0 -0
  67. package/build/src/models/http-flows/steps/assertion/NotOkAssertion.js.map +1 -0
  68. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.d.ts +0 -0
  69. package/build/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.js +0 -0
  70. package/build/src/models/http-flows/steps/assertion/NotToBeAssertion.js.map +1 -0
  71. package/build/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.d.ts +0 -0
  72. package/build/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.js +0 -0
  73. package/build/src/models/http-flows/steps/assertion/OkAssertion.js.map +1 -0
  74. package/build/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.d.ts +0 -0
  75. package/build/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.js +0 -0
  76. package/build/src/models/http-flows/steps/assertion/ToBeAssertion.js.map +1 -0
  77. package/build/src/models/{http-actions → http-flows}/steps/assertion/index.d.ts +0 -0
  78. package/build/src/models/{http-actions → http-flows}/steps/assertion/index.js +0 -0
  79. package/build/src/models/http-flows/steps/assertion/index.js.map +1 -0
  80. package/build/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.d.ts +5 -1
  81. package/build/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.js +6 -1
  82. package/build/src/models/http-flows/steps/data/DeleteCookieStep.js.map +1 -0
  83. package/build/src/models/http-flows/steps/data/DeleteVariableStep.d.ts +36 -0
  84. package/build/src/models/http-flows/steps/data/DeleteVariableStep.js +44 -0
  85. package/build/src/models/http-flows/steps/data/DeleteVariableStep.js.map +1 -0
  86. package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.d.ts +0 -0
  87. package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.js +0 -0
  88. package/build/src/models/http-flows/steps/data/ReadDataSourceStep.js.map +1 -0
  89. package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.d.ts +0 -0
  90. package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.js +0 -0
  91. package/build/src/models/http-flows/steps/data/ReadDataStep.js.map +1 -0
  92. package/build/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.d.ts +0 -0
  93. package/build/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.js +0 -0
  94. package/build/src/models/http-flows/steps/data/ReadValueStep.js.map +1 -0
  95. package/build/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.d.ts +2 -1
  96. package/build/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.js +2 -1
  97. package/build/src/models/http-flows/steps/data/SetCookieStep.js.map +1 -0
  98. package/build/src/models/{http-actions → http-flows}/steps/data/SetDataStep.d.ts +0 -0
  99. package/build/src/models/{http-actions → http-flows}/steps/data/SetDataStep.js +0 -0
  100. package/build/src/models/http-flows/steps/data/SetDataStep.js.map +1 -0
  101. package/build/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.d.ts +0 -0
  102. package/build/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.js +0 -0
  103. package/build/src/models/http-flows/steps/data/SetVariableStep.js.map +1 -0
  104. package/build/src/models/{http-actions → http-flows}/steps/data/index.d.ts +1 -0
  105. package/build/src/models/{http-actions → http-flows}/steps/data/index.js +1 -0
  106. package/build/src/models/http-flows/steps/data/index.js.map +1 -0
  107. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.d.ts +0 -0
  108. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.js +0 -0
  109. package/build/src/models/http-flows/steps/transformation/AsLowerCaseStep.js.map +1 -0
  110. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.d.ts +0 -0
  111. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.js +0 -0
  112. package/build/src/models/http-flows/steps/transformation/AsNumberStep.js.map +1 -0
  113. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.d.ts +0 -0
  114. package/build/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.js +0 -0
  115. package/build/src/models/http-flows/steps/transformation/AsUpperCaseStep.js.map +1 -0
  116. package/build/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.d.ts +0 -0
  117. package/build/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.js +0 -0
  118. package/build/src/models/http-flows/steps/transformation/RoundStep.js.map +1 -0
  119. package/build/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.d.ts +0 -0
  120. package/build/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.js +0 -0
  121. package/build/src/models/http-flows/steps/transformation/SubstringStep.js.map +1 -0
  122. package/build/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.d.ts +0 -0
  123. package/build/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.js +0 -0
  124. package/build/src/models/http-flows/steps/transformation/TrimStep.js.map +1 -0
  125. package/build/src/models/{http-actions → http-flows}/steps/transformation/index.d.ts +0 -0
  126. package/build/src/models/{http-actions → http-flows}/steps/transformation/index.js +0 -0
  127. package/build/src/models/http-flows/steps/transformation/index.js.map +1 -0
  128. package/build/src/proxy/HttpProjectProxy.d.ts +4 -0
  129. package/build/src/proxy/HttpProjectProxy.js.map +1 -1
  130. package/build/src/proxy/RequestProxy.d.ts +6 -2
  131. package/build/src/proxy/RequestProxy.js.map +1 -1
  132. package/build/src/runtime/http-runner/ConditionCheck.d.ts +1 -1
  133. package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +7 -57
  134. package/build/src/runtime/http-runner/HttpAssertionRunner.js +24 -382
  135. package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -1
  136. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +10 -57
  137. package/build/src/runtime/http-runner/HttpFlowRunner.js +45 -203
  138. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  139. package/build/src/runtime/http-runner/HttpFlows.d.ts +119 -0
  140. package/build/src/runtime/http-runner/HttpFlows.js +541 -0
  141. package/build/src/runtime/http-runner/HttpFlows.js.map +1 -0
  142. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +2 -2
  143. package/package.json +1 -1
  144. package/src/data/DataExtractor.ts +188 -0
  145. package/src/data/RequestDataExtractor.ts +14 -26
  146. package/src/models/Request.ts +3 -3
  147. package/src/models/RequestLog.ts +1 -1
  148. package/src/models/{http-actions → http-flows}/AssertionError.ts +0 -0
  149. package/src/models/{http-actions → http-flows}/HttpAssertion.ts +0 -0
  150. package/src/models/{http-actions → http-flows}/HttpFlows.ts +5 -39
  151. package/src/models/{http-actions → http-flows}/HttpStep.ts +0 -0
  152. package/src/models/{http-actions → http-flows}/LegacyTranslator.ts +89 -31
  153. package/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.ts +0 -0
  154. package/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.ts +0 -0
  155. package/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.ts +0 -0
  156. package/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.ts +0 -0
  157. package/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.ts +0 -0
  158. package/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.ts +0 -0
  159. package/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.ts +0 -0
  160. package/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.ts +0 -0
  161. package/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.ts +0 -0
  162. package/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.ts +0 -0
  163. package/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.ts +0 -0
  164. package/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.ts +0 -0
  165. package/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.ts +0 -0
  166. package/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.ts +0 -0
  167. package/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.ts +0 -0
  168. package/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.ts +6 -1
  169. package/src/models/http-flows/steps/data/DeleteVariableStep.ts +78 -0
  170. package/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.ts +0 -0
  171. package/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.ts +0 -0
  172. package/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.ts +0 -0
  173. package/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.ts +4 -2
  174. package/src/models/{http-actions → http-flows}/steps/data/SetDataStep.ts +0 -0
  175. package/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.ts +0 -0
  176. package/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.ts +0 -0
  177. package/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.ts +0 -0
  178. package/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.ts +0 -0
  179. package/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.ts +0 -0
  180. package/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.ts +0 -0
  181. package/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.ts +0 -0
  182. package/src/proxy/HttpProjectProxy.ts +4 -0
  183. package/src/proxy/RequestProxy.ts +6 -2
  184. package/src/runtime/http-runner/ConditionCheck.ts +1 -1
  185. package/src/runtime/http-runner/HttpAssertionRunner.ts +28 -410
  186. package/src/runtime/http-runner/HttpFlowRunner.ts +47 -212
  187. package/src/runtime/http-runner/HttpFlows.ts +576 -0
  188. package/src/runtime/http-runner/HttpRequestRunner.ts +2 -2
  189. package/build/src/data/DataUtils.d.ts +0 -40
  190. package/build/src/data/DataUtils.js +0 -106
  191. package/build/src/data/DataUtils.js.map +0 -1
  192. package/build/src/models/http-actions/AssertionError.js.map +0 -1
  193. package/build/src/models/http-actions/HttpAssertion.js.map +0 -1
  194. package/build/src/models/http-actions/HttpFlows.js.map +0 -1
  195. package/build/src/models/http-actions/HttpStep.js.map +0 -1
  196. package/build/src/models/http-actions/LegacyTranslator.js.map +0 -1
  197. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +0 -1
  198. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +0 -1
  199. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +0 -1
  200. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +0 -1
  201. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +0 -1
  202. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +0 -1
  203. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +0 -1
  204. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +0 -1
  205. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +0 -1
  206. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +0 -1
  207. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +0 -1
  208. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +0 -1
  209. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +0 -1
  210. package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +0 -1
  211. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +0 -1
  212. package/build/src/models/http-actions/steps/assertion/index.js.map +0 -1
  213. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +0 -1
  214. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +0 -1
  215. package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +0 -1
  216. package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +0 -1
  217. package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +0 -1
  218. package/build/src/models/http-actions/steps/data/SetDataStep.js.map +0 -1
  219. package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +0 -1
  220. package/build/src/models/http-actions/steps/data/index.js.map +0 -1
  221. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +0 -1
  222. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +0 -1
  223. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +0 -1
  224. package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +0 -1
  225. package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +0 -1
  226. package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +0 -1
  227. package/build/src/models/http-actions/steps/transformation/index.js.map +0 -1
  228. package/src/data/DataUtils.ts +0 -108
@@ -0,0 +1,188 @@
1
+ import { IHttpRequest, HttpRequest } from '../models/HttpRequest.js';
2
+ import { ISentRequest, SentRequest } from '../models/SentRequest.js';
3
+ import { IHttpResponse, HttpResponse } from '../models/HttpResponse.js';
4
+ import { IErrorResponse, ErrorResponse } from '../models/ErrorResponse.js';
5
+ import { Headers } from '../lib/headers/Headers.js';
6
+ import { DataReader } from './DataReader.js';
7
+ import { JmespathReader } from './JmespathReader.js';
8
+ import { XmlReader } from './XmlReader.js';
9
+ import { UrlEncodedReader } from './UrlEncodedReader.js';
10
+ import { CookieParser } from '../cookies/CookieParser.js';
11
+
12
+ type DataInput = HttpRequest | SentRequest | IHttpRequest | ISentRequest | IHttpResponse | HttpResponse | IErrorResponse | ErrorResponse | undefined;
13
+
14
+ /**
15
+ * This is a factory class for the `RequestDataExtractor`.
16
+ */
17
+ export class DataExtractor {
18
+ /**
19
+ * Reads the value of a cookie.
20
+ * @param name The name of the cookie to read.
21
+ * @param input The response object.
22
+ */
23
+ static readCookieValue(name: string, input: IHttpResponse | HttpResponse | IErrorResponse | ErrorResponse | undefined): string | undefined {
24
+ const headers = this.readHeaders(input);
25
+ if (!headers) {
26
+ return undefined;
27
+ }
28
+ const parsed = new Headers(headers);
29
+ const header = parsed.get('set-cookie');
30
+ if (!header) {
31
+ return undefined;
32
+ }
33
+ const cookies = CookieParser.parseRelaxed(header);
34
+ const cookie = cookies.find(i => i.name === name);
35
+ if (cookie) {
36
+ return cookie.value;
37
+ }
38
+ return undefined;
39
+ }
40
+
41
+ static readHeaders(obj: DataInput): string {
42
+ if (!obj) {
43
+ return '';
44
+ }
45
+ const typedInstance = obj as HttpRequest | SentRequest;
46
+ if (typedInstance.headersModel && typeof typedInstance.headersModel.toRawString === 'function') {
47
+ return typedInstance.headersModel.toString();
48
+ }
49
+ const typedSchema = obj as IHttpRequest | ISentRequest;
50
+ if (Array.isArray(typedSchema.headersModel)) {
51
+ const headers = Headers.fromPropertyArray(typedSchema.headersModel);
52
+ return headers.toString();
53
+ }
54
+ return obj.headers || '';
55
+ }
56
+
57
+ /**
58
+ * Reads value from the body.
59
+ * @param value The read body value as string
60
+ * @param mime The body mime
61
+ * @param path THe path to read.
62
+ * @returns The extracted value.
63
+ */
64
+ static async extractBody(value: string, mime: string, path: string): Promise<string | undefined> {
65
+ let reader: DataReader | undefined;
66
+ if (mime.includes('json')) {
67
+ // reader = new JsonReader();
68
+ reader = new JmespathReader();
69
+ } else if (mime.includes('xml')) {
70
+ reader = new XmlReader();
71
+ } else if (mime.includes('x-www-form-urlencoded')) {
72
+ reader = new UrlEncodedReader();
73
+ }
74
+ if (!reader) {
75
+ return undefined;
76
+ }
77
+ await reader.writePayload(value);
78
+ return reader.getValue(path) as Promise<string>;
79
+ }
80
+
81
+ /**
82
+ * Returns the value for path for given source object
83
+ *
84
+ * @param url An url to parse.
85
+ * @param path Path to the data
86
+ * @return Value for the path.
87
+ */
88
+ static getDataUrl(url: string, path: string[]): string | number | undefined {
89
+ if (!path || path.length === 0 || !url) {
90
+ return url;
91
+ }
92
+ let value: URL | undefined;
93
+ try {
94
+ value = new URL(url);
95
+ } catch (e) {
96
+ //
97
+ }
98
+ if (!value) {
99
+ return undefined;
100
+ }
101
+ switch (path[0]) {
102
+ case 'host':
103
+ return value.host;
104
+ case 'protocol':
105
+ return value.protocol;
106
+ case 'path':
107
+ return value.pathname;
108
+ case 'query':
109
+ return DataExtractor.readUrlQueryValue(value, path[1]) || undefined;
110
+ case 'hash':
111
+ return DataExtractor.readUrlHashValue(value, path[1]) || undefined;
112
+ default:
113
+ throw new Error(`Unknown path in the URL: ${path}`);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Reads value of the URL query parameters.
119
+ *
120
+ * The `?` at the beginning of the query string is removed.
121
+ *
122
+ * @param url The URL object instance
123
+ * @param param Param name to return. If not set then it returns whole query string value.
124
+ * @return Full query string value if `param` is not set or parameter
125
+ * value. This function does not returns `null` values.
126
+ */
127
+ static readUrlQueryValue(url: URL, param?: string): string | null {
128
+ if (!param) {
129
+ let v = url.search || '';
130
+ if (v[0] === '?') {
131
+ v = v.substring(1);
132
+ }
133
+ return v;
134
+ }
135
+ let value = url.searchParams.get(param);
136
+ if (!value && value !== '') {
137
+ value = null;
138
+ }
139
+ return value;
140
+ }
141
+
142
+ /**
143
+ * Reads value of the URL hash.
144
+ *
145
+ * The `#` at the beginning of the hash string is removed.
146
+ *
147
+ * If the `param` argument is set then it treats hahs value as a query
148
+ * parameters string and parses it to get the value.
149
+ *
150
+ * @param url The URL object instance
151
+ * @param param Param name to return. If not set then it returns whole hash string value.
152
+ * @return Hash parameter or whole hash value.
153
+ */
154
+ static readUrlHashValue(url: URL, param?: string): string | undefined {
155
+ let value: string | undefined = (url.hash || '').substring(1);
156
+ if (!param) {
157
+ return value;
158
+ }
159
+ const obj = new URLSearchParams(value);
160
+ value = obj.get(param) || undefined;
161
+ if (!value && value !== '') {
162
+ value = undefined;
163
+ }
164
+ return value;
165
+ }
166
+
167
+
168
+ /**
169
+ * Returns a value for the headers.
170
+ *
171
+ * @param source HTTP headers string
172
+ * @param path The path to the object
173
+ * @returns The value for the path.
174
+ */
175
+ static getDataHeaders(source: string, path: string[]): string | undefined {
176
+ if (!path || !path.length || !path[0]) {
177
+ return source;
178
+ }
179
+ const headers = new Headers(source);
180
+ const lowerName = path[0].toLowerCase();
181
+ for (const [name, value] of headers) {
182
+ if (name.toLowerCase() === lowerName) {
183
+ return value;
184
+ }
185
+ }
186
+ return undefined;
187
+ }
188
+ }
@@ -1,14 +1,10 @@
1
- import * as DataUtils from './DataUtils.js';
2
1
  import { IHttpRequest, HttpRequest } from '../models/HttpRequest.js';
3
2
  import { ISentRequest, SentRequest } from '../models/SentRequest.js';
4
3
  import { IHttpResponse, HttpResponse } from '../models/HttpResponse.js';
5
4
  import { IErrorResponse, ErrorResponse } from '../models/ErrorResponse.js';
6
- import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from '../models/http-actions/HttpFlows.js';
5
+ import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from '../models/http-flows/HttpFlows.js';
7
6
  import { Headers } from '../lib/headers/Headers.js';
8
- import { JsonReader } from './JsonReader.js';
9
- import { XmlReader } from './XmlReader.js';
10
- import { UrlEncodedReader } from './UrlEncodedReader.js';
11
- import { DataReader } from './DataReader.js';
7
+ import { DataExtractor } from './DataExtractor.js';
12
8
 
13
9
  /**
14
10
  * A class to extract data from the request or the response.
@@ -47,15 +43,19 @@ export class RequestDataExtractor {
47
43
  const args = path ? path.split('.') : [];
48
44
  switch (data) {
49
45
  case 'url':
50
- return DataUtils.getDataUrl(this.getUrl(), args);
46
+ return DataExtractor.getDataUrl(this.getUrl(), args);
51
47
  case 'headers':
52
- return DataUtils.getDataHeaders(this.getHeaders(source), args);
48
+ return DataExtractor.getDataHeaders(this.getHeaders(source), args);
53
49
  case 'status':
54
50
  return this.response && this.response.status;
51
+ case 'statusText':
52
+ return this.response && this.response.statusText;
55
53
  case 'method':
56
54
  return this.request.method;
57
55
  case 'body':
58
56
  return this.processBody(path, source);
57
+ case 'cookie':
58
+ return DataExtractor.readCookieValue(args[0], this.response);
59
59
  default:
60
60
  throw new Error(`Unknown data ${data} for ${source} data`);
61
61
  }
@@ -74,10 +74,7 @@ export class RequestDataExtractor {
74
74
  * @returns The headers from the request / response
75
75
  */
76
76
  getHeaders(source?: FlowSourceEnum): string {
77
- if (source === 'request') {
78
- return this.request.headers || '';
79
- }
80
- return this.response && this.response.headers || '';
77
+ return DataExtractor.readHeaders(source === 'request' ? this.request : this.response);
81
78
  }
82
79
 
83
80
  async processBody(path?: string, source?: FlowSourceEnum): Promise<string | undefined> {
@@ -97,7 +94,7 @@ export class RequestDataExtractor {
97
94
  if (!mime) {
98
95
  return undefined;
99
96
  }
100
- return this.extractBody(value, mime, path);
97
+ return DataExtractor.extractBody(value, mime, path);
101
98
  }
102
99
 
103
100
  /**
@@ -114,19 +111,10 @@ export class RequestDataExtractor {
114
111
  return undefined;
115
112
  }
116
113
 
114
+ /**
115
+ * @deprecated Use `DataExtractor.extractBody()` instead.
116
+ */
117
117
  async extractBody(value: string, mime: string, path: string): Promise<string | undefined> {
118
- let reader: DataReader | undefined;
119
- if (mime.includes('json')) {
120
- reader = new JsonReader();
121
- } else if (mime.includes('xml')) {
122
- reader = new XmlReader();
123
- } else if (mime.includes('x-www-form-urlencoded')) {
124
- reader = new UrlEncodedReader();
125
- }
126
- if (!reader) {
127
- return undefined;
128
- }
129
- await reader.writePayload(value);
130
- return reader.getValue(path) as Promise<string>;
118
+ return DataExtractor.extractBody(value, mime, path)
131
119
  }
132
120
  }
@@ -13,9 +13,9 @@ import { ARCSavedRequest, ARCHistoryRequest } from './legacy/request/ArcRequest.
13
13
  import { ErrorResponse as LegacyErrorResponse, Response as LegacyResponse } from './legacy/request/ArcResponse.js';
14
14
  import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
15
15
  import { Normalizer } from './legacy/Normalizer.js';
16
- import { IHttpFlow } from './http-actions/HttpFlows.js';
17
- import { IHttpAssertion } from './http-actions/HttpAssertion.js';
18
- import { LegacyTranslator } from './http-actions/LegacyTranslator.js';
16
+ import { IHttpFlow } from './http-flows/HttpFlows.js';
17
+ import { IHttpAssertion } from './http-flows/HttpAssertion.js';
18
+ import { LegacyTranslator } from './http-flows/LegacyTranslator.js';
19
19
 
20
20
  export const Kind = 'Core#Request';
21
21
  export const createdSymbol = Symbol('created');
@@ -4,7 +4,7 @@ import { IErrorResponse, ErrorResponse } from './ErrorResponse.js';
4
4
  import { IResponse, Response } from './Response.js';
5
5
  import { IRequestsSize, RequestsSize } from './RequestsSize.js';
6
6
  import { ResponseRedirect as LegacyRedirect } from './legacy/request/ArcResponse.js';
7
- import { AssertionResult } from './http-actions/HttpAssertion.js';
7
+ import { AssertionResult } from './http-flows/HttpAssertion.js';
8
8
 
9
9
  export const Kind = 'Core#ResponseLog';
10
10
 
@@ -1,4 +1,3 @@
1
- import { AssertionEnum } from './HttpAssertion.js';
2
1
  import { IHttpStep } from './HttpStep.js';
3
2
 
4
3
  export enum FlowSourceEnum {
@@ -28,6 +27,10 @@ export enum FlowResponseDataEnum {
28
27
  status = "status",
29
28
  statusText = "statusText",
30
29
  headers = "headers",
30
+ /**
31
+ * Reads the value of a cookie in the `set-cookie` header.
32
+ */
33
+ cookie = "cookie",
31
34
  body = "body"
32
35
  }
33
36
 
@@ -54,7 +57,7 @@ export interface IHttpFlow {
54
57
  /**
55
58
  * A condition to check before running the flow.
56
59
  */
57
- condition?: IHttpCondition;
60
+ condition?: IHttpAction;
58
61
  }
59
62
 
60
63
  /**
@@ -76,40 +79,3 @@ export interface IHttpAction {
76
79
  */
77
80
  steps: IHttpStep[];
78
81
  }
79
-
80
- /**
81
- * A condition to execute for an action.
82
- */
83
- export interface IHttpCondition {
84
- /**
85
- * The main data source.
86
- * In the legacy actions this was `type`.
87
- */
88
- source?: FlowSourceEnum;
89
- /**
90
- * Source of the data.
91
- * In the legacy actions this was `source`.
92
- * This is not required when the source is not `request` or `response`.
93
- */
94
- data?: FlowRequestDataEnum | FlowResponseDataEnum;
95
- /**
96
- * The path to the data.
97
- * For JSON value use https://jmespath.org/ syntax.
98
- * For XML use xpath.
99
- * For any other use a simple path to the data separated by dot (e.g. headers.content-type)
100
- */
101
- path?: string;
102
- /**
103
- * The comparison operator.
104
- */
105
- operator?: AssertionEnum;
106
- /**
107
- * The value to compare the read result.
108
- * In runtime, the type is casted to the same type as read value.
109
- *
110
- * When this is not set it compares to an empty string value or `0`.
111
- *
112
- * In ARC actions this was the `predictedValue`.
113
- */
114
- value?: string;
115
- }
@@ -4,16 +4,21 @@ import {
4
4
  SetCookieConfig, SetVariableConfig, DeleteCookieConfig, DataSourceConfiguration
5
5
  } from '../../models/legacy/actions/Actions.js';
6
6
  import {
7
- IHttpFlow, IHttpAction, IHttpCondition, FlowSourceEnum, FlowRequestDataEnum,
7
+ IHttpFlow, IHttpAction, FlowSourceEnum, FlowRequestDataEnum,
8
8
  FlowResponseDataEnum,
9
9
  } from './HttpFlows.js';
10
10
  import { AmfNamespace } from '../../amf/definitions/Namespace.js';
11
- import { AssertionEnum } from './HttpAssertion.js';
12
11
  import { IHttpStep } from './HttpStep.js';
13
- import { IReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js';
12
+ import { IReadDataStep, ReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js';
14
13
  import { ISetDataStep, SetDataStepKind } from './steps/data/SetDataStep.js';
15
14
  import { ISetCookieStep, SetCookieStepKind } from './steps/data/SetCookieStep.js';
16
15
  import { DeleteCookieStepKind, IDeleteCookieStep } from './steps/data/DeleteCookieStep.js';
16
+ import { IncludesAssertion } from './steps/assertion/IncludesAssertion.js';
17
+ import { EqualAssertion } from './steps/assertion/EqualAssertion.js';
18
+ import { GreaterThanAssertion } from './steps/assertion/GreaterThanAssertion.js';
19
+ import { LessThanAssertion } from './steps/assertion/LessThanAssertion.js';
20
+ import { NotEqualAssertion } from './steps/assertion/NotEqualAssertion.js';
21
+ import { MatchesAssertion } from './steps/assertion/MatchesAssertion.js';
17
22
 
18
23
  /**
19
24
  * Allows to translate the old ARC actions into Action flows.
@@ -64,45 +69,98 @@ export class LegacyTranslator {
64
69
  return flow;
65
70
  }
66
71
 
67
- protected static _translateCondition(runnable: LegacyCondition): IHttpCondition | undefined {
72
+ protected static _translateCondition(runnable: LegacyCondition): IHttpAction | undefined {
68
73
  const { source, alwaysPass, operator, path, predictedValue, type } = runnable;
69
74
  if (alwaysPass) {
70
75
  // in the flow, if there's no condition the steps are always executed.
71
76
  return undefined
72
77
  }
73
-
74
- const result: IHttpCondition = {};
75
- if (typeof path === 'string') {
76
- result.path = path;
78
+ if (!path || !type) {
79
+ return undefined;
77
80
  }
78
- if (type) {
79
- switch (type) {
80
- case 'request': result.source = FlowSourceEnum.request; break;
81
- case 'response': result.source = FlowSourceEnum.response; break;
82
- }
81
+ if (!['request', 'response'].includes(type)) {
82
+ return;
83
83
  }
84
- if (type && source) {
84
+
85
+ const result: IHttpAction = {
86
+ steps: [],
87
+ };
88
+ const readData = new ReadDataStep();
89
+ readData.source = type === 'request' ? FlowSourceEnum.request : FlowSourceEnum.response;
90
+ readData.path = path;
91
+ if (source) {
85
92
  if (type === 'request') {
86
- result.data = source as FlowRequestDataEnum;
87
- }
88
- if (type === 'response') {
89
- result.data = source as FlowResponseDataEnum;
93
+ readData.data = source as FlowRequestDataEnum;
94
+ } else if (type === 'response') {
95
+ readData.data = source as FlowResponseDataEnum;
90
96
  }
91
97
  }
92
- if (predictedValue) {
93
- result.value = String(predictedValue);
94
- }
95
- if (operator) {
96
- switch (operator) {
97
- case 'contains': result.operator = AssertionEnum.contains; break;
98
- case 'equal': result.operator = AssertionEnum.equal; break;
99
- case 'greater-than': result.operator = AssertionEnum.greaterThan; break;
100
- case 'greater-than-equal': result.operator = AssertionEnum.greaterThanEqual; break;
101
- case 'less-than': result.operator = AssertionEnum.lessThan; break;
102
- case 'less-than-equal': result.operator = AssertionEnum.lessThanEqual; break;
103
- case 'not-equal': result.operator = AssertionEnum.notEqual; break;
104
- case 'regex': result.operator = AssertionEnum.regex; break;
98
+ result.steps.push(readData.toJSON());
99
+ if (!operator) {
100
+ return result;
101
+ }
102
+ if (operator === 'contains') {
103
+ const assertion = new IncludesAssertion();
104
+ if (predictedValue) {
105
+ assertion.value = String(predictedValue);
106
+ }
107
+ result.steps.push(assertion.toJSON());
108
+ } else if (operator === 'equal') {
109
+ const assertion = new EqualAssertion();
110
+ if (predictedValue) {
111
+ assertion.value = String(predictedValue);
112
+ }
113
+ result.steps.push(assertion.toJSON());
114
+ } else if (operator === 'not-equal') {
115
+ const assertion = new NotEqualAssertion();
116
+ if (predictedValue) {
117
+ assertion.value = String(predictedValue);
118
+ }
119
+ result.steps.push(assertion.toJSON());
120
+ } else if (operator === 'greater-than') {
121
+ const assertion = new GreaterThanAssertion();
122
+ if (predictedValue) {
123
+ const typed = Number(predictedValue);
124
+ if (!Number.isNaN(typed)) {
125
+ assertion.value = typed;
126
+ }
127
+ }
128
+ result.steps.push(assertion.toJSON());
129
+ } else if (operator === 'greater-than-equal') {
130
+ const assertion = new GreaterThanAssertion();
131
+ assertion.equal = true;
132
+ if (predictedValue) {
133
+ const typed = Number(predictedValue);
134
+ if (!Number.isNaN(typed)) {
135
+ assertion.value = typed;
136
+ }
137
+ }
138
+ result.steps.push(assertion.toJSON());
139
+ } else if (operator === 'less-than') {
140
+ const assertion = new LessThanAssertion();
141
+ if (predictedValue) {
142
+ const typed = Number(predictedValue);
143
+ if (!Number.isNaN(typed)) {
144
+ assertion.value = typed;
145
+ }
146
+ }
147
+ result.steps.push(assertion.toJSON());
148
+ } else if (operator === 'less-than-equal') {
149
+ const assertion = new LessThanAssertion();
150
+ assertion.equal = true;
151
+ if (predictedValue) {
152
+ const typed = Number(predictedValue);
153
+ if (!Number.isNaN(typed)) {
154
+ assertion.value = typed;
155
+ }
156
+ }
157
+ result.steps.push(assertion.toJSON());
158
+ } else if (operator === 'regex') {
159
+ const assertion = new MatchesAssertion();
160
+ if (predictedValue) {
161
+ assertion.value = String(predictedValue);
105
162
  }
163
+ result.steps.push(assertion.toJSON());
106
164
  }
107
165
  return result;
108
166
  }
@@ -33,11 +33,16 @@ export class DeleteCookieStep extends HttpStep {
33
33
  */
34
34
  name?: string;
35
35
 
36
- static byName(name: string): DeleteCookieStep {
36
+ /**
37
+ * @param name The name of the cookie
38
+ * @param url Optionally, the URL of the cookie.
39
+ */
40
+ static byName(name: string, url?: string): DeleteCookieStep {
37
41
  return new DeleteCookieStep({
38
42
  kind: DeleteCookieStepKind,
39
43
  enabled: true,
40
44
  name,
45
+ url,
41
46
  });
42
47
  }
43
48
 
@@ -0,0 +1,78 @@
1
+ import { HttpStep, IHttpStep } from "../../HttpStep.js";
2
+
3
+ export const DeleteVariableStepKind = 'HttpAction#DeleteVariable';
4
+
5
+ /**
6
+ * A step that deletes a variable.
7
+ */
8
+ export interface IDeleteVariableStep extends IHttpStep {
9
+ kind: typeof DeleteVariableStepKind;
10
+ /**
11
+ * The name of the variable to delete
12
+ */
13
+ name: string;
14
+ }
15
+
16
+
17
+ export class DeleteVariableStep extends HttpStep {
18
+ override kind = DeleteVariableStepKind;
19
+
20
+ /**
21
+ * The name of the variable to delete
22
+ */
23
+ name = '';
24
+
25
+ /**
26
+ * Creates the step from values.
27
+ * @param name The name of the variable to delete
28
+ */
29
+ constructor(name: string);
30
+
31
+ /**
32
+ * Creates the step from serialized schema.
33
+ * @param init The serialized step values.
34
+ */
35
+ constructor(init: IDeleteVariableStep);
36
+
37
+ /**
38
+ * Creates an empty step.
39
+ */
40
+ constructor();
41
+
42
+ constructor(nameOrInit?: string | IDeleteVariableStep) {
43
+ super();
44
+ if (!nameOrInit) {
45
+ return;
46
+ }
47
+ if (typeof nameOrInit === 'object') {
48
+ const typed = nameOrInit as IDeleteVariableStep;
49
+ this.new(typed);
50
+ } else if (typeof nameOrInit === 'string') {
51
+ this.new({
52
+ kind: DeleteVariableStepKind,
53
+ name: nameOrInit,
54
+ enabled: true,
55
+ });
56
+ }
57
+ }
58
+
59
+ override new(init: IDeleteVariableStep): void {
60
+ super.new(init);
61
+ this.kind = DeleteVariableStepKind;
62
+ this.name = init.name;
63
+ }
64
+
65
+ checkValidity(): boolean {
66
+ const { name } = this;
67
+ return !!name;
68
+ }
69
+
70
+ override toJSON(): IDeleteVariableStep {
71
+ const result: IDeleteVariableStep = {
72
+ ...super.toJSON(),
73
+ kind: DeleteVariableStepKind,
74
+ name: this.name,
75
+ };
76
+ return result;
77
+ }
78
+ }