@api-client/core 0.9.22 → 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 (225) 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/RequestProxy.d.ts +2 -2
  129. package/build/src/proxy/RequestProxy.js.map +1 -1
  130. package/build/src/runtime/http-runner/ConditionCheck.d.ts +1 -1
  131. package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +7 -57
  132. package/build/src/runtime/http-runner/HttpAssertionRunner.js +24 -382
  133. package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -1
  134. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +10 -57
  135. package/build/src/runtime/http-runner/HttpFlowRunner.js +45 -203
  136. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  137. package/build/src/runtime/http-runner/HttpFlows.d.ts +119 -0
  138. package/build/src/runtime/http-runner/HttpFlows.js +541 -0
  139. package/build/src/runtime/http-runner/HttpFlows.js.map +1 -0
  140. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +2 -2
  141. package/package.json +1 -1
  142. package/src/data/DataExtractor.ts +188 -0
  143. package/src/data/RequestDataExtractor.ts +14 -26
  144. package/src/models/Request.ts +3 -3
  145. package/src/models/RequestLog.ts +1 -1
  146. package/src/models/{http-actions → http-flows}/AssertionError.ts +0 -0
  147. package/src/models/{http-actions → http-flows}/HttpAssertion.ts +0 -0
  148. package/src/models/{http-actions → http-flows}/HttpFlows.ts +5 -39
  149. package/src/models/{http-actions → http-flows}/HttpStep.ts +0 -0
  150. package/src/models/{http-actions → http-flows}/LegacyTranslator.ts +89 -31
  151. package/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.ts +0 -0
  152. package/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.ts +0 -0
  153. package/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.ts +0 -0
  154. package/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.ts +0 -0
  155. package/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.ts +0 -0
  156. package/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.ts +0 -0
  157. package/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.ts +0 -0
  158. package/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.ts +0 -0
  159. package/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.ts +0 -0
  160. package/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.ts +0 -0
  161. package/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.ts +0 -0
  162. package/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.ts +0 -0
  163. package/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.ts +0 -0
  164. package/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.ts +0 -0
  165. package/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.ts +0 -0
  166. package/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.ts +6 -1
  167. package/src/models/http-flows/steps/data/DeleteVariableStep.ts +78 -0
  168. package/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.ts +0 -0
  169. package/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.ts +0 -0
  170. package/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.ts +0 -0
  171. package/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.ts +4 -2
  172. package/src/models/{http-actions → http-flows}/steps/data/SetDataStep.ts +0 -0
  173. package/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.ts +0 -0
  174. package/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.ts +0 -0
  175. package/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.ts +0 -0
  176. package/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.ts +0 -0
  177. package/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.ts +0 -0
  178. package/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.ts +0 -0
  179. package/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.ts +0 -0
  180. package/src/proxy/RequestProxy.ts +2 -2
  181. package/src/runtime/http-runner/ConditionCheck.ts +1 -1
  182. package/src/runtime/http-runner/HttpAssertionRunner.ts +28 -410
  183. package/src/runtime/http-runner/HttpFlowRunner.ts +47 -212
  184. package/src/runtime/http-runner/HttpFlows.ts +576 -0
  185. package/src/runtime/http-runner/HttpRequestRunner.ts +2 -2
  186. package/build/src/data/DataUtils.d.ts +0 -40
  187. package/build/src/data/DataUtils.js +0 -106
  188. package/build/src/data/DataUtils.js.map +0 -1
  189. package/build/src/models/http-actions/AssertionError.js.map +0 -1
  190. package/build/src/models/http-actions/HttpAssertion.js.map +0 -1
  191. package/build/src/models/http-actions/HttpFlows.js.map +0 -1
  192. package/build/src/models/http-actions/HttpStep.js.map +0 -1
  193. package/build/src/models/http-actions/LegacyTranslator.js.map +0 -1
  194. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +0 -1
  195. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +0 -1
  196. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +0 -1
  197. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +0 -1
  198. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +0 -1
  199. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +0 -1
  200. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +0 -1
  201. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +0 -1
  202. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +0 -1
  203. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +0 -1
  204. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +0 -1
  205. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +0 -1
  206. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +0 -1
  207. package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +0 -1
  208. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +0 -1
  209. package/build/src/models/http-actions/steps/assertion/index.js.map +0 -1
  210. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +0 -1
  211. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +0 -1
  212. package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +0 -1
  213. package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +0 -1
  214. package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +0 -1
  215. package/build/src/models/http-actions/steps/data/SetDataStep.js.map +0 -1
  216. package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +0 -1
  217. package/build/src/models/http-actions/steps/data/index.js.map +0 -1
  218. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +0 -1
  219. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +0 -1
  220. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +0 -1
  221. package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +0 -1
  222. package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +0 -1
  223. package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +0 -1
  224. package/build/src/models/http-actions/steps/transformation/index.js.map +0 -1
  225. package/src/data/DataUtils.ts +0 -108
@@ -97,8 +97,9 @@ export class SetCookieStep extends HttpStep {
97
97
  /**
98
98
  * Creates the step from values.
99
99
  * @param name The name of the variable to set
100
+ * @param url Optional URL of the cookie to set.
100
101
  */
101
- constructor(name: string);
102
+ constructor(name: string, url?: string);
102
103
 
103
104
  /**
104
105
  * Creates the step from serialized schema.
@@ -111,7 +112,7 @@ export class SetCookieStep extends HttpStep {
111
112
  */
112
113
  constructor();
113
114
 
114
- constructor(nameOrInit?: string | ISetCookieStepInit) {
115
+ constructor(nameOrInit?: string | ISetCookieStepInit, url?: string) {
115
116
  super();
116
117
  if (!nameOrInit) {
117
118
  return;
@@ -124,6 +125,7 @@ export class SetCookieStep extends HttpStep {
124
125
  kind: SetCookieStepKind,
125
126
  name: nameOrInit,
126
127
  enabled: true,
128
+ url,
127
129
  });
128
130
  }
129
131
  }
@@ -3,12 +3,12 @@ import { IRequestAuthorization } from '../models/RequestAuthorization.js';
3
3
  import { IRequestConfig } from '../models/RequestConfig.js';
4
4
  import Proxy, { IProxyResult } from "./Proxy.js";
5
5
  import { HttpCertificate } from '../models/ClientCertificate.js';
6
- import { IHttpFlow } from '../models/http-actions/HttpFlows.js';
7
6
  import { ApiError } from '../runtime/store/Errors.js';
8
7
  import { DummyLogger } from '../lib/logging/DummyLogger.js';
9
8
  import { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js';
10
9
  import { IRequestLog } from "../models/RequestLog.js";
11
- import { IHttpAssertion } from '../models/http-actions/HttpAssertion.js';
10
+ import { IHttpFlow } from '../models/http-flows/HttpFlows.js';
11
+ import { IHttpAssertion } from '../models/http-flows/HttpAssertion.js';
12
12
 
13
13
  export interface IRequestProxyInit {
14
14
  kind: typeof HttpRequestKind;
@@ -1,4 +1,4 @@
1
- import { AssertionEnum } from "../../models/http-actions/HttpAssertion";
1
+ import { AssertionEnum } from "../../models/http-flows/HttpAssertion";
2
2
 
3
3
  /**
4
4
  * Checks if values equal.
@@ -1,53 +1,32 @@
1
- import { assert } from '@esm-bundle/chai';
2
- import { HttpRequest } from "../../models/HttpRequest.js";
3
1
  import { ISentRequest } from "../../models/SentRequest.js";
4
2
  import { IResponse } from "../../models/Response.js";
5
- import { ErrorResponse, IErrorResponse } from "../../models/ErrorResponse.js";
6
- import { AssertionResult, IHttpAssertion } from "../../models/http-actions/HttpAssertion.js";
7
- import { IHttpStep } from "../../models/http-actions/HttpStep.js";
8
- import { FlowValue } from "./HttpFlowRunner.js";
9
- import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from "../../models/http-actions/HttpFlows.js";
10
- import { IReadDataSourceStep, ReadDataSourceStep, ReadDataSourceStepKind } from "../../models/http-actions/steps/data/ReadDataSourceStep.js";
11
- import { IReadValueStep, ReadValueStep, ReadValueStepKind } from "../../models/http-actions/steps/data/ReadValueStep.js";
12
- import * as DataUtils from '../../data/DataUtils.js';
13
- import { HttpResponse } from "../../models/HttpResponse.js";
14
- import { Headers } from '../../lib/headers/Headers.js';
15
- import { DataReader } from "../../data/DataReader.js";
16
- import { JmespathReader } from "../../data/JmespathReader.js";
17
- import { XmlReader } from "../../data/XmlReader.js";
18
- import { UrlEncodedReader } from "../../data/UrlEncodedReader.js";
19
- import { AsLowerCaseStepKind } from "../../models/http-actions/steps/transformation/AsLowerCaseStep.js";
20
- import { AsUpperCaseStepKind } from "../../models/http-actions/steps/transformation/AsUpperCaseStep.js";
21
- import { AsNumberStepKind } from "../../models/http-actions/steps/transformation/AsNumberStep.js";
22
- import { IRoundStep, RoundStepKind } from "../../models/http-actions/steps/transformation/RoundStep.js";
23
- import { ISubstringStep, SubstringStepKind } from "../../models/http-actions/steps/transformation/SubstringStep.js";
24
- import { TrimStepKind } from "../../models/http-actions/steps/transformation/TrimStep.js";
25
- import { EqualAssertionKind, IEqualAssertion } from "../../models/http-actions/steps/assertion/EqualAssertion.js";
26
- import { INotEqualAssertion, NotEqualAssertionKind } from "../../models/http-actions/steps/assertion/NotEqualAssertion.js";
27
- import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
28
- import { AssertionError } from "../../models/http-actions/AssertionError.js";
29
- import { GreaterThanAssertionKind, IGreaterThanAssertion } from "../../models/http-actions/steps/assertion/GreaterThanAssertion.js";
30
- import { ILessThanAssertion, LessThanAssertionKind } from "../../models/http-actions/steps/assertion/LessThanAssertion.js";
31
- import { IIncludesAssertion, IncludesAssertionKind } from "../../models/http-actions/steps/assertion/IncludesAssertion.js";
32
- import { INotIncludesAssertion, NotIncludesAssertionKind } from "../../models/http-actions/steps/assertion/NotIncludesAssertion.js";
33
- import { OkAssertionKind } from "../../models/http-actions/steps/assertion/OkAssertion.js";
34
- import { NotOkAssertionKind } from "../../models/http-actions/steps/assertion/NotOkAssertion.js";
35
- import { IToBeAssertion, ToBeAssertionKind, ToBeTypes } from '../../models/http-actions/steps/assertion/ToBeAssertion.js';
36
- import { INotToBeAssertion, NotToBeAssertionKind } from '../../models/http-actions/steps/assertion/NotToBeAssertion.js';
37
- import { IsEmptyAssertionKind } from '../../models/http-actions/steps/assertion/IsEmptyAssertion.js';
38
- import { IsNotEmptyAssertionKind } from '../../models/http-actions/steps/assertion/IsNotEmptyAssertion.js';
39
- import { ILengthOfAssertion, LengthOfAssertionKind } from '../../models/http-actions/steps/assertion/LengthOfAssertion.js';
40
-
41
- interface IStepValue {
42
- value: FlowValue;
43
- type?: FlowRequestDataEnum | FlowResponseDataEnum;
44
- bodyMime?: string;
45
- }
3
+ import { IErrorResponse } from "../../models/ErrorResponse.js";
4
+ import { AssertionResult, IHttpAssertion } from "../../models/http-flows/HttpAssertion.js";
5
+ import { IHttpStep } from "../../models/http-flows/HttpStep.js";
6
+ import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from "../../models/http-flows/HttpFlows.js";
7
+ import { IReadDataSourceStep, ReadDataSourceStepKind } from "../../models/http-flows/steps/data/ReadDataSourceStep.js";
8
+ import { IReadValueStep, ReadValueStepKind } from "../../models/http-flows/steps/data/ReadValueStep.js";
9
+ import { AsLowerCaseStepKind } from "../../models/http-flows/steps/transformation/AsLowerCaseStep.js";
10
+ import { AsUpperCaseStepKind } from "../../models/http-flows/steps/transformation/AsUpperCaseStep.js";
11
+ import { AsNumberStepKind } from "../../models/http-flows/steps/transformation/AsNumberStep.js";
12
+ import { RoundStepKind } from "../../models/http-flows/steps/transformation/RoundStep.js";
13
+ import { SubstringStepKind } from "../../models/http-flows/steps/transformation/SubstringStep.js";
14
+ import { TrimStepKind } from "../../models/http-flows/steps/transformation/TrimStep.js";
15
+ import { EqualAssertionKind, IEqualAssertion } from "../../models/http-flows/steps/assertion/EqualAssertion.js";
16
+ import { INotEqualAssertion, NotEqualAssertionKind } from "../../models/http-flows/steps/assertion/NotEqualAssertion.js";
17
+ import { AssertionError } from "../../models/http-flows/AssertionError.js";
18
+ import { GreaterThanAssertionKind, IGreaterThanAssertion } from "../../models/http-flows/steps/assertion/GreaterThanAssertion.js";
19
+ import { ILessThanAssertion, LessThanAssertionKind } from "../../models/http-flows/steps/assertion/LessThanAssertion.js";
20
+ import { IIncludesAssertion, IncludesAssertionKind } from "../../models/http-flows/steps/assertion/IncludesAssertion.js";
21
+ import { INotIncludesAssertion, NotIncludesAssertionKind } from "../../models/http-flows/steps/assertion/NotIncludesAssertion.js";
22
+ import { OkAssertionKind } from "../../models/http-flows/steps/assertion/OkAssertion.js";
23
+ import { NotOkAssertionKind } from "../../models/http-flows/steps/assertion/NotOkAssertion.js";
24
+ import { HttpFlows, IStepValue } from './HttpFlows.js';
46
25
 
47
26
  /**
48
27
  * A class that perform assertions that have been defined on an HTTP request.
49
28
  */
50
- export class HttpAssertionRunner {
29
+ export class HttpAssertionRunner extends HttpFlows {
51
30
  report: AssertionResult[] = [];
52
31
 
53
32
  /**
@@ -71,6 +50,10 @@ export class HttpAssertionRunner {
71
50
  protected async runAssertion(request: ISentRequest, response: IResponse | IErrorResponse, assertion: IHttpAssertion): Promise<void> {
72
51
  const { steps } = assertion;
73
52
 
53
+ if (!Array.isArray(steps) || !steps.length) {
54
+ return;
55
+ }
56
+
74
57
  // this keeps a value from the last step to be passed to the next step.
75
58
  let lastResult: IStepValue = {
76
59
  value: undefined,
@@ -78,7 +61,7 @@ export class HttpAssertionRunner {
78
61
  let error: AssertionError | undefined;
79
62
  for (const step of steps) {
80
63
  try {
81
- lastResult = await this.runStep(request, response, step, lastResult);
64
+ lastResult = await this.runStep(request, step, lastResult, response);
82
65
  } catch (e) {
83
66
  const typed = e as AssertionError;
84
67
  if (typed.name === 'AssertionError') {
@@ -172,369 +155,4 @@ export class HttpAssertionRunner {
172
155
  const { path } = step;
173
156
  return path || '';
174
157
  }
175
-
176
- protected async runStep(request: ISentRequest, response: IResponse | IErrorResponse, step: IHttpStep, input: IStepValue): Promise<IStepValue> {
177
- switch (step.kind) {
178
- // data reading
179
- case ReadDataSourceStepKind: return this.readDataSource(request, response, step);
180
- case ReadValueStepKind: return this.readValue(input, step as IReadValueStep);
181
- // transformations
182
- case AsLowerCaseStepKind: return this.toLowerCase(input);
183
- case AsUpperCaseStepKind: return this.toUpperCase(input);
184
- case AsNumberStepKind: return this.asNumber(input);
185
- case RoundStepKind: return this.round(input, step as IRoundStep);
186
- case TrimStepKind: return this.trim(input);
187
- case SubstringStepKind: return this.substring(input, step as ISubstringStep);
188
- // assertions
189
- case EqualAssertionKind: return this.assertEqual(input, step as IEqualAssertion);
190
- case NotEqualAssertionKind: return this.assertNotEqual(input, step as INotEqualAssertion);
191
- case GreaterThanAssertionKind: return this.assertGreaterThan(input, step as IGreaterThanAssertion);
192
- case LessThanAssertionKind: return this.assertLessThan(input, step as ILessThanAssertion);
193
- case IncludesAssertionKind: return this.assertIncludes(input, step as IIncludesAssertion);
194
- case NotIncludesAssertionKind: return this.assertNotIncludes(input, step as INotIncludesAssertion);
195
- case OkAssertionKind: return this.assertOk(input);
196
- case NotOkAssertionKind: return this.assertNotOk(input);
197
- case ToBeAssertionKind: return this.toBe(input, step as IToBeAssertion);
198
- case NotToBeAssertionKind: return this.notToBe(input, step as INotToBeAssertion);
199
- case IsEmptyAssertionKind: return this.isEmpty(input);
200
- case IsNotEmptyAssertionKind: return this.isNotEmpty(input);
201
- case LengthOfAssertionKind: return this.lengthOf(input, step as ILengthOfAssertion);
202
- default: return { value: undefined };
203
- }
204
- }
205
-
206
- /**
207
- * Produces the data source.
208
- */
209
- protected async readDataSource(request: ISentRequest, response: IResponse | IErrorResponse, step: IReadDataSourceStep): Promise<IStepValue> {
210
- const instance = new ReadDataSourceStep(step);
211
- if (instance.enabled === false || !instance.checkValidity()) {
212
- return { value: undefined };
213
- }
214
- const { source, data } = step;
215
- if (source === FlowSourceEnum.request) {
216
- if (data === FlowRequestDataEnum.url) {
217
- return {
218
- value: request.url,
219
- type: data,
220
- };
221
- }
222
- if (data === FlowRequestDataEnum.headers) {
223
- return {
224
- value: request.headers,
225
- type: data,
226
- };
227
- }
228
- if (data === FlowRequestDataEnum.method) {
229
- return {
230
- value: request.method,
231
- type: data,
232
- };
233
- }
234
- if (data === FlowRequestDataEnum.body) {
235
- const instance = new HttpRequest(request);
236
- const value = await this.processBody(instance);
237
- return {
238
- ...value,
239
- type: data,
240
- };
241
- }
242
- }
243
- if (source === FlowSourceEnum.response) {
244
- if (data === FlowResponseDataEnum.url) {
245
- return {
246
- value: request.url,
247
- type: data,
248
- };
249
- }
250
- if (data === FlowResponseDataEnum.headers) {
251
- return {
252
- value: response.headers,
253
- type: data,
254
- };
255
- }
256
- if (data === FlowResponseDataEnum.status) {
257
- return {
258
- value: response.status,
259
- type: data,
260
- };
261
- }
262
- if (data === FlowResponseDataEnum.statusText) {
263
- return {
264
- value: response.statusText,
265
- type: data,
266
- };
267
- }
268
- if (data === FlowResponseDataEnum.body) {
269
- let instance: ErrorResponse | HttpResponse;
270
- if (ErrorResponse.isErrorResponse(response)) {
271
- instance = new ErrorResponse(response as IErrorResponse);
272
- } else {
273
- instance = new HttpResponse(response);
274
- }
275
- const value = await this.processBody(instance);
276
- return {
277
- ...value,
278
- type: data,
279
- };
280
- }
281
- }
282
- return { value: undefined };
283
- }
284
-
285
- protected async processBody(input: HttpRequest | HttpResponse | ErrorResponse): Promise<IStepValue> {
286
- const { headers } = input;
287
- if (!headers) {
288
- return { value: undefined };
289
- }
290
- const body = await input.readPayloadAsString();
291
- if (!body) {
292
- return { value: undefined };
293
- }
294
-
295
- const parser = new Headers(headers);
296
- const mime = parser.get('content-type');
297
- if (!mime) {
298
- return { value: undefined };
299
- }
300
- return {
301
- value: body,
302
- bodyMime: mime,
303
- }
304
- }
305
-
306
- /**
307
- * Produces the value from the current input.
308
- */
309
- protected async readValue(input: IStepValue, step: IReadValueStep): Promise<IStepValue> {
310
- const instance = new ReadValueStep(step);
311
- if (instance.enabled === false || !instance.checkValidity() || input.value === undefined || input.value === null) {
312
- return { value: undefined };
313
- }
314
-
315
- const { path } = step;
316
- const { type, value } = input;
317
- const args = path ? path.split('.') : [];
318
- if (type === FlowRequestDataEnum.url || type === FlowResponseDataEnum.url) {
319
- if (!value) {
320
- return { value: undefined };
321
- }
322
- const v = String(input.value);
323
- return {
324
- value: DataUtils.getDataUrl(v, args),
325
- };
326
- }
327
- if (type === FlowRequestDataEnum.headers || type === FlowResponseDataEnum.headers) {
328
- if (!value) {
329
- return { value: undefined };
330
- }
331
- const v = String(input.value);
332
- return {
333
- value: DataUtils.getDataHeaders(v, args),
334
- }
335
- }
336
- if (type === FlowRequestDataEnum.body || type === FlowResponseDataEnum.body) {
337
- if (!input.bodyMime || !path) {
338
- return { value: undefined };
339
- }
340
- let reader: DataReader | undefined;
341
- if (input.bodyMime.includes('json')) {
342
- reader = new JmespathReader();
343
- } else if (input.bodyMime.includes('xml')) {
344
- reader = new XmlReader();
345
- } else if (input.bodyMime.includes('x-www-form-urlencoded')) {
346
- reader = new UrlEncodedReader();
347
- }
348
- if (!reader) {
349
- return { value: undefined };
350
- }
351
- await reader.writePayload(String(value));
352
- const readValue = await reader.getValue(path);
353
- return {
354
- value: readValue,
355
- }
356
- }
357
- if (type === FlowResponseDataEnum.status) {
358
- const v = Number(input.value);
359
- if (Number.isNaN(v)) {
360
- return { value: undefined };
361
- }
362
- return {
363
- value: v,
364
- }
365
- }
366
-
367
- if (type === FlowResponseDataEnum.statusText) {
368
- if (!value) {
369
- return { value: undefined };
370
- }
371
- return {
372
- value,
373
- }
374
- }
375
- return { value: undefined };
376
- }
377
-
378
- protected async toLowerCase(input: IStepValue): Promise<IStepValue> {
379
- if (input.value === null || input.value === undefined) {
380
- return { value: undefined };
381
- }
382
- const value = String(input.value);
383
- return { value: value.toLowerCase() };
384
- }
385
-
386
- protected async toUpperCase(input: IStepValue): Promise<IStepValue> {
387
- if (input.value === null || input.value === undefined) {
388
- return { value: undefined };
389
- }
390
- const value = String(input.value);
391
- return { value: value.toUpperCase() };
392
- }
393
-
394
- protected async asNumber(input: IStepValue): Promise<IStepValue> {
395
- if (input.value === null || input.value === undefined) {
396
- return { value: undefined };
397
- }
398
- const value = String(input.value);
399
- const parsed = Number(value);
400
- if (Number.isNaN(parsed)) {
401
- return { value: undefined };
402
- }
403
- return { value: parsed };
404
- }
405
-
406
- protected async round(input: IStepValue, step: IRoundStep): Promise<IStepValue> {
407
- if (input.value === null || input.value === undefined) {
408
- return { value: undefined };
409
- }
410
- const value = String(input.value);
411
- const parsed = typeof input.value === 'number' ? input.value : Number(value);
412
- if (Number.isNaN(parsed)) {
413
- return { value: undefined };
414
- }
415
- return { value: parsed.toFixed(step.precision) };
416
- }
417
-
418
- protected async trim(input: IStepValue): Promise<IStepValue> {
419
- if (input.value === null || input.value === undefined) {
420
- return { value: undefined };
421
- }
422
- const value = String(input.value);
423
- return { ...input, value: value.trim() };
424
- }
425
-
426
- protected async substring(input: IStepValue, step: ISubstringStep): Promise<IStepValue> {
427
- if (input.value === null || input.value === undefined) {
428
- return { value: undefined };
429
- }
430
- if (typeof step.start !== 'number') {
431
- return input;
432
- }
433
- const value = String(input.value);
434
- return { ...input, value: value.substring(step.start, step.end) };
435
- }
436
-
437
- protected async assertEqual(input: IStepValue, step: IEqualAssertion): Promise<IStepValue> {
438
- const { value } = input;
439
- if (step.strict) {
440
- const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
441
- assert.strictEqual(value, comparator);
442
- } else {
443
- assert.equal(String(value), step.value);
444
- }
445
- return input;
446
- }
447
-
448
- protected async assertNotEqual(input: IStepValue, step: INotEqualAssertion): Promise<IStepValue> {
449
- const { value } = input;
450
- if (step.strict) {
451
- const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
452
- assert.notStrictEqual(value, comparator);
453
- } else {
454
- assert.notEqual(value, step.value);
455
- }
456
- return input;
457
- }
458
-
459
- protected async assertGreaterThan(input: IStepValue, step: IGreaterThanAssertion): Promise<IStepValue> {
460
- assert.typeOf(input.value, 'number');
461
- const value = input.value as number;
462
- if (step.equal) {
463
- assert.isAtLeast(value as number, step.value as number);
464
- } else {
465
- assert.isAbove(value as number, step.value as number);
466
- }
467
- return input;
468
- }
469
-
470
- protected async assertLessThan(input: IStepValue, step: ILessThanAssertion): Promise<IStepValue> {
471
- assert.typeOf(input.value, 'number');
472
- const value = input.value as number;
473
- if (step.equal) {
474
- assert.isAtMost(value, step.value as number);
475
- } else {
476
- assert.isBelow(value, step.value as number);
477
- }
478
- return input;
479
- }
480
-
481
- protected async assertIncludes(input: IStepValue, step: IIncludesAssertion): Promise<IStepValue> {
482
- if (this.isPrimitive(input.value)) {
483
- assert.include(String(input.value), String(step.value));
484
- } else {
485
- assert.include(JSON.stringify(input.value), String(step.value));
486
- }
487
- return input;
488
- }
489
-
490
- protected async assertNotIncludes(input: IStepValue, step: INotIncludesAssertion): Promise<IStepValue> {
491
- if (this.isPrimitive(input.value)) {
492
- assert.notInclude(String(input.value), String(step.value));
493
- } else {
494
- assert.notInclude(JSON.stringify(input.value), String(step.value));
495
- }
496
- return input;
497
- }
498
-
499
- protected async assertOk(input: IStepValue): Promise<IStepValue> {
500
- assert.ok(input.value);
501
- return input;
502
- }
503
-
504
- protected async assertNotOk(input: IStepValue): Promise<IStepValue> {
505
- assert.notOk(input.value);
506
- return input;
507
- }
508
-
509
- protected async toBe(input: IStepValue, step: IToBeAssertion): Promise<IStepValue> {
510
- assert.typeOf(input.value, step.value as string);
511
- return input;
512
- }
513
-
514
- protected async notToBe(input: IStepValue, step: INotToBeAssertion): Promise<IStepValue> {
515
- if (Array.isArray(input.value) && step.value === ToBeTypes.object) {
516
- assert(false, 'expected [Array] to be an object');
517
- }
518
- assert.notTypeOf(input.value, step.value as string);
519
- return input;
520
- }
521
-
522
- protected async isEmpty(input: IStepValue): Promise<IStepValue> {
523
- assert.isEmpty(input.value);
524
- return input;
525
- }
526
-
527
- protected async isNotEmpty(input: IStepValue): Promise<IStepValue> {
528
- assert.isNotEmpty(input.value);
529
- return input;
530
- }
531
-
532
- protected async lengthOf(input: IStepValue, step: ILengthOfAssertion): Promise<IStepValue> {
533
- assert.lengthOf(input.value as unknown[], step.value as number);
534
- return input;
535
- }
536
-
537
- protected isPrimitive(value: unknown): boolean {
538
- return (typeof value !== 'object' && typeof value !== 'function') || value === null;
539
- }
540
158
  }